commit
5de7bfffa6
@ -93,8 +93,8 @@ script:
|
||||
- php upgrade.php 3.5.0 3.6.0 >> upgrade.log
|
||||
- php upgrade2.php 3.5.0 3.6.0 >> upgrade2.log
|
||||
- php upgrade.php 3.6.0 3.7.0 >> upgrade.log
|
||||
- php upgrade2.php 3.6.0 3.7.0 >> upgrade2.log
|
||||
# - cat upgrade.log
|
||||
- php upgrade2.php 3.6.0 3.7.0 >> upgrade2.log
|
||||
# - cat upgrade2.log
|
||||
- cd ../..
|
||||
- date
|
||||
|
||||
12
.tx/config
12
.tx/config
@ -2,6 +2,12 @@
|
||||
host = https://www.transifex.com
|
||||
lang_map = uz: uz_UZ
|
||||
|
||||
[dolibarr.accountancy]
|
||||
file_filter = htdocs/langs/<lang>/accountancy.lang
|
||||
source_file = htdocs/langs/en_US/accountancy.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.admin]
|
||||
file_filter = htdocs/langs/<lang>/admin.lang
|
||||
source_file = htdocs/langs/en_US/admin.lang
|
||||
@ -266,12 +272,6 @@ source_file = htdocs/langs/en_US/sendings.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.shop]
|
||||
file_filter = htdocs/langs/<lang>/shop.lang
|
||||
source_file = htdocs/langs/en_US/shop.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.sms]
|
||||
file_filter = htdocs/langs/<lang>/sms.lang
|
||||
source_file = htdocs/langs/en_US/sms.lang
|
||||
|
||||
@ -19,9 +19,9 @@ FPDF_TPL 1.2 Apache Software License 2.0 Yes
|
||||
GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package)
|
||||
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
|
||||
odtPHP 1.0.1 GPL-2+ b Yes Library to build/edit ODT files
|
||||
PHPExcel 1.7.6 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
|
||||
PHPExcel 1.7.8 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
|
||||
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
|
||||
TCPDF 6.0.021 LGPL-3+ Yes PDF generation
|
||||
TCPDF 6.0.093 LGPL-3+ Yes PDF generation
|
||||
|
||||
JS libraries:
|
||||
jQuery 1.8.2 MIT License Yes JS library
|
||||
|
||||
152
ChangeLog
152
ChangeLog
@ -5,22 +5,39 @@ English Dolibarr ChangeLog
|
||||
|
||||
***** ChangeLog for 3.7 compared to 3.6.* *****
|
||||
For users:
|
||||
- New: extrafields for projects and tasks are exported to ODT documents.
|
||||
- New: Add number of active notification into tab title (like we do for notes and documents)
|
||||
- New: Can add product into category from category card.
|
||||
- New: PDF event report show project and status of event.
|
||||
- New: Can filter on status on interventions.
|
||||
- New: Add help info of field type into dictionary of payment types.
|
||||
- New: Add proposals into referer page of thirdparty.
|
||||
- New: On contact list can set filter on both active and not active (no more exclusive select).
|
||||
- New: Intervention documents are now available in ECM module.
|
||||
- New: Can attach supplier order to a customer order.
|
||||
- New: Supervisor is now visible into user list.
|
||||
- New: Add user of creation and validation on invoice export.
|
||||
- New: Add info page about browser.
|
||||
- New: Enable feature developed for 3.6 we forgot to enabled: Adding prefix
|
||||
on uploaded file names.
|
||||
- New: No more dependency between contract and service module.
|
||||
- New: [ task #867 ] Remove ESAEB external module code from core.
|
||||
- New: Can create proposal from an intervention.
|
||||
- New: An event can be assigned to several users.
|
||||
- New: Can filter events on a group of users.
|
||||
- New: Can filter events of a thirdparty.
|
||||
- New: Onto event summary of elements, end date and status are visible.
|
||||
- New: Split Agenda view (month, week, day) into different tabs.
|
||||
- New: Add a view "per user" of agenda events (with different colors according to type of event).
|
||||
- New: Each user can include its own external ics calendar into dolibarr agenda view.
|
||||
- New: Add event FICHINTER_CLASSIFY_BILLED into list of possible events to
|
||||
create an automatic event into agenda.
|
||||
- New: Add new type of event (when type of events are used, not by default).
|
||||
- New: Can disable predefined type of events.
|
||||
- New: Form to add a photo is immediatly available on photo page if
|
||||
permissions are ok (save one click per photo to add).
|
||||
- New: Add option PRODUCT_MAX_VISIBLE_PHOTO to limit number of photos
|
||||
shown on main product card.
|
||||
- New: Add event FICHINTER_CLASSIFY_BILLED into list of possible events to
|
||||
create an automatic event into agenda.
|
||||
- New: Add new type of event (when type of events are used, not by default)
|
||||
- New: Add country into table of thirdparties type. This will allow to provide
|
||||
a list of thirdparty types specific to a country (like argentina that
|
||||
need type A or B).
|
||||
@ -31,6 +48,23 @@ For users:
|
||||
Differentiate text and img.
|
||||
Use label into quick search form.
|
||||
Use accesskey on form search.
|
||||
- New: Intervention documents are now available in ECM module.
|
||||
- New: Add attachments on user card + in ECM module.
|
||||
- New: Can add __PROJECT_REF__ and __TIHRPARTY_NAME__ into email topic or content template.
|
||||
- New: [ task #1204 ] add Numering contrat module free (like leopard in product module).
|
||||
- New: [ task #712 ] Add warning when creating invoice from proposal or order, when there is already one invoice.
|
||||
- New: Enable supplier price log table.
|
||||
- New: [ task #1204 ] add a supplier reference to contract.
|
||||
- New: [ task #1218 ] Can drag and drop an event from calendar to change its day.
|
||||
- New: Optimize size of image static resources.
|
||||
- New: Add hourly and daily amount on user card. Add weekly working hours and salary on user card.
|
||||
- New: Content of predefined email come firstly from table llx_c_email_template, then translation key.
|
||||
- New: Add option MAIN_GENERATE_INVOICES_WITH_PICTURE to show picture
|
||||
onto PDF like MAIN_GENERATE_PROPOSALS_WITH_PICTURE dir for proposals.
|
||||
- New: Add more search field in list of cheque deposits.
|
||||
- New: Add feature to order to invoice on supplier part
|
||||
- Upgrade phpexcel lib to 1.7.8
|
||||
- New : Use of MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR to use disk cache for big excel export
|
||||
- Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action
|
||||
- Fix: [ bug #1470, #1472, #1473] User trigger problem
|
||||
- Fix: [ bug #1489, #1491 ] Intervention trigger problem
|
||||
@ -48,28 +82,96 @@ For users:
|
||||
- Fix: [ bug #1506, #1507 ] ECM trigger error problem
|
||||
- Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message
|
||||
- Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe.
|
||||
- New: [ task #1204 ] add a External reference to contract
|
||||
- New: Direct invoice creation from predefined invoice
|
||||
- New: Add dunning into accountancy report
|
||||
For users, new experimental module (need to set feature level of instance to experimental to see them):
|
||||
- New: Module Accounting Expert to manage accountancy
|
||||
Special Thanks to developpers :
|
||||
Olivier Geffroy
|
||||
Alexandre Spangaro
|
||||
Ari Elbaz
|
||||
Florian Henry
|
||||
Juanjo Menent
|
||||
And to the contributors :
|
||||
Jeff Info 2000 euros
|
||||
Nord Anim 120 euros
|
||||
Hydroflex 120 euros
|
||||
Asysteo 120 euros
|
||||
Fournisseur médical 120 euros
|
||||
- Removed: unmaintained OScommerce module
|
||||
|
||||
For translators:
|
||||
- Update language files.
|
||||
- New: When a translation is not available we always jump to en_US and only en_US.
|
||||
|
||||
For developers:
|
||||
- New: getBrowserInfo can return type of layout (classic/phone/tablet)
|
||||
- New: Add hook "searchAgendaFrom".
|
||||
- New: Add a css style "cursorpointer".
|
||||
- New: Select list of users can return user into hierarchy.
|
||||
- New: getBrowserInfo can return type of layout of browser (classic/phone/tablet)
|
||||
- New: Add hook "searchAgendaFrom" and "beforePDFCreation".
|
||||
- New: Add trigger DON_UPDATE, DON_DELETE
|
||||
- New: Add country iso code on 3 chars into table of countries.
|
||||
- Qual: Removed hard coded rowid into data init of table llx_c_action_trigger.
|
||||
- LINEBILL_DELETE, LINK_DELETE, ORDER_SUPPLIER_DELETE, RESOURCE_DELETE trigger called before SQL delete
|
||||
- New: [ Task #1481 ] Add trigger BILL_SUPPLIER_UPDATE.
|
||||
- New: [ Task #1495 ] Add trigger LINECONTRACT_CREATE.
|
||||
- New: Added hook "formConfirm" and "doActions" for supplier invoice card
|
||||
- New: [ task #1511, #1426 ] Added hook "doActions" for supplier card and supplier order card
|
||||
- New: Added hook "formConfirm" and "doActions" for supplier invoice card.
|
||||
- New: [ task #1511, #1426 ] Added hook "doActions" for supplier card and supplier order card.
|
||||
- New: renamed table llx_c_pays to llx_c_country & libelle field to label.
|
||||
- New: Added hook "formConfirm" and "doActions" for fichinter card
|
||||
- New: Can search list of thirdparties from web service on part of name.
|
||||
- Qual: Renamed table llx_c_civilite into llx_c_civility,
|
||||
field civilite into label in the same table,
|
||||
and field civilite into civility in other table.
|
||||
- Qual: Renamed all files & links "liste.php" into "list.php".
|
||||
- Qual: Renamed all files & links "fiche.php" into "card.php".
|
||||
- Qual: Replace all constants COMPTA_* by ACCOUNTING_*.
|
||||
- Qual: Replace all constants ACCOUNTINGEX_* by ACCOUNTING_* to simplify migration of the module
|
||||
|
||||
WARNING: Following change may create regression for some external modules, but was necessary to make
|
||||
WARNING: Following changes may create regression for some external modules, but was necessary to make
|
||||
Dolibarr better:
|
||||
|
||||
- Change the way parameters are provides to scripts sync_xxx_ldap2dolibarr.php
|
||||
|
||||
- Deprecated module "oscommerce" were removed.
|
||||
- Changed the way parameters are provided to scripts sync_xxx_ldap2dolibarr.php
|
||||
- Some field into database were renamed from "libelle" to "label".
|
||||
- Table llx_c_pays were renamed into llx_c_country.
|
||||
- Triggers *_BUILDDOC are removed. Building a doc is not a business event. For action after
|
||||
creation of a pdf or odt, hook "afterPDFCreation" or "afterODTCreation" must be used instead.
|
||||
- A lot of pages called fiche.php were renamed into card.php
|
||||
- A lot of pages called liste.php were renamed into list.php
|
||||
|
||||
|
||||
|
||||
***** ChangeLog for 3.6.2 compared to 3.6.1 *****
|
||||
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice
|
||||
- Fix: bug 1588 : relative discount
|
||||
- Fix: label of input method not tranlated.
|
||||
|
||||
***** ChangeLog for 3.6.1 compared to 3.6.* *****
|
||||
For users:
|
||||
- Fix: Can upload files on services.
|
||||
- Fix: sql errors on updat fichinter.
|
||||
- Fix: debian script syntax error.
|
||||
- Fix: error "menu param is not inside list" into pos module.
|
||||
- Fix: Salary payments are not reflected on the reporting sheets.
|
||||
- Fix: Unsubscribe emailing not working.
|
||||
- Fix: Trigger on create category call failed because user is not passed on card.
|
||||
- Fix: list event view lost type event filter.
|
||||
- Fix: Save also code event.
|
||||
- Fix: VAT payment - Add control on field date value.
|
||||
- Fix: Salaries payment - Field date value is now required and add control on it.
|
||||
- Fix: Iban was used instead of Bic into SEPA file.
|
||||
- Fix: Must unaccent strings into SEPA file.
|
||||
- Fix: Extrafield feature select from table should try to translate multiple column when not needed
|
||||
- Fix: cents for indian ruppes are calle paisa and paise.
|
||||
- Fix: Invoices payments may be older than invoices.
|
||||
- Fix: Withdrawal total amount is double
|
||||
- Fix: [ bug #1593 ] Spanish Localtax IRPF not being calculated since 3.6.0 in supplier invoices when adding a line
|
||||
- Fix: Web service categorie WDSL declaration is correct
|
||||
- Fix: ErrorBadValueForParamNotAString was displayed in virtual product if no base price defined
|
||||
- Fix: Category creation failed and no message output
|
||||
- Fix: Lanf for Payment Type
|
||||
- Fix: PHPCheckstyle 1.5.5
|
||||
|
||||
***** ChangeLog for 3.6 compared to 3.5.* *****
|
||||
For users:
|
||||
@ -185,7 +287,34 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
|
||||
|
||||
|
||||
***** ChangeLog for 3.5.5 compared to 3.5.4 *****
|
||||
Fix: Holiday module was broken. Initializaion of amount of holidays failed.
|
||||
Fix: [ bug #1523 ] suite bug #1334 : filtre et ordre de tri conjoints ne s'appliquent pas.
|
||||
Fix: Fusion PDF button on unpaid invoice is no more displayed.
|
||||
Fix: Unpaid invoice launch fusion PDF action even if it is only search (with enter keyboard input instead of lens click).
|
||||
Fix: Pb when showing log list of holiday module with some mysql versions.
|
||||
Fix: Error with bad timezone pushed by some browsers.
|
||||
Fix: shipping list SQL request was not filtering on shipping element
|
||||
Fix: debian package provided by dolibarr team must use embedded libraries.
|
||||
Fix: [ bug #1528 ] Leopard Services numeration module description is not translated.
|
||||
Fix: [ bug #1523 ] suite bug #1334 : filtre et ordre de tri conjoints ne s'appliquent pas.
|
||||
Fix: [ bug #1534 ] Unknown error when deleting a product photo under special circumstances.
|
||||
Fix: Update impayees.php
|
||||
Fix: Link product, In list view and label product.
|
||||
Fix: visible task into area "time" for "My task" must limit task to tasks i am assigned to.
|
||||
Fix: When disabled, all fields to add time into task line must be disabled.
|
||||
Fix: Missing include files.lib.php in some pages that use dol_delete_recursive
|
||||
Fix: [ bug #1558 ] Product/service edit page title shows new Ref instead of old ref.
|
||||
Fix: [ bug #1553 ] Saving User displays setup removes menu.
|
||||
Fix: [ bug #1544 ] Can remove date from invoice.
|
||||
Fix: list event view lost type event filter.
|
||||
Fix: Add code save on create event.
|
||||
Fix: SQL injection.
|
||||
Fix: [ bug #1589 ] Menu type in "Edit menu" page is not translated
|
||||
Fix: [ bug #1591 ] Linked object block shows Total HT/TTC even if not having permission to read them
|
||||
Fix: [ bug #1577 ] When creating new Private individual third, selected third type is ignored
|
||||
Fix: [ bug #1555 ] Update accountancy code of products does not throw PRODUCT_MODIFY trigger
|
||||
Fix: [ bug #1548 ] Supplier payment card shows type in French
|
||||
Fix: [ bug #1546 ] Incorrect page number when searching in the list of bank transactions
|
||||
|
||||
***** ChangeLog for 3.5.4 compared to 3.5.3 *****
|
||||
Fix: Hide title of event when agenda module disabled.
|
||||
@ -495,6 +624,7 @@ Fix: Add a limit into list to avoid browser to hang when database is too large.
|
||||
Fix: [ bug #1212 ] 'jqueryFileTree.php' directory traversal vulnerability
|
||||
Fix: Agenda and Banks module were not working with multicompany module
|
||||
Fix: [ bug #1317 ] Removing a category does not remove all child categories
|
||||
Fix: [ bug #1380 ] Customer invoices are not grouped in company results report.
|
||||
|
||||
***** ChangeLog for 3.4.2 compared to 3.4.1 *****
|
||||
Fix: field's problem into company's page (RIB).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="dolibarr" default="hudson" basedir=".">
|
||||
|
||||
fdfds
|
||||
<!-- Exclude/ignore paths -->
|
||||
<property name="ignorepaths" value="${basedir}/htdocs/conf,${basedir}/htdocs/core/filemanagerdol,${basedir}/htdocs/includes" />
|
||||
<property name="ignoreregexp" value="**/PEAR/*,**/NET/*,**/HTTP/*,**/zendgdata/*,**/reportico/*" />
|
||||
|
||||
@ -153,7 +153,9 @@ from origin/upstream and origin/pristine.
|
||||
|
||||
* Into root dir, launch:
|
||||
> debian/get-orig-source.sh
|
||||
If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0 " to solve this.
|
||||
If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0" to solve this.
|
||||
|
||||
* Some files are removed from archive by the get-orig-source.sh
|
||||
|
||||
* Staying into git root directory, run
|
||||
> git-import-orig -vv ../tcpdf_x.y.z+dfsg.orig.tar.xz
|
||||
@ -161,8 +163,8 @@ If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VER
|
||||
Note: If there was errors solved manually, you may need to make a git commit
|
||||
|
||||
* Add an entry into debian/changelog
|
||||
> dch -v x.y.z-dsfg-1 "My comment" will add entry.
|
||||
For example: dch -v x.y.z-dsfg-1 "New upstream release." for a new version
|
||||
> dch -v x.y.z+dfsg-1 "My comment" will add entry.
|
||||
For example: dch -v x.y.z+dfsg-1 "New upstream release." for a new version
|
||||
Then modify changelog to replace "version" or "unstable" with "UNRELEASED".
|
||||
|
||||
Warning: Date must have format reported by "date -R"
|
||||
@ -229,27 +231,28 @@ from origin/upstream and origin/pristine.
|
||||
|
||||
* If new upstream is available onto sourceforge, launch:
|
||||
> debian/get-orig-source.sh
|
||||
If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0 " to solve this.
|
||||
If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0" to solve this.
|
||||
|
||||
* Edit tgz file to remove
|
||||
- ckeditor
|
||||
- phpexcel
|
||||
- tcpdf
|
||||
- htdocs/includes/ckeditor
|
||||
- htdocs/includes/jquery/plugins/datatables/extras/TableTools/swf
|
||||
- htdocs/includes/phpexcel
|
||||
- htdocs/includes/tcpdf
|
||||
And rename file into
|
||||
dolibarr-x.y.z+dsfgw.tgz
|
||||
(x.y.z = version, w start from 1 and is increased for each new import)
|
||||
dolibarr-x.y.z+dfsgw.tgz
|
||||
(x.y.z = version, w start from 1 and is increased for each new git-import-orig already done)
|
||||
|
||||
* Staying into git root directory, run
|
||||
> git-import-orig -vv ../dolibarr-x.y.z+dsfgw.tgz
|
||||
> git-import-orig -vv ../dolibarr-x.y.z+dfsgw.tgz
|
||||
and enter version when requested with format
|
||||
x.y.z+dsfgw
|
||||
x.y.z+dfsgw
|
||||
(x.y.z = version, w start from 1 and is increased for each new import)
|
||||
|
||||
Note: If there was errors solved manually after get-orig-sources.sh, you may need to make a git commit
|
||||
|
||||
* Add an entry into debian/changelog
|
||||
> dch -v x.y.z-w "My comment" will add entry.
|
||||
For example: dch -v x.y.z-w "New upstream release." for a new version (x.y.z = version, w start from 1 and increaed for each new import)
|
||||
> dch -v x.y.z+dfsg-w "My comment" will add entry.
|
||||
For example: dch -v x.y.z+dfsgw-1 "New upstream release." for a new version (x.y.z = version, w start from 1 and increaed for each new import)
|
||||
Then modify changelog to replace "version" or "unstable" with "UNRELEASED".
|
||||
Then check/modify also the user/date signature:
|
||||
- Date must have format reported by "date -R"
|
||||
|
||||
@ -1,3 +1,10 @@
|
||||
dolibarr (3.6.1-3) unstable; urgency=low
|
||||
|
||||
[ Laurent Destailleur (eldy) ]
|
||||
* New upstream release.
|
||||
|
||||
-- Laurent Destailleur (eldy) <eldy@users.sourceforge.net> Tue, 23 Sep 2014 12:00:00 +0100
|
||||
|
||||
dolibarr (3.6.0-3) unstable; urgency=low
|
||||
|
||||
[ Laurent Destailleur (eldy) ]
|
||||
|
||||
@ -39,7 +39,7 @@ Description: Web based software to manage a company or foundation
|
||||
It's a web software you can install as a standalone program or on any web
|
||||
hosting provider to use it from anywhere with any web browser.
|
||||
.
|
||||
Dolibarr was designed to be easy to use. Only the features that you need
|
||||
Dolibarr was designed to be easy to use. Only the features that you need
|
||||
are visible, depending on which modules were activated.
|
||||
.
|
||||
This is an example of most common used modules:
|
||||
@ -68,4 +68,4 @@ Description: Web based software to manage a company or foundation
|
||||
PDF exports,
|
||||
And a lot more modules...
|
||||
.
|
||||
You can also add third parties external modules or develop yours.
|
||||
You can also add external modules from third parties or develop yours.
|
||||
|
||||
@ -61,7 +61,7 @@ License: GPL-3+
|
||||
Files: htdocs/includes/adodbtime/*
|
||||
Copyright: 2003-2005, John Lim
|
||||
unknown, jackbbs
|
||||
License: BSD
|
||||
License: BSD-3-Clause
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
@ -272,7 +272,7 @@ Comment:
|
||||
|
||||
Files: htdocs/includes/jquery/plugins/flot/*
|
||||
Copyright: Flot team
|
||||
License: Public Domain
|
||||
License: Public-Domain
|
||||
This work is not subject to copyright in any jurisdiction
|
||||
Comment:
|
||||
Those files are not shipped in the binary package because we configure
|
||||
|
||||
@ -129,21 +129,21 @@ case "$1" in
|
||||
then
|
||||
# Create an empty conf.php with permission to web server
|
||||
setup_empty_conf
|
||||
else
|
||||
#else
|
||||
# File already exist. We add params not found.
|
||||
echo Add new params to overwrite path to use shared libraries/fonts
|
||||
grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "<?php \$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>" >> $config
|
||||
grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "<?php \$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
|
||||
grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "<?php \$dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>" >> $config
|
||||
grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "<?php \$dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "<?php \$dolibarr_lib_PHPEXCEL_PATH=''; ?>" >> $config
|
||||
#grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "<?php \$dolibarr_lib_TCPDF_PATH=''; ?>" >> $config
|
||||
grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "<?php \$dolibarr_js_CKEDITOR='/javascript/ckeditor'; ?>" >> $config
|
||||
grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "<?php \$dolibarr_js_JQUERY='/javascript/jquery'; ?>" >> $config
|
||||
grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "<?php \$dolibarr_js_JQUERY_UI='/javascript/jquery-ui'; ?>" >> $config
|
||||
grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "<?php \$dolibarr_js_JQUERY_FLOT='/javascript/flot'; ?>" >> $config
|
||||
grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "<?php \$dolibarr_font_DOL_DEFAULT_TTF_BOLD='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf'; ?>" >> $config
|
||||
#echo Add new params to overwrite path to use shared libraries/fonts
|
||||
#grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "<?php \$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "<?php \$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>" >> $config
|
||||
##grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
|
||||
#grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "<?php \$dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "<?php \$dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>" >> $config
|
||||
##grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "<?php \$dolibarr_lib_PHPEXCEL_PATH=''; ?>" >> $config
|
||||
##grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "<?php \$dolibarr_lib_TCPDF_PATH=''; ?>" >> $config
|
||||
#grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "<?php \$dolibarr_js_CKEDITOR='/javascript/ckeditor'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "<?php \$dolibarr_js_JQUERY='/javascript/jquery'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "<?php \$dolibarr_js_JQUERY_UI='/javascript/jquery-ui'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "<?php \$dolibarr_js_JQUERY_FLOT='/javascript/flot'; ?>" >> $config
|
||||
#grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "<?php \$dolibarr_font_DOL_DEFAULT_TTF_BOLD='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf'; ?>" >> $config
|
||||
fi
|
||||
|
||||
db_get dolibarr/reconfigure-webserver
|
||||
|
||||
@ -1,23 +1,26 @@
|
||||
#!/bin/sh
|
||||
# Scan for new official sources and download file
|
||||
# run with debian/get-orig-source.sh [x.y.z]
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
echo "tmpdir = $tmpdir"
|
||||
|
||||
|
||||
# Download source file
|
||||
if [ -n "$1" ]; then
|
||||
uscan_opts="--download-version=$1"
|
||||
fi
|
||||
uscan --noconf --force-download --no-symlink --verbose --destdir=$tmpdir $uscan_opts
|
||||
#uscan --noconf --force-download --no-symlink --verbose --destdir=$tmpdir $uscan_opts
|
||||
|
||||
cd $tmpdir
|
||||
|
||||
# Other method to download (comment uscan if you use this)
|
||||
wget http://www.dolibarr.org/files/stable/standard/dolibarr-3.5.4.tgz
|
||||
|
||||
# Rename file to add +dfsg
|
||||
tgzfile=$(echo *.tgz)
|
||||
version=$(echo "$tgzfile" | perl -pi -e 's/^dolibarr-//; s/\.tgz$//; s/_/./g; s/\+nmu1//; ')
|
||||
|
||||
cd - >/dev/null
|
||||
|
||||
mv $tmpdir/dolibarr-${version}.tgz ../
|
||||
echo "File ../dolibarr-${version}.tgz is ready for git-import"
|
||||
echo "File ../dolibarr-${version}.tgz is ready for git-import-orig"
|
||||
|
||||
rm -rf $tmpdir
|
||||
|
||||
@ -17,9 +17,9 @@
|
||||
; ----- Change this -----
|
||||
AppName=DoliWamp
|
||||
; DoliWamp-x.x.x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x
|
||||
AppVerName=DoliWamp-3.6.0
|
||||
AppVerName=DoliWamp-3.6.1
|
||||
; DoliWamp-x.x x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x
|
||||
OutputBaseFilename=DoliWamp-3.6.0
|
||||
OutputBaseFilename=DoliWamp-3.6.1
|
||||
; ----- End of change
|
||||
;OutputManifestFile=build\doliwampbuild.log
|
||||
; Define full path from which all relative path are defined
|
||||
@ -32,7 +32,7 @@ AppPublisherURL=http://www.nltechno.com
|
||||
AppSupportURL=http://www.dolibarr.org
|
||||
AppUpdatesURL=http://www.dolibarr.org
|
||||
AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares.
|
||||
AppCopyright=Copyright (C) 2008-2013 Laurent Destailleur, NLTechno
|
||||
AppCopyright=Copyright (C) 2008-2014 Laurent Destailleur, NLTechno
|
||||
DefaultDirName=c:\dolibarr
|
||||
DefaultGroupName=Dolibarr
|
||||
;LicenseFile=COPYING
|
||||
@ -108,8 +108,8 @@ Source: "C:\Program Files\Wamp\bin\mysql\mysql5.0.45\*.*"; DestDir: "{app}\bin\m
|
||||
; Mysql data files (does not overwrite if exists)
|
||||
Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mysql\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db"
|
||||
; Dolibarr
|
||||
Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php"
|
||||
Source: "dev\*.*"; DestDir: "{app}\www\dolibarr\dev"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,dbmodel\*,fpdf\*,initdata\*,iso-normes\*,licence\*,phpcheckstyle\*,phpunit\*,samples\*,test\*,uml\*,xdebug\*"
|
||||
Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,nltechno*\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php"
|
||||
Source: "dev\*.*"; DestDir: "{app}\www\dolibarr\dev"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,dbmodel\*,fpdf\*,initdata\*,iso-normes\*,licence\*,phpcheckstyle\*,phpunit\*,samples\*,test\*,uml\*,vagrant\*,xdebug\*"
|
||||
Source: "doc\*.*"; DestDir: "{app}\www\dolibarr\doc"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,wiki\*,plaquette\*,dev\*,images\dolibarr_screenshot2.png,images\dolibarr_screenshot3.png,images\dolibarr_screenshot4.png,images\dolibarr_screenshot5.png,images\dolibarr_screenshot6.png,images\dolibarr_screenshot7.png,images\dolibarr_screenshot8.png,images\dolibarr_screenshot9.png,images\dolibarr_screenshot10.png,images\dolibarr_screenshot11.png,images\dolibarr_screenshot12.png"
|
||||
Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,product\materiel.net.php,product\import-product.php"
|
||||
Source: "*.*"; DestDir: "{app}\www\dolibarr"; Flags: ignoreversion; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,default.properties,install.lock"
|
||||
|
||||
@ -416,6 +416,7 @@ if ($nboftargetok) {
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/dev/spec`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/dev/test`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/dev/uml`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/dev/vagrant`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/dev/xdebug`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/dev/dolibarr_changes.txt`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/dev/README`;
|
||||
@ -441,6 +442,7 @@ if ($nboftargetok) {
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/nltechno*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/pos*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/test`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/Thumbs.db $BUILDROOT/$PROJECT/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/*/Thumbs.db`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/.cvsignore $BUILDROOT/$PROJECT/*/.cvsignore $BUILDROOT/$PROJECT/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.cvsignore`;
|
||||
@ -459,8 +461,8 @@ if ($nboftargetok) {
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PCLZip`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.33`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-20100919`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/LICENSE.TXT`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/savant`;
|
||||
@ -609,9 +611,6 @@ if ($nboftargetok) {
|
||||
|
||||
print "Version is $MAJOR.$MINOR.$REL1-$RPMSUBVERSION\n";
|
||||
|
||||
#print "Create directory $RPMDIR\n";
|
||||
#$ret=`mkdir -p "$RPMDIR"`;
|
||||
|
||||
print "Remove target ".$FILENAMERPM."...\n";
|
||||
unlink("$NEWDESTI/".$FILENAMERPM);
|
||||
print "Remove target ".$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm...\n";
|
||||
@ -619,13 +618,13 @@ if ($nboftargetok) {
|
||||
|
||||
print "Create directory $BUILDROOT/$FILENAMETGZ2\n";
|
||||
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2`;
|
||||
|
||||
print "Copy $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMETGZ2\n";
|
||||
$cmd="cp -pr '$BUILDROOT/$PROJECT' '$BUILDROOT/$FILENAMETGZ2'";
|
||||
$ret=`$cmd`;
|
||||
|
||||
# Set owners
|
||||
#print "Set owners on files/dir\n";
|
||||
#$ret=`chown -R root.root $BUILDROOT/$FILENAMETGZ2`;
|
||||
# Removed files we don't need
|
||||
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/htdocs/includes/ckeditor/_source`;
|
||||
|
||||
print "Set permissions on files/dir\n";
|
||||
$ret=`chmod -R 755 $BUILDROOT/$FILENAMETGZ2`;
|
||||
@ -746,10 +745,18 @@ if ($nboftargetok) {
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/rpm`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/zip`;
|
||||
# Removed duplicate license files
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/LICENSE.md`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/scayt/LICENSE.md`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/wsc/LICENSE.md`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/LICENSE.md`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/scayt/LICENSE.md`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/wsc/LICENSE.md`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/flot/LICENSE.txt`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/freefont-20120503/COPYING`;
|
||||
# Removed files we don't need
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source`;
|
||||
|
||||
# Rename upstream changelog to match debian rules
|
||||
$ret=`mv $BUILDROOT/$PROJECT.tmp/ChangeLog $BUILDROOT/$PROJECT.tmp/changelog`;
|
||||
|
||||
|
||||
@ -1,300 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#----------------------------------------------------------------------------
|
||||
# \file build/makepack-dolibarrlang.pl
|
||||
# \brief Package builder (tgz, zip, rpm, deb, exe)
|
||||
# \author (c)2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
use Cwd;
|
||||
|
||||
$PROJECT = "dolibarr";
|
||||
|
||||
@LISTETARGET = ("TGZ"); # Possible packages
|
||||
%REQUIREMENTTARGET = ( # Tool requirement for each package
|
||||
"TGZ" => "tar",
|
||||
"ZIP" => "7z",
|
||||
"EXE" => "makensis.exe"
|
||||
);
|
||||
%ALTERNATEPATH = (
|
||||
"7z" => "7-ZIP",
|
||||
"makensis.exe" => "NSIS"
|
||||
);
|
||||
|
||||
use vars qw/ $REVISION $VERSION /;
|
||||
$REVISION = '1.10';
|
||||
$VERSION = "1.0 (build $REVISION)";
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#------------------------------------------------------------------------------
|
||||
( $DIR = $0 ) =~ s/([^\/\\]+)$//;
|
||||
( $PROG = $1 ) =~ s/\.([^\.]*)$//;
|
||||
$Extension = $1;
|
||||
$DIR ||= '.';
|
||||
$DIR =~ s/([^\/\\])[\\\/]+$/$1/;
|
||||
|
||||
# Detect OS type
|
||||
# --------------
|
||||
if ( "$^O" =~ /linux/i || ( -d "/etc" && -d "/var" && "$^O" !~ /cygwin/i ) ) {
|
||||
$OS = 'linux';
|
||||
$CR = '';
|
||||
}
|
||||
elsif ( -d "/etc" && -d "/Users" ) { $OS = 'macosx'; $CR = ''; }
|
||||
elsif ( "$^O" =~ /cygwin/i || "$^O" =~ /win32/i ) {
|
||||
$OS = 'windows';
|
||||
$CR = "\r";
|
||||
}
|
||||
if ( !$OS ) {
|
||||
print "$PROG.$Extension was not able to detect your OS.\n";
|
||||
print "Can't continue.\n";
|
||||
print "$PROG.$Extension aborted.\n";
|
||||
sleep 2;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Define buildroot
|
||||
# ----------------
|
||||
if ( $OS =~ /linux/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp";
|
||||
}
|
||||
if ( $OS =~ /macos/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp";
|
||||
}
|
||||
if ( $OS =~ /windows/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "c:/temp";
|
||||
$PROGPATH = $ENV{"ProgramFiles"};
|
||||
}
|
||||
if ( !$TEMP || !-d $TEMP ) {
|
||||
print "Error: A temporary directory can not be find.\n";
|
||||
print "Check that TEMP or TMP environment variable is set correctly.\n";
|
||||
print "makepack-dolibarrlang.pl aborted.\n";
|
||||
sleep 2;
|
||||
exit 2;
|
||||
}
|
||||
$BUILDROOT = "$TEMP/dolibarr-buildroot";
|
||||
|
||||
my $copyalreadydone = 0;
|
||||
my $batch = 0;
|
||||
|
||||
print "Makepack langs version $VERSION\n";
|
||||
print "Enter language code to package (en_US, fr_FR, ...) : ";
|
||||
$PROJECT = <STDIN>;
|
||||
chomp($PROJECT);
|
||||
|
||||
# Ask and set version $MAJOR and $MINOR
|
||||
print "Enter value for version: ";
|
||||
$PROJVERSION = <STDIN>;
|
||||
chomp($PROJVERSION);
|
||||
( $MAJOR, $MINOR ) = split( /\./, $PROJVERSION, 2 );
|
||||
if ( $MINOR eq '' ) {
|
||||
print "Enter value for minor version: ";
|
||||
$MINOR = <STDIN>;
|
||||
chomp($MINOR);
|
||||
}
|
||||
|
||||
$FILENAME = "$PROJECT";
|
||||
$FILENAMETGZ = "lang_$PROJECT-$MAJOR.$MINOR";
|
||||
if ( -d "/usr/src/redhat" ) {
|
||||
|
||||
# redhat
|
||||
$RPMDIR = "/usr/src/redhat";
|
||||
}
|
||||
if ( -d "/usr/src/RPM" ) {
|
||||
|
||||
# mandrake
|
||||
$RPMDIR = "/usr/src/RPM";
|
||||
}
|
||||
|
||||
$SOURCE = "$DIR/../../dolibarr";
|
||||
$DESTI = "$SOURCE/build";
|
||||
|
||||
# Choose package targets
|
||||
#-----------------------
|
||||
$target = "ZIP"; # Les langs sont au format zip
|
||||
if ($target) {
|
||||
$CHOOSEDTARGET{ uc($target) } = 1;
|
||||
}
|
||||
else {
|
||||
my $found = 0;
|
||||
my $NUM_SCRIPT;
|
||||
while ( !$found ) {
|
||||
my $cpt = 0;
|
||||
printf( " %d - %3s (%s)\n",
|
||||
$cpt, "All", "Need " . join( ",", values %REQUIREMENTTARGET ) );
|
||||
foreach my $target (@LISTETARGET) {
|
||||
$cpt++;
|
||||
printf( " %d - %3s (%s)\n",
|
||||
$cpt, $target, "Need " . $REQUIREMENTTARGET{$target} );
|
||||
}
|
||||
|
||||
# Are asked to select the file to move
|
||||
print "Choose one package number or several separated with space: ";
|
||||
$NUM_SCRIPT = <STDIN>;
|
||||
chomp($NUM_SCRIPT);
|
||||
if ( $NUM_SCRIPT =~ s/-//g ) {
|
||||
|
||||
# Do not do copy
|
||||
$copyalreadydone = 1;
|
||||
}
|
||||
if ( $NUM_SCRIPT !~ /^[0-$cpt\s]+$/ ) {
|
||||
print "This is not a valid package number list.\n";
|
||||
$found = 0;
|
||||
}
|
||||
else {
|
||||
$found = 1;
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
if ($NUM_SCRIPT) {
|
||||
foreach my $num ( split( /\s+/, $NUM_SCRIPT ) ) {
|
||||
$CHOOSEDTARGET{ $LISTETARGET[ $num - 1 ] } = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach my $key (@LISTETARGET) {
|
||||
$CHOOSEDTARGET{$key} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Test if requirement is ok
|
||||
#--------------------------
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
foreach my $req ( split( /[,\s]/, $REQUIREMENTTARGET{$target} ) ) {
|
||||
|
||||
# Test
|
||||
print "Test requirement for target $target: Search '$req'... ";
|
||||
$ret = `"$req" 2>&1`;
|
||||
$coderetour = $?;
|
||||
$coderetour2 = $coderetour >> 8;
|
||||
if (
|
||||
$coderetour != 0
|
||||
&& ( ( $coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i )
|
||||
|| ( $coderetour2 == 127 && $OS !~ /windows/ ) )
|
||||
&& $PROGPATH
|
||||
)
|
||||
{
|
||||
|
||||
# Not found error, we try in PROGPATH
|
||||
$ret = `"$PROGPATH/$ALTERNATEPATH{$req}/$req\" 2>&1`;
|
||||
$coderetour = $?;
|
||||
$coderetour2 = $coderetour >> 8;
|
||||
$REQUIREMENTTARGET{$target} = "$PROGPATH/$ALTERNATEPATH{$req}/$req";
|
||||
}
|
||||
|
||||
if (
|
||||
$coderetour != 0
|
||||
&& ( ( $coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i )
|
||||
|| ( $coderetour2 == 127 && $OS !~ /windows/ ) )
|
||||
)
|
||||
{
|
||||
|
||||
# Not found error
|
||||
print
|
||||
"Not found\nCan't build target $target. Requirement '$req' not found in PATH\n";
|
||||
$CHOOSEDTARGET{$target} = -1;
|
||||
last;
|
||||
}
|
||||
else {
|
||||
|
||||
# Pas erreur ou erreur autre que programme absent
|
||||
print " Found " . $REQUIREMENTTARGET{$target} . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
# Check if there is at least on target to build
|
||||
#----------------------------------------------
|
||||
$nboftargetok = 0;
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) { next; }
|
||||
$nboftargetok++;
|
||||
}
|
||||
|
||||
if ($nboftargetok) {
|
||||
|
||||
# Update buildroot
|
||||
#-----------------
|
||||
if ( !$copyalreadydone ) {
|
||||
print "Delete directory $BUILDROOT\n";
|
||||
$ret = `rm -fr "$BUILDROOT"`;
|
||||
mkdir "$BUILDROOT";
|
||||
mkdir "$BUILDROOT/htdocs";
|
||||
mkdir "$BUILDROOT/htdocs/langs";
|
||||
mkdir "$BUILDROOT/htdocs/langs/$PROJECT";
|
||||
|
||||
print "Copy $SOURCE into $BUILDROOT\n";
|
||||
mkdir "$BUILDROOT";
|
||||
$ret =
|
||||
`cp -pr "$SOURCE/htdocs/langs/$PROJECT" "$BUILDROOT/htdocs/langs"`;
|
||||
}
|
||||
print "Clean $BUILDROOT\n";
|
||||
$ret =
|
||||
`rm -fr $BUILDROOT/htdocs/langs/$PROJECT/Thumbs.db $BUILDROOT/htdocs/langs/$PROJECT/*/Thumbs.db $BUILDROOT/htdocs/langs/$PROJECT/*/*/Thumbs.db $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/Thumbs.db`;
|
||||
$ret =
|
||||
`rm -fr $BUILDROOT/htdocs/langs/$PROJECT/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/*/*/CVS*`;
|
||||
|
||||
# Build package for each target
|
||||
#------------------------------
|
||||
foreach my $target ( keys %CHOOSEDTARGET )
|
||||
{
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) { next; }
|
||||
|
||||
print "\nBuild package for target $target\n";
|
||||
|
||||
if ( $target eq 'TGZ' )
|
||||
{
|
||||
unlink $FILENAMETGZ . tgz;
|
||||
|
||||
# unlink $BUILDROOT/$FILENAMETGZ.tgz;
|
||||
print "Compress $BUILDROOT/htdocs into $FILENAMETGZ.tgz...\n";
|
||||
$cmd =
|
||||
"tar --exclude-vcs --exclude-from \"$DESTI/tgz/tar.exclude\" --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$FILENAMETGZ.tgz\" htdocs";
|
||||
$ret = `$cmd`;
|
||||
|
||||
# $cmd="tar --exclude-vcs --exclude-from \"$DESTI/tgz/tar.exclude\" --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$BUILDROOT/$FILENAMETGZ.tgz\" htdocs\n";
|
||||
# $ret=`$cmd`;
|
||||
if ( $OS =~ /windows/i ) {
|
||||
print "Move $FILENAMETGZ.tgz to $DESTI/$FILENAMETGZ.tgz\n";
|
||||
$ret = `mv "$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`;
|
||||
|
||||
# $ret=`mv "$BUILDROOT/$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`;
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if ( $target eq 'ZIP' )
|
||||
{
|
||||
unlink $FILENAMEZIP . zip;
|
||||
print "Compress $FILENAMETGZ into $FILENAMEZIP.zip...\n";
|
||||
chdir("$BUILDROOT");
|
||||
|
||||
#print "cd $BUILDROOTNT & 7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*\n";
|
||||
#$ret=`cd $BUILDROOTNT & 7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*`;
|
||||
$ret =
|
||||
`7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*`;
|
||||
print "Move $FILENAMEZIP.zip to $DESTI\n";
|
||||
rename( "$BUILDROOT/$FILENAMEZIP.zip", "$DESTI/$FILENAMEZIP.zip" );
|
||||
next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "\n----- Summary -----\n";
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) {
|
||||
print "Package $target not built (bad requirement).\n";
|
||||
}
|
||||
else {
|
||||
print "Package $target built succeessfully in $DESTI\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$btach ) {
|
||||
print "\nPress key to finish...";
|
||||
my $WAITKEY = <STDIN>;
|
||||
}
|
||||
|
||||
0;
|
||||
@ -36,14 +36,13 @@ complete release of Dolibarr, step by step.
|
||||
- Update version number with x.y.z in build/exe/doliwamp/doliwamp.iss
|
||||
- Update version number with x.y.z in build/rpm/*.spec
|
||||
- Commit all changes.
|
||||
- Add a Tag (x.y.z)
|
||||
|
||||
- Build Dolibarr and DoliWamp packages with makepack-dolibarr.pl
|
||||
- Check content of built packages.
|
||||
- Move build files into www.dolibarr.org web site
|
||||
(/home/dolibarr/wwwroot/files/stable).
|
||||
- Run makepack-dolibarr.pl again with option to publish files on
|
||||
sourceforge.
|
||||
sourceforge. This will also add official tag.
|
||||
- Edit symbolic links in directory "/home/dolibarr/wwwroot/files/stable/xxx"
|
||||
on server to point to new files (used by some web sites).
|
||||
|
||||
|
||||
@ -162,7 +162,6 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/asterisk
|
||||
%_datadir/dolibarr/htdocs/barcode
|
||||
%_datadir/dolibarr/htdocs/bookmarks
|
||||
%_datadir/dolibarr/htdocs/boutique
|
||||
%_datadir/dolibarr/htdocs/cashdesk
|
||||
%_datadir/dolibarr/htdocs/categories
|
||||
%_datadir/dolibarr/htdocs/comm
|
||||
@ -333,6 +332,9 @@ fi
|
||||
|
||||
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
|
||||
%changelog
|
||||
* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3
|
||||
- Upstream release
|
||||
|
||||
* Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3
|
||||
- Upstream release
|
||||
|
||||
|
||||
@ -242,7 +242,6 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/asterisk
|
||||
%_datadir/dolibarr/htdocs/barcode
|
||||
%_datadir/dolibarr/htdocs/bookmarks
|
||||
%_datadir/dolibarr/htdocs/boutique
|
||||
%_datadir/dolibarr/htdocs/cashdesk
|
||||
%_datadir/dolibarr/htdocs/categories
|
||||
%_datadir/dolibarr/htdocs/comm
|
||||
@ -569,6 +568,9 @@ fi
|
||||
|
||||
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
|
||||
%changelog
|
||||
* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3
|
||||
- Upstream release
|
||||
|
||||
* Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3
|
||||
- Upstream release
|
||||
|
||||
|
||||
@ -159,7 +159,6 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/asterisk
|
||||
%_datadir/dolibarr/htdocs/barcode
|
||||
%_datadir/dolibarr/htdocs/bookmarks
|
||||
%_datadir/dolibarr/htdocs/boutique
|
||||
%_datadir/dolibarr/htdocs/cashdesk
|
||||
%_datadir/dolibarr/htdocs/categories
|
||||
%_datadir/dolibarr/htdocs/comm
|
||||
@ -338,6 +337,9 @@ fi
|
||||
|
||||
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
|
||||
%changelog
|
||||
* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3
|
||||
- Upstream release
|
||||
|
||||
* Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3
|
||||
- Upstream release
|
||||
|
||||
|
||||
@ -170,7 +170,6 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/asterisk
|
||||
%_datadir/dolibarr/htdocs/barcode
|
||||
%_datadir/dolibarr/htdocs/bookmarks
|
||||
%_datadir/dolibarr/htdocs/boutique
|
||||
%_datadir/dolibarr/htdocs/cashdesk
|
||||
%_datadir/dolibarr/htdocs/categories
|
||||
%_datadir/dolibarr/htdocs/comm
|
||||
@ -349,6 +348,9 @@ fi
|
||||
|
||||
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
|
||||
%changelog
|
||||
* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3
|
||||
- Upstream release
|
||||
|
||||
* Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3
|
||||
- Upstream release
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
"ext-mcrypt": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-soap": "*"
|
||||
"ext-soap": "*",
|
||||
"ext-zip": "*",
|
||||
"ext-xml": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,6 +243,10 @@
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.NamingConventions.ValidFunctionName" />
|
||||
|
||||
<rule ref="PEAR.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.NamingConventions.ValidFunctionName.FunctionNameInvalid">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
@ -253,13 +257,13 @@
|
||||
<rule ref="PEAR.NamingConventions.ValidFunctionName.FunctionNoCaptial">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.NamingConventions.ValidFunctionName.NotCamelCaps">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.NamingConventions.ValidVariableName" />
|
||||
|
||||
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />
|
||||
|
||||
@ -94,7 +94,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
||||
|
||||
print "Invoice ".$i." for socid ".$socid;
|
||||
|
||||
$facture = new Facture($db, $socids[$socid]);
|
||||
$facture = new Facture($db);
|
||||
$facture->date = time();
|
||||
$facture->cond_reglement_id = 3;
|
||||
$facture->mode_reglement_id = 3;
|
||||
|
||||
@ -122,7 +122,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
||||
$soc = new Societe($db);
|
||||
|
||||
|
||||
$propal = new Propal($db, $socids[$socid]);
|
||||
$propal = new Propal($db);
|
||||
|
||||
$obj = $conf->global->PROPALE_ADDON;
|
||||
$modPropale = new $obj;
|
||||
@ -130,6 +130,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
||||
|
||||
$propal->ref = $numpr;
|
||||
$propal->contactid = $contids[$socids[$socid]][0];
|
||||
$propal->socid = $socids[$socid];
|
||||
$propal->datep = time();
|
||||
$propal->cond_reglement_id = 3;
|
||||
$propal->mode_reglement_id = 3;
|
||||
|
||||
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
195
dev/optimize_images.sh
Executable file
195
dev/optimize_images.sh
Executable file
@ -0,0 +1,195 @@
|
||||
#!/bin/bash
|
||||
# Borrowed from https://gist.github.com/lgiraudel/6065155
|
||||
# Inplace mode added by Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
|
||||
PROGNAME=${0##*/}
|
||||
INPUT=''
|
||||
QUIET='0'
|
||||
NOSTATS='0'
|
||||
INPLACE='0'
|
||||
max_input_size=0
|
||||
max_output_size=0
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EO
|
||||
Usage: $PROGNAME [options]
|
||||
|
||||
Script to optimize JPG and PNG images in a directory.
|
||||
|
||||
Options:
|
||||
EO
|
||||
cat <<EO | column -s\& -t
|
||||
-h, --help & shows this help
|
||||
-q, --quiet & disables output
|
||||
-i, --input [dir] & specify input directory (current directory by default)
|
||||
-o, --output [dir] & specify output directory ("output" by default)
|
||||
-ns, --no-stats & no stats at the end
|
||||
-p, --inplace & optimizes files inplace
|
||||
EO
|
||||
}
|
||||
|
||||
# $1: input image
|
||||
# $2: output image
|
||||
optimize_image()
|
||||
{
|
||||
input_file_size=$(stat -c%s "$1")
|
||||
max_input_size=$(expr $max_input_size + $input_file_size)
|
||||
|
||||
if [ "${1##*.}" = "png" ]; then
|
||||
optipng -o1 -clobber -quiet $1 -out $2.firstpass
|
||||
pngcrush -q -rem alla -reduce $2.firstpass $2 >/dev/null
|
||||
rm -fr $2.firstpass
|
||||
fi
|
||||
if [ "${1##*.}" = "jpg" -o "${1##*.}" = "jpeg" ]; then
|
||||
jpegtran -copy none -progressive $1 > $2
|
||||
fi
|
||||
|
||||
output_file_size=$(stat -c%s "$2")
|
||||
max_output_size=$(expr $max_output_size + $output_file_size)
|
||||
}
|
||||
|
||||
get_max_file_length()
|
||||
{
|
||||
local maxlength=0
|
||||
|
||||
IMAGES=$(find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v $OUTPUT)
|
||||
|
||||
for CURRENT_IMAGE in $IMAGES; do
|
||||
filename=$(basename "$CURRENT_IMAGE")
|
||||
if [[ ${#filename} -gt $maxlength ]]; then
|
||||
maxlength=${#filename}
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$maxlength"
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
# If $INPUT is empty, then we use current directory
|
||||
if [[ "$INPUT" == "" ]]; then
|
||||
INPUT=$(pwd)
|
||||
fi
|
||||
|
||||
# If $OUTPUT is empty, then we use the directory "output" in the current directory
|
||||
if [[ "$OUTPUT" == "" ]]; then
|
||||
OUTPUT=$(pwd)/output
|
||||
fi
|
||||
# If inplace, we use /tmp for output
|
||||
if [[ "$INPLACE" == "1" ]]; then
|
||||
OUTPUT='/tmp/optimize'
|
||||
fi
|
||||
|
||||
# We create the output directory
|
||||
mkdir -p $OUTPUT
|
||||
|
||||
# To avoid some troubles with filename with spaces, we store the current IFS (Internal File Separator)...
|
||||
SAVEIFS=$IFS
|
||||
# ...and we set a new one
|
||||
IFS=$(echo -en "\n\b")
|
||||
|
||||
max_filelength=`get_max_file_length`
|
||||
pad=$(printf '%0.1s' "."{1..600})
|
||||
sDone=' [ DONE ]'
|
||||
linelength=$(expr $max_filelength + ${#sDone} + 5)
|
||||
|
||||
# Search of all jpg/jpeg/png in $INPUT
|
||||
# We remove images from $OUTPUT if $OUTPUT is a subdirectory of $INPUT
|
||||
IMAGES=$(find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v $OUTPUT)
|
||||
|
||||
if [ "$QUIET" == "0" ]; then
|
||||
echo --- Optimizing $INPUT ---
|
||||
echo
|
||||
fi
|
||||
for CURRENT_IMAGE in $IMAGES; do
|
||||
filename=$(basename $CURRENT_IMAGE)
|
||||
if [ "$QUIET" == "0" ]; then
|
||||
printf '%s ' "$filename"
|
||||
printf '%*.*s' 0 $((linelength - ${#filename} - ${#sDone} )) "$pad"
|
||||
fi
|
||||
|
||||
optimize_image $CURRENT_IMAGE $OUTPUT/$filename
|
||||
|
||||
# Replace file
|
||||
if [[ "$INPLACE" == "1" ]]; then
|
||||
mv $OUTPUT/$filename $CURRENT_IMAGE
|
||||
fi
|
||||
|
||||
if [ "$QUIET" == "0" ]; then
|
||||
printf '%s\n' "$sDone"
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
if [[ "$INPLACE" == "1" ]]; then
|
||||
rm -rf $OUTPUT
|
||||
fi
|
||||
|
||||
# we restore the saved IFS
|
||||
IFS=$SAVEIFS
|
||||
|
||||
if [ "$NOSTATS" == "0" -a "$QUIET" == "0" ]; then
|
||||
echo
|
||||
echo "Input: " $(human_readable_filesize $max_input_size)
|
||||
echo "Output: " $(human_readable_filesize $max_output_size)
|
||||
space_saved=$(expr $max_input_size - $max_output_size)
|
||||
echo "Space save: " $(human_readable_filesize $space_saved)
|
||||
fi
|
||||
}
|
||||
|
||||
human_readable_filesize()
|
||||
{
|
||||
echo -n $1 | awk 'function human(x) {
|
||||
s=" b Kb Mb Gb Tb"
|
||||
while (x>=1024 && length(s)>1)
|
||||
{x/=1024; s=substr(s,4)}
|
||||
s=substr(s,1,4)
|
||||
xf=(s==" b ")?"%5d ":"%.2f"
|
||||
return sprintf( xf"%s", x, s)
|
||||
}
|
||||
{gsub(/^[0-9]+/, human($1)); print}'
|
||||
}
|
||||
|
||||
SHORTOPTS="h,i:,o:,q,s,p"
|
||||
LONGOPTS="help,input:,output:,quiet,no-stats,inplace"
|
||||
ARGS=$(getopt -s bash --options $SHORTOPTS --longoptions $LONGOPTS --name $PROGNAME -- "$@")
|
||||
|
||||
eval set -- "$ARGS"
|
||||
while true; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-i|--input)
|
||||
shift
|
||||
INPUT=$1
|
||||
;;
|
||||
-o|--output)
|
||||
shift
|
||||
OUTPUT=$1
|
||||
;;
|
||||
-q|--quiet)
|
||||
QUIET='1'
|
||||
;;
|
||||
-s|--no-stats)
|
||||
NOSTATS='1'
|
||||
;;
|
||||
-p|--inplace)
|
||||
INPLACE='1'
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
main
|
||||
|
||||
@ -254,11 +254,11 @@ foreach($property as $key => $prop)
|
||||
$varprop.="\t\t\$sql.= \" ";
|
||||
if ($prop['istime'])
|
||||
{
|
||||
$varprop.='".(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':$this->db->idate(';
|
||||
$varprop.='".(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':"\'".$this->db->idate(';
|
||||
$varprop.="\$this->".$prop['field']."";
|
||||
$varprop.='))."';
|
||||
$varprop.=')."\'")."';
|
||||
if ($i < count($property)) $varprop.=",";
|
||||
$varprop.="\";";
|
||||
$varprop.='";';
|
||||
}
|
||||
elseif ($prop['ischar'])
|
||||
{
|
||||
|
||||
@ -106,7 +106,7 @@ class Skeleton_Class extends CommonObject
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
@ -133,10 +133,11 @@ class Skeleton_Class extends CommonObject
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param int $id Id object
|
||||
* @param string $ref Ref
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
function fetch($id,$ref='')
|
||||
{
|
||||
global $langs;
|
||||
$sql = "SELECT";
|
||||
@ -145,7 +146,8 @@ class Skeleton_Class extends CommonObject
|
||||
$sql.= " t.field2";
|
||||
//...
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
|
||||
$sql.= " WHERE t.rowid = ".$id;
|
||||
if ($ref) $sql.= " WHERE t.ref = '".$ref."'";
|
||||
else $sql.= " WHERE t.rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch");
|
||||
$resql=$this->db->query($sql);
|
||||
@ -214,7 +216,7 @@ class Skeleton_Class extends CommonObject
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
@ -261,7 +263,7 @@ class Skeleton_Class extends CommonObject
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@includ
|
||||
if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||
if (! $res) die("Include of main fails");
|
||||
// Change this following line to use the correct relative path from htdocs
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/formcompany.class.php');
|
||||
dol_include_once('/module/class/skeleton_class.class.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
@ -52,6 +53,7 @@ $langs->load("other");
|
||||
// Get parameters
|
||||
$id = GETPOST('id','int');
|
||||
$action = GETPOST('action','alpha');
|
||||
$backtopage = GETPOST('backtopage');
|
||||
$myparam = GETPOST('myparam','alpha');
|
||||
|
||||
// Protection if external user
|
||||
@ -60,6 +62,16 @@ if ($user->societe_id > 0)
|
||||
//accessforbidden();
|
||||
}
|
||||
|
||||
if (empty($action) && empty($id) && empty($ref)) $action='create';
|
||||
|
||||
// Load object if id or ref is provided as parameter
|
||||
$object=new Skeleton_Class($db);
|
||||
if (($id > 0 || ! empty($ref)) && $action != 'add')
|
||||
{
|
||||
$result=$object->fetch($id,$ref);
|
||||
if ($result < 0) dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
@ -68,19 +80,104 @@ if ($user->societe_id > 0)
|
||||
* Put here all code to do according to value of "action" parameter
|
||||
********************************************************************/
|
||||
|
||||
// Action to add record
|
||||
if ($action == 'add')
|
||||
{
|
||||
$object=new Skeleton_Class($db);
|
||||
$object->prop1=$_POST["field1"];
|
||||
$object->prop2=$_POST["field2"];
|
||||
$result=$object->create($user);
|
||||
if (GETPOST('cancel'))
|
||||
{
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/buildingmanagement/list.php',1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
|
||||
$error=0;
|
||||
|
||||
/* object_prop_getpost_prop */
|
||||
$object->prop1=GETPOST("field1");
|
||||
$object->prop2=GETPOST("field2");
|
||||
|
||||
if (empty($object->ref))
|
||||
{
|
||||
$error++;
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$object->create($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Creation OK
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
{
|
||||
// Creation KO
|
||||
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
|
||||
else setEventMessages($object->error, null, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel
|
||||
if ($action == 'update' && GETPOST('cancel')) $action='view';
|
||||
|
||||
// Action to update record
|
||||
if ($action == 'update' && ! GETPOST('cancel'))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$object->prop1=GETPOST("field1");
|
||||
$object->prop2=GETPOST("field2");
|
||||
|
||||
if (empty($object->ref))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),null,'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$object->update($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$action='view';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Creation KO
|
||||
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
|
||||
else setEventMessages($object->error, null, 'errors');
|
||||
$action='edit';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$action='edit';
|
||||
}
|
||||
}
|
||||
|
||||
// Action to delete
|
||||
if ($action == 'confirm_delete')
|
||||
{
|
||||
$result=$object->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Creation OK
|
||||
// Delete OK
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
header("Location: ".dol_buildpath('/buildingmanagement/list.php',1));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Creation KO
|
||||
$mesg=$object->error;
|
||||
if (! empty($object->errors)) setEventMessages(null,$object->errors,'errors');
|
||||
else setEventMessages($object->error,null,'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +198,7 @@ $form=new Form($db);
|
||||
|
||||
// Put here content of your page
|
||||
|
||||
// Example 1 : Adding jquery code
|
||||
// Example : Adding jquery code
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
function init_myfunc()
|
||||
@ -117,13 +214,8 @@ jQuery(document).ready(function() {
|
||||
</script>';
|
||||
|
||||
|
||||
// Example 2 : Adding links to objects
|
||||
// The class must extends CommonObject class to have this method available
|
||||
//$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
|
||||
// Example 3 : List of data
|
||||
if ($action == 'list')
|
||||
// Part to show a list
|
||||
if ($action == 'list' || empty($id))
|
||||
{
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
@ -145,21 +237,18 @@ if ($action == 'list')
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num)
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
// You can use here results
|
||||
print '<tr><td>';
|
||||
print $obj->field1;
|
||||
print $obj->field2;
|
||||
print '</td></tr>';
|
||||
}
|
||||
$i++;
|
||||
// You can use here results
|
||||
print '<tr><td>';
|
||||
print $obj->field1;
|
||||
print $obj->field2;
|
||||
print '</td></tr>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -173,6 +262,102 @@ if ($action == 'list')
|
||||
|
||||
|
||||
|
||||
// Part to create
|
||||
if ($action == 'create')
|
||||
{
|
||||
print_fiche_titre($langs->trans("NewResidence"));
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
|
||||
print '<table class="border centpercent">'."\n";
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
|
||||
print '<input class="flat" type="text" size="36" name="label" value="'.$label.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>'."\n";
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<center><input type="submit" class="button" name="add" value="'.$langs->trans("Create").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit')
|
||||
{
|
||||
dol_fiche_head();
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<center><input type="submit" class="button" name="add" value="'.$langs->trans("Create").'"></center>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Part to show record
|
||||
if ($id && (empty($action) || $action == 'view'))
|
||||
{
|
||||
dol_fiche_head();
|
||||
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
// Buttons
|
||||
print '<div class="tabsAction">'."\n";
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($user->rights->mymodule->write)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||
}
|
||||
|
||||
if ($user->rights->mymodule->delete)
|
||||
{
|
||||
if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile
|
||||
{
|
||||
print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</div>'."\n";
|
||||
|
||||
|
||||
// Example 2 : Adding links to objects
|
||||
// The class must extends CommonObject class to have this method available
|
||||
//$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -269,5 +269,4 @@ function createSkeleton($authentication,$skeleton)
|
||||
}
|
||||
|
||||
// Return the results.
|
||||
$server->service($HTTP_RAW_POST_DATA);
|
||||
|
||||
$server->service(file_get_contents("php://input"));
|
||||
|
||||
2
htdocs/.gitignore
vendored
2
htdocs/.gitignore
vendored
@ -2,6 +2,8 @@
|
||||
/custom*
|
||||
/extensions*
|
||||
/nltechno*
|
||||
/ancot*
|
||||
/teclib*
|
||||
/bootstrap*
|
||||
/google*
|
||||
/multicompany*
|
||||
|
||||
205
htdocs/accountancy/admin/account.php
Normal file
205
htdocs/accountancy/admin/account.php
Normal file
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/account.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief List accounting account
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
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/html.formventilation.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$mesg = '';
|
||||
$action = GETPOST('action');
|
||||
$id = GETPOST('id', 'int');
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'sortorder');
|
||||
$limit = $conf->liste_limit;
|
||||
$page = GETPOST("page", 'int');
|
||||
if ($page == - 1) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield)
|
||||
$sortfield = "aa.account_number";
|
||||
if (! $sortorder)
|
||||
$sortorder = "ASC";
|
||||
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
$accounting = new AccountingAccount($db);
|
||||
|
||||
if ($action == 'disable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$result = $accounting->account_desactivate($id);
|
||||
}
|
||||
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessage($accounting->error, 'errors');
|
||||
}
|
||||
} else if ($action == 'enable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$result = $accounting->account_activate($id);
|
||||
}
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessage($accounting->error, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*
|
||||
*/
|
||||
llxHeader('', $langs->trans("ListAccounts"));
|
||||
|
||||
$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 .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa, " . MAIN_DB_PREFIX . "accounting_system as asy";
|
||||
$sql .= " WHERE aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $pcgver;
|
||||
|
||||
if (strlen(trim($_GET["search_account"]))) {
|
||||
$sql .= " AND aa.account_number like '%" . $_GET["search_account"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_label"]))) {
|
||||
$sql .= " AND aa.label like '%" . $_GET["search_label"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_accountparent"]))) {
|
||||
$sql .= " AND aa.account_parent like '%" . $_GET["search_accountparent"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_pcgtype"]))) {
|
||||
$sql .= " AND aa.pcg_type like '%" . $_GET["search_pcgtype"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_pcgsubtype"]))) {
|
||||
$sql .= " AND aa.pcg_subtype like '%" . $_GET["search_pcgsubtype"] . "%'";
|
||||
}
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/admin/account.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
|
||||
|
||||
$i = 0;
|
||||
|
||||
print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
|
||||
print '<br/>';
|
||||
|
||||
print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
|
||||
print '<a class="butAction" href="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
|
||||
print '<br/><br/>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("AccountNumber"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "aa.label", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Accountparent"), $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Active"), $_SERVER["PHP_SELF"], "aa.active", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre(" ");
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST("search_account") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST("search_label") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_accountparent" value="' . GETPOST("search_accountparent") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgtype" value="' . GETPOST("search_pcgtype") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgsubtype" value="' . GETPOST("search_pcgsubtype") . '"></td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre" align="right">';
|
||||
print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$var = true;
|
||||
|
||||
while ( $i < min($num, $limit) ) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$var = ! $var;
|
||||
print '<tr ' . $bc[$var] . '>';
|
||||
print '<td><a href="./card.php?id=' . $obj->rowid . '">' . $obj->account_number . '</td>';
|
||||
print '<td>' . $obj->label . '</td>';
|
||||
print '<td>' . $obj->account_parent . '</td>';
|
||||
print '<td>' . $obj->pcg_type . '</td>';
|
||||
print '<td>' . $obj->pcg_subtype . '</td>';
|
||||
print '<td>';
|
||||
if (empty($obj->active)) {
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($user->admin) {
|
||||
print '<a href="./card.php?action=update&id=' . $obj->rowid . '">';
|
||||
print img_edit();
|
||||
print '</a> ';
|
||||
print '<a href="./card.php?action=delete&id=' . $obj->rowid . '">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>' . "\n";
|
||||
|
||||
print "</tr>\n";
|
||||
$i ++;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print '</form>';
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
302
htdocs/accountancy/admin/card.php
Normal file
302
htdocs/accountancy/admin/card.php
Normal file
@ -0,0 +1,302 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/card.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Card accounting account
|
||||
*/
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
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/html.formventilation.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("bills");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$mesg = '';
|
||||
$action = GETPOST('action');
|
||||
$id = GETPOST('id', 'int');
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$accounting = new AccountingAccount($db);
|
||||
|
||||
// Action
|
||||
if ($action == 'add')
|
||||
{
|
||||
if (! GETPOST('cancel', 'alpha')) {
|
||||
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$accounting->fk_pcg_version = $obj->pcg_version;
|
||||
$accounting->pcg_type = GETPOST('pcg_type');
|
||||
$accounting->pcg_subtype = GETPOST('pcg_subtype');
|
||||
$accounting->account_number = GETPOST('account_number', 'int');
|
||||
$accounting->account_parent = GETPOST('account_parent', 'int');
|
||||
$accounting->label = GETPOST('label', 'alpha');
|
||||
$accounting->active = 1;
|
||||
|
||||
$res = $accounting->create($user);
|
||||
|
||||
if ($res == 0) {
|
||||
} else {
|
||||
if ($res == - 3) {
|
||||
$_error = 1;
|
||||
$action = "create";
|
||||
}
|
||||
if ($res == - 4) {
|
||||
$_error = 2;
|
||||
$action = "create";
|
||||
}
|
||||
}
|
||||
}
|
||||
Header("Location: account.php");
|
||||
}
|
||||
else if ($action == 'edit')
|
||||
{
|
||||
if (! GETPOST('cancel', 'alpha')) {
|
||||
$result = $accounting->fetch($id);
|
||||
|
||||
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
|
||||
$result2 = $db->query($sql);
|
||||
$obj = $db->fetch_object($result2);
|
||||
|
||||
$accounting->fk_pcg_version = $obj->pcg_version;
|
||||
$accounting->pcg_type = GETPOST('pcg_type');
|
||||
$accounting->pcg_subtype = GETPOST('pcg_subtype');
|
||||
$accounting->account_number = GETPOST('account_number', 'int');
|
||||
$accounting->account_parent = GETPOST('account_parent', 'int');
|
||||
$accounting->label = GETPOST('label', 'alpha');
|
||||
|
||||
$result = $accounting->update($user);
|
||||
|
||||
if ($result > 0) {
|
||||
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
||||
exit();
|
||||
} else {
|
||||
$mesg = $object->error;
|
||||
}
|
||||
} else {
|
||||
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
else if ($action == 'delete')
|
||||
{
|
||||
$result = $accounting->fetch($id);
|
||||
|
||||
if (! empty($accounting->id)) {
|
||||
$result = $accounting->delete($user);
|
||||
|
||||
if ($result > 0) {
|
||||
Header("Location: account.php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
setEventMessage($accounting->error, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*
|
||||
*/
|
||||
llxheader('', $langs->trans('AccountAccounting'));
|
||||
|
||||
$form = new Form($db);
|
||||
$htmlacc = new FormVentilation($db);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print_fiche_titre($langs->trans('NewAccount'));
|
||||
|
||||
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">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
|
||||
print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Label") . '</td>';
|
||||
print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
||||
print '<td>';
|
||||
print $htmlacc->select_account($accounting->account_parent, 'account_parent');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
||||
print '<td>';
|
||||
print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
||||
print '<td>';
|
||||
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br><center><input class="button" type="submit" value="' . $langs->trans("Save") . '"> ';
|
||||
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '"></center';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else if ($id)
|
||||
{
|
||||
$rowid = $id;
|
||||
$account = $accounting->fetch($rowid);
|
||||
|
||||
if ($account > 0) {
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
$head = accounting_prepare_head($accounting);
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
// WYSIWYG Editor
|
||||
$htmlacc = new FormVentilation($db);
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||
|
||||
$soc = new Societe($db);
|
||||
if ($object->socid) {
|
||||
$soc->fetch($object->socid);
|
||||
}
|
||||
|
||||
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 '<input type="hidden" name="action" value="edit">';
|
||||
print '<input type="hidden" name="id" value="' . $id . '">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
|
||||
print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Label") . '</td>';
|
||||
print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
||||
print '<td>';
|
||||
print $htmlacc->select_account($accounting->account_parent, 'account_parent');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
||||
print '<td>';
|
||||
print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
||||
print '<td>';
|
||||
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br><center><input type="submit" class="button" value="' . $langs->trans("Save") . '"> ';
|
||||
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
|
||||
print '</center>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Account number
|
||||
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
|
||||
print '<td>' . $accounting->account_number . '</td>';
|
||||
print '<td align="right" width="25%">' . $linkback . '</td></tr>';
|
||||
|
||||
print '<tr><td>' . $langs->trans("Label") . '</td>';
|
||||
print '<td colspan="2">' . $accounting->label . '</td></tr>';
|
||||
|
||||
$accp = new AccountingAccount($db);
|
||||
if (! empty($accounting->account_parent)) {
|
||||
$accp->fetch($accounting->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("Pcgtype") . '</td>';
|
||||
print '<td colspan="2">' . $accounting->pcg_type . '</td></tr>';
|
||||
|
||||
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
||||
print '<td colspan="2">' . $accounting->pcg_subtype . '</td></tr>';
|
||||
|
||||
print '<tr><td>' . $langs->trans("Active") . '</td>';
|
||||
print '<td colspan="2">';
|
||||
|
||||
if (empty($accounting->active)) {
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
} else {
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->admin) {
|
||||
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Modify') . '</a>';
|
||||
}
|
||||
|
||||
if ($user->admin) {
|
||||
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Delete') . '</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
164
htdocs/accountancy/admin/export.php
Normal file
164
htdocs/accountancy/admin/export.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/export.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Setup page to configure accounting expert module
|
||||
*/
|
||||
|
||||
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';
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("admin");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
// Other parameters ACCOUNTING_*
|
||||
$list = array (
|
||||
'ACCOUNTING_SEPARATORCSV'
|
||||
);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($action == 'update') {
|
||||
$error = 0;
|
||||
|
||||
$modelcsv = GETPOST('modelcsv', 'int');
|
||||
|
||||
if (! empty($modelcsv)) {
|
||||
|
||||
if (! dolibarr_set_const($db, 'ACCOUNTING_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
} else {
|
||||
$error ++;
|
||||
}
|
||||
|
||||
foreach ( $list as $constname ) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
} else {
|
||||
setEventMessage($langs->trans("Error"), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'setup');
|
||||
|
||||
$head = admin_accounting_prepare_head(null);
|
||||
|
||||
dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');
|
||||
|
||||
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">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
$var = true;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$var = ! $var;
|
||||
|
||||
print '<tr ' . $bc[$var] . '>';
|
||||
print "<td>" . $langs->trans("Selectmodelcsv") . "</td>";
|
||||
print "<td>";
|
||||
print '<select class="flat" name="modelcsv" id="modelcsv">';
|
||||
print '<option value="0"';
|
||||
if ($conf->global->ACCOUNTING_MODELCSV == 0) {
|
||||
print ' selected="selected"';
|
||||
}
|
||||
print '>' . $langs->trans("Modelcsv_normal") . '</option>';
|
||||
print '<option value="1"';
|
||||
if ($conf->global->ACCOUNTING_MODELCSV == 1) {
|
||||
print ' selected="selected"';
|
||||
}
|
||||
print '>' . $langs->trans("Modelcsv_CEGID") . '</option>';
|
||||
print "</select>";
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
/*
|
||||
* Params
|
||||
*
|
||||
*/
|
||||
|
||||
$num = count($list);
|
||||
if ($num) {
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
foreach ( $list as $key ) {
|
||||
$var = ! $var;
|
||||
|
||||
print '<tr ' . $bc[$var] . ' class="value">';
|
||||
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
print '<td>' . $label . '</td>';
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</form>';
|
||||
print "</table>\n";
|
||||
|
||||
print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -16,12 +16,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/admin/fiscalyear.php
|
||||
* \file htdocs/accountancy/admin/fiscalyear.php
|
||||
* \ingroup fiscal year
|
||||
* \brief Setup page to configure fiscal year
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require '../../main.inc.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
|
||||
@ -55,6 +55,8 @@ $object = new Fiscalyear($db);
|
||||
* View
|
||||
*/
|
||||
|
||||
$max=100;
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('',$title);
|
||||
@ -68,16 +70,13 @@ $sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
|
||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
$max=10;
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$var=false;
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$i = 0;
|
||||
|
||||
|
||||
// Load attribute_label
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
@ -85,13 +84,13 @@ if ($result)
|
||||
print '<td>'.$langs->trans("Label").'</td>';
|
||||
print '<td>'.$langs->trans("DateStart").'</td>';
|
||||
print '<td>'.$langs->trans("DateEnd").'</td>';
|
||||
print '<td>'.$langs->trans("Statut").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Statut").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
if ($num)
|
||||
{
|
||||
$fiscalyearstatic=new Fiscalyear($db);
|
||||
|
||||
|
||||
while ($i < $num && $i < $max)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
@ -102,7 +101,7 @@ if ($result)
|
||||
print '<td align="left">'.$obj->label.'</td>';
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->date_start),'day').'</td>';
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->date_end),'day').'</td>';
|
||||
print '<td>'.$fiscalyearstatic->LibStatut($obj->statut,5).'</td>';
|
||||
print '<td align="right">'.$fiscalyearstatic->LibStatut($obj->statut,5).'</td>';
|
||||
print '</tr>';
|
||||
$var=!$var;
|
||||
$i++;
|
||||
@ -113,10 +112,9 @@ if ($result)
|
||||
{
|
||||
print '<tr '.$bc[$var].'><td colspan="5">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
@ -16,11 +16,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/admin/fiscalyear_card.php
|
||||
* \file htdocs/accountancy/admin/fiscalyear_card.php
|
||||
* \brief Page to show a fiscal year
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require '../../main.inc.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
|
||||
@ -51,6 +51,7 @@ $object = new Fiscalyear($db);
|
||||
$date_start=dol_mktime(0,0,0,GETPOST('fiscalyearmonth','int'),GETPOST('fiscalyearday','int'),GETPOST('fiscalyearyear','int'));
|
||||
$date_end=dol_mktime(0,0,0,GETPOST('fiscalyearendmonth','int'),GETPOST('fiscalyearendday','int'),GETPOST('fiscalyearendyear','int'));
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -74,9 +75,7 @@ else if ($action == 'add')
|
||||
if (! GETPOST('cancel','alpha'))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
$object->date_start = $date_start;
|
||||
$object->date_end = $date_end;
|
||||
$object->label = GETPOST('label','alpha');
|
||||
@ -96,21 +95,27 @@ else if ($action == 'add')
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$id = $object->create($user);
|
||||
$db->begin();
|
||||
|
||||
$id = $object->create($user);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
{
|
||||
$db->rollback();
|
||||
|
||||
setEventMessage($object->error, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
@ -127,7 +132,7 @@ else if ($action == 'update')
|
||||
if (! GETPOST('cancel','alpha'))
|
||||
{
|
||||
$result = $object->fetch($id);
|
||||
|
||||
|
||||
$object->date_start = empty($_POST["fiscalyear"])?'':$date_start;
|
||||
$object->date_end = empty($_POST["fiscalyearend"])?'':$date_end;
|
||||
$object->label = GETPOST('label','alpha');
|
||||
@ -175,7 +180,7 @@ if ($action == 'create')
|
||||
|
||||
// Label
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="32" value="' . GETPOST("label") . '"></td></tr>';
|
||||
|
||||
|
||||
// Date start
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
|
||||
print $form->select_date(($date_start?$date_start:''),'fiscalyear');
|
||||
@ -185,7 +190,7 @@ if ($action == 'create')
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
|
||||
print $form->select_date(($date_end?$date_end:-1),'fiscalyearend');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Statut
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans("Statut").'</td>';
|
||||
@ -207,11 +212,11 @@ else if ($id)
|
||||
{
|
||||
$head = fiscalyear_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
|
||||
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
|
||||
|
||||
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.'">';
|
||||
@ -223,12 +228,12 @@ else if ($id)
|
||||
print '<td width="20%">'.$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 '</td></tr>';
|
||||
|
||||
|
||||
// Date start
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
|
||||
print $form->select_date($object->date_start?$object->date_start:-1,'fiscalyear');
|
||||
@ -238,7 +243,7 @@ else if ($id)
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
|
||||
print $form->select_date($object->date_end?$object->date_end:-1,'fiscalyearend');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Statut").'</td><td>';
|
||||
print $form->selectarray('statut',$statut2label,$object->statut);
|
||||
@ -252,7 +257,7 @@ else if ($id)
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
dol_fiche_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -264,18 +269,20 @@ else if ($id)
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteFiscalYear"),$langs->trans("ConfirmDeleteFiscalYear"),"confirm_delete");
|
||||
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/fiscalyear.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td width="50%">';
|
||||
print $object->ref;
|
||||
print '</td><td width="25%">';
|
||||
print $linkback;
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Label
|
||||
print '<tr><td valign="top">';
|
||||
print $form->editfieldkey("Label",'label',$object->label,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'alpha:32');
|
||||
@ -289,7 +296,7 @@ else if ($id)
|
||||
print '</td><td colspan="2">';
|
||||
print $form->editfieldval("Date",'date_start',$object->date_start,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Date end
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey("Date",'date_end',$object->date_end,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
@ -300,9 +307,9 @@ else if ($id)
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
print "</table><br>";
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
dol_fiche_end();
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
@ -311,9 +318,9 @@ else if ($id)
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
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>';
|
||||
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
@ -16,11 +16,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/admin/fiscalyear_card.php
|
||||
* \file htdocs/accountancy/admin/fiscalyear_card.php
|
||||
* \brief Page to show info of a fiscal year
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require '../../main.inc.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
@ -43,15 +43,15 @@ if ($id)
|
||||
$object = new Fiscalyear($db);
|
||||
$object->fetch($id);
|
||||
$object->info($id);
|
||||
|
||||
|
||||
$head = fiscalyear_prepare_head($object);
|
||||
|
||||
|
||||
dol_fiche_head($head, 'info', $langs->trans("FiscalYearCard"), 0, 'cron');
|
||||
|
||||
print '<table width="100%"><tr><td>';
|
||||
dol_print_object_info($object);
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
186
htdocs/accountancy/admin/importaccounts.php
Normal file
186
htdocs/accountancy/admin/importaccounts.php
Normal file
@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/importaccounts.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page import accounting account
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
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/html.formventilation.class.php';
|
||||
|
||||
// langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
llxHeader('', $langs->trans("ImportAccount"));
|
||||
|
||||
$to_import = GETPOST("mesCasesCochees");
|
||||
|
||||
if ($_POST["action"] == 'import') {
|
||||
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (is_array($to_import) && count($to_import) > 0) {
|
||||
print '<div><font color="red">' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
|
||||
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result && ($db->num_rows($result) > 0)) {
|
||||
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$cpt = 0;
|
||||
foreach ( $to_import as $maLigneCochee ) {
|
||||
|
||||
$accounting = new AccountingAccount($db);
|
||||
|
||||
$monLabel = GETPOST('label' . $maLigneCochee);
|
||||
$monParentAccount = GETPOST('AccountParent' . $maLigneCochee);
|
||||
$monType = GETPOST('pcgType' . $maLigneCochee);
|
||||
$monSubType = GETPOST('pcgSubType' . $maLigneCochee);
|
||||
|
||||
$accounting->fk_pcg_version = $obj->pcg_version;
|
||||
$accounting->account_number = $maLigneCochee;
|
||||
$accounting->label = $monLabel;
|
||||
$accounting->account_parent = $monParentAccount;
|
||||
$accounting->pcg_type = $monType;
|
||||
$accounting->pcg_subtype = $monSubType;
|
||||
$accounting->active = 1;
|
||||
|
||||
$result = $accounting->create($user);
|
||||
if ($result > 0) {
|
||||
setEventMessage($langs->trans("AccountingAccountAdd"), 'mesgs');
|
||||
} else {
|
||||
setEventMessage($accounting->error, 'errors');
|
||||
}
|
||||
$cpt ++;
|
||||
}
|
||||
} else {
|
||||
setEventMessage($langs->trans('AccountPlanNotFoundCheckSetting'), 'errors');
|
||||
}
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("AnyLineImport") . '</font></div>';
|
||||
}
|
||||
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
|
||||
}
|
||||
|
||||
/*
|
||||
* list accounting account from product
|
||||
*
|
||||
*/
|
||||
$page = GETPOST("page");
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql = "(SELECT p.rowid as product_id, p.accountancy_code_sell as accounting ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p ";
|
||||
$sql .= " WHERE p.accountancy_code_sell >=0";
|
||||
$sql .= " GROUP BY accounting ";
|
||||
$sql .= ")";
|
||||
$sql .= "UNION ALL(SELECT p.rowid as product_id, p.accountancy_code_buy as accounting ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p ";
|
||||
$sql .= " WHERE p.accountancy_code_buy >=0";
|
||||
$sql .= " GROUP BY accounting ";
|
||||
$sql .= ") ";
|
||||
$sql .= " ORDER BY accounting DESC " . $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/admin/importaccounts.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
print_barre_liste($langs->trans("ImportAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>' . $langs->trans("accountingaccount") . '</td>';
|
||||
print '<td>' . $langs->trans("label") . '</td>';
|
||||
print '<td>' . $langs->trans("Accountparent") . '</td>';
|
||||
print '<td>' . $langs->trans("Pcgtype") . '</td>';
|
||||
print '<td>' . $langs->trans("Pcgsubtype") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("Import") . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$form = new Form($db);
|
||||
$htmlacc = new FormVentilation($db);
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
|
||||
print '<input type="hidden" name="action" value="import">';
|
||||
|
||||
$var = true;
|
||||
while ( $i < min($num_lines, $limit) ) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td align="left">';
|
||||
print $objp->accounting;
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
print '<input name="label" size="30" value="">';
|
||||
print '</td>';
|
||||
|
||||
// Colonne choix du compte
|
||||
print '<td>';
|
||||
print $htmlacc->select_account($accounting->account_parent, 'AccountParent');
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcgType');
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcgSubType');
|
||||
print '</td>';
|
||||
|
||||
// Colonne choix ligne a ventiler
|
||||
|
||||
$checked = ('label' == 'O') ? ' checked=checked' : '';
|
||||
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="mesCasesCochees[]" ' . $checked . ' value="' . $objp->accounting . '"/>';
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
|
||||
print '<tr><td colspan="8"> </td></tr><tr><td colspan="8" align="center"><input type="submit" class="butAction" value="' . $langs->trans("Import") . '"></td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
294
htdocs/accountancy/admin/index.php
Normal file
294
htdocs/accountancy/admin/index.php
Normal file
@ -0,0 +1,294 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/index.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Setup page to configure accounting expert module
|
||||
*/
|
||||
|
||||
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';
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("admin");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
// Other parameters ACCOUNTING_*
|
||||
$list = array (
|
||||
'ACCOUNTING_LIMIT_LIST_VENTILATION',
|
||||
'ACCOUNTING_LENGTH_GACCOUNT',
|
||||
'ACCOUNTING_LENGTH_AACCOUNT',
|
||||
'ACCOUNTING_ACCOUNT_CUSTOMER',
|
||||
'ACCOUNTING_ACCOUNT_SUPPLIER',
|
||||
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
|
||||
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
|
||||
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
|
||||
'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
|
||||
'ACCOUNTING_ACCOUNT_SUSPENSE',
|
||||
'ACCOUNTING_ACCOUNT_TRANSFER_CASH'
|
||||
);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$accounting_mode = defined('ACCOUNTING_MODE')?ACCOUNTING_MODE:'RECETTES-DEPENSES';
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$accounting_modes = array(
|
||||
'RECETTES-DEPENSES',
|
||||
'CREANCES-DETTES'
|
||||
);
|
||||
|
||||
$accounting_mode = GETPOST('accounting_mode','alpha');
|
||||
|
||||
if (in_array($accounting_mode,$accounting_modes)) {
|
||||
|
||||
if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$chartofaccounts = GETPOST('chartofaccounts', 'int');
|
||||
|
||||
if (! empty($chartofaccounts)) {
|
||||
|
||||
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
} else {
|
||||
$error ++;
|
||||
}
|
||||
|
||||
foreach ($list as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
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 (! $error) {
|
||||
setEventMessage($langs->trans("SetupSaved"), 'mesgs');
|
||||
} else {
|
||||
setEventMessage($langs->trans("Error"), 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
setEventMessage($langs->trans("SetupSaved"), 'mesgs');
|
||||
} else {
|
||||
setEventMessage($langs->trans("Error"), 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'setup');
|
||||
|
||||
$head = admin_accounting_prepare_head($accounting);
|
||||
|
||||
dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron');
|
||||
|
||||
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">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// Cas du parametre ACCOUNTING_MODE
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
|
||||
// Write info on way to count VAT
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
|
||||
//{
|
||||
// // print "<br>\n";
|
||||
// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// // print "<br>\n";
|
||||
// // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
|
||||
//}
|
||||
print "</td></tr>\n";
|
||||
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
|
||||
print '</form>';
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
/*
|
||||
* Define Chart of accounts
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
$var = true;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">';
|
||||
print $langs->trans("Chartofaccounts") . '</td>';
|
||||
print "</tr>\n";
|
||||
$var = ! $var;
|
||||
print '<tr ' . $bc[$var] . '>';
|
||||
print "<td>" . $langs->trans("Selectchartofaccounts") . "</td>";
|
||||
print "<td>";
|
||||
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
|
||||
|
||||
$sql = "SELECT rowid, pcg_version, fk_pays, label, active";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
|
||||
$sql .= " WHERE active = 1";
|
||||
$sql .= " AND fk_pays = " . $mysoc->country_id;
|
||||
|
||||
dol_syslog('accountancy/admin/index.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
$var = true;
|
||||
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ( $i < $num ) {
|
||||
$var = ! $var;
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<option value="' . $row[0] . '"';
|
||||
print $conf->global->CHARTOFACCOUNTS == $row[0] ? ' selected="selected"' : '';
|
||||
print '>' . $row[1] . ' - ' . $row[3] . '</option>';
|
||||
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
print "</select>";
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
/*
|
||||
* Others params
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
print '<tr '.$bc[$var].' class="value">';
|
||||
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
print '<td><label for="'.$key.'">'.$label.'</label></td>';
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
$var = ! $var;
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
|
||||
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
|
||||
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$var = ! $var;
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
|
||||
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
|
||||
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
print "</table>\n";
|
||||
|
||||
print '<br /><br /><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
172
htdocs/accountancy/admin/journaux.php
Normal file
172
htdocs/accountancy/admin/journaux.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/journaux.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Setup page to configure accounting expert module
|
||||
*/
|
||||
|
||||
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/lib/bank.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
// Other parameters ACCOUNTING_*
|
||||
$list = array (
|
||||
'ACCOUNTING_SELL_JOURNAL',
|
||||
'ACCOUNTING_PURCHASE_JOURNAL',
|
||||
'ACCOUNTING_SOCIAL_JOURNAL',
|
||||
'ACCOUNTING_CASH_JOURNAL',
|
||||
'ACCOUNTING_MISCELLANEOUS_JOURNAL'
|
||||
);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'update') {
|
||||
$error = 0;
|
||||
|
||||
foreach ( $list as $constname ) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
} else {
|
||||
setEventMessage($langs->trans("Error"), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'setup');
|
||||
|
||||
$head = admin_accounting_prepare_head(null);
|
||||
|
||||
dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron');
|
||||
|
||||
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">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('Journaux') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ( $list as $key ) {
|
||||
$var = ! $var;
|
||||
|
||||
print '<tr ' . $bc[$var] . ' class="value">';
|
||||
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
print '<td width="50%"><label for="' . $key . '">' . $label . '</label></td>';
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</form>';
|
||||
print "</table>\n";
|
||||
|
||||
print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
|
||||
|
||||
print '<br />';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('JournalFinancial') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Bank account
|
||||
$sql = "SELECT rowid, label, accountancy_journal";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
$sql.= " AND clos = 0";
|
||||
$sql.= " ORDER BY label";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$numr = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
if ($numr > 0)
|
||||
|
||||
while ($i < $numr)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$var = ! $var;
|
||||
|
||||
print '<tr ' . $bc[$var] . ' class="value">';
|
||||
|
||||
// Param
|
||||
print '<td width="50%"><label for="' . $objp->rowid . '">' . $langs->trans("Journal") . ' - ' . $objp->label . '</label></td>';
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
print '<input type="text" size="20" id="' . $objp->rowid . '" name="' . $objp->label . '" value="' . $objp->accountancy_journal . '" disabled>';
|
||||
print '</td></tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
$db->free($resql);
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
147
htdocs/accountancy/admin/productaccount.php
Normal file
147
htdocs/accountancy/admin/productaccount.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?PHP
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/productaccount.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Onglet de gestion de parametrages des ventilations
|
||||
*/
|
||||
|
||||
// Dolibarr environment
|
||||
$res = @include ("../main.inc.php");
|
||||
if (! $res && file_exists("../main.inc.php"))
|
||||
$res = @include ("../main.inc.php");
|
||||
if (! $res && file_exists("../../main.inc.php"))
|
||||
$res = @include ("../../main.inc.php");
|
||||
if (! $res && file_exists("../../../main.inc.php"))
|
||||
$res = @include ("../../../main.inc.php");
|
||||
if (! $res)
|
||||
die("Include of main fails");
|
||||
|
||||
// Class
|
||||
dol_include_once("/core/lib/report.lib.php");
|
||||
dol_include_once("/core/lib/date.lib.php");
|
||||
dol_include_once("/product/class/product.class.php");
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("compta");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
llxHeader('', $langs->trans("Accounts"));
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
print '<input type="button" class="button" style="float: right;" value="Renseigner les comptes comptables produits manquant" onclick="launch_export();" />';
|
||||
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell as codesell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
|
||||
$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1";
|
||||
|
||||
dol_syslog('accountancy/admin/productaccount.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
/*
|
||||
* view
|
||||
*/
|
||||
|
||||
print '<br><br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<td align="left">' . $langs->trans("Ref") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Label") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Description") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_buy") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
|
||||
|
||||
$var = true;
|
||||
|
||||
while ( $i < min($num, 250) ) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var = ! $var;
|
||||
|
||||
$compta_prodsell = $obj->accountancy_code_sell;
|
||||
if (empty($compta_prodsell)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
else
|
||||
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
|
||||
$compta_prodbuy = $obj->accountancy_code_buy;
|
||||
if (empty($compta_prodbuy)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
else
|
||||
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
|
||||
$product_static = new Product($db);
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
// Ref produit
|
||||
$product_static->ref = $objp->ref;
|
||||
$product_static->id = $objp->rowid;
|
||||
$product_static->type = $objp->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td align="left">' . $obj->ref . '</td>';
|
||||
print '<td align="left">' . $obj->label . '</td>';
|
||||
print '<td align="left">' . $obj->description . '</td>';
|
||||
|
||||
print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
||||
print '<td align="left">' . $compta_prodbuy . '</td>';
|
||||
|
||||
print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
||||
print '<td align="left">' . $compta_prodsell . '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i ++;
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
134
htdocs/accountancy/bookkeeping/balancebymonth.php
Normal file
134
htdocs/accountancy/bookkeeping/balancebymonth.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/bookkeeping/balancebymonth.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Balance by month
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("main");
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Filter
|
||||
$year = $_GET["year"];
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
llxHeader('', $langs->trans("CustomersVentilation"));
|
||||
|
||||
$textprevyear = "<a href=\"balancebymonth.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
|
||||
$textnextyear = " <a href=\"balancebymonth.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
|
||||
|
||||
print_fiche_titre($langs->trans("AccountBalanceByMonth") . ' ' . $textprevyear . ' ' . $langs->trans("Year") . ' ' . $year_start . ' ' . $textnextyear);
|
||||
|
||||
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "facture as f";
|
||||
$sql .= " WHERE fd.fk_code_ventilation = 0";
|
||||
$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
|
||||
|
||||
dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$row = $db->fetch_row($result);
|
||||
$nbfac = $row[0];
|
||||
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
$var = true;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width=150>' . $langs->trans("Label") . '</td><td align="center">' . $langs->trans("JanuaryMin") . '</td><td align="center">' . $langs->trans("FebruaryMin") . '</td><td align="center">' . $langs->trans("MarchMin") . '</td><td align="center">' . $langs->trans("AprilMin") . '</td><td align="center">' . $langs->trans("MayMin") . '</td><td align="center">' . $langs->trans("JuneMin") . '</td><td align="center">' . $langs->trans("JulyMin") . '</td><td align="center">' . $langs->trans("AugustMin") . '</td><td align="center">' . $langs->trans("SeptemberMin") . '</td><td align="center">' . $langs->trans("OctoberMin") . '</td><td align="center">' . $langs->trans("NovemberMin") . '</td><td align="center">' . $langs->trans("DecemberMin") . '</td><td align="center"><b>Total</b></td></tr>';
|
||||
|
||||
$sql = "SELECT bk.numero_compte AS 'compte',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',";
|
||||
$sql .= " ROUND(SUM(bk.montant),2) as 'Total'";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
$sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " GROUP BY bk.numero_compte";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $i < $num ) {
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<tr><td width="14%">' . length_accountg($row[0]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[1]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[2]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[3]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[4]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[5]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[6]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[7]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[8]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[9]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[10]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[11]) . '</td>';
|
||||
print '<td align="right" width="6.5%">' . price($row[12]) . '</td>';
|
||||
print '<td align="right" width="8%"><b>' . price($row[13]) . '</b></td>';
|
||||
print '</tr>';
|
||||
|
||||
$i ++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror();
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
375
htdocs/accountancy/bookkeeping/card.php
Normal file
375
htdocs/accountancy/bookkeeping/card.php
Normal file
@ -0,0 +1,375 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/bookkeeping/card.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page to show account
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("accounting");
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id', 'int');
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->access)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action');
|
||||
$piece_num = GETPOST("piece_num");
|
||||
|
||||
$mesg = '';
|
||||
|
||||
$numero_compte = GETPOST('numero_compte');
|
||||
$code_tiers = GETPOST('code_tiers');
|
||||
$label_compte = GETPOST('label_compte');
|
||||
$debit = price2num(GETPOST('debit'));
|
||||
$credit = price2num(GETPOST('credit'));
|
||||
|
||||
if ($action == "confirm_update") {
|
||||
|
||||
$error = 0;
|
||||
|
||||
if ((intval($debit) != 0) && (intval($credit) != 0)) {
|
||||
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$result = $book->fetch($id);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
$book->numero_compte = $numero_compte;
|
||||
$book->code_tiers = $code_tiers;
|
||||
$book->label_compte = $label_compte;
|
||||
$book->debit = $debit;
|
||||
$book->credit = $credit;
|
||||
|
||||
if (! empty($debit)) {
|
||||
$book->montant = $debit;
|
||||
$book->sens = 'D';
|
||||
}
|
||||
if (! empty($credit)) {
|
||||
$book->montant = $credit;
|
||||
$book->sens = 'C';
|
||||
}
|
||||
|
||||
$result = $book->update();
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == "add") {
|
||||
|
||||
$error = 0;
|
||||
if ((intval($debit) != 0) && (intval($credit) != 0)) {
|
||||
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$book->numero_compte = $numero_compte;
|
||||
$book->code_tiers = $code_tiers;
|
||||
$book->label_compte = $label_compte;
|
||||
$book->debit = $debit;
|
||||
$book->credit = $credit;
|
||||
$book->doc_date = GETPOST('doc_date');
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = $piece_num;
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = GETPOST('fk_doc');
|
||||
$book->fk_docdet = GETPOST('fk_docdet');
|
||||
|
||||
if (! empty($debit)) {
|
||||
$book->montant = $debit;
|
||||
$book->sens = 'D';
|
||||
}
|
||||
if (! empty($credit)) {
|
||||
$book->montant = $credit;
|
||||
$book->sens = 'C';
|
||||
}
|
||||
|
||||
$result = $book->create_std($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == "confirm_delete") {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$result = $book->fetch($id);
|
||||
|
||||
$piece_num = $book->piece_num;
|
||||
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
$result = $book->delete($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
|
||||
else if ($action == "confirm_create") {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$book->label_compte = '';
|
||||
$book->debit = 0;
|
||||
$book->credit = 0;
|
||||
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = GETPOST('next_num_mvt');
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = 0;
|
||||
$book->fk_docdet = 0;
|
||||
|
||||
$book->montant = 0;
|
||||
|
||||
$result = $book->create_std($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
$piece_num = $book->piece_num;
|
||||
}
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
/*
|
||||
* Confirmation to delete the command
|
||||
*/
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
if ($action == 'create') {
|
||||
|
||||
print_fiche_titre($langs->trans("CreateMvts"));
|
||||
|
||||
$code_journal_array = array (
|
||||
$conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL,
|
||||
$conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL,
|
||||
$conf->global->ACCOUNTING_BANK_JOURNAL => $conf->global->ACCOUNTING_BANK_JOURNAL,
|
||||
$conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL
|
||||
);
|
||||
|
||||
$book = new BookKeeping($db);
|
||||
$next_num_mvt = $book->getNextNumMvt();
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
|
||||
print '<input type="hidden" name="action" value="confirm_create">' . "\n";
|
||||
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("NumMvts") . '</td>';
|
||||
print '<td>' . $next_num_mvt . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td>';
|
||||
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Codejournal") . '</td>';
|
||||
|
||||
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docref") . '</td>';
|
||||
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Doctype") . '</td>';
|
||||
print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
print '<input type="submit" class="butAction" value="' . $langs->trans("Save") . '">';
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
$book = new BookKeeping($db);
|
||||
$result = $book->fetch_per_mvt($piece_num);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
}
|
||||
if (! empty($book->piece_num)) {
|
||||
|
||||
print_fiche_titre($langs->trans("UpdateMvts"));
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("NumMvts") . '</td>';
|
||||
print '<td>' . $book->piece_num . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td>' . dol_print_date($book->doc_date, 'daytextshort') . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Codejournal") . '</td>';
|
||||
print '<td>' . $book->code_journal . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docref") . '</td>';
|
||||
print '<td>' . $book->doc_ref . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Doctype") . '</td>';
|
||||
print '<td>' . $book->doc_type . '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
$result = $book->fetch_all_per_mvt($piece_num);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
|
||||
print_fiche_titre($langs->trans("ListeMvts"));
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
if (count($book->linesmvt) > 0) {
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print_liste_field_titre($langs->trans("Numerocompte"));
|
||||
print_liste_field_titre($langs->trans("Code_tiers"));
|
||||
print_liste_field_titre($langs->trans("Labelcompte"));
|
||||
print_liste_field_titre($langs->trans("Debit"));
|
||||
print_liste_field_titre($langs->trans("Credit"));
|
||||
print_liste_field_titre($langs->trans("Amount"));
|
||||
print_liste_field_titre($langs->trans("Sens"));
|
||||
|
||||
print '<td></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ( $book->linesmvt as $line ) {
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
if ($action == 'update' && $line->id == $id) {
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
|
||||
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
|
||||
print '<input type="hidden" name="action" value="confirm_update">' . "\n";
|
||||
print '<td><input type="text" size="6" name="numero_compte" value="' . $line->numero_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="code_tiers" value="' . $line->code_tiers . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>';
|
||||
print '<td>' . $line->montant . '</td>';
|
||||
print '<td>' . $line->sens . '</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($user->rights->accounting->access) {
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("Update") . '">';
|
||||
}
|
||||
print '</form>';
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td>' . $line->numero_compte . '</td>';
|
||||
print '<td>' . $line->code_tiers . '</td>';
|
||||
print '<td>' . $line->label_compte . '</td>';
|
||||
print '<td>' . $line->debit . '</td>';
|
||||
print '<td>' . $line->credit . '</td>';
|
||||
print '<td>' . $line->montant . '</td>';
|
||||
print '<td>' . $line->sens . '</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($user->rights->accouting->access) {
|
||||
print '<a href="./card.php?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
|
||||
print img_edit();
|
||||
print '</a> ';
|
||||
print '<a href="./card.php?action=delete&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
if ($action == "" || $action == 'add') {
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">' . "\n";
|
||||
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
|
||||
print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n";
|
||||
print '<input type="hidden" name="doc_ref" value="' . $book->doc_ref . '">' . "\n";
|
||||
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n";
|
||||
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
|
||||
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
|
||||
print '<td><input type="text" size="6" name="numero_compte" value="' . $numero_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="code_tiers" value="' . $code_tiers . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="debit" value="' . price($debit) . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="credit" value="' . price($credit) . '"/></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td><input type="submit" class="button" value="' . $langs->trans("Save") . '"></td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_fiche_titre($langs->trans("NoRecords"));
|
||||
}
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
218
htdocs/accountancy/bookkeeping/list.php
Normal file
218
htdocs/accountancy/bookkeeping/list.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/bookkeeping/list.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief List operation of book keeping
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
|
||||
$page = GETPOST("page");
|
||||
$sortorder = GETPOST("sortorder");
|
||||
$sortfield = GETPOST("sortfield");
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
if ($sortorder == "")
|
||||
$sortorder = "ASC";
|
||||
if ($sortfield == "")
|
||||
$sortfield = "bk.rowid";
|
||||
|
||||
$offset = $conf->liste_limit * $page;
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
if ($action == 'delbookkeeping') {
|
||||
|
||||
$import_key = GETPOST('importkey', 'alpha');
|
||||
|
||||
if (! empty($import_key)) {
|
||||
$object = new BookKeeping($db);
|
||||
$result = $object->delete_by_importkey($import_key);
|
||||
Header("Location: list.php");
|
||||
if ($result < 0) {
|
||||
setEventMessage($object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} // export csv
|
||||
else if ($action == 'export_csv') {
|
||||
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment;filename=export_csv.csv');
|
||||
|
||||
$object = new BookKeeping($db);
|
||||
$result = $object->export_bookkeping('ebp');
|
||||
if ($result < 0) {
|
||||
setEventMessage($object->errors, 'errors');
|
||||
}
|
||||
|
||||
foreach ( $object->linesexport as $line ) {
|
||||
print $line->id . ',';
|
||||
print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
|
||||
print '"' . $line->code_journal . '",';
|
||||
print '"' . $line->numero_compte . '",';
|
||||
print '"' . substr($line->code_journal, 0, 2) . '",';
|
||||
print '"' . substr($line->doc_ref, 0, 40) . '",';
|
||||
print '"' . $line->num_piece . '",';
|
||||
print '"' . $line->montant . '",';
|
||||
print '"' . $line->sens . '",';
|
||||
print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
|
||||
print '"' . $conf->currency . '",';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
llxHeader('', $langs->trans("Bookkeeping"));
|
||||
|
||||
/*
|
||||
* List
|
||||
*/
|
||||
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
|
||||
if (dol_strlen(trim(GETPOST("search_doc_type")))) {
|
||||
|
||||
$sql .= " WHERE bk.doc_type LIKE '%" . GETPOST("search_doc_type") . "%'";
|
||||
|
||||
if (dol_strlen(trim(GETPOST("search_doc_ref")))) {
|
||||
$sql .= " AND bk.doc_ref LIKE '%" . GETPOST("search_doc_ref") . "%'";
|
||||
}
|
||||
}
|
||||
if (dol_strlen(trim(GETPOST("search_doc_ref")))) {
|
||||
$sql .= " WHERE bk.doc_ref LIKE '%" . GETPOST("search_doc_ref") . "%'";
|
||||
}
|
||||
if (dol_strlen(trim(GETPOST("search_compte")))) {
|
||||
$sql .= " WHERE bk.numero_compte LIKE '%" . GETPOST("search_compte") . "%'";
|
||||
}
|
||||
if (dol_strlen(trim(GETPOST("search_tiers")))) {
|
||||
$sql .= " WHERE bk.code_tiers LIKE '%" . GETPOST("search_tiers") . "%'";
|
||||
}
|
||||
if (dol_strlen(trim(GETPOST("search_journal")))) {
|
||||
$sql .= " WHERE bk.code_journal LIKE '%" . GETPOST("search_journal") . "%'";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/bookkeeping/list.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
|
||||
|
||||
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="delbookkeeping">';
|
||||
|
||||
print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey'));
|
||||
|
||||
print '<div class="inline-block divButAction"><input type="submit" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" />';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<a href="./card.php?action=create" class="butAction">' . $langs->trans("NewAccountingMvt") . '</a></div>';
|
||||
|
||||
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="export_csv">';
|
||||
print '<input type="submit" class="button" style="float: right;" value="Export CSV" />';
|
||||
print '</form>';
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre(" ");
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
|
||||
print '<td><input type="text" name="search_doc_type" value="' . $_GET["search_doc_type"] . '"></td>';
|
||||
print '<td> </td>';
|
||||
print '<td><input type="text" name="search_doc_ref" value="' . $_GET["search_doc_ref"] . '"></td>';
|
||||
print '<td><input type="text" name="search_compte" value="' . $_GET["search_compte"] . '"></td>';
|
||||
print '<td><input type="text" name="search_tiers" value="' . $_GET["search_tiers"] . '"></td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td><input type="text" name="search_journal" size="3" value="' . $_GET["search_journal"] . '"></td>';
|
||||
print '<td align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
|
||||
print '</td>';
|
||||
print '</form>';
|
||||
print '</tr>';
|
||||
|
||||
$var = True;
|
||||
|
||||
while ( $i < min($num, $conf->liste_limit) ) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var = ! $var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td>' . $obj->doc_type . '</td>';
|
||||
print '<td>' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
|
||||
print '<td>' . $obj->doc_ref . '</td>';
|
||||
print '<td>' . length_accountg($obj->numero_compte) . '</td>';
|
||||
print '<td>' . length_accounta($obj->code_tiers) . '</td>';
|
||||
print '<td>' . $obj->label_compte . '</td>';
|
||||
print '<td align="right">' . price($obj->debit) . '</td>';
|
||||
print '<td align="right">' . price($obj->credit) . '</td>';
|
||||
print '<td align="right">' . price($obj->montant) . '</td>';
|
||||
print '<td>' . $obj->sens . '</td>';
|
||||
print '<td>' . $obj->code_journal . '</td>';
|
||||
print '<td><a href="./card.php?piece_num=' . $obj->piece_num . '">' . img_edit() . '</a></td>';
|
||||
print "</tr>\n";
|
||||
$i ++;
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
128
htdocs/accountancy/bookkeeping/listbyyear.php
Normal file
128
htdocs/accountancy/bookkeeping/listbyyear.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/bookkeeping/listbyyear.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Book keeping by year
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("accountancy");
|
||||
|
||||
$page = GETPOST("page");
|
||||
$sortorder = GETPOST("sortorder");
|
||||
$sortfield = GETPOST("sortfield");
|
||||
|
||||
// Filter
|
||||
$year = GETPOST("year", 'int');
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
|
||||
if ($sortorder == "")
|
||||
$sortorder = "ASC";
|
||||
if ($sortfield == "")
|
||||
$sortfield = "bk.rowid";
|
||||
|
||||
$offset = $conf->liste_limit * $page;
|
||||
|
||||
llxHeader('', $langs->trans("Bookkeeping"));
|
||||
|
||||
$textprevyear = "<a href=\"listbyyear.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
|
||||
$textnextyear = " <a href=\"listbyyear.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
|
||||
|
||||
/*
|
||||
* Mode Liste
|
||||
*
|
||||
*/
|
||||
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens, bk.code_journal";
|
||||
$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 .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/bookkeeping/listbyyear.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
print_barre_liste($langs->trans("Bookkeeping") . " $textprevyear " . $langs->trans("Year") . " $year_start $textnextyear", $page, $_SERVER['PHP_SELF'], "", $sortfield, $sortorder, '', $num);
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre(" ");
|
||||
print "</tr>\n";
|
||||
|
||||
$var = True;
|
||||
|
||||
while ( $i < min($num, $conf->liste_limit) ) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var = ! $var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td>' . $obj->doc_type . '</td>' . "\n";
|
||||
print '<td>' . dol_print_date($db->jdate($obj->doc_date)) . '</td>';
|
||||
print '<td>' . $obj->doc_ref . '</td>';
|
||||
print '<td>' . length_accountg($obj->numero_compte) . '</td>';
|
||||
print '<td>' . length_accounta($obj->code_tiers) . '</td>';
|
||||
print '<td>' . $obj->label_compte . '</td>';
|
||||
print '<td align="right">' . price($obj->debit) . '</td>';
|
||||
print '<td align="right">' . price($obj->credit) . '</td>';
|
||||
print '<td align="right">' . price($obj->montant) . '</td>';
|
||||
print '<td>' . $obj->sens . '</td>';
|
||||
print '<td>' . $obj->code_journal . '</td>';
|
||||
print '<td><a href="./card.php?action=update&id=' . $obj->rowid . '">' . img_edit() . '</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i ++;
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/class/accountancyaccount.class.php
|
||||
* \ingroup accounting
|
||||
* \brief Fichier de la classe des comptes comptables
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \class AccountancyAccount
|
||||
* \brief Classe permettant la gestion des comptes
|
||||
*/
|
||||
class AccountancyAccount
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
var $rowid;
|
||||
var $fk_pcg_version;
|
||||
var $pcg_type;
|
||||
var $pcg_subtype;
|
||||
var $label;
|
||||
var $account_number;
|
||||
var $account_parent;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert account into database
|
||||
*
|
||||
* @param User $user User making add
|
||||
* @return int <0 if KO, Id line added if OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
$now=dol_now();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingaccount";
|
||||
$sql.= " (date_creation, fk_user_author, numero,intitule)";
|
||||
$sql.= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->numero."','".$this->intitule."')";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."accountingaccount");
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
$result = $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -2;
|
||||
$this->error="AccountancyAccount::Create Erreur $result";
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -1;
|
||||
$this->error="AccountancyAccount::Create Erreur $result";
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -16,20 +18,18 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/class/accountancysystem.class.php
|
||||
* \ingroup accounting
|
||||
* \brief File of class to manage accountancy systems
|
||||
* \file htdocs/accountancy/class/accountancysystem.class.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief File of class to manage accountancy systems
|
||||
*/
|
||||
|
||||
|
||||
/** \class AccountancySystem
|
||||
* \brief Classe to manage accountancy systems
|
||||
/**
|
||||
* Class to manage accountancy systems
|
||||
*/
|
||||
class AccountancySystem
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
var $rowid;
|
||||
var $fk_pcg_version;
|
||||
var $pcg_type;
|
||||
@ -38,57 +38,47 @@ class AccountancySystem
|
||||
var $account_number;
|
||||
var $account_parent;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param DoliDB $db handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
function __construct($db) {
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert accountancy system name into database
|
||||
* Insert accountancy system name into database
|
||||
*
|
||||
* @param User $user User making insert
|
||||
* @return int <0 if KO, Id of line if OK
|
||||
* @param User $user making insert
|
||||
* @return int if KO, Id of line if OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
$now=dol_now();
|
||||
function create($user) {
|
||||
$now = dol_now();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
|
||||
$sql.= " (date_creation, fk_user_author, numero,intitule)";
|
||||
$sql.= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->numero."','".$this->intitule."')";
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system";
|
||||
$sql .= " (date_creation, fk_user_author, numero, label)";
|
||||
$sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->label . "')";
|
||||
|
||||
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system");
|
||||
if ($resql) {
|
||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system");
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$this->id = $id;
|
||||
$result = $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -2;
|
||||
$this->error="AccountancySystem::Create Erreur $result";
|
||||
} else {
|
||||
$result = - 2;
|
||||
$this->error = "AccountancySystem::Create Erreur $result";
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -1;
|
||||
$this->error="AccountancySystem::Create Erreur $result";
|
||||
} else {
|
||||
$result = - 1;
|
||||
$this->error = "AccountancySystem::Create Erreur $result";
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
447
htdocs/accountancy/class/accountingaccount.class.php
Normal file
447
htdocs/accountancy/class/accountingaccount.class.php
Normal file
@ -0,0 +1,447 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/class/accountingaccount.class.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Fichier de la classe des comptes comptable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Classe permettant la gestion des comptes generaux de compta
|
||||
*/
|
||||
class AccountingAccount
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
var $id;
|
||||
var $rowid;
|
||||
|
||||
var $datec; // Creation date
|
||||
var $fk_pcg_version;
|
||||
var $pcg_type;
|
||||
var $pcg_subtype;
|
||||
var $account_number;
|
||||
var $account_parent;
|
||||
var $label;
|
||||
var $fk_user_author;
|
||||
var $fk_user_modif;
|
||||
var $active;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handle
|
||||
*/
|
||||
function __construct($db)
|
||||
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load record in memory
|
||||
*
|
||||
* @param int $rowid Id
|
||||
* @param string $account_number Account number
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($rowid = null, $account_number = null)
|
||||
{
|
||||
if ($rowid || $account_number)
|
||||
{
|
||||
$sql = "SELECT rowid, datec, tms, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, fk_user_author, fk_user_modif, active";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE";
|
||||
if ($rowid) {
|
||||
$sql .= " rowid = '" . $rowid . "'";
|
||||
} elseif ($account_number) {
|
||||
$sql .= " account_number = '" . $account_number . "'";
|
||||
}
|
||||
|
||||
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->rowid = $obj->rowid;
|
||||
$this->datec = $obj->datec;
|
||||
$this->tms = $obj->tms;
|
||||
$this->fk_pcg_version = $obj->fk_pcg_version;
|
||||
$this->pcg_type = $obj->pcg_type;
|
||||
$this->pcg_subtype = $obj->pcg_subtype;
|
||||
$this->account_number = $obj->account_number;
|
||||
$this->account_parent = $obj->account_parent;
|
||||
$this->label = $obj->label;
|
||||
$this->fk_user_author = $obj->fk_user_author;
|
||||
$this->fk_user_modif = $obj->fk_user_modif;
|
||||
$this->active = $obj->active;
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert line in accountingaccount
|
||||
*
|
||||
* @param User $user Use making action
|
||||
* @param int $notrigger Disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_pcg_version))
|
||||
$this->fk_pcg_version = trim($this->fk_pcg_version);
|
||||
if (isset($this->pcg_type))
|
||||
$this->pcg_type = trim($this->pcg_type);
|
||||
if (isset($this->pcg_subtype))
|
||||
$this->pcg_subtype = trim($this->pcg_subtype);
|
||||
if (isset($this->account_number))
|
||||
$this->account_number = trim($this->account_number);
|
||||
if (isset($this->account_parent))
|
||||
$this->account_parent = trim($this->account_parent);
|
||||
if (isset($this->label))
|
||||
$this->label = trim($this->label);
|
||||
if (isset($this->fk_user_author))
|
||||
$this->fk_user_author = trim($this->fk_user_author);
|
||||
if (isset($this->active))
|
||||
$this->active = trim($this->active);
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accountingaccount(";
|
||||
|
||||
$sql .= "datec";
|
||||
$sql .= ", entity";
|
||||
$sql .= ", fk_pcg_version";
|
||||
$sql .= ", pcg_type";
|
||||
$sql .= ", pcg_subtype";
|
||||
$sql .= ", account_number";
|
||||
$sql .= ", account_parent";
|
||||
$sql .= ", label";
|
||||
$sql .= ", fk_user_author";
|
||||
$sql .= ", active";
|
||||
|
||||
$sql .= ") VALUES (";
|
||||
|
||||
$sql .= " '" . $this->db->idate($now) . "'";
|
||||
$sql .= ", " . $conf->entity;
|
||||
$sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
|
||||
$sql .= ", " . (! isset($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
|
||||
$sql .= ", " . (! isset($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'");
|
||||
$sql .= ", " . (! isset($this->account_number) ? 'NULL' : "'" . $this->account_number . "'");
|
||||
$sql .= ", " . (! isset($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'");
|
||||
$sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
|
||||
$sql .= ", " . $user->id;
|
||||
$sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'");
|
||||
|
||||
$sql .= ")";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accountingaccount");
|
||||
|
||||
if (! $notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
// // Call triggers
|
||||
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
// $interface=new Interfaces($this->db);
|
||||
// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
|
||||
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// // End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update record
|
||||
*
|
||||
* @param User $user Use making update
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
|
||||
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
|
||||
$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
|
||||
$sql .= " , pcg_subtype = " . ($this->pcg_subtype ? "'" . $this->db->escape($this->pcg_subtype) . "'" : "null");
|
||||
$sql .= " , account_number = '" . $this->account_number . "'";
|
||||
$sql .= " , account_parent = '" . $this->account_parent . "'";
|
||||
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
|
||||
$sql .= " , fk_user_modif = " . $user->id;
|
||||
$sql .= " , active = '" . $this->active . "'";
|
||||
|
||||
$sql .= " WHERE rowid = " . $this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check usage of accounting code
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function checkUsage()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
|
||||
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
|
||||
$sql .= "UNION";
|
||||
$sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det";
|
||||
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
|
||||
|
||||
dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num > 0) {
|
||||
$this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse');
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that deletes
|
||||
* @param int $notrigger 0=triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$result = $this->checkUsage();
|
||||
|
||||
if ($result > 0) {
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error) {
|
||||
if (! $notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
// // Call triggers
|
||||
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
// $interface=new Interfaces($this->db);
|
||||
// $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf);
|
||||
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// // End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accountingaccount";
|
||||
$sql .= " WHERE rowid=" . $this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Information on record
|
||||
*
|
||||
* @param int $id of record
|
||||
* @return void
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as a';
|
||||
$sql .= ' WHERE a.rowid = ' . $id;
|
||||
|
||||
dol_syslog(get_class($this) . '::info sql=' . $sql);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_modif) {
|
||||
$muser = new User($this->db);
|
||||
$muser->fetch($obj->fk_user_modif);
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->tms);
|
||||
}
|
||||
$this->db->free($result);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Account desactivate
|
||||
*
|
||||
* @param int $id Id
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function account_desactivate($id)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result = $this->checkUsage();
|
||||
|
||||
if ($result > 0) {
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
|
||||
$sql .= "SET active = '0'";
|
||||
$sql .= " WHERE rowid = ".$this->db->escape($id);
|
||||
|
||||
dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return - 1;
|
||||
}
|
||||
} else {
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Account activate
|
||||
*
|
||||
* @param int $id Id
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function account_activate($id)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
|
||||
$sql .= "SET active = '1'";
|
||||
$sql .= " WHERE rowid = ".$this->db->escape($id);
|
||||
|
||||
dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
712
htdocs/accountancy/class/bookkeeping.class.php
Normal file
712
htdocs/accountancy/class/bookkeeping.class.php
Normal file
@ -0,0 +1,712 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/class/bookkeeping.class.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief File of class to manage book keeping
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to manage accountancy book keeping
|
||||
*/
|
||||
class BookKeeping
|
||||
{
|
||||
var $db;
|
||||
var $id;
|
||||
var $doc_date;
|
||||
var $doc_type;
|
||||
var $doc_ref;
|
||||
var $date_create;
|
||||
var $fk_doc;
|
||||
var $fk_docdet;
|
||||
var $code_tiers;
|
||||
var $numero_compte;
|
||||
var $label_compte;
|
||||
var $debit;
|
||||
var $credit;
|
||||
var $montant;
|
||||
var $sens;
|
||||
var $fk_user_author;
|
||||
var $code_journal;
|
||||
var $piece_num;
|
||||
var $linesexport = array ();
|
||||
var $linesmvt = array ();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a line into memory from database
|
||||
*
|
||||
* @param int $id id of line to get
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers, ";
|
||||
$sql .= " numero_compte, label_compte, debit, credit, ";
|
||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
|
||||
$sql .= " WHERE rowid = '" . $id . "'";
|
||||
|
||||
dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->doc_date = $this->db->jdate($obj->doc_date);
|
||||
$this->doc_type = $obj->doc_type;
|
||||
$this->doc_ref = $obj->doc_ref;
|
||||
$this->fk_doc = $obj->fk_doc;
|
||||
$this->fk_docdet = $obj->fk_docdet;
|
||||
$this->code_tiers = $obj->code_tiers;
|
||||
$this->numero_compte = $obj->numero_compte;
|
||||
$this->label_compte = $obj->label_compte;
|
||||
$this->debit = $obj->debit;
|
||||
$this->credit = $obj->credit;
|
||||
$this->montant = $obj->montant;
|
||||
$this->sens = $obj->sens;
|
||||
$this->code_journal = $obj->code_journal;
|
||||
$this->piece_num = $obj->piece_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an accounting document into memory from database
|
||||
*
|
||||
* @param int $piecenum Accounting document to get
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch_per_mvt($piecenum)
|
||||
{
|
||||
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||
$sql .= " WHERE piece_num = '" . $piecenum . "'";
|
||||
|
||||
dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->piece_num = $obj->piece_num;
|
||||
$this->code_journal = $obj->code_journal;
|
||||
$this->doc_date = $this->db->jdate($obj->doc_date);
|
||||
$this->doc_ref = $obj->doc_ref;
|
||||
$this->doc_type = $obj->doc_type;
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next number movement
|
||||
*
|
||||
* @return string Last number
|
||||
*/
|
||||
function getNextNumMvt() {
|
||||
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||
|
||||
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
return $obj->max;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all informations of accountancy document
|
||||
*
|
||||
* @param int $piecenum id of line to get
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch_all_per_mvt($piecenum)
|
||||
{
|
||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||
$sql .= " numero_compte, label_compte, debit, credit,";
|
||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
|
||||
$sql .= " WHERE piece_num = '" . $piecenum . "'";
|
||||
|
||||
dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
|
||||
while ( $obj = $this->db->fetch_object($result) ) {
|
||||
|
||||
$line = new BookKeepingLine();
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
|
||||
$line->doc_date = $this->db->jdate($obj->doc_date);
|
||||
$line->doc_type = $obj->doc_type;
|
||||
$line->doc_ref = $obj->doc_ref;
|
||||
$line->fk_doc = $obj->fk_doc;
|
||||
$line->fk_docdet = $obj->fk_docdet;
|
||||
$line->code_tiers = $obj->code_tiers;
|
||||
$line->numero_compte = $obj->numero_compte;
|
||||
$line->label_compte = $obj->label_compte;
|
||||
$line->debit = $obj->debit;
|
||||
$line->credit = $obj->credit;
|
||||
$line->montant = $obj->montant;
|
||||
$line->sens = $obj->sens;
|
||||
$line->code_journal = $obj->code_journal;
|
||||
$line->piece_num = $obj->piece_num;
|
||||
|
||||
$this->linesmvt[] = $line;
|
||||
}
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert line into bookkeeping
|
||||
*
|
||||
* @param User $user User who inserted operation
|
||||
* @return $result Result
|
||||
*/
|
||||
function create($user='')
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$this->piece_num = 0;
|
||||
|
||||
// first check if line not yet in bookkeeping
|
||||
$sql = "SELECT count(*)";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
|
||||
$sql .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
||||
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
|
||||
|
||||
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql) {
|
||||
$row = $this->db->fetch_array($resql);
|
||||
if ($row[0] == 0) {
|
||||
|
||||
// Determine piece_num
|
||||
$sqlnum = "SELECT piece_num";
|
||||
$sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
|
||||
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
|
||||
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'";
|
||||
|
||||
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
||||
$resqlnum = $this->db->query($sqlnum);
|
||||
if ($resqlnum)
|
||||
{
|
||||
$objnum = $this->db->fetch_object($resqlnum);
|
||||
$this->piece_num = $objnum->piece_num;
|
||||
}
|
||||
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
|
||||
if (empty($this->piece_num))
|
||||
{
|
||||
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
|
||||
$sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
|
||||
|
||||
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
||||
$resqlnum = $this->db->query($sqlnum);
|
||||
if ($resqlnum) {
|
||||
$objnum = $this->db->fetch_object($resqlnum);
|
||||
$this->piece_num = $objnum->maxpiecenum;
|
||||
}
|
||||
}
|
||||
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
|
||||
if (empty($this->piece_num)) {
|
||||
$this->piece_num = 1;
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
if (empty($this->date_create))
|
||||
$this->date_create = $now();
|
||||
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, ";
|
||||
$sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,";
|
||||
$sql .= "debit,credit,montant,sens,fk_user_author,import_key,code_journal,piece_num)";
|
||||
$sql .= " VALUES ('" . $this->doc_date . "','" . $this->doc_type . "','" . $this->doc_ref . "'," . $this->fk_doc . ",";
|
||||
$sql .= $this->fk_docdet . ",'" . $this->code_tiers . "','" . $this->numero_compte . "','" . $this->db->escape($this->label_compte) . "',";
|
||||
$sql .= $this->debit . "," . $this->credit . "," . $this->montant . ",'" . $this->sens . "'," . $user->id . ", '";
|
||||
$sql .= $this->date_create . "','" . $this->code_journal . "'," . $this->piece_num . ")";
|
||||
|
||||
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping");
|
||||
|
||||
if ($id > 0) {
|
||||
$this->id = $id;
|
||||
$result = 0;
|
||||
} else {
|
||||
$result = - 2;
|
||||
dol_syslog("BookKeeping::Create Erreur $result lecture ID");
|
||||
}
|
||||
} else {
|
||||
$result = - 1;
|
||||
dol_syslog("BookKeeping::Create Erreur $result INSERT Mysql");
|
||||
}
|
||||
} else {
|
||||
$result = - 3;
|
||||
dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql");
|
||||
}
|
||||
} else {
|
||||
$result = - 5;
|
||||
dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete bookkepping by importkey
|
||||
*
|
||||
* @param string $importkey Import key
|
||||
* @return int Result
|
||||
*/
|
||||
function delete_by_importkey($importkey) {
|
||||
$this->db->begin();
|
||||
|
||||
// first check if line not yet in bookkeeping
|
||||
$sql = "DELETE";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
|
||||
$sql .= " WHERE import_key = '" . $importkey . "'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user Object user that create
|
||||
* @param int $notrigger 1=Does not execute triggers, 0 otherwise
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function create_std($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->doc_type))
|
||||
$this->doc_type = trim($this->doc_type);
|
||||
if (isset($this->doc_ref))
|
||||
$this->doc_ref = trim($this->doc_ref);
|
||||
if (isset($this->fk_doc))
|
||||
$this->fk_doc = trim($this->fk_doc);
|
||||
if (isset($this->fk_docdet))
|
||||
$this->fk_docdet = trim($this->fk_docdet);
|
||||
if (isset($this->code_tiers))
|
||||
$this->code_tiers = trim($this->code_tiers);
|
||||
if (isset($this->numero_compte))
|
||||
$this->numero_compte = trim($this->numero_compte);
|
||||
if (isset($this->label_compte))
|
||||
$this->label_compte = trim($this->label_compte);
|
||||
if (isset($this->debit))
|
||||
$this->debit = trim($this->debit);
|
||||
if (isset($this->credit))
|
||||
$this->credit = trim($this->credit);
|
||||
if (isset($this->montant))
|
||||
$this->montant = trim($this->montant);
|
||||
if (isset($this->sens))
|
||||
$this->sens = trim($this->sens);
|
||||
if (isset($this->fk_user_author))
|
||||
$this->fk_user_author = trim($this->fk_user_author);
|
||||
if (isset($this->import_key))
|
||||
$this->import_key = trim($this->import_key);
|
||||
if (isset($this->code_journal))
|
||||
$this->code_journal = trim($this->code_journal);
|
||||
if (isset($this->piece_num))
|
||||
$this->piece_num = trim($this->piece_num);
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping(";
|
||||
$sql .= "doc_date,";
|
||||
$sql .= "doc_type,";
|
||||
$sql .= "doc_ref,";
|
||||
$sql .= "fk_doc,";
|
||||
$sql .= "fk_docdet,";
|
||||
$sql .= "code_tiers,";
|
||||
$sql .= "numero_compte,";
|
||||
$sql .= "label_compte,";
|
||||
$sql .= "debit,";
|
||||
$sql .= "credit,";
|
||||
$sql .= "montant,";
|
||||
$sql .= "sens,";
|
||||
$sql .= "fk_user_author,";
|
||||
$sql .= "import_key,";
|
||||
$sql .= "code_journal,";
|
||||
$sql .= "piece_num";
|
||||
|
||||
$sql .= ") VALUES (";
|
||||
|
||||
$sql .= " " . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : $this->db->idate($this->doc_date)) . ",";
|
||||
$sql .= " " . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->fk_doc) ? 'NULL' : "'" . $this->fk_doc . "'") . ",";
|
||||
$sql .= " " . (! isset($this->fk_docdet) ? 'NULL' : "'" . $this->fk_docdet . "'") . ",";
|
||||
$sql .= " " . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->debit) ? 'NULL' : "'" . $this->debit . "'") . ",";
|
||||
$sql .= " " . (! isset($this->credit) ? 'NULL' : "'" . $this->credit . "'") . ",";
|
||||
$sql .= " " . (! isset($this->montant) ? 'NULL' : "'" . $this->montant . "'") . ",";
|
||||
$sql .= " " . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->piece_num) ? 'NULL' : "'" . $this->piece_num . "'") . "";
|
||||
|
||||
$sql .= ")";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this) . "::create_std sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping");
|
||||
|
||||
if (! $notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
// // Call triggers
|
||||
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
// $interface=new Interfaces($this->db);
|
||||
// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
|
||||
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// // End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::create_std " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user Object user that create
|
||||
* @param int $notrigger 1=Does not execute triggers, 0 otherwise
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user = 0, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->doc_type))
|
||||
$this->doc_type = trim($this->doc_type);
|
||||
if (isset($this->doc_ref))
|
||||
$this->doc_ref = trim($this->doc_ref);
|
||||
if (isset($this->fk_doc))
|
||||
$this->fk_doc = trim($this->fk_doc);
|
||||
if (isset($this->fk_docdet))
|
||||
$this->fk_docdet = trim($this->fk_docdet);
|
||||
if (isset($this->code_tiers))
|
||||
$this->code_tiers = trim($this->code_tiers);
|
||||
if (isset($this->numero_compte))
|
||||
$this->numero_compte = trim($this->numero_compte);
|
||||
if (isset($this->label_compte))
|
||||
$this->label_compte = trim($this->label_compte);
|
||||
if (isset($this->debit))
|
||||
$this->debit = trim($this->debit);
|
||||
if (isset($this->credit))
|
||||
$this->credit = trim($this->credit);
|
||||
if (isset($this->montant))
|
||||
$this->montant = trim($this->montant);
|
||||
if (isset($this->sens))
|
||||
$this->sens = trim($this->sens);
|
||||
if (isset($this->fk_user_author))
|
||||
$this->fk_user_author = trim($this->fk_user_author);
|
||||
if (isset($this->import_key))
|
||||
$this->import_key = trim($this->import_key);
|
||||
if (isset($this->code_journal))
|
||||
$this->code_journal = trim($this->code_journal);
|
||||
if (isset($this->piece_num))
|
||||
$this->piece_num = trim($this->piece_num);
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add a control on parameters values
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET";
|
||||
|
||||
$sql .= " doc_date=" . (dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ",";
|
||||
$sql .= " doc_type=" . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ",";
|
||||
$sql .= " doc_ref=" . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ",";
|
||||
$sql .= " fk_doc=" . (isset($this->fk_doc) ? $this->fk_doc : "null") . ",";
|
||||
$sql .= " fk_docdet=" . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ",";
|
||||
$sql .= " code_tiers=" . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ",";
|
||||
$sql .= " numero_compte=" . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ",";
|
||||
$sql .= " label_compte=" . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ",";
|
||||
$sql .= " debit=" . (isset($this->debit) ? $this->debit : "null") . ",";
|
||||
$sql .= " credit=" . (isset($this->credit) ? $this->credit : "null") . ",";
|
||||
$sql .= " montant=" . (isset($this->montant) ? $this->montant : "null") . ",";
|
||||
$sql .= " sens=" . (isset($this->sens) ? "'" . $this->db->escape($this->sens) . "'" : "null") . ",";
|
||||
$sql .= " fk_user_author=" . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ",";
|
||||
$sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ",";
|
||||
$sql .= " code_journal=" . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ",";
|
||||
$sql .= " piece_num=" . (isset($this->piece_num) ? $this->piece_num : "null") . "";
|
||||
|
||||
$sql .= " WHERE rowid=" . $this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (! $notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
// // Call triggers
|
||||
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
// $interface=new Interfaces($this->db);
|
||||
// $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
|
||||
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// // End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user Object user that create
|
||||
* @param int $notrigger 1=Does not execute triggers, 0 otherwise
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||
$sql .= " WHERE rowid=" . $this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete bookkepping by importkey
|
||||
*
|
||||
* @param string $model Model
|
||||
* @return int Result
|
||||
*/
|
||||
function export_bookkeping($model = 'ebp')
|
||||
{
|
||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||
$sql .= " numero_compte, label_compte, debit, credit,";
|
||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
dol_syslog(get_class($this) . "::export_bookkeping sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$this->linesexport = array ();
|
||||
|
||||
$num = $this->db->num_rows($resql);
|
||||
while ( $obj = $this->db->fetch_object($resql) ) {
|
||||
$line = new BookKeepingLine();
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
|
||||
$line->doc_date = $this->db->jdate($obj->doc_date);
|
||||
$line->doc_type = $obj->doc_type;
|
||||
$line->doc_ref = $obj->doc_ref;
|
||||
$line->fk_doc = $obj->fk_doc;
|
||||
$line->fk_docdet = $obj->fk_docdet;
|
||||
$line->code_tiers = $obj->code_tiers;
|
||||
$line->numero_compte = $obj->numero_compte;
|
||||
$line->label_compte = $obj->label_compte;
|
||||
$line->debit = $obj->debit;
|
||||
$line->credit = $obj->credit;
|
||||
$line->montant = $obj->montant;
|
||||
$line->sens = $obj->sens;
|
||||
$line->code_journal = $obj->code_journal;
|
||||
$line->piece_num = $obj->piece_num;
|
||||
|
||||
$this->linesexport[] = $line;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return $num;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::export_bookkeping " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class BookKeepingLine
|
||||
*/
|
||||
class BookKeepingLine
|
||||
{
|
||||
var $id;
|
||||
var $doc_date;
|
||||
var $doc_type;
|
||||
var $doc_ref;
|
||||
var $fk_doc;
|
||||
var $fk_docdet;
|
||||
var $code_tiers;
|
||||
var $numero_compte;
|
||||
var $label_compte;
|
||||
var $debit;
|
||||
var $credit;
|
||||
var $montant;
|
||||
var $sens;
|
||||
var $fk_user_author;
|
||||
var $code_journal;
|
||||
var $piece_num;
|
||||
}
|
||||
263
htdocs/accountancy/class/html.formventilation.class.php
Normal file
263
htdocs/accountancy/class/html.formventilation.class.php
Normal file
@ -0,0 +1,263 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/class/html.formventilation.class.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief File of class with all html predefined components
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to manage generation of HTML components for bank module
|
||||
*/
|
||||
class FormVentilation extends Form
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return select filter with date of transaction
|
||||
*
|
||||
* @param string $htmlname Name of select field
|
||||
* @param string $selectedkey Value
|
||||
* @return string HTML edit field
|
||||
*/
|
||||
function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey='')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$date_array = array ();
|
||||
|
||||
$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
|
||||
$sql .= ' ORDER BY import_key DESC';
|
||||
|
||||
$out = '<SELECT name="' . $htmlname . '">';
|
||||
|
||||
dol_syslog(get_class($this) . "::select_bookkeeping_importkey sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ( $i < $num ) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$selected = '';
|
||||
if ($selectedkey == $obj->import_key) {
|
||||
$selected = ' selected="selected" ';
|
||||
}
|
||||
|
||||
$out .= '<OPTION value="' . $obj->import_key . '"' . $selected . '>' . $obj->import_key . '</OPTION>';
|
||||
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
|
||||
$out .= '</SELECT>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of accounts with label by chart of accounts
|
||||
*
|
||||
* @param string $selectid Preselected chart of accounts
|
||||
* @param string $htmlname Name of field in html form
|
||||
* @param int $showempty Add an empty field
|
||||
* @param array $event Event options
|
||||
*
|
||||
* @return string String with HTML select
|
||||
*/
|
||||
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array())
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$out = '';
|
||||
|
||||
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
|
||||
$sql .= " AND aa.active = 1";
|
||||
$sql .= " ORDER BY aa.account_number";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
|
||||
$out .= ajax_combobox($htmlname, $event);
|
||||
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
|
||||
if ($showempty)
|
||||
$out .= '<option value="-1"></option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ( $i < $num ) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$label = $obj->account_number . ' - ' . $obj->label;
|
||||
|
||||
// Remember guy's we store in database llx_facturedet the rowid of accountingaccount and not the account_number
|
||||
// Bacause same account_number can be share between different accounting_system and do have the same meaning
|
||||
if (($selectid != '') && $selectid == $obj->rowid) {
|
||||
// $out .= '<option value="' . $obj->account_number . '" selected="selected">' . $label . '</option>';
|
||||
$out .= '<option value="' . $obj->rowid . '" selected="selected">' . $label . '</option>';
|
||||
} else {
|
||||
// $out .= '<option value="' . $obj->account_number . '">' . $label . '</option>';
|
||||
$out .= '<option value="' . $obj->rowid . '">' . $label . '</option>';
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
$out .= '</select>';
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of accounts with label by class of accounts
|
||||
*
|
||||
* @param string $selectid Preselected pcg_type
|
||||
* @param string $htmlname Name of field in html form
|
||||
* @param int $showempty Add an empty field
|
||||
* @param array $event Event options
|
||||
*
|
||||
* @return string String with HTML select
|
||||
*/
|
||||
function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array())
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$out = '';
|
||||
|
||||
$sql = "SELECT DISTINCT pcg_type ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
|
||||
$sql .= " ORDER BY pcg_type";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
|
||||
$out .= ajax_combobox($htmlname, $event);
|
||||
|
||||
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
|
||||
if ($showempty)
|
||||
$out .= '<option value="-1"></option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ( $i < $num ) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$label = $obj->pcg_type;
|
||||
|
||||
if (($selectid != '') && $selectid == $obj->pcg_type) {
|
||||
$out .= '<option value="' . $obj->pcg_type . '" selected="selected">' . $label . '</option>';
|
||||
} else {
|
||||
$out .= '<option value="' . $obj->pcg_type . '">' . $label . '</option>';
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
$out .= '</select>';
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::select_pcgtype " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of accounts with label by sub_class of accounts
|
||||
*
|
||||
* @param string $selectid Preselected pcg_type
|
||||
* @param string $htmlname Name of field in html form
|
||||
* @param int $showempty Add an empty field
|
||||
* @param array $event Event options
|
||||
*
|
||||
* @return string String with HTML select
|
||||
*/
|
||||
function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array())
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$out = '';
|
||||
|
||||
$sql = "SELECT DISTINCT pcg_subtype ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
|
||||
$sql .= " ORDER BY pcg_subtype";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
|
||||
$out .= ajax_combobox($htmlname, $event);
|
||||
|
||||
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
|
||||
if ($showempty)
|
||||
$out .= '<option value="-1"></option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ( $i < $num ) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$label = $obj->pcg_subtype;
|
||||
|
||||
if (($selectid != '') && $selectid == $obj->pcg_subtype) {
|
||||
$out .= '<option value="' . $obj->pcg_subtype . '" selected="selected">' . $label . '</option>';
|
||||
} else {
|
||||
$out .= '<option value="' . $obj->pcg_subtype . '">' . $label . '</option>';
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
$out .= '</select>';
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
147
htdocs/accountancy/customer/card.php
Normal file
147
htdocs/accountancy/customer/card.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/customer/card.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Card customer ventilation
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("bills");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$codeventil = GETPOST('codeventil');
|
||||
$id = GETPOST('id');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->access)
|
||||
accessforbidden();
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'ventil' && $user->rights->accounting->access)
|
||||
{
|
||||
if (! GETPOST('cancel', 'alpha'))
|
||||
{
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
|
||||
$sql .= " SET fk_code_ventilation = " . $codeventil;
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) {
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
} else {
|
||||
header("Location: ./lines.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
llxHeader("", "", "FicheVentilation");
|
||||
|
||||
if ($cancel == $langs->trans("Cancel")) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
/*
|
||||
* Create
|
||||
*/
|
||||
$form = new Form($db);
|
||||
$facture_static = new Facture($db);
|
||||
$formventilation = new FormVentilation($db);
|
||||
|
||||
if (! empty($id)) {
|
||||
$sql = "SELECT f.facnumber, 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 . "accountingaccount 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;
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
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 '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/accountancy/customer/lines.php">'.$langs->trans("Back").'</a>';
|
||||
print_fiche_titre($langs->trans('AccountingVentilationCustomer'),$linkback,'setup');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref facture
|
||||
print '<tr><td>' . $langs->trans("Invoice") . '</td>';
|
||||
$facture_static->ref = $objp->facnumber;
|
||||
$facture_static->id = $objp->facid;
|
||||
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 $objp->account_number . '-' . $objp->label;
|
||||
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
|
||||
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '<br><center><input class="button" type="submit" value="' . $langs->trans("Save") . '"> ';
|
||||
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '"></center';
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
print "Error";
|
||||
}
|
||||
} else {
|
||||
print "Error";
|
||||
}
|
||||
} else {
|
||||
print "Error ID incorrect";
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
347
htdocs/accountancy/customer/index.php
Normal file
347
htdocs/accountancy/customer/index.php
Normal file
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/customer/index.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page accueil clients ventilation comptable
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->read)
|
||||
accessforbidden();
|
||||
|
||||
// Filter
|
||||
$year = $_GET["year"];
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
|
||||
// Validate History
|
||||
$action = GETPOST('action');
|
||||
if ($action == 'validatehistory') {
|
||||
|
||||
$error = 0;
|
||||
$db->begin();
|
||||
|
||||
if ($db->type == 'pgsql') {
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
|
||||
$sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
|
||||
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
|
||||
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number";
|
||||
$sql1 .= " AND fd.fk_code_ventilation = 0";
|
||||
} else {
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
|
||||
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
|
||||
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
|
||||
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number";
|
||||
$sql1 .= " AND fd.fk_code_ventilation = 0";
|
||||
}
|
||||
|
||||
dol_syslog("/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
||||
$resql1 = $db->query($sql1);
|
||||
if (! $resql1) {
|
||||
$error ++;
|
||||
$db->rollback();
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
} else {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('Dispatched'), 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
llxHeader('', $langs->trans("CustomersVentilation"));
|
||||
|
||||
$textprevyear = "<a href=\"index.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
|
||||
$textnextyear = " <a href=\"index.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
|
||||
|
||||
print_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear);
|
||||
|
||||
print '<b>' . $langs->trans("DescVentilCustomer") . '</b>';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>';
|
||||
|
||||
$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/customer/index.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$row = $db->fetch_row($result);
|
||||
$nbfac = $row[0];
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
$var = true;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
|
||||
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT IF(aa.account_number IS NULL, 'Non pointe', aa.account_number) AS 'code comptable',";
|
||||
$sql .= " IF(aa.label IS NULL, 'Non pointe', aa.label) AS 'Intitulé',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,fd.total_ht,0)),2) AS 'Janvier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,fd.total_ht,0)),2) AS 'Fevrier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,fd.total_ht,0)),2) AS 'Mars',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,fd.total_ht,0)),2) AS 'Avril',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,fd.total_ht,0)),2) AS 'Mai',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,fd.total_ht,0)),2) AS 'Juin',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,fd.total_ht,0)),2) AS 'Juillet',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,fd.total_ht,0)),2) AS 'Aout',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,fd.total_ht,0)),2) AS 'Septembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,fd.total_ht,0)),2) AS 'Octobre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,fd.total_ht,0)),2) AS 'Novembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,fd.total_ht,0)),2) AS 'Decembre',";
|
||||
$sql .= " ROUND(SUM(fd.total_ht),2) as 'Total'";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY fd.fk_code_ventilation";
|
||||
|
||||
dol_syslog("/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $i < $num ) {
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<tr><td>' . length_accountg($row[0]) . '</td>';
|
||||
print '<td align="left">' . $row[1] . '</td>';
|
||||
print '<td align="right">' . price($row[2]) . '</td>';
|
||||
print '<td align="right">' . price($row[3]) . '</td>';
|
||||
print '<td align="right">' . price($row[4]) . '</td>';
|
||||
print '<td align="right">' . price($row[5]) . '</td>';
|
||||
print '<td align="right">' . price($row[6]) . '</td>';
|
||||
print '<td align="right">' . price($row[7]) . '</td>';
|
||||
print '<td align="right">' . price($row[8]) . '</td>';
|
||||
print '<td align="right">' . price($row[9]) . '</td>';
|
||||
print '<td align="right">' . price($row[10]) . '</td>';
|
||||
print '<td align="right">' . price($row[11]) . '</td>';
|
||||
print '<td align="right">' . price($row[12]) . '</td>';
|
||||
print '<td align="right">' . price($row[13]) . '</td>';
|
||||
print '<td align="right"><b>' . price($row[14]) . '</b></td>';
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
print "<br>\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
|
||||
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Total',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,fd.total_ht,0)),2) AS 'Janvier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,fd.total_ht,0)),2) AS 'Fevrier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,fd.total_ht,0)),2) AS 'Mars',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,fd.total_ht,0)),2) AS 'Avril',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,fd.total_ht,0)),2) AS 'Mai',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,fd.total_ht,0)),2) AS 'Juin',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,fd.total_ht,0)),2) AS 'Juillet',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,fd.total_ht,0)),2) AS 'Aout',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,fd.total_ht,0)),2) AS 'Septembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,fd.total_ht,0)),2) AS 'Octobre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,fd.total_ht,0)),2) AS 'Novembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,fd.total_ht,0)),2) AS 'Decembre',";
|
||||
$sql .= " ROUND(SUM(fd.total_ht),2) as 'Total'";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
dol_syslog('accountancy/customer/index.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $i < $num ) {
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
print '<td align="right">' . price($row[1]) . '</td>';
|
||||
print '<td align="right">' . price($row[2]) . '</td>';
|
||||
print '<td align="right">' . price($row[3]) . '</td>';
|
||||
print '<td align="right">' . price($row[4]) . '</td>';
|
||||
print '<td align="right">' . price($row[5]) . '</td>';
|
||||
print '<td align="right">' . price($row[6]) . '</td>';
|
||||
print '<td align="right">' . price($row[7]) . '</td>';
|
||||
print '<td align="right">' . price($row[8]) . '</td>';
|
||||
print '<td align="right">' . price($row[9]) . '</td>';
|
||||
print '<td align="right">' . price($row[10]) . '</td>';
|
||||
print '<td align="right">' . price($row[11]) . '</td>';
|
||||
print '<td align="right">' . price($row[12]) . '</td>';
|
||||
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
if (! empty($conf->margin->enabled)) {
|
||||
print "<br>\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
|
||||
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Marge',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Janvier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Fevrier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Mars',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Avril',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Mai',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Juin',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Juillet',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Aout',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Septembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Octobre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Novembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Decembre',";
|
||||
$sql .= " ROUND(SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))),2) as 'Total'";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
dol_syslog('accountancy/customer/index.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $i < $num ) {
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
print '<td align="right">' . price($row[1]) . '</td>';
|
||||
print '<td align="right">' . price($row[2]) . '</td>';
|
||||
print '<td align="right">' . price($row[3]) . '</td>';
|
||||
print '<td align="right">' . price($row[4]) . '</td>';
|
||||
print '<td align="right">' . price($row[5]) . '</td>';
|
||||
print '<td align="right">' . price($row[6]) . '</td>';
|
||||
print '<td align="right">' . price($row[7]) . '</td>';
|
||||
print '<td align="right">' . price($row[8]) . '</td>';
|
||||
print '<td align="right">' . price($row[9]) . '</td>';
|
||||
print '<td align="right">' . price($row[10]) . '</td>';
|
||||
print '<td align="right">' . price($row[11]) . '</td>';
|
||||
print '<td align="right">' . price($row[12]) . '</td>';
|
||||
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
print '</td></tr></table>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
224
htdocs/accountancy/customer/lines.php
Normal file
224
htdocs/accountancy/customer/lines.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/customer/lines.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page of detail of the lines of ventilation of invoices customers
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
|
||||
// langs
|
||||
$langs->load("bills");
|
||||
$langs->load("compta");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$account_parent = GETPOST('account_parent');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
|
||||
// change account
|
||||
|
||||
$changeaccount = GETPOST('changeaccount');
|
||||
|
||||
$is_search = GETPOST('button_search_x');
|
||||
|
||||
if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) {
|
||||
$error = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l";
|
||||
$sql1 .= " SET l.fk_code_ventilation=" . $account_parent;
|
||||
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
|
||||
|
||||
dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1);
|
||||
$resql1 = $db->query($sql1);
|
||||
if (! $resql1) {
|
||||
$error ++;
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('Save'), 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched"));
|
||||
|
||||
$page = GETPOST("page");
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
|
||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
||||
} elseif ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
|
||||
$limit = $conf->liste_limit;
|
||||
} else {
|
||||
$limit = $conf->liste_limit;
|
||||
}
|
||||
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql = "SELECT l.rowid , f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.qty, l.tva_tx, l.fk_code_ventilation, aa.label, aa.account_number,";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "facturedet as l";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
|
||||
$sql .= " AND aa.rowid = l.fk_code_ventilation";
|
||||
if (strlen(trim(GETPOST("search_facture")))) {
|
||||
$sql .= " AND f.facnumber like '%" . GETPOST("search_facture") . "%'";
|
||||
}
|
||||
if (strlen(trim(GETPOST("search_ref")))) {
|
||||
$sql .= " AND p.ref like '%" . GETPOST("search_ref") . "%'";
|
||||
}
|
||||
if (strlen(trim(GETPOST("search_label")))) {
|
||||
$sql .= " AND p.label like '%" . GETPOST("search_label") . "%'";
|
||||
}
|
||||
if (strlen(trim(GETPOST("search_desc")))) {
|
||||
$sql .= " AND l.description like '%" . GETPOST("search_desc") . "%'";
|
||||
}
|
||||
if (strlen(trim(GETPOST("search_account")))) {
|
||||
$sql .= " AND aa.account_number like '%" . GETPOST("search_account") . "%'";
|
||||
}
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY l.rowid";
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
|
||||
$sql .= " DESC ";
|
||||
}
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog("/accountancy/customer/linges.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
|
||||
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<td align="left"><b>' . $langs->trans("DescVentilDoneCustomer") . '</b></td>';
|
||||
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<br><br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount");
|
||||
print $formventilation->select_account($account_parent, 'account_parent', 1);
|
||||
print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '"/></div>';
|
||||
|
||||
print '<tr class="liste_titre"><td>' . $langs->trans("Invoice") . '</td>';
|
||||
print '<td>' . $langs->trans("Ref") . '</td>';
|
||||
print '<td>' . $langs->trans("Label") . '</td>';
|
||||
print '<td>' . $langs->trans("Description") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Amount") . '</td>';
|
||||
print '<td colspan="2" align="left">' . $langs->trans("Account") . '</td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre"><td><input name="search_facture" size="8" value="' . GETPOST("search_facture") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . GETPOST("search_ref") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST("search_label") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . GETPOST("search_desc") . '"></td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST("search_account") . '"></td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" alt="' . $langs->trans("Search") . '">';
|
||||
print '</td>';
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$facture_static = new Facture($db);
|
||||
$product_static = new Product($db);
|
||||
|
||||
$var = True;
|
||||
while ( $objp = $db->fetch_object($result) ) {
|
||||
$var = ! $var;
|
||||
$codeCompta = $objp->account_number . ' ' . $objp->label;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Ref facture
|
||||
$facture_static->ref = $objp->facnumber;
|
||||
$facture_static->id = $objp->facid;
|
||||
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
|
||||
|
||||
// Ref produit
|
||||
$product_static->ref = $objp->product_ref;
|
||||
$product_static->id = $objp->product_id;
|
||||
$product_static->type = $objp->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
|
||||
print '<td align="left">' . price($objp->total_ht) . '</td>';
|
||||
print '<td align="left">' . $codeCompta . '</td>';
|
||||
print '<td>' . $objp->rowid . '</td>';
|
||||
print '<td><a href="./card.php?id=' . $objp->rowid . '">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
|
||||
print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
|
||||
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
print "</table></form>";
|
||||
|
||||
$db->close();
|
||||
llxFooter();
|
||||
238
htdocs/accountancy/customer/list.php
Normal file
238
htdocs/accountancy/customer/list.php
Normal file
@ -0,0 +1,238 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/customer/list.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Ventilation page from customers invoices
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$action = GETPOST('action');
|
||||
$codeventil = GETPOST('codeventil', 'array');
|
||||
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
|
||||
llxHeader('', $langs->trans("Ventilation"));
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
if ($action == 'ventil') {
|
||||
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (! empty($codeventil) && ! empty($mesCasesCochees)) {
|
||||
print '<div><font color="red">' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
|
||||
$mesCodesVentilChoisis = $codeventil;
|
||||
$cpt = 0;
|
||||
foreach ( $mesCasesCochees as $maLigneCochee ) {
|
||||
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monNumLigne = $maLigneCourante[1];
|
||||
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
|
||||
$sql .= " SET fk_code_ventilation = " . $monCompte;
|
||||
$sql .= " WHERE rowid = " . $monId;
|
||||
|
||||
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
}
|
||||
|
||||
$cpt ++;
|
||||
}
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
|
||||
}
|
||||
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Customer Invoice lines
|
||||
*/
|
||||
$page = GETPOST('page');
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
|
||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
||||
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
|
||||
$limit = $conf->liste_limit;
|
||||
} else {
|
||||
$limit = $conf->liste_limit;
|
||||
}
|
||||
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation,";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell";
|
||||
$sql .= " , aa.rowid as aarowid";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_sell = aa.account_number";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
|
||||
$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
|
||||
$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_sell IS NULL)";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY l.rowid";
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
|
||||
$sql .= " DESC ";
|
||||
}
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
|
||||
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
||||
print '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>' . $langs->trans("Invoice") . '</td>';
|
||||
print '<td>' . $langs->trans("Ref") . '</td>';
|
||||
print '<td>' . $langs->trans("Label") . '</td>';
|
||||
print '<td>' . $langs->trans("Description") . '</td>';
|
||||
print '<td align="right">' . $langs->trans("Amount") . '</td>';
|
||||
print '<td align="right">' . $langs->trans("AccountAccounting") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("IntoAccount") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("Ventilate") . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$facture_static = new Facture($db);
|
||||
$product_static = new Product($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$var = True;
|
||||
while ( $i < min($num_lines, $limit) ) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$var = ! $var;
|
||||
|
||||
// product_type: 0 = service ? 1 = product
|
||||
// if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service
|
||||
// issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB !
|
||||
$code_sell_notset = '';
|
||||
|
||||
if (empty($objp->code_sell)) {
|
||||
$code_sell_notset = 'color:red';
|
||||
|
||||
if (! empty($objp->type)) {
|
||||
if ($objp->type == 1) {
|
||||
$objp->code_sell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
} else {
|
||||
$objp->code_sell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
} else {
|
||||
$code_sell_notset = 'color:blue';
|
||||
|
||||
if ($objp->type == 1) {
|
||||
$objp->code_sell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
} else {
|
||||
$objp->code_sell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Ref facture
|
||||
$facture_static->ref = $objp->facnumber;
|
||||
$facture_static->id = $objp->facid;
|
||||
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
|
||||
|
||||
// Ref produit
|
||||
$product_static->ref = $objp->product_ref;
|
||||
$product_static->id = $objp->product_id;
|
||||
$product_static->type = $objp->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
print price($objp->total_ht);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center" style="' . $code_sell_notset . '">';
|
||||
print $objp->code_sell;
|
||||
print '</td>';
|
||||
|
||||
// Colonne choix du compte
|
||||
print '<td align="center">';
|
||||
print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1);
|
||||
print '</td>';
|
||||
|
||||
// Colonne choix ligne a ventiler
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '"></div>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
llxFooter();
|
||||
592
htdocs/accountancy/journal/bankjournal.php
Normal file
592
htdocs/accountancy/journal/bankjournal.php
Normal file
@ -0,0 +1,592 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/journal/bankjournal.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page with sells journal
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("companies");
|
||||
$langs->load("other");
|
||||
$langs->load("compta");
|
||||
$langs->load("bank");
|
||||
$langs->load('bills');
|
||||
$langs->load("accountancy");
|
||||
|
||||
$id_accountancy_journal = GETPOST('id_account');
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
$date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
$action = GETPOST('action');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->access)
|
||||
accessforbidden();
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
if (empty($id_accountancy_journal))
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$year_current = strftime("%Y", dol_now());
|
||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
|
||||
$idpays = $p[0];
|
||||
|
||||
$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta, ba.courant,";
|
||||
$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "bank b";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account ba on b.fk_account=ba.rowid";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe soc on bu1.url_id=soc.rowid";
|
||||
// To isolate the cash of the other accounts
|
||||
$sql .= " WHERE ba.courant <> 2";
|
||||
$sql .= " AND ba.rowid=".$id_accountancy_journal;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ba.entity = " . $conf->entity;
|
||||
}
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " ORDER BY b.datev";
|
||||
|
||||
$object = new Account($db);
|
||||
$paymentstatic = new Paiement($db);
|
||||
$paymentsupplierstatic = new PaiementFourn($db);
|
||||
$societestatic = new Societe($db);
|
||||
$chargestatic = new ChargeSociales($db);
|
||||
$paymentvatstatic = new TVA($db);
|
||||
$paymentsalstatic = new PaymentSalary($db);
|
||||
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
// Variables
|
||||
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
|
||||
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
|
||||
$accountancy_account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"));
|
||||
|
||||
$tabpay = array ();
|
||||
$tabbq = array ();
|
||||
$tabtp = array ();
|
||||
$tabtype = array ();
|
||||
|
||||
$i = 0;
|
||||
while ( $i < $num )
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$tabcompany[$obj->rowid] = array(
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_client' => $obj->code_compta
|
||||
);
|
||||
|
||||
// Controls
|
||||
$compta_bank = $obj->account_number;
|
||||
if ($obj->label == '(SupplierInvoicePayment)')
|
||||
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour);
|
||||
if ($obj->label == '(CustomerInvoicePayment)')
|
||||
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
|
||||
if ($obj->typeop == '(BankTransfert)')
|
||||
$compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH;
|
||||
|
||||
// Variable bookkeeping
|
||||
$tabpay[$obj->rowid]["date"] = $obj->do;
|
||||
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
|
||||
$tabpay[$obj->rowid]["ref"] = $obj->label;
|
||||
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
|
||||
if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) {
|
||||
$tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]);
|
||||
} else {
|
||||
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
|
||||
}
|
||||
$links = $object->get_url($obj->rowid);
|
||||
|
||||
foreach ( $links as $key => $val )
|
||||
{
|
||||
$tabtype[$obj->rowid] = $links[$key]['type'];
|
||||
|
||||
if ($links[$key]['type'] == 'payment')
|
||||
{
|
||||
$paymentstatic->id = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
|
||||
}
|
||||
else if ($links[$key]['type'] == 'payment_supplier')
|
||||
{
|
||||
$paymentsupplierstatic->id = $links[$key]['url_id'];
|
||||
$paymentsupplierstatic->ref = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
|
||||
}
|
||||
else if ($links[$key]['type'] == 'company')
|
||||
{
|
||||
$societestatic->id = $links[$key]['url_id'];
|
||||
$societestatic->name = $links[$key]['label'];
|
||||
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
|
||||
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
||||
}
|
||||
else if ($links[$key]['type'] == 'sc')
|
||||
{
|
||||
$chargestatic->id = $links[$key]['url_id'];
|
||||
$chargestatic->ref = $links[$key]['url_id'];
|
||||
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
|
||||
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
|
||||
if ($reg[1] == 'socialcontribution')
|
||||
$reg[1] = 'SocialContribution';
|
||||
$chargestatic->lib = $langs->trans($reg[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$chargestatic->lib = $links[$key]['label'];
|
||||
}
|
||||
$chargestatic->ref = $chargestatic->lib;
|
||||
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
|
||||
|
||||
$sqlmid = 'SELECT cchgsoc.accountancy_code';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
|
||||
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
|
||||
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid)
|
||||
{
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
|
||||
}
|
||||
}
|
||||
else if ($links[$key]['type'] == 'payment_vat')
|
||||
{
|
||||
$paymentvatstatic->id = $links[$key]['url_id'];
|
||||
$paymentvatstatic->ref = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
|
||||
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
|
||||
}
|
||||
else if ($links[$key]['type'] == 'payment_salary')
|
||||
{
|
||||
$paymentsalstatic->id = $links[$key]['url_id'];
|
||||
$paymentsalstatic->ref = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
|
||||
$tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount;
|
||||
}
|
||||
else if ($links[$key]['type'] == 'banktransfert')
|
||||
{
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
|
||||
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
|
||||
}
|
||||
/*else {
|
||||
$tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount;
|
||||
}*/
|
||||
}
|
||||
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
|
||||
|
||||
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
||||
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// Write bookkeeping
|
||||
if ($action == 'writeBookKeeping')
|
||||
{
|
||||
$error = 0;
|
||||
foreach ( $tabpay as $key => $val )
|
||||
{
|
||||
// Bank
|
||||
foreach ( $tabbq[$key] as $k => $mt )
|
||||
{
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $compte->label;
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
|
||||
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
|
||||
$sqlmid = 'SELECT fac.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
|
||||
$sqlmid = 'SELECT facf.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create();
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessage($object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
// Third party
|
||||
foreach ( $tabtp[$key] as $k => $mt )
|
||||
{
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'banque';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
|
||||
|
||||
if ($tabtype[$key] == 'sc') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else if ($tabtype[$key] == 'payment') {
|
||||
|
||||
$sqlmid = 'SELECT fac.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
$bookkeeping->code_tiers = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
|
||||
$sqlmid = 'SELECT facf.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
$bookkeeping->code_tiers = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
} else if ($tabtype[$key] == 'company') {
|
||||
|
||||
$sqlmid = 'SELECT fac.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
$bookkeeping->code_tiers = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
} else {
|
||||
|
||||
$bookkeeping->doc_ref = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create();
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessage($object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
setEventMessage($langs->trans('Success'), 'mesgs');
|
||||
}
|
||||
}
|
||||
// export csv
|
||||
if ($action == 'export_csv')
|
||||
{
|
||||
$sep = $conf->global->ACCOUNTING_SEPARATORCSV;
|
||||
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment;filename=journal_banque.csv');
|
||||
|
||||
$companystatic = new Client($db);
|
||||
|
||||
if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
|
||||
{
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
|
||||
// Bank
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_BANK_JOURNAL . $sep;
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $val["type_payment"] . $sep;
|
||||
print $sep;
|
||||
}
|
||||
print "\n";
|
||||
|
||||
// Third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_BANK_JOURNAL . $sep;
|
||||
if ($val["lib"] == '(SupplierInvoicePayment)') {
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||
} else {
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
|
||||
}
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $val["type_payment"] . $sep;
|
||||
print $sep;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else // Modèle Export Classique
|
||||
{
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
|
||||
// Bank
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Bank") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
}
|
||||
print "\n";
|
||||
|
||||
// Third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $companystatic->name . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('', $langs->trans("BankJournal"));
|
||||
|
||||
$namereport = $langs->trans("BankJournal");
|
||||
$namelink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate = time();
|
||||
$description = $langs->trans("DescBankJournal") . '<br>';
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||
report_header($namereport, $namelink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
|
||||
|
||||
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
|
||||
|
||||
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
|
||||
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
function writeBookKeeping() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("writeBookKeeping");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
|
||||
/*
|
||||
* Show result array
|
||||
*/
|
||||
print '<br><br>';
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td>" . $langs->trans("Date") . "</td>";
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("Account") . "</td>";
|
||||
print "<td>" . $langs->trans("Type") . "</td>";
|
||||
print "<td>" . $langs->trans("PaymentMode") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$var = true;
|
||||
$r = '';
|
||||
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
if ($val["lib"] == '(SupplierInvoicePayment)')
|
||||
$reflabel = $langs->trans('SupplierInvoicePayment');
|
||||
if ($val["lib"] == '(CustomerInvoicePayment)')
|
||||
$reflabel = $langs->trans('CustomerInvoicePayment');
|
||||
|
||||
// Bank
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
if (1) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $reflabel . "</td>";
|
||||
print "<td>" . length_accountg($k) . "</td>";
|
||||
print "<td>" . $langs->trans('Bank') . "</td>";
|
||||
print "<td>" . $val["type_payment"] . "</td>";
|
||||
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
// Third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($k != 'type') {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $val["soclib"] . "</td>";
|
||||
print "<td>" . length_accounta($k) . "</td>";
|
||||
print "<td>" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")</td>";
|
||||
print "<td>" . $val["type_payment"] . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
$var = ! $var;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
533
htdocs/accountancy/journal/cashjournal.php
Normal file
533
htdocs/accountancy/journal/cashjournal.php
Normal file
@ -0,0 +1,533 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/journal/cashjournal.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page with cash journal
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("companies");
|
||||
$langs->load("other");
|
||||
$langs->load("compta");
|
||||
$langs->load("bank");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
$date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->access)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$year_current = strftime("%Y", dol_now());
|
||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
|
||||
$idpays = $p[0];
|
||||
|
||||
$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta, ba.courant,";
|
||||
$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "bank b";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account ba on b.fk_account=ba.rowid";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe soc on bu1.url_id=soc.rowid";
|
||||
|
||||
// Code opération type caisse
|
||||
$sql .= " WHERE ba.courant = 2";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ba.entity = " . $conf->entity;
|
||||
}
|
||||
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " ORDER BY b.datev";
|
||||
|
||||
$object = new Account($db);
|
||||
$paymentstatic = new Paiement($db);
|
||||
$paymentsupplierstatic = new PaiementFourn($db);
|
||||
$societestatic = new Societe($db);
|
||||
$chargestatic = new ChargeSociales($db);
|
||||
$paymentvatstatic = new TVA($db);
|
||||
|
||||
dol_syslog("accountancy/journal/cashjournal.php:: sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
// les variables
|
||||
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
|
||||
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
|
||||
$cptsociale = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
|
||||
|
||||
$tabpay = array ();
|
||||
$tabbq = array ();
|
||||
$tabtp = array ();
|
||||
$tabcompany = array ();
|
||||
$tabtype = array ();
|
||||
|
||||
$i = 0;
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// controls
|
||||
$compta_bank = $obj->account_number;
|
||||
if ($obj->label == '(SupplierInvoicePayment)')
|
||||
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour);
|
||||
if ($obj->label == '(CustomerInvoicePayment)')
|
||||
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
|
||||
if ($obj->typeop == '(BankTransfert)')
|
||||
$compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH;
|
||||
|
||||
// variable bookkeeping
|
||||
|
||||
$tabpay[$obj->rowid]["date"] = $obj->do;
|
||||
$tabpay[$obj->rowid]["ref"] = $obj->label;
|
||||
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
|
||||
if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) {
|
||||
$tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]);
|
||||
} else {
|
||||
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
|
||||
}
|
||||
$links = $object->get_url($obj->rowid);
|
||||
|
||||
foreach ( $links as $key => $val ) {
|
||||
|
||||
$tabtype[$obj->rowid] = $links[$key]['type'];
|
||||
|
||||
if ($links[$key]['type'] == 'payment') {
|
||||
$paymentstatic->id = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
|
||||
} else if ($links[$key]['type'] == 'payment_supplier') {
|
||||
$paymentsupplierstatic->id = $links[$key]['url_id'];
|
||||
$paymentsupplierstatic->ref = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
|
||||
} else if ($links[$key]['type'] == 'company') {
|
||||
|
||||
$societestatic->id = $links[$key]['url_id'];
|
||||
$societestatic->name = $links[$key]['label'];
|
||||
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
|
||||
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
||||
} else if ($links[$key]['type'] == 'sc') {
|
||||
|
||||
$chargestatic->id = $links[$key]['url_id'];
|
||||
$chargestatic->ref = $links[$key]['url_id'];
|
||||
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
|
||||
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
|
||||
if ($reg[1] == 'socialcontribution')
|
||||
$reg[1] = 'SocialContribution';
|
||||
$chargestatic->lib = $langs->trans($reg[1]);
|
||||
} else {
|
||||
$chargestatic->lib = $links[$key]['label'];
|
||||
}
|
||||
$chargestatic->ref = $chargestatic->lib;
|
||||
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
|
||||
|
||||
$sqlmid = 'SELECT cchgsoc.accountancy_code';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
|
||||
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
|
||||
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
|
||||
}
|
||||
} else if ($links[$key]['type'] == 'payment_vat') {
|
||||
|
||||
$paymentvatstatic->id = $links[$key]['url_id'];
|
||||
$paymentvatstatic->ref = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
|
||||
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
|
||||
} else if ($links[$key]['type'] == 'banktransfert') {
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
|
||||
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
|
||||
}
|
||||
/*else {
|
||||
$tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
|
||||
}*/
|
||||
}
|
||||
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
|
||||
|
||||
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
||||
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// write bookkeeping
|
||||
if ($action == 'writeBookKeeping') {
|
||||
$error = 0;
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
// cash
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'cash';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $compte->label;
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL;
|
||||
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
|
||||
$sqlmid = 'SELECT fac.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
|
||||
$sqlmid = 'SELECT facf.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create();
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessage($object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
// third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'cash';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0 ? $mt : 0);
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL;
|
||||
|
||||
if ($tabtype[$key] == 'sc') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else if ($tabtype[$key] == 'payment') {
|
||||
|
||||
$sqlmid = 'SELECT fac.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
$bookkeeping->code_tiers = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
|
||||
$sqlmid = 'SELECT facf.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
$bookkeeping->code_tiers = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
} else if ($tabtype[$key] == 'company') {
|
||||
|
||||
$sqlmid = 'SELECT fac.facnumber';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||
$sqlmid .= " WHERE pay.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->facnumber;
|
||||
}
|
||||
$bookkeeping->code_tiers = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
} else {
|
||||
|
||||
$bookkeeping->doc_ref = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create();
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessage($object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
setEventMessage($langs->trans('Success'), 'mesgs');
|
||||
}
|
||||
}
|
||||
// export csv
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_SEPARATORCSV;
|
||||
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition:attachment;filename=journal_caisse.csv');
|
||||
|
||||
if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
|
||||
{
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||
|
||||
// Cash
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_CASH_JOURNAL . $sep;
|
||||
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print price($mt) . $sep;
|
||||
}
|
||||
print utf8_decode($langs->trans("CashPayment")) . $sep;
|
||||
print $val["ref"] . $sep;
|
||||
print "\n";
|
||||
|
||||
// Third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_CASH_JOURNAL . $sep;
|
||||
if ($obj->label == '(SupplierInvoicePayment)') {
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||
} else {
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
|
||||
}
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print price($mt) . $sep;
|
||||
print $langs->trans("ThirdParty") . $sep;
|
||||
print $val["ref"] . $sep;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else // Modèle Export Classique
|
||||
{
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
|
||||
// Cash
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Cash") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
}
|
||||
print "\n";
|
||||
|
||||
// Third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("ThirdParty") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('', $langs->trans("CashJournal"), '');
|
||||
|
||||
$name = $langs->trans("CashJournal");
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate = time();
|
||||
$description = $langs->trans("DescCashJournal") . '<br>';
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||
report_header($name, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
|
||||
|
||||
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
|
||||
|
||||
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
|
||||
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
function writeBookKeeping() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("writeBookKeeping");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
|
||||
/*
|
||||
* Show result array
|
||||
*/
|
||||
print '<br><br>';
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td>" . $langs->trans("Date") . "</td>";
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("Account") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$var = true;
|
||||
$r = '';
|
||||
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
// Cash
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
if (1) {
|
||||
print "<tr " . $bc[$var] . " >";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $val["lib"] . "</td>";
|
||||
print "<td>" . length_accountg($k) . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
// third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($k != 'type') {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $val["soclib"] . "</td>";
|
||||
|
||||
print "<td>" . length_accounta($k) . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
}
|
||||
}
|
||||
|
||||
$var = ! $var;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
}
|
||||
$db->close();
|
||||
48
htdocs/accountancy/journal/index.php
Normal file
48
htdocs/accountancy/journal/index.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/journal/index.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Index
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->access)
|
||||
accessforbidden();
|
||||
|
||||
llxHeader('', 'Journaux', '');
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
// End of page
|
||||
$db->close();
|
||||
llxFooter();
|
||||
468
htdocs/accountancy/journal/purchasesjournal.php
Normal file
468
htdocs/accountancy/journal/purchasesjournal.php
Normal file
@ -0,0 +1,468 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/journal/purchasesjournal.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page with purchases journal
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.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.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
$date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->access)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$year_current = strftime("%Y", dol_now());
|
||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
|
||||
$idpays = $p[0];
|
||||
|
||||
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur, s.fournisseur,";
|
||||
$sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
||||
$sql .= " WHERE f.fk_statut > 0 ";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = " . $conf->entity;
|
||||
}
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||
$sql .= " AND f.type IN (0,1,2)";
|
||||
else
|
||||
$sql .= " AND f.type IN (0,1,2,3)";
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " ORDER BY f.datef";
|
||||
|
||||
dol_syslog('accountancy/journal/purchasesjournal.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
// les variables
|
||||
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
|
||||
$tabfac = array ();
|
||||
$tabht = array ();
|
||||
$tabtva = array ();
|
||||
$tabttc = array ();
|
||||
$tabcompany = array ();
|
||||
|
||||
$i = 0;
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object($result);
|
||||
// contrôles
|
||||
$compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour;
|
||||
$compta_prod = $obj->compte;
|
||||
if (empty($compta_prod)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
else
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
}
|
||||
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
||||
|
||||
$tabfac[$obj->rowid]["date"] = $obj->df;
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->ref;
|
||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||
$tabfac[$obj->rowid]["description"] = $obj->description;
|
||||
$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
|
||||
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
|
||||
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
|
||||
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
|
||||
$tabcompany[$obj->rowid] = array (
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_fournisseur' => $obj->code_compta_fournisseur
|
||||
);
|
||||
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
// Bookkeeping Write
|
||||
if ($action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
// get compte id and label
|
||||
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur'];
|
||||
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
|
||||
$bookkeeping->create();
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
// get compte id and label
|
||||
$compte = new AccountingAccount($db);
|
||||
if ($compte->fetch(null, $k)) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->label_compte = dol_trunc($val["description"], 128);
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
|
||||
$bookkeeping->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
// get compte id and label
|
||||
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->label_compte = $langs->trans("VAT");
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
|
||||
$bookkeeping->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// export csv
|
||||
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_SEPARATORCSV;
|
||||
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment;filename=journal_achats.csv');
|
||||
|
||||
if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
|
||||
{
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_PURCHASE_JOURNAL . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($val["description"], 32) . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_PURCHASE_JOURNAL . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_PURCHASE_JOURNAL . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print utf8_decode($companystatic->name) . $sep;
|
||||
print $val["ref"];
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
} else // Modèle Export Classique
|
||||
{
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($val["description"], 32) . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Third party
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
llxHeader('', '', '');
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$nom = $langs->trans("PurchasesJournal");
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate = time();
|
||||
$description = $langs->trans("DescPurchasesJournal") . '<br>';
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
else
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
|
||||
|
||||
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
|
||||
|
||||
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
function writebookkeeping() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
|
||||
/*
|
||||
* Show result array
|
||||
*/
|
||||
print '<br><br>';
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
// /print "<td>".$langs->trans("JournalNum")."</td>";
|
||||
print "<td>" . $langs->trans("Date") . "</td>";
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("Account") . "</td>";
|
||||
print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$var = true;
|
||||
$r = '';
|
||||
|
||||
$invoicestatic = new FactureFournisseur($db);
|
||||
$companystatic = new Fournisseur($db);
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
$invoicestatic->type = $val["type"];
|
||||
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
|
||||
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . " >";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>" . length_accountg($k) . "</td>";
|
||||
print "<td>" . $invoicestatic->description . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . " >";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>" . length_accountg($k) . "</td><td>" . $langs->trans("VAT") . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
|
||||
// Third party
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
|
||||
print "<td>" . length_accounta($k);
|
||||
print "</td><td>" . $langs->trans("ThirdParty");
|
||||
print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')';
|
||||
print "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
}
|
||||
print "</tr>";
|
||||
|
||||
$var = ! $var;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
}
|
||||
$db->close();
|
||||
476
htdocs/accountancy/journal/sellsjournal.php
Normal file
476
htdocs/accountancy/journal/sellsjournal.php
Normal file
@ -0,0 +1,476 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/journal/sellsjournal.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page with sells journal
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.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.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
$date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->access)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$year_current = strftime("%Y", dol_now());
|
||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
|
||||
$idpays = $p[0];
|
||||
|
||||
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
|
||||
$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte, ";
|
||||
$sql .= " ct.accountancy_code_sell as account_tva";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
|
||||
$sql .= " WHERE fd.fk_code_ventilation > 0 ";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = " . $conf->entity;
|
||||
}
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||
$sql .= " AND f.type IN (0,1,2)";
|
||||
else
|
||||
$sql .= " AND f.type IN (0,1,2,3)";
|
||||
$sql .= " AND fd.product_type IN (0,1)";
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " ORDER BY f.datef";
|
||||
|
||||
dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$tabfac = array ();
|
||||
$tabht = array ();
|
||||
$tabtva = array ();
|
||||
$tabttc = array ();
|
||||
$tabcompany = array ();
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object($result);
|
||||
// les variables
|
||||
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
|
||||
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
|
||||
|
||||
$compta_prod = $obj->compte;
|
||||
if (empty($compta_prod)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
else
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
}
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
||||
|
||||
// Invoice lines
|
||||
$tabfac[$obj->rowid]["date"] = $obj->df;
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
|
||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||
$tabfac[$obj->rowid]["description"] = $obj->description;
|
||||
$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
|
||||
if (! isset($tabttc[$obj->rowid][$compta_soc]))
|
||||
$tabttc[$obj->rowid][$compta_soc] = 0;
|
||||
if (! isset($tabht[$obj->rowid][$compta_prod]))
|
||||
$tabht[$obj->rowid][$compta_prod] = 0;
|
||||
if (! isset($tabtva[$obj->rowid][$compta_tva]))
|
||||
$tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
|
||||
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
|
||||
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
|
||||
$tabcompany[$obj->rowid] = array (
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_client' => $obj->code_compta
|
||||
);
|
||||
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
// Bookkeeping Write
|
||||
if ($action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
|
||||
$bookkeeping->create();
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
// get compte id and label
|
||||
$compte = new AccountingAccount($db);
|
||||
if ($compte->fetch(null, $k)) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = dol_trunc($val["description"], 128);
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
|
||||
$bookkeeping->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->fk_compte = $compte->id;
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $langs->trans("VAT");
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
|
||||
$bookkeeping->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// export csv
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_SEPARATORCSV;
|
||||
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment;filename=journal_ventes.csv');
|
||||
|
||||
$companystatic = new Client($db);
|
||||
|
||||
if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
|
||||
{
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_SELL_JOURNAL . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print utf8_decode($companystatic->name) . $sep;
|
||||
}
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_SELL_JOURNAL . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($val["description"], 32) . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
// TVA
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $conf->global->ACCOUNTING_SELL_JOURNAL . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else // Modèle Export Classique
|
||||
{
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
}
|
||||
print "\n";
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($val["description"], 32) . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('', $langs->trans("SellsJournal"));
|
||||
|
||||
$nom = $langs->trans("SellsJournal");
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate = time();
|
||||
$description = $langs->trans("DescSellsJournal") . '<br>';
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
else
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
|
||||
|
||||
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
|
||||
|
||||
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
function writebookkeeping() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
|
||||
/*
|
||||
* Show result array
|
||||
*/
|
||||
print '<br><br>';
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td>" . $langs->trans("Date") . "</td>";
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("Account") . "</td>";
|
||||
print "<td>" . $langs->trans("Type") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$var = true;
|
||||
$r = '';
|
||||
|
||||
$invoicestatic = new Facture($db);
|
||||
$companystatic = new Client($db);
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
$invoicestatic->type = $val["type"];
|
||||
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
|
||||
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
|
||||
// Third party
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
print "<td>" . length_accounta($k);
|
||||
print "</td><td>" . $langs->trans("ThirdParty");
|
||||
print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
|
||||
print "</td><td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
}
|
||||
print "</tr>";
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>" . length_accountg($k) . "</td>";
|
||||
print "<td>" . $invoicestatic->description . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>" . length_accountg($k) . "</td>";
|
||||
print "<td>" . $langs->trans("VAT") . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
$var = ! $var;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
}
|
||||
$db->close();
|
||||
141
htdocs/accountancy/supplier/card.php
Normal file
141
htdocs/accountancy/supplier/card.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent s<jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file htdocs/accountancy/supplier/card.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Card supplier ventilation
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$action = GETPOST('action');
|
||||
$id = GETPOST('id', 'int');
|
||||
$codeventil = GETPOST('codeventil');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
accessforbidden();
|
||||
|
||||
if ($action == 'ventil' && $user->rights->accounting->access) {
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = " . $codeventil;
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) {
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
llxHeader("", "", "FicheVentilation");
|
||||
|
||||
if ($cancel == $langs->trans("Cancel")) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
/*
|
||||
* Create
|
||||
*/
|
||||
$form = new Form($db);
|
||||
$facturefournisseur_static = new FactureFournisseur($db);
|
||||
$formventilation = new FormVentilation($db);
|
||||
|
||||
if ($_GET["id"]) {
|
||||
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label";
|
||||
$sql .= ", aa.account_number, aa.label";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
|
||||
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
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 '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
print_fiche_titre($langs->trans("Ventilation"));
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
|
||||
// ref invoice
|
||||
print '<tr><td>' . $langs->trans("BillsSuppliers") . '</td>';
|
||||
$facturefournisseur_static->ref = $objp->facnumber;
|
||||
$facturefournisseur_static->id = $objp->facid;
|
||||
print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td width="20%">Ligne</td>';
|
||||
print '<td>' . stripslashes(nl2br($objp->description)) . '</td></tr>';
|
||||
print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
|
||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
|
||||
print $objp->account_number . '-' . $objp->label;
|
||||
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
|
||||
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
|
||||
print '</td></tr>';
|
||||
print '<tr><td> </td><td><input type="submit" class="button" value="' . $langs->trans("Update") . '"></td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print "Error 1";
|
||||
}
|
||||
} else {
|
||||
print "Error 2";
|
||||
}
|
||||
} else {
|
||||
print "Error ID incorrect";
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
262
htdocs/accountancy/supplier/index.php
Normal file
262
htdocs/accountancy/supplier/index.php
Normal file
@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/supplier/index.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page accueil ventilation
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->read)
|
||||
accessforbidden();
|
||||
|
||||
// Filter
|
||||
$year = $_GET["year"];
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
|
||||
// Validate History
|
||||
$action = GETPOST('action');
|
||||
if ($action == 'validatehistory') {
|
||||
|
||||
$error = 0;
|
||||
$db->begin();
|
||||
|
||||
if ($db->type == 'pgsql') {
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
|
||||
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
|
||||
$sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
|
||||
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
|
||||
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number";
|
||||
$sql1 .= " AND fd.fk_code_ventilation = 0";
|
||||
} else {
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
|
||||
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
|
||||
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
|
||||
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number";
|
||||
$sql1 .= " AND fd.fk_code_ventilation = 0";
|
||||
}
|
||||
|
||||
$resql1 = $db->query($sql1);
|
||||
if (! $resql1) {
|
||||
$error ++;
|
||||
$db->rollback();
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
} else {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('Dispatched'), 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('', $langs->trans("SuppliersVentilation"));
|
||||
|
||||
$textprevyear = "<a href=\"index.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
|
||||
$textnextyear = " <a href=\"index.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
|
||||
|
||||
print_fiche_titre($langs->trans("AccountingVentilationSupplier") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear);
|
||||
|
||||
print '<b>' . $langs->trans("DescVentilSupplier") . '</b>';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>';
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
$var = true;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
|
||||
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT IF(aa.account_number IS NULL, 'Non pointe', aa.account_number) AS 'code comptable',";
|
||||
$sql .= " IF(aa.label IS NULL, 'Non pointe', aa.label) AS 'Intitulé',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=1,ffd.total_ht,0)),2) AS 'Janvier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=2,ffd.total_ht,0)),2) AS 'Fevrier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=3,ffd.total_ht,0)),2) AS 'Mars',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=4,ffd.total_ht,0)),2) AS 'Avril',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=5,ffd.total_ht,0)),2) AS 'Mai',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=6,ffd.total_ht,0)),2) AS 'Juin',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=7,ffd.total_ht,0)),2) AS 'Juillet',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=8,ffd.total_ht,0)),2) AS 'Aout',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=9,ffd.total_ht,0)),2) AS 'Septembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=10,ffd.total_ht,0)),2) AS 'Octobre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=11,ffd.total_ht,0)),2) AS 'Novembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=12,ffd.total_ht,0)),2) AS 'Decembre',";
|
||||
$sql .= " ROUND(SUM(ffd.total_ht),2) as 'Total'";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = ffd.fk_code_ventilation";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0 ";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ff.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY ffd.fk_code_ventilation";
|
||||
|
||||
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $i < $num ) {
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<tr><td>' . length_accountg($row[0]) . '</td>';
|
||||
print '<td align="left">' . $row[1] . '</td>';
|
||||
print '<td align="right">' . price($row[2]) . '</td>';
|
||||
print '<td align="right">' . price($row[3]) . '</td>';
|
||||
print '<td align="right">' . price($row[4]) . '</td>';
|
||||
print '<td align="right">' . price($row[5]) . '</td>';
|
||||
print '<td align="right">' . price($row[6]) . '</td>';
|
||||
print '<td align="right">' . price($row[7]) . '</td>';
|
||||
print '<td align="right">' . price($row[8]) . '</td>';
|
||||
print '<td align="right">' . price($row[9]) . '</td>';
|
||||
print '<td align="right">' . price($row[10]) . '</td>';
|
||||
print '<td align="right">' . price($row[11]) . '</td>';
|
||||
print '<td align="right">' . price($row[12]) . '</td>';
|
||||
print '<td align="right">' . price($row[13]) . '</td>';
|
||||
print '<td align="right"><b>' . price($row[14]) . '</b></td>';
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
print "<br>\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
|
||||
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
|
||||
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS 'Total',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=1,ffd.total_ht,0)),2) AS 'Janvier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=2,ffd.total_ht,0)),2) AS 'Fevrier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=3,ffd.total_ht,0)),2) AS 'Mars',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=4,ffd.total_ht,0)),2) AS 'Avril',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=5,ffd.total_ht,0)),2) AS 'Mai',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=6,ffd.total_ht,0)),2) AS 'Juin',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=7,ffd.total_ht,0)),2) AS 'Juillet',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=8,ffd.total_ht,0)),2) AS 'Aout',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=9,ffd.total_ht,0)),2) AS 'Septembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=10,ffd.total_ht,0)),2) AS 'Octobre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=11,ffd.total_ht,0)),2) AS 'Novembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=12,ffd.total_ht,0)),2) AS 'Decembre',";
|
||||
$sql .= " ROUND(SUM(ffd.total_ht),2) as 'Total'";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0 ";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ff.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $i < $num ) {
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
print '<td align="right">' . $row[1] . '</td>';
|
||||
print '<td align="right">' . price($row[2]) . '</td>';
|
||||
print '<td align="right">' . price($row[3]) . '</td>';
|
||||
print '<td align="right">' . price($row[4]) . '</td>';
|
||||
print '<td align="right">' . price($row[5]) . '</td>';
|
||||
print '<td align="right">' . price($row[6]) . '</td>';
|
||||
print '<td align="right">' . price($row[7]) . '</td>';
|
||||
print '<td align="right">' . price($row[8]) . '</td>';
|
||||
print '<td align="right">' . price($row[9]) . '</td>';
|
||||
print '<td align="right">' . price($row[10]) . '</td>';
|
||||
print '<td align="right">' . price($row[11]) . '</td>';
|
||||
print '<td align="right">' . price($row[12]) . '</td>';
|
||||
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
||||
print '</tr>';
|
||||
|
||||
$i ++;
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
224
htdocs/accountancy/supplier/lines.php
Normal file
224
htdocs/accountancy/supplier/lines.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/supplier/lines.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page of detail of the lines of ventilation of invoices suppliers
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
|
||||
$changeaccount = GETPOST('changeaccount');
|
||||
|
||||
$is_search = GETPOST('button_search_x');
|
||||
|
||||
if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) {
|
||||
$error = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
|
||||
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent');
|
||||
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
|
||||
|
||||
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1);
|
||||
$resql1 = $db->query($sql1);
|
||||
if (! $resql1) {
|
||||
$error ++;
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('Save'), 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched"));
|
||||
|
||||
$page = $_GET["page"];
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
|
||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
||||
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
|
||||
$limit = $conf->liste_limit;
|
||||
} else {
|
||||
$limit = $conf->liste_limit;
|
||||
}
|
||||
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht , l.qty, l.rowid, l.tva_tx, aa.label, aa.account_number, ";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "facture_fourn_det as l";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
|
||||
$sql .= " AND aa.rowid = l.fk_code_ventilation";
|
||||
if (strlen(trim($_GET["search_facture"]))) {
|
||||
$sql .= " AND f.facnumber like '%" . $_GET["search_facture"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_ref"]))) {
|
||||
$sql .= " AND p.ref like '%" . $_GET["search_ref"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_label"]))) {
|
||||
$sql .= " AND p.label like '%" . $_GET["search_label"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_desc"]))) {
|
||||
$sql .= " AND l.description like '%" . $_GET["search_desc"] . "%'";
|
||||
}
|
||||
if (strlen(trim($_GET["search_account"]))) {
|
||||
$sql .= " AND aa.account_number like '%" . $_GET["search_account"] . "%'";
|
||||
}
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY l.rowid";
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
|
||||
$sql .= " DESC ";
|
||||
}
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/supplier/lines.php::list sql= ' . $sql1);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
|
||||
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<td align="left"><b>' . $langs->trans("DescVentilDoneSupplier") . '</b></td>';
|
||||
|
||||
print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<br><br><div class="inline-block divButAction">'. $langs->trans("ChangeAccount");
|
||||
print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
|
||||
print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '" /></div>';
|
||||
|
||||
print '<tr class="liste_titre"><td>' . $langs->trans("Invoice") . '</td>';
|
||||
print '<td>' . $langs->trans("Ref") . '</td>';
|
||||
print '<td>' . $langs->trans("Label") . '</td>';
|
||||
print '<td>' . $langs->trans("Description") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Amount") . '</td>';
|
||||
print '<td colspan="2" align="left">' . $langs->trans("Account") . '</td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre"><td><input name="search_facture" size="8" value="' . $_GET["search_facture"] . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . GETPOST("search_ref") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST("search_label") . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . GETPOST("search_desc") . '"></td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST("search_account") . '"></td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" alt="' . $langs->trans("Search") . '">';
|
||||
print '</td>';
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$facturefournisseur_static = new FactureFournisseur($db);
|
||||
$product_static = new Product($db);
|
||||
|
||||
$var = True;
|
||||
while ( $i < min($num_lines, $limit) ) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$var = ! $var;
|
||||
$codeCompta = $objp->account_number . ' ' . $objp->label;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Ref Invoice
|
||||
$facturefournisseur_static->ref = $objp->facnumber;
|
||||
$facturefournisseur_static->id = $objp->facid;
|
||||
print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
|
||||
|
||||
// Ref Product
|
||||
$product_static->ref = $objp->product_ref;
|
||||
$product_static->id = $objp->product_id;
|
||||
$product_static->type = $objp->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
|
||||
print '<td align="left">' . price($objp->total_ht) . '</td>';
|
||||
print '<td align="left">' . $codeCompta . '</td>';
|
||||
print '<td>' . $objp->rowid . '</td>';
|
||||
print '<td><a href="./card.php?id=' . $objp->rowid . '">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
|
||||
print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
|
||||
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
print "</table></form>";
|
||||
|
||||
$db->close();
|
||||
llxFooter();
|
||||
219
htdocs/accountancy/supplier/list.php
Normal file
219
htdocs/accountancy/supplier/list.php
Normal file
@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/supplier/list.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page de ventilation des lignes de facture
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$action = GETPOST('action');
|
||||
$codeventil = GETPOST('codeventil', 'array');
|
||||
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
|
||||
llxHeader('', $langs->trans("Ventilation"));
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
if ($action == 'ventil') {
|
||||
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) {
|
||||
print '<div><font color="red">' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
|
||||
$mesCodesVentilChoisis = $codeventil;
|
||||
$cpt = 0;
|
||||
|
||||
foreach ( $mesCasesCochees as $maLigneCochee ) {
|
||||
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monNumLigne = $maLigneCourante[1];
|
||||
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = " . $monCompte;
|
||||
$sql .= " WHERE rowid = " . $monId;
|
||||
|
||||
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql);
|
||||
if ($db->query($sql)) {
|
||||
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
}
|
||||
|
||||
$cpt ++;
|
||||
}
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
|
||||
}
|
||||
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Supplier Invoice Lines
|
||||
*
|
||||
*/
|
||||
$page = GETPOST('page');
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
|
||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
||||
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
|
||||
$limit = $conf->liste_limit;
|
||||
} else {
|
||||
$limit = $conf->liste_limit;
|
||||
}
|
||||
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, ";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_buy = aa.account_number";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
|
||||
$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
|
||||
$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_sell IS NULL)";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity = '" . $conf->entity . "'";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY l.rowid";
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
|
||||
$sql .= " DESC ";
|
||||
}
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/supplier/list.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
|
||||
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<td align="left"><br><b>' . $langs->trans("DescVentilTodoSupplier") . '</b></br></td>';
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
||||
print '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>Facture</td>';
|
||||
print '<td align="left">' . $langs->trans("Ref") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Label") . '</td>';
|
||||
print '<td>' . $langs->trans("Description") . '</td>';
|
||||
print '<td align="right">' . $langs->trans("Amount") . '</td>';
|
||||
print '<td align="right">' . $langs->trans("Compte") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("IntoAccount") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("Ventilate") . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$facturefourn_static = new FactureFournisseur($db);
|
||||
$productfourn_static = new ProductFournisseur($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$var = True;
|
||||
while ( $i < min($num_lines, $limit) ) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Ref facture
|
||||
$facturefourn_static->ref = $objp->ref;
|
||||
$facturefourn_static->id = $objp->facid;
|
||||
print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>';
|
||||
|
||||
// Ref facture supplier
|
||||
$productfourn_static->ref = $objp->product_ref;
|
||||
$productfourn_static->id = $objp->product_id;
|
||||
$productfourn_static->type = $objp->type;
|
||||
print '<td>';
|
||||
if ($productfourn_static->id)
|
||||
print $productfourn_static->getNomUrl(1);
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
// print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$objp->facid.'">'.$objp->ref.'</a></td>';
|
||||
|
||||
// print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$objp->facid.'">'.$objp->ref_supplier.'</a></td>';
|
||||
|
||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
|
||||
print '<td>' . stripslashes(nl2br($objp->description)) . '</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
print price($objp->price);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
print $objp->code_buy;
|
||||
print '</td>';
|
||||
|
||||
// Colonne choix du compte
|
||||
print '<td align="center">';
|
||||
print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1);
|
||||
print '</td>';
|
||||
// Colonne choix ligne a ventiler
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '"></div>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -35,7 +35,7 @@ $extrafields = new ExtraFields($db);
|
||||
$form = new Form($db);
|
||||
|
||||
// List of supported format
|
||||
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
|
||||
$tmptype2label=ExtraFields::$type2label;
|
||||
$type2label=array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ $extrafields = new ExtraFields($db);
|
||||
$form = new Form($db);
|
||||
|
||||
// List of supported format
|
||||
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
|
||||
$tmptype2label=ExtraFields::$type2label;
|
||||
$type2label=array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@ $object = new Adherent($db);
|
||||
$result=$object->fetch($id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$adht = new AdherentType($db);
|
||||
$result=$adht->fetch($object->typeid);
|
||||
}
|
||||
@ -84,7 +86,7 @@ if ($object->id > 0)
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Reference
|
||||
print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
|
||||
@ -139,14 +141,30 @@ if ($object->id > 0)
|
||||
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create">'.$langs->trans("AddAction").'</a></div>';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create">'.$langs->trans("AddAction").'</a></div>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print load_fiche_titre($langs->trans("ActionsOnMember"),'','');
|
||||
$out='';
|
||||
|
||||
/*$objthirdparty=$object->thirdparty;
|
||||
$objcon=new stdClass();
|
||||
|
||||
$permok=$user->rights->agenda->myactions->create;
|
||||
if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
|
||||
{
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
|
||||
if (get_class($objthirdparty) == 'Societe') $out.='&socid='.$objthirdparty->id;
|
||||
$out.=(! empty($objcon->id)?'&contactid='.$objcon->id:'').'&backtopage=1&percentage=-1">';
|
||||
$out.=$langs->trans("AddAnAction").' ';
|
||||
$out.=img_picto($langs->trans("AddAnAction"),'filenew');
|
||||
$out.="</a>";
|
||||
}*/
|
||||
|
||||
print load_fiche_titre($langs->trans("ActionsOnMember"),$out,'');
|
||||
|
||||
// List of todo actions
|
||||
show_actions_todo($conf,$langs,$db,$object);
|
||||
|
||||
@ -94,7 +94,7 @@ abstract class ActionsAdherentCardCommon
|
||||
/**
|
||||
* Load data control
|
||||
*
|
||||
* @param string &$action Type of action
|
||||
* @param string $action Type of action
|
||||
* @param int $id Id of object
|
||||
* @return void
|
||||
*/
|
||||
@ -130,7 +130,7 @@ abstract class ActionsAdherentCardCommon
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errors=$nuser->error;
|
||||
$this->errors[]=$nuser->error;
|
||||
|
||||
$this->db->rollback();
|
||||
}
|
||||
@ -228,7 +228,7 @@ abstract class ActionsAdherentCardCommon
|
||||
/**
|
||||
* Set content of ->tpl array, to use into template
|
||||
*
|
||||
* @param string &$action Type of action
|
||||
* @param string $action Type of action
|
||||
* @param int $id Id
|
||||
* @return string HTML output
|
||||
*/
|
||||
@ -412,7 +412,7 @@ abstract class ActionsAdherentCardCommon
|
||||
// We set country_id, and country_code label of the chosen country
|
||||
if ($this->object->country_id)
|
||||
{
|
||||
$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->country_id;
|
||||
$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id;
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
@ -76,7 +76,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
|
||||
/**
|
||||
* Assign custom values for canvas
|
||||
*
|
||||
* @param string &$action Type of action
|
||||
* @param string $action Type of action
|
||||
* @param int $id Id
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/adherents/fiche.php
|
||||
* \file htdocs/adherents/card.php
|
||||
* \ingroup member
|
||||
* \brief Page of member
|
||||
*/
|
||||
@ -108,7 +108,7 @@ if ($rowid)
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('membercard'));
|
||||
$hookmanager->initHooks(array('membercard','globalcard'));
|
||||
|
||||
|
||||
/*
|
||||
@ -117,6 +117,7 @@ $hookmanager->initHooks(array('membercard'));
|
||||
|
||||
$parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas);
|
||||
$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 ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
|
||||
{
|
||||
@ -326,6 +327,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
|
||||
{
|
||||
if (GETPOST('deletephoto'))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/'.$object->photo;
|
||||
$dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/thumbs';
|
||||
dol_delete_file($fileimg);
|
||||
@ -458,7 +460,7 @@ if ($action == 'add' && $user->rights->adherent->creer)
|
||||
$object->email = $email;
|
||||
$object->login = $login;
|
||||
$object->pass = $pass;
|
||||
$object->naiss = $birthdate;
|
||||
$object->birth = $birthdate;
|
||||
$object->photo = $photo;
|
||||
$object->typeid = $typeid;
|
||||
//$object->note = $comment;
|
||||
@ -563,7 +565,7 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confir
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Location: liste.php");
|
||||
header("Location: list.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -881,7 +883,7 @@ else
|
||||
|
||||
// Birthday
|
||||
print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
|
||||
$form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc');
|
||||
$form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc');
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Profil public
|
||||
@ -945,7 +947,7 @@ else
|
||||
$country=GETPOST('country','int');
|
||||
if (!empty($country) || $object->country_id)
|
||||
{
|
||||
$sql = "SELECT rowid, code, libelle as label from ".MAIN_DB_PREFIX."c_pays where rowid = ".(!empty($country)?$country:$object->country_id);
|
||||
$sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country)?$country:$object->country_id);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -1283,13 +1285,13 @@ else
|
||||
if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
|
||||
$formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
|
||||
}
|
||||
print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1);
|
||||
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1);
|
||||
}
|
||||
|
||||
// Confirm send card by mail
|
||||
if ($action == 'sendinfo')
|
||||
{
|
||||
print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
|
||||
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
|
||||
}
|
||||
|
||||
// Confirm resiliate
|
||||
@ -1320,7 +1322,7 @@ else
|
||||
$formquestion=array();
|
||||
if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
|
||||
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
||||
print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion);
|
||||
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion);
|
||||
}
|
||||
|
||||
// Confirm remove member
|
||||
@ -1328,7 +1330,7 @@ else
|
||||
{
|
||||
$formquestion=array();
|
||||
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
||||
print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
|
||||
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1336,7 +1338,7 @@ else
|
||||
*/
|
||||
if ($action == 'add_spip')
|
||||
{
|
||||
print $form->formconfirm("fiche.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
|
||||
print $form->formconfirm("card.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1344,7 +1346,7 @@ else
|
||||
*/
|
||||
if ($action == 'del_spip')
|
||||
{
|
||||
print $form->formconfirm("fiche.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
|
||||
print $form->formconfirm("card.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
|
||||
}
|
||||
|
||||
$rowspan=17;
|
||||
@ -1354,7 +1356,7 @@ else
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
@ -1542,7 +1544,7 @@ else
|
||||
// Modify
|
||||
if ($user->rights->adherent->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid='.$rowid.'&action=edit">'.$langs->trans("Modify")."</a></div>";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=edit">'.$langs->trans("Modify")."</a></div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1554,7 +1556,7 @@ else
|
||||
{
|
||||
if ($user->rights->adherent->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Validate")."</a></div>\n";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Validate")."</a></div>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1567,7 +1569,7 @@ else
|
||||
{
|
||||
if ($user->rights->adherent->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Reenable")."</a></div>\n";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Reenable")."</a></div>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1580,7 +1582,7 @@ else
|
||||
{
|
||||
if ($object->statut >= 1)
|
||||
{
|
||||
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
|
||||
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
|
||||
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a></div>\n";
|
||||
}
|
||||
else
|
||||
@ -1598,7 +1600,7 @@ else
|
||||
{
|
||||
if ($user->rights->adherent->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid='.$rowid.'&action=resign">'.$langs->trans("Resiliate")."</a></div>\n";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=resign">'.$langs->trans("Resiliate")."</a></div>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1637,7 +1639,7 @@ else
|
||||
// Delete
|
||||
if ($user->rights->adherent->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="fiche.php?rowid='.$object->id.'&action=delete">'.$langs->trans("Delete")."</a></div>\n";
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete">'.$langs->trans("Delete")."</a></div>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1651,11 +1653,11 @@ else
|
||||
|
||||
if ($isinspip == 1)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid='.$object->id.'&action=del_spip">'.$langs->trans("DeleteIntoSpip")."</a></div>\n";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=del_spip">'.$langs->trans("DeleteIntoSpip")."</a></div>\n";
|
||||
}
|
||||
if ($isinspip == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
|
||||
$db->begin();
|
||||
|
||||
// Create subscription
|
||||
$crowid=$object->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $option);
|
||||
$crowid=$object->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
|
||||
if ($crowid <= 0)
|
||||
{
|
||||
$error++;
|
||||
@ -299,7 +299,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
|
||||
$insertid=$acct->addline($dateop, $operation, $label, $cotisation, $num_chq, '', $user, $emetteur_nom, $emetteur_banque);
|
||||
if ($insertid > 0)
|
||||
{
|
||||
$inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/fiche.php?rowid=', $object->getFullname($langs), 'member');
|
||||
$inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $object->getFullname($langs), 'member');
|
||||
if ($inserturlid > 0)
|
||||
{
|
||||
// Met a jour la table cotisation
|
||||
@ -482,7 +482,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
|
||||
}
|
||||
// Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
|
||||
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
facture_pdf_create($db, $invoice, $invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
$invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
|
||||
}
|
||||
@ -554,7 +555,7 @@ if ($rowid)
|
||||
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
|
||||
@ -64,9 +64,9 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
|
||||
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
|
||||
$sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
|
||||
$sql.= " t.libelle as type,";
|
||||
$sql.= " p.code as country_code, p.libelle as country";
|
||||
$sql.= " c.code as country_code, c.label as country";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.country = p.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
|
||||
$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
|
||||
if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
|
||||
if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'";
|
||||
|
||||
@ -187,7 +187,7 @@ class Adherent extends CommonObject
|
||||
if (dol_textishtml($text,1)) $msgishtml = 1;
|
||||
|
||||
$infos='';
|
||||
if ($this->civility_id) $infos.= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel(1)."\n";
|
||||
if ($this->civility_id) $infos.= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n";
|
||||
$infos.= $langs->transnoentities("id").": ".$this->id."\n";
|
||||
$infos.= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
|
||||
$infos.= $langs->transnoentities("Firstname").": ".$this->firstname."\n";
|
||||
@ -210,7 +210,7 @@ class Adherent extends CommonObject
|
||||
$substitutionarray=array(
|
||||
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
|
||||
'%ID%'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id,
|
||||
'%CIVILITY%'=>$this->getCivilityLabel($msgishtml?0:1),
|
||||
'%CIVILITY%'=>$this->getCivilityLabel(),
|
||||
'%FIRSTNAME%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
|
||||
'%LASTNAME%'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
|
||||
'%FULLNAME%'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs),
|
||||
@ -350,7 +350,7 @@ class Adherent extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('MEMBER_CREATE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ class Adherent extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
|
||||
$sql.= " civilite = ".(!is_null($this->civility_id)?"'".$this->civility_id."'":"null");
|
||||
$sql.= " civility = ".(!is_null($this->civility_id)?"'".$this->civility_id."'":"null");
|
||||
$sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null");
|
||||
$sql.= ", lastname=" .($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
|
||||
$sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null");
|
||||
@ -599,7 +599,7 @@ class Adherent extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('MEMBER_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
@ -774,7 +774,7 @@ class Adherent extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('MEMBER_DELETE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ class Adherent extends CommonObject
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
// Mise a jour
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET pass = '".$this->db->escape($password_indatabase)."'";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
@ -877,7 +877,7 @@ class Adherent extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('MEMBER_NEW_PASSWORD',$user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -1048,7 +1048,7 @@ class Adherent extends CommonObject
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT d.rowid, d.ref_ext, d.civilite as civility_id, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note,";
|
||||
$sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note,";
|
||||
$sql.= " d.email, d.skype, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
|
||||
$sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
|
||||
$sql.= " d.datec as datec,";
|
||||
@ -1058,19 +1058,19 @@ class Adherent extends CommonObject
|
||||
$sql.= " d.datevalid as datev,";
|
||||
$sql.= " d.country,";
|
||||
$sql.= " d.state_id,";
|
||||
$sql.= " p.rowid as country_id, p.code as country_code, p.libelle as country,";
|
||||
$sql.= " c.rowid as country_id, c.code as country_code, c.label as country,";
|
||||
$sql.= " dep.nom as state, dep.code_departement as state_code,";
|
||||
$sql.= " t.libelle as type, t.cotisation as cotisation,";
|
||||
$sql.= " u.rowid as user_id, u.login as user_login";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.country = p.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member";
|
||||
$sql.= " WHERE d.fk_adherent_type = t.rowid";
|
||||
if ($rowid) $sql.= " AND d.rowid=".$rowid;
|
||||
elseif ($ref || $fk_soc) {
|
||||
$sql.= " AND d.entity IN (".getEntity().")";
|
||||
if ($ref) $sql.= " AND d.rowid='".$ref."'";
|
||||
if ($ref) $sql.= " AND d.rowid='".$this->db->escape($ref)."'";
|
||||
elseif ($fk_soc) $sql.= " AND d.fk_soc='".$fk_soc."'";
|
||||
}
|
||||
elseif ($ref_ext)
|
||||
@ -1090,7 +1090,7 @@ class Adherent extends CommonObject
|
||||
$this->ref = $obj->rowid;
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref_ext = $obj->ref_ext;
|
||||
$this->civility_id = $obj->civility;
|
||||
$this->civility_id = $obj->civility_id;
|
||||
$this->firstname = $obj->firstname;
|
||||
$this->lastname = $obj->lastname;
|
||||
$this->login = $obj->login;
|
||||
@ -1292,7 +1292,7 @@ class Adherent extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('MEMBER_SUBSCRIPTION',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -1351,7 +1351,7 @@ class Adherent extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('MEMBER_VALIDATE',$user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// End call triggers
|
||||
|
||||
$this->db->commit();
|
||||
@ -1399,7 +1399,7 @@ class Adherent extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('MEMBER_RESILIATE',$user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// End call triggers
|
||||
|
||||
$this->db->commit();
|
||||
@ -1530,7 +1530,7 @@ class Adherent extends CommonObject
|
||||
/**
|
||||
* Return civility label of a member
|
||||
*
|
||||
* @return string Translated name of civility
|
||||
* @return string Translated name of civility (translated with transnoentitiesnoconv)
|
||||
*/
|
||||
function getCivilityLabel()
|
||||
{
|
||||
@ -1539,7 +1539,7 @@ class Adherent extends CommonObject
|
||||
|
||||
$code=(empty($this->civility_id)?'':$this->civility_id);
|
||||
if (empty($code)) return '';
|
||||
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civilite", "code", "civilite", $code);
|
||||
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1558,7 +1558,7 @@ class Adherent extends CommonObject
|
||||
|
||||
if ($option == 'card')
|
||||
{
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$this->id.'">';
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id.'">';
|
||||
$lienfin='</a>';
|
||||
}
|
||||
if ($option == 'subscription')
|
||||
|
||||
@ -119,7 +119,7 @@ class AdherentType extends CommonObject
|
||||
if ($result)
|
||||
{
|
||||
$action='update';
|
||||
|
||||
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
$hookmanager->initHooks(array('membertypedao'));
|
||||
$parameters=array('membertype'=>$this->id);
|
||||
@ -151,21 +151,23 @@ class AdherentType extends CommonObject
|
||||
* Fonction qui permet de supprimer le status de l'adherent
|
||||
*
|
||||
* @param int $rowid Id of member type to delete
|
||||
* @return int >0 if OK, < 0 if KO
|
||||
* @return int >0 if OK, 0 if not found, < 0 if KO
|
||||
*/
|
||||
function delete($rowid)
|
||||
function delete($rowid='')
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type WHERE rowid = $rowid";
|
||||
if (empty($rowid)) $rowid=$this->id;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type WHERE rowid = ".$rowid;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ( $this->db->affected_rows($resql) )
|
||||
if ($this->db->affected_rows($resql))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,17 +97,17 @@ if ($result)
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Ref"),"cotisations.php","c.rowid",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Name"),"cotisations.php","d.lastname",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Login"),"cotisations.php","d.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),"cotisations.php","c.note",$param,"",'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"c.note",$param,"",'align="left"',$sortfield,$sortorder);
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print_liste_field_titre($langs->trans("Account"),"cotisations.php","b.fk_account",$pram,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"b.fk_account",$pram,"","",$sortfield,$sortorder);
|
||||
}
|
||||
print_liste_field_titre($langs->trans("Date"),"cotisations.php","c.dateadh",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateEnd"),"cotisations.php","c.datef",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation",$param,"",'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"c.dateadh",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"c.datef",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"c.cotisation",$param,"",'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
// Static objects
|
||||
|
||||
@ -113,7 +113,7 @@ if ($id > 0)
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
|
||||
@ -127,7 +127,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
|
||||
// Formulaire recherche adherent
|
||||
print '<form action="liste.php" method="post">';
|
||||
print '<form action="list.php" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="search">';
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/adherents/liste.php
|
||||
* \file htdocs/adherents/list.php
|
||||
* \ingroup member
|
||||
* \brief Page to list all members of foundation
|
||||
*/
|
||||
@ -294,7 +294,7 @@ if ($resql)
|
||||
print "</td>\n";
|
||||
|
||||
// Lastname
|
||||
print "<td><a href=\"fiche.php?rowid=$objp->rowid\">";
|
||||
print "<td><a href=\"card.php?rowid=$objp->rowid\">";
|
||||
print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : '');
|
||||
print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : '');
|
||||
print (! empty($companyname) ? dol_trunc($companyname, 32) : '');
|
||||
@ -348,16 +348,16 @@ if ($resql)
|
||||
print '<td align="center">';
|
||||
if ($user->rights->adherent->creer)
|
||||
{
|
||||
print "<a href=\"fiche.php?rowid=".$objp->rowid."&action=edit&backtopage=1\">".img_edit()."</a>";
|
||||
print "<a href=\"card.php?rowid=".$objp->rowid."&action=edit&backtopage=1\">".img_edit()."</a>";
|
||||
}
|
||||
print ' ';
|
||||
if ($user->rights->adherent->supprimer && $objp->statut == -1)
|
||||
{
|
||||
print "<a href=\"fiche.php?rowid=".$objp->rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png')."</a>";
|
||||
print "<a href=\"card.php?rowid=".$objp->rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png')."</a>";
|
||||
}
|
||||
if ($user->rights->adherent->supprimer && $objp->statut == 1)
|
||||
{
|
||||
print "<a href=\"fiche.php?rowid=".$objp->rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
|
||||
print "<a href=\"card.php?rowid=".$objp->rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
@ -87,7 +87,7 @@ if ($id)
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Reference
|
||||
print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
|
||||
|
||||
@ -76,11 +76,11 @@ if ($mode)
|
||||
$tab='statscountry';
|
||||
|
||||
$data = array();
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.libelle as label";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_pays as c on d.country = c.rowid";
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
|
||||
$sql.=" WHERE d.entity IN (".getEntity().")";
|
||||
$sql.=" AND d.statut = 1";
|
||||
$sql.=" GROUP BY c.libelle, c.code";
|
||||
$sql.=" GROUP BY c.label, c.code";
|
||||
//print $sql;
|
||||
}
|
||||
|
||||
@ -91,29 +91,29 @@ if ($mode)
|
||||
$tab='statsstate';
|
||||
|
||||
$data = array();
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, c.nom as label2"; //
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, c.nom as label2"; //
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.country = p.rowid";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
|
||||
$sql.=" WHERE d.entity IN (".getEntity().")";
|
||||
$sql.=" AND d.statut = 1";
|
||||
$sql.=" GROUP BY p.libelle, p.code, c.nom";
|
||||
$sql.=" GROUP BY co.label, co.code, c.nom";
|
||||
//print $sql;
|
||||
}
|
||||
if ($mode == 'memberbyregion') //
|
||||
{
|
||||
$label=$langs->trans("Country"); //pays
|
||||
$label=$langs->trans("Country");
|
||||
$label2=$langs->trans("Region"); //département
|
||||
$tab='statsregion'; //onglet
|
||||
|
||||
$data = array(); //tableau de donnée
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, r.nom as label2";
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, r.nom as label2";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.country = p.rowid";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
|
||||
$sql.=" WHERE d.entity IN (".getEntity().")";
|
||||
$sql.=" AND d.statut = 1";
|
||||
$sql.=" GROUP BY p.libelle, p.code, r.nom"; //+
|
||||
$sql.=" GROUP BY co.label, co.code, r.nom"; //+
|
||||
//print $sql;
|
||||
}
|
||||
if ($mode == 'memberbytown')
|
||||
@ -123,12 +123,12 @@ if ($mode)
|
||||
$tab='statstown';
|
||||
|
||||
$data = array();
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, d.town as label2";
|
||||
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.country = p.rowid";
|
||||
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
|
||||
$sql.=" WHERE d.entity IN (".getEntity().")";
|
||||
$sql.=" AND d.statut = 1";
|
||||
$sql.=" GROUP BY p.libelle, p.code, d.town";
|
||||
$sql.=" GROUP BY c.label, c.code, d.town";
|
||||
//print $sql;
|
||||
}
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ if (GETPOST('button_removefilter'))
|
||||
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('membertypecard'));
|
||||
$hookmanager->initHooks(array('membertypecard','globalcard'));
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -353,7 +353,7 @@ if ($rowid > 0)
|
||||
}
|
||||
|
||||
// Add
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?action=create&typeid='.$adht->id.'">'.$langs->trans("AddMember").'</a></div>';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$adht->id.'">'.$langs->trans("AddMember").'</a></div>';
|
||||
|
||||
// Delete
|
||||
if ($user->rights->adherent->configurer)
|
||||
@ -364,7 +364,7 @@ if ($rowid > 0)
|
||||
print "</div>";
|
||||
|
||||
|
||||
// Show list of members (nearly same code than in page liste.php)
|
||||
// Show list of members (nearly same code than in page list.php)
|
||||
|
||||
$membertypestatic=new AdherentType($db);
|
||||
|
||||
@ -526,11 +526,11 @@ if ($rowid > 0)
|
||||
print '<tr '.$bc[$var].'>';
|
||||
if ($objp->societe != '')
|
||||
{
|
||||
print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
|
||||
print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
|
||||
print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
|
||||
}
|
||||
|
||||
// Login
|
||||
@ -588,12 +588,12 @@ if ($rowid > 0)
|
||||
print '<td align="center">';
|
||||
if ($user->rights->adherent->creer)
|
||||
{
|
||||
print '<a href="fiche.php?rowid='.$objp->rowid.'&action=edit&return=liste.php">'.img_edit().'</a>';
|
||||
print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&return=list.php">'.img_edit().'</a>';
|
||||
}
|
||||
print ' ';
|
||||
if ($user->rights->adherent->supprimer)
|
||||
{
|
||||
print '<a href="fiche.php?rowid='.$objp->rowid.'&action=resign&return=liste.php">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
|
||||
print '<a href="card.php?rowid='.$objp->rowid.'&action=resign&return=list.php">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
|
||||
@ -1,260 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/admin/accounting.php
|
||||
* \ingroup compta
|
||||
* \brief Page to setup accountancy module
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
$langs->load('admin');
|
||||
$langs->load('compta');
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
|
||||
$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
|
||||
|
||||
if ($action == 'setcomptamode')
|
||||
{
|
||||
$compta_mode = GETPOST('compta_mode','alpha');
|
||||
|
||||
$res = dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($action == 'setchart')
|
||||
{
|
||||
$chartofaccounts = GETPOST('chartofaccounts','alpha');
|
||||
|
||||
$res = dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts,'chaine',0,'',$conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'update' || $action == 'add')
|
||||
{
|
||||
$constname = GETPOST('constname','alpha');
|
||||
$constvalue = GETPOST('constvalue','alpha');
|
||||
$consttype = GETPOST('consttype','alpha');
|
||||
$constnote = GETPOST('constnote','alpha');
|
||||
|
||||
$res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*if ($action == 'delete')
|
||||
{
|
||||
if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
|
||||
{
|
||||
print $db->error();
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup');
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// Cas du parametre COMPTA_MODE
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="setcomptamode">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
print '<td align="right"><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
|
||||
print "</tr>\n";
|
||||
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
|
||||
// Write info on way to count VAT
|
||||
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
|
||||
{
|
||||
// print "<br>\n";
|
||||
// print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
|
||||
}
|
||||
else
|
||||
{
|
||||
// print "<br>\n";
|
||||
// print nl2br($langs->trans('OptionModeTrueInfoExpert'));
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
|
||||
print '</form>';
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
/*
|
||||
* Define Chart of accounts
|
||||
*
|
||||
*/
|
||||
if (! empty($conf->global->ACCOUNTING_SELECTCHART) && ! empty($conf->accounting->enabled))
|
||||
{
|
||||
print '<br>';
|
||||
print_titre($langs->trans("Definechartofaccounts"));
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
$var=True;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="action" value="setchart">';
|
||||
print $langs->trans("Chartofaccounts").'</td>';
|
||||
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
print "</tr>\n";
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print "<td>".$langs->trans("Selectchartofaccounts")."</td>";
|
||||
print "<td>";
|
||||
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
|
||||
print '<option value="0">'.$langs->trans("DoNotSuggestChart").'</option>';
|
||||
|
||||
$sql = "SELECT rowid, pcg_version, fk_pays, label, active";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_system";
|
||||
$sql.= " WHERE active = 1";
|
||||
$sql.= " AND fk_pays = ".$mysoc->country_id;
|
||||
$var=True;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$var=!$var;
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<option value="'.$row[0].'"';
|
||||
print $conf->global->CHARTOFACCOUNTS == $row[0] ? ' selected="selected"':'';
|
||||
print '>'.$row[1].' - '.$row[3].'</option>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print "</select>";
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
}
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
// Cas des autres parametres COMPTA_*
|
||||
$list=array('COMPTA_PRODUCT_BUY_ACCOUNT','COMPTA_PRODUCT_SOLD_ACCOUNT','COMPTA_SERVICE_BUY_ACCOUNT','COMPTA_SERVICE_SOLD_ACCOUNT',
|
||||
'COMPTA_VAT_ACCOUNT','COMPTA_ACCOUNT_CUSTOMER','COMPTA_ACCOUNT_SUPPLIER'
|
||||
);
|
||||
|
||||
$num=count($list);
|
||||
if ($num)
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
print '<form action="accounting.php" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="consttype" value="string">';
|
||||
print '<input type="hidden" name="constname" value="'.$key.'">';
|
||||
|
||||
print '<tr '.$bc[$var].' class="value">';
|
||||
|
||||
// Param
|
||||
$libelle = $langs->trans($key);
|
||||
print '<td>'.$libelle;
|
||||
//print ' ('.$key.')';
|
||||
print "</td>\n";
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
print '<input type="text" size="20" name="constvalue" value="'.$conf->global->$key.'">';
|
||||
print '</td><td>';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> ';
|
||||
print "</td></tr>\n";
|
||||
print '</form>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($num)
|
||||
{
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
@ -41,7 +41,7 @@ $extrafields = new ExtraFields($db);
|
||||
$form = new Form($db);
|
||||
|
||||
// List of supported format
|
||||
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
|
||||
$tmptype2label=ExtraFields::$type2label;
|
||||
$type2label=array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||
|
||||
|
||||
@ -62,10 +62,11 @@ if ($actionsave)
|
||||
// Save agendas
|
||||
while ($i <= $MAXAGENDA)
|
||||
{
|
||||
$name=trim(GETPOST('agenda_ext_name'.$i,'alpha'));
|
||||
$src=trim(GETPOST('agenda_ext_src'.$i,'alpha'));
|
||||
$color=trim(GETPOST('agenda_ext_color'.$i,'alpha'));
|
||||
$name=trim(GETPOST('AGENDA_EXT_NAME'.$i,'alpha'));
|
||||
$src=trim(GETPOST('AGENDA_EXT_SRC'.$i,'alpha'));
|
||||
$color=trim(GETPOST('AGENDA_EXT_COLOR'.$i,'alpha'));
|
||||
if ($color=='-1') $color='';
|
||||
$enabled=trim(GETPOST('AGENDA_EXT_ENABLED'.$i,'alpha'));
|
||||
|
||||
if (! empty($src) && ! dol_is_url($src))
|
||||
{
|
||||
@ -82,6 +83,8 @@ if ($actionsave)
|
||||
if (! $res > 0) $error++;
|
||||
$res=dolibarr_set_const($db,'AGENDA_EXT_COLOR'.$i,$color,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
$res=dolibarr_set_const($db,'AGENDA_EXT_ENABLED'.$i,$enabled,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -195,19 +198,20 @@ while ($i <= $MAXAGENDA)
|
||||
$name='AGENDA_EXT_NAME'.$key;
|
||||
$src='AGENDA_EXT_SRC'.$key;
|
||||
$color='AGENDA_EXT_COLOR'.$key;
|
||||
$enabled='AGENDA_EXT_ENABLED'.$key;
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
// Nb
|
||||
print '<td width="180" class="nowrap">'.$langs->trans("AgendaExtNb",$key)."</td>";
|
||||
// Name
|
||||
print '<td><input type="text" class="flat hideifnotset" name="agenda_ext_name'.$key.'" value="'. (GETPOST('agenda_ext_name'.$key)?GETPOST('agenda_ext_name'.$key):$conf->global->$name) . '" size="28"></td>';
|
||||
print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_NAME'.$key.'" value="'. (GETPOST('AGENDA_EXT_NAME'.$key)?GETPOST('AGENDA_EXT_NAME'.$key):$conf->global->$name) . '" size="28"></td>';
|
||||
// URL
|
||||
print '<td><input type="url" class="flat hideifnotset" name="agenda_ext_src'.$key.'" value="'. (GETPOST('agenda_ext_src'.$key)?GETPOST('agenda_ext_src'.$key):$conf->global->$src) . '" size="60"></td>';
|
||||
print '<td><input type="url" class="flat hideifnotset" name="AGENDA_EXT_SRC'.$key.'" value="'. (GETPOST('AGENDA_EXT_SRC'.$key)?GETPOST('AGENDA_EXT_SRC'.$key):$conf->global->$src) . '" size="60"></td>';
|
||||
// Color (Possible colors are limited by Google)
|
||||
print '<td class="nowrap" align="right">';
|
||||
//print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist);
|
||||
print $formother->selectColor((GETPOST("agenda_ext_color".$key)?GETPOST("agenda_ext_color".$key):$conf->global->$color), "agenda_ext_color".$key, 'extsitesconfig', 1, '', 'hideifnotset');
|
||||
print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key)?GETPOST("AGENDA_EXT_COLOR".$key):$conf->global->$color), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset');
|
||||
print '</td>';
|
||||
print "</tr>";
|
||||
$i++;
|
||||
|
||||
@ -142,7 +142,7 @@ print "</center>";
|
||||
|
||||
print "</form>\n";
|
||||
|
||||
print '</div>';
|
||||
dol_fiche_end();
|
||||
|
||||
clearstatcache();
|
||||
|
||||
|
||||
@ -396,7 +396,7 @@ if ($conf->produit->enabled)
|
||||
$var = !$var;
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$modBarCode->nom."</td><td>\n";
|
||||
print '<td>'.(isset($modBarCode->name)?$modBarCode->name:$modBarCode->nom)."</td><td>\n";
|
||||
print $modBarCode->info($langs);
|
||||
print '</td>';
|
||||
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
@ -117,6 +117,35 @@ else if ($action == 'specimen')
|
||||
}
|
||||
}
|
||||
|
||||
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
|
||||
if ($action == 'setModuleOptions')
|
||||
{
|
||||
$post_size=count($_POST);
|
||||
|
||||
$db->begin();
|
||||
|
||||
for($i=0;$i < $post_size;$i++)
|
||||
{
|
||||
if (array_key_exists('param'.$i,$_POST))
|
||||
{
|
||||
$param=GETPOST("param".$i,'alpha');
|
||||
$value=GETPOST("value".$i,'alpha');
|
||||
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
if ($action == 'set')
|
||||
{
|
||||
@ -192,14 +221,6 @@ else if ($action == 'set_COMMANDE_FREE_TEXT')
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
else if ($action=='setModuleOptions') {
|
||||
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF_ODT_PATH",GETPOST('value1'),'chaine',0,'',$conf->entity))
|
||||
{
|
||||
// La constante qui a ete lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage coherent
|
||||
$conf->global->COMMANDE_ADDON_PDF_ODT_PATH = GETPOST('value1');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -318,7 +318,7 @@ if ($action == 'edit' || $action == 'updateedit')
|
||||
// Country
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
|
||||
//if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation
|
||||
//if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization
|
||||
print $form->select_country($mysoc->country_id,'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
@ -37,39 +37,39 @@ accessforbidden();
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
|
||||
// Other parameters COMPTA_*
|
||||
// Other parameters ACCOUNTING_*
|
||||
$list = array(
|
||||
'COMPTA_PRODUCT_BUY_ACCOUNT',
|
||||
'COMPTA_PRODUCT_SOLD_ACCOUNT',
|
||||
'COMPTA_SERVICE_BUY_ACCOUNT',
|
||||
'COMPTA_SERVICE_SOLD_ACCOUNT',
|
||||
'COMPTA_VAT_ACCOUNT',
|
||||
'COMPTA_VAT_BUY_ACCOUNT',
|
||||
'COMPTA_ACCOUNT_CUSTOMER',
|
||||
'COMPTA_ACCOUNT_SUPPLIER'
|
||||
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
|
||||
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
|
||||
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
|
||||
'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
|
||||
'ACCOUNTING_VAT_ACCOUNT',
|
||||
'ACCOUNTING_VAT_BUY_ACCOUNT',
|
||||
'ACCOUNTING_ACCOUNT_CUSTOMER',
|
||||
'ACCOUNTING_ACCOUNT_SUPPLIER'
|
||||
);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
|
||||
$accounting_mode = defined('ACCOUNTING_MODE')?ACCOUNTING_MODE:'RECETTES-DEPENSES';
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$compta_modes = array(
|
||||
$accounting_modes = array(
|
||||
'RECETTES-DEPENSES',
|
||||
'CREANCES-DETTES'
|
||||
);
|
||||
|
||||
$compta_mode = GETPOST('compta_mode','alpha');
|
||||
$accounting_mode = GETPOST('accounting_mode','alpha');
|
||||
|
||||
|
||||
if (in_array($compta_mode,$compta_modes)) {
|
||||
if (in_array($accounting_mode,$accounting_modes)) {
|
||||
|
||||
if (!dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode, 'chaine', 0, '', $conf->entity)) {
|
||||
if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
@ -113,12 +113,12 @@ print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// Cas du parametre COMPTA_MODE
|
||||
// Cas du parametre ACCOUNTING_MODE
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
|
||||
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
|
||||
// Write info on way to count VAT
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
|
||||
@ -132,7 +132,7 @@ print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
|
||||
// // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
|
||||
//}
|
||||
print "</td></tr>\n";
|
||||
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
|
||||
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
|
||||
print '</form>';
|
||||
|
||||
|
||||
@ -35,8 +35,9 @@ if (!$user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
$value = GETPOST('value','alpha');
|
||||
$label = GETPOST('label','alpha');
|
||||
$scandir = GETPOST('scandir','alpha');
|
||||
$type='contrat';
|
||||
$type='contract';
|
||||
|
||||
if (empty($conf->global->CONTRACT_ADDON))
|
||||
{
|
||||
@ -111,6 +112,35 @@ else if ($action == 'specimen') // For contract
|
||||
}
|
||||
}
|
||||
|
||||
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
|
||||
if ($action == 'setModuleOptions')
|
||||
{
|
||||
$post_size=count($_POST);
|
||||
|
||||
$db->begin();
|
||||
|
||||
for($i=0;$i < $post_size;$i++)
|
||||
{
|
||||
if (array_key_exists('param'.$i,$_POST))
|
||||
{
|
||||
$param=GETPOST("param".$i,'alpha');
|
||||
$value=GETPOST("value".$i,'alpha');
|
||||
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
else if ($action == 'set')
|
||||
{
|
||||
@ -192,7 +222,7 @@ else if ($action == 'set_CONTRACT_DRAFT_WATERMARK')
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form=new Form($db);
|
||||
@ -318,7 +348,6 @@ print '</table><br>';
|
||||
print_titre($langs->trans("TemplatePDFContracts"));
|
||||
|
||||
// Defini tableau def des modeles
|
||||
$type='contrat';
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
@ -70,15 +70,15 @@ $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(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23,0,26);
|
||||
$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,23,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24);
|
||||
|
||||
// Name of SQL tables of dictionaries
|
||||
$tabname=array();
|
||||
$tabname[1] = MAIN_DB_PREFIX."c_forme_juridique";
|
||||
$tabname[2] = MAIN_DB_PREFIX."c_departements";
|
||||
$tabname[3] = MAIN_DB_PREFIX."c_regions";
|
||||
$tabname[4] = MAIN_DB_PREFIX."c_pays";
|
||||
$tabname[5] = MAIN_DB_PREFIX."c_civilite";
|
||||
$tabname[4] = MAIN_DB_PREFIX."c_country";
|
||||
$tabname[5] = MAIN_DB_PREFIX."c_civility";
|
||||
$tabname[6] = MAIN_DB_PREFIX."c_actioncomm";
|
||||
$tabname[7] = MAIN_DB_PREFIX."c_chargesociales";
|
||||
$tabname[8] = MAIN_DB_PREFIX."c_typent";
|
||||
@ -96,10 +96,8 @@ $tabname[19]= MAIN_DB_PREFIX."c_effectif";
|
||||
$tabname[20]= MAIN_DB_PREFIX."c_input_method";
|
||||
$tabname[21]= MAIN_DB_PREFIX."c_availability";
|
||||
$tabname[22]= MAIN_DB_PREFIX."c_input_reason";
|
||||
$tabname[23]= MAIN_DB_PREFIX."accountingaccount";
|
||||
$tabname[24]= MAIN_DB_PREFIX."accounting_system";
|
||||
$tabname[25]= MAIN_DB_PREFIX."c_revenuestamp";
|
||||
$tabname[26]= MAIN_DB_PREFIX."c_type_resource";
|
||||
$tabname[23]= MAIN_DB_PREFIX."c_revenuestamp";
|
||||
$tabname[24]= MAIN_DB_PREFIX."c_type_resource";
|
||||
|
||||
// Dictionary labels
|
||||
$tablib=array();
|
||||
@ -125,39 +123,35 @@ $tablib[19]= "DictionaryStaff";
|
||||
$tablib[20]= "DictionaryOrderMethods";
|
||||
$tablib[21]= "DictionaryAvailability";
|
||||
$tablib[22]= "DictionarySource";
|
||||
$tablib[23]= "DictionaryAccountancyplan";
|
||||
$tablib[24]= "DictionaryAccountancysystem";
|
||||
$tablib[25]= "DictionaryRevenueStamp";
|
||||
$tablib[26]= "DictionaryResourceType";
|
||||
$tablib[23]= "DictionaryRevenueStamp";
|
||||
$tablib[24]= "DictionaryResourceType";
|
||||
|
||||
// Requests to extract data
|
||||
$tabsql=array();
|
||||
$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as country_code, p.libelle as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid";
|
||||
$tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, p.code as country_code, p.libelle as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid and r.active=1 and p.active=1";
|
||||
$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, p.code as country_code, p.libelle as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE r.fk_pays=p.rowid and p.active=1";
|
||||
$tabsql[4] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_pays";
|
||||
$tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.civilite AS libelle, c.active FROM ".MAIN_DB_PREFIX."c_civilite AS c";
|
||||
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
|
||||
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, p.code as country_code, p.libelle as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1";
|
||||
$tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, p.code as country_code, p.libelle as country, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON t.fk_country=p.rowid";
|
||||
$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid";
|
||||
$tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1";
|
||||
$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[4] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_country";
|
||||
$tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
|
||||
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
|
||||
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid";
|
||||
$tabsql[9] = "SELECT code_iso as code, label, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies";
|
||||
$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, p.libelle as country, p.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid";
|
||||
$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
||||
$tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
|
||||
$tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
|
||||
$tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active, accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement AS c";
|
||||
$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, p.code as country_code, p.libelle as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_pays as p WHERE e.fk_pays=p.rowid and p.active=1";
|
||||
$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
|
||||
$tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
||||
$tabsql[17]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_fees";
|
||||
$tabsql[17]= "SELECT id as rowid, code, label, accountancy_code, active FROM ".MAIN_DB_PREFIX."c_type_fees";
|
||||
$tabsql[18]= "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
|
||||
$tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
|
||||
$tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
|
||||
$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
|
||||
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
|
||||
$tabsql[23]= "SELECT rowid as rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number as accountancy_code, account_parent, label, active FROM ".MAIN_DB_PREFIX."accountingaccount";
|
||||
$tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, p.code as country_code, p.libelle as pays, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_pays as p WHERE s.fk_pays=p.rowid and p.active=1";
|
||||
$tabsql[25]= "SELECT t.rowid, t.taux, p.libelle as country, p.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid";
|
||||
$tabsql[26]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
|
||||
$tabsql[23]= "SELECT t.rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
||||
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
|
||||
|
||||
// Criteria to sort dictionaries
|
||||
$tabsqlsort=array();
|
||||
@ -165,7 +159,7 @@ $tabsqlsort[1] ="country ASC, code ASC";
|
||||
$tabsqlsort[2] ="country ASC, code ASC";
|
||||
$tabsqlsort[3] ="country ASC, code ASC";
|
||||
$tabsqlsort[4] ="code ASC";
|
||||
$tabsqlsort[5] ="libelle ASC";
|
||||
$tabsqlsort[5] ="label ASC";
|
||||
$tabsqlsort[6] ="a.type ASC, a.module ASC, a.position ASC, a.code ASC";
|
||||
$tabsqlsort[7] ="country ASC, code ASC, a.libelle ASC";
|
||||
$tabsqlsort[8] ="country DESC, libelle ASC";
|
||||
@ -183,19 +177,17 @@ $tabsqlsort[19]="id ASC";
|
||||
$tabsqlsort[20]="code ASC, libelle ASC";
|
||||
$tabsqlsort[21]="code ASC, label ASC";
|
||||
$tabsqlsort[22]="code ASC, label ASC";
|
||||
$tabsqlsort[23]="fk_pcg_version ASC, accountancy_code ASC";
|
||||
$tabsqlsort[24]="pcg_version ASC";
|
||||
$tabsqlsort[25]="country ASC, taux ASC";
|
||||
$tabsqlsort[26]="code ASC,label ASC";
|
||||
$tabsqlsort[23]="country ASC, taux ASC";
|
||||
$tabsqlsort[24]="code ASC,label ASC";
|
||||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield=array();
|
||||
$tabfield[1] = "code,libelle,country";
|
||||
$tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country"
|
||||
$tabfield[3] = "code,libelle,country_id,country";
|
||||
$tabfield[4] = "code,libelle";
|
||||
$tabfield[5] = "code,libelle";
|
||||
$tabfield[6] = "code,libelle,type,position";
|
||||
$tabfield[4] = "code,label";
|
||||
$tabfield[5] = "code,label";
|
||||
$tabfield[6] = "code,libelle,type,color,position";
|
||||
$tabfield[7] = "code,libelle,country_id,country,accountancy_code,deductible";
|
||||
$tabfield[8] = "code,libelle,country_id,country";
|
||||
$tabfield[9] = "code,label,unicode";
|
||||
@ -206,25 +198,23 @@ $tabfield[13]= "code,libelle,type,accountancy_code";
|
||||
$tabfield[14]= "code,libelle,price,organization,country_id,country";
|
||||
$tabfield[15]= "code,libelle,width,height,unit";
|
||||
$tabfield[16]= "code,libelle,sortorder";
|
||||
$tabfield[17]= "code,libelle";
|
||||
$tabfield[17]= "code,label,accountancy_code";
|
||||
$tabfield[18]= "code,libelle,tracking";
|
||||
$tabfield[19]= "code,libelle";
|
||||
$tabfield[20]= "code,libelle";
|
||||
$tabfield[21]= "code,label";
|
||||
$tabfield[22]= "code,label";
|
||||
$tabfield[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
|
||||
$tabfield[24]= "pcg_version,country_id,country,label";
|
||||
$tabfield[25]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfield[26]= "code,label";
|
||||
$tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfield[24]= "code,label";
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue=array();
|
||||
$tabfieldvalue[1] = "code,libelle,country";
|
||||
$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region"
|
||||
$tabfieldvalue[3] = "code,libelle,country";
|
||||
$tabfieldvalue[4] = "code,libelle";
|
||||
$tabfieldvalue[5] = "code,libelle";
|
||||
$tabfieldvalue[6] = "code,libelle,type,position";
|
||||
$tabfieldvalue[4] = "code,label";
|
||||
$tabfieldvalue[5] = "code,label";
|
||||
$tabfieldvalue[6] = "code,libelle,type,color,position";
|
||||
$tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible";
|
||||
$tabfieldvalue[8] = "code,libelle,country";
|
||||
$tabfieldvalue[9] = "code,label,unicode";
|
||||
@ -235,25 +225,23 @@ $tabfieldvalue[13]= "code,libelle,type,accountancy_code";
|
||||
$tabfieldvalue[14]= "code,libelle,price,organization,country";
|
||||
$tabfieldvalue[15]= "code,libelle,width,height,unit";
|
||||
$tabfieldvalue[16]= "code,libelle,sortorder";
|
||||
$tabfieldvalue[17]= "code,libelle";
|
||||
$tabfieldvalue[17]= "code,label,accountancy_code";
|
||||
$tabfieldvalue[18]= "code,libelle,tracking";
|
||||
$tabfieldvalue[19]= "code,libelle";
|
||||
$tabfieldvalue[20]= "code,libelle";
|
||||
$tabfieldvalue[21]= "code,label";
|
||||
$tabfieldvalue[22]= "code,label";
|
||||
$tabfieldvalue[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
|
||||
$tabfieldvalue[24]= "pcg_version,country,label";
|
||||
$tabfieldvalue[25]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldvalue[26]= "code,label";
|
||||
$tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldvalue[24]= "code,label";
|
||||
|
||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||
$tabfieldinsert=array();
|
||||
$tabfieldinsert[1] = "code,libelle,fk_pays";
|
||||
$tabfieldinsert[2] = "code_departement,nom,fk_region";
|
||||
$tabfieldinsert[3] = "code_region,nom,fk_pays";
|
||||
$tabfieldinsert[4] = "code,libelle";
|
||||
$tabfieldinsert[5] = "code,civilite";
|
||||
$tabfieldinsert[6] = "code,libelle,type,position";
|
||||
$tabfieldinsert[4] = "code,label";
|
||||
$tabfieldinsert[5] = "code,label";
|
||||
$tabfieldinsert[6] = "code,libelle,type,color,position";
|
||||
$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible";
|
||||
$tabfieldinsert[8] = "code,libelle,fk_country";
|
||||
$tabfieldinsert[9] = "code_iso,label,unicode";
|
||||
@ -264,16 +252,14 @@ $tabfieldinsert[13]= "code,libelle,type,accountancy_code";
|
||||
$tabfieldinsert[14]= "code,libelle,price,organization,fk_pays";
|
||||
$tabfieldinsert[15]= "code,label,width,height,unit";
|
||||
$tabfieldinsert[16]= "code,label,sortorder";
|
||||
$tabfieldinsert[17]= "code,libelle";
|
||||
$tabfieldinsert[17]= "code,label,accountancy_code";
|
||||
$tabfieldinsert[18]= "code,libelle,tracking";
|
||||
$tabfieldinsert[19]= "code,libelle";
|
||||
$tabfieldinsert[20]= "code,libelle";
|
||||
$tabfieldinsert[21]= "code,label";
|
||||
$tabfieldinsert[22]= "code,label";
|
||||
$tabfieldinsert[23]= "fk_pcg_version,account_number,account_parent,pcg_type,pcg_subtype,label";
|
||||
$tabfieldinsert[24]= "pcg_version,fk_pays,label";
|
||||
$tabfieldinsert[25]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldinsert[26]= "code,label";
|
||||
$tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldinsert[24]= "code,label";
|
||||
|
||||
// Nom du rowid si le champ n'est pas de type autoincrement
|
||||
// Example: "" if id field is "rowid" and has autoincrement on
|
||||
@ -302,9 +288,7 @@ $tabrowid[20]= "";
|
||||
$tabrowid[21]= "rowid";
|
||||
$tabrowid[22]= "rowid";
|
||||
$tabrowid[23]= "";
|
||||
$tabrowid[24]= "";
|
||||
$tabrowid[25]= "";
|
||||
$tabrowid[25]= "";
|
||||
$tabrowid[23]= "";
|
||||
|
||||
// Condition to show dictionary in setup page
|
||||
$tabcond=array();
|
||||
@ -330,10 +314,8 @@ $tabcond[19]= ! empty($conf->societe->enabled);
|
||||
$tabcond[20]= ! empty($conf->fournisseur->enabled);
|
||||
$tabcond[21]= ! empty($conf->propal->enabled);
|
||||
$tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled));
|
||||
$tabcond[23]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy plan should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
|
||||
$tabcond[24]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy system should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
|
||||
$tabcond[25]= true;
|
||||
$tabcond[26]= ! empty($conf->resource->enabled);
|
||||
$tabcond[23]= true;
|
||||
$tabcond[24]= ! empty($conf->resource->enabled);
|
||||
|
||||
// List of help for fields
|
||||
$tabhelp=array();
|
||||
@ -361,8 +343,6 @@ $tabhelp[21] = array();
|
||||
$tabhelp[22] = array();
|
||||
$tabhelp[23] = array();
|
||||
$tabhelp[24] = array();
|
||||
$tabhelp[25] = array();
|
||||
$tabhelp[26] = array();
|
||||
|
||||
// List of check for fields (NOT USED YET)
|
||||
$tabfieldcheck=array();
|
||||
@ -390,14 +370,12 @@ $tabfieldcheck[21] = array();
|
||||
$tabfieldcheck[22] = array();
|
||||
$tabfieldcheck[23] = array();
|
||||
$tabfieldcheck[24] = array();
|
||||
$tabfieldcheck[25] = array();
|
||||
$tabfieldcheck[26] = array();
|
||||
|
||||
// Complete all arrays with entries found into modules
|
||||
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);
|
||||
|
||||
|
||||
// Define elementList and sourceList (used for dictionary "type of contacts")
|
||||
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
|
||||
$elementList = array();
|
||||
$sourceList=array();
|
||||
if ($id == 11)
|
||||
@ -409,26 +387,32 @@ if ($id == 11)
|
||||
$langs->load("bills");
|
||||
$langs->load("interventions");
|
||||
$elementList = array(
|
||||
'commande' => $langs->trans('Order'),
|
||||
'proposal' => $langs->trans('Proposal'),
|
||||
'order' => $langs->trans('Order'),
|
||||
'invoice' => $langs->trans('Bill'),
|
||||
'invoice_supplier' => $langs->trans('SupplierBill'),
|
||||
'order_supplier' => $langs->trans('SupplierOrder'),
|
||||
'contrat' => $langs->trans('Contract'),
|
||||
'intervention' => $langs->trans('InterventionCard'),
|
||||
'contract' => $langs->trans('Contract'),
|
||||
'project' => $langs->trans('Project'),
|
||||
'project_task' => $langs->trans('Task'),
|
||||
'agenda' => $langs->trans('Agenda'),
|
||||
// old deprecated
|
||||
'contrat' => $langs->trans('Contract'),
|
||||
'propal' => $langs->trans('Proposal'),
|
||||
'commande' => $langs->trans('Order'),
|
||||
'facture' => $langs->trans('Bill'),
|
||||
'facture_fourn' => $langs->trans('SupplierBill'),
|
||||
'fichinter' => $langs->trans('InterventionCard'),
|
||||
'agenda' => $langs->trans('Agenda')
|
||||
'fichinter' => $langs->trans('InterventionCard')
|
||||
);
|
||||
if (! empty($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty');
|
||||
if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty');
|
||||
$sourceList = array(
|
||||
'internal' => $langs->trans('Internal'),
|
||||
'external' => $langs->trans('External')
|
||||
);
|
||||
}
|
||||
|
||||
// Define localtax_typeList (used for dictionary "c_tva")
|
||||
// Define localtax_typeList (used for dictionary "llx_c_tva")
|
||||
$localtax_typeList = array();
|
||||
if ($id == 10)
|
||||
{
|
||||
@ -441,7 +425,6 @@ if ($id == 10)
|
||||
"5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"),
|
||||
"6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"),
|
||||
);
|
||||
if (! empty($conf->global->MAIN_USE_LOCALTAX_TYPE_7)) $localtax_typeList["7"]= $langs->trans("Yes").' ('.$langs->trans("Type")." 7)"; //$langs->trans("AmountOnOrder") // We will enable this later. For the moment, work only of invoice localtype
|
||||
}
|
||||
|
||||
|
||||
@ -461,6 +444,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryRegion','DictionaryCompanyType'))) continue; // For some pages, country is not mandatory
|
||||
if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
|
||||
if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
|
||||
if ($value == 'color' && empty($_POST['color'])) continue;
|
||||
if ((! isset($_POST[$value]) || $_POST[$value]=='')
|
||||
&& (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy'))) // Fields that are not mandatory
|
||||
)
|
||||
@ -570,7 +554,8 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
$result = $db->query($sql);
|
||||
if ($result) // Add is ok
|
||||
{
|
||||
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
|
||||
setEventMessage($langs->transnoentities("RecordSaved"));
|
||||
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -791,7 +776,10 @@ if ($id)
|
||||
if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3";}
|
||||
if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
|
||||
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
|
||||
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
|
||||
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,''));
|
||||
else $valuetoshow=$langs->trans("Type");
|
||||
}
|
||||
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
|
||||
if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
|
||||
@ -818,7 +806,7 @@ if ($id)
|
||||
if ($valuetoshow != '')
|
||||
{
|
||||
print '<td align="'.$align.'">';
|
||||
if (! empty($tabhelp[$id][$value]) && preg_match('/http:/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.'</a>';
|
||||
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>';
|
||||
else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
|
||||
else print $valuetoshow;
|
||||
print '</td>';
|
||||
@ -1019,7 +1007,7 @@ if ($id)
|
||||
$valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
|
||||
$valuetoshow=nl2br($valuetoshow);
|
||||
}
|
||||
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_pays') {
|
||||
else if ($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]);
|
||||
}
|
||||
@ -1044,7 +1032,7 @@ if ($id)
|
||||
$key=$langs->trans(strtoupper($obj->code));
|
||||
$valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
|
||||
}
|
||||
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_civilite') {
|
||||
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') {
|
||||
$key=$langs->trans("Civility".strtoupper($obj->code));
|
||||
$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
|
||||
}
|
||||
@ -1082,7 +1070,7 @@ if ($id)
|
||||
$key = $langs->trans('PaperFormat'.strtoupper($obj->code));
|
||||
$valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]);
|
||||
}
|
||||
else if ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees')
|
||||
else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees')
|
||||
{
|
||||
$langs->load('trips');
|
||||
$key = $langs->trans(strtoupper($obj->code));
|
||||
@ -1139,27 +1127,29 @@ if ($id)
|
||||
}
|
||||
}
|
||||
|
||||
// Est-ce une entree du dictionnaire qui peut etre desactivee ?
|
||||
// True by default
|
||||
$iserasable=1;
|
||||
// Can an entry be erased or disabled ?
|
||||
$iserasable=1;$isdisable=1; // true by default
|
||||
|
||||
if (isset($obj->code))
|
||||
{
|
||||
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable = 0;
|
||||
else if ($obj->code == 'RECEP') $iserasable = 0;
|
||||
else if ($obj->code == 'EF0') $iserasable = 0;
|
||||
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $isdisable = 0; }
|
||||
else if ($obj->code == 'RECEP') { $iserasable = 0; $isdisable = 0; }
|
||||
else if ($obj->code == 'EF0') { $iserasable = 0; $isdisable = 0; }
|
||||
}
|
||||
|
||||
if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) $iserasable=0;
|
||||
if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; }
|
||||
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $isdisable=0; $isdisable = 0; }
|
||||
|
||||
$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)?$obj->code:'').'&id='.$id.'&';
|
||||
|
||||
// Active
|
||||
print '<td align="center" class="nowrap">';
|
||||
if ($iserasable) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
if ($isdisable) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
else
|
||||
{
|
||||
if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
|
||||
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
|
||||
else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
|
||||
else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
|
||||
else print $langs->trans("AlwaysActive");
|
||||
}
|
||||
print "</td>";
|
||||
@ -1276,7 +1266,7 @@ function fieldList($fieldlist,$obj='',$tabname='')
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if ($fieldlist[$field] == 'country') {
|
||||
if (in_array('region_id',$fieldlist)) { print '<td> </td>'; continue; } // For region page, we do not show the country input
|
||||
if (in_array('region_id',$fieldlist)) { print '<td>'.join(',',$fieldlist).' </td>'; continue; } // For state page, we do not show the country input (we link to region, not country)
|
||||
print '<td>';
|
||||
print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), 'country', '', 28);
|
||||
print '</td>';
|
||||
|
||||
@ -138,6 +138,35 @@ else if ($action == 'specimen')
|
||||
}
|
||||
}
|
||||
|
||||
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
|
||||
else if ($action == 'setModuleOptions')
|
||||
{
|
||||
$post_size=count($_POST);
|
||||
|
||||
$db->begin();
|
||||
|
||||
for($i=0;$i < $post_size;$i++)
|
||||
{
|
||||
if (array_key_exists('param'.$i,$_POST))
|
||||
{
|
||||
$param=GETPOST("param".$i,'alpha');
|
||||
$value=GETPOST("value".$i,'alpha');
|
||||
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
else if ($action == 'set')
|
||||
{
|
||||
@ -175,14 +204,6 @@ else if ($action == 'setmodel')
|
||||
{
|
||||
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
|
||||
}
|
||||
else if ($action=='setModuleOptions') {
|
||||
if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF_ODT_PATH",GETPOST('value1'),'chaine',0,'',$conf->entity))
|
||||
{
|
||||
// La constante qui a ete lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage coherent
|
||||
$conf->global->EXPEDITION_ADDON_PDF_ODT_PATH = GETPOST('value1');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user