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

This commit is contained in:
Inovea Conseil 2019-11-29 18:01:28 +01:00
commit cfffcab950
839 changed files with 81671 additions and 198777 deletions

23
.gitignore vendored
View File

@ -1,5 +1,7 @@
htdocs/conf/conf.php
htdocs/conf/conf.php.old
htdocs/conf/conf.php.sav
htdocs/conf/conf.php.back
documents/
custom2/
test/report/
@ -8,22 +10,33 @@ default.properties
.settings/
.buildpath
.gitmodules
dolibarr_install.log
upgrade.log
doxygen_warnings.log
/.project
/.pydevproject
/.vscode
.DS_Store
.idea
*.iml
Thumbs.db
/dolibarr_genesis.mp4
# Log files
dolibarr_install.log
upgrade.log
doxygen_warnings.log
# Vagrant generated files
.vagrant
# Composer installed repositories
/htdocs/includes/**/.git
# Composer autoloader and unwanted files
composer.phar
htdocs/includes/autoload.php
htdocs/includes/bin/
htdocs/includes/composer/
/.pydevproject
/dolibarr_genesis.mp4
htdocs/includes/doctrine/
htdocs/includes/jakub-onderka/
htdocs/includes/phpdocumentor/
htdocs/includes/phpspec/
htdocs/includes/phpunit/
htdocs/includes/sebastian/
htdocs/includes/squizlabs/
htdocs/includes/symfony/
htdocs/includes/webmozart/

203
ChangeLog
View File

@ -6,9 +6,184 @@ English Dolibarr ChangeLog
***** ChangeLog for 11.0.0 compared to 10.0.0 *****
For Users:
NEW: Module BOM is now stable (Module MO - Manufacturing Order is still in development).
NEW: A nicer dashboard for opened elements on Home page.
NEW: Add task widget and add task progress bar
NEW: Accountancy - Can add specific widget in this accountancy area.
NEW: Accountancy - Add export model LDCompta V9 & higher
NEW: Accountancy - Add permission on export, delete operations in ledger
NEW: Add 2 hidden options to set the default sorting (sort and order) on document page.
NEW: add ability to edit price without tax before adding a line of a predefined product.
NEW: Add a tab to setup "Opening hours" of company (information only).
NEW: Add attendee to ical export + cleanup.
NEW: Add bank data of users into the expense report exports.
NEW: add clone customers prices in clone product or service.
NEW: Add column of module source and POS terminal in the invoice list.
NEW: Add column last modification date into the table of targets for emailing.
NEW: Add column VAT rate in product list
NEW: add constant DISPATCH_FORCE_QTY_INPUT
NEW: Add constant MAIN_DISABLE_GLOBAL_WORKBOARD to disable workboard in home page
NEW: add country code in import product model
NEW: Add 'Direct Cash Payment' button in TakePOS
NEW: Add odt support to supplier orders
NEW: Add experimental SumUp payment to TakePOS (need to set a hidden constant)
NEW: Add feature to search a string into website containers
NEW: Add GET and POST /supplierinvoices/payments REST API endpoints.
NEW: Show progress bar for declared progression of tasks.
NEW: Add hidden option to update supplier buying price during receptions.
NEW: Add hidden option PROPOSAL_SHOW_INVOICED_AMOUNT (not reliable if one invoice is done on several order or several proposal)
NEW: Add hidden option SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT for add possibility to update supplier buying price in the reception on a supplier order
NEW: Add hidden option THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER to copy extrafields from third party to order.
NEW: Add hidden options to send by email even for object with draft status.
NEW: Add last change date in page "Other setup". Can sort page on name/date.
NEW: Add link to export targets of an emailings into a CSV file.
NEW: Add link to the public interface on the ticket card.
NEW: Add location into event tooltip. Use full day for fullday events
NEW: add MAIN_LANGUAGES_ALLOWED constant to limit languages displayed.
NEW: add MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS constant.
NEW: add mass actions in shipment list.
NEW: add minimum stock filter in load warehoues for product form.
NEW: add name_alias in fields to search all
NEW: add new rule fetchidfromcodeandlabel for categories import
NEW: add office phone for salespresentatives
NEW: add office phone & job on user tooltips
NEW: Add option MAIN_PDF_FORCE_FONT_SIZE
NEW: Add option MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS
NEW: Add option multiselect for developers on the selector of language.
NEW: Add option WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL
NEW: Add pagination on list of object of a category
NEW: add parent category id or label in import category module
NEW: add parent id or ref column in warehouse import
NEW: Can set the Address/Contact by default on third parties.
NEW: Add search into template
NEW: Add shipment widget
NEW: add socialnetworks dictionary
NEW: Add statistics on product into contracts
NEW: Add status of warehouse in tooltip of a warehouse.
NEW: add supplier's product list
NEW: add units fields in buying price tab of product card
NEW: Add units in select products lines
NEW: Add upload document on account statement
NEW: Add widgets for BOMs and MOs
NEW: Amount invoiced column in proposal list
NEW: Ask the new label and new dates in confirm popup when cloning tax
NEW: auto set closing date and user on invoice
NEW: Avoid wrap between picto and text on getNomUrl
NEW: Balance Stripe connect account for supplier
NEW: Bank Add an option for colorize background color of debit or credit movement
NEW: Beautify the select box of warehouses
NEW: birthday widget for member
NEW: Widgets uses fiscal year
NEW: Can change supplier when cloning a Purchase Order
NEW: can choose lines while creating order from origin
NEW: Can crop/resize image attached on a bank record
NEW: Can defined a position of numbering submodules for thirdparties
NEW: Can edit date or RUM mandate.
NEW: Can edit link to the translation page in website module
NEW: Can edit the price of predefined product during adding in documents
NEW: Can enter price tax incl on vendor proposal and purchase orders
NEW: Can filter on description on bank account transaction lists.
NEW: Can filter on label on invoice in accounting vendor binding pages
NEW: Can load multilang translation in same step than fetch_lines
NEW: Can restrict access using DAV module to some host IPs only
NEW: Can restrict API usage to some IP only
NEW: Can select website templates from available default templates with a preview.
NEW: Can set a filter on object linked in modulebuilder.
NEW: Can set a squarred icon on your company setup
NEW: can specify hour start end for selectDate and step for minutes
NEW: Categories/Tags are also available on warehouses
NEW: Check if a resource is in use in an event
NEW: Code for extrafields uses the new array $extrafields->attributes
NEW: Compute column value from others columns in import module
NEW: Copy linked categories on product clone process.
NEW: Default for Stripe is STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION
NEW: Digitaria model for numbering accountancy thirdparty
NEW: Display membership in takepos if member linked to the thirdparty
NEW: Display supplier in objectline if defined
NEW: Add default duration of subscriptions on members type
NEW: Email template for Takepos (to send invoice)
NEW: Expense request and holiday validator fields
NEW: Export ledger table in Charlemagne format
NEW: Export livre Charlemagne
NEW: Extend option ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC for all virtual product stats (renamed into PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)
NEW: FCKeditor setup for tickets
NEW: GeoIP v2 support is natively provided -> So IPv6 is supported
NEW: List by closing date on order list and proposal list
NEW: Look and feel v11: Some setup pages are by default direclty in edit mode.
NEW: Management of retained warranty on situation invoices
NEW: Mass email action on invoice list use billing contact if exists
NEW: more living colors for charts and option for "color bind" people
NEW: Supports multiple payments in a TakePOS sale
NEW: multiselect with checkbox in categories/tags search for product list
NEW: Option to allow to create members from third-party
NEW: Platform compliance with Stripe Connect
NEW: print / send email form in TakePOS
NEW: Public holidays are now in a dictionary table (no more hard coded per country)
NEW: Better performance by reducing the $companystatic calls on some pages.
NEW: Replace the "info" tab on contract with the more complete "agenda" tab.
NEW: Save user of last modification in donation record.
NEW: Show html combo list instead input text for extrafields typed as list.
NEW: Show POS application and the terminal used on invoice card.
NEW: Add categories/tags for stocks.
NEW: Support Net Measure in product's card.php
NEW: Extrafields separator can be collapsed or not
NEW: Extrafields support on Leave requests.
NEW: Extrafields support on Salaries.
NEW: Extrafields support in Product supplier prices.
NEW: Add extrafields for warehouses
NEW: Add extrafields in export of expense report (and holiday)
NEW: The integrity checker now show also the expected size of files.
NEW: The order method in purchase order is now mandatory when recording an order.
NEW: update / delete stripe account for supplier
NEW: Use the gender of member for picto in member lists.
NEW: Use the squarre logo as favicon of pages
NEW: VAT list - Add date start & date end in filters
NEW: widget box for supplier orders awaiting reception
NEW: Update translations
NEW: #4301
For Developers:
For Developers or integrators:
NEW: Add a manifest.json.php file for web app.
NEW: Removed deprecated code that create linked object from ->origin
NEW: experimental zapier for dolibarr
NEW: Accountancy - Add hook bookkeepinglist on general ledger
NEW: Can update product type with the update method.
NEW: add API shipment mode dictionnary
NEW: Add API to get Country by code and iso
NEW: Add API to get objects by ref, ref_ext, ...
NEW: Add anonymous telemetry
NEW: Add a category to a contact in API
NEW: Add fk projet on stock movement
NEW: Add hidden option to set fields for the quick search on products.
NEW: add hook on commongeneratedocument
NEW: Add hook on fileupload.class.php to enable modules to override…
NEW: Add hooks on index pages
NEW: adding 'formObjectOptions' hooks loading at card.php of adherents module
NEW: Add method getStructuredData for website
NEW: Add payments GET and POST REST API endpoints for supplierinvoices.
NEW: Add POST /bankaccounts/transfer REST API endpoint.
NEW: add "printBucktrackInfo" hook, an external module can add info
NEW: Add trigger DIRECT_DEBIT_ORDER_CREATE on widthdraw is missing
NEW: API to post documents for "product" and Delete document
NEW: add new function "setEntity()" and better compatibility with Multicompany
NEW: Can add a button "Create" after combo of object with modulebuilder.
NEW: contacts type dictionnary in api_setup.class.php
NEW: Look and feel v11: Introduce CSS "trforbreak"
NEW: list of measuring units API
NEW: get social networks dictionary by API
NEW: Get thirdparty's salesrepresentatives by API
NEW: get user connected informations in REST API
NEW: mode for list thirdparty API (add easy filter for supplier only)
NEW: purchase_prices API
NEW: Provides more complete demo data
NEW: Module builder can generate CSS of JS file.
NEW: Use a dedicated css for the pencil to edit a field.
NEW: multilangs in fetch_lines
NEW: Add more complete info for triggers actioncom
NEW: add multicurrency rate at currency list API
NEW: Update jquery library to 3.4.1
NEW: Upgrade ACE editor to v1.4.6
WARNING:
@ -29,6 +204,32 @@ Following changes may create regressions for some external modules, but were nec
* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'.
* All properties 'type_libelle' were renamed into 'type_label'.
* Renamed property of thirdparty "statut_commercial" into "status_prospect_label"
* The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core.
***** ChangeLog for 10.0.4 compared to 10.0.3 *****
FIX: The pdf templates were using the large logo making PDF too large (and edition of proposal, order, invoice VERY slow)
FIX: #12258
FIX: #12319 Restore feature ACCOUNTANCY_AUTOFILL_ACCOUNT_WITH_GENERIC.
FIX: #12356
FIX: #12372
FIX: #12385
FIX: Advisory ID: usd20190053
FIX: Advisory ID: usd20190067
FIX: Avoid fatal error when creating thumb from PDF
FIX: compatibility with Multicompany
FIX: display job of contact list
FIX: Extrafields missing in export of expense report
FIX: Hook getAccessForbiddenMessage was missing parameters
FIX: limit 20 prevent to see all products/services
FIX: Search on leave request ref
FIX: security check. A user can see holiday with link without permissions
FIX: Set unpaid of expense report
FIX: shipping extrafields line
FIX: the SELECT examine more than MAX_JOIN_SIZE rows #12305
FIX: triggers: directories read with opendir() never closed
FIX: we need to be able to recalculate tva only if invoice not in accountancy
FIX: wrong invoice id for fetchObjetctLinked
***** ChangeLog for 10.0.3 compared to 10.0.2 *****
IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card.

1
build/.gitignore vendored
View File

@ -5,6 +5,5 @@
/dolibarr-*.tgz
/dolibarr-*.rpm
/dolibarr-*.zip
/dolibarr-*.tgz
/*.exe
/html

29
build/exakat/README.md Normal file
View File

@ -0,0 +1,29 @@
== Install exakat ==
mkdir exakat
cd exakat
curl -o exakat.phar http://dist.exakat.io/index.php?file=latest
curl -o apache-tinkerpop-gremlin-server-3.3.5-bin.zip http://dist.exakat.io/apache-tinkerpop-gremlin-server-3.3.5-bin.zip
unzip apache-tinkerpop-gremlin-server-3.3.5-bin.zip
mv apache-tinkerpop-gremlin-server-3.3.5 tinkergraph
rm -rf apache-tinkerpop-gremlin-server-3.3.5-bin.zip
cd tinkergraph ./bin/gremlin-server.sh -i org.apache.tinkerpop neo4j-gremlin 3.3.5
cd ..
php exakat.phar version
php exakat.phar doctor
== Init project ==
php
Edit config.ini file to exclude some dirs:
ignore_dirs[] = "/htdocs/includes";
ignore_dirs[] = "/scripts";
ignore_dirs[] = "/build";
ignore_dirs[] = "/dev";
ignore_dirs[] = "/documents";
== Analyze project ==
php

View File

@ -461,15 +461,18 @@ if ($nboftargetok) {
print "Clean $BUILDROOT\n";
$ret=`rm -f $BUILDROOT/$PROJECT/.buildpath`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.cache`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.editorconfig`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.codeclimate`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.externalToolBuilders`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.git*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.project`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.pydevproject`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.settings`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.scrutinizer.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.stickler.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.travis.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.tx`;
$ret=`rm -f $BUILDROOT/$PROJECT/build.xml`;
$ret=`rm -f $BUILDROOT/$PROJECT/phpstan.neon`;
$ret=`rm -f $BUILDROOT/$PROJECT/pom.xml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/build/html`;

View File

@ -24,10 +24,10 @@
"vendor-dir" : "htdocs/includes"
},
"require" : {
"php" : ">=5.3.0",
"php" : ">=5.5.0",
"ext-curl" : "*",
"ckeditor/ckeditor" : "4.12.1",
"mike42/escpos-php" : "1.2.1",
"mike42/escpos-php" : "2.2",
"mobiledetect/mobiledetectlib" : "2.8.33",
"phpoffice/phpexcel" : "1.8.1",
"restler/framework" : "3.0.0-RC6",
@ -48,13 +48,12 @@
"ext-mssql" : "To use with MSSQL (experimental)",
"ext-pdo_sqlite" : "To use with SQLite (experimental)",
"ext-gd" : "Image manipulation (Required but maybe built-in PHP)",
"ext-imagick" : "Image manipulation (TCPDF)",
"ext-imagick" : "Generation of thumbs from PDF",
"ext-mcrypt" : "(Required but maybe built-in PHP)",
"ext-openssl" : "Secure connections (Emails, SOAP\u2026)",
"ext-mbstring" : "Handle non UTF-8 databases",
"ext-mbstring" : "Handle non UTF-8 characters",
"ext-soap" : "Native SOAP",
"ext-zip" : "ODT and Excel support",
"ext-xml" : "Excel support",
"firephp/firephp-core" : "Logging to Firebug console support"
"ext-zip" : "ODT, Excel and file compression support",
"ext-xml" : "Excel support"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3
htdocs/.gitignore vendored
View File

@ -16,9 +16,6 @@
/teclib*
/test.php
/ultimatepdf*
/lead
/dolimed*
/allscreens*
/ecommerce/
/cabinetmed*
/webmail*

View File

@ -24,12 +24,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy","salaries"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries"));
$mesg = '';
$action = GETPOST('action', 'aZ09');
@ -37,7 +37,7 @@ $cancel = GETPOST('cancel', 'alpha');
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
$massaction = GETPOST('massaction', 'aZ09');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'accountingaccountlist'; // To manage different context of search
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search
$search_account = GETPOST('search_account', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
@ -58,10 +58,10 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield = "aa.account_number";
if (! $sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "aa.account_number";
if (!$sortorder) $sortorder = "ASC";
$arrayfields=array(
$arrayfields = array(
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
@ -78,27 +78,27 @@ $accounting = new AccountingAccount($db);
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha')) { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if (! empty($cancel)) $action = '';
if (!empty($cancel)) $action = '';
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_label = "";
$search_accountparent = "";
$search_pcgtype = "";
$search_pcgsubtype = "";
$search_array_options=array();
$search_array_options = array();
}
if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax)))
@ -108,8 +108,8 @@ if (empty($reshook))
if ($chartofaccounts > 0)
{
// 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.=' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
$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;
$resql = $db->query($sql);
if ($resql)
{
@ -132,7 +132,7 @@ if (empty($reshook))
{
$offsetforchartofaccount += $reg[1];
}
$offsetforchartofaccount+=($conf->entity * 100000000);
$offsetforchartofaccount += ($conf->entity * 100000000);
$result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount);
@ -146,7 +146,7 @@ if (empty($reshook))
}
}
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
@ -179,12 +179,12 @@ if (empty($reshook))
* View
*/
$form=new Form($db);
$form = new Form($db);
llxHeader('', $langs->trans("ListAccounts"));
if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
@ -192,11 +192,11 @@ $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, ";
$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 .= " 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;
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 .= " 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;
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;
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;
//print $sql;
if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account);
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
@ -220,24 +220,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$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);
if ($resql)
{
$num = $db->num_rows($resql);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_account) $param.= '&search_account='.urlencode($search_account);
if ($search_label) $param.= '&search_label='.urlencode($search_label);
if ($search_accountparent) $param.= '&search_accountparent='.urlencode($search_accountparent);
if ($search_pcgtype) $param.= '&search_pcgtype='.urlencode($search_pcgtype);
if ($search_pcgsubtype) $param.= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
if ($optioncss != '') $param.='&optioncss='.$optioncss;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($search_account) $param .= '&search_account='.urlencode($search_account);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_accountparent) $param .= '&search_accountparent='.urlencode($search_accountparent);
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
if ($optioncss != '') $param .= '&optioncss='.$optioncss;
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print '<!-- Add javascript to update a flag when we select "Change plan" -->
<script type="text/javascript">
@ -256,7 +256,7 @@ if ($resql)
</script>';
}
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.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -266,17 +266,17 @@ if ($resql)
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton.= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
$newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
// Box to select active chart of account
print $langs->trans("Selectchartofaccounts") . " : ";
print $langs->trans("Selectchartofaccounts")." : ";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON a.fk_country = c.rowid AND c.active = 1";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1";
$sql .= " WHERE a.active = 1";
dol_syslog('accountancy/admin/account.php $sql='.$sql);
print $sql;
@ -287,9 +287,9 @@ if ($resql)
while ($i < $numbis) {
$obj = $db->fetch_object($resqlchart);
print '<option value="' . $obj->rowid . '"';
print '<option value="'.$obj->rowid.'"';
print ($pcgver == $obj->rowid) ? ' selected' : '';
print '>' . $obj->pcg_version . ' - ' . $obj->label . ' - (' . $obj->country_code . ')</option>';
print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>';
$i++;
}
@ -303,43 +303,43 @@ if ($resql)
print '<br>';
print '<br>';
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$moreforfilter = '';
$massactionbutton = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Line for search fields
print '<tr class="liste_titre_filter">';
if (! empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
if (! empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
if (! empty($arrayfields['aa.account_parent']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_accountparent" value="' . $search_accountparent . '"></td>';
if (! empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="' . $search_pcgtype . '"></td>';
if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
if (! empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="'.$search_account.'"></td>';
if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
if (!empty($arrayfields['aa.account_parent']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_accountparent" value="'.$search_accountparent.'"></td>';
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="'.$search_pcgsubtype.'"></td>';
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
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 '</td>';
print '</tr>';
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.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $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 (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']);
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.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.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $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 (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']);
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 "</tr>\n";
$accountstatic = new AccountingAccount($db);
$accountparent = new AccountingAccount($db);
$i=0;
$i = 0;
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
@ -351,27 +351,27 @@ if ($resql)
print '<tr class="oddeven">';
// Account number
if (! empty($arrayfields['aa.account_number']['checked']))
if (!empty($arrayfields['aa.account_number']['checked']))
{
print "<td>";
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1);
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Account label
if (! empty($arrayfields['aa.label']['checked']))
if (!empty($arrayfields['aa.label']['checked']))
{
print "<td>";
print $obj->label;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Account parent
if (! empty($arrayfields['aa.account_parent']['checked']))
if (!empty($arrayfields['aa.account_parent']['checked']))
{
if (! empty($obj->account_parent))
if (!empty($obj->account_parent))
{
$accountparent->id = $obj->rowid2;
$accountparent->label = $obj->label2;
@ -380,63 +380,63 @@ if ($resql)
print "<td>";
print $accountparent->getNomUrl(1);
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
else
{
print '<td>&nbsp;</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
}
// Chart of accounts type
if (! empty($arrayfields['aa.pcg_type']['checked']))
if (!empty($arrayfields['aa.pcg_type']['checked']))
{
print "<td>";
print $obj->pcg_type;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Chart of accounts subtype
if (! empty($arrayfields['aa.pcg_subtype']['checked']))
if (!empty($arrayfields['aa.pcg_subtype']['checked']))
{
print "<td>";
print $obj->pcg_subtype;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Activated or not
if (! empty($arrayfields['aa.active']['checked']))
if (!empty($arrayfields['aa.active']['checked']))
{
print '<td>';
if (empty($obj->active)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Action
print '<td class="center">';
if ($user->rights->accounting->chartofaccount) {
print '<a href="./card.php?action=update&id=' . $obj->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">';
print '<a href="./card.php?action=update&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="./card.php?action=delete&id=' . $obj->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id). '">';
print '<a href="./card.php?action=delete&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">';
print img_delete();
print '</a>';
}
print '</td>' . "\n";
if (! $i) $totalarray['nbfield']++;
print '</td>'."\n";
if (!$i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;

View File

@ -24,15 +24,15 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancysystem.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$error = 0;
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy"));
$langs->loadLangs(array("bills", "accountancy"));
$mesg = '';
$action = GETPOST('action', 'aZ09');
@ -55,24 +55,24 @@ $object = new AccountingAccount($db);
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);
exit;
}
if ($action == 'add' && $user->rights->accounting->chartofaccount)
{
if (! $cancel) {
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
if (!$cancel) {
$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
$result = $db->query($sql);
$obj = $db->fetch_object($result);
// Clean code
// To manage zero or not at the end of the accounting account
if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{
$account_number = GETPOST('account_number', 'string');
}
@ -116,28 +116,28 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
setEventMessages($object->error, $object->errors, 'errors');
$action = "create";
}
if (! $error)
if (!$error)
{
setEventMessages("RecordCreatedSuccessfully", null, 'mesgs');
$urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php', 1);
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
header("Location: ".$urltogo);
exit;
}
}
} elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
if (! $cancel) {
if (!$cancel) {
$result = $object->fetch($id);
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
$result2 = $db->query($sql);
$obj = $db->fetch_object($result2);
// Clean code
// To manage zero or not at the end of the accounting account
if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{
$account_number = GETPOST('account_number', 'string');
}
@ -166,21 +166,21 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$result = $object->update($user);
if ($result > 0) {
$urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: " . $urltogo);
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: ".$urltogo);
exit();
} else {
$mesg = $object->error;
}
} else {
$urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: " . $urltogo);
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: ".$urltogo);
exit();
}
} elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) {
$result = $object->fetch($id);
if (! empty($object->id)) {
if (!empty($object->id)) {
$result = $object->delete($user);
if ($result > 0) {
@ -205,7 +205,7 @@ $formaccounting = new FormAccounting($db);
$accountsystem = new AccountancySystem($db);
$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card');
$title = $langs->trans('AccountAccounting')." - ".$langs->trans('Card');
$helpurl = '';
llxheader('', $title, $helpurl);
@ -214,8 +214,8 @@ llxheader('', $title, $helpurl);
if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAccountingAccount'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
@ -223,41 +223,41 @@ if ($action == 'create') {
print '<table class="border centpercent">';
// Chart of account
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("Chartofaccounts") . '</span></td>';
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Chartofaccounts").'</span></td>';
print '<td>';
print $accountsystem->ref;
print '</td></tr>';
// Account number
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
print '<td><input name="account_number" size="30" value="' . $accountingaccount . '"></td></tr>';
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("AccountNumber").'</span></td>';
print '<td><input name="account_number" size="30" value="'.$accountingaccount.'"></td></tr>';
// Label
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
print '<td><input name="label" size="70" value="' . $object->label . '"></td></tr>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
print '<td><input name="label" size="70" value="'.$object->label.'"></td></tr>';
// Account parent
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td>';
print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
print '</td></tr>';
// Category
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
print '</td></tr>';
// Chart of accounts type
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type', 'alpha'):$object->pcg_type).'">';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Chart of acounts subtype
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$object->pcg_subtype).'">';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
print '</td></tr>';
print '</table>';
@ -265,9 +265,9 @@ if ($action == 'create') {
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -285,24 +285,24 @@ elseif ($id > 0 || $ref) {
{
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="edit">';
print '<input type="hidden" name="id" value="' . $id . '">';
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<table class="border centpercent">';
// Account number
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
print '<td><input name="account_number" size="30" value="' . $object->account_number . '"</td></tr>';
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("AccountNumber").'</span></td>';
print '<td><input name="account_number" size="30" value="'.$object->account_number.'"</td></tr>';
// Label
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
print '<td><input name="label" size="70" value="' . $object->label . '"</td></tr>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
print '<td><input name="label" size="70" value="'.$object->label.'"</td></tr>';
// Account parent
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td>';
print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
print '</td></tr>';
@ -314,15 +314,15 @@ elseif ($id > 0 || $ref) {
print '</td></tr>';
// Chart of accounts type
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type', 'alpha'):$object->pcg_type).'">';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Chart of accounts subtype
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$object->pcg_subtype).'">';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
print '</td></tr>';
print '</table>';
@ -330,15 +330,15 @@ elseif ($id > 0 || $ref) {
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
} else {
// View mode
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
@ -351,27 +351,27 @@ elseif ($id > 0 || $ref) {
print '<table class="border centpercent">';
// Label
print '<tr><td class="titlefield">' . $langs->trans("Label") . '</td>';
print '<td colspan="2">' . $object->label . '</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td>';
print '<td colspan="2">'.$object->label.'</td></tr>';
// Account parent
$accp = new AccountingAccount($db);
if (! empty($object->account_parent)) {
if (!empty($object->account_parent)) {
$accp->fetch($object->account_parent, '');
}
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td colspan="2">'.$accp->account_number.' - '.$accp->label.'</td></tr>';
// Category
print "<tr><td>".$langs->trans("AccountingCategory")."</td><td colspan='2'>".$object->account_category_label."</td>";
// Chart of accounts type
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td colspan="2">' . $object->pcg_type . '</td></tr>';
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td colspan="2">'.$object->pcg_type.'</td></tr>';
// Chart of accounts subtype
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td colspan="2">' . $object->pcg_subtype . '</td></tr>';
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td colspan="2">'.$object->pcg_subtype.'</td></tr>';
print '</table>';
@ -384,16 +384,16 @@ elseif ($id > 0 || $ref) {
*/
print '<div class="tabsAction">';
if (! empty($user->rights->accounting->chartofaccount)) {
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
if (!empty($user->rights->accounting->chartofaccount)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$id.'">'.$langs->trans('Modify').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Modify') . '</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
}
if (! empty($user->rights->accounting->chartofaccount)) {
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
if (!empty($user->rights->accounting->chartofaccount)) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Delete') . '</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
}
print '</div>';

View File

@ -23,14 +23,14 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$error = 0;
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy"));
$langs->loadLangs(array("bills", "accountancy"));
$mesg = '';
$id = GETPOST('id', 'int');
@ -59,16 +59,16 @@ $accountingcategory = new AccountancyCategory($db);
*/
// si ajout de comptes
if (! empty($selectcpt)) {
if (!empty($selectcpt)) {
$cpts = array();
foreach ($selectcpt as $selectedoption) {
if (! array_key_exists($selectedoption, $cpts))
$cpts[$selectedoption] = "'" . $selectedoption . "'";
if (!array_key_exists($selectedoption, $cpts))
$cpts[$selectedoption] = "'".$selectedoption."'";
}
$return= $accountingcategory->updateAccAcc($cat_id, $cpts);
$return = $accountingcategory->updateAccAcc($cat_id, $cpts);
if ($return<0) {
if ($return < 0) {
setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
} else {
setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs');
@ -98,8 +98,8 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?res
print load_fiche_titre($langs->trans('AccountingCategory'), $linkback);
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="display">';
dol_fiche_head();
@ -107,26 +107,26 @@ dol_fiche_head();
print '<table class="border centpercent">';
// Select the category
print '<tr><td class="titlefield">' . $langs->trans("AccountingCategory") . '</td>';
print '<tr><td class="titlefield">'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1);
print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Select").'">';
print '</td></tr>';
// Select the accounts
if (! empty($cat_id))
if (!empty($cat_id))
{
$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
if ($return < 0) {
setEventMessages(null, $accountingcategory->errors, 'errors');
}
print '<tr><td>' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . '</td>';
print '<tr><td>'.$langs->trans("AddAccountFromBookKeepingWithNoCategories").'</td>';
print '<td>';
$arraykeyvalue=array();
foreach($accountingcategory->lines_cptbk as $key => $val)
$arraykeyvalue = array();
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 : '').')';
}
if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
@ -139,7 +139,7 @@ if (! empty($cat_id))
print '</select><br>';
print ajax_combobox('cpt_bk');
*/
print '<input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("Add") . '"> ';
print '<input class="button" type="submit" id="" class="action-delete" value="'.$langs->trans("Add").'"> ';
}
print '</td></tr>';
}
@ -158,8 +158,8 @@ if ($action == 'display' || $action == 'delete') {
print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>";
print "</tr>\n";
if (! empty($cat_id)) {
$return = $accountingcategory->display($cat_id); // This load ->lines_display
if (!empty($cat_id)) {
$return = $accountingcategory->display($cat_id); // This load ->lines_display
if ($return < 0) {
setEventMessages(null, $accountingcategory->errors, 'errors');
}
@ -167,10 +167,10 @@ if ($action == 'display' || $action == 'delete') {
if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
foreach ($accountingcategory->lines_display as $cpt) {
print '<tr class="oddeven">';
print '<td>' . length_accountg($cpt->account_number) . '</td>';
print '<td>' . $cpt->label . '</td>';
print '<td>'.length_accountg($cpt->account_number).'</td>';
print '<td>'.$cpt->label.'</td>';
print '<td class="right">';
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=" . $cat_id . "&cptid=" . $cpt->rowid."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=".$cat_id."&cptid=".$cpt->rowid."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print "</a>";

View File

@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("errors","admin","companies","resource","holiday","accountancy","hrm"));
$langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "accountancy", "hrm"));
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view';
$confirm=GETPOST('confirm', 'alpha');
$id=32;
$rowid=GETPOST('rowid', 'alpha');
$code=GETPOST('code', 'alpha');
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
$confirm = GETPOST('confirm', 'alpha');
$id = 32;
$rowid = GETPOST('rowid', 'alpha');
$code = GETPOST('code', 'alpha');
// Security access
if (empty($user->rights->accounting->chartofaccount)) {
@ -50,15 +50,15 @@ $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$listoffset=GETPOST('listoffset', 'alpha');
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
$listoffset = GETPOST('listoffset', 'alpha');
$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
$active = 1;
$sortfield = GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page ;
$offset = $listlimit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -71,52 +71,52 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(32);
$taborder = array(32);
// Name of SQL tables of dictionaries
$tabname=array();
$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
$tabname = array();
$tabname[32] = MAIN_DB_PREFIX."c_accounting_category";
// Dictionary labels
$tablib=array();
$tablib[32]= "DictionaryAccountancyCategory";
$tablib = array();
$tablib[32] = "DictionaryAccountancyCategory";
// Requests to extract data
$tabsql=array();
$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
$tabsql = array();
$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
// Criteria to sort dictionaries
$tabsqlsort=array();
$tabsqlsort[32]="position ASC";
$tabsqlsort = array();
$tabsqlsort[32] = "position ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
$tabfield[32]= "code,label,range_account,category_type,formula,position,country";
$tabfield = array();
$tabfield[32] = "code,label,range_account,category_type,formula,position,country";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
$tabfieldvalue[32]= "code,label,range_account,category_type,formula,position,country_id";
$tabfieldvalue = array();
$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
$tabfieldinsert[32]= "code,label,range_account,category_type,formula,position,fk_country";
$tabfieldinsert = array();
$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array();
$tabrowid[32]= "";
$tabrowid = array();
$tabrowid[32] = "";
// Condition to show dictionary in setup page
$tabcond=array();
$tabcond[32]= ! empty($conf->accounting->enabled);
$tabcond = array();
$tabcond[32] = !empty($conf->accounting->enabled);
// List of help for fields
$tabhelp=array();
$tabhelp = array();
$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'category_type'=>$langs->trans("SetToYesIfGroupIsComputationOfOtherGroups"), 'formula'=>$langs->trans("EnterCalculationRuleIfPreviousFieldIsYes"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
$tabfieldcheck = array();
$tabfieldcheck[32] = array();
// Complete all arrays with entries found into modules
@ -125,7 +125,7 @@ complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqls
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
$sourceList=array();
$sourceList = array();
@ -141,24 +141,24 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
// Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{
$listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
$ok = 1;
foreach ($listfield as $f => $value)
{
if ($value == 'formula' && empty($_POST['formula'])) continue;
if ($value == 'range_account' && empty($_POST['range_account'])) continue;
if ($value == 'country' || $value == 'country_id') continue;
if (! isset($_POST[$value]) || $_POST[$value]=='')
if (!isset($_POST[$value]) || $_POST[$value] == '')
{
$ok=0;
$fieldnamekey=$listfield[$f];
$ok = 0;
$fieldnamekey = $listfield[$f];
// We take translate key of field
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
@ -170,23 +170,23 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
}
if (isset($_POST["code"]))
{
if ($_POST["code"]=='0')
if ($_POST["code"] == '0')
{
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
}
if (! is_numeric(GETPOST('position', 'alpha')))
if (!is_numeric(GETPOST('position', 'alpha')))
{
$langs->loadLangs(array("errors"));
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors');
}
// Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // 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
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // 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
if ($ok && GETPOST('actionadd', 'alpha'))
@ -194,13 +194,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
$newid = ($obj->newid + 1);
} else {
dol_print_error($db);
}
@ -209,32 +209,32 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active)";
$sql.= " VALUES(";
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].",";
$sql .= $tabfieldinsert[$id];
$sql .= ",active)";
$sql .= " VALUES(";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $newid.",";
$i=0;
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.",";
$i = 0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! $listfieldvalue[$i] == 'formula') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
$sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
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
{
@ -250,16 +250,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
$sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
@ -270,18 +270,18 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! $listfieldvalue[$i] == 'range_account') $sql.="null"; // For range_account, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
$sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
setEventMessages($db->error(), null, 'errors');
}
@ -296,14 +296,14 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
if (!$result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
@ -319,8 +319,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -339,8 +339,8 @@ if ($action == $acts[0])
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -359,8 +359,8 @@ if ($action == $acts[1])
// favorite
if ($action == 'activate_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -379,8 +379,8 @@ if ($action == 'activate_favorite')
// disable favorite
if ($action == 'disable_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -402,13 +402,13 @@ if ($action == 'disable_favorite')
*/
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
llxHeader('', $langs->trans('DictionaryAccountancyCategory'));
$titre=$langs->trans($tablib[$id]);
$linkback='';
$titlepicto='title_setup';
$titre = $langs->trans($tablib[$id]);
$linkback = '';
$titlepicto = 'title_setup';
print load_fiche_titre($titre, $linkback, $titlepicto);
@ -417,7 +417,7 @@ print '<span class="opacitymedium">'.$langs->trans("AccountingAccountGroupsDesc"
// Confirmation de la suppression de la ligne
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);
@ -427,22 +427,22 @@ if ($action == 'delete')
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
$sql = $tabsql[$id];
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /', $sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)";
if (preg_match('/ WHERE /', $sql)) $sql .= " AND ";
else $sql .= " WHERE ";
$sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)";
}
// If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code';
$sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($listlimit+1, $offset);
if ($sortfield == 'country') $sortfield = 'country_code';
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset);
//print $sql;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -454,9 +454,9 @@ if ($id)
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$alabelisused = 0;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
@ -464,55 +464,55 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$class="left";
if ($fieldlist[$field]=='type') {
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
$class = "left";
if ($fieldlist[$field] == 'type') {
if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") {
$valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
$valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
} else {
$valuetoshow=$langs->trans("Type");
$valuetoshow = $langs->trans("Type");
}
}
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='libelle_facture') {
$valuetoshow=$langs->trans("LabelOnDocuments");
if ($fieldlist[$field] == 'libelle_facture') {
$valuetoshow = $langs->trans("LabelOnDocuments");
}
if ($fieldlist[$field]=='country') {
$valuetoshow=$langs->trans("Country");
if ($fieldlist[$field] == 'country') {
$valuetoshow = $langs->trans("Country");
}
if ($fieldlist[$field]=='accountancy_code') {
$valuetoshow=$langs->trans("AccountancyCode");
if ($fieldlist[$field] == 'accountancy_code') {
$valuetoshow = $langs->trans("AccountancyCode");
}
if ($fieldlist[$field]=='accountancy_code_sell') {
$valuetoshow=$langs->trans("AccountancyCodeSell");
if ($fieldlist[$field] == 'accountancy_code_sell') {
$valuetoshow = $langs->trans("AccountancyCodeSell");
}
if ($fieldlist[$field]=='accountancy_code_buy') {
$valuetoshow=$langs->trans("AccountancyCodeBuy");
if ($fieldlist[$field] == 'accountancy_code_buy') {
$valuetoshow = $langs->trans("AccountancyCodeBuy");
}
if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') {
$valuetoshow=$langs->trans("Pcg_version");
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') {
$valuetoshow = $langs->trans("Pcg_version");
}
if ($fieldlist[$field]=='range_account') {
$valuetoshow=$langs->trans("Comment");
if ($fieldlist[$field] == 'range_account') {
$valuetoshow = $langs->trans("Comment");
}
if ($fieldlist[$field]=='category_type') {
$valuetoshow=$langs->trans("Calculated");
if ($fieldlist[$field] == 'category_type') {
$valuetoshow = $langs->trans("Calculated");
}
if ($valuetoshow != '') {
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>';
elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
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>';
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
else print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
}
print '<td>';
@ -533,14 +533,14 @@ if ($id)
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val) != '')
$obj->$val=GETPOST($val);
$obj->$val = GETPOST($val);
}
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$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;
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$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;
if (empty($reshook))
{
@ -552,42 +552,42 @@ if ($id)
print '</td>';
print "</tr>";
$colspan=count($fieldlist)+3;
$colspan = count($fieldlist) + 3;
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
}
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$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;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch.= '&from='.GETPOST('from', 'alpha');
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
// There is several pages
if ($num > $listlimit)
{
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 '<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 '</td></tr>';
}
// Title line with search boxes
print '<tr class="liste_titre liste_titre_add liste_titre_filter">';
$filterfound=0;
$filterfound = 0;
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)
{
@ -610,7 +610,7 @@ if ($id)
print '<td class="liste_titre center">';
if ($filterfound)
{
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
}
print '</td>';
@ -622,80 +622,80 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // By defaut
$class="left";
$sortable=1;
$valuetoshow='';
$showfield = 1; // By defaut
$class = "left";
$sortable = 1;
$valuetoshow = '';
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='source') {
$valuetoshow=$langs->trans("Contact");
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'source') {
$valuetoshow = $langs->trans("Contact");
}
if ($fieldlist[$field]=='price') {
$valuetoshow=$langs->trans("PriceUHT");
if ($fieldlist[$field] == 'price') {
$valuetoshow = $langs->trans("PriceUHT");
}
if ($fieldlist[$field]=='taux') {
if ($fieldlist[$field] == 'taux') {
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") {
$valuetoshow=$langs->trans("Rate");
$valuetoshow = $langs->trans("Rate");
} else {
$valuetoshow=$langs->trans("Amount");
$valuetoshow = $langs->trans("Amount");
}
$class='center';
$class = 'center';
}
if ($fieldlist[$field]=='type') {
$valuetoshow=$langs->trans("Type");
if ($fieldlist[$field] == 'type') {
$valuetoshow = $langs->trans("Type");
}
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='country') {
$valuetoshow=$langs->trans("Country");
if ($fieldlist[$field] == 'country') {
$valuetoshow = $langs->trans("Country");
}
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
$showfield=0;
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
$showfield = 0;
}
if ($fieldlist[$field]=='accountancy_code') {
$valuetoshow=$langs->trans("AccountancyCode");
if ($fieldlist[$field] == 'accountancy_code') {
$valuetoshow = $langs->trans("AccountancyCode");
}
if ($fieldlist[$field]=='accountancy_code_sell') {
$valuetoshow=$langs->trans("AccountancyCodeSell");
$sortable=0;
if ($fieldlist[$field] == 'accountancy_code_sell') {
$valuetoshow = $langs->trans("AccountancyCodeSell");
$sortable = 0;
}
if ($fieldlist[$field]=='accountancy_code_buy') {
$valuetoshow=$langs->trans("AccountancyCodeBuy");
$sortable=0;
if ($fieldlist[$field] == 'accountancy_code_buy') {
$valuetoshow = $langs->trans("AccountancyCodeBuy");
$sortable = 0;
}
if ($fieldlist[$field]=='fk_pcg_version') {
$valuetoshow=$langs->trans("Pcg_version");
if ($fieldlist[$field] == 'fk_pcg_version') {
$valuetoshow = $langs->trans("Pcg_version");
}
if ($fieldlist[$field]=='account_parent') {
$valuetoshow=$langs->trans("Accountsparent");
if ($fieldlist[$field] == 'account_parent') {
$valuetoshow = $langs->trans("Accountsparent");
}
if ($fieldlist[$field]=='pcg_type') {
$valuetoshow=$langs->trans("Pcg_type");
if ($fieldlist[$field] == 'pcg_type') {
$valuetoshow = $langs->trans("Pcg_type");
}
if ($fieldlist[$field]=='pcg_subtype') {
$valuetoshow=$langs->trans("Pcg_subtype");
if ($fieldlist[$field] == 'pcg_subtype') {
$valuetoshow = $langs->trans("Pcg_subtype");
}
if ($fieldlist[$field]=='type_template') {
$valuetoshow=$langs->trans("TypeOfTemplate");
if ($fieldlist[$field] == 'type_template') {
$valuetoshow = $langs->trans("TypeOfTemplate");
}
if ($fieldlist[$field]=='range_account') {
$valuetoshow=$langs->trans("Comment");
if ($fieldlist[$field] == 'range_account') {
$valuetoshow = $langs->trans("Comment");
}
if ($fieldlist[$field]=='category_type') {
$valuetoshow=$langs->trans("Calculated");
if ($fieldlist[$field] == 'category_type') {
$valuetoshow = $langs->trans("Calculated");
}
// Affiche nom du champ
if ($showfield) {
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' ');
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
@ -709,12 +709,12 @@ if ($id)
$obj = $db->fetch_object($resql);
//print_r($obj);
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';
$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
$error=$hookmanager->error; $errors=$hookmanager->errors;
$tmpaction = 'edit';
$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
$error = $hookmanager->error; $errors = $hookmanager->errors;
// Show fields
if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit');
@ -725,7 +725,7 @@ if ($id)
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</td>';
print '<td></td>';
@ -733,71 +733,71 @@ if ($id)
else
{
$tmpaction = 'view';
$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
$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
$error=$hookmanager->error; $errors=$hookmanager->errors;
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$class="left";
$valuetoshow=$obj->{$fieldlist[$field]};
$showfield = 1;
$class = "left";
$valuetoshow = $obj->{$fieldlist[$field]};
if ($value == 'category_type')
{
$valuetoshow = yn($valuetoshow);
}
elseif ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All');
}
elseif ($fieldlist[$field]=='country') {
elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code))
{
$valuetoshow='-';
$valuetoshow = '-';
}
else
{
$key=$langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country);
$key = $langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
}
}
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') {
$key=$langs->trans("Country".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
$key = $langs->trans("Country".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') {
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
$langs->loadLangs(array("propal"));
$key=$langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
$key = $langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') {
$key=$langs->trans("Action".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
$key = $langs->trans("Action".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
$showfield=0;
elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
$showfield = 0;
}
$class='tddict';
$class = 'tddict';
// Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
}
// 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 (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $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;
$url.='&';
$url .= '&';
// Active
print '<td class="center" class="nowrap">';
@ -865,38 +865,38 @@ $db->close();
*/
function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $context = '')
{
global $conf,$langs,$db;
global $conf, $langs, $db;
global $form, $mysoc;
global $region_id;
global $elementList,$sourceList,$localtax_typeList;
global $elementList, $sourceList, $localtax_typeList;
global $bc;
$formadmin = new FormAdmin($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)
{
if ($fieldlist[$field] == 'country')
{
print '<td>';
$fieldname='country';
$fieldname = 'country';
if ($context == 'add')
{
$fieldname='country_id';
$fieldname = 'country_id';
print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
}
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>';
}
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 '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>';
@ -904,21 +904,21 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
}
elseif ($fieldlist[$field] == 'category_type') {
print '<td>';
print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
print '</td>';
}
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat minwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
}
else
{
print '<td>';
$size=''; $class='';
if ($fieldlist[$field]=='code') $class='maxwidth100';
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].'">';
$size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
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 '</td>';
}
}

View File

@ -30,12 +30,12 @@
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy","salaries","loan"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan"));
// Security check
if (empty($user->rights->accounting->chartofaccount))
@ -52,25 +52,40 @@ $list_account_main = array (
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
);
$list_account = array (
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
'ACCOUNTING_VAT_BUY_ACCOUNT',
'ACCOUNTING_VAT_SOLD_ACCOUNT',
'ACCOUNTING_VAT_PAY_ACCOUNT',
'ACCOUNTING_ACCOUNT_SUSPENSE',
'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'DONATION_ACCOUNTINGACCOUNT',
'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT',
'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
);
$list_account = array ();
$list_account[] = '---Product---';
$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT';
if ($mysoc->isInEEC()) {
$list_account[] = 'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT';
}
$list_account[] = 'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT';
$list_account[] = '---Service---';
$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_SERVICE_SOLD_ACCOUNT';
if ($mysoc->isInEEC()) {
$list_account[] = 'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT';
}
$list_account[] = 'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT';
$list_account[] = '---Other---';
$list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT';
$list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT';
$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE';
if ($conf->banque->enabled) {
$list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH';
}
if ($conf->don->enabled) {
$list_account[] = 'DONATION_ACCOUNTINGACCOUNT';
}
if ($conf->adherent->enabled) {
$list_account[] = 'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT';
}
if ($conf->loan->enabled) {
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL';
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST';
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE';
}
/*
* Actions
@ -82,12 +97,12 @@ if (GETPOST('change_chart', 'alpha'))
{
$chartofaccounts = GETPOST('chartofaccounts', 'int');
if (! empty($chartofaccounts)) {
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!empty($chartofaccounts)) {
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
$error ++;
$error++;
}
}
@ -103,7 +118,12 @@ if ($action == 'update') {
}
foreach ($list_account as $constname) {
$constvalue = GETPOST($constname, 'alpha');
$reg=array();
if (preg_match('/---(.*)---/', $constname, $reg)) { // This is a separator
continue;
}
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
@ -133,8 +153,8 @@ print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_a
print '<span class="opacitymedium">'.$langs->trans("DefaultBindingDesc").'</span><br>';
print '<br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
@ -146,14 +166,14 @@ foreach ($list_account_main as $key) {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
$keydesc=$key.'_Desc';
$keydesc = $key.'_Desc';
$htmltext = $langs->trans($keydesc);
print '<td class="fieldrequired" width="50%">';
print $form->textwithpicto($label, $htmltext);
print '</td>';
// Value
print '<td>'; // Do not force class=right, or it align also the content of the select box
print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
@ -170,22 +190,28 @@ print '<br>';
print '<table class="noborder centpercent">';
foreach ($list_account as $key) {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';
// Value
print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
$reg=array();
if (preg_match('/---(.*)---/', $key, $reg)) {
print '<tr class="liste_titre"><td>'.$langs->trans($reg[1]).'</td><td></td></tr>';
}
else {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';
// Value
print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
}
}
print "</table>\n";
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
print '</form>';

View File

@ -28,12 +28,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
// Security access
if (empty($user->rights->accounting->chartofaccount))
@ -57,7 +57,7 @@ $listformat = $configuration['format'];
$listcr = $configuration['cr'];
$model_option = array (
$model_option = array(
'1' => array(
'label' => 'ACCOUNTING_EXPORT_FORMAT',
'param' => $listformat,
@ -86,37 +86,37 @@ if ($action == 'update') {
$modelcsv = GETPOST('ACCOUNTING_EXPORT_MODELCSV', 'int');
if (! empty($modelcsv)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!empty($modelcsv)) {
if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error++;
}
//if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) {
// dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity);
//}
} else {
$error ++;
$error++;
}
foreach ($main_option as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
foreach ($listparam[$modelcsv] as $key => $value) {
$constante = $key;
if (strpos($constante, 'ACCOUNTING')!==false) {
if (strpos($constante, 'ACCOUNTING') !== false) {
$constvalue = GETPOST($key, 'alpha');
if (! dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
}
if (! $error) {
if (!$error) {
// reload
$configuration = AccountancyExport::getTypeConfig();
$listparam = $configuration['param'];
@ -138,7 +138,7 @@ $title = $langs->trans('ConfigAccountingExpert');
llxHeader('', $title);
$linkback='';
$linkback = '';
// $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy');
@ -187,8 +187,8 @@ print ' });'."\n";
print '})'."\n";
print '</script>'."\n";
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
/*
@ -197,7 +197,7 @@ print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('Options') . '</td>';
print '<td colspan="3">'.$langs->trans('Options').'</td>';
print "</tr>\n";
$num = count($main_option);
@ -207,11 +207,11 @@ if ($num) {
// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';
print '<td width="50%">'.$label.'</td>';
// Value
print '<td>';
print '<input type="text" size="20" id="'.$key.'" name="' . $key . '" value="' . $conf->global->$key . '">';
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td></tr>';
}
}
@ -226,13 +226,13 @@ print "<br>\n";
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
print '<td colspan="2">'.$langs->trans("Modelcsv").'</td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td width="50%">' . $langs->trans("Selectmodelcsv") . '</td>';
if (! $conf->use_javascript_ajax) {
print '<td width="50%">'.$langs->trans("Selectmodelcsv").'</td>';
if (!$conf->use_javascript_ajax) {
print '<td class="nowrap">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
@ -256,7 +256,7 @@ $num2 = count($model_option);
if ($num2) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n";
foreach ($model_option as $key) {
@ -264,14 +264,14 @@ if ($num2) {
// Param
$label = $key['label'];
print '<td width="50%">' . $langs->trans($label) . '</td>';
print '<td width="50%">'.$langs->trans($label).'</td>';
// Value
print '<td>';
if (is_array($key['param'])) {
print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
} else {
print '<input type="text" size="20" id="'. $label .'" name="' . $key['label'] . '" value="' . $conf->global->$label . '">';
print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.$conf->global->$label.'">';
}
print '</td></tr>';
@ -280,7 +280,7 @@ if ($num2) {
print "</table>\n";
}
print '<div class="center"><input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Modify')) . '" name="button"></div>';
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Modify')).'" name="button"></div>';
print '</form>';

View File

@ -22,13 +22,13 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
$action = GETPOST('action', 'aZ09');
// 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', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -36,32 +36,32 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="f.rowid"; // Set here default search field
if (! $sortorder) $sortorder="ASC";
if (!$sortfield) $sortfield = "f.rowid"; // Set here default search field
if (!$sortorder) $sortorder = "ASC";
// Load translation files required by the page
$langs->loadLangs(array("admin","compta"));
$langs->loadLangs(array("admin", "compta"));
// Security check
if ($user->socid > 0)
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();
$error = 0;
// List of status
static $tmpstatut2label = array (
static $tmpstatut2label = array(
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
);
$statut2label = array (
$statut2label = array(
''
);
foreach ($tmpstatut2label as $key => $val)
$statut2label[$key] = $langs->trans($val);
$errors = array ();
$errors = array();
$object = new Fiscalyear($db);
@ -85,9 +85,9 @@ $helpurl = "";
llxHeader('', $title, $helpurl);
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f";
$sql .= " WHERE f.entity = " . $conf->entity;
$sql.=$db->order($sortfield, $sortorder);
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
@ -102,7 +102,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);
if ($result)
@ -112,7 +112,7 @@ if ($result)
$i = 0;
$addbutton.= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
$addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
$title = $langs->trans('AccountingPeriods');
@ -122,34 +122,34 @@ if ($result)
print '<div class="div-table-responsive">';
print '<table class="tagtable liste centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("DateStart") . '</td>';
print '<td>' . $langs->trans("DateEnd") . '</td>';
print '<td class="center">' . $langs->trans("NumberOfAccountancyEntries") . '</td>';
print '<td class="center">' . $langs->trans("NumberOfAccountancyMovements") . '</td>';
print '<td class="right">' . $langs->trans("Statut") . '</td>';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("DateStart").'</td>';
print '<td>'.$langs->trans("DateEnd").'</td>';
print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
print '<td class="right">'.$langs->trans("Statut").'</td>';
print '</tr>';
if ($num) {
$fiscalyearstatic = new Fiscalyear($db);
while ( $i < $num && $i < $max ) {
while ($i < $num && $i < $max) {
$obj = $db->fetch_object($result);
$fiscalyearstatic->id = $obj->rowid;
print '<tr class="oddeven">';
print '<td><a href="fiscalyear_card.php?id=' . $obj->rowid . '">' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . '</a></td>';
print '<td class="left">' . $obj->label . '</td>';
print '<td class="left">' . dol_print_date($db->jdate($obj->date_start), 'day') . '</td>';
print '<td class="left">' . dol_print_date($db->jdate($obj->date_end), 'day') . '</td>';
print '<td class="center">' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td class="center">' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td class="right">' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '</td>';
print '<td><a href="fiscalyear_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowFiscalYear"), "technic").' '.$obj->rowid.'</a></td>';
print '<td class="left">'.$obj->label.'</td>';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->statut, 5).'</td>';
print '</tr>';
$i++;
}
} else {
print '<tr class="oddeven"><td colspan="7" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print '</table>';
print '</div>';

View File

@ -24,11 +24,11 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","compta"));
$langs->loadLangs(array("admin", "compta"));
// Security check
if ($user->socid > 0)
@ -43,11 +43,11 @@ $confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
// List of statut
static $tmpstatut2label = array (
static $tmpstatut2label = array(
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
);
$statut2label = array (
$statut2label = array(
''
);
foreach ($tmpstatut2label as $key => $val)
@ -74,7 +74,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
}
elseif ($action == 'add') {
if (! GETPOST('cancel', 'alpha')) {
if (!GETPOST('cancel', 'alpha')) {
$error = 0;
$object->date_start = $date_start;
@ -85,14 +85,14 @@ elseif ($action == 'add') {
if (empty($object->date_start) && empty($object->date_end)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error ++;
$error++;
}
if (empty($object->label)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$error ++;
$error++;
}
if (! $error) {
if (!$error) {
$db->begin();
$id = $object->create($user);
@ -100,7 +100,7 @@ elseif ($action == 'add') {
if ($id > 0) {
$db->commit();
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
} else {
$db->rollback();
@ -119,7 +119,7 @@ elseif ($action == 'add') {
// Update record
elseif ($action == 'update') {
if (! GETPOST('cancel', 'alpha')) {
if (!GETPOST('cancel', 'alpha')) {
$result = $object->fetch($id);
$object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start;
@ -130,13 +130,13 @@ elseif ($action == 'update') {
$result = $object->update($user);
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
}
}
@ -149,7 +149,7 @@ elseif ($action == 'update') {
$form = new Form($db);
$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card");
$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Card");
$helpurl = "";
llxHeader("", $title, $helpurl);
@ -157,8 +157,8 @@ if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewFiscalYear"));
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
@ -166,15 +166,15 @@ if ($action == 'create')
print '<table class="border centpercent">';
// Label
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Label") . '</td><td><input name="label" size="32" value="' . GETPOST('label', 'alpha') . '"></td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="32" value="'.GETPOST('label', 'alpha').'"></td></tr>';
// Date start
print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear');
print '</td></tr>';
// Date end
print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend');
print '</td></tr>';
@ -192,9 +192,9 @@ if ($action == 'create')
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -206,36 +206,36 @@ if ($action == 'create')
if ($action == 'edit') {
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="' . $id . '">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<table class="border centpercent">';
// Ref
print "<tr>";
print '<td class="titlefieldcreate titlefield">' . $langs->trans("Ref") . '</td><td>';
print '<td class="titlefieldcreate titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->ref;
print '</td></tr>';
// Label
print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td>';
print '<input name="label" class="flat" size="32" value="' . $object->label . '">';
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
print '<input name="label" class="flat" size="32" value="'.$object->label.'">';
print '</td></tr>';
// Date start
print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear');
print '</td></tr>';
// Date end
print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
print '</td></tr>';
// Statut
print '<tr><td>' . $langs->trans("Statut") . '</td><td>';
print '<tr><td>'.$langs->trans("Statut").'</td><td>';
// print $form->selectarray('statut', $statut2label, $object->statut);
print $object->getLibStatut(4);
print '</td></tr>';
@ -243,9 +243,9 @@ if ($action == 'create')
print '</table>';
print '<br><div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -256,17 +256,17 @@ if ($action == 'create')
* Confirm delete
*/
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
}
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<table class="border centpercent">';
$linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/fiscalyear.php">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/fiscalyear.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td width="50%">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td width="50%">';
print $object->ref;
print '</td><td>';
print $linkback;
@ -294,20 +294,20 @@ if ($action == 'create')
print '</td></tr>';
// Statut
print '<tr><td>' . $langs->trans("Status") . '</td><td colspan="2">' . $object->getLibStatut(4) . '</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$object->getLibStatut(4).'</td></tr>';
print "</table>";
dol_fiche_end();
if (! empty($user->rights->accounting->fiscalyear->write))
if (!empty($user->rights->accounting->fiscalyear->write))
{
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
// print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';

View File

@ -29,11 +29,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
// Security access
if (empty($user->rights->accounting->chartofaccount))
@ -44,9 +44,9 @@ if (empty($user->rights->accounting->chartofaccount))
$action = GETPOST('action', 'aZ09');
// Parameters ACCOUNTING_* and others
$list = array (
$list = array(
'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT' ,
'ACCOUNTING_LENGTH_AACCOUNT',
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
);
@ -62,13 +62,13 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' :
if ($action == 'update') {
$error = 0;
if (! $error)
if (!$error)
{
foreach ($list as $constname)
{
$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++;
}
}
@ -77,7 +77,7 @@ if ($action == 'update') {
}
}
if (! $error) {
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
}
@ -85,10 +85,10 @@ if ($action == 'update') {
if ($action == 'setlistsorttodo') {
$setlistsorttodo = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (!$res > 0)
$error++;
if (! $error) {
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -98,9 +98,9 @@ if ($action == 'setlistsorttodo') {
if ($action == 'setlistsortdone') {
$setlistsortdone = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -110,9 +110,9 @@ if ($action == 'setlistsortdone') {
if ($action == 'setmanagezero') {
$setmanagezero = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -122,9 +122,9 @@ if ($action == 'setmanagezero') {
if ($action == 'setdisabledirectinput') {
$setdisabledirectinput = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -134,9 +134,9 @@ if ($action == 'setdisabledirectinput') {
if ($action == 'setenabledraftexport') {
$setenabledraftexport = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -146,9 +146,9 @@ if ($action == 'setenabledraftexport') {
if ($action == 'setenablesubsidiarylist') {
$setenablesubsidiarylist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -159,15 +159,15 @@ if ($action == 'setenablesubsidiarylist') {
* View
*/
$title= $langs->trans('ConfigAccountingExpert');
$title = $langs->trans('ConfigAccountingExpert');
llxHeader('', $title);
$linkback='';
$linkback = '';
//$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy');
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
// Default mode for calculating turnover (parameter ACCOUNTING_MODE)
@ -204,85 +204,85 @@ print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
print '<td colspan="2">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n";
if (! empty($user->admin))
if (!empty($user->admin))
{
// TO DO Mutualize code for yes/no constants
print '<tr class="oddeven">';
print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . '</td>';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . '</td>';
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenablesubsidiarylist&value=0">';
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenablesubsidiarylist&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
@ -295,14 +295,14 @@ foreach ($list as $key)
{
print '<tr class="oddeven value">';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
// Param
$label = $langs->trans($key);
print '<td>'.$label.'</td>';
// Value
print '<td class="right">';
print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td>';
print '</tr>';
@ -311,7 +311,7 @@ foreach ($list as $key)
print '</table>';
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
print '<br>';
print '<br>';

View File

@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","compta","accountancy"));
$langs->loadLangs(array("admin", "compta", "accountancy"));
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view';
$confirm=GETPOST('confirm', 'alpha');
$id=35;
$rowid=GETPOST('rowid', 'alpha');
$code=GETPOST('code', 'alpha');
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
$confirm = GETPOST('confirm', 'alpha');
$id = 35;
$rowid = GETPOST('rowid', 'alpha');
$code = GETPOST('code', 'alpha');
// Security access
if (empty($user->rights->accounting->chartofaccount))
@ -51,19 +51,19 @@ $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$listoffset=GETPOST('listoffset', 'alpha');
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
$listoffset = GETPOST('listoffset', 'alpha');
$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
$active = 1;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page ;
$offset = $listlimit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (empty($sortfield)) $sortfield='code';
if (empty($sortorder)) $sortorder='ASC';
if (empty($sortfield)) $sortfield = 'code';
if (empty($sortorder)) $sortorder = 'ASC';
$error = 0;
@ -74,52 +74,52 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(35);
$taborder = array(35);
// Name of SQL tables of dictionaries
$tabname=array();
$tabname[35]= MAIN_DB_PREFIX."accounting_journal";
$tabname = array();
$tabname[35] = MAIN_DB_PREFIX."accounting_journal";
// Dictionary labels
$tablib=array();
$tablib[35]= "DictionaryAccountancyJournal";
$tablib = array();
$tablib[35] = "DictionaryAccountancyJournal";
// Requests to extract data
$tabsql=array();
$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
$tabsql = array();
$tabsql[35] = "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
// Criteria to sort dictionaries
$tabsqlsort=array();
$tabsqlsort[35]="code ASC";
$tabsqlsort = array();
$tabsqlsort[35] = "code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
$tabfield[35]= "code,label,nature";
$tabfield = array();
$tabfield[35] = "code,label,nature";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
$tabfieldvalue[35]= "code,label,nature";
$tabfieldvalue = array();
$tabfieldvalue[35] = "code,label,nature";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
$tabfieldinsert[35]= "code,label,nature";
$tabfieldinsert = array();
$tabfieldinsert[35] = "code,label,nature";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array();
$tabrowid[35]= "";
$tabrowid = array();
$tabrowid[35] = "";
// Condition to show dictionary in setup page
$tabcond=array();
$tabcond[35]= ! empty($conf->accounting->enabled);
$tabcond = array();
$tabcond[35] = !empty($conf->accounting->enabled);
// List of help for fields
$tabhelp=array();
$tabhelp = array();
$tabhelp[35] = array('code'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
$tabfieldcheck = array();
$tabfieldcheck[35] = array();
// Complete all arrays with entries found into modules
@ -151,25 +151,25 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
// Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{
$listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
$ok = 1;
foreach ($listfield as $f => $value)
{
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal';
}
// Other checks
if (isset($_POST["code"]))
{
if ($_POST["code"]=='0')
if ($_POST["code"] == '0')
{
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
@ -178,16 +178,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$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');
$ok=0;
$ok = 0;
}
// Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // 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
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // 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
if ($ok && GETPOST('actionadd', 'alpha'))
@ -195,13 +195,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
$newid = ($obj->newid + 1);
} else {
dol_print_error($db);
}
@ -210,34 +210,34 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active,entity)";
$sql.= " VALUES(";
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $tabrowid[$id].",";
$sql .= $tabfieldinsert[$id];
$sql .= ",active,entity)";
$sql .= " VALUES(";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $newid.",";
$i=0;
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $newid.",";
$i = 0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; // For vat, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1,".$conf->entity.")";
$sql .= ",1,".$conf->entity.")";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
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
{
@ -253,16 +253,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
$sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
@ -273,19 +273,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
$sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
$sql.=" AND entity = ".$conf->entity;
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
$sql .= " AND entity = ".$conf->entity;
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
setEventMessages($db->error(), null, 'errors');
}
@ -300,15 +300,15 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
$sql.=" AND entity = ".$conf->entity;
$sql .= " AND entity = ".$conf->entity;
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
if (!$result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
@ -324,8 +324,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
@ -333,7 +333,7 @@ if ($action == $acts[0])
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
}
$sql.=" AND entity = ".$conf->entity;
$sql .= " AND entity = ".$conf->entity;
$result = $db->query($sql);
if (!$result)
@ -345,8 +345,8 @@ if ($action == $acts[0])
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
@ -354,7 +354,7 @@ if ($action == $acts[1])
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
}
$sql.=" AND entity = ".$conf->entity;
$sql .= " AND entity = ".$conf->entity;
$result = $db->query($sql);
if (!$result)
@ -369,16 +369,16 @@ if ($action == $acts[1])
*/
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
llxHeader();
$titre=$langs->trans("DictionarySetup");
$linkback='';
$titre = $langs->trans("DictionarySetup");
$linkback = '';
if ($id)
{
$titre.=' - '.$langs->trans($tablib[$id]);
$titlepicto='title_accountancy';
$titre .= ' - '.$langs->trans($tablib[$id]);
$titlepicto = 'title_accountancy';
}
print load_fiche_titre($titre, $linkback, $titlepicto);
@ -387,7 +387,7 @@ print load_fiche_titre($titre, $linkback, $titlepicto);
// Confirmation de la suppression de la ligne
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);
@ -397,15 +397,15 @@ if ($action == 'delete')
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
$sql.= " WHERE a.entity = ".$conf->entity;
$sql = $tabsql[$id];
$sql .= " WHERE a.entity = ".$conf->entity;
// If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code';
$sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($listlimit+1, $offset);
if ($sortfield == 'country') $sortfield = 'country_code';
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset);
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -417,9 +417,9 @@ if ($id)
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$alabelisused = 0;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
@ -427,27 +427,27 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$class="left";
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
$class = "left";
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='nature') {
$valuetoshow=$langs->trans("NatureOfJournal");
if ($fieldlist[$field] == 'nature') {
$valuetoshow = $langs->trans("NatureOfJournal");
}
if ($valuetoshow != '') {
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>';
elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
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>';
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
else print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
}
print '<td>';
@ -468,14 +468,14 @@ if ($id)
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val) != '')
$obj->$val=GETPOST($val);
$obj->$val = GETPOST($val);
}
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$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;
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$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;
if (empty($reshook))
{
@ -487,31 +487,31 @@ if ($id)
print '</td>';
print "</tr>";
print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
}
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$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;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch.= '&from='.GETPOST('from', 'alpha');
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
// There is several pages
if ($num > $listlimit)
{
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 '<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 '</td></tr>';
}
@ -536,10 +536,10 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // By defaut
$class="left";
$sortable=1;
$valuetoshow='';
$showfield = 1; // By defaut
$class = "left";
$sortable = 1;
$valuetoshow = '';
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
@ -547,24 +547,24 @@ if ($id)
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='nature') {
$valuetoshow=$langs->trans("NatureOfJournal");
if ($fieldlist[$field] == 'nature') {
$valuetoshow = $langs->trans("NatureOfJournal");
}
// Affiche nom du champ
if ($showfield) {
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' ');
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
@ -578,12 +578,12 @@ if ($id)
$obj = $db->fetch_object($resql);
//print_r($obj);
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';
$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
$error=$hookmanager->error; $errors=$hookmanager->errors;
$tmpaction = 'edit';
$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
$error = $hookmanager->error; $errors = $hookmanager->errors;
// Show fields
if (empty($reshook)) fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
@ -593,44 +593,44 @@ if ($id)
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
print '</td>';
}
else
{
$tmpaction = 'view';
$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
$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
$error=$hookmanager->error; $errors=$hookmanager->errors;
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
$langs->load("accountancy");
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$class="left";
$valuetoshow=$obj->{$fieldlist[$field]};
if ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
$showfield = 1;
$class = "left";
$valuetoshow = $obj->{$fieldlist[$field]};
if ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All');
}
elseif ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]});
elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
$key = $langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$valuetoshow=$langs->trans($obj->label);
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
$valuetoshow = $langs->trans($obj->label);
}
$class='tddict';
$class = 'tddict';
// Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
}
// 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) && $id != 10) {
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
$iserasable = 0;
@ -644,11 +644,11 @@ 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;
$url.='&';
$url .= '&';
// Active
print '<td class="nowrap center">';
@ -708,10 +708,10 @@ $db->close();
*/
function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
{
global $conf,$langs,$db;
global $conf, $langs, $db;
global $form, $mysoc;
global $region_id;
global $elementList,$sourceList,$localtax_typeList;
global $elementList, $sourceList, $localtax_typeList;
global $bc;
$formadmin = new FormAdmin($db);
@ -722,20 +722,20 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
if ($fieldlist[$field] == 'nature')
{
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>';
}
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat minwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
}
else
{
print '<td>';
$size=''; $class='';
if ($fieldlist[$field]=='code') $class='maxwidth100';
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].'">';
$size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
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 '</td>';
}
}

View File

@ -26,22 +26,22 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
// Load translation files required by the page
$langs->loadLangs(array("companies","compta","accountancy","products"));
$langs->loadLangs(array("companies", "compta", "accountancy", "products"));
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
// search & action GETPOST
@ -60,6 +60,8 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_current_account = GETPOST('search_current_account', 'alpha');
$search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
if ($search_current_account_valid == '') $search_current_account_valid='withoutvalidaccount';
$search_onsell = GETPOST('search_onsell', 'alpha');
$search_onpurchase = GETPOST('search_onpurchase', 'alpha');
$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
$btn_changeaccount = GETPOST('changeaccount', 'alpha');
@ -75,23 +77,23 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="p.ref";
if (! $sortorder) $sortorder="ASC";
if (!$sortfield) $sortfield = "p.ref";
if (!$sortorder) $sortorder = "ASC";
if (empty($action)) $action='list';
if (empty($action)) $action = 'list';
$arrayfields=array();
$arrayfields = array();
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Purge search criteria
@ -100,16 +102,18 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_ref = '';
$search_label = '';
$search_desc = '';
$search_onsell = '';
$search_onpurchase = '';
$search_current_account = '';
$search_current_account_valid = '-1';
}
// Sales or Purchase mode ?
if ($action == 'update') {
if (! empty($btn_changetype)) {
if (!empty($btn_changetype)) {
$error = 0;
$accounting_product_modes = array (
$accounting_product_modes = array(
'ACCOUNTANCY_SELL',
'ACCOUNTANCY_SELL_INTRA',
'ACCOUNTANCY_SELL_EXPORT',
@ -117,17 +121,17 @@ if ($action == 'update') {
);
if (in_array($accounting_product_mode, $accounting_product_modes)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
$error ++;
$error++;
}
}
if (! empty($btn_changeaccount)) {
if (!empty($btn_changeaccount)) {
//$msg = '<div><span class="accountingprocessing">' . $langs->trans("Processing") . '...</span></div>';
if (! empty($chk_prod)) {
if (!empty($chk_prod)) {
$accounting = new AccountingAccount($db);
//$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
@ -136,37 +140,37 @@ if ($action == 'update') {
$cpt = 0; $ok = 0; $ko = 0;
foreach ($chk_prod as $productid)
{
$accounting_account_id = GETPOST('codeventil_' . $productid);
$accounting_account_id = GETPOST('codeventil_'.$productid);
$result = 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);
}
if ($result <= 0) {
// setEventMessages(null, $accounting->errors, 'errors');
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '<br/> <pre>' . $sql . '</pre></font></div>';
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br/> <pre>'.$sql.'</pre></font></div>';
$ko++;
} else {
$db->begin();
$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
$sql = " UPDATE ".MAIN_DB_PREFIX."product";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= " SET accountancy_code_buy = " . $accounting->account_number;
$sql .= " SET accountancy_code_buy = ".$accounting->account_number;
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$sql .= " SET accountancy_code_sell = " . $accounting->account_number;
$sql .= " SET accountancy_code_sell = ".$accounting->account_number;
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$sql .= " SET accountancy_code_sell_intra = " . $accounting->account_number;
$sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number;
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$sql .= " SET accountancy_code_sell_export = " . $accounting->account_number;
$sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
}
$sql .= " WHERE rowid = " . $productid;
$sql .= " WHERE rowid = ".$productid;
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql))
{
$ok++;
@ -196,12 +200,14 @@ $form = new FormAccounting($db);
// Default AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
// so we need to get those default value rowid first
// so we need to get those the rowid of those default value first
$accounting = new AccountingAccount($db);
// TODO: we should need to check if result is already exists accountaccount rowid.....
$aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
$aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
$aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_servsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT, 1);
$aarowid_servsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT, 1);
$aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
$aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1);
$aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1);
@ -209,6 +215,8 @@ $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_P
$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_servsell_intra = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_servsell_export = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell_export = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
@ -219,7 +227,9 @@ $pcgverid = $conf->global->CHARTOFACCOUNTS;
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
if (empty($pcgvercode)) $pcgvercode=$pcgverid;
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type,";
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,";
$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,";
$sql.= " p.tms, p.fk_product_type as product_type,";
$sql.= " aa.rowid as aaid";
$sql.= " FROM " . MAIN_DB_PREFIX . "product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
@ -236,7 +246,7 @@ elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
}
else
{
$sql.=" p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
$sql.=" p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
}
$sql.= ' WHERE p.entity IN ('.getEntity('product').')';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
@ -276,6 +286,9 @@ if (strlen(trim($search_label))) {
if (strlen(trim($search_desc))) {
$sql .= natural_search("p.description", $search_desc);
}
if ($search_onsell != '' && $search_onsell != '-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);
$nbtotalofrecords = '';
@ -292,24 +305,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$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);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
if ($search_current_account_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);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account);
if ($search_current_account_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.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -369,9 +382,13 @@ if ($result)
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
// On sell
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') print '<td class="liste_titre"></td>';
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
print '<td class="liste_titre">'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).'</td>';
}
// On buy
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print '<td class="liste_titre"></td>';
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print '<td class="liste_titre">'.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).'</td>';
}
// Current account
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_current_account" id="search_current_account" value="' . dol_escape_htmltag($search_current_account) . '">';
@ -389,6 +406,7 @@ if ($result)
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);
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
// On sell / On purchase
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount="p.accountancy_code_sell";
@ -424,20 +442,45 @@ if ($result)
$product_static->status = $obj->tosell;
$product_static->status_buy = $obj->tobuy;
if ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
} elseif ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
} elseif ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
} else {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
// Sales
if ($obj->product_type == 0) {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
}
else {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
}
}
else {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
}
else {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
}
}
// Purchases
if ($obj->product_type == 0) {
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy;
@ -454,13 +497,13 @@ if ($result)
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
// print '<td class="left">' . $obj->description . '</td>';
// TODO: we shoul set a user defined value to adjust user square / wide screen size
$trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print '<td>' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
print '<td>'.nl2br(dol_trunc($obj->description, $trunclengh)).'</td>';
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT')
@ -486,7 +529,7 @@ if ($result)
}
print '</td>';
// Dedicated account
// New account to set
$defaultvalue='';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
// Accounting account buy

View File

@ -28,24 +28,24 @@
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy"));
$page = GETPOST("page");
$page = GETPOST("page", 'int');
$sortorder = GETPOST("sortorder", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha');
$action = GETPOST('action', 'aZ09');
if (GETPOST("exportcsv", 'alpha')) $action = 'export_csv';
// 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', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -75,18 +75,18 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($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.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql.= $db->plimit(1);
$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 .= $db->plimit(1);
$res = $db->query($sql);
if ($res->num_rows > 0) {
$fiscalYear = $db->fetch_object($res);
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} 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_end = $year_start + 1;
$month_end = $month_start - 1;
@ -105,26 +105,26 @@ if ($sortfield == "")
$sortfield = "t.numero_compte";
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
$filter = array ();
if (! empty($search_date_start)) {
$filter = array();
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$param .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
$param .= '&amp;date_startmonth='.GETPOST('date_startmonth', 'int').'&amp;date_startday='.GETPOST('date_startday', 'int').'&amp;date_startyear='.GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$param .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
$param .= '&amp;date_endmonth='.GETPOST('date_endmonth', 'int').'&amp;date_endday='.GETPOST('date_endday', 'int').'&amp;date_endyear='.GETPOST('date_endyear', 'int');
}
if (! empty($search_accountancy_code_start)) {
if (!empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
$param .= '&amp;search_accountancy_code_start='.$search_accountancy_code_start;
}
if (! empty($search_accountancy_code_end)) {
if (!empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&amp;search_accountancy_code_end=' . $search_accountancy_code_end;
$param .= '&amp;search_accountancy_code_end='.$search_accountancy_code_end;
}
/*
@ -151,7 +151,7 @@ if ($action == 'export_csv')
$filename = 'balance';
$type_export = 'balance';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter);
if ($result < 0) {
@ -160,11 +160,11 @@ if ($action == 'export_csv')
foreach ($object->lines as $line)
{
print length_accountg($line->numero_compte) . $sep;
print $object->get_compte_desc($line->numero_compte) . $sep;
print price($line->debit) . $sep;
print price($line->credit) . $sep;
print price($line->debit - $line->credit) . $sep;
print length_accountg($line->numero_compte).$sep;
print $object->get_compte_desc($line->numero_compte).$sep;
print price($line->debit).$sep;
print price($line->credit).$sep;
print price($line->debit - $line->credit).$sep;
print "\n";
}
@ -203,20 +203,20 @@ if ($action != 'export_csv')
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$button = '<input type="submit" name="exportcsv" class="butAction" value="' . $langs->trans("Export") . ' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
$button = '<input type="submit" name="exportcsv" class="butAction" value="'.$langs->trans("Export").' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
$moreforfilter = '';
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateStart') . ': ';
$moreforfilter .= $form->selectDate($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateEnd') . ': ';
$moreforfilter .= $form->selectDate($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateStart').': ';
$moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateEnd').': ';
$moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0);
$moreforfilter .= '</div>';
if (! empty($moreforfilter)) {
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters = array();
@ -225,7 +225,7 @@ if ($action != 'export_csv')
print '</div>';
}
print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">';
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="5">';
@ -236,7 +236,7 @@ if ($action != 'export_csv')
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
print '</td>';
print '<td class="liste_titre right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
@ -265,7 +265,7 @@ if ($action != 'export_csv')
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
$root_account_description = $object->get_compte_racine($line->numero_compte);
if (empty($description)) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
}
print '<tr class="oddeven">';
@ -291,12 +291,12 @@ if ($action != 'export_csv')
// $object->get_compte_racine($line->numero_compte);
print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . $description . '</td>';
print '<td class="nowraponall right">' . price($line->debit) . '</td>';
print '<td class="nowraponall right">' . price($line->credit) . '</td>';
print '<td class="nowraponall right">' . price($line->debit - $line->credit) . '</td>';
print '<td class="center">' . $link;
print '<td>'.length_accountg($line->numero_compte).'</td>';
print '<td>'.$description.'</td>';
print '<td class="nowraponall right">'.price($line->debit).'</td>';
print '<td class="nowraponall right">'.price($line->credit).'</td>';
print '<td class="nowraponall right">'.price($line->debit - $line->credit).'</td>';
print '<td class="center">'.$link;
print '</td>';
print "</tr>\n";
@ -305,11 +305,11 @@ if ($action != 'export_csv')
$sous_total_credit += $line->credit;
}
print '<tr class="liste_total"><td class="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap right">' . price($sous_total_debit) . '</td><td class="nowrap right">' . price($sous_total_credit) . '</td><td class="nowrap right">' . price(price2num($sous_total_debit - $sous_total_credit)) . '</td>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
print '<tr class="liste_total"><td class="right" colspan="2">' . $langs->trans("AccountBalance") . ':</td><td class="nowrap right">' . price($total_debit) . '</td><td class="nowrap right">' . price($total_credit) . '</td><td class="nowrap right">' . price(price2num($total_debit - $total_credit)) . '</td>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';

View File

@ -26,11 +26,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.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"));
$langs->loadLangs(array("bills", "compta", "accountancy", "other"));
// Filter
$year = GETPOST("year", 'int');
@ -49,17 +49,17 @@ if ($year == 0) {
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>';
$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);
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 = "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);
dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql);
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_row($result);
@ -72,10 +72,10 @@ $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 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="right">'.$langs->trans("MonthShort".sprintf("%02s", $i)).'</td>';
}
print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>';
print '</tr>';
@ -94,9 +94,9 @@ $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 .= " 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);
@ -104,26 +104,26 @@ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
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 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 ++;
$i++;
}
$db->free($resql);
} else {

View File

@ -26,23 +26,23 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy", "bills", "compta"));
$action = GETPOST('action', 'aZ09');
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$id = GETPOST('id', 'int'); // id of record
$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp'
$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id)
$id = GETPOST('id', 'int'); // id of record
$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp'
$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id)
// Security check
if ($user->socid > 0) {
@ -66,14 +66,14 @@ $subledger_account = GETPOST('subledger_account', 'alphanohtml');
if ($subledger_account == - 1) {
$subledger_account = null;
}
$label_operation= GETPOST('label_operation', 'alphanohtml');
$label_operation = GETPOST('label_operation', 'alphanohtml');
$debit = price2num(GETPOST('debit', 'alpha'));
$credit = price2num(GETPOST('credit', 'alpha'));
$save = GETPOST('save', 'alpha');
if (! empty($save)) $action = 'add';
if (!empty($save)) $action = 'add';
$update = GETPOST('update', 'alpha');
if (! empty($update)) $action = 'confirm_update';
if (!empty($update)) $action = 'confirm_update';
$object = new BookKeeping($db);
@ -88,16 +88,16 @@ if ($action == "confirm_update") {
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
$error++;
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action='update';
$action = 'update';
}
if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
{
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action='update';
$action = 'update';
}
if (! $error)
if (!$error)
{
$object = new BookKeeping($db);
@ -109,7 +109,7 @@ if ($action == "confirm_update") {
$object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account;
$object->label_compte = $accountingaccount_label;
$object->label_operation= $label_operation;
$object->label_operation = $label_operation;
$object->debit = $debit;
$object->credit = $credit;
@ -147,22 +147,22 @@ elseif ($action == "add") {
{
$error++;
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action='';
$action = '';
}
if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
{
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action='';
$action = '';
}
if (! $error) {
if (!$error) {
$object = new BookKeeping($db);
$object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account;
$object->label_compte = $accountingaccount_label;
$object->label_operation= $label_operation;
$object->label_operation = $label_operation;
$object->debit = $debit;
$object->credit = $credit;
$object->doc_date = GETPOST('doc_date', 'alpha');
@ -223,18 +223,18 @@ elseif ($action == "confirm_create") {
$object = new BookKeeping($db);
if (! $journal_code || $journal_code == '-1') {
if (!$journal_code || $journal_code == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors');
$action='create';
$action = 'create';
$error++;
}
if (! GETPOST('next_num_mvt', 'alpha'))
if (!GETPOST('next_num_mvt', 'alpha'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors');
$error++;
}
if (! $error)
if (!$error)
{
$object->label_compte = '';
$object->debit = 0;
@ -258,7 +258,7 @@ elseif ($action == "confirm_create") {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
}
$action = 'update';
$id=$object->id;
$id = $object->id;
$piece_num = $object->piece_num;
}
}
@ -329,7 +329,7 @@ llxHeader('', $langs->trans("CreateMvts"));
// Confirmation to delete the command
if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
@ -345,12 +345,12 @@ if ($action == 'create')
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.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
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="mode" value="_tmp">' . "\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="mode" value="_tmp">'."\n";
dol_fiche_head();
@ -362,19 +362,19 @@ if ($action == 'create')
print '</tr>';*/
print '<tr>';
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("Docdate") . '</td>';
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Docdate").'</td>';
print '<td>';
print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1) . '</td>';
print '<td class="fieldrequired">'.$langs->trans("Codejournal").'</td>';
print '<td>'.$formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1).'</td>';
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("Piece") . '</td>';
print '<td>'.$langs->trans("Piece").'</td>';
print '<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST('doc_ref', 'alpha').'"></td>';
print '</tr>';
@ -390,9 +390,9 @@ if ($action == 'create')
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Create") . '">';
print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="button" value="' . $langs->trans("Cancel") . '" class="button" onclick="history.go(-1)" />';
print '<input type="button" value="'.$langs->trans("Cancel").'" class="button" onclick="history.go(-1)" />';
print '</div>';
print '</form>';
@ -403,15 +403,15 @@ if ($action == 'create')
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);
$head=array();
$h=0;
$head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode?'&mode='.$mode:'');
$head = array();
$h = 0;
$head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : '');
$head[$h][1] = $langs->trans("Transaction");
$head[$h][2] = 'transaction';
$h++;
@ -428,8 +428,8 @@ if ($action == 'create')
// Account movement
print '<tr>';
print '<td class="titlefield">' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $object->piece_num . '</td>';
print '<td class="titlefield">'.$langs->trans("NumMvts").'</td>';
print '<td>'.$object->piece_num.'</td>';
print '</tr>';
// Date
@ -438,17 +438,17 @@ if ($action == 'create')
print $langs->trans('Docdate');
print '</td>';
if ($action != 'editdate')
print '<td class="right"><a class="editfielda" 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" 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 '</td><td colspan="3">';
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.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->doc_date ? dol_print_date($object->doc_date, 'day') : '&nbsp;';
@ -462,20 +462,20 @@ if ($action == 'create')
print $langs->trans('Codejournal');
print '</td>';
if ($action != 'editjournal')
print '<td class="right"><a class="editfielda" 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" 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 '</td><td>';
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.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->code_journal ;
print $object->code_journal;
}
print '</td>';
print '</tr>';
@ -486,20 +486,20 @@ if ($action == 'create')
print $langs->trans('Piece');
print '</td>';
if ($action != 'editdocref')
print '<td class="right"><a class="editfielda" 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" 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 '</td><td>';
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.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">';
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->doc_ref ;
print $object->doc_ref;
}
print '</td>';
print '</tr>';
@ -514,17 +514,17 @@ if ($action == 'create')
print '<table class="border tableforfield" width="100%">';
// Doc type
if(! empty($object->doc_type))
if (!empty($object->doc_type))
{
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Doctype") . '</td>';
print '<td>' . $object->doc_type . '</td>';
print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
print '<td>'.$object->doc_type.'</td>';
print '</tr>';
}
// Date document creation
print '<tr>';
print '<td class="titlefield">' . $langs->trans("DateCreation") . '</td>';
print '<td class="titlefield">'.$langs->trans("DateCreation").'</td>';
print '<td>';
print $object->date_creation ? dol_print_date($object->date_creation, 'day') : '&nbsp;';
print '</td>';
@ -536,11 +536,11 @@ if ($action == 'create')
print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>';
if (empty($object->validated)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">';
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=disable">';
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
@ -586,16 +586,16 @@ if ($action == 'create')
} else {
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.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
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_ref" value="' . $object->doc_ref . '">' . "\n";
print '<input type="hidden" name="code_journal" value="' . $object->code_journal . '">' . "\n";
print '<input type="hidden" name="fk_doc" value="' . $object->fk_doc . '">' . "\n";
print '<input type="hidden" name="fk_docdet" value="' . $object->fk_docdet . '">' . "\n";
print '<input type="hidden" name="mode" value="' . $mode . '">' . "\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_ref" value="'.$object->doc_ref.'">'."\n";
print '<input type="hidden" name="code_journal" value="'.$object->code_journal.'">'."\n";
print '<input type="hidden" name="fk_doc" value="'.$object->fk_doc.'">'."\n";
print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'">'."\n";
print '<input type="hidden" name="mode" value="'.$mode.'">'."\n";
print "<table class=\"noborder\" width=\"100%\">";
if (count($object->linesmvt) > 0) {
@ -620,12 +620,12 @@ if ($action == 'create')
if ($action == 'update' && $line->id == $id) {
print '<td>';
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array (), 1, 1, '');
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// 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.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1);
}
@ -634,30 +634,30 @@ if ($action == 'create')
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
}
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . (GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation). '"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="' . (GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)) . '"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value="' . (GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)) . '"></td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value="'.(GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)).'"></td>';
print '<td>';
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">';
print '<input type="hidden" name="id" value="'.$line->id.'">'."\n";
print '<input type="submit" class="button" name="update" value="'.$langs->trans("Update").'">';
print '</td>';
} else {
$accountingaccount->fetch(null, $line->numero_compte, true);
print '<td>' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_operation. '</td>';
print '<td class="nowrap right">' . price($line->debit) . '</td>';
print '<td class="nowrap right">' . price($line->credit) . '</td>';
print '<td>'.$accountingaccount->getNomUrl(0, 1, 1, '', 0).'</td>';
print '<td>'.length_accounta($line->subledger_account).'</td>';
print '<td>'.$line->label_operation.'</td>';
print '<td class="nowrap right">'.price($line->debit).'</td>';
print '<td class="nowrap right">'.price($line->credit).'</td>';
print '<td class="center">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
print img_edit();
print '</a> &nbsp;';
$actiontodelete='delete';
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete='confirm_delete';
$actiontodelete = 'delete';
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete = 'confirm_delete';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action='.$actiontodelete.'&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
print img_delete();
print '</a>';
@ -677,12 +677,12 @@ if ($action == 'create')
if ($action == "" || $action == 'add') {
print '<tr class="oddeven">';
print '<td>';
print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, '');
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// 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.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount('', 'subledger_account', 1);
}
@ -694,19 +694,19 @@ if ($action == 'create')
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';
print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>';
print '<td><input type="submit" class="button" name="save" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
}
print '</table>';
if ($mode=='_tmp' && $action=='')
if ($mode == '_tmp' && $action == '')
{
print '<br>';
print '<div class="center">';
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
{
@ -714,7 +714,7 @@ if ($action == 'create')
}
print ' &nbsp; ';
print '<a class="button" href="' . DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">'.$langs->trans("Cancel").'</a>';
print '<a class="button" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">'.$langs->trans("Cancel").'</a>';
print "</div>";
}

View File

@ -25,14 +25,14 @@
* \brief List operation of book keeping
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy"));
@ -88,7 +88,7 @@ $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
// Load variable for pagination
$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');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -107,12 +107,12 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && ! GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !isset($_POST['begin']) && !isset($_GET['begin']) && !isset($_POST['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'))
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.= " 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);
if ($res->num_rows > 0) {
@ -120,9 +120,9 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} 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');
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;
$month_end = $month_start - 1;
if ($month_end < 1)
@ -137,7 +137,7 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !
}
$arrayfields=array(
$arrayfields = array(
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
@ -155,7 +155,7 @@ $arrayfields=array(
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
$listofformat=AccountancyExport::getType();
$listofformat = AccountancyExport::getType();
$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV;
if (empty($listofformat[$formatexportset])) $formatexportset = 1;
@ -166,8 +166,8 @@ $error = 0;
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
@ -318,7 +318,7 @@ if (empty($reshook))
if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
$import_key = GETPOST('importkey', 'alpha');
if (! empty($import_key)) {
if (!empty($import_key)) {
$result = $object->deleteByImportkey($import_key);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -331,15 +331,15 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri
}
if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
$delyear = GETPOST('delyear', 'int');
if ($delyear==-1) {
$delyear=0;
if ($delyear == -1) {
$delyear = 0;
}
$deljournal = GETPOST('deljournal', 'alpha');
if ($deljournal==-1) {
$deljournal=0;
if ($deljournal == -1) {
$deljournal = 0;
}
if (! empty($delyear) || ! empty($deljournal))
if (!empty($delyear) || !empty($deljournal))
{
$result = $object->deleteByYearAndJournal($delyear, $deljournal);
if ($result < 0) {
@ -351,7 +351,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: list.php".($param?'?'.$param:''));
header("Location: list.php".($param ? '?'.$param : ''));
exit;
}
else
@ -362,7 +362,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
$mvt_num = GETPOST('mvt_num', 'int');
if (! empty($mvt_num)) {
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -372,15 +372,15 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
header("Location: list.php?noreset=1".($param?'&'.$param:''));
header("Location: list.php?noreset=1".($param ? '&'.$param : ''));
exit;
}
}
if ($action == 'setreexport') {
$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) {
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
} else {
@ -421,27 +421,27 @@ $sql .= " t.piece_num,";
$sql .= " t.date_creation,";
$sql .= " t.tms as date_modification,";
$sql .= " t.date_export";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t';
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
// Manage filter
$sqlwhere = array ();
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.doc_date') {
$sqlwhere[] = $key . '=\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'=\''.$db->idate($value).'\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
$sqlwhere[] = $key . '\'' . $db->escape($value) . '\'';
$sqlwhere[] = $key.'\''.$db->escape($value).'\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value;
$sqlwhere[] = $key.'='.$value;
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $db->escape($value) . '%\'';
$sqlwhere[] = $key.' LIKE \''.$db->escape($value).'%\'';
} elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.tms>=' || $key == 't.tms<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} else {
@ -449,14 +449,14 @@ if (count($filter) > 0) {
}
}
}
$sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')';
$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
if ($conf->global->ACCOUNTING_REEXPORT == 0) {
$sql .= " AND t.date_export IS NULL";
}
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' AND ', $sqlwhere);
$sql .= ' AND '.implode(' AND ', $sqlwhere);
}
if (! empty($sortfield)) {
if (!empty($sortfield)) {
$sql .= $db->order($sortfield, $sortorder);
}
//print $sql;
@ -478,14 +478,14 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
$accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines, $formatexportset);
if (! empty($accountancyexport->errors))
if (!empty($accountancyexport->errors))
{
setEventMessages('', $accountancyexport->errors, 'errors');
}
else
{
// Specify as export : update field date_export
$error=0;
$error = 0;
$db->begin();
if (is_array($object->lines))
@ -494,13 +494,13 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
{
$now = dol_now();
$sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping";
$sql .= " SET date_export = '" . $db->idate($now) . "'";
$sql .= " WHERE rowid = " . $movement->id;
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_export = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id;
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);
if (! $result)
if (!$result)
{
$error++;
break;
@ -508,7 +508,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
}
}
if (! $error)
if (!$error)
{
$db->commit();
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
@ -550,10 +550,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
}
else
{
$sql.= $db->plimit($limit+1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
$resql=$db->query($sql);
if (! $resql)
$resql = $db->query($sql);
if (!$resql)
{
dol_print_error($db);
exit;
@ -574,9 +574,9 @@ if ($action == 'delmouv') {
print $formconfirm;
}
if ($action == 'delbookkeepingyear') {
$form_question = array ();
$delyear = GETPOST('delyear');
$deljournal = GETPOST('deljournal');
$form_question = array();
$delyear = GETPOST('delyear', 'int');
$deljournal = GETPOST('deljournal', 'alpha');
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
@ -584,16 +584,16 @@ if ($action == 'delbookkeepingyear') {
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
$form_question['delyear'] = array (
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$form_question['deljournal'] = array (
$form_question['deljournal'] = array(
'name' => 'deljournal',
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('DelJournal'),
'value' => $journal_array,
'default' => $deljournal
@ -604,10 +604,10 @@ if ($action == 'delbookkeepingyear') {
}
//$param=''; param started before
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$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="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -620,27 +620,27 @@ if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList");
else $buttonLabel = $langs->trans("ExportList");
// Button re-export
if (! empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton ='<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
} else {
$newcardbutton ='<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
}
$newcardbutton.= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
$newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
$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($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('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
@ -650,52 +650,52 @@ print '<table class="tagtable liste centpercent">';
// Filters lines
print '<tr class="liste_titre_filter">';
// 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>';
}
// Date document
if (! empty($arrayfields['t.doc_date']['checked']))
if (!empty($arrayfields['t.doc_date']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
print $langs->trans('From').' ';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
print $langs->trans('to').' ';
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// 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
if (! empty($arrayfields['t.numero_compte']['checked']))
if (!empty($arrayfields['t.numero_compte']['checked']))
{
print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '</td>';
}
// Subledger account
if (! empty($arrayfields['t.subledger_account']['checked']))
if (!empty($arrayfields['t.subledger_account']['checked']))
{
print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
// 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.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
}
@ -708,7 +708,7 @@ if (! empty($arrayfields['t.subledger_account']['checked']))
print $langs->trans('to').' ';
// 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.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
}
@ -720,111 +720,111 @@ if (! empty($arrayfields['t.subledger_account']['checked']))
print '</td>';
}
// Label operation
if (! empty($arrayfields['t.label_operation']['checked']))
if (!empty($arrayfields['t.label_operation']['checked']))
{
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>';
}
// Debit
if (! empty($arrayfields['t.debit']['checked']))
if (!empty($arrayfields['t.debit']['checked']))
{
print '<td class="liste_titre right">';
print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
print '</td>';
}
// Credit
if (! empty($arrayfields['t.credit']['checked']))
if (!empty($arrayfields['t.credit']['checked']))
{
print '<td class="liste_titre right">';
print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
print '</td>';
}
// Lettering code
if (! empty($arrayfields['t.lettering_code']['checked']))
if (!empty($arrayfields['t.lettering_code']['checked']))
{
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 '</td>';
}
// 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="' . $search_ledger_code . '"></td>';
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.$search_ledger_code.'"></td>';
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['t.date_creation']['checked']))
if (!empty($arrayfields['t.date_creation']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $langs->trans('From').' ';
print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $langs->trans('to').' ';
print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Date modification
if (! empty($arrayfields['t.tms']['checked']))
if (!empty($arrayfields['t.tms']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $langs->trans('From').' ';
print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $langs->trans('to').' ';
print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Date export
if (! empty($arrayfields['t.date_export']['checked']))
if (!empty($arrayfields['t.date_export']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $langs->trans('From').' ';
print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $langs->trans('to').' ';
print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Action column
print '<td class="liste_titre center">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>\n";
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.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.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 ');
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 ');
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.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.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 ');
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 ');
// Hook fields
$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
$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
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.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 ');
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.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 "</tr>\n";
@ -833,12 +833,12 @@ $line = new BookKeepingLine();
// Loop on record
// --------------------------------------------------------------------
$i=0;
$totalarray=array();
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) break; // Should not happen
$line->id = $obj->rowid;
$line->doc_date = $db->jdate($obj->doc_date);
@ -1006,8 +1006,8 @@ print '</div>';
// TODO Replace this with mass delete action
if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">' . "\n";
print '<a class="butActionDelete" name="button_delmvt" href="' . $_SERVER["PHP_SELF"] . '?action=delbookkeepingyear' . ($param ? '&' . $param : '') . '">' . $langs->trans("DeleteMvt") . '</a>';
print '<div class="tabsAction tabsActionNoBottom">'."\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
print '</div>';
}

View File

@ -27,12 +27,12 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy"));
@ -59,7 +59,7 @@ $search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
// Load variable for pagination
$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');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -81,9 +81,9 @@ if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} 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');
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;
$month_end = $month_start - 1;
if ($month_end < 1)
@ -112,76 +112,76 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_label_operation = '';
$search_direction = '';
$search_ledger_code = '';
$search_date_start='';
$search_date_end='';
$search_date_startyear='';
$search_date_startmonth='';
$search_date_startday='';
$search_date_endyear='';
$search_date_endmonth='';
$search_date_endday='';
$search_date_start = '';
$search_date_end = '';
$search_date_startyear = '';
$search_date_startmonth = '';
$search_date_startday = '';
$search_date_endyear = '';
$search_date_endmonth = '';
$search_date_endday = '';
$search_debit = '';
$search_credit = '';
}
// Must be after the remove filter action, before the export.
$param = '';
$filter = array ();
$filter = array();
if (! empty($search_date_start)) {
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int');
$param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int');
}
if (! empty($search_date_end)) {
if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int');
$param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int');
}
if (! empty($search_doc_date)) {
if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int');
$param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int');
}
if (! empty($search_accountancy_code_start)) {
if (!empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
}
if (! empty($search_accountancy_code_end)) {
if (!empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
}
if (! empty($search_label_account)) {
if (!empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account;
$param .= '&search_label_compte=' . urlencode($search_label_account);
$param .= '&search_label_compte='.urlencode($search_label_account);
}
if (! empty($search_doc_ref)) {
if (!empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref=' . urlencode($search_doc_ref);
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
}
if (! empty($search_label_operation)) {
if (!empty($search_label_operation)) {
$filter['t.label_operation'] = $search_label_operation;
$param .= '&search_label_operation=' . urlencode($search_label_operation);
$param .= '&search_label_operation='.urlencode($search_label_operation);
}
if (! empty($search_direction)) {
if (!empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$param .= '&search_direction=' . urlencode($search_direction);
$param .= '&search_direction='.urlencode($search_direction);
}
if (! empty($search_ledger_code)) {
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code=' . urlencode($search_ledger_code);
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
}
if (! empty($search_debit)) {
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit=' . urlencode($search_debit);
$param .= '&search_debit='.urlencode($search_debit);
}
if (! empty($search_credit)) {
if (!empty($search_credit)) {
$filter['t.credit'] = $search_credit;
$param .= '&search_credit=' . urlencode($search_credit);
$param .= '&search_credit='.urlencode($search_credit);
}
if ($action == 'delmouvconfirm') {
$mvt_num = GETPOST('mvt_num', 'int');
if (! empty($mvt_num)) {
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -200,7 +200,7 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting"));
$title_page = $langs->trans("Bookkeeping").' '.strtolower($langs->trans("By")).' '.strtolower($langs->trans("AccountAccounting"));
llxHeader('', $title_page);
@ -236,7 +236,7 @@ if ($action == 'delbookkeepingyear') {
}
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$form_question['delyear'] = array (
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
@ -278,28 +278,28 @@ print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '</td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre center">';
print $langs->trans('From') . ': ';
print $langs->trans('From').': ';
print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1);
print '<br>';
print $langs->trans('to') . ': ';
print $langs->trans('to').': ';
print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1);
print '</td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="' . dol_escape_htmltag($search_doc_ref) . '"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="' . dol_escape_htmltag($search_label_operation) . '"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
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 center"><input type="text" name="search_ledger_code" size="3" value="' . dol_escape_htmltag($search_ledger_code) . '"></td>';
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.dol_escape_htmltag($search_ledger_code).'"></td>';
print '<td class="liste_titre right" colspan="2">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print '</tr>';
@ -321,9 +321,9 @@ $total_debit = 0;
$total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
$i=0;
$i = 0;
while ($i < min($num, $limit))
{
$line = $object->lines[$i];
@ -361,8 +361,8 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">';
print '<td>&nbsp;</td>';
print '<td class="right"><a href="./card.php?piece_num=' . $line->piece_num . '">'.$line->piece_num.'</a></td>';
print '<td class="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
print '<td class="right"><a href="./card.php?piece_num='.$line->piece_num.'">'.$line->piece_num.'</a></td>';
print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
// TODO Add a link according to doc_type and fk_doc
print '<td class="nowrap">';

View File

@ -67,7 +67,7 @@ $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
*/
$lettering = GETPOST('lettering', 'alpha');
if (! empty($lettering)) {
if (!empty($lettering)) {
$action = $lettering;
}
@ -127,8 +127,8 @@ if ($action == 'autolettrage') {
$form = new Form($db);
$formaccounting = new FormAccounting($db);
$title=$object->name." - ".$langs->trans('TabLetteringCustomer');
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
$title = $object->name." - ".$langs->trans('TabLetteringCustomer');
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
$head = societe_prepare_head($object);
@ -164,13 +164,13 @@ $solde = 0;
// Count total nb of records and calc total sum
$nbtotalofrecords = '';
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
dol_print_error($db);
exit();
}
$nbtotalofrecords = $db->num_rows($resql);
while ( $obj = $db->fetch_object($resql) ) {
while ($obj = $db->fetch_object($resql)) {
$debit += $obj->debit;
$credit += $obj->credit;
@ -181,7 +181,7 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
dol_print_error($db);
exit();
}

View File

@ -89,7 +89,7 @@ $lettering = new Lettering($db);
$object = new Societe($db);
$object->id = $socid;
$result = $object->fetch($socid);
if ($result<0)
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
@ -126,8 +126,8 @@ if ($action == 'autolettrage') {
$form = new Form($db);
$formaccounting = new FormAccounting($db);
$title=$object->name." - ".$langs->trans('TabLetteringSupplier');
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
$title = $object->name." - ".$langs->trans('TabLetteringSupplier');
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
$head = societe_prepare_head($object);
@ -159,7 +159,7 @@ $solde = 0;
// Count total nb of records and calc total sum
$nbtotalofrecords = '';
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
dol_print_error($db);
exit;

View File

@ -57,6 +57,12 @@ class AccountancyCategory // extends CommonObject
*/
public $table_element='c_accounting_category';
/**
* @var int ID
* @deprecated
*/
public $rowid;
/**
* @var int ID
*/

View File

@ -31,7 +31,7 @@
* \brief Class accountancy export
*/
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
/**
* Manage the different format accountancy export
@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
class AccountancyExport
{
// Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV
public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
public static $EXPORT_TYPE_AGIRIS = 10;
public static $EXPORT_TYPE_EBP = 15;
public static $EXPORT_TYPE_CEGID = 20;
@ -83,7 +83,7 @@ class AccountancyExport
$this->db = &$db;
$this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?"\n":($conf->global->ACCOUNTING_EXPORT_ENDLINE==1?"\n":"\r\n");
$this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n");
}
/**
@ -125,7 +125,7 @@ class AccountancyExport
*/
private static function getFormatCode($type)
{
$formatcode = array (
$formatcode = array(
self::$EXPORT_TYPE_CONFIGURABLE => 'csv',
self::$EXPORT_TYPE_CEGID => 'cegid',
self::$EXPORT_TYPE_COALA => 'coala',
@ -153,14 +153,14 @@ class AccountancyExport
{
global $conf, $langs;
return array (
return array(
'param' => array(
self::$EXPORT_TYPE_CONFIGURABLE => array(
'label' => $langs->trans('Modelcsv_configurable'),
'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT)?'txt':$conf->global->ACCOUNTING_EXPORT_FORMAT,
'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV)?',':$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?1:$conf->global->ACCOUNTING_EXPORT_ENDLINE,
'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE)?'%d%m%Y':$conf->global->ACCOUNTING_EXPORT_DATE,
'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ? 'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT,
'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ? ',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE,
'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ? '%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE,
),
self::$EXPORT_TYPE_CEGID => array(
'label' => $langs->trans('Modelcsv_CEGID'),
@ -209,11 +209,11 @@ class AccountancyExport
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
),
),
'cr'=> array (
'cr'=> array(
'1' => $langs->trans("Unix"),
'2' => $langs->trans("Windows")
),
'format' => array (
'format' => array(
'csv' => $langs->trans("csv"),
'txt' => $langs->trans("txt")
),
@ -231,13 +231,13 @@ class AccountancyExport
public function export(&$TData, $formatexportset)
{
global $conf, $langs;
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
// Define name of file to save
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
$type_export = 'general_ledger';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
switch ($formatexportset) {
@ -303,13 +303,13 @@ class AccountancyExport
$separator = ";";
$end_line = "\n";
print $date . $separator;
print $line->code_journal . $separator;
print length_accountg($line->numero_compte) . $separator;
print length_accounta($line->subledger_account) . $separator;
print $line->sens . $separator;
print price($line->montant) . $separator;
print $line->label_operation . $separator;
print $date.$separator;
print $line->code_journal.$separator;
print length_accountg($line->numero_compte).$separator;
print length_accounta($line->subledger_account).$separator;
print $line->sens.$separator;
print price($line->montant).$separator;
print $line->label_operation.$separator;
print $line->doc_ref;
print $end_line;
}
@ -328,22 +328,22 @@ class AccountancyExport
$separator = ";";
$end_line = "\n";
print $line->code_journal . $separator;
print $date . $separator;
print $line->piece_num . $separator;
print length_accountg($line->numero_compte) . $separator;
print '' . $separator;
print $line->label_operation . $separator;
print $date . $separator;
if ($line->sens=='D') {
print price($line->montant) . $separator;
print '' . $separator;
}elseif ($line->sens=='C') {
print '' . $separator;
print price($line->montant) . $separator;
print $line->code_journal.$separator;
print $date.$separator;
print $line->piece_num.$separator;
print length_accountg($line->numero_compte).$separator;
print ''.$separator;
print $line->label_operation.$separator;
print $date.$separator;
if ($line->sens == 'D') {
print price($line->montant).$separator;
print ''.$separator;
}elseif ($line->sens == 'C') {
print ''.$separator;
print price($line->montant).$separator;
}
print $line->doc_ref . $separator;
print $line->label_operation . $separator;
print $line->doc_ref.$separator;
print $line->label_operation.$separator;
print $end_line;
}
}
@ -362,15 +362,15 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $separator;
print $line->code_journal . $separator;
print length_accountg($line->numero_compte) . $separator;
print $line->piece_num . $separator;
print $line->doc_ref . $separator;
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print 'E' . $separator;
print length_accountg($line->subledger_account) . $separator;
print $date.$separator;
print $line->code_journal.$separator;
print length_accountg($line->numero_compte).$separator;
print $line->piece_num.$separator;
print $line->doc_ref.$separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print 'E'.$separator;
print length_accountg($line->subledger_account).$separator;
print $end_line;
}
}
@ -389,26 +389,26 @@ class AccountancyExport
$end_line = "\n";
foreach ($objectLines as $line) {
print $line->piece_num . $separator;
print $line->piece_num.$separator;
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $separator;
print $date.$separator;
if (empty($line->subledger_account)) {
print 'G' . $separator;
print length_accounta($line->numero_compte) . $separator;
print 'G'.$separator;
print length_accounta($line->numero_compte).$separator;
} else {
if (substr($line->numero_compte, 0, 3) == '411') {
print 'C' . $separator;
print 'C'.$separator;
}
if (substr($line->numero_compte, 0, 3) == '401') {
print 'F' . $separator;
print 'F'.$separator;
}
print length_accountg($line->subledger_account) . $separator;
print length_accountg($line->subledger_account).$separator;
}
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print dol_trunc($line->label_operation, 32) . $separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print dol_trunc($line->label_operation, 32).$separator;
print $end_line;
}
}
@ -423,23 +423,23 @@ class AccountancyExport
{
global $conf;
$end_line ="\r\n";
$end_line = "\r\n";
$i = 1;
$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
foreach ($TData as $data) {
$code_compta = $data->numero_compte;
if (! empty($data->subledger_account))
if (!empty($data->subledger_account))
$code_compta = $data->subledger_account;
$Tab = array ();
$Tab = array();
$Tab['num_ecriture'] = str_pad($i, 5);
$Tab['code_journal'] = str_pad($data->code_journal, 2);
$Tab['date_ecriture'] = $date_ecriture;
$Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
$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['type_montant'] = str_pad($data->sens, 1);
$Tab['vide'] = str_repeat(' ', 18);
@ -449,7 +449,7 @@ class AccountancyExport
$Tab['end_line'] = $end_line;
print implode($Tab);
$i ++;
$i++;
}
}
@ -463,17 +463,17 @@ class AccountancyExport
{
global $conf;
$end_line ="\r\n";
$end_line = "\r\n";
//We should use dol_now function not time however this is wrong date to transfert in accounting
//$date_ecriture = dol_print_date(dol_now(), $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) {
$code_compta = $data->numero_compte;
if (! empty($data->subledger_account))
if (!empty($data->subledger_account))
$code_compta = $data->subledger_account;
$Tab = array ();
$Tab = array();
$Tab['type_ligne'] = 'M';
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
$Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
@ -484,19 +484,19 @@ class AccountancyExport
//$Tab['date_ecriture'] = $date_ecriture;
$Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
$Tab['filler'] = ' ';
$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);
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
//elarifr le montant doit etre en centimes sans point decimal !
$Tab['montant'] = str_pad(abs($data->montant*100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
// $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
$Tab['contrepartie'] = str_repeat(' ', 8);
// elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting
if (! empty($data->date_echeance))
if (!empty($data->date_echeance))
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
else
$Tab['date_echeance'] = '000000';
@ -551,20 +551,20 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->id . $separator;
print $date . $separator;
print $line->code_journal . $separator;
print $line->id.$separator;
print $date.$separator;
print $line->code_journal.$separator;
if (empty($line->subledger_account)) {
print $line->numero_compte . $separator;
print $line->numero_compte.$separator;
} else {
print $line->subledger_account . $separator;
print $line->subledger_account.$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 price2num(abs($line->montant)).$separator;
print $line->sens.$separator;
print $date . $separator;
print $date.$separator;
//print 'EUR';
print $end_line;
}
@ -586,25 +586,25 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->piece_num . $separator;
print self::toAnsi($line->label_operation) . $separator;
print $date . $separator;
print self::toAnsi($line->label_operation) . $separator;
print $line->piece_num.$separator;
print self::toAnsi($line->label_operation).$separator;
print $date.$separator;
print self::toAnsi($line->label_operation).$separator;
if (empty($line->subledger_account)) {
print length_accountg($line->numero_compte) . $separator;
print self::toAnsi($line->label_compte) . $separator;
print length_accountg($line->numero_compte).$separator;
print self::toAnsi($line->label_compte).$separator;
} else {
print length_accounta($line->subledger_account) . $separator;
print self::toAnsi($line->subledger_label) . $separator;
print length_accounta($line->subledger_account).$separator;
print self::toAnsi($line->subledger_label).$separator;
}
print self::toAnsi($line->doc_ref) . $separator;
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print price($line->montant) . $separator;
print $line->sens . $separator;
print $line->lettering_code . $separator;
print self::toAnsi($line->doc_ref).$separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print price($line->montant).$separator;
print $line->sens.$separator;
print $line->lettering_code.$separator;
print $line->code_journal;
print $end_line;
}
@ -625,17 +625,17 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $separator;
print $line->code_journal . $separator;
print $date.$separator;
print $line->code_journal.$separator;
if (empty($line->subledger_account)) {
print length_accountg($line->numero_compte) . $separator;
print length_accountg($line->numero_compte).$separator;
} else {
print length_accounta($line->subledger_account) . $separator;
print length_accounta($line->subledger_account).$separator;
}
print $line->doc_ref . $separator;
print $line->label_operation . $separator;
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print $line->doc_ref.$separator;
print $line->label_operation.$separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print $end_line;
}
@ -668,7 +668,7 @@ class AccountancyExport
$tab[] = price2num($line->montant);
$tab[] = $line->code_journal;
print implode($separator, $tab) . $this->end_line;
print implode($separator, $tab).$this->end_line;
}
}
@ -683,23 +683,23 @@ class AccountancyExport
$separator = "\t";
$end_line = "\n";
print "JournalCode" . $separator;
print "JournalLib" . $separator;
print "EcritureNum" . $separator;
print "EcritureDate" . $separator;
print "CompteNum" . $separator;
print "CompteLib" . $separator;
print "CompAuxNum" . $separator;
print "CompAuxLib" . $separator;
print "PieceRef" . $separator;
print "PieceDate" . $separator;
print "EcritureLib" . $separator;
print "Debit" . $separator;
print "Credit" . $separator;
print "EcritureLet" . $separator;
print "DateLet" . $separator;
print "ValidDate" . $separator;
print "Montantdevise" . $separator;
print "JournalCode".$separator;
print "JournalLib".$separator;
print "EcritureNum".$separator;
print "EcritureDate".$separator;
print "CompteNum".$separator;
print "CompteLib".$separator;
print "CompAuxNum".$separator;
print "CompAuxLib".$separator;
print "PieceRef".$separator;
print "PieceDate".$separator;
print "EcritureLib".$separator;
print "Debit".$separator;
print "Credit".$separator;
print "EcritureLet".$separator;
print "DateLet".$separator;
print "ValidDate".$separator;
print "Montantdevise".$separator;
print "Idevise";
print $end_line;
@ -709,55 +709,55 @@ class AccountancyExport
$date_valid = dol_print_date($line->date_validated, '%d%m%Y');
// FEC:JournalCode
print $line->code_journal . $separator;
print $line->code_journal.$separator;
// FEC:JournalLib
print $line->journal_label . $separator;
print $line->journal_label.$separator;
// FEC:EcritureNum
print $line->piece_num . $separator;
print $line->piece_num.$separator;
// FEC:EcritureDate
print $date_creation . $separator;
print $date_creation.$separator;
// FEC:CompteNum
print $line->numero_compte . $separator;
print $line->numero_compte.$separator;
// FEC:CompteLib
print $line->label_compte . $separator;
print $line->label_compte.$separator;
// FEC:CompAuxNum
print $line->subledger_account . $separator;
print $line->subledger_account.$separator;
// FEC:CompAuxLib
print $line->subledger_label . $separator;
print $line->subledger_label.$separator;
// FEC:PieceRef
print $line->doc_ref . $separator;
print $line->doc_ref.$separator;
// FEC:PieceDate
print $date_doc . $separator;
print $date_doc.$separator;
// FEC:EcritureLib
print $line->label_operation . $separator;
print $line->label_operation.$separator;
// FEC:Debit
print price2num($line->debit) . $separator;
print price2num($line->debit).$separator;
// FEC:Credit
print price2num($line->credit) . $separator;
print price2num($line->credit).$separator;
// FEC:EcritureLet
print $line->lettering_code . $separator;
print $line->lettering_code.$separator;
// FEC:DateLet
print $line->date_lettering . $separator;
print $line->date_lettering.$separator;
// FEC:ValidDate
print $date_valid . $separator;
print $date_valid.$separator;
// FEC:Montantdevise
print $line->multicurrency_amount . $separator;
print $line->multicurrency_amount.$separator;
// FEC:Idevise
print $line->multicurrency_code;
@ -785,121 +785,121 @@ class AccountancyExport
// Print header line
print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
print $this->end_line;
$thisPieceNum= "";
$thisPieceAccountNr= "";
$aSize= count($objectLines);
$thisPieceNum = "";
$thisPieceAccountNr = "";
$aSize = count($objectLines);
foreach ($objectLines as $aIndex=>$line)
{
$sammelBuchung= false;
if ($aIndex-2 >= 0 && $objectLines[$aIndex-2]->piece_num == $line->piece_num)
$sammelBuchung = false;
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
&& $objectLines[$aIndex+1]->piece_num == $line->piece_num
&& $aIndex-1 < $aSize
&& $objectLines[$aIndex-1]->piece_num == $line->piece_num
elseif ($aIndex + 1 < $aSize
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num
&& $aIndex - 1 < $aSize
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num
)
{
$sammelBuchung= true;
$sammelBuchung = true;
}
//Blg
print $line->piece_num . $this->separator;
print $line->piece_num.$this->separator;
// Datum
$date = dol_print_date($line->doc_date, '%d.%m.%Y');
print $date . $this->separator;
print $date.$this->separator;
// Kto
print length_accountg($line->numero_compte) . $this->separator;
print length_accountg($line->numero_compte).$this->separator;
// S/H
if ($line->sens == 'D')
{
print 'S' . $this->separator;
print 'S'.$this->separator;
}
else
{
print 'H' . $this->separator;
print 'H'.$this->separator;
}
//Grp
print self::trunc($line->code_journal, 1) . $this->separator;
print self::trunc($line->code_journal, 1).$this->separator;
// GKto
if (empty($line->code_tiers))
{
if ($line->piece_num == $thisPieceNum)
{
print length_accounta($thisPieceAccountNr) . $this->separator;
print length_accounta($thisPieceAccountNr).$this->separator;
}
else
{
print "div" . $this->separator;
print "div".$this->separator;
}
}
else
{
print length_accounta($line->code_tiers) . $this->separator;
print length_accounta($line->code_tiers).$this->separator;
}
//SId
print $this->separator;
//SIdx
print "0" . $this->separator;
print "0".$this->separator;
//KIdx
print "0" . $this->separator;
print "0".$this->separator;
//BTyp
print "0" . $this->separator;
print "0".$this->separator;
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
if ($sammelBuchung)
{
print "2" . $this->separator;
print "2".$this->separator;
}
else
{
print "1" . $this->separator;
print "1".$this->separator;
}
// Code
print '""' . $this->separator;
print '""'.$this->separator;
// Netto
if ($line->montant >= 0)
{
print $line->montant . $this->separator;
print $line->montant.$this->separator;
}
else
{
print $line->montant*-1 . $this->separator;
print ($line->montant * -1).$this->separator;
}
// Steuer
print "0.00" . $this->separator;
print "0.00".$this->separator;
// FW-Betrag
print "0.00" . $this->separator;
print "0.00".$this->separator;
// 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)
{
$line1= "";
$line1 = "";
}
$line2= self::toAnsi($line->doc_ref, 29);
$line2 = self::toAnsi($line->doc_ref, 29);
if (strlen($line1) == 0)
{
$line1= $line2;
$line2= "";
$line1 = $line2;
$line2 = "";
}
if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
{
$line1= $line1 . ' / ' . $line2;
$line2= "";
$line1 = $line1.' / '.$line2;
$line2 = "";
}
print '"' . self::toAnsi($line1). '"' . $this->separator;
print '"'.self::toAnsi($line1).'"'.$this->separator;
// Tx2
print '"' . self::toAnsi($line2). '"' . $this->separator;
print '"'.self::toAnsi($line2).'"'.$this->separator;
//PkKey
print "0" . $this->separator;
print "0".$this->separator;
//OpId
print $this->separator;
@ -910,8 +910,8 @@ class AccountancyExport
if ($line->piece_num !== $thisPieceNum)
{
$thisPieceNum= $line->piece_num;
$thisPieceAccountNr= $line->numero_compte;
$thisPieceNum = $line->piece_num;
$thisPieceAccountNr = $line->numero_compte;
}
}
}
@ -932,23 +932,23 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
// TYPE
$type_enregistrement = 'E'; // For write movement
print $type_enregistrement . $separator;
print $type_enregistrement.$separator;
// JNAL
print substr($line->code_journal, 0, 2) . $separator;
print substr($line->code_journal, 0, 2).$separator;
// NECR
print $line->id . $separator;
print $line->id.$separator;
// NPIE
print $line->piece_num . $separator;
print $line->piece_num.$separator;
// DATP
print $date_document . $separator;
print $date_document.$separator;
// LIBE
print $line->label_operation . $separator;
print $line->label_operation.$separator;
// DATH
print $line->date_lim_reglement . $separator;
print $line->date_lim_reglement.$separator;
// CNPI
if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) {
@ -965,7 +965,7 @@ class AccountancyExport
} else {
$nature_piece = '';
}
print $nature_piece . $separator;
print $nature_piece.$separator;
// RACI
/*
if (! empty($line->subledger_account)) {
@ -983,28 +983,28 @@ class AccountancyExport
*/
print $separator; // deprecated CPTG & CPTA use instead
// MONT
print price(abs($line->montant), 0, '', 1, 2) . $separator;
print price(abs($line->montant), 0, '', 1, 2).$separator;
// CODC
print $line->sens . $separator;
print $line->sens.$separator;
// CPTG
print length_accountg($line->numero_compte) . $separator;
print length_accountg($line->numero_compte).$separator;
// DATE
print $date_creation . $separator;
print $date_creation.$separator;
// CLET
print $line->lettering_code . $separator;
print $line->lettering_code.$separator;
// DATL
print $line->date_lettering . $separator;
print $line->date_lettering.$separator;
// CPTA
if (! empty($line->subledger_account)) {
print length_accounta($line->subledger_account) . $separator;
if (!empty($line->subledger_account)) {
print length_accounta($line->subledger_account).$separator;
} else {
print $separator;
}
// CNAT
if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) {
print 'F' . $separator;
} elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) {
print 'C' . $separator;
if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
print 'F'.$separator;
} elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
print 'C'.$separator;
} else {
print $separator;
}
@ -1017,17 +1017,17 @@ class AccountancyExport
// DATV
print $separator;
// REFD
print $line->doc_ref . $separator;
print $line->doc_ref.$separator;
// CODH
print $separator;
// NSEQ
print $separator;
// MTDV
print '0' . $separator;
print '0'.$separator;
// CODV
print $separator;
// TXDV
print '0' . $separator;
print '0'.$separator;
// MOPM
print $separator;
// BONP
@ -1066,43 +1066,43 @@ class AccountancyExport
/*
* Charlemagne export need header
*/
print $langs->transnoentitiesnoconv('Date') . $separator;
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator;
print $langs->transnoentitiesnoconv('Amount') . $separator;
print 'S' . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator;
print $langs->transnoentitiesnoconv('Date').$separator;
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6).$separator;
print self::trunc($langs->transnoentitiesnoconv('Account'), 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60).$separator;
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20).$separator;
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60).$separator;
print $langs->transnoentitiesnoconv('Amount').$separator;
print 'S'.$separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60).$separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60).$separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60).$separator;
print $end_line;
foreach($objectLines as $line) {
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%Y%m%d');
print $date . $separator; //Date
print $date.$separator; //Date
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)) $account = $line->subledger_account;
else $account = $line->numero_compte;
print self::trunc($account, 15) . $separator;//Account number
print self::trunc($account, 15).$separator; //Account number
print self::trunc($line->label_compte, 60) . $separator;//Account label
print self::trunc($line->doc_ref, 20) . $separator;//Piece
print self::trunc($line->label_operation, 60) . $separator;//Operation label
print price(abs($line->montant)) . $separator;//Amount
print $line->sens . $separator;//Direction
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print self::trunc($line->label_compte, 60).$separator; //Account label
print self::trunc($line->doc_ref, 20).$separator; //Piece
print self::trunc($line->label_operation, 60).$separator; //Operation label
print price(abs($line->montant)).$separator; //Amount
print $line->sens.$separator; //Direction
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $end_line;
}
}
@ -1129,10 +1129,10 @@ class AccountancyExport
*/
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)
{
$retVal= mb_substr($retVal, 0, $size, 'Windows-1251');
$retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
}
return $retVal;
}

View File

@ -36,7 +36,7 @@ class AccountancySystem
/**
* @var string Error code (or message)
*/
public $error='';
public $error = '';
/**
* @var int ID
@ -48,7 +48,14 @@ class AccountancySystem
*/
public $fk_pcg_version;
/**
* @var string pcg type
*/
public $pcg_type;
/**
* @var string pcg subtype
*/
public $pcg_subtype;
/**
@ -61,7 +68,14 @@ class AccountancySystem
*/
public $label;
/**
* @var string account number
*/
public $account_number;
/**
* @var string account parent
*/
public $account_parent;
/**

View File

@ -29,12 +29,12 @@ class AccountingJournal extends CommonObject
/**
* @var string ID to identify managed object
*/
public $element='accounting_journal';
public $element = 'accounting_journal';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element='accounting_journal';
public $table_element = 'accounting_journal';
/**
* @var int Field with ID of parent key if this field has a parent
@ -42,8 +42,7 @@ class AccountingJournal extends CommonObject
public $fk_element = '';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
* @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 0;
@ -57,6 +56,9 @@ class AccountingJournal extends CommonObject
*/
public $rowid;
/**
* @var string Accounting journal code
*/
public $code;
/**
@ -64,9 +66,19 @@ class AccountingJournal extends CommonObject
*/
public $label;
public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
/**
* @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
*/
public $nature;
/**
* @var int is active or not
*/
public $active;
/**
* @var array array of lines
*/
public $lines;
/**
@ -93,29 +105,29 @@ class AccountingJournal extends CommonObject
if ($rowid || $journal_code)
{
$sql = "SELECT rowid, code, label, nature, active";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE";
if ($rowid) {
$sql .= " rowid = " . (int) $rowid;
$sql .= " rowid = ".(int) $rowid;
}
elseif ($journal_code)
{
$sql .= " code = '" . $this->db->escape($journal_code) . "'";
$sql .= " AND entity = " . $conf->entity;
$sql .= " code = '".$this->db->escape($journal_code)."'";
$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);
if ($result)
{
$obj = $this->db->fetch_object($result);
if ($obj) {
$this->id = $obj->rowid;
$this->id = $obj->rowid;
$this->rowid = $obj->rowid;
$this->code = $obj->code;
$this->ref = $obj->code;
$this->ref = $obj->code;
$this->label = $obj->label;
$this->nature = $obj->nature;
$this->active = $obj->active;
@ -127,8 +139,8 @@ class AccountingJournal extends CommonObject
}
else
{
$this->error = "Error " . $this->db->lasterror();
$this->errors[] = "Error " . $this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
$this->errors[] = "Error ".$this->db->lasterror();
}
}
return -1;
@ -149,38 +161,38 @@ class AccountingJournal extends CommonObject
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
$sql = "SELECT rowid, code, label, nature, active";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.code' || $key == 't.label' || $key == 't.nature') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
$sqlwhere[] = $key.'\''.$this->db->escape($value).'\'';
} elseif ($key == 't.rowid' || $key == 't.active') {
$sqlwhere[] = $key . '=' . $value;
$sqlwhere[] = $key.'='.$value;
}
}
}
$sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$sql .= " AND entity IN (".getEntity('accountancy').")";
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
}
if (! empty($sortfield)) {
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
if (!empty($limit)) {
$sql .= ' '.$this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
while ($obj = $this->db->fetch_object($resql)) {
$line = new self($this->db);
$line->id = $obj->rowid;
@ -196,10 +208,10 @@ class AccountingJournal extends CommonObject
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
return - 1;
return -1;
}
}
@ -217,34 +229,34 @@ class AccountingJournal extends CommonObject
{
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 = '';
$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>';
if (! empty($this->code))
$label .= '<br><b>'.$langs->trans('Code') . ':</b> ' . $this->code;
if (! empty($this->label))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $langs->transnoentities($this->label);
if ($moretitle) $label.=' - '.$moretitle;
$label = '<u>'.$langs->trans("ShowAccountingJournal").'</u>';
if (!empty($this->code))
$label .= '<br><b>'.$langs->trans('Code').':</b> '.$this->code;
if (!empty($this->label))
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$langs->transnoentities($this->label);
if ($moretitle) $label .= ' - '.$moretitle;
$linkclose='';
$linkclose = '';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowAccountingJournal");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
$label = $langs->trans("ShowAccountingJournal");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip"';
}
$linkstart='<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
if ($nourl)
{
@ -254,11 +266,11 @@ class AccountingJournal extends CommonObject
}
$label_link = $this->code;
if ($withlabel) $label_link .= ' - ' . $langs->transnoentities($this->label);
if ($withlabel) $label_link .= ' - '.$langs->transnoentities($this->label);
$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 != 2) $result.= $label_link;
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 != 2) $result .= $label_link;
$result .= $linkend;
return $result;
@ -292,7 +304,7 @@ class AccountingJournal extends CommonObject
if ($mode == 0)
{
$prefix='';
$prefix = '';
if ($nature == 9) return $langs->trans('AccountingJournalType9');
elseif ($nature == 5) return $langs->trans('AccountingJournalType5');
elseif ($nature == 4) return $langs->trans('AccountingJournalType4');

File diff suppressed because it is too large Load Diff

View File

@ -23,12 +23,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear->write)
if (!$user->rights->accounting->fiscalyear->write)
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');
else
{
$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;
$month_end = $month_start - 1;
@ -69,54 +69,54 @@ $year_current = $year_start;
llxHeader('', $langs->trans("Closure"));
$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>';
$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("Closure") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("Closure")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
print '<span class="opacitymedium">'.$langs->trans("DescClosure") . '</span><br>';
print '<span class="opacitymedium">'.$langs->trans("DescClosure").'</span><br>';
print '<br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="./validate.php">' . $langs->trans("ValidateMovements") . '</a>';
$buttonbind = '<a class="butAction" href="./validate.php">'.$langs->trans("ValidateMovements").'</a>';
print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
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"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT COUNT(b.rowid) as detail,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
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) . ",";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
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 .= " COUNT(b.rowid) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG);
dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven">';
for($i = 1; $i <= 12; $i ++) {
print '<td class="right">' . $row[$i] . '</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="right">'.$row[$i].'</td>';
}
print '<td class="right"><b>' . $row[13] . '</b></td>';
print '<td class="right"><b>'.$row[13].'</b></td>';
print '</tr>';
}

View File

@ -23,12 +23,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear->write)
if (!$user->rights->accounting->fiscalyear->write)
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');
else
{
$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;
$month_end = $month_start - 1;
@ -68,14 +68,14 @@ if ($action == 'validate')
// Update database
$db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
$sql .= " SET b.date_validated = '" . $db->idate($now) . "'";
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " SET b.date_validated = '".$db->idate($now)."'";
$sql .= ' WHERE b.date_validated IS NULL';
dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -91,13 +91,13 @@ if ($action == 'validate')
llxHeader('', $langs->trans("ValidateMovements"));
$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>';
$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("ValidateMovements") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
print $langs->trans("DescValidateMovements") . '<br>';
print $langs->trans("DescValidateMovements").'<br>';
print '<br>';
@ -108,38 +108,38 @@ print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="oddeven">';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td class="center">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td class="center">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td><b>'.$langs->trans("Total").'</b></td></tr>';
print '<tr class="oddeven">';
$sql = "SELECT COUNT(b.rowid) as detail,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
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) . ",";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
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 .= " COUNT(b.rowid) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG);
dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
for($i = 1; $i <= 12; $i ++) {
print '<td class="nowrap center">' . $row[$i] . '<br><br>';
print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected?' checked="checked"':'').'>';
print '</td>' ;
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap center">'.$row[$i].'<br><br>';
print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected ? ' checked="checked"' : '').'>';
print '</td>';
}
print '<td class="valigntop"><b>' . $row[13] . '</b></td>';
print '<td class="valigntop"><b>'.$row[13].'</b></td>';
}
$db->free($resql);
@ -149,7 +149,7 @@ if ($resql) {
print '</tr>';
print "</table>\n";
print '<br><div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?month=' . $year_current . '&action=validate"">' . $langs->trans("ValidateMovements") . '</a></div>';
print '<br><div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?month='.$year_current.'&action=validate"">'.$langs->trans("ValidateMovements").'</a></div>';
print '</div>';
// End of page

View File

@ -24,11 +24,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy"));
$langs->loadLangs(array("bills", "accountancy"));
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
@ -48,16 +48,16 @@ if ($user->socid > 0)
if ($action == 'ventil' && $user->rights->accounting->bind->write)
{
if (! $cancel)
if (!$cancel)
{
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
$sql .= " SET fk_code_ventilation = ".$codeventil;
$sql .= " WHERE rowid = ".$id;
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors');
}
else
@ -93,18 +93,18 @@ $form = new Form($db);
$facture_static = new Facture($db);
$formaccounting = new FormAccounting($db);
if (! empty($id)) {
if (!empty($id)) {
$sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,";
$sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,";
$sql .= " l.fk_code_ventilation, aa.account_number, aa.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id;
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
dol_syslog("/accounting/customer/card.php sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
@ -114,8 +114,8 @@ if (! empty($id)) {
if ($num_lines) {
$objp = $db->fetch_object($result);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
@ -126,15 +126,15 @@ if (! empty($id)) {
print '<table class="border centpercent">';
// Ref facture
print '<tr><td>' . $langs->trans("Invoice") . '</td>';
print '<tr><td>'.$langs->trans("Invoice").'</td>';
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
print '<td>'.$facture_static->getNomUrl(1).'</td>';
print '</tr>';
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
print '<td>' . nl2br($objp->description) . '</td></tr>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print '<tr><td width="20%">'.$langs->trans("Line").'</td>';
print '<td>'.nl2br($objp->description).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Account").'</td><td>';
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
@ -142,9 +142,9 @@ if (! empty($id)) {
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';

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