Merge branch 'developupstream' into develop
This commit is contained in:
commit
7cd69c7ad9
@ -327,6 +327,9 @@ script:
|
||||
php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log
|
||||
php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log
|
||||
php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log
|
||||
php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log
|
||||
php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log
|
||||
php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log
|
||||
cd -
|
||||
set +e
|
||||
echo
|
||||
|
||||
348
ChangeLog
348
ChangeLog
@ -2,54 +2,269 @@
|
||||
English Dolibarr ChangeLog
|
||||
--------------------------------------------------------------
|
||||
|
||||
***** ChangeLog for 6.0.5 compared to 6.0.4 *****
|
||||
FIX: security vulnerability reported by ADLab of Venustech
|
||||
CVE-2017-17897, CVE-2017-17898, CVE-2017-17899, CVE-2017-17900
|
||||
FIX: #7379: Compatibility with PRODUCT_USE_OLD_PATH_FOR_PHOTO variable
|
||||
FIX: #7903
|
||||
FIX: #7933
|
||||
FIX: #8029 Unable to make leave request in holyday module
|
||||
FIX: Edit accountancy account and warning message on loan
|
||||
FIX: $accounts[$bid] is a label !
|
||||
FIX: $oldvatrateclean & $newvatrateclean must be set if preg_match === false
|
||||
FIX: product best price on product list
|
||||
FIX: search on contact list
|
||||
FIX: stats trad for customerinvoice
|
||||
FIX: translate unactivate on contractline
|
||||
|
||||
***** ChangeLog for 6.0.4 compared to 6.0.3 *****
|
||||
FIX: #7737
|
||||
FIX: #7751
|
||||
FIX: #7756 Add better error message
|
||||
FIX: #7786
|
||||
FIX: #7806
|
||||
FIX: #7824
|
||||
FIX: add line bad price and ref
|
||||
FIX: A lot of several fix on local taxes and NPR tax
|
||||
FIX: createfromorder
|
||||
FIX: CSS for IE10
|
||||
FIX: external user cannot be set as internal
|
||||
FIX: Filter type on actioncomm with multiselect doesn't work
|
||||
FIX: list of donation not filtered on multicompany
|
||||
FIX: list of module not complete when module mb_strlen not available
|
||||
FIX: Locatax were not propagated when cloning order or proposal
|
||||
FIX: Searching translation should not be case sensitive
|
||||
FIX: Search into language is ok for file into external modules two.
|
||||
FIX: test for filter fk_status
|
||||
FIX: too much users on holiday list
|
||||
FIX: Wrong alias sql
|
||||
***** ChangeLog for 8.0.0 compared to 7.0.0 *****
|
||||
|
||||
WARNING:
|
||||
|
||||
***** ChangeLog for 7.0.0 compared to 6.0.* *****
|
||||
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
|
||||
* Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from
|
||||
'doaction' into 'sendMail'.
|
||||
|
||||
|
||||
***** ChangeLog for 7.0.0 compared to 6.0.5 *****
|
||||
For users:
|
||||
NEW: Add a preview icon after files that can be previewed (pdf + images)
|
||||
NEW: When payment is registered, PDF of invoices are also regenerated so payments
|
||||
appears with no need to click on regenerate.
|
||||
NEW: #5711 Add shipment line deleting and editing for draft shipments.
|
||||
NEW: Accept substitution key __(ABC)__ replaced with value of translation of key ABC
|
||||
NEW: Accept substitution key __[ABC]__ replaced with value of const ABC
|
||||
NEW: Accountancy Add fields for sale accounting account for intracommunity sales & export sales
|
||||
NEW: Add a button "Activate all services" on contracts
|
||||
NEW: Add a confirmation for all mass action 'delete'
|
||||
NEW: Add a group task line for tasks on same level on gantt diagram
|
||||
NEW: Add and edit country for chart of accounts systems
|
||||
NEW: add a new notification for the signed closed event of a proposal.
|
||||
NEW: Add a parameter to specify char used as separator for variant product label
|
||||
NEW: Add a profile to import product translations
|
||||
NEW: Add a protection so we can't journalize non balanced transactions
|
||||
NEW: Add a status enabled/disabled on recurring invoices
|
||||
NEW: add burger menu to list action comm
|
||||
NEW: Add button cancel on shipment creation
|
||||
NEW: Add chart of account for england
|
||||
NEW: Add Chile accounting plan
|
||||
NEW: Add class in societe/card.php
|
||||
NEW: add company alias name when create company from member
|
||||
NEW: Add date of birth on user card.
|
||||
NEW: Add date_valid and date_pointoftax on supplier invoices.
|
||||
NEW: Added Region name to state/province form field
|
||||
NEW: Added regions to third party/societe lists, can be filtered
|
||||
NEW: Add error message
|
||||
NEW: Add expense report rules and ik
|
||||
NEW: Add filter on event code on automatic filling setup page
|
||||
NEW: Add filters on month/year on the accountancy binding tools
|
||||
NEW: add fk_unit field into product/service import/export
|
||||
NEW: add 'formObjectOptions' hook to the form setting the product selling price
|
||||
NEW: Add hidden option PROJECT_DISABLE_UNLINK_FROM_OVERVIEW
|
||||
NEW: add image object_phoning_mobile.png
|
||||
NEW: Adding Field "First date of expire" + filter on contract list
|
||||
NEW: add ldap_rename for avoid password if ldap key changed
|
||||
NEW: Add mass action "validate" on supplier invoices.
|
||||
NEW: add members types ldap group management
|
||||
NEW: Add new property visible dy default on lists on extrafields
|
||||
NEW: Add Next/Previous button on operation date of bank line
|
||||
NEW: Add option EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS
|
||||
NEW: Add option PROPOSAL/ORDER/INVOICE_ALLOW_EXTERNAL_DOWNLOAD
|
||||
NEW: Add product unit fields for ODT substitution
|
||||
NEW: Add project on a various payment
|
||||
NEW: Add project related fields to ODT
|
||||
NEW: Add protection to avoid to send to much emails using builk actions
|
||||
NEW: Add search field for date on supplier payment page
|
||||
NEW: Add search on date and accounting account in various payment list
|
||||
NEW: add specific translation for title of documents (Invoice, Order, Proposal)
|
||||
NEW: Adds the payment reference to the return of the function getListOfPayements
|
||||
NEW: Add supplier proposals into stats of product page.
|
||||
NEW: Add tab "Expense report" on user card
|
||||
NEW: add the ability to regenerate a pdf for the order module
|
||||
NEW: Add The accountancy Switzerland chart of accounts
|
||||
NEW: Add The developed French chart of accounts 2014
|
||||
NEW: Add The Luxembourg chart of accounts
|
||||
NEW: Add The Moroccan chart of accounts
|
||||
NEW: Add The Switzerland chart of accounts
|
||||
NEW: Add The SYSCOHADA chart of accounts
|
||||
NEW: Add the total in the perday view of the time spent form.
|
||||
NEW: Add The Tunisia chart of accounts
|
||||
NEW: Add toolkit for StockLimit and DesiredStock
|
||||
NEW: add translation and possibility to change month and year
|
||||
NEW: Add view of status of template invoice
|
||||
NEW: All search boxes are available on smartphone
|
||||
NEW: All setup of accountancy can be done from menu "Accountancy-Setup"
|
||||
NEW: Attaching doc automatically in email is now a parameter of template.
|
||||
NEW: automatic activation of external module on country set
|
||||
NEW: Better autoselect customer or supplier fields to save clicks
|
||||
NEW: Better behaviour when using a text browser
|
||||
NEW: Break lines per project on the new timesheet page
|
||||
NEW: Bulk action validate on customer invoices
|
||||
NEW: Bulk delete actions available on leave requests
|
||||
NEW: burger menu and hooks on list action
|
||||
NEW: Can add html content on right of tabs
|
||||
NEW: Can add link to other element on a donation
|
||||
NEW: Can create intervention from a proposal
|
||||
NEW: Can create thirdparty from card proposal, order or invoice
|
||||
NEW: Can download PDF document from the payment page
|
||||
NEW: Can edit the language into the email templates editor.
|
||||
NEW: Can edit with delete/insert a forced translation
|
||||
NEW: Can export list of stock movements
|
||||
NEW: Can filter on date on the page showing existing bindings
|
||||
NEW: Can filter on document name in ECM module for automatic tree
|
||||
NEW: can filter on status of template invoices
|
||||
NEW: Can filter on the "other" column on emailing target list
|
||||
NEW: Can filter on type of email template
|
||||
NEW: Can filter on user on unalterable log
|
||||
NEW: Can import local tax rates in prices
|
||||
NEW: Can include extrafields into member card templates
|
||||
NEW: Can include tag {uuu} into some numbering masks to replace with user
|
||||
NEW: Can make a specific setup for SMTP sending for emailing module
|
||||
NEW: Can rename (so reorder) bank receipts
|
||||
NEW: Can send email from contract card
|
||||
NEW: Can send email from the member card using email templates.
|
||||
NEW: Can set a dedicated message on payment forms
|
||||
NEW: Can set email of thirdparty as unique and/or mandatory
|
||||
NEW: Can setup csv accounting export from admin config
|
||||
NEW: Can show currency in list of bank accounts
|
||||
NEW: Can show stock in alert even if alter is set to 0
|
||||
NEW: Can sort joined files on thirdparty and user card.
|
||||
NEW: Can transfer from bank account to bank account with different currencies
|
||||
NEW: Can use an url like $conf->global>-MYPARAM for menu urls
|
||||
NEW: change description on click
|
||||
NEW: Chart of account is loaded when selected into accounting setup
|
||||
NEW: Classify the order as invoiced in the REST API
|
||||
NEW: comments system on task
|
||||
NEW: comment system working with all objects
|
||||
NEW: Compatibility with PHP 7.2
|
||||
NEW: confirm form style to accept or reject proposal
|
||||
NEW: Create an invoice using an existing order
|
||||
NEW: Create an order using an existing proposal
|
||||
NEW: customizable meteo in value or percentage
|
||||
NEW: Days where user is on vacation use different colors in timesheet.
|
||||
NEW: Deduct an available credit to an existing invoice
|
||||
NEW: Default filter and sort order can use partial list of query
|
||||
NEW: Deposit invoice more explicit in invoice line description
|
||||
NEW: deposits can be converted even if unpaid
|
||||
NEW: detection of edge browser
|
||||
NEW: Each user can edit its own email template (menu tools)
|
||||
NEW: Enabled sending email in bulk actions for supplier orders
|
||||
NEW: Enhance the anti XSS filter
|
||||
NEW: extrafield on facture_rec
|
||||
NEW: Extrafields "link to object" now use a combo selection and getNomUrl
|
||||
NEW: filter date for blockedlog
|
||||
NEW: filter on extrafield on product list (as in company list)
|
||||
NEW: General ledger : Add field date_creation and selected field
|
||||
NEW: generate also document when invoice is build from recurring template
|
||||
NEW: Generated files are now indexed in database
|
||||
NEW: generate invoice PDF on disount application or payment
|
||||
NEW: Get a list of payments terms
|
||||
NEW: hrm details output on user
|
||||
NEW: If max nb of generation is reached, date for next gen is striked
|
||||
NEW: improvements of invoices, orders and proposals in the REST API
|
||||
NEW: Include a color syntaxed HTML editor for emailing edition.
|
||||
NEW: Introduce code syntax coloration with mode 'ace' for DolEditor.
|
||||
NEW: Introduce experimental feature to search dolistore from application
|
||||
NEW: jquery date selector become default date selector
|
||||
NEW: langs
|
||||
NEW: link project from other company conf
|
||||
NEW: manageme extrafields with multientity
|
||||
NEW: Mass PDF Merging is available on contracts
|
||||
NEW: merge categories while merging thirdparties
|
||||
NEW: Merge resource/add.php to resource/card.php
|
||||
NEW: Module "Product variants" is moved as stable.
|
||||
NEW: More picto for phone
|
||||
NEW: Move accountancy features into a dedicated menu
|
||||
NEW: Move contacts of a thirdparty on tab Contacts/Addresses
|
||||
NEW: Move the upload input on top right in ECM module
|
||||
NEW: new columns into extrafields table to get update create information
|
||||
NEW: new param on load_board() function in ActionComm class to avoid duplicate code
|
||||
NEW: On bulk email from a list, can uncheck "Join main document".
|
||||
NEW: On reconciliation, show balance including all reconciliated fields
|
||||
NEW: Option "one email per recipient" when using bulk actions emails.
|
||||
NEW: Option STOCK_SUPPORTS_SERVICES become visible.
|
||||
NEW: option to avoid countries to disable there blockedlog
|
||||
NEW: option to fix top menu with eldy theme (hidden conf)
|
||||
NEW: Popup for preview of image add a button "Original size"
|
||||
NEW: post lines of an invoice using the REST API
|
||||
NEW: preload comments in task
|
||||
NEW: Provide a way to download a file from a public URL for files in ECM
|
||||
NEW: Reduce size of HTML page by removing duplicate tooltips
|
||||
NEW: Remove background on agenda view when event is a not busy event.
|
||||
NEW: Retrieves available discounts and payments details from a specific invoice
|
||||
NEW: Revenue stamp can be a percent
|
||||
NEW: Search filters in lists are restored when using "back to list"
|
||||
NEW: Send by email available in bulk for expense report
|
||||
NEW: Set a proposal to draft
|
||||
NEW: Show badge with nbr of shipment on shimpen tab of order
|
||||
NEW: Show country and vat number into company tooltip
|
||||
NEW: Show direct preview link on contract
|
||||
NEW: Show expected worked hours on the timesheet form.
|
||||
NEW: Show line "other filtered task" when using filter on timesheet.
|
||||
NEW: Show list of tracked events into the module config page.
|
||||
NEW: Show the supplier ref into supplier cards
|
||||
NEW: Show user id of web process in system info - web server
|
||||
NEW: Summary of last events on a card are sorted on decreasing date.
|
||||
NEW: Support Italian addresses format. Fixes #7785
|
||||
NEW: Support visibility on extrafields
|
||||
NEW: Template invoices are visible on the customer tab
|
||||
NEW: template invoices support substition key
|
||||
NEW: The bank account is visible on payment of taxes
|
||||
NEW: The comment when closing a proposal is added to commercial proposal
|
||||
NEW: The gantt diagram is now sensitive to hours
|
||||
NEW: The lot of a product uses the link and picto when shown into list.
|
||||
NEW: The "Show detail by account" accepts 3 values: yes, no, if non zero
|
||||
NEW: The unalterable log can be browse by any user with he permission
|
||||
NEW: Tooltip for substitutions variables on tooltips on admin pages
|
||||
NEW: unexistant function load_state_board() on several objects
|
||||
NEW: Update availability
|
||||
NEW: Update bank account when updating an invoice
|
||||
NEW: Update bank account when updating an order
|
||||
NEW: Use autocompletion on selection of chart of account
|
||||
NEW: view company name if different of fullname in dol_banner
|
||||
NEW: warning on module blocked log reset if country code is FR
|
||||
|
||||
For developers:
|
||||
NEW: Add 2 new automatic classification in workflow module
|
||||
NEW: Add API for contracts
|
||||
NEW: Add API to activate/unactivate a contract
|
||||
NEW: Add api validate and close on contracts
|
||||
NEW: add doActions hook in admin ihm
|
||||
NEW: add doActions hook in company admin
|
||||
NEW: Added functionality to get order customer contact as contact_xx tags
|
||||
NEW: Add hook addAdminLdapOptions and doAction in ldap admin page
|
||||
NEW: Add method executeCLI and a phpunit
|
||||
NEW: add '$moreatt' parameter in picto_from_langcode function
|
||||
NEW: Add non intrusive js library to make syntaxic coloring of textarea
|
||||
NEW: Add payment line to a specific invoice using the REST API
|
||||
NEW: add possibility to disabled the LDAP trigger
|
||||
NEW: add possibility to hide LDAP tab for non admin
|
||||
NEW: Add possibility to propose last num releve in conciliation
|
||||
NEW: add possibility to remove address field
|
||||
NEW: Add REST API for supplier proposals
|
||||
NEW: Add REST API to add payment line to a specific invoice
|
||||
NEW: Add the attribute accept to the input form for file upload
|
||||
NEW: add translation column for extrafields list
|
||||
NEW: Add performances indexes on calendar events
|
||||
NEW: A module can change order of element in the quick search combo
|
||||
NEW: Can test signature of a version from API
|
||||
NEW: complete_head_from_modules() in ldap_prepare_head()
|
||||
NEW: Consolidates REST dictionary APIs into a single tree and a single file
|
||||
NEW: Delete a line of invoice using the REST API
|
||||
NEW: documents REST API return list of documents by element
|
||||
NEW: Download a document using the REST API
|
||||
NEW: Enhance framework so we can use html/icons into SELECT options.
|
||||
NEW: External module can interact with the customer summary page
|
||||
NEW: Generates the document before downloading using REST API
|
||||
NEW: get and post lines of an invoice using the REST API
|
||||
NEW: Get a payment list of a given invoice using the REST API
|
||||
NEW: Get available assets of an invoice using the REST API
|
||||
NEW: Get credit notes or deposits of a thirdparty
|
||||
NEW: GET lines of an invoice in the REST API
|
||||
NEW: get payment types using the REST API + consolidates REST dictionary APIs
|
||||
NEW: Get the list of payments terms.
|
||||
NEW: hook formObjectOptions in the form setting product selling price
|
||||
NEW: hook to enrich homepage open elements dashboard
|
||||
NEW: Insert a discount in a specific invoice using the REST API
|
||||
NEW: Remove js library fileupload that was not used by core code.
|
||||
NEW: Remove tooltip tipTip library replaced with standatd jquery tooltip
|
||||
NEW: Set invoices as draft using the REST API
|
||||
NEW: Sets an invoice as paid using the REST API
|
||||
NEW: Tag the order as validated (opened) in the REST API
|
||||
NEW: Update end of validity date of proposal using the API
|
||||
NEW: Update in the order REST API
|
||||
NEW: Upgrade jquery select2 to 4.0.4
|
||||
|
||||
WARNING:
|
||||
|
||||
If you enabled (for test) the experimental BlockedLog module before 7.0, you must purge the table llx_blockedlog because
|
||||
WARNING:
|
||||
|
||||
If you enabled (for test) the experimental BlockedLog module before 7.0, you must purge the table llx_blockedlog because
|
||||
way to save data for final version has changed.
|
||||
|
||||
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
|
||||
@ -74,6 +289,59 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* Jquery plugin tableDnd updated. You now need to use decodeURI on the return value of tableDnDSerialize()
|
||||
and add 'td.' to the beginning of the dragHandle match string.
|
||||
* IE8 and earlier and Firefox 12 and earlier (< 2012) are no more supported.
|
||||
* The module ExpenseReport use numbering rules that you can setup (like other modules do). If you need to
|
||||
keep the hard coded numbering rule of expenses report used in 6.0, just add constant
|
||||
EXPENSEREPORT_USE_OLD_NUMBERING_RULE to 1.
|
||||
* If you use the external module "multicompany", you must also upgrade the module. Multicompany module for
|
||||
Dolibarr v7 is required because with Dolibarr v7, payment modes and payment conditions are management as data
|
||||
that are dedicated to each company. If you keep your old version of multicompany module, mode and
|
||||
condition of payments will appears empty in all companies that are not the first one. By upgrading the
|
||||
multicompany module to a version that support Dolibarr v7, everything should work as expected.
|
||||
|
||||
|
||||
***** ChangeLog for 6.0.5 compared to 6.0.4 *****
|
||||
FIX: security vulnerability reported by ADLab of Venustech
|
||||
CVE-2017-17897, CVE-2017-17898, CVE-2017-17899, CVE-2017-17900
|
||||
FIX: #7379: Compatibility with PRODUCT_USE_OLD_PATH_FOR_PHOTO variable
|
||||
FIX: #7903
|
||||
FIX: #7933
|
||||
FIX: #8029 Unable to make leave request in holyday module
|
||||
FIX: #8093
|
||||
FIX: Bad name alias showing in name of third column
|
||||
FIX: Cashdesk should not sell to inactive third parties
|
||||
FIX: Edit accountancy account and warning message on loan
|
||||
FIX: $accounts[$bid] is a label !
|
||||
FIX: $oldvatrateclean & $newvatrateclean must be set if preg_match === false
|
||||
FIX: product best price on product list
|
||||
FIX: search on contact list
|
||||
FIX: stats trad for customerinvoice
|
||||
FIX: translate unactivate on contractline
|
||||
FIX: email sent was not in HTML
|
||||
FIX: missing hook invoice index
|
||||
FIX: subject mail sepa
|
||||
|
||||
|
||||
***** ChangeLog for 6.0.4 compared to 6.0.3 *****
|
||||
FIX: #7737
|
||||
FIX: #7751
|
||||
FIX: #7756 Add better error message
|
||||
FIX: #7786
|
||||
FIX: #7806
|
||||
FIX: #7824
|
||||
FIX: add line bad price and ref
|
||||
FIX: A lot of several fix on local taxes and NPR tax
|
||||
FIX: createfromorder
|
||||
FIX: CSS for IE10
|
||||
FIX: external user cannot be set as internal
|
||||
FIX: Filter type on actioncomm with multiselect doesn't work
|
||||
FIX: list of donation not filtered on multicompany
|
||||
FIX: list of module not complete when module mb_strlen not available
|
||||
FIX: Locatax were not propagated when cloning order or proposal
|
||||
FIX: Searching translation should not be case sensitive
|
||||
FIX: Search into language is ok for file into external modules two.
|
||||
FIX: test for filter fk_status
|
||||
FIX: too much users on holiday list
|
||||
FIX: Wrong alias sql
|
||||
|
||||
|
||||
***** ChangeLog for 6.0.3 compared to 6.0.2 *****
|
||||
@ -317,7 +585,9 @@ Following changes may create regression for some external modules, but were nece
|
||||
exists, but if an external module need action on it, it must provides itself its trigger file.
|
||||
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode. So, if you set var
|
||||
$multicompany_transverse_mode to 1 into your conf file, you must remove this line and a new key into
|
||||
the Home - setup - other admin page.
|
||||
the Home - setup - other admin page.
|
||||
* If you use Multicompany transverse mode, it will be necessary to check the activation of the modules in the children
|
||||
entities and to review completely the rights of the groups and the users.
|
||||
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
|
||||
* Some other change were done in the way we read permission of a user when module multicompany is enabled. You can
|
||||
retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1.
|
||||
|
||||
@ -19,7 +19,7 @@ use Term::ANSIColor;
|
||||
# Change this to defined target for option 98 and 99
|
||||
$PROJECT="dolibarr";
|
||||
$PUBLISHSTABLE="eldy,dolibarr\@frs.sourceforge.net:/home/frs/project/dolibarr";
|
||||
$PUBLISHBETARC="ldestailleur\@vmprod.dolibarr.org:/home/dolibarr/dolibarr.org/httpdocs/files";
|
||||
$PUBLISHBETARC="dolibarr\@vmprod1.dolibarr.org:/home/dolibarr/dolibarr.org/httpdocs/files";
|
||||
|
||||
|
||||
#@LISTETARGET=("TGZ","ZIP","RPM_GENERIC","RPM_FEDORA","RPM_MANDRIVA","RPM_OPENSUSE","DEB","APS","EXEDOLIWAMP","SNAPSHOT"); # Possible packages
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
"agenda"
|
||||
],
|
||||
"homepage": "https://www.dolibarr.org",
|
||||
"license": "GPL-3.0+",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"support": {
|
||||
"issues": "https://github.com/Dolibarr/dolibarr/issues",
|
||||
"forum": "https://www.dolibarr.org/forum",
|
||||
|
||||
@ -136,17 +136,25 @@ if ($action == 'update') {
|
||||
$accounting = new AccountingAccount($db);
|
||||
|
||||
//$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
|
||||
$arrayofdifferentselectedvalues = array();
|
||||
|
||||
$cpt = 0; $ok = 0; $ko = 0;
|
||||
foreach ( $chk_prod as $productid ) {
|
||||
|
||||
foreach ( $chk_prod as $productid )
|
||||
{
|
||||
$accounting_account_id = GETPOST('codeventil_' . $productid);
|
||||
|
||||
$result = $accounting->fetch($accounting_account_id, null, 1);
|
||||
if ($result < 0) {
|
||||
$result = 0;
|
||||
if ($accounting_account_id > 0)
|
||||
{
|
||||
$arrayofdifferentselectedvalues[$accounting_account_id]=$accounting_account_id;
|
||||
$result = $accounting->fetch($accounting_account_id, null, 1);
|
||||
}
|
||||
if ($result <= 0) {
|
||||
// setEventMessages(null, $accounting->errors, 'errors');
|
||||
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
$ko++;
|
||||
} else {
|
||||
$db->begin();
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
@ -158,23 +166,23 @@ if ($action == 'update') {
|
||||
$sql .= " WHERE rowid = " . $productid;
|
||||
|
||||
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
if ($db->query($sql))
|
||||
{
|
||||
$ok++;
|
||||
//$msg .= '<div><font color="green">' . $langs->trans("Product") . ' ' . $productid . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '</font></div>';
|
||||
$db->commit();
|
||||
} else {
|
||||
$ko++;
|
||||
//$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
$cpt ++;
|
||||
$cpt++;
|
||||
}
|
||||
} else {
|
||||
//$msg .= '<div><span class="accountingprocessing">' . $langs->trans("AnyLineVentilate") . '</span></div>';
|
||||
|
||||
}
|
||||
|
||||
if ($ko) setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
|
||||
if ($ok) setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
|
||||
//$msg .= '<div><span class="accountingprocessing">' . $langs->trans("EndProcessing") . '</span></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -615,8 +615,8 @@ if ($action == 'create')
|
||||
print '<input type="text" name="subledger_account" value="'.$line->subledger_account.'">';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
|
||||
print '<td><input type="text" class="minwidth100" name="label_compte" value="' . $line->label_compte . '"/></td>';
|
||||
print '<td><input type="text" class="minwidth300" name="label_operation" value="' . $line->label_operation. '"/></td>';
|
||||
print '<td align="right"><input type="text" size="6" class="right" name="debit" value="' . price($line->debit) . '"/></td>';
|
||||
print '<td align="right"><input type="text" size="6" class="right" name="credit" value="' . price($line->credit) . '"/></td>';
|
||||
print '<td>';
|
||||
@ -636,8 +636,8 @@ if ($action == 'create')
|
||||
print img_edit();
|
||||
print '</a> ';
|
||||
|
||||
$actiontodelete='detele';
|
||||
if ($mode == '_tmp') $actiontodelete='confirm_delete';
|
||||
$actiontodelete='delete';
|
||||
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete='confirm_delete';
|
||||
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?action='.$actiontodelete.'&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
|
||||
print img_delete();
|
||||
@ -673,8 +673,8 @@ if ($action == 'create')
|
||||
print '<input type="text" name="subledger_account" value="">';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
|
||||
print '<td><input type="text" class="minwidth100" name="label_compte" value="' . $line->label_compte . '"/></td>';
|
||||
print '<td><input type="text" class="minwidth300" name="label_operation" value="' . $line->label_operation. '"/></td>';
|
||||
print '<td align="right"><input type="text" size="6" class="right" name="debit" value="' . ($debit ? price($debit) : '') . '"/></td>';
|
||||
print '<td align="right"><input type="text" size="6" class="right" name="credit" value="' . ($credit ? price($credit) : '') . '"/></td>';
|
||||
print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>';
|
||||
|
||||
@ -87,7 +87,7 @@ $offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if ($sortorder == "") $sortorder = "ASC";
|
||||
if ($sortfield == "") $sortfield = "t.rowid";
|
||||
if ($sortfield == "") $sortfield = "t.piece_num,t.rowid";
|
||||
|
||||
|
||||
$object = new BookKeeping($db);
|
||||
@ -98,25 +98,30 @@ $form = new Form($db);
|
||||
|
||||
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int'))
|
||||
{
|
||||
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
|
||||
$query.= " where date_start < '".$this->idate(dol_now())."' and date_end > '".$this->idate(dol_now())."' limit 1";
|
||||
$res = $db->query($query);
|
||||
if ($res->num_rows > 0) {
|
||||
$fiscalYear = $db->fetch_object($res);
|
||||
$search_date_start = strtotime($fiscalYear->date_start);
|
||||
$search_date_end = strtotime($fiscalYear->date_end);
|
||||
} else {
|
||||
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
|
||||
$year_start = dol_print_date(dol_now(), '%Y');
|
||||
$year_end = $year_start + 1;
|
||||
$month_end = $month_start - 1;
|
||||
if ($month_end < 1)
|
||||
{
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
if (empty($search_date_start) && empty($search_date_end))
|
||||
{
|
||||
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
|
||||
$query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
|
||||
$res = $db->query($query);
|
||||
|
||||
if ($res->num_rows > 0) {
|
||||
$fiscalYear = $db->fetch_object($res);
|
||||
$search_date_start = strtotime($fiscalYear->date_start);
|
||||
$search_date_end = strtotime($fiscalYear->date_end);
|
||||
} else {
|
||||
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
|
||||
$year_start = dol_print_date(dol_now(), '%Y');
|
||||
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
|
||||
$year_end = $year_start + 1;
|
||||
$month_end = $month_start - 1;
|
||||
if ($month_end < 1)
|
||||
{
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
}
|
||||
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
|
||||
$search_date_end = dol_get_last_day($year_end, $month_end);
|
||||
}
|
||||
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
|
||||
$search_date_end = dol_get_last_day($year_end, $month_end);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +129,7 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !
|
||||
$arrayfields=array(
|
||||
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
|
||||
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
|
||||
't.doc_ref'=>array('label'=>$langs->trans("Docref"), 'checked'=>1),
|
||||
't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
|
||||
't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1),
|
||||
't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
|
||||
't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
|
||||
@ -430,7 +435,7 @@ else $button.= $langs->trans("ExportList");
|
||||
$button.= '</a>';
|
||||
|
||||
|
||||
$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">' . $langs->trans("GroupByAccountAccounting") . '</a>';
|
||||
$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param.'">' . $langs->trans("GroupByAccountAccounting") . '</a>';
|
||||
$addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
|
||||
|
||||
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$addbutton, '', $limit);
|
||||
@ -576,17 +581,17 @@ print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre("Docref", $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre("SubledgerAccount", $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre("DateCreation", $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
@ -677,21 +682,21 @@ if ($num > 0)
|
||||
// Creation operation date
|
||||
if (! empty($arrayfields['t.date_creation']['checked']))
|
||||
{
|
||||
print '<td align="center">' . dol_print_date($line->date_creation, 'day') . '</td>';
|
||||
print '<td align="center">' . dol_print_date($line->date_creation, 'dayhour') . '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Modification operation date
|
||||
if (! empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
print '<td align="center">' . dol_print_date($line->date_modification, 'day') . '</td>';
|
||||
print '<td align="center">' . dol_print_date($line->date_modification, 'dayhour') . '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Action column
|
||||
print '<td align="center">';
|
||||
print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a> ';
|
||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a> ';
|
||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>';
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
@ -704,6 +709,7 @@ if ($num > 0)
|
||||
if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield']))
|
||||
{
|
||||
$i=0;
|
||||
print '<tr class="liste_total">';
|
||||
while ($i < $totalarray['nbfield'])
|
||||
{
|
||||
$i++;
|
||||
@ -724,7 +730,7 @@ if ($num > 0)
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
|
||||
// TODO Replace this with mass action
|
||||
// TODO Replace this with mass delete action
|
||||
print '<div class="tabsAction tabsActionNoBottom">' . "\n";
|
||||
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DelBookKeeping") . '</a>';
|
||||
print '</div>';
|
||||
|
||||
@ -68,7 +68,7 @@ $pagenext = $page + 1;
|
||||
if ($sortorder == "") $sortorder = "ASC";
|
||||
if ($sortfield == "") $sortfield = "t.rowid";
|
||||
|
||||
if (empty($search_date_start)) {
|
||||
if (empty($search_date_start) && empty($search_date_end)) {
|
||||
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
|
||||
$sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
|
||||
$sql.= $db->plimit(1);
|
||||
@ -81,6 +81,7 @@ if (empty($search_date_start)) {
|
||||
} else {
|
||||
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
|
||||
$year_start = dol_print_date(dol_now(), '%Y');
|
||||
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
|
||||
$year_end = $year_start + 1;
|
||||
$month_end = $month_start - 1;
|
||||
if ($month_end < 1)
|
||||
@ -225,14 +226,13 @@ if ($action == 'delbookkeepingyear') {
|
||||
}
|
||||
|
||||
|
||||
|
||||
$param=$options;
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
|
||||
$viewflat = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">' . $langs->trans("ViewFlatList") . '</a>';
|
||||
$viewflat = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param.'">' . $langs->trans("ViewFlatList") . '</a>';
|
||||
$addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
|
||||
|
||||
$param=$options;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||
|
||||
|
||||
@ -172,10 +172,10 @@ print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
|
||||
$sql .= " bk.thirdparty_code, bk.numero_compte , bk.label_compte, bk.debit, ";
|
||||
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
|
||||
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
$sql .= " WHERE (bk.thirdparty_code = '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )";
|
||||
$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )";
|
||||
|
||||
if (dol_strlen($search_year)) {
|
||||
$date_start = dol_mktime(0, 0, 0, 1, 1, $search_year);
|
||||
|
||||
@ -188,10 +188,10 @@ print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
|
||||
$sql .= " bk.thirdparty_code, bk.numero_compte , bk.label_compte, bk.debit, ";
|
||||
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
|
||||
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
$sql .= " WHERE (bk.thirdparty_code = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )";
|
||||
$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )";
|
||||
|
||||
if (dol_strlen($search_year)) {
|
||||
$date_start = dol_mktime(0, 0, 0, 1, 1, $search_year);
|
||||
|
||||
@ -82,7 +82,7 @@ class AccountingAccount extends CommonObject
|
||||
* @param int $rowid Id
|
||||
* @param string $account_number Account number
|
||||
* @param int $limittocurrentchart 1=Do not load record if it is into another accounting system
|
||||
* @return int <0 if KO, Id of record if OK and found
|
||||
* @return int <0 if KO, 0 if not found, Id of record if OK and found
|
||||
*/
|
||||
function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) {
|
||||
global $conf;
|
||||
@ -135,7 +135,7 @@ class AccountingAccount extends CommonObject
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
return - 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -59,6 +59,8 @@ class AccountingJournal extends CommonObject
|
||||
*/
|
||||
function fetch($rowid = null, $journal_code = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($rowid || $journal_code)
|
||||
{
|
||||
$sql = "SELECT rowid, code, label, nature, active";
|
||||
@ -66,8 +68,11 @@ class AccountingJournal extends CommonObject
|
||||
$sql .= " WHERE";
|
||||
if ($rowid) {
|
||||
$sql .= " rowid = " . (int) $rowid;
|
||||
} elseif ($journal_code) {
|
||||
}
|
||||
elseif ($journal_code)
|
||||
{
|
||||
$sql .= " code = '" . $this->db->escape($journal_code) . "'";
|
||||
$sql .= " AND entity = " . $conf->entity;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
|
||||
|
||||
@ -781,7 +781,8 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " t.code_journal,";
|
||||
$sql .= " t.journal_label,";
|
||||
$sql .= " t.piece_num,";
|
||||
$sql .= " t.date_creation";
|
||||
$sql .= " t.date_creation,";
|
||||
$sql .= " t.tms as date_modification";
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
// Manage filter
|
||||
$sqlwhere = array ();
|
||||
@ -849,7 +850,8 @@ class BookKeeping extends CommonObject
|
||||
$line->code_journal = $obj->code_journal;
|
||||
$line->journal_label = $obj->journal_label;
|
||||
$line->piece_num = $obj->piece_num;
|
||||
$line->date_creation = $obj->date_creation;
|
||||
$line->date_creation = $this->db->jdate($obj->date_creation);
|
||||
$line->date_modification = $this->db->jdate($obj->date_modification);
|
||||
|
||||
$this->lines[] = $line;
|
||||
}
|
||||
|
||||
@ -39,6 +39,8 @@ class lettering extends BookKeeping
|
||||
*/
|
||||
public function lettrageTiers($socid)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$object = new Societe($this->db);
|
||||
@ -56,18 +58,18 @@ class lettering extends BookKeeping
|
||||
/**
|
||||
* Prise en charge des lettering complexe avec prelevment , virement
|
||||
*/
|
||||
$sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.thirdparty_code, ";
|
||||
$sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, ";
|
||||
$sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant ";
|
||||
$sql .= " , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
|
||||
$sql .= " WHERE ( ";
|
||||
if (! empty($object->code_compta))
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
|
||||
if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur))
|
||||
$sql .= " OR ";
|
||||
if (! empty($object->code_compta_fournisseur))
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
|
||||
|
||||
$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
|
||||
$sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) ";
|
||||
@ -91,16 +93,17 @@ class lettering extends BookKeeping
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='" . $obj->code_journal . "')";
|
||||
$sql .= " WHERE payfacf.fk_paiementfourn = '" . $obj->url_id . "' ";
|
||||
$sql .= " AND code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4) ";
|
||||
$sql .= " AND facf.entity = ".$conf->entity;
|
||||
$sql .= " AND code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
|
||||
$sql .= " AND ( ";
|
||||
if (! empty($object->code_compta)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
|
||||
}
|
||||
if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " OR ";
|
||||
}
|
||||
if (! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
|
||||
}
|
||||
$sql .= " ) ";
|
||||
|
||||
@ -118,16 +121,17 @@ class lettering extends BookKeeping
|
||||
$sql = 'SELECT bk.rowid, facf.ref, facf.ref_supplier ';
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = facf.rowid AND facf.rowid IN (" . implode(',', $ids_fact) . "))";
|
||||
$sql .= " WHERE bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=3) ";
|
||||
$sql .= " WHERE bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=3 AND entity=".$conf->entity.") ";
|
||||
$sql .= " AND facf.entity = ".$conf->entity;
|
||||
$sql .= " AND ( ";
|
||||
if (! empty($object->code_compta)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
|
||||
}
|
||||
if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " OR ";
|
||||
}
|
||||
if (! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
|
||||
}
|
||||
$sql .= " ) ";
|
||||
|
||||
@ -149,16 +153,17 @@ class lettering extends BookKeeping
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='" . $obj->code_journal . "')";
|
||||
$sql .= " WHERE payfac.fk_paiement = '" . $obj->url_id . "' ";
|
||||
$sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4) ";
|
||||
$sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
|
||||
$sql .= " AND fac.entity = ".$conf->entity;
|
||||
$sql .= " AND ( ";
|
||||
if (! empty($object->code_compta)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
|
||||
}
|
||||
if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " OR ";
|
||||
}
|
||||
if (! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
|
||||
}
|
||||
$sql .= " ) ";
|
||||
|
||||
@ -176,16 +181,17 @@ class lettering extends BookKeeping
|
||||
$sql = 'SELECT bk.rowid, fac.ref, fac.ref_supplier ';
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (" . implode(',', $ids_fact) . "))";
|
||||
$sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2) ";
|
||||
$sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2 AND entity=".$conf->entity.") ";
|
||||
$sql .= " AND fac.entity = ".$conf->entity;
|
||||
$sql .= " AND ( ";
|
||||
if (! empty($object->code_compta)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
|
||||
}
|
||||
if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " OR ";
|
||||
}
|
||||
if (! empty($object->code_compta_fournisseur)) {
|
||||
$sql .= " bk.thirdparty_code = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
|
||||
}
|
||||
$sql .= " ) ";
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ print '<script type="text/javascript">
|
||||
/*
|
||||
* Customer Invoice lines
|
||||
*/
|
||||
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client,";
|
||||
$sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.datef, f.ref_client,";
|
||||
$sql .= " fd.rowid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
|
||||
@ -333,7 +333,7 @@ if ($result) {
|
||||
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte;
|
||||
|
||||
$facture_static->ref = $objp->facnumber;
|
||||
$facture_static->id = $objp->rowid;
|
||||
$facture_static->id = $objp->facid;
|
||||
|
||||
$product_static->ref = $objp->product_ref;
|
||||
$product_static->id = $objp->product_id;
|
||||
|
||||
@ -223,7 +223,7 @@ $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountan
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.fk_pcg_version = '" . $chartaccountcode."'";
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.fk_pcg_version = '" . $chartaccountcode."'";
|
||||
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
|
||||
$sql.= " AND product_type <= 2";
|
||||
$sql.= " AND l.product_type <= 2";
|
||||
// Add search filter like
|
||||
if ($search_lineid) {
|
||||
$sql .= natural_search("l.rowid", $search_lineid, 1);
|
||||
|
||||
@ -271,7 +271,8 @@ if ($result) {
|
||||
|
||||
if ($links[$key]['type'] == 'payment') {
|
||||
$paymentstatic->id = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
|
||||
$paymentstatic->ref = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this
|
||||
$tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
|
||||
} else if ($links[$key]['type'] == 'payment_supplier') {
|
||||
$paymentsupplierstatic->id = $links[$key]['url_id'];
|
||||
@ -303,6 +304,7 @@ if ($result) {
|
||||
}
|
||||
$chargestatic->ref = $chargestatic->lib;
|
||||
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
|
||||
$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
|
||||
|
||||
$sqlmid = 'SELECT cchgsoc.accountancy_code';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
|
||||
@ -319,11 +321,12 @@ if ($result) {
|
||||
}
|
||||
} else if ($links[$key]['type'] == 'payment_donation') {
|
||||
$paymentdonstatic->id = $links[$key]['url_id'];
|
||||
$paymentdonstatic->ref = $links[$key]['url_id'];
|
||||
$paymentdonstatic->fk_donation = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2);
|
||||
$tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id;
|
||||
$tabtp[$obj->rowid][$account_pay_donation] += $obj->amount;
|
||||
} else if ($links[$key]['type'] == 'payment_vat') {
|
||||
} else if ($links[$key]['type'] == 'payment_vat') { // Payment VAT
|
||||
$paymentvatstatic->id = $links[$key]['url_id'];
|
||||
$paymentvatstatic->ref = $links[$key]['url_id'];
|
||||
$paymentvatstatic->label = $links[$key]['label'];
|
||||
@ -401,7 +404,9 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
|
||||
$error = 0;
|
||||
foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank
|
||||
foreach ( $tabpay as $key => $val ) // $key is rowid into llx_bank
|
||||
{
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
$ref = getSourceDocRef($val, $tabtype[$key]);
|
||||
|
||||
@ -423,7 +428,13 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
// Line into bank account
|
||||
foreach ( $tabbq[$key] as $k => $mt )
|
||||
{
|
||||
if ($mt) {
|
||||
if ($mt)
|
||||
{
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
|
||||
$reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
|
||||
if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']);
|
||||
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $ref;
|
||||
@ -442,31 +453,8 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
// No subledger_account value for the bank line but add a specific label_operation
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_expensereport') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'unknown') {
|
||||
// ???
|
||||
$bookkeeping->subledger_account = '';
|
||||
}
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $reflabel;
|
||||
|
||||
$totaldebit += $bookkeeping->debit;
|
||||
$totalcredit += $bookkeeping->credit;
|
||||
@ -491,115 +479,162 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// Third party
|
||||
if (! $errorforline && is_array($tabtp[$key]))
|
||||
if (! $errorforline)
|
||||
{
|
||||
// Line into thirdparty account
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $ref;
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->journal_label = $journal_label;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
if (is_array($tabtp[$key]))
|
||||
{
|
||||
// Line into thirdparty account
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt)
|
||||
{
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":"");
|
||||
$reflabel.= dol_string_nohtmltag($val['soclib']);
|
||||
|
||||
if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_expensereport') {
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $objmid->labelc;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'banktransfert') {
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else {
|
||||
if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty.
|
||||
{
|
||||
// Temporary account
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $ref;
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->journal_label = $journal_label;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_expensereport') {
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $objmid->labelc;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'banktransfert') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else {
|
||||
if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty.
|
||||
{
|
||||
// Temporary account
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
|
||||
$bookkeeping->label_compte = '';
|
||||
}
|
||||
}
|
||||
|
||||
$bookkeeping->label_operation = $reflabel;
|
||||
|
||||
$totaldebit += $bookkeeping->debit;
|
||||
$totalcredit += $bookkeeping->credit;
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // If thirdparty unkown, output the waiting account
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
if ($mt)
|
||||
{
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
|
||||
$reflabel.= dol_string_nohtmltag('WaitingAccount');
|
||||
|
||||
$totaldebit += $bookkeeping->debit;
|
||||
$totalcredit += $bookkeeping->credit;
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $ref;
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->journal_label = $journal_label;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->label_compte = '';
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
$bookkeeping->label_operation = $reflabel;
|
||||
|
||||
$totaldebit += $bookkeeping->debit;
|
||||
$totalcredit += $bookkeeping->credit;
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($totaldebit != $totalcredit)
|
||||
if (price2num($totaldebit) != price2num($totalcredit))
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
@ -662,101 +697,105 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
$companystatic = new Client($db);
|
||||
$userstatic = new User($db);
|
||||
// CSV header line
|
||||
print '"' . $langs->trans("BankId").'"' . $sep;
|
||||
print '"' . $langs->trans("Date") . '"' . $sep;
|
||||
print '"' . $langs->trans("PaymentMode") . '"' . $sep;
|
||||
print '"' . $langs->trans("AccountAccounting") . '"' . $sep;
|
||||
print '"' . $langs->trans("LedgerAccount") . '"' . $sep;
|
||||
print '"' . $langs->trans("SubledgerAccount") . '"' . $sep;
|
||||
print '"' . $langs->trans("Label"). '"' . $sep;
|
||||
print '"' . $langs->trans("Amount") . '"' . $sep;
|
||||
print '"' . $langs->trans("Amount") . '"' . $sep;
|
||||
print '"' . $langs->trans("Journal") . '"' . $sep;
|
||||
print '"' . $langs->trans("Note") . '"' . $sep;
|
||||
print "\n";
|
||||
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
|
||||
foreach ( $tabpay as $key => $val )
|
||||
{
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
$ref = getSourceDocRef($val, $tabtype[$key]);
|
||||
|
||||
//
|
||||
if (! empty($tabcompany[$key]['id']))
|
||||
{
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$companystatic->id = 0;
|
||||
$companystatic->name = '';
|
||||
}
|
||||
if (! empty($tabuser[$key]['id']))
|
||||
{
|
||||
$userstatic->id = $tabuser[$key]['id'];
|
||||
$userstatic->lastname = $tabuser[$key]['lastname'];
|
||||
$userstatic->firstname = $tabuser[$key]['firstname'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$userstatic->id = 0;
|
||||
$userstatic->lastname = '';
|
||||
$userstatic->firstname = '';
|
||||
}
|
||||
|
||||
// Bank
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $val['bank_account_ref'] . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
if ($mt)
|
||||
{
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
|
||||
$reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
|
||||
if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']);
|
||||
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '"' . $reflabel . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"' . $sep;
|
||||
print '"' . dol_string_nohtmltag($ref) . '"' . $sep;
|
||||
print "\n";
|
||||
}
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"' . $sep;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Third party
|
||||
if (is_array($tabtp[$key])) {
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
if ($mt)
|
||||
{
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":"");
|
||||
$reflabel.= dol_string_nohtmltag($val['soclib']);
|
||||
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
if ($tabtype[$key] == 'payment_supplier') {
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
} else if($tabtype[$key] == 'payment') {
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
|
||||
} else if($tabtype[$key] == 'payment_expensereport') {
|
||||
print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep;
|
||||
} else if($tabtype[$key] == 'payment_salary') {
|
||||
print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep;
|
||||
} else {
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
}
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
print '"' . $reflabel . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"' . $sep;
|
||||
print '"' . dol_string_nohtmltag($ref) . '"' . $sep;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else { // If thirdparty unkown, output the waiting account
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
if ($mt)
|
||||
{
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
|
||||
$reflabel.= dol_string_nohtmltag('WaitingAccount');
|
||||
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print "" . $sep;
|
||||
print '"' . $reflabel . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"' . $sep;
|
||||
print '"' . dol_string_nohtmltag($ref) . '"' . $sep;
|
||||
print "\n";
|
||||
}
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"' . $sep;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -862,7 +901,8 @@ if (empty($action) || $action == 'view') {
|
||||
|
||||
$r = '';
|
||||
|
||||
foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank
|
||||
foreach ( $tabpay as $key => $val ) // $key is rowid in llx_bank
|
||||
{
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
$ref = getSourceDocRef($val, $tabtype[$key]);
|
||||
@ -870,48 +910,56 @@ if (empty($action) || $action == 'view') {
|
||||
// Bank
|
||||
foreach ( $tabbq[$key] as $k => $mt )
|
||||
{
|
||||
//var_dump($tabpay[$key]);
|
||||
print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->';
|
||||
print '<tr class="oddeven">';
|
||||
print "<td></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $ref . "</td>";
|
||||
// Ledger account
|
||||
print "<td>";
|
||||
$accounttoshow = length_accountg($k);
|
||||
if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
|
||||
if ($mt)
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - ";
|
||||
$reflabel.= $langs->trans("Bank").' '.$val['bank_account_ref'];
|
||||
if (! empty($val['soclib'])) $reflabel .= " - " . $val['soclib'];
|
||||
|
||||
//var_dump($tabpay[$key]);
|
||||
print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->';
|
||||
print '<tr class="oddeven">';
|
||||
print "<td></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $ref . "</td>";
|
||||
// Ledger account
|
||||
print "<td>";
|
||||
$accounttoshow = length_accountg($k);
|
||||
if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
|
||||
}
|
||||
else print $accounttoshow;
|
||||
print "</td>";
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
/*$accounttoshow = length_accountg($k);
|
||||
if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
|
||||
}
|
||||
else print $accounttoshow;*/
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print $reflabel;
|
||||
print "</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>";
|
||||
}
|
||||
else print $accounttoshow;
|
||||
print "</td>";
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
/*$accounttoshow = length_accountg($k);
|
||||
if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
|
||||
}
|
||||
else print $accounttoshow;*/
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
//var_dump($tabpay[$key]);
|
||||
print $langs->trans("Bank");
|
||||
print ' '.$val['bank_account_ref'];
|
||||
if (! empty($val['soclib'])) {
|
||||
print " - " . $val['soclib'];
|
||||
}
|
||||
print "</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
|
||||
if (is_array($tabtp[$key])) {
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($k != 'type') {
|
||||
if ($mt)
|
||||
{
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= $val['lib'] . ($val['soclib']?" - ":"");
|
||||
$reflabel.= $val['soclib'];
|
||||
|
||||
print '<!-- Thirdparty bank.rowid='.$key.' -->';
|
||||
print '<tr class="oddeven">';
|
||||
print "<td></td>";
|
||||
@ -974,42 +1022,49 @@ if (empty($action) || $action == 'view') {
|
||||
}
|
||||
}
|
||||
print "</td>";
|
||||
print "<td>" . $reflabel . ' ' . $val['soclib'] . "</td>";
|
||||
print "<td>" . $reflabel . "</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>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else { // Waiting account
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print '<!-- Wait bank.rowid='.$key.' -->';
|
||||
print '<tr class="oddeven">';
|
||||
print "<td></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $ref . "</td>";
|
||||
// Ledger account
|
||||
print "<td>";
|
||||
/*if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
|
||||
if ($mt)
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
|
||||
$reflabel = '';
|
||||
if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - ";
|
||||
$reflabel.= 'WaitingAccount';
|
||||
|
||||
print '<!-- Wait bank.rowid='.$key.' -->';
|
||||
print '<tr class="oddeven">';
|
||||
print "<td></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $ref . "</td>";
|
||||
// Ledger account
|
||||
print "<td>";
|
||||
/*if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
|
||||
}
|
||||
else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
|
||||
print "</td>";
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
/*if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
|
||||
}
|
||||
else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
|
||||
*/
|
||||
print "</td>";
|
||||
print "<td>" . $reflabel . "</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>";
|
||||
}
|
||||
else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
|
||||
print "</td>";
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
/*if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
|
||||
}
|
||||
else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
|
||||
*/
|
||||
print "</td>";
|
||||
print "<td>" . $reflabel . "</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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1089,6 +1144,13 @@ function getSourceDocRef($val, $typerecord)
|
||||
$sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"];
|
||||
$ref = $langs->trans("SalaryPayment");
|
||||
}
|
||||
elseif ($typerecord == 'sc')
|
||||
{
|
||||
$sqlmid = 'SELECT sc.rowid as ref';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc";
|
||||
$sqlmid .= " WHERE sc.rowid=" . $val["paymentscid"];
|
||||
$ref = $langs->trans("SocialContribution");
|
||||
}
|
||||
elseif ($typerecord == 'payment_vat')
|
||||
{
|
||||
$sqlmid = 'SELECT v.rowid as ref';
|
||||
|
||||
@ -344,7 +344,8 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
}
|
||||
|
||||
if ($totaldebit != $totalcredit)
|
||||
// Protection against a bug on line before
|
||||
if (price2num($totaldebit) != price2num($totalcredit))
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
|
||||
@ -98,14 +98,12 @@ $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
|
||||
//$sql .= " ct.accountancy_code_buy as account_tva";
|
||||
$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 . "accounting_account 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"; // TODO Facture annulée ?
|
||||
$sql .= " WHERE f.fk_statut > 0";
|
||||
$sql .= " AND fd.fk_code_ventilation > 0";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
@ -214,6 +212,29 @@ if ($result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$errorforinvoice = array();
|
||||
|
||||
// Loop in invoices to detect lines with not binding lines
|
||||
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$sql = "SELECT COUNT(fd.rowid) as nb";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
|
||||
$sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql.= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj->nb > 0)
|
||||
{
|
||||
$errorforinvoice[$key]='somelinesarenotbound';
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
}
|
||||
//var_dump($errorforinvoice);exit;
|
||||
|
||||
|
||||
|
||||
// Bookkeeping Write
|
||||
if ($action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
@ -257,17 +278,26 @@ if ($action == 'writebookkeeping') {
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
|
||||
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
|
||||
if ($replacedinvoice == 1)
|
||||
{
|
||||
$db->rollback();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Error if some lines are not binded/ready to be journalized
|
||||
if ($errorforinvoice[$key] == 'somelinesarenotbound')
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
|
||||
}
|
||||
|
||||
// Thirdparty
|
||||
if (! $errorforline)
|
||||
{
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
@ -298,16 +328,18 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,7 +347,7 @@ if ($action == 'writebookkeeping') {
|
||||
if (! $errorforline)
|
||||
{
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
// get compte id and label
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
if ($accountingaccount->fetch(null, $k, true)) {
|
||||
@ -349,17 +381,19 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,12 +440,14 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -422,7 +458,7 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
// Counterpart of VAT for VAT NPR
|
||||
// var_dump($tabother);
|
||||
if (! $errorforline)
|
||||
if (! $errorforline && is_array($tabother[$key]))
|
||||
{
|
||||
foreach ( $tabother[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
@ -456,12 +492,14 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -469,10 +507,12 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
}
|
||||
|
||||
if ($totaldebit != $totalcredit)
|
||||
// Protection against a bug on lines before
|
||||
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='amountsnotbalanced';
|
||||
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
|
||||
}
|
||||
|
||||
@ -567,7 +607,7 @@ if ($action == 'exportcsv') {
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
|
||||
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
|
||||
if ($replacedinvoice == 1)
|
||||
{
|
||||
continue;
|
||||
@ -575,26 +615,28 @@ if ($action == 'exportcsv') {
|
||||
|
||||
// Third party
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
print "\n";
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
print "\n";
|
||||
//}
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
@ -608,7 +650,7 @@ if ($action == 'exportcsv') {
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
print "\n";
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
// VAT
|
||||
@ -787,45 +829,67 @@ if (empty($action) || $action == 'view') {
|
||||
print '<td align="right"></td>';
|
||||
print '<td align="right"></td>';
|
||||
print "</tr>";
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Third party
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
if ($errorforinvoice[$key] == 'somelinesarenotbound')
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- Thirdparty --></td>";
|
||||
print "<td><!-- Some lines are not bound --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
|
||||
print '</td>';
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($k);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "<td>";
|
||||
print "</td>";
|
||||
print '<td align="right"></td>';
|
||||
print '<td align="right"></td>';
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
// Third party
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
//if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- Thirdparty --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($k);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print '<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 ) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- Product --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
@ -848,7 +912,7 @@ if (empty($action) || $action == 'view') {
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
// VAT
|
||||
@ -890,27 +954,28 @@ if (empty($action) || $action == 'view') {
|
||||
if (is_array($tabother[$key]))
|
||||
{
|
||||
foreach ( $tabother[$key] as $k => $mt ) {
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- VAT counterpart NPR --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accountg($k);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account'.'</span>';
|
||||
if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- VAT counterpart NPR --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accountg($k);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account'.'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT") . " NPR (counterpart)</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT") . " NPR (counterpart)</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,17 +93,15 @@ $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client, f.date
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$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 . "accounting_account 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 as ct ON ((fd.vat_src_code <> '' AND fd.vat_src_code = ct.code) OR (fd.vat_src_code = '' AND fd.tva_tx = ct.taux)) AND ct.fk_pays = '" . $idpays . "'";
|
||||
$sql .= " WHERE fd.fk_code_ventilation > 0";
|
||||
$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ?
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy, we use source object sharing
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
@ -218,6 +216,28 @@ if ($result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$errorforinvoice = array();
|
||||
|
||||
// Loop in invoices to detect lines with not binding lines
|
||||
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$sql = "SELECT COUNT(fd.rowid) as nb";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql.= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj->nb > 0)
|
||||
{
|
||||
$errorforinvoice[$key]='somelinesarenotbound';
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
}
|
||||
//var_dump($errorforinvoice);exit;
|
||||
|
||||
|
||||
// Bookkeeping Write
|
||||
if ($action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
@ -259,17 +279,26 @@ if ($action == 'writebookkeeping') {
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
|
||||
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
|
||||
if ($replacedinvoice == 1)
|
||||
{
|
||||
$db->rollback();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Error if some lines are not binded/ready to be journalized
|
||||
if ($errorforinvoice[$key] == 'somelinesarenotbound')
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
|
||||
}
|
||||
|
||||
// Thirdparty
|
||||
if (! $errorforline)
|
||||
{
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
@ -300,16 +329,18 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +348,7 @@ if ($action == 'writebookkeeping') {
|
||||
if (! $errorforline)
|
||||
{
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
// get compte id and label
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
if ($accountingaccount->fetch(null, $k, true)) {
|
||||
@ -351,22 +382,23 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
if (! $errorforline)
|
||||
{
|
||||
$listoftax=array(0, 1, 2);
|
||||
@ -408,12 +440,14 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -422,10 +456,12 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
}
|
||||
|
||||
if ($totaldebit != $totalcredit)
|
||||
// Protection against a bug on lines before
|
||||
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='amountsnotbalanced';
|
||||
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
|
||||
}
|
||||
|
||||
@ -522,7 +558,7 @@ if ($action == 'exportcsv') {
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
|
||||
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
|
||||
if ($replacedinvoice == 1)
|
||||
{
|
||||
continue;
|
||||
@ -530,26 +566,28 @@ if ($action == 'exportcsv') {
|
||||
|
||||
// Third party
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
//}
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ($tabht[$key] as $k => $mt) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
@ -563,7 +601,7 @@ if ($action == 'exportcsv') {
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
// VAT
|
||||
@ -719,38 +757,60 @@ if (empty($action) || $action == 'view') {
|
||||
print '<td align="right"></td>';
|
||||
print '<td align="right"></td>';
|
||||
print "</tr>";
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($errorforinvoice[$key] == 'somelinesarenotbound')
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- Some lines are not bound --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
|
||||
print '</td>';
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>";
|
||||
print "</td>";
|
||||
print '<td align="right"></td>';
|
||||
print '<td align="right"></td>';
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
// Third party
|
||||
foreach ($tabttc[$key] as $k => $mt)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- Thirdparty --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($k);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
//if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- Thirdparty --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($k);
|
||||
if (empty($accountoshow) || $accountoshow == 'NotDefined')
|
||||
{
|
||||
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
//}
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
@ -759,7 +819,7 @@ if (empty($action) || $action == 'view') {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
|
||||
if ($mt) {
|
||||
//if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><!-- Product --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
@ -782,7 +842,7 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
// VAT
|
||||
|
||||
@ -222,7 +222,7 @@ $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
|
||||
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
|
||||
$sql.= " AND product_type <= 2";
|
||||
$sql.= " AND l.product_type <= 2";
|
||||
// Add search filter like
|
||||
if ($search_lineid) {
|
||||
$sql .= natural_search("l.rowid", $search_lineid, 1);
|
||||
|
||||
@ -148,10 +148,10 @@ if ($object->id > 0)
|
||||
//print '</div>';
|
||||
|
||||
|
||||
$morehtmlcenter = '';
|
||||
$createbutton = '';
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
$morehtmlcenter.='<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction").'</a>';
|
||||
$createbutton.='<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
@ -162,7 +162,7 @@ if ($object->id > 0)
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
|
||||
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
|
||||
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $createbutton, '', 0, 1, 1);
|
||||
|
||||
// List of all actions
|
||||
$filters=array();
|
||||
|
||||
@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
|
||||
$object->subscription = (int) trim($subscription);
|
||||
$object->note = trim($comment);
|
||||
$object->mail_valid = trim($mail_valid);
|
||||
$object->vote = trim($vote);
|
||||
$object->vote = (boolean) trim($vote);
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
@ -160,7 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
|
||||
$object->subscription = (int) trim($subscription);
|
||||
$object->note = trim($comment);
|
||||
$object->mail_valid = trim($mail_valid);
|
||||
$object->vote = trim($vote);
|
||||
$object->vote = (boolean) trim($vote);
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
@ -187,7 +187,7 @@ $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAI
|
||||
$tabsql[10]= "SELECT t.rowid, t.code, 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, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
|
||||
$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12]);
|
||||
$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13]);
|
||||
$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13]);
|
||||
$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";
|
||||
@ -265,7 +265,7 @@ $tabfield[9] = "code,label,unicode";
|
||||
$tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfield[11]= "element,source,code,libelle,position";
|
||||
$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
|
||||
$tabfield[13]= "code,libelle,type,accountancy_code,entity";
|
||||
$tabfield[13]= "code,libelle,type,entity";
|
||||
$tabfield[14]= "code,libelle,price,organization,country_id,country";
|
||||
$tabfield[15]= "code,libelle,width,height,unit";
|
||||
$tabfield[16]= "code,libelle,sortorder";
|
||||
@ -304,7 +304,7 @@ $tabfieldvalue[9] = "code,label,unicode";
|
||||
$tabfieldvalue[10]= "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldvalue[11]= "element,source,code,libelle,position";
|
||||
$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
|
||||
$tabfieldvalue[13]= "code,libelle,type,accountancy_code";
|
||||
$tabfieldvalue[13]= "code,libelle,type";
|
||||
$tabfieldvalue[14]= "code,libelle,price,organization,country";
|
||||
$tabfieldvalue[15]= "code,libelle,width,height,unit";
|
||||
$tabfieldvalue[16]= "code,libelle,sortorder";
|
||||
@ -343,7 +343,7 @@ $tabfieldinsert[9] = "code_iso,label,unicode";
|
||||
$tabfieldinsert[10]= "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldinsert[11]= "element,source,code,libelle,position";
|
||||
$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
|
||||
$tabfieldinsert[13]= "code,libelle,type,accountancy_code,entity";
|
||||
$tabfieldinsert[13]= "code,libelle,type,entity";
|
||||
$tabfieldinsert[14]= "code,libelle,price,organization,fk_pays";
|
||||
$tabfieldinsert[15]= "code,label,width,height,unit";
|
||||
$tabfieldinsert[16]= "code,label,sortorder";
|
||||
|
||||
103
htdocs/admin/export.php
Normal file
103
htdocs/admin/export.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.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/expedition.php
|
||||
* \ingroup expedition
|
||||
* \brief Page d'administration/configuration du module Expedition
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("exports");
|
||||
|
||||
$langs->load('other');
|
||||
|
||||
if (! $user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$action=GETPOST('action','alpha');
|
||||
$value=GETPOST('value','alpha');
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$page_name = "ExportSetup";
|
||||
llxHeader('', $langs->trans($page_name));
|
||||
|
||||
// Subheader
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
|
||||
. $langs->trans("BackToModuleList") . '</a>';
|
||||
print_fiche_titre($langs->trans($page_name), $linkback);
|
||||
|
||||
// Configuration header
|
||||
|
||||
dol_fiche_head(
|
||||
$head,
|
||||
'settings',
|
||||
$langs->trans("ExportsArea"),
|
||||
0,
|
||||
"exports"
|
||||
);
|
||||
|
||||
// Setup page goes here
|
||||
$form=new Form($db);
|
||||
$var=false;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("ExportModel").'</td>'."\n";
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="center" width="100"></td>'."\n";
|
||||
|
||||
|
||||
// Example with a yes / no select
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("set_EXPORTS_SHARE_MODELS").'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="center" width="100">';
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_EXPORTS_SHARE_MODELS">';
|
||||
echo ajax_constantonoff('EXPORTS_SHARE_MODELS');
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -70,6 +70,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs);
|
||||
if ($action == 'update' && empty($_POST["cancel"]))
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity);
|
||||
// Send mode parameters
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity);
|
||||
@ -239,6 +240,11 @@ if ($action == 'edit')
|
||||
print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Force e-mail recipient
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>';
|
||||
print '<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="' . (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO)?$conf->global->MAIN_MAIL_FORCE_SENDTO:'') . '" />';
|
||||
print '</td></tr>';
|
||||
|
||||
// Separator
|
||||
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
@ -478,6 +484,11 @@ else
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn($conf->global->MAIN_DISABLE_ALL_MAILS).'</td></tr>';
|
||||
|
||||
// Force e-mail recipient
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.$conf->global->MAIN_MAIL_FORCE_SENDTO;
|
||||
if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO) && ! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail"));
|
||||
print '</td></tr>';
|
||||
|
||||
// Separator
|
||||
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
@ -644,25 +655,7 @@ else
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
|
||||
{
|
||||
print '<br>';
|
||||
/*
|
||||
// Warning 1
|
||||
if ($linuxlike)
|
||||
{
|
||||
$sendmailoption=ini_get('mail.force_extra_parameters');
|
||||
if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
|
||||
{
|
||||
print info_admin($langs->trans("SendmailOptionNotComplete"));
|
||||
}
|
||||
}*/
|
||||
// Warning 2
|
||||
print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
|
||||
}
|
||||
|
||||
|
||||
// Boutons actions
|
||||
// Actions button
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
@ -689,6 +682,22 @@ else
|
||||
print '</div>';
|
||||
|
||||
|
||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
|
||||
{
|
||||
/*
|
||||
// Warning 1
|
||||
if ($linuxlike)
|
||||
{
|
||||
$sendmailoption=ini_get('mail.force_extra_parameters');
|
||||
if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
|
||||
{
|
||||
print info_admin($langs->trans("SendmailOptionNotComplete"));
|
||||
}
|
||||
}*/
|
||||
// Warning 2
|
||||
print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
|
||||
}
|
||||
|
||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && ! in_array($action, array('testconnect', 'test', 'testhtml')))
|
||||
{
|
||||
$text = $langs->trans("WarningPHPMail");
|
||||
|
||||
@ -127,7 +127,7 @@ print info_admin(showModulesExludedForExternal($modules)).'<br>'."\n";
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// Affiche lignes des permissions
|
||||
// Show permissions lines
|
||||
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||
|
||||
@ -39,8 +39,7 @@ $action = GETPOST('action', 'alpha');
|
||||
|
||||
// Other parameters SALARIES_*
|
||||
$list = array (
|
||||
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
|
||||
'SALARIES_ACCOUNTING_ACCOUNT_CHARGE'
|
||||
'SALARIES_XXX',
|
||||
);
|
||||
|
||||
/*
|
||||
@ -97,7 +96,7 @@ print "</tr>\n";
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
|
||||
@ -401,6 +401,23 @@ $titre=$langs->trans("WebsiteSetup");
|
||||
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($titre,$linkback,'title_setup');
|
||||
|
||||
// Onglets
|
||||
$head=array();
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/website.php";
|
||||
$head[$h][1] = $langs->trans("WebSites");
|
||||
$head[$h][2] = 'website';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/website_options.php";
|
||||
$head[$h][1] = $langs->trans("Options");
|
||||
$head[$h][2] = 'options';
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, 'website', '', -1);
|
||||
|
||||
|
||||
print $langs->trans("WebsiteSetupDesc").'<br>';
|
||||
print "<br>\n";
|
||||
|
||||
@ -648,7 +665,9 @@ if ($id)
|
||||
}
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
dol_fiche_end();
|
||||
|
||||
//print '<br>';
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
153
htdocs/admin/website_options.php
Normal file
153
htdocs/admin/website_options.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2017 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/admin/website.php
|
||||
* \ingroup setup
|
||||
* \brief Page to administer web sites
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
|
||||
|
||||
$langs->load("errors");
|
||||
$langs->load("admin");
|
||||
$langs->load("companies");
|
||||
$langs->load("website");
|
||||
|
||||
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$rowid=GETPOST('rowid','alpha');
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$status = 1;
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
$sortorder = GETPOST('sortorder','alpha');
|
||||
$page = GETPOST('page','int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('admin'));
|
||||
|
||||
$arrayofparameters=array('WEBSITE_USE_WEBSITE_ACCOUNTS'=>array('css'=>'minwidth200'));
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formadmin=new FormAdmin($db);
|
||||
|
||||
llxHeader('', $langs->trans("WebsiteSetup"));
|
||||
|
||||
$titre=$langs->trans("WebsiteSetup");
|
||||
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($titre,$linkback,'title_setup');
|
||||
|
||||
// Onglets
|
||||
$head=array();
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/website.php";
|
||||
$head[$h][1] = $langs->trans("WebSites");
|
||||
$head[$h][2] = 'website';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/website_options.php";
|
||||
$head[$h][1] = $langs->trans("Options");
|
||||
$head[$h][2] = 'options';
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, 'options', '', -1);
|
||||
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
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"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
foreach($arrayofparameters as $key => $val)
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip'));
|
||||
print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
foreach($arrayofparameters as $key => $val)
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip'));
|
||||
print '</td><td>' . $conf->global->$key . '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
//print '<br>';
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -87,7 +87,13 @@ foreach ($modulesdir as $dir)
|
||||
$part = 'compta/facture';
|
||||
$obj = 'facture';
|
||||
}
|
||||
if (empty($conf->$module->enabled)) $enabled=false;
|
||||
if ($module == 'ficheinter') {
|
||||
$obj = 'fichinter';
|
||||
$part = 'fichinter';
|
||||
$module='fichinter';
|
||||
}
|
||||
|
||||
if (empty($conf->$module->enabled)) $enabled=false;
|
||||
|
||||
if ($enabled)
|
||||
{
|
||||
|
||||
@ -145,6 +145,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' ||
|
||||
$modulenameforenabled = $module;
|
||||
if ($module == 'propale') { $modulenameforenabled='propal'; }
|
||||
if ($module == 'supplierproposal') { $modulenameforenabled='supplier_proposal'; }
|
||||
if ($module == 'ficheinter') { $modulenameforenabled='ficheinter'; }
|
||||
|
||||
dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass);
|
||||
|
||||
@ -217,7 +218,7 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
|
||||
$moduledirforclass = getModuleDirForApiClass($module);
|
||||
|
||||
// Load a dedicated API file
|
||||
dol_syslog("Load a dedicated API file moduledirforclass=".$moduledirforclass);
|
||||
dol_syslog("Load a dedicated API file module=".$module." moduledirforclass=".$moduledirforclass);
|
||||
|
||||
$tmpmodule = $module;
|
||||
if ($tmpmodule != 'api')
|
||||
@ -229,6 +230,11 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
|
||||
$classfile = 'supplier_orders';
|
||||
if ($module == 'supplierinvoices')
|
||||
$classfile = 'supplier_invoices';
|
||||
if ($module == 'ficheinter')
|
||||
$classfile = 'interventions';
|
||||
if ($module == 'interventions')
|
||||
$classfile = 'interventions';
|
||||
|
||||
$dir_part_file = dol_buildpath('/' . $moduledirforclass . '/class/api_' . $classfile . '.class.php', 0, 2);
|
||||
|
||||
$classname = ucwords($module);
|
||||
|
||||
@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
$langs->loadLangs(array("admin", "other", "blockedlog", "bills"));
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
if ((! $user->admin && ! $user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden();
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'blockedloglist'; // To manage different context of search
|
||||
@ -103,93 +103,147 @@ if ($action === 'downloadblockchain') {
|
||||
|
||||
exit;
|
||||
}
|
||||
else if($action === 'downloadcsv') {
|
||||
else if (GETPOST('downloadcsv','alpha'))
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
$sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
|
||||
$previoushash='';
|
||||
$firstid='';
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($res) {
|
||||
|
||||
$signature = $block_static->getSignature();
|
||||
|
||||
header('Content-Type: application/octet-stream');
|
||||
header("Content-Transfer-Encoding: Binary");
|
||||
header("Content-disposition: attachment; filename=\"archive-log-" .$signature. ".csv\"");
|
||||
|
||||
print $langs->transnoentities('Id')
|
||||
.';'.$langs->transnoentities('Date')
|
||||
.';'.$langs->transnoentities('User')
|
||||
.';'.$langs->transnoentities('Action')
|
||||
.';'.$langs->transnoentities('Element')
|
||||
.';'.$langs->transnoentities('Amounts')
|
||||
.';'.$langs->transnoentities('ObjectId')
|
||||
.';'.$langs->transnoentities('Date')
|
||||
.';'.$langs->transnoentities('Ref')
|
||||
.';'.$langs->transnoentities('Fingerprint')
|
||||
.';'.$langs->transnoentities('Status')
|
||||
.';'.$langs->transnoentities('FullData')
|
||||
."\n";
|
||||
|
||||
$previoushash = '';
|
||||
$loweridinerror = 0;
|
||||
|
||||
while ($obj = $db->fetch_object($res))
|
||||
if (! $error)
|
||||
{
|
||||
// Get ID of first line
|
||||
$sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
if (GETPOST('yeartoexport','int') > 0)
|
||||
{
|
||||
// We set here all data used into signature calculation (see checkSignature method) and more
|
||||
// IMPORTANT: We must have here, the same rule for transformation of data than into the fetch method (db->jdate for date, ...)
|
||||
$block_static->id = $obj->rowid;
|
||||
$block_static->date_creation = $db->jdate($obj->date_creation);
|
||||
$block_static->date_modification = $db->jdate($obj->tms);
|
||||
$block_static->action = $obj->action;
|
||||
$block_static->fk_object = $obj->fk_object;
|
||||
$block_static->element = $obj->element;
|
||||
$block_static->amounts = (double) $obj->amounts;
|
||||
$block_static->ref_object = $obj->ref_object;
|
||||
$block_static->date_object = $db->jdate($obj->date_object);
|
||||
$block_static->user_fullname = $obj->user_fullname;
|
||||
$block_static->fk_user = $obj->fk_user;
|
||||
$block_static->signature = $obj->signature;
|
||||
$block_static->object_data = unserialize($obj->object_data);
|
||||
$dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1);
|
||||
$datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12);
|
||||
$sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
|
||||
}
|
||||
$sql.= " ORDER BY rowid ASC"; // Required so we get the first one
|
||||
$sql.= $db->plimit(1);
|
||||
|
||||
$checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it
|
||||
$res = $db->query($sql);
|
||||
if($res)
|
||||
{
|
||||
// Make the first fetch to get first line
|
||||
$obj = $db->fetch_object($res);
|
||||
|
||||
if ($checksignature)
|
||||
{
|
||||
if ($loweridinerror > 0) $statusofrecord = 'ValidButFoundAPreviousKO';
|
||||
else $statusofrecord = 'Valid';
|
||||
}
|
||||
else
|
||||
{
|
||||
$statusofrecord = 'KO';
|
||||
$loweridinerror = $obj->rowid;
|
||||
}
|
||||
$previoushash = $block_static->getPreviousHash(0, $obj->rowid);
|
||||
$firstid = $obj->rowid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
setEventMessage($db->lasterror, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
print $obj->rowid
|
||||
.';'.$obj->date_creation
|
||||
.';"'.$obj->user_fullname.'"'
|
||||
.';'.$obj->action
|
||||
.';'.$obj->element
|
||||
.';'.$obj->amounts
|
||||
.';'.$obj->fk_object
|
||||
.';'.$obj->date_object
|
||||
.';"'.$obj->ref_object.'"'
|
||||
.';'.$obj->signature
|
||||
.';'.$statusofrecord
|
||||
.';"'.str_replace('"','""',$obj->object_data).'"'
|
||||
if (! $error)
|
||||
{
|
||||
// Now restart request with all data
|
||||
$sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
if (GETPOST('yeartoexport','int') > 0)
|
||||
{
|
||||
$dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1);
|
||||
$datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12);
|
||||
$sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
|
||||
}
|
||||
$sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($res)
|
||||
{
|
||||
header('Content-Type: application/octet-stream');
|
||||
header("Content-Transfer-Encoding: Binary");
|
||||
header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport','int')>0?GETPOST('yeartoexport','int').'-':'').$previoushash. ".csv\"");
|
||||
|
||||
print $langs->transnoentities('Id')
|
||||
.';'.$langs->transnoentities('Date')
|
||||
.';'.$langs->transnoentities('User')
|
||||
.';'.$langs->transnoentities('Action')
|
||||
.';'.$langs->transnoentities('Element')
|
||||
.';'.$langs->transnoentities('Amounts')
|
||||
.';'.$langs->transnoentities('ObjectId')
|
||||
.';'.$langs->transnoentities('Date')
|
||||
.';'.$langs->transnoentities('Ref')
|
||||
.';'.$langs->transnoentities('Fingerprint')
|
||||
.';'.$langs->transnoentities('Status')
|
||||
.';'.$langs->transnoentities('Note')
|
||||
.';'.$langs->transnoentities('FullData')
|
||||
."\n";
|
||||
|
||||
// Set new previous hash for next fetch
|
||||
$previoushash = $obj->signature;
|
||||
}
|
||||
$loweridinerror = 0;
|
||||
$i = 0;
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($db->lasterror, 'errors');
|
||||
while ($obj = $db->fetch_object($res))
|
||||
{
|
||||
// We set here all data used into signature calculation (see checkSignature method) and more
|
||||
// IMPORTANT: We must have here, the same rule for transformation of data than into the fetch method (db->jdate for date, ...)
|
||||
$block_static->id = $obj->rowid;
|
||||
$block_static->date_creation = $db->jdate($obj->date_creation);
|
||||
$block_static->date_modification = $db->jdate($obj->tms);
|
||||
$block_static->action = $obj->action;
|
||||
$block_static->fk_object = $obj->fk_object;
|
||||
$block_static->element = $obj->element;
|
||||
$block_static->amounts = (double) $obj->amounts;
|
||||
$block_static->ref_object = $obj->ref_object;
|
||||
$block_static->date_object = $db->jdate($obj->date_object);
|
||||
$block_static->user_fullname = $obj->user_fullname;
|
||||
$block_static->fk_user = $obj->fk_user;
|
||||
$block_static->signature = $obj->signature;
|
||||
$block_static->object_data = unserialize($obj->object_data);
|
||||
|
||||
$checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it
|
||||
|
||||
if ($checksignature)
|
||||
{
|
||||
$statusofrecord = 'Valid';
|
||||
if ($loweridinerror > 0) $statusofrecordnote = 'ValidButFoundAPreviousKO';
|
||||
else $statusofrecordnote = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$statusofrecord = 'KO';
|
||||
$statusofrecordnote = 'LineCorruptedOrNotMatchingPreviousOne';
|
||||
$loweridinerror = $obj->rowid;
|
||||
}
|
||||
|
||||
if ($i==0)
|
||||
{
|
||||
$statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote?' - '.$statusofrecordnote:'');
|
||||
}
|
||||
print $obj->rowid
|
||||
.';'.$obj->date_creation
|
||||
.';"'.$obj->user_fullname.'"'
|
||||
.';'.$obj->action
|
||||
.';'.$obj->element
|
||||
.';'.$obj->amounts
|
||||
.';'.$obj->fk_object
|
||||
.';'.$obj->date_object
|
||||
.';"'.$obj->ref_object.'"'
|
||||
.';'.$obj->signature
|
||||
.';'.$statusofrecord
|
||||
.';'.$statusofrecordnote
|
||||
.';"'.str_replace('"','""',$obj->object_data).'"'
|
||||
."\n";
|
||||
|
||||
// Set new previous hash for next fetch
|
||||
$previoushash = $obj->signature;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($db->lasterror, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,18 +316,22 @@ if (GETPOST('withtab','alpha')) $param.='&withtab='.urlencode(GETPOST('withtab',
|
||||
// Add $param from extra fields
|
||||
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
||||
print '<div align="right">';
|
||||
//print ' <a href="?all=1'.(GETPOST('withtab','alpha')?'&withtab='.GETPOST('withtab','alpha'):'').'">'.$langs->trans('ShowAllFingerPrintsMightBeTooLong').'</a>';
|
||||
//print ' | <a href="?all=1&search_showonlyerrors=1'.(GETPOST('withtab','alpha')?'&withtab='.GETPOST('withtab','alpha'):'').'">'.$langs->trans('ShowAllFingerPrintsErrorsMightBeTooLong').'</a>';
|
||||
print ' <a href="?action=downloadcsv'.(GETPOST('withtab','alpha')?'&withtab='.GETPOST('withtab','alpha'):'').'">'.$langs->trans('DownloadLogCSV').'</a>';
|
||||
print $langs->trans("RestrictYearToExport").': ';
|
||||
print '<input type="text" name="yeartoexport" class="maxwidth75" value="'.GETPOST('yeartoexport','int').'">';
|
||||
print '<input type="hidden" name="withtab" value="'.GETPOST('withtab','alpha').'">';
|
||||
print '<input type="submit" name="downloadcsv" class="button" value="'.$langs->trans('DownloadLogCSV').'">';
|
||||
if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | <a href="?action=downloadblockchain'.(GETPOST('withtab','alpha')?'&withtab='.GETPOST('withtab','alpha'):'').'">'.$langs->trans('DownloadBlockChain').'</a>';
|
||||
print ' </div>';
|
||||
print ' </div><br>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
@ -301,7 +359,8 @@ print '</td>';
|
||||
|
||||
// User
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1);
|
||||
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
||||
|
||||
print '</td>';
|
||||
|
||||
// Actions code
|
||||
@ -330,6 +389,9 @@ $array=array("1"=>$langs->trans("OnlyNonValid"));
|
||||
print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1);
|
||||
print '</td>';
|
||||
|
||||
// Status note
|
||||
print '<td class="liste_titre"></td>';
|
||||
|
||||
// Action column
|
||||
print '<td class="liste_titre" align="middle">';
|
||||
$searchpicto=$form->showFilterButtons();
|
||||
@ -349,6 +411,7 @@ print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"],'',''
|
||||
print getTitleFieldOfList($langs->trans('DataOfArchivedEvent'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
|
||||
print getTitleFieldOfList($langs->trans('Fingerprint'), 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
|
||||
print getTitleFieldOfList($langs->trans('Status'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
|
||||
print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
|
||||
print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
|
||||
print '</tr>';
|
||||
|
||||
@ -386,35 +449,49 @@ if (is_array($blocks))
|
||||
{
|
||||
$object_link = $block->getObjectLink();
|
||||
|
||||
if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
|
||||
//if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
|
||||
if (empty($search_showonlyerrors) || ! $checkresult[$block->id])
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// ID
|
||||
print '<td>'.$block->id.'</td>';
|
||||
|
||||
// Date
|
||||
print '<td>'.dol_print_date($block->date_creation,'dayhour').'</td>';
|
||||
|
||||
// User
|
||||
print '<td>';
|
||||
|
||||
//print $block->getUser()
|
||||
print $block->user_fullname;
|
||||
print '</td>';
|
||||
|
||||
// Action
|
||||
print '<td>'.$langs->trans('log'.$block->action).'</td>';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap">'.$block->ref_object.'</td>';
|
||||
|
||||
// Link to source object
|
||||
print '<td>'.$object_link.'</td>';
|
||||
|
||||
// Amount
|
||||
print '<td align="right">'.price($block->amounts).'</td>';
|
||||
|
||||
// Details link
|
||||
print '<td align="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
|
||||
|
||||
// Fingerprint
|
||||
print '<td>';
|
||||
print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature);
|
||||
print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint');
|
||||
print '</td>';
|
||||
|
||||
// Status
|
||||
print '<td class="center">';
|
||||
if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
|
||||
{
|
||||
if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut1');
|
||||
if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut4');
|
||||
else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
|
||||
}
|
||||
else
|
||||
@ -422,10 +499,19 @@ if (is_array($blocks))
|
||||
print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4');
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
// Status note
|
||||
print '<td class="center">';
|
||||
if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
|
||||
{
|
||||
if ($checkresult[$block->id]) print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo'));
|
||||
}
|
||||
|
||||
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
|
||||
print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') );
|
||||
}
|
||||
print '</td>';
|
||||
print '</td>';
|
||||
|
||||
print '<td></td>';
|
||||
|
||||
@ -437,12 +523,11 @@ if (is_array($blocks))
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
// Javascript to manage the showinfo popup
|
||||
print '<script type="text/javascript">
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
@ -454,36 +539,19 @@ jQuery(document).ready(function () {
|
||||
|
||||
$("a[rel=show-info]").click(function() {
|
||||
|
||||
console.log("We click on tooltip");
|
||||
|
||||
jQuery("#dialogforpopup").html(\'<div id="pop-info"><table width="100%" height="80%" class="border"><thead><th width="50%">'.$langs->trans('Field').'</th><th>'.$langs->trans('Value').'</th></thead><tbody></tbody></table></div>\');
|
||||
console.log("We click on tooltip, we open popup and get content using an ajax call");
|
||||
|
||||
var fk_block = $(this).attr("data-blockid");
|
||||
|
||||
$.ajax({
|
||||
url:"../ajax/block-info.php?id="+fk_block
|
||||
,dataType:"json"
|
||||
,dataType:"html"
|
||||
}).done(function(data) {
|
||||
drawData(data,"");
|
||||
jQuery("#dialogforpopup").html(data);
|
||||
});
|
||||
|
||||
jQuery("#dialogforpopup").dialog("open");
|
||||
});
|
||||
|
||||
|
||||
function drawData(data, prefix) {
|
||||
for(x in data) {
|
||||
value = data[x];
|
||||
|
||||
if (typeof value != "object") {
|
||||
$("#pop-info table tbody").append("<tr><td>"+prefix+x+"</td><td class=\"wordwrap\">"+value+"</td></tr>");
|
||||
}
|
||||
if ((typeof value === "object") && (value !== null)) {
|
||||
drawData(value, prefix+x+" >> ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
</script>'."\n";
|
||||
|
||||
|
||||
@ -36,12 +36,77 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
|
||||
|
||||
$id = GETPOST('id');
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
$block = new BlockedLog($db);
|
||||
if ($block->fetch($id)>0) {
|
||||
echo json_encode($block->object_data);
|
||||
|
||||
if ((! $user->admin && ! $user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
print '<div id="pop-info"><table width="100%" height="80%" class="border"><thead><th width="50%" class="left">'.$langs->trans('Field').'</th><th class="left">'.$langs->trans('Value').'</th></thead>';
|
||||
print '<tbody>';
|
||||
|
||||
if ($block->fetch($id) > 0)
|
||||
{
|
||||
$objtoshow = $block->object_data;
|
||||
print formatObject($objtoshow, '');
|
||||
}
|
||||
else {
|
||||
echo json_encode(false);
|
||||
print 'Error, failed to get unalterable log with id '.$id;
|
||||
}
|
||||
|
||||
print '</tbody>';
|
||||
print '</table></div>';
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
/**
|
||||
* formatObject
|
||||
*
|
||||
* @param Object $objtoshow Object to show
|
||||
* @param string $prefix Prefix of key
|
||||
* @return string String formatted
|
||||
*/
|
||||
function formatObject($objtoshow, $prefix)
|
||||
{
|
||||
$s = '';
|
||||
|
||||
$newobjtoshow = $objtoshow;
|
||||
|
||||
if (is_object($newobjtoshow) || is_array($newobjtoshow))
|
||||
{
|
||||
//var_dump($newobjtoshow);
|
||||
foreach($newobjtoshow as $key => $val)
|
||||
{
|
||||
if (! is_object($val) && ! is_array($val))
|
||||
{
|
||||
$s.='<tr><td>'.($prefix?$prefix.' > ':'').$key.'</td>';
|
||||
$s.='<td>';
|
||||
if (in_array($key, array('date','datef')))
|
||||
{
|
||||
$s.=dol_print_date($val, 'dayhour');
|
||||
}
|
||||
else
|
||||
{
|
||||
$s.=$val;
|
||||
}
|
||||
$s.='</td></tr>';
|
||||
}
|
||||
elseif (is_array($val))
|
||||
{
|
||||
$s.=formatObject($val, ($prefix?$prefix.' > ':'').$key);
|
||||
}
|
||||
elseif (is_object($val))
|
||||
{
|
||||
$s.=formatObject($val, ($prefix?$prefix.' > ':'').$key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
@ -149,11 +149,10 @@ class BlockedLog
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY']='logMEMBER_SUBSCRIPTION_MODIFY';
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE']='logMEMBER_SUBSCRIPTION_DELETE';
|
||||
|
||||
/*
|
||||
$trackedevents['PAYMENT_VARIOUS_CREATE']='BlockedLogVariousPaymentCreate';
|
||||
$trackedevents['PAYMENT_VARIOUS_MODIFY']='BlockedLogVariousPaymentModify';
|
||||
$trackedevents['PAYMENT_VARIOUS_DELETE']='BlockedLogVariousPaymentDelete';
|
||||
*/
|
||||
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logPAYMENT_VARIOUS_CREATE';
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logPAYMENT_VARIOUS_MODIFY';
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logPAYMENT_VARIOUS_DELETE';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,6 +217,17 @@ class BlockedLog
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
else if($this->element === 'payment_various') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
|
||||
|
||||
$object = new PaymentVarious($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
else if($this->element === 'don' || $this->element === 'donation') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
|
||||
@ -299,7 +309,7 @@ class BlockedLog
|
||||
{
|
||||
$this->date_object = $object->datev;
|
||||
}
|
||||
elseif ($object->element == 'payment_donation')
|
||||
elseif ($object->element == 'payment_donation' || $object->element == 'payment_various')
|
||||
{
|
||||
$this->date_object = $object->datepaid?$object->datepaid:$object->datep;
|
||||
}
|
||||
@ -363,9 +373,27 @@ class BlockedLog
|
||||
{
|
||||
if (in_array($key, array('fields'))) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'ref','facnumber','ref_client','ref_supplier','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public'
|
||||
'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value)) $this->object_data->{$key} = $value;
|
||||
if ($key == 'lines')
|
||||
{
|
||||
$lineid=0;
|
||||
foreach($value as $tmpline) // $tmpline is object FactureLine
|
||||
{
|
||||
$lineid++;
|
||||
foreach($tmpline as $keyline => $valueline)
|
||||
{
|
||||
if (! in_array($keyline, array(
|
||||
'ref','multicurrency_code','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','qty','product_type','vat_src_code','tva_tx','info_bits','localtax1_tx','localtax2_tx','total_ht','total_tva','total_ttc','total_localtax1','total_localtax2'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
|
||||
if (! is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass();
|
||||
|
||||
$this->object_data->invoiceline[$lineid]->{$keyline} = $valueline;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!is_object($value)) $this->object_data->{$key} = $value;
|
||||
}
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
@ -376,28 +404,33 @@ class BlockedLog
|
||||
{
|
||||
if (in_array($key, array('fields'))) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'ref','facnumber','ref_client','ref_supplier','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public'
|
||||
'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value)) $this->object_data->{$key} = $value;
|
||||
}
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
}
|
||||
elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation')
|
||||
elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various')
|
||||
{
|
||||
$datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep);
|
||||
$paymenttypeid = $object->paiementid?$object->paiementid:$object->paymenttype;
|
||||
$paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment);
|
||||
|
||||
$this->object_data->ref = $object->ref;
|
||||
$this->object_data->date = $datepayment;
|
||||
$this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code');
|
||||
$this->object_data->payment_num = $object->num_paiement;
|
||||
$this->object_data->payment_num = ($object->num_paiement?$object->num_paiement:$object->num_payment);
|
||||
//$this->object_data->fk_account = $object->fk_account;
|
||||
$this->object_data->note = $object->note;
|
||||
//var_dump($this->object_data);exit;
|
||||
|
||||
$totalamount=0;
|
||||
|
||||
if (! is_array($object->amounts) && $object->amount)
|
||||
{
|
||||
$object->amounts=array($object->id => $object->amount);
|
||||
}
|
||||
|
||||
$paymentpartnumber=0;
|
||||
foreach($object->amounts as $objid => $amount)
|
||||
{
|
||||
@ -421,26 +454,41 @@ class BlockedLog
|
||||
include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
$tmpobject = new Don($this->db);
|
||||
}
|
||||
elseif ($this->element == 'payment_various')
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
|
||||
$tmpobject = new PaymentVarious($this->db);
|
||||
}
|
||||
|
||||
if (! is_object($tmpobject))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = $tmpobject->fetch($objid);
|
||||
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error = $tmpobject->error;
|
||||
$this->errors = $tmpobject->errors;
|
||||
dol_syslog("Failed to fetch object with id ".$objid, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$paymentpart = new stdClass();
|
||||
$paymentpart->amount = $amount;
|
||||
|
||||
if ($this->element != 'payment_donation')
|
||||
if (! in_array($this->element, array('payment_donation', 'payment_various')))
|
||||
{
|
||||
$result = $tmpobject->fetch_thirdparty();
|
||||
if ($result <= 0)
|
||||
if ($result == 0)
|
||||
{
|
||||
$this->error='Failed to fetch thirdparty for object with id '.$tmpobject->id;
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
elseif ($result < 0)
|
||||
{
|
||||
$this->error = $tmpobject->error;
|
||||
$this->errors = $tmpobject->errors;
|
||||
@ -463,21 +511,25 @@ class BlockedLog
|
||||
if ($this->element == 'payment_donation') $paymentpart->donation = new stdClass();
|
||||
else $paymentpart->invoice = new stdClass();
|
||||
|
||||
foreach($tmpobject as $key=>$value)
|
||||
if ($this->element != 'payment_various')
|
||||
{
|
||||
if (in_array($key, array('fields'))) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'ref','facnumber','ref_client','ref_supplier','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value))
|
||||
foreach($tmpobject as $key=>$value)
|
||||
{
|
||||
if ($this->element == 'payment_donation') $paymentpart->donation->{$key} = $value;
|
||||
else $paymentpart->invoice->{$key} = $value;
|
||||
if (in_array($key, array('fields'))) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value))
|
||||
{
|
||||
if ($this->element == 'payment_donation') $paymentpart->donation->{$key} = $value;
|
||||
elseif ($this->element == 'payment_various') $paymentpart->various->{$key} = $value;
|
||||
else $paymentpart->invoice->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$paymentpartnumber++;
|
||||
$this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
|
||||
$paymentpartnumber++; // first payment will be 1
|
||||
$this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
|
||||
}
|
||||
}
|
||||
|
||||
$this->object_data->amount = $totalamount;
|
||||
@ -724,7 +776,9 @@ class BlockedLog
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string for signature
|
||||
* Return a string for signature.
|
||||
* Note: rowid of line not included as it is not a business data and this allow to make backup of a year
|
||||
* and restore it into another database with different id wihtout comprimising checksums
|
||||
*
|
||||
* @return string Key for signature
|
||||
*/
|
||||
|
||||
@ -825,7 +825,7 @@ class Categorie extends CommonObject
|
||||
$sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type];
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c";
|
||||
$sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o";
|
||||
$sql .= " WHERE o.entity IN (" . getEntity( $obj->element, 1).")";
|
||||
$sql .= " WHERE o.entity IN (" . getEntity( $obj->element).")";
|
||||
$sql.= " AND c.fk_categorie = ".$this->id;
|
||||
$sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid";
|
||||
|
||||
@ -896,10 +896,14 @@ class Categorie extends CommonObject
|
||||
|
||||
$sub_type = $type;
|
||||
$subcol_name = "fk_".$type;
|
||||
if ($type=="customer" || $type=="supplier") {
|
||||
if ($type=="customer") {
|
||||
$sub_type="societe";
|
||||
$subcol_name="fk_soc";
|
||||
}
|
||||
if ($type=="supplier") {
|
||||
$sub_type="fournisseur";
|
||||
$subcol_name="fk_soc";
|
||||
}
|
||||
if ($type=="contact") {
|
||||
$subcol_name="fk_socpeople";
|
||||
}
|
||||
@ -1066,7 +1070,7 @@ class Categorie extends CommonObject
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
|
||||
$sql .= " WHERE c.entity IN (" . getEntity( 'category', 1 ) . ")";
|
||||
$sql .= " WHERE c.entity IN (" . getEntity( 'category') . ")";
|
||||
$sql .= " AND c.type = " . $type;
|
||||
|
||||
dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG);
|
||||
@ -1481,7 +1485,7 @@ class Categorie extends CommonObject
|
||||
$sql = "SELECT ct.fk_categorie, c.label, c.rowid";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c";
|
||||
$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . (int) $id . " AND c.type = " . $this->MAP_ID[$type];
|
||||
$sql .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")";
|
||||
$sql .= " AND c.entity IN (" . getEntity( 'category') . ")";
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
@ -1542,7 +1546,7 @@ class Categorie extends CommonObject
|
||||
// Generation requete recherche
|
||||
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie";
|
||||
$sql .= " WHERE type = " . $this->MAP_ID[$type];
|
||||
$sql .= " AND entity IN (" . getEntity( 'category', 1 ) . ")";
|
||||
$sql .= " AND entity IN (" . getEntity( 'category') . ")";
|
||||
if ($nom)
|
||||
{
|
||||
if (! $exact)
|
||||
|
||||
@ -67,13 +67,14 @@ $extrafields = new ExtraFields($db);
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('categorycard'));
|
||||
$hookmanager->initHooks(array('categorycard','globalcard'));
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
// Remove element from category
|
||||
if ($id > 0 && $removeelem > 0)
|
||||
{
|
||||
@ -353,7 +354,7 @@ if ($type == Categorie::TYPE_PRODUCT)
|
||||
|
||||
print "<br>";
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("ProductsAndServices")."</td></tr>\n";
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("ProductsAndServices")." (".count($prods).")</td></tr>\n";
|
||||
|
||||
if (count($prods) > 0)
|
||||
{
|
||||
@ -402,7 +403,7 @@ if ($type == Categorie::TYPE_SUPPLIER)
|
||||
{
|
||||
print "<br>";
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Suppliers")."</td></tr>\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Suppliers")." (".count($socs).")</td></tr>\n";
|
||||
|
||||
if (count($socs) > 0)
|
||||
{
|
||||
@ -451,7 +452,7 @@ if($type == Categorie::TYPE_CUSTOMER)
|
||||
{
|
||||
print "<br>";
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Customers")."</td></tr>\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Customers")." (".count($socs).")</td></tr>\n";
|
||||
|
||||
if (count($socs) > 0)
|
||||
{
|
||||
@ -507,7 +508,7 @@ if ($type == Categorie::TYPE_MEMBER)
|
||||
{
|
||||
print "<br>";
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Member")."</td></tr>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Member")." (".count($prods).")</td></tr>\n";
|
||||
|
||||
if (count($prods) > 0)
|
||||
{
|
||||
@ -558,7 +559,7 @@ if ($type == Categorie::TYPE_CONTACT)
|
||||
{
|
||||
print "<br>";
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Contact")."</td></tr>\n";
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Contact")." (".count($contacts).")</td></tr>\n";
|
||||
|
||||
if (count($contacts) > 0)
|
||||
{
|
||||
@ -613,7 +614,7 @@ if ($type == Categorie::TYPE_ACCOUNT)
|
||||
{
|
||||
print "<br>";
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Account")."</td></tr>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Account")." (".count($accounts).")</td></tr>\n";
|
||||
|
||||
if (count($accounts) > 0)
|
||||
{
|
||||
@ -666,7 +667,7 @@ if ($type == Categorie::TYPE_PROJECT)
|
||||
{
|
||||
print "<br>";
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Project")."</td></tr>\n";
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Project")." (".count($projects).")</td></tr>\n";
|
||||
|
||||
if (count($projects) > 0)
|
||||
{
|
||||
|
||||
@ -1048,7 +1048,7 @@ class ActionComm extends CommonObject
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay = $conf->agenda->warning_delay/60/60/24;
|
||||
$response->label = $langs->trans("ActionsToDo");
|
||||
$response->url = DOL_URL_ROOT.'/comm/action/list.php?status=todo&mainmenu=agenda';
|
||||
$response->url = DOL_URL_ROOT.'/comm/action/list.php?actioncode=0&status=todo&mainmenu=agenda';
|
||||
if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1';
|
||||
$response->img = img_object('',"action",'class="inline-block valigntextmiddle"');
|
||||
}
|
||||
@ -1633,6 +1633,7 @@ class ActionComm extends CommonObject
|
||||
|
||||
if (empty($conf->global->AGENDA_REMINDER_EMAIL))
|
||||
{
|
||||
$langs->load("agenda");
|
||||
$this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -140,6 +140,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -353,15 +354,15 @@ if ($resql)
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
$nav='';
|
||||
if ($optioncss != '') $nav.= '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
//if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
|
||||
if ($resourceid) $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">';
|
||||
if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
|
||||
if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
|
||||
if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
|
||||
if ($showbirthday) $nav.='<input type="hidden" name="showbirthday" value="1">';
|
||||
if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">';
|
||||
if ($usergroup) $nav.='<input type="hidden" name="usergroup" value="'.$usergroup.'">';
|
||||
|
||||
//if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
|
||||
//if ($resourceid) $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">';
|
||||
if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
|
||||
if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
|
||||
//if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
|
||||
if ($showbirthday) $nav.='<input type="hidden" name="showbirthday" value="1">';
|
||||
//if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">';
|
||||
//if ($usergroup) $nav.='<input type="hidden" name="usergroup" value="'.$usergroup.'">';
|
||||
print $nav;
|
||||
|
||||
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
|
||||
|
||||
@ -177,6 +177,15 @@ if (empty($reshook))
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// update order min amount
|
||||
if ($action == 'setorder_min_amount')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->order_min_amount=GETPOST('order_min_amount');
|
||||
$result=$object->update($object->id, $user);
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
if ($action == 'update_extras') {
|
||||
$object->fetch($id);
|
||||
|
||||
@ -211,7 +220,7 @@ if ($id > 0 && empty($object->id))
|
||||
{
|
||||
// Load data of third party
|
||||
$res=$object->fetch($id);
|
||||
if ($object->id <= 0) dol_print_error($db,$object->error,$object->errors);
|
||||
if ($object->id < 0) dol_print_error($db, $object->error, $object->errors);
|
||||
}
|
||||
|
||||
$title=$langs->trans("CustomerCard");
|
||||
@ -220,7 +229,7 @@ $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('',$title,$help_url);
|
||||
|
||||
|
||||
if ($id > 0)
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
@ -401,10 +410,20 @@ if ($id > 0)
|
||||
print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
|
||||
//if (empty($object->outstanding_limit)) print $langs->trans("NoLimit");
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="nowrap">';
|
||||
print '<td>';
|
||||
print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
// Multiprice level
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
{
|
||||
@ -549,7 +568,7 @@ if ($id > 0)
|
||||
$outstandingTotal=$tmp['total_ht'];
|
||||
$outstandingTotalIncTax=$tmp['total_ttc'];
|
||||
$text=$langs->trans("OverAllProposals");
|
||||
$link='';
|
||||
$link=DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id;
|
||||
$icon='bill';
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
@ -561,13 +580,13 @@ if ($id > 0)
|
||||
|
||||
if (! empty($conf->commande->enabled))
|
||||
{
|
||||
// Box proposals
|
||||
// Box commandes
|
||||
$tmp = $object->getOutstandingOrders();
|
||||
$outstandingOpened=$tmp['opened'];
|
||||
$outstandingTotal=$tmp['total_ht'];
|
||||
$outstandingTotalIncTax=$tmp['total_ttc'];
|
||||
$text=$langs->trans("OverAllOrders");
|
||||
$link='';
|
||||
$link=DOL_URL_ROOT.'/commande/list.php?socid='.$object->id;
|
||||
$icon='bill';
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
@ -579,12 +598,13 @@ if ($id > 0)
|
||||
|
||||
if (! empty($conf->facture->enabled))
|
||||
{
|
||||
// Box factures
|
||||
$tmp = $object->getOutstandingBills();
|
||||
$outstandingOpened=$tmp['opened'];
|
||||
$outstandingTotal=$tmp['total_ht'];
|
||||
$outstandingTotalIncTax=$tmp['total_ttc'];
|
||||
$text=$langs->trans("OverAllInvoices");
|
||||
$link='';
|
||||
$link=DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id;
|
||||
$icon='bill';
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
@ -773,7 +793,7 @@ if ($id > 0)
|
||||
}
|
||||
|
||||
/*
|
||||
* Last sendings
|
||||
* Last shipments
|
||||
*/
|
||||
if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
|
||||
$sendingstatic = new Expedition($db);
|
||||
@ -1245,7 +1265,7 @@ if ($id > 0)
|
||||
|
||||
print '</div>';
|
||||
|
||||
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
|
||||
if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD))
|
||||
{
|
||||
// List of contacts
|
||||
show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
@ -1271,7 +1291,8 @@ if ($id > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db,'Bad value for socid parameter');
|
||||
$langs->load("errors");
|
||||
print $langs->trans('ErrorRecordNotFound');
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
@ -470,7 +470,7 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.client IN (1, 2, 3)";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND s.rowid = $socid";
|
||||
$sql .= " ORDER BY s.tms DESC";
|
||||
@ -534,7 +534,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.fournisseur = 1";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY s.datec DESC";
|
||||
|
||||
@ -156,6 +156,7 @@ if (empty($reshook))
|
||||
$sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id;
|
||||
$sql .= " ORDER BY mc.statut DESC"; // first status 0, then status -1
|
||||
|
||||
dol_syslog("card.php: select targets", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
@ -840,7 +841,7 @@ else
|
||||
if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings');
|
||||
$_GET["action"]='';
|
||||
}
|
||||
else if ($conf->global->MAILING_LIMIT_SENDBYWEB == '-1')
|
||||
else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
|
||||
{
|
||||
if (! empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings');
|
||||
if (! empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings');
|
||||
@ -875,7 +876,16 @@ else
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlright='';
|
||||
if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
|
||||
$nbtry = $nbok = 0;
|
||||
if ($object->statut == 2 || $object->statut == 3)
|
||||
{
|
||||
$nbtry = $object->countNbOfTargets('alreadysent');
|
||||
$nbko = $object->countNbOfTargets('alreadysentko');
|
||||
|
||||
$morehtmlright.=' ('.$nbtry.'/'.$object->nbemail;
|
||||
if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error");
|
||||
$morehtmlright.=') ';
|
||||
}
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
|
||||
|
||||
@ -903,11 +913,11 @@ else
|
||||
print '<tr><td>';
|
||||
print $langs->trans("TotalNbOfDistinctRecipients");
|
||||
print '</td><td colspan="3">';
|
||||
$nbemail = ($object->nbemail?$object->nbemail:img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>');
|
||||
if ($object->statut != 3 && is_numeric($nbemail))
|
||||
$nbemail = ($object->nbemail?$object->nbemail:0);
|
||||
if (is_numeric($nbemail))
|
||||
{
|
||||
$text='';
|
||||
if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
|
||||
if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
|
||||
{
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
|
||||
{
|
||||
@ -915,9 +925,10 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
$text.=$langs->trans('NotEnoughPermissions');
|
||||
$text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed');
|
||||
}
|
||||
}
|
||||
if (empty($nbemail)) $nbemail.=' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
|
||||
if ($text)
|
||||
{
|
||||
print $form->textwithpicto($nbemail,$text,1,'warning');
|
||||
@ -1008,7 +1019,11 @@ else
|
||||
|
||||
if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider)
|
||||
{
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0 || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send))
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("SendingFromWebInterfaceIsNotAllowed")).'">'.$langs->trans("SendMailing").'</a>';
|
||||
}
|
||||
else if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send)
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("SendMailing").'</a>';
|
||||
}
|
||||
@ -1183,15 +1198,30 @@ else
|
||||
print '<tr><td>';
|
||||
print $langs->trans("TotalNbOfDistinctRecipients");
|
||||
print '</td><td colspan="3">';
|
||||
$nbemail = ($object->nbemail?$object->nbemail:img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>');
|
||||
if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && is_numeric($nbemail) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
|
||||
$nbemail = ($object->nbemail?$object->nbemail:0);
|
||||
if (is_numeric($nbemail))
|
||||
{
|
||||
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
|
||||
print $form->textwithpicto($nbemail,$text,1,'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
print $nbemail;
|
||||
$text='';
|
||||
if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2))
|
||||
{
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
|
||||
{
|
||||
$text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
|
||||
}
|
||||
else
|
||||
{
|
||||
$text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed');
|
||||
}
|
||||
}
|
||||
if (empty($nbemail)) $nbemail.=' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
|
||||
if ($text)
|
||||
{
|
||||
print $form->textwithpicto($nbemail,$text,1,'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
print $nbemail;
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
@ -171,6 +171,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans("Mailing"),'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing');
|
||||
|
||||
$form = new Form($db);
|
||||
@ -185,7 +186,16 @@ if ($object->fetch($id) >= 0)
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlright='';
|
||||
if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
|
||||
$nbtry = $nbok = 0;
|
||||
if ($object->statut == 2 || $object->statut == 3)
|
||||
{
|
||||
$nbtry = $object->countNbOfTargets('alreadysent');
|
||||
$nbko = $object->countNbOfTargets('alreadysentko');
|
||||
|
||||
$morehtmlright.=' ('.$nbtry.'/'.$object->nbemail;
|
||||
if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error");
|
||||
$morehtmlright.=') ';
|
||||
}
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
|
||||
|
||||
@ -206,15 +216,30 @@ if ($object->fetch($id) >= 0)
|
||||
print '<tr><td>';
|
||||
print $langs->trans("TotalNbOfDistinctRecipients");
|
||||
print '</td><td colspan="3">';
|
||||
$nbemail = ($object->nbemail?$object->nbemail:'0');
|
||||
if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && ($conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2))
|
||||
$nbemail = ($object->nbemail?$object->nbemail:0);
|
||||
if (is_numeric($nbemail))
|
||||
{
|
||||
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
|
||||
print $form->textwithpicto($nbemail,$text,1,'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
print $nbemail;
|
||||
$text='';
|
||||
if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
|
||||
{
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
|
||||
{
|
||||
$text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
|
||||
}
|
||||
else
|
||||
{
|
||||
$text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed');
|
||||
}
|
||||
}
|
||||
if (empty($nbemail)) $nbemail.=' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
|
||||
if ($text)
|
||||
{
|
||||
print $form->textwithpicto($nbemail,$text,1,'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
print $nbemail;
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -411,6 +436,8 @@ if ($object->fetch($id) >= 0)
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$param = "&id=".$object->id;
|
||||
//if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||
if ($search_lastname) $param.= "&search_lastname=".urlencode($search_lastname);
|
||||
if ($search_firstname) $param.= "&search_firstname=".urlencode($search_firstname);
|
||||
if ($search_email) $param.= "&search_email=".urlencode($search_email);
|
||||
@ -552,7 +579,7 @@ if ($object->fetch($id) >= 0)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Statut pour l'email destinataire (Attentioon != statut du mailing)
|
||||
// Status of recipient sending email (Warning != status of emailing)
|
||||
if ($obj->statut == 0)
|
||||
{
|
||||
print '<td align="center"> </td>';
|
||||
@ -563,18 +590,22 @@ if ($object->fetch($id) >= 0)
|
||||
{
|
||||
print '<td align="center">'.$obj->date_envoi.'</td>';
|
||||
print '<td align="right" class="nowrap">';
|
||||
print $object::libStatutDest($obj->statut,2,$obj->error_text);
|
||||
print $object::libStatutDest($obj->statut, 2, $obj->error_text);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Search Icon
|
||||
print '<td align="right">';
|
||||
if ($obj->statut == 0)
|
||||
if ($obj->statut == 0) // Not sent yet
|
||||
{
|
||||
if ($user->rights->mailing->creer && $allowaddtarget) {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient"));
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
|
||||
}
|
||||
}
|
||||
/*if ($obj->statut == -1) // Sent with error
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
|
||||
}*/
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ class Mailing extends CommonObject
|
||||
public $element='mailing';
|
||||
public $table_element='mailing';
|
||||
public $picto='email';
|
||||
|
||||
|
||||
var $titre;
|
||||
var $sujet;
|
||||
var $body;
|
||||
@ -43,7 +43,7 @@ class Mailing extends CommonObject
|
||||
var $bgimage;
|
||||
|
||||
var $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
|
||||
|
||||
|
||||
var $email_from;
|
||||
var $email_replyto;
|
||||
var $email_errorsto;
|
||||
@ -431,7 +431,7 @@ class Mailing extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete targets emailing
|
||||
*
|
||||
@ -481,11 +481,11 @@ class Mailing extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Count number of target with status
|
||||
*
|
||||
* @param string $mode Mode ('alreadysent' = Sent success or error)
|
||||
* @param string $mode Mode ('alreadysent' = Sent success or error, 'alreadysentok' = Sent success, 'alreadysentko' = Sent error)
|
||||
* @return int Nb of target with status
|
||||
*/
|
||||
function countNbOfTargets($mode)
|
||||
@ -493,12 +493,14 @@ class Mailing extends CommonObject
|
||||
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql.= " WHERE fk_mailing = ".$this->id;
|
||||
if ($mode == 'alreadysent') $sql.= " AND statut <> 0";
|
||||
else
|
||||
elseif ($mode == 'alreadysentok') $sql.= " AND statut > 0";
|
||||
elseif ($mode == 'alreadysentko') $sql.= " AND statut = -1";
|
||||
else
|
||||
{
|
||||
$this->error='BadValueForParameterMode';
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -512,10 +514,10 @@ class Mailing extends CommonObject
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retourne le libelle du statut d'un mailing (brouillon, validee, ...
|
||||
* Return label of status of emailing (draft, validated, ...)
|
||||
*
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
|
||||
* @return string Label
|
||||
|
||||
@ -104,8 +104,11 @@ if ($id > 0 || ! empty($ref)) {
|
||||
$ret = $object->fetch($id, $ref);
|
||||
if ($ret > 0)
|
||||
$ret = $object->fetch_thirdparty();
|
||||
if ($ret < 0)
|
||||
dol_print_error('', $object->error);
|
||||
if ($ret <= 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
@ -1711,7 +1714,7 @@ if ($action == 'create')
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
} else {
|
||||
} elseif ($object->id > 0) {
|
||||
/*
|
||||
* Show object in view mode
|
||||
*/
|
||||
@ -1818,7 +1821,6 @@ if ($action == 'create')
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1);
|
||||
@ -2130,6 +2132,22 @@ if ($action == 'create')
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$tmparray=$object->getTotalWeightVolume();
|
||||
$totalWeight=$tmparray['weight'];
|
||||
$totalVolume=$tmparray['volume'];
|
||||
if ($totalWeight) {
|
||||
print '<tr><td>' . $langs->trans("CalculatedWeight") . '</td>';
|
||||
print '<td>';
|
||||
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
|
||||
print '</td></tr>';
|
||||
}
|
||||
if ($totalVolume) {
|
||||
print '<tr><td>' . $langs->trans("CalculatedVolume") . '</td>';
|
||||
print '<td>';
|
||||
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Incoterms
|
||||
if (!empty($conf->incoterm->enabled))
|
||||
{
|
||||
|
||||
@ -41,15 +41,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
if (! empty($conf->projet->enabled))
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
$langs->load('companies');
|
||||
$langs->load('propal');
|
||||
$langs->load('compta');
|
||||
$langs->load('bills');
|
||||
$langs->load('orders');
|
||||
$langs->load('products');
|
||||
$langs->loadLangs(array('companies','propal','compta','bills','orders','products'));
|
||||
|
||||
$socid=GETPOST('socid','int');
|
||||
|
||||
@ -141,7 +135,7 @@ $checkedtypetiers=0;
|
||||
$arrayfields=array(
|
||||
'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
||||
'p.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
|
||||
'pr.ref'=>array('label'=>$langs->trans("Project"), 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
|
||||
'pr.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
|
||||
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
|
||||
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
|
||||
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
|
||||
@ -237,6 +231,7 @@ $formother = new FormOther($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formpropal = new FormPropal($db);
|
||||
$companystatic=new Societe($db);
|
||||
$projectstatic=new Project($db);
|
||||
$formcompany=new FormCompany($db);
|
||||
|
||||
$help_url='EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
|
||||
|
||||
@ -76,7 +76,7 @@ $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.fk_stcomm = st.id";
|
||||
$sql.= " AND s.client IN (2, 3)";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql.= " GROUP BY st.id";
|
||||
$sql.= " ORDER BY st.id";
|
||||
@ -96,7 +96,7 @@ if ($resql)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<a href="prospects.php?page=0&stcomm='.$obj->id.'">';
|
||||
print img_action($langs->trans("Show"),$obj->id).' ';
|
||||
@ -140,7 +140,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'</a>';
|
||||
print '</td><td align="right">';
|
||||
@ -150,7 +150,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||
$total += $obj->price;
|
||||
}
|
||||
if ($total>0) {
|
||||
|
||||
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td></tr>";
|
||||
}
|
||||
print "</table><br>";
|
||||
@ -205,7 +205,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<a href="../propal.php?id='.$obj->propalid.'">';
|
||||
print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'</a></td>';
|
||||
@ -243,7 +243,7 @@ $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.fk_stcomm = 1";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")";
|
||||
$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql.= " ORDER BY s.tms ASC";
|
||||
$sql.= $db->plimit(15, 0);
|
||||
@ -263,7 +263,7 @@ if ($resql)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td width="12%">';
|
||||
$companystatic->id=$obj->socid;
|
||||
$companystatic->name=$obj->name;
|
||||
|
||||
@ -2300,12 +2300,15 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
$tmparray=$object->getTotalWeightVolume();
|
||||
$totalWeight=$tmparray['weight'];
|
||||
$totalVolume=$tmparray['volume'];
|
||||
if ($totalWeight || $totalVolume)
|
||||
if ($totalWeight)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>';
|
||||
print '<td>';
|
||||
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
|
||||
print '</td></tr>';
|
||||
}
|
||||
if ($totalVolume)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>';
|
||||
print '<td>';
|
||||
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
|
||||
@ -2388,8 +2391,12 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
}
|
||||
|
||||
// Total HT
|
||||
$alert = '';
|
||||
if($object->total_ht < $object->thirdparty->order_min_amount) {
|
||||
$alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount));
|
||||
}
|
||||
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
|
||||
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>';
|
||||
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . $alert . '</td>';
|
||||
|
||||
// Total VAT
|
||||
print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
|
||||
|
||||
@ -153,6 +153,7 @@ class Orders extends DolibarrApi
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
$i=0;
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
@ -276,7 +277,7 @@ class Orders extends DolibarrApi
|
||||
$request_data->product_type,
|
||||
$request_data->rang,
|
||||
$request_data->special_code,
|
||||
$fk_parent_line,
|
||||
$request_data->fk_parent_line,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
@ -424,14 +425,6 @@ class Orders extends DolibarrApi
|
||||
if ($this->commande->availability($this->commande->availability_id) < 0)
|
||||
throw new RestException(400, 'Error while updating availability');
|
||||
}
|
||||
// update bank account
|
||||
if(!empty($this->commande->fk_account))
|
||||
{
|
||||
if($this->commande->setBankAccount($this->commande->fk_account) == 0)
|
||||
{
|
||||
throw new RestException(400,$this->commande->error);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->commande->update(DolibarrApiAccess::$user) > 0)
|
||||
{
|
||||
@ -479,7 +472,7 @@ class Orders extends DolibarrApi
|
||||
/**
|
||||
* Validate an order
|
||||
*
|
||||
* If you get a bad value for param notrigger check that ou provide this in body
|
||||
* If you get a bad value for param notrigger check, provide this in body
|
||||
* {
|
||||
* "idwarehouse": 0,
|
||||
* "notrigger": 0
|
||||
|
||||
@ -3036,6 +3036,8 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
function update(User $user, $notrigger=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
@ -3069,6 +3071,7 @@ class Commande extends CommonOrder
|
||||
$sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").",";
|
||||
$sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").",";
|
||||
$sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").",";
|
||||
$sql.= " fk_account=".($this->fk_account>0?$this->fk_account:"null").",";
|
||||
$sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
|
||||
$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
|
||||
$sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").",";
|
||||
|
||||
@ -383,11 +383,13 @@ if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPO
|
||||
if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int');
|
||||
if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb);
|
||||
if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty"));
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
$options = array();
|
||||
|
||||
$buttonreconcile = '';
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
@ -398,7 +400,6 @@ if ($id > 0 || ! empty($ref))
|
||||
// Load bank groups
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
|
||||
$bankcateg = new BankCateg($db);
|
||||
$options = array();
|
||||
|
||||
foreach ($bankcateg->fetchAll() as $bankcategory) {
|
||||
$options[$bankcategory->id] = $bankcategory->label;
|
||||
@ -421,18 +422,19 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
if ($action != 'reconcile')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
//print '<div class="tabsAction">';
|
||||
|
||||
if ($object->canBeConciliated() > 0) {
|
||||
if ($object->canBeConciliated() > 0)
|
||||
{
|
||||
// If not cash account and can be reconciliate
|
||||
if ($user->rights->banque->consolidate) {
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
|
||||
$buttonreconcile = '<a class="butAction" style="margin-bottom: 5px !important; margin-top: 5px !important" href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
$buttonreconcile = '<a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
//print '</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -531,7 +533,6 @@ dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=True;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
@ -569,14 +570,12 @@ if ($resql)
|
||||
// Form to reconcile
|
||||
if ($user->rights->banque->consolidate && $action == 'reconcile')
|
||||
{
|
||||
// print '<table class="noborder" width="100%">';
|
||||
// print '<tr '.$bcnd[false].'>';
|
||||
// print '<td>';
|
||||
print '<div class="valignmiddle inline-block" style="padding-right: 20px;">';
|
||||
print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
|
||||
print '<input class="flat" id="num_releve" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):'').'" size="10">'; // The only default value is value we just entered
|
||||
print '</div>';
|
||||
if ($options) {
|
||||
if (is_array($options) && count($options))
|
||||
{
|
||||
print $langs->trans("EventualyAddCategory").': ';
|
||||
print Form::selectarray('cat', $options, GETPOST('cat'), 1);
|
||||
}
|
||||
@ -589,7 +588,7 @@ if ($resql)
|
||||
$nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
|
||||
$liste="";
|
||||
$sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE fk_account=".$id." AND num_releve IS NOT NULL";
|
||||
$sql.= " WHERE fk_account=".$object->id." AND num_releve IS NOT NULL";
|
||||
$sql.= $db->order("num_releve","DESC");
|
||||
$sql.= $db->plimit($nbmax+1);
|
||||
print '<br><br>';
|
||||
@ -618,18 +617,17 @@ if ($resql)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
/**
|
||||
* Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not)
|
||||
*/
|
||||
if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE == 1) {
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
$("#num_releve").val("' . $last_releve . '");
|
||||
</script>
|
||||
';
|
||||
}
|
||||
print '<br><br>';
|
||||
// print '</td></tr></table>';
|
||||
|
||||
// Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not)
|
||||
if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE == 1)
|
||||
{
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
$("#num_releve").val("' . $last_releve . '");
|
||||
</script>
|
||||
';
|
||||
}
|
||||
print '<br><br>';
|
||||
}
|
||||
|
||||
// Form to add a transaction with no invoice
|
||||
@ -663,7 +661,8 @@ if ($resql)
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
print '<input name="label" class="flat minwidth200" type="text" value="'.GETPOST("label","alpha").'">';
|
||||
if (is_array($options) && count($options)) {
|
||||
if (is_array($options) && count($options))
|
||||
{
|
||||
print '<br>'.$langs->trans("Rubrique").': ';
|
||||
print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
|
||||
}
|
||||
@ -725,11 +724,6 @@ if ($resql)
|
||||
|
||||
// Title
|
||||
$bankcateg=new BankCateg($db);
|
||||
$morehtml='<div class="inline-block">';
|
||||
$morehtml.= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page ';
|
||||
$morehtml.='<input type="text" name="pageplusone" id="pageplusone" class="flat right width25" value="'.($page+1).'">';
|
||||
$morehtml.='/'.$nbtotalofpages.' ';
|
||||
$morehtml.='</div>';
|
||||
|
||||
$addbutton = '';
|
||||
if ($action != 'addline' && $action != 'reconcile')
|
||||
@ -758,6 +752,18 @@ if ($resql)
|
||||
$addbutton = '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$morehtml='<div class="inline-block '.(($buttonreconcile || $addbutton)?'marginrightonly':'').'">';
|
||||
$morehtml.= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page ';
|
||||
$morehtml.='<input type="text" name="pageplusone" id="pageplusone" class="flat right width25" value="'.($page+1).'">';
|
||||
$morehtml.='/'.$nbtotalofpages.' ';
|
||||
$morehtml.='</div>';
|
||||
|
||||
if ($action != 'addline' && $action != 'reconcile')
|
||||
{
|
||||
$morehtml.=$buttonreconcile;
|
||||
}
|
||||
|
||||
$morehtml.=$addbutton;
|
||||
|
||||
$picto='title_bank';
|
||||
@ -928,6 +934,7 @@ if ($resql)
|
||||
|
||||
$balance = 0; // For balance
|
||||
$balancecalculated = false;
|
||||
$posconciliatecol = 0;
|
||||
|
||||
// Loop on each record
|
||||
$sign = 1;
|
||||
@ -1015,7 +1022,7 @@ if ($resql)
|
||||
print '<td align="right">';
|
||||
print price(price2num($balance, 'MT'), 1, $langs);
|
||||
print '</td>';
|
||||
print '<td colspan="'.($tmpnbfieldafterbalance+2).'">';
|
||||
print '<td colspan="'.($tmpnbfieldafterbalance+3).'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
@ -1351,7 +1358,11 @@ if ($resql)
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! $i)
|
||||
{
|
||||
$totalarray['nbfield']++;
|
||||
$posconciliatecol = $totalarray['nbfield'];
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($arrayfields['b.conciliated']['checked']))
|
||||
@ -1434,6 +1445,12 @@ if ($resql)
|
||||
}
|
||||
elseif ($totalarray['totaldebfield'] == $i) print '<td align="right">'.price(-1 * $totalarray['totaldeb']).'</td>';
|
||||
elseif ($totalarray['totalcredfield'] == $i) print '<td align="right">'.price($totalarray['totalcred']).'</td>';
|
||||
elseif ($i == $posconciliatecol)
|
||||
{
|
||||
print '<td>';
|
||||
if ($user->rights->banque->consolidate && $action == 'reconcile') print '<input class="button" name="confirm_reconcile" type="submit" value="' . $langs->trans("Conciliate") . '">';
|
||||
print '</td>';
|
||||
}
|
||||
else print '<td></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
@ -34,6 +34,8 @@ class PaymentVarious extends CommonObject
|
||||
public $table_element='payment_various'; //!< Name of table without prefix where object is stored
|
||||
public $picto = 'bill';
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $tms;
|
||||
var $datep;
|
||||
var $datev;
|
||||
@ -87,8 +89,7 @@ class PaymentVarious extends CommonObject
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET";
|
||||
|
||||
$sql.= " tms='".$this->db->idate($this->tms)."',";
|
||||
if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',";
|
||||
$sql.= " datep='".$this->db->idate($this->datep)."',";
|
||||
$sql.= " datev='".$this->db->idate($this->datev)."',";
|
||||
$sql.= " sens=".$this->sens.",";
|
||||
@ -102,7 +103,6 @@ class PaymentVarious extends CommonObject
|
||||
$sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").",";
|
||||
$sql.= " fk_user_author=".$this->fk_user_author.",";
|
||||
$sql.= " fk_user_modif=".$this->fk_user_modif;
|
||||
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
@ -146,7 +146,6 @@ class PaymentVarious extends CommonObject
|
||||
global $langs;
|
||||
$sql = "SELECT";
|
||||
$sql.= " v.rowid,";
|
||||
|
||||
$sql.= " v.tms,";
|
||||
$sql.= " v.datep,";
|
||||
$sql.= " v.datev,";
|
||||
@ -164,7 +163,6 @@ class PaymentVarious extends CommonObject
|
||||
$sql.= " b.fk_account,";
|
||||
$sql.= " b.fk_type,";
|
||||
$sql.= " b.rappro";
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
|
||||
$sql.= " WHERE v.rowid = ".$id;
|
||||
@ -184,7 +182,7 @@ class PaymentVarious extends CommonObject
|
||||
$this->datev = $this->db->jdate($obj->datev);
|
||||
$this->sens = $obj->sens;
|
||||
$this->amount = $obj->amount;
|
||||
$this->type_payement = $obj->fk_typepayment;
|
||||
$this->type_payment = $obj->fk_typepayment;
|
||||
$this->num_payment = $obj->num_payment;
|
||||
$this->label = $obj->label;
|
||||
$this->note = $obj->note;
|
||||
@ -350,6 +348,7 @@ class PaymentVarious extends CommonObject
|
||||
if ($result)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various");
|
||||
$this->ref = $this->id;
|
||||
|
||||
if ($this->id > 0)
|
||||
{
|
||||
|
||||
@ -62,6 +62,7 @@ if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) acces
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
if ($backtopage)
|
||||
@ -108,10 +109,23 @@ if ($user->rights->banque->modifier && $action == "update")
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$ac = new Account($db);
|
||||
$ac->fetch($id);
|
||||
$acline = new AccountLine($db);
|
||||
$acline->fetch($rowid);
|
||||
|
||||
if ($ac->courant == Account::TYPE_CASH && $_POST['value'] != 'LIQ')
|
||||
$acsource = new Account($db);
|
||||
$acsource->fetch($id);
|
||||
|
||||
$actarget = new Account($db);
|
||||
if (GETPOST('accountid','int') > 0 && ! $acline->rappro && ! $acline->getVentilExportCompta()) // We ask to change bank account
|
||||
{
|
||||
$actarget->fetch(GETPOST('accountid','int'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$actarget->fetch($id);
|
||||
}
|
||||
|
||||
if ($actarget->courant == Account::TYPE_CASH && GETPOST('value','alpha') != 'LIQ')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors');
|
||||
$error++;
|
||||
@ -119,16 +133,6 @@ if ($user->rights->banque->modifier && $action == "update")
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche
|
||||
$conciliated=0;
|
||||
$sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid;
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$conciliated=$objp->rappro;
|
||||
}
|
||||
|
||||
$db->begin();
|
||||
|
||||
$amount = price2num($_POST['amount']);
|
||||
@ -142,15 +146,15 @@ if ($user->rights->banque->modifier && $action == "update")
|
||||
if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',";
|
||||
if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',";
|
||||
// Blocked when conciliated
|
||||
if (! $conciliated)
|
||||
if (! $acline->rappro)
|
||||
{
|
||||
if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',";
|
||||
if (isset($_POST['amount'])) $sql.=" amount='".$amount."',";
|
||||
if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',";
|
||||
if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',";
|
||||
}
|
||||
$sql.= " fk_account = ".$id;
|
||||
$sql.= " WHERE rowid = ".$rowid;
|
||||
$sql.= " fk_account = ".$actarget->id;
|
||||
$sql.= " WHERE rowid = ".$acline->id;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (! $result)
|
||||
@ -282,7 +286,7 @@ if ($result)
|
||||
$account = $acct->id;
|
||||
|
||||
$bankline = new AccountLine($db);
|
||||
$bankline->fetch($rowid,$ref);
|
||||
$bankline->fetch($rowid, $ref);
|
||||
|
||||
$links=$acct->get_url($rowid);
|
||||
$bankline->load_previous_next_ref('','rowid');
|
||||
@ -311,21 +315,19 @@ if ($result)
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
/*
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Ref")."</td>";
|
||||
print '<td>';
|
||||
print $form->showrefnav($bankline, 'rowid', $linkback, 1, 'rowid', 'rowid');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
|
||||
$i++;
|
||||
|
||||
// Bank account
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Account").'</td>';
|
||||
print '<td>';
|
||||
print $acct->getNomUrl(1,'transactions','reflabel');
|
||||
if (! $objp->rappro && ! $bankline->getVentilExportCompta())
|
||||
{
|
||||
print $form->select_comptes($acct->id, 'accountid', 0, '', 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $acct->getNomUrl(1,'transactions','reflabel');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ if ($action == 'add')
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$mesgs = $langs->trans("TransferFromToDone",'<a href="bankentries.php?id='.$accountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$accountfrom->label."</a>",'<a href="bankentries.php?id='.$accountto->id.'">'.$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
|
||||
$mesgs = $langs->trans("TransferFromToDone",'<a href="bankentries_list.php?id='.$accountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$accountfrom->label."</a>",'<a href="bankentries_list.php?id='.$accountto->id.'">'.$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
|
||||
setEventMessages($mesgs, null, 'mesgs');
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ $sens=GETPOST("sens","int");
|
||||
$amount=GETPOST("amount");
|
||||
$paymenttype=GETPOST("paymenttype");
|
||||
$accountancy_code=GETPOST("accountancy_code","int");
|
||||
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
||||
$projectid = (GETPOST('projectid','int') ? GETPOST('projectid', 'int') : GETPOST('fk_project','int'));
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid","int");
|
||||
@ -96,22 +96,23 @@ if (empty($reshook))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
|
||||
$datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
|
||||
$datep=dol_mktime(12,0,0, GETPOST("datepmonth",'int'), GETPOST("datepday",'int'), GETPOST("datepyear",'int'));
|
||||
$datev=dol_mktime(12,0,0, GETPOST("datevmonth",'int'), GETPOST("datevday",'int'), GETPOST("datevyear",'int'));
|
||||
if (empty($datev)) $datev=$datep;
|
||||
|
||||
$object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
|
||||
$object->ref=''; // TODO
|
||||
$object->accountid=GETPOST("accountid",'int') > 0 ? GETPOST("accountid","int") : 0;
|
||||
$object->datev=$datev;
|
||||
$object->datep=$datep;
|
||||
$object->amount=price2num(GETPOST("amount"));
|
||||
$object->label=GETPOST("label");
|
||||
$object->note=GETPOST("note");
|
||||
$object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0;
|
||||
$object->num_payment=GETPOST("num_payment");
|
||||
$object->amount=price2num(GETPOST("amount",'alpha'));
|
||||
$object->label=GETPOST("label",'none');
|
||||
$object->note=GETPOST("note",'none');
|
||||
$object->type_payment=GETPOST("paymenttype",'int') > 0 ? GETPOST("paymenttype", "int") : 0;
|
||||
$object->num_payment=GETPOST("num_payment",'alpha');
|
||||
$object->fk_user_author=$user->id;
|
||||
$object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : "";
|
||||
$object->sens=GETPOST('sens');
|
||||
$object->fk_project= GETPOST('fk_project');
|
||||
$object->fk_project= GETPOST('fk_project','int');
|
||||
|
||||
if (empty($datep) || empty($datev))
|
||||
{
|
||||
@ -411,7 +412,7 @@ if ($id)
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||
|
||||
// Payment date
|
||||
print "<tr>";
|
||||
|
||||
@ -108,21 +108,19 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.row
|
||||
$sql.= " WHERE v.entity IN (".getEntity('payment_various').")";
|
||||
|
||||
// Search criteria
|
||||
if ($search_ref) $sql.=" AND v.rowid=".$search_ref;
|
||||
if ($search_label) $sql.=natural_search(array('v.label'), $search_label);
|
||||
if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1);
|
||||
if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1);
|
||||
if ($search_account > 0) $sql.=" AND b.fk_account=".$search_account;
|
||||
if ($search_date) $sql.=" AND v.datep=".$search_date;
|
||||
if ($search_accountancy_code) $sql.=" AND v.accountancy_code=".$search_accountancy_code;
|
||||
|
||||
if ($search_ref) $sql.=" AND v.rowid=".$search_ref;
|
||||
if ($search_label) $sql.=natural_search(array('v.label'), $search_label);
|
||||
if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1);
|
||||
if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1);
|
||||
if ($search_account > 0) $sql.=" AND b.fk_account=".$search_account;
|
||||
if ($search_date) $sql.=" AND v.datep=".$search_date;
|
||||
if ($search_accountancy_code > 0) $sql.=" AND v.accountancy_code=".$search_accountancy_code;
|
||||
if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid;
|
||||
if ($filtre) {
|
||||
$filtre=str_replace(":","=",$filtre);
|
||||
$sql .= " AND ".$filtre;
|
||||
}
|
||||
if ($typeid) {
|
||||
$sql .= " AND v.fk_typepayment=".$typeid;
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
$totalnboflines=0;
|
||||
@ -142,10 +140,18 @@ if ($result)
|
||||
$var=true;
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($typeid) $param.='&typeid='.$typeid;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
|
||||
if ($search_label) $param.='&search_label='.urlencode($search_label);
|
||||
if ($typeid > 0) $param.='&typeid='.urlencode($typeid);
|
||||
if ($search_amount_deb) $param.='&search_amount_deb='.urlencode($search_amount_deb);
|
||||
if ($search_amount_cred) $param.='&search_amount_cred='.urlencode($search_amount_cred);
|
||||
if ($search_account > 0) $param.='&search_amount='.urlencode($search_account);
|
||||
//if ($search_date) $param.='&search_date='.$search_date;
|
||||
if ($search_accountancy_code > 0) $param.='&search_accountancy_code='.urlencode($search_accountancy_code);
|
||||
|
||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
||||
@ -162,18 +168,6 @@ if ($result)
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"v.rowid","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"v.label","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("PaymentMode",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
|
||||
if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccounting",$_SERVER["PHP_SELF"],"v.accountancy_code","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Debit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Credit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
// Ref
|
||||
@ -227,6 +221,20 @@ if ($result)
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"v.rowid","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"v.label","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("PaymentMode",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
|
||||
if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccounting",$_SERVER["PHP_SELF"],"v.accountancy_code","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Debit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Credit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
$totalarray=array();
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
|
||||
@ -217,6 +217,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -529,6 +530,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -606,7 +608,6 @@ if (empty($reshook))
|
||||
$result=$object->set_draft($user, $idwarehouse);
|
||||
if ($result<0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
|
||||
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
@ -617,6 +618,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -683,7 +685,7 @@ if (empty($reshook))
|
||||
$i = 0;
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
if ($line->total_ht!=0)
|
||||
if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9
|
||||
{ // no need to create discount if amount is null
|
||||
$amount_ht[$line->tva_tx] += $line->total_ht;
|
||||
$amount_tva[$line->tva_tx] += $line->total_tva;
|
||||
@ -1495,6 +1497,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -1570,7 +1573,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
||||
$error ++;
|
||||
}
|
||||
if ($prod_entry_mode == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not ''
|
||||
if ($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not ''
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
|
||||
$error ++;
|
||||
@ -1747,6 +1750,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
|
||||
$desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
|
||||
@ -1770,6 +1774,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
if (! empty($prod->customcode))
|
||||
$tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
|
||||
@ -1835,6 +1840,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -2012,6 +2018,7 @@ if (empty($reshook))
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -3047,10 +3054,10 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
}
|
||||
|
||||
// Confirmation de la validation
|
||||
// Confirmation of validation
|
||||
if ($action == 'valid')
|
||||
{
|
||||
// on verifie si l'objet est en numerotation provisoire
|
||||
// we check object has a draft number
|
||||
$objectref = substr($object->ref, 1, 4);
|
||||
if ($objectref == 'PROV') {
|
||||
$savdate = $object->date;
|
||||
|
||||
@ -60,30 +60,30 @@ class Invoices extends DolibarrApi
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
function get($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
$result = $this->invoice->fetch($id);
|
||||
if (! $result) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
// Get payment details
|
||||
$this->invoice->totalpaye = $this->invoice->getSommePaiement();
|
||||
$this->invoice->totalcreditnotes = $this->invoice->getSumCreditNotesUsed();
|
||||
$this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed();
|
||||
$this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT');
|
||||
// Get payment details
|
||||
$this->invoice->totalpaye = $this->invoice->getSommePaiement();
|
||||
$this->invoice->totalcreditnotes = $this->invoice->getSumCreditNotesUsed();
|
||||
$this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed();
|
||||
$this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT');
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
if (! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$this->invoice->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->invoice);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List invoices
|
||||
|
||||
@ -1163,9 +1163,9 @@ class Facture extends CommonInvoice
|
||||
$label.= '<br><b>' . $langs->trans('AmountHT') . ':</b> ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_tva))
|
||||
$label.= '<br><b>' . $langs->trans('VAT') . ':</b> ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_tva))
|
||||
if (! empty($this->total_localtax1))
|
||||
$label.= '<br><b>' . $langs->trans('LT1') . ':</b> ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_tva))
|
||||
if (! empty($this->total_localtax2))
|
||||
$label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
if (! empty($this->total_ttc))
|
||||
$label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
@ -3004,6 +3004,9 @@ class Facture extends CommonInvoice
|
||||
$line->total_ttc = $tabprice[2];
|
||||
$line->total_localtax1 = $tabprice[9];
|
||||
$line->total_localtax2 = $tabprice[10];
|
||||
$line->multicurrency_total_ht = $tabprice[16];
|
||||
$line->multicurrency_total_tva = $tabprice[17];
|
||||
$line->multicurrency_total_ttc = $tabprice[18];
|
||||
$line->update($user);
|
||||
$this->update_price(1);
|
||||
$this->db->commit();
|
||||
|
||||
@ -1057,7 +1057,7 @@ if ($action == 'create')
|
||||
print '<td class="tdtop">';
|
||||
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
|
||||
print '</td>';
|
||||
print '<td colspan="2">';
|
||||
print '<td>';
|
||||
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
|
||||
print $doleditor->Create(1);
|
||||
|
||||
@ -1068,7 +1068,7 @@ if ($action == 'create')
|
||||
print '<td class="tdtop">';
|
||||
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
|
||||
print '</td>';
|
||||
print '<td valign="top" colspan="2">';
|
||||
print '<td>';
|
||||
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
|
||||
print $doleditor->Create(1);
|
||||
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
|
||||
@ -1397,7 +1397,7 @@ else
|
||||
// Note public
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer);
|
||||
print '</td><td>';
|
||||
print '</td><td class="wordbreak">';
|
||||
print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -1405,7 +1405,7 @@ else
|
||||
// Note private
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
|
||||
print '</td><td>';
|
||||
print '</td><td class="wordbreak">';
|
||||
print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -46,8 +46,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
|
||||
$langs->load('bills');
|
||||
$langs->load('companies');
|
||||
@ -72,6 +73,7 @@ $search_product_category=GETPOST('search_product_category','int');
|
||||
$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
|
||||
$search_refcustomer=GETPOST('search_refcustomer','alpha');
|
||||
$search_type=GETPOST('search_type','int');
|
||||
$search_project=GETPOST('search_project','alpha');
|
||||
$search_societe=GETPOST('search_societe','alpha');
|
||||
$search_montant_ht=GETPOST('search_montant_ht','alpha');
|
||||
$search_montant_vat=GETPOST('search_montant_vat','alpha');
|
||||
@ -151,6 +153,7 @@ $arrayfields=array(
|
||||
'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0),
|
||||
'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1),
|
||||
'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1),
|
||||
'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
|
||||
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
|
||||
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
|
||||
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
|
||||
@ -160,8 +163,8 @@ $arrayfields=array(
|
||||
'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1),
|
||||
'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
|
||||
'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
|
||||
'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj=="1"),
|
||||
'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj=="1"),
|
||||
'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")),
|
||||
'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1")),
|
||||
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
|
||||
'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0),
|
||||
'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0),
|
||||
@ -362,7 +365,8 @@ $sql.= ' f.datec as date_creation, f.tms as date_update,';
|
||||
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
|
||||
$sql.= " typent.code as typent_code,";
|
||||
$sql.= " state.code_departement as state_code, state.nom as state_name,";
|
||||
$sql.= " country.code as country_code";
|
||||
$sql.= " country.code as country_code,";
|
||||
$sql.= " p.rowid as project_id, p.ref as project_ref";
|
||||
// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
|
||||
// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
|
||||
if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
|
||||
@ -381,6 +385,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
|
||||
if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture';
|
||||
if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet";
|
||||
// We'll need this table joined to the select in order to filter by sale
|
||||
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if ($search_user > 0)
|
||||
@ -488,7 +493,8 @@ if (! $sall)
|
||||
$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
|
||||
$sql.= ' typent.code,';
|
||||
$sql.= ' state.code_departement, state.nom,';
|
||||
$sql.= ' country.code';
|
||||
$sql.= ' country.code,';
|
||||
$sql.= " p.rowid, p.ref";
|
||||
|
||||
foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by
|
||||
{
|
||||
@ -714,12 +720,12 @@ if ($resql)
|
||||
// Project
|
||||
if (! empty($arrayfields['p.ref']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_project" value="'.$search_project.'"></td>';
|
||||
print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_project" value="'.$search_project.'"></td>';
|
||||
}
|
||||
// Thirpdarty
|
||||
if (! empty($arrayfields['s.nom']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_societe" value="'.$search_societe.'"></td>';
|
||||
print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_societe" value="'.$search_societe.'"></td>';
|
||||
}
|
||||
// Town
|
||||
if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
|
||||
@ -838,6 +844,7 @@ if ($resql)
|
||||
if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'],$_SERVER["PHP_SELF"],'f.type','',$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'],$_SERVER['PHP_SELF'],'f.datef','',$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'],$_SERVER['PHP_SELF'],"f.date_lim_reglement",'',$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER['PHP_SELF'],"p.ref",'',$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
|
||||
@ -864,6 +871,8 @@ if ($resql)
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
$projectstatic=new Project($db);
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$i=0;
|
||||
|
||||
@ -140,8 +140,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$sql.= ", f.rowid, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client";
|
||||
$sql.= ", f.type";
|
||||
$sql.= ", s.nom as name";
|
||||
$sql.= ", s.rowid as socid";
|
||||
$sql.= ",s.code_client";
|
||||
$sql.= ", s.rowid as socid, s.email";
|
||||
$sql.= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
@ -177,22 +177,28 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven"><td class="nowrap">';
|
||||
|
||||
$facturestatic->ref=$obj->facnumber;
|
||||
$facturestatic->id=$obj->rowid;
|
||||
$facturestatic->total_ht=$obj->total_ht;
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->ref_client=$obj->ref_client;
|
||||
$facturestatic->total_ht=$obj->total_ht;
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->ref_client=$obj->ref_client;
|
||||
$facturestatic->type=$obj->type;
|
||||
|
||||
$companystatic->id=$obj->socid;
|
||||
$companystatic->name=$obj->name;
|
||||
$companystatic->email=$obj->email;
|
||||
$companystatic->client = 1;
|
||||
$companystatic->code_client = $obj->code_client;
|
||||
$companystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
$companystatic->code_compta = $obj->code_compta;
|
||||
$companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
|
||||
print '<tr class="oddeven"><td class="nowrap">';
|
||||
print $facturestatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
print '<td class="nowrap">';
|
||||
$companystatic->id=$obj->socid;
|
||||
$companystatic->name=$obj->name;
|
||||
$companystatic->client = 1;
|
||||
$companystatic->code_client = $obj->code_client;
|
||||
$companystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
print $companystatic->getNomUrl(1,'',16);
|
||||
print '</td>';
|
||||
print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td>';
|
||||
@ -226,8 +232,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
{
|
||||
$sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier";
|
||||
$sql.= ", s.nom as name";
|
||||
$sql.= ", s.rowid as socid";
|
||||
$sql.= ", s.code_fournisseur";
|
||||
$sql.= ", s.rowid as socid, s.email";
|
||||
$sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
|
||||
@ -256,22 +262,28 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven"><td class="nowrap">';
|
||||
|
||||
$facturesupplierstatic->ref=$obj->ref;
|
||||
$facturesupplierstatic->id=$obj->rowid;
|
||||
$facturesupplierstatic->total_ht=$obj->total_ht;
|
||||
$facturesupplierstatic->total_tva=$obj->total_tva;
|
||||
$facturesupplierstatic->total_ttc=$obj->total_ttc;
|
||||
$facturesupplierstatic->ref_supplier=$obj->ref_supplier;
|
||||
$facturesupplierstatic->total_ht=$obj->total_ht;
|
||||
$facturesupplierstatic->total_tva=$obj->total_tva;
|
||||
$facturesupplierstatic->total_ttc=$obj->total_ttc;
|
||||
$facturesupplierstatic->ref_supplier=$obj->ref_supplier;
|
||||
$facturesupplierstatic->type=$obj->type;
|
||||
|
||||
$companystatic->id=$obj->socid;
|
||||
$companystatic->name=$obj->name;
|
||||
$companystatic->email=$obj->email;
|
||||
$companystatic->fournisseur = 1;
|
||||
$companystatic->code_client = $obj->code_client;
|
||||
$companystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
$companystatic->code_compta = $obj->code_compta;
|
||||
$companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
|
||||
print '<tr class="oddeven"><td class="nowrap">';
|
||||
print $facturesupplierstatic->getNomUrl(1,'',16);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$companystatic->id=$obj->socid;
|
||||
$companystatic->name=$obj->name;
|
||||
$companystatic->fournisseur = 1;
|
||||
$companystatic->code_client = $obj->code_client;
|
||||
$companystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
print $companystatic->getNomUrl(1,'supplier',16);
|
||||
print '</td>';
|
||||
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
||||
@ -311,7 +323,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$sql.= ", f.date_lim_reglement as datelimite";
|
||||
$sql.= ", s.nom as name";
|
||||
$sql.= ", s.rowid as socid";
|
||||
$sql.= ", s.code_client";
|
||||
$sql.= ", s.code_client, s.code_compta";
|
||||
$sql.= ", sum(pf.amount) as am";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
|
||||
@ -325,7 +337,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhereCustomerLastModified',$parameters);
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid, s.code_client";
|
||||
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
|
||||
$sql.= " s.nom, s.rowid, s.code_client, s.code_compta";
|
||||
$sql.= " ORDER BY f.tms DESC ";
|
||||
$sql.= $db->plimit($max, 0);
|
||||
|
||||
@ -350,19 +363,28 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$facturestatic->ref=$obj->facnumber;
|
||||
$facturestatic->id=$obj->rowid;
|
||||
$facturestatic->total_ht=$obj->total_ht;
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->statut = $obj->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
|
||||
$facturestatic->type=$obj->type;
|
||||
|
||||
$thirdpartystatic->id=$obj->socid;
|
||||
$thirdpartystatic->name=$obj->name;
|
||||
$thirdpartystatic->client=1;
|
||||
$thirdpartystatic->code_client = $obj->code_client;
|
||||
//$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
$thirdpartystatic->code_compta = $obj->code_compta;
|
||||
//$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td width="110" class="nobordernopadding nowrap">';
|
||||
$facturestatic->ref=$obj->facnumber;
|
||||
$facturestatic->id=$obj->rowid;
|
||||
$facturestatic->total_ht=$obj->total_ht;
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->statut = $obj->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
|
||||
$facturestatic->type=$obj->type;
|
||||
print $facturestatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
print '<td width="20" class="nobordernopadding nowrap">';
|
||||
@ -379,12 +401,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
|
||||
print '</td>';
|
||||
print '<td align="left">';
|
||||
$thirdpartystatic->id=$obj->socid;
|
||||
$thirdpartystatic->name=$obj->name;
|
||||
$thirdpartystatic->client=1;
|
||||
$thirdpartystatic->code_client = $obj->code_client;
|
||||
$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
print $thirdpartystatic->getNomUrl(1,'customer',44);
|
||||
print $thirdpartystatic->getNomUrl(1,'customer',44);
|
||||
print '</td>';
|
||||
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
|
||||
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
||||
@ -425,7 +442,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
$sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye";
|
||||
$sql.= ", s.nom as name";
|
||||
$sql.= ", s.rowid as socid";
|
||||
$sql.= ", s.code_fournisseur";
|
||||
$sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
|
||||
$sql.= ", SUM(pf.amount) as am";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
|
||||
@ -439,7 +456,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhereSupplierLastModified',$parameters);
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, s.nom, s.rowid, s.code_fournisseur";
|
||||
$sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,";
|
||||
$sql.= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur";
|
||||
$sql.= " ORDER BY ff.tms DESC ";
|
||||
$sql.= $db->plimit($max, 0);
|
||||
|
||||
@ -463,20 +481,25 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven"><td>';
|
||||
|
||||
$facstatic->ref=$obj->ref;
|
||||
$facstatic->id = $obj->rowid;
|
||||
$facstatic->total_ht = $obj->total_ht;
|
||||
$facstatic->total_tva = $obj->total_tva;
|
||||
$facstatic->total_ttc = $obj->total_ttc;
|
||||
print $facstatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$facstatic->id = $obj->rowid;
|
||||
$facstatic->total_ht = $obj->total_ht;
|
||||
$facstatic->total_tva = $obj->total_tva;
|
||||
$facstatic->total_ttc = $obj->total_ttc;
|
||||
|
||||
$thirdpartystatic->id=$obj->socid;
|
||||
$thirdpartystatic->name=$obj->name;
|
||||
$thirdpartystatic->fournisseur=1;
|
||||
$thirdpartystatic->code_client = $obj->code_client;
|
||||
$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
//$thirdpartystatic->code_client = $obj->code_client;
|
||||
$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
|
||||
//$thirdpartystatic->code_compta = $obj->code_compta;
|
||||
$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $facstatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $thirdpartystatic->getNomUrl(1,'supplier',44);
|
||||
print '</td>';
|
||||
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
|
||||
@ -673,9 +696,9 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
|
||||
$langs->load("orders");
|
||||
|
||||
$sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc";
|
||||
$sql.= ", s.nom as name";
|
||||
$sql.= ", s.nom as name, s.email";
|
||||
$sql.= ", s.rowid as socid";
|
||||
$sql.= ", s.code_client";
|
||||
$sql.= ", s.code_client, s.code_compta";
|
||||
$sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
@ -693,7 +716,7 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill',$parameters);
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= " GROUP BY s.nom, s.rowid, s.code_client, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc";
|
||||
$sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ( $resql )
|
||||
@ -712,18 +735,28 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
|
||||
print '<th align="right">'.$langs->trans("ToBill").'</th>';
|
||||
print '<th align="center" width="16"> </th>';
|
||||
print '</tr>';
|
||||
|
||||
$tot_ht=$tot_ttc=$tot_tobill=0;
|
||||
$societestatic = new Societe($db);
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
$societestatic->id=$obj->socid;
|
||||
$societestatic->name=$obj->name;
|
||||
$societestatic->email=$obj->email;
|
||||
$societestatic->client=1;
|
||||
$societestatic->code_client = $obj->code_client;
|
||||
//$societestatic->code_fournisseur = $obj->code_fournisseur;
|
||||
$societestatic->code_compta = $obj->code_compta;
|
||||
//$societestatic->code_fournisseur = $obj->code_fournisseur;
|
||||
|
||||
$commandestatic->id=$obj->rowid;
|
||||
$commandestatic->ref=$obj->ref;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td width="110" class="nobordernopadding nowrap">';
|
||||
print $commandestatic->getNomUrl(1);
|
||||
@ -741,11 +774,6 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
$societestatic->id=$obj->socid;
|
||||
$societestatic->name=$obj->name;
|
||||
$societestatic->client=1;
|
||||
$societestatic->code_client = $obj->code_client;
|
||||
$societestatic->code_fournisseur = $obj->code_fournisseur;
|
||||
print $societestatic->getNomUrl(1,'customer',44);
|
||||
print '</td>';
|
||||
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
|
||||
@ -787,8 +815,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms";
|
||||
$sql.= ", f.date_lim_reglement as datelimite";
|
||||
$sql.= ", s.nom as name";
|
||||
$sql.= ", s.rowid as socid";
|
||||
$sql.= ", s.code_client";
|
||||
$sql.= ", s.rowid as socid, s.email";
|
||||
$sql.= ", s.code_client, s.code_compta";
|
||||
$sql.= ", sum(pf.amount) as am";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
|
||||
@ -802,7 +830,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhereCustomerUnpaid',$parameters);
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid, s.code_client";
|
||||
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
|
||||
$sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta";
|
||||
$sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -829,19 +858,29 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$facturestatic->ref=$obj->facnumber;
|
||||
$facturestatic->id=$obj->rowid;
|
||||
$facturestatic->total_ht=$obj->total_ht;
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->type=$obj->type;
|
||||
$facturestatic->statut = $obj->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
|
||||
|
||||
$societestatic->id=$obj->socid;
|
||||
$societestatic->name=$obj->name;
|
||||
$societestatic->email=$obj->email;
|
||||
$societestatic->client=1;
|
||||
$societestatic->code_client = $obj->code_client;
|
||||
$societestatic->code_fournisseur = $obj->code_fournisseur;
|
||||
$societestatic->code_compta = $obj->code_compta;
|
||||
$societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td width="110" class="nobordernopadding nowrap">';
|
||||
$facturestatic->ref=$obj->facnumber;
|
||||
$facturestatic->id=$obj->rowid;
|
||||
$facturestatic->total_ht=$obj->total_ht;
|
||||
$facturestatic->total_tva=$obj->total_tva;
|
||||
$facturestatic->total_ttc=$obj->total_ttc;
|
||||
$facturestatic->type=$obj->type;
|
||||
$facturestatic->statut = $obj->fk_statut;
|
||||
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
|
||||
print $facturestatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
print '<td width="20" class="nobordernopadding nowrap">';
|
||||
@ -858,11 +897,6 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
|
||||
print '</td>';
|
||||
print '<td align="left">' ;
|
||||
$societestatic->id=$obj->socid;
|
||||
$societestatic->name=$obj->name;
|
||||
$societestatic->client=1;
|
||||
$societestatic->code_client = $obj->code_client;
|
||||
$societestatic->code_fournisseur = $obj->code_fournisseur;
|
||||
print $societestatic->getNomUrl(1,'customer',44);
|
||||
print '</td>';
|
||||
print '<td align="right">'.dol_print_date($db->jdate($obj->datelimite),'day').'</td>';
|
||||
@ -912,9 +946,9 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
$sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye";
|
||||
$sql.= ", ff.date_lim_reglement";
|
||||
$sql.= ", s.nom as name";
|
||||
$sql.= ", s.rowid as socid";
|
||||
$sql.= ", s.code_client";
|
||||
$sql.= ", s.code_fournisseur";
|
||||
$sql.= ", s.rowid as socid, s.email";
|
||||
$sql.= ", s.code_client, s.code_compta";
|
||||
$sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
|
||||
$sql.= ", sum(pf.amount) as am";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
|
||||
@ -930,8 +964,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhereSupplierUnpaid',$parameters);
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye,";
|
||||
$sql.= " s.nom, s.rowid, s.code_client, s.code_fournisseur, ff.date_lim_reglement";
|
||||
$sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,";
|
||||
$sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
|
||||
$sql.= " ORDER BY ff.date_lim_reglement ASC";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
@ -958,19 +992,25 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
$facstatic->ref=$obj->ref;
|
||||
$facstatic->id = $obj->rowid;
|
||||
$facstatic->total_ht = $obj->total_ht;
|
||||
$facstatic->total_tva = $obj->total_tva;
|
||||
$facstatic->total_ttc = $obj->total_ttc;
|
||||
$facstatic->total_ht = $obj->total_ht;
|
||||
$facstatic->total_tva = $obj->total_tva;
|
||||
$facstatic->total_ttc = $obj->total_ttc;
|
||||
|
||||
$societestatic->id=$obj->socid;
|
||||
$societestatic->name=$obj->name;
|
||||
$societestatic->email=$obj->email;
|
||||
$societestatic->client=0;
|
||||
$societestatic->fournisseur=1;
|
||||
$societestatic->code_client = $obj->code_client;
|
||||
$societestatic->code_fournisseur = $obj->code_fournisseur;
|
||||
$societestatic->code_compta = $obj->code_compta;
|
||||
$societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $facstatic->getNomUrl(1,'');
|
||||
print '</td>';
|
||||
$societestatic->id=$obj->socid;
|
||||
$societestatic->name=$obj->name;
|
||||
$societestatic->client=0;
|
||||
$societestatic->code_client = $obj->code_client;
|
||||
$societestatic->code_fournisseur = $obj->code_fournisseur;
|
||||
print '<td>'.$societestatic->getNomUrl(1, 'supplier', 44).'</td>';
|
||||
print '<td align="right">'.dol_print_date($db->jdate($obj->date_lim_reglement),'day').'</td>';
|
||||
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
|
||||
|
||||
@ -257,7 +257,7 @@ if (empty($reshook))
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices
|
||||
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices and regenerating documents
|
||||
if ($paiement_id < 0)
|
||||
{
|
||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||
|
||||
@ -141,7 +141,7 @@ class Paiement extends CommonObject
|
||||
/**
|
||||
* Create payment of invoices into database.
|
||||
* Use this->amounts to have list of invoices for the payment.
|
||||
* For payment of a customer invoice, amounts are postive, for payment of credit note, amounts are negative
|
||||
* For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative
|
||||
*
|
||||
* @param User $user Object user
|
||||
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
|
||||
@ -233,11 +233,12 @@ class Paiement extends CommonObject
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$invoice=new Facture($this->db);
|
||||
$invoice->fetch($facid);
|
||||
|
||||
// If we want to closed payed invoices
|
||||
if ($closepaidinvoices)
|
||||
{
|
||||
$invoice=new Facture($this->db);
|
||||
$invoice->fetch($facid);
|
||||
$paiement = $invoice->getSommePaiement();
|
||||
$creditnotes=$invoice->getSumCreditNotesUsed();
|
||||
$deposits=$invoice->getSumDepositsUsed();
|
||||
@ -338,26 +339,25 @@ class Paiement extends CommonObject
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $invoice->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
|
||||
if ($result < 0) {
|
||||
setEventMessages($invoice->error, $invoice->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Regenerate documents of invoices
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $invoice->fetch($facid); // Reload to get new records
|
||||
$result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
|
||||
if ($result < 0) {
|
||||
setEventMessages($invoice->error, $invoice->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1042,11 +1042,14 @@ class Paiement extends CommonObject
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param string $option Sur quoi pointe le lien
|
||||
* @param string $mode 'withlistofinvoices'=Include list of invoices into tooltip
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @return string Chaine avec URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$option='',$mode='withlistofinvoices')
|
||||
function getNomUrl($withpicto=0, $option='', $mode='withlistofinvoices', $notooltip=0)
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
|
||||
|
||||
$result='';
|
||||
$label = $langs->trans("ShowPayment").': '.$this->ref;
|
||||
@ -1064,12 +1067,31 @@ class Paiement extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
|
||||
$linkclose='';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$label=$langs->trans("ShowMyObject");
|
||||
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
|
||||
}
|
||||
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
|
||||
|
||||
$url = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id;
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart.=$linkclose.'>';
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment"), 'payment', 'class="classfortooltip"').$linkend);
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$link.($this->ref?$this->ref:$this->id).$linkend;
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
|
||||
if ($withpicto && $withpicto != 2) $result.= $this->ref;
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -73,10 +73,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
||||
|
||||
llxHeader('',$langs->trans("WithdrawalsReceipts"));
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
|
||||
$sql.= ", p.datec";
|
||||
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('facture').")";
|
||||
if ($search_ref) $sql.=natural_search("p.ref", $search_ref);
|
||||
if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1);
|
||||
|
||||
|
||||
@ -284,7 +284,7 @@ class BonPrelevement extends CommonObject
|
||||
$sql.= ", p.fk_user_credit";
|
||||
$sql.= ", p.statut";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('facture').")";
|
||||
if ($rowid > 0) $sql.= " AND p.rowid = ".$rowid;
|
||||
else $sql.= " AND p.ref = '".$this->db->escape($ref)."'";
|
||||
|
||||
|
||||
@ -236,10 +236,10 @@ class RejetPrelevement
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
|
||||
$subject = $langs->trans("InfoRejectSubject");
|
||||
$subject = $langs->transnoentities("InfoRejectSubject");
|
||||
$sendto = $emuser->getFullName($langs)." <".$emuser->email.">";
|
||||
$from = $this->user->getFullName($langs)." <".$this->user->email.">";
|
||||
$msgishtml=0;
|
||||
$msgishtml=1;
|
||||
|
||||
$arr_file = array();
|
||||
$arr_mime = array();
|
||||
|
||||
@ -279,7 +279,7 @@ print load_fiche_titre($langs->trans("LastWithdrawalReceipts",$limit),'','');
|
||||
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
|
||||
$sql.= ", p.datec";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('facture').")";
|
||||
$sql.= " ORDER BY datec DESC";
|
||||
$sql.=$db->plimit($limit);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2018 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
|
||||
@ -101,7 +101,7 @@ if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
if ($search_line) $sql.= " AND pl.rowid = '".$db->escape($search_line)."'";
|
||||
if ($search_bon) $sql.= natural_search("p.ref", $search_bon);
|
||||
if ($search_code) $sql.= natural_search("s.code_client", $search_code);
|
||||
if ($search_company) natural_search("s.nom", $search_company);
|
||||
if ($search_company) $sql.= natural_search("s.nom", $search_company);
|
||||
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
@ -123,13 +123,14 @@ if ($result)
|
||||
|
||||
$urladd = "&statut=".$statut;
|
||||
$urladd .= "&search_bon=".$search_bon;
|
||||
|
||||
print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $urladd.='&limit='.urlencode($limit);
|
||||
|
||||
print"\n<!-- debut table -->\n";
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
|
||||
|
||||
$moreforfilter='';
|
||||
print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit);
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
@ -740,7 +740,7 @@ else
|
||||
$sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('payment_salary').")";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
|
||||
|
||||
@ -813,7 +813,7 @@ else
|
||||
$sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
|
||||
$sql.= " AND p.fk_statut>=5";
|
||||
|
||||
$column='p.date_valid';
|
||||
@ -823,7 +823,7 @@ else
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")";
|
||||
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
|
||||
$sql.= " AND p.fk_statut>=5";
|
||||
|
||||
$column='pe.datep';
|
||||
@ -898,7 +898,7 @@ else
|
||||
{
|
||||
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql.= " AND fk_statut in (1,2)";
|
||||
}
|
||||
else
|
||||
|
||||
@ -638,7 +638,7 @@ if (! empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $m
|
||||
$subtotal_ttc = 0;
|
||||
$sql = "SELECT p.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "payment_salary as p";
|
||||
$sql .= " WHERE p.entity = " . $conf->entity;
|
||||
$sql .= " WHERE p.entity IN (".getEntity('payment_salary').")";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'";
|
||||
$sql .= " GROUP BY p.label, dm";
|
||||
@ -686,7 +686,7 @@ if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES'
|
||||
$sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
|
||||
$sql.= " AND p.fk_statut>=5";
|
||||
|
||||
$column='p.date_valid';
|
||||
@ -699,7 +699,7 @@ if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES'
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")";
|
||||
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
|
||||
$sql.= " AND p.fk_statut>=5";
|
||||
|
||||
$column='pe.datep';
|
||||
@ -752,7 +752,7 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql.= " AND fk_statut in (1,2)";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
|
||||
|
||||
@ -156,6 +156,7 @@ class ChargeSociales extends CommonObject
|
||||
function create($user)
|
||||
{
|
||||
global $conf;
|
||||
$error=0;
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
@ -191,8 +192,17 @@ class ChargeSociales extends CommonObject
|
||||
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales");
|
||||
|
||||
//dol_syslog("ChargesSociales::create this->id=".$this->id);
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
$result=$this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE',$user);
|
||||
if ($result < 0) $error++;
|
||||
|
||||
if(empty($error)) {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else {
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.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
|
||||
@ -651,26 +652,83 @@ class Tva extends CommonObject
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param string $option link option
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $morecss More CSS
|
||||
* @return string Chaine with URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$option='')
|
||||
function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='')
|
||||
{
|
||||
global $langs;
|
||||
global $langs, $conf;
|
||||
|
||||
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
|
||||
|
||||
$result='';
|
||||
$label=$langs->trans("ShowVatPayment").': '.$this->ref;
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend='</a>';
|
||||
$url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id;
|
||||
|
||||
$linkclose='';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$label=$langs->trans("ShowMyObject");
|
||||
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
|
||||
}
|
||||
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart.=$linkclose.'>';
|
||||
$linkend ='</a>';
|
||||
|
||||
$picto='payment';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$link.$this->ref.$linkend;
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
|
||||
if ($withpicto != 2) $result.= $this->ref;
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return amount of payments already done
|
||||
*
|
||||
* @return int Amount of payment already done, <0 if KO
|
||||
*/
|
||||
function getSommePaiement()
|
||||
{
|
||||
$table='paiementcharge';
|
||||
$field='fk_charge';
|
||||
|
||||
$sql = 'SELECT sum(amount) as amount';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$table;
|
||||
$sql.= ' WHERE '.$field.' = '.$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$amount=0;
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) $amount=$obj->amount?$obj->amount:0;
|
||||
|
||||
$this->db->free($resql);
|
||||
return $amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Informations of vat payment object
|
||||
*
|
||||
|
||||
177
htdocs/compta/tva/document.php
Normal file
177
htdocs/compta/tva/document.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.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/compta/tva/document.php
|
||||
* \ingroup tax
|
||||
* \brief Page with attached files on social contributions
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
|
||||
$langs->load("other");
|
||||
$langs->load("companies");
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
$action = GETPOST('action','aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', $id, 'vat','charges');
|
||||
|
||||
|
||||
// Get parameters
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="name";
|
||||
|
||||
|
||||
$object = new Tva($db);
|
||||
if ($id > 0) $object->fetch($id);
|
||||
|
||||
$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
$modulepart='tax';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
|
||||
|
||||
if ($action == 'setlib' && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
|
||||
$title = $langs->trans("VATPayment") . ' - ' . $langs->trans("Documents");
|
||||
$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)';
|
||||
llxHeader("",$title,$help_url);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
$alreadypayed=$object->getSommePaiement();
|
||||
|
||||
$head=vat_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'bill');
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Label of social contribution
|
||||
$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' : ';
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/tva/index.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
// Construit liste des fichiers
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
||||
$totalsize=0;
|
||||
foreach($filearray as $key => $file)
|
||||
{
|
||||
$totalsize+=$file['size'];
|
||||
}
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
$modulepart = 'tax';
|
||||
$permission = $user->rights->tax->charges->creer;
|
||||
$permtoedit = $user->rights->fournisseur->facture->creer;
|
||||
$param = '&id=' . $object->id;
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -97,7 +97,7 @@ $formother=new FormOther($db);
|
||||
$tva_static = new Tva($db);
|
||||
$bankstatic = new Account($db);
|
||||
|
||||
$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,";
|
||||
$sql = "SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,";
|
||||
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id AND pst.entity IN (".getEntity('c_paiement').")";
|
||||
@ -192,8 +192,8 @@ if ($result)
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"t.rowid","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"t.label","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateValue",$_SERVER["PHP_SELF"],"dv","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"dp","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateValue",$_SERVER["PHP_SELF"],"t.datev","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"t.datep","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
|
||||
if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"t.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
@ -217,10 +217,13 @@ if ($result)
|
||||
|
||||
$tva_static->id=$obj->rowid;
|
||||
$tva_static->ref=$obj->rowid;
|
||||
|
||||
// Ref
|
||||
print "<td>".$tva_static->getNomUrl(1)."</td>\n";
|
||||
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->dv),'day')."</td>\n";
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->dp),'day')."</td>\n";
|
||||
// Label
|
||||
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->datev),'day')."</td>\n";
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day')."</td>\n";
|
||||
// Type
|
||||
print $type;
|
||||
// Account
|
||||
|
||||
@ -607,7 +607,15 @@ else
|
||||
// State
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
{
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="'.$colspan.'" class="maxwidthonsmartphone">';
|
||||
if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
|
||||
{
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('Region-State').'</label></td><td colspan="'.$colspan.'" class="maxwidthonsmartphone">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="'.$colspan.'" class="maxwidthonsmartphone">';
|
||||
}
|
||||
|
||||
if ($object->country_id)
|
||||
{
|
||||
print $formcompany->select_state(GETPOST("state_id",'alpha')?GETPOST("state_id",'alpha'):$object->state_id,$object->country_code,'state_id');
|
||||
@ -852,7 +860,15 @@ else
|
||||
// State
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
{
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
|
||||
{
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('Region-State').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
}
|
||||
|
||||
print $formcompany->select_state($object->state_id,isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id,'state_id');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -42,6 +42,27 @@ class Contact extends CommonObject
|
||||
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
public $picto = 'contact';
|
||||
|
||||
|
||||
// BEGIN MODULEBUILDER PROPERTIES
|
||||
/**
|
||||
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
|
||||
*/
|
||||
public $fields=array(
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
|
||||
'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
|
||||
'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
||||
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60),
|
||||
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61),
|
||||
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
|
||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
|
||||
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
|
||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
|
||||
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
|
||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
|
||||
);
|
||||
|
||||
public $civility_id; // In fact we store civility_code
|
||||
public $civility_code;
|
||||
public $address;
|
||||
@ -96,9 +117,15 @@ class Contact extends CommonObject
|
||||
public $user_id;
|
||||
public $user_login;
|
||||
|
||||
// END MODULEBUILDER PROPERTIES
|
||||
|
||||
|
||||
public $oldcopy; // To contains a clone of this when we need to save old properties of object
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -131,7 +158,7 @@ class Contact extends CommonObject
|
||||
$sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$clause = "AND";
|
||||
}
|
||||
$sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')';
|
||||
$sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')';
|
||||
$sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))";
|
||||
if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
@ -657,43 +657,53 @@ if (empty($reshook))
|
||||
|
||||
else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel','alpha'))
|
||||
{
|
||||
if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update)
|
||||
{
|
||||
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
||||
$action = 'editline';
|
||||
$_GET['rowid'] = GETPOST('elrowid');
|
||||
$error++;
|
||||
}
|
||||
$error = 0;
|
||||
|
||||
if (!$error) {
|
||||
$objectline = new ContratLigne($db);
|
||||
if ($objectline->fetch(GETPOST('elrowid')))
|
||||
{
|
||||
$db->begin();
|
||||
if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update)
|
||||
{
|
||||
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
||||
$action = 'editline';
|
||||
$_GET['rowid'] = GETPOST('elrowid');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture;
|
||||
if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture;
|
||||
if (! $error)
|
||||
{
|
||||
$objectline = new ContratLigne($db);
|
||||
if ($objectline->fetch(GETPOST('elrowid')) < 0)
|
||||
{
|
||||
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
$vat_rate = GETPOST('eltva_tx');
|
||||
// Define info_bits
|
||||
$info_bits = 0;
|
||||
if (preg_match('/\*/', $vat_rate))
|
||||
$db->begin();
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture;
|
||||
if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture;
|
||||
|
||||
$vat_rate = GETPOST('eltva_tx');
|
||||
// Define info_bits
|
||||
$info_bits = 0;
|
||||
if (preg_match('/\*/', $vat_rate))
|
||||
$info_bits |= 0x01;
|
||||
|
||||
// Define vat_rate
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_tx=get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
||||
$localtax2_tx=get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
|
||||
$localtax1_tx=get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
||||
$localtax2_tx=get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
|
||||
|
||||
$txtva = $vat_rate;
|
||||
$txtva = $vat_rate;
|
||||
|
||||
// Clean vat code
|
||||
$vat_src_code='';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||
{
|
||||
$vat_src_code='';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||
{
|
||||
$vat_src_code = $reg[1];
|
||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||
}
|
||||
}
|
||||
|
||||
// ajout prix d'achat
|
||||
$fk_fournprice = $_POST['fournprice'];
|
||||
@ -704,22 +714,22 @@ if (empty($reshook))
|
||||
|
||||
$fk_unit = GETPOST('unit', 'alpha');
|
||||
|
||||
$objectline->description=GETPOST('product_desc','none');
|
||||
$objectline->price_ht=GETPOST('elprice');
|
||||
$objectline->subprice=GETPOST('elprice');
|
||||
$objectline->qty=GETPOST('elqty');
|
||||
$objectline->remise_percent=GETPOST('elremise_percent');
|
||||
$objectline->tva_tx=($txtva?$txtva:0); // Field may be disabled, so we use vat rate 0
|
||||
$objectline->vat_src_code=$vat_src_code;
|
||||
$objectline->localtax1_tx=is_numeric($localtax1_tx)?$localtax1_tx:0;
|
||||
$objectline->localtax2_tx=is_numeric($localtax2_tx)?$localtax2_tx:0;
|
||||
$objectline->date_ouverture_prevue=$date_start_update;
|
||||
$objectline->date_ouverture=$date_start_real_update;
|
||||
$objectline->date_fin_validite=$date_end_update;
|
||||
$objectline->date_cloture=$date_end_real_update;
|
||||
$objectline->fk_user_cloture=$user->id;
|
||||
$objectline->fk_fournprice=$fk_fournprice;
|
||||
$objectline->pa_ht=$pa_ht;
|
||||
$objectline->description=GETPOST('product_desc','none');
|
||||
$objectline->price_ht=GETPOST('elprice');
|
||||
$objectline->subprice=GETPOST('elprice');
|
||||
$objectline->qty=GETPOST('elqty');
|
||||
$objectline->remise_percent=GETPOST('elremise_percent');
|
||||
$objectline->tva_tx=($txtva?$txtva:0); // Field may be disabled, so we use vat rate 0
|
||||
$objectline->vat_src_code=$vat_src_code;
|
||||
$objectline->localtax1_tx=is_numeric($localtax1_tx)?$localtax1_tx:0;
|
||||
$objectline->localtax2_tx=is_numeric($localtax2_tx)?$localtax2_tx:0;
|
||||
$objectline->date_ouverture_prevue=$date_start_update;
|
||||
$objectline->date_ouverture=$date_start_real_update;
|
||||
$objectline->date_fin_validite=$date_end_update;
|
||||
$objectline->date_cloture=$date_end_real_update;
|
||||
$objectline->fk_user_cloture=$user->id;
|
||||
$objectline->fk_fournprice=$fk_fournprice;
|
||||
$objectline->pa_ht=$pa_ht;
|
||||
|
||||
if ($fk_unit > 0) {
|
||||
$objectline->fk_unit = GETPOST('unit');
|
||||
@ -727,30 +737,30 @@ if (empty($reshook))
|
||||
$objectline->fk_unit = null;
|
||||
}
|
||||
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$objectline->array_options=$array_options;
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$objectline->array_options=$array_options;
|
||||
|
||||
// TODO verifier price_min si fk_product et multiprix
|
||||
// TODO verifier price_min si fk_product et multiprix
|
||||
|
||||
$result=$objectline->update($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$objectline->update($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||
@ -771,6 +781,30 @@ if (empty($reshook))
|
||||
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||
{
|
||||
$result = $object->validate($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'reopen' && $user->rights->contrat->creer)
|
||||
@ -1477,9 +1511,11 @@ else
|
||||
|
||||
// Title line for service
|
||||
$cursorline=1;
|
||||
while ($cursorline <= $nbofservices)
|
||||
print '<div id="contrat-lines-container" data-contractid="'.$object->id.'" data-element="'.$object->element.'" >';
|
||||
while ($cursorline <= $nbofservices)
|
||||
{
|
||||
print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
|
||||
print '<div id="contrat-line-container'.$object->lines[$cursorline-1]->id.'" data-contratlineid = "'.$object->lines[$cursorline-1]->id.'" data-element="'.$object->lines[$cursorline-1]->element.'" >';
|
||||
print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="updateline">';
|
||||
print '<input type="hidden" name="elrowid" value="'.$object->lines[$cursorline-1]->id.'">';
|
||||
@ -1525,7 +1561,7 @@ else
|
||||
|
||||
if ($action != 'editline' || GETPOST('rowid') != $objp->rowid)
|
||||
{
|
||||
print '<tr '.$bcnd[$var].' valign="top">';
|
||||
print '<tr '.$bcnd[$var].' class="tdtop">';
|
||||
// Label
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
@ -1535,12 +1571,10 @@ else
|
||||
$productstatic->ref=$objp->pref;
|
||||
$productstatic->entity=$objp->pentity;
|
||||
$productstatic->label=$objp->plabel;
|
||||
$text = $productstatic->getNomUrl(1,'',20);
|
||||
$text = $productstatic->getNomUrl(1,'',32);
|
||||
if ($objp->plabel)
|
||||
{
|
||||
$text .= ' - ';
|
||||
//$productstatic->ref=$objp->label;
|
||||
//$text .= $productstatic->getNomUrl(0,'',16);
|
||||
$text .= $objp->plabel;
|
||||
}
|
||||
$description = $objp->description;
|
||||
@ -1677,8 +1711,8 @@ else
|
||||
$productstatic->type=$objp->ptype;
|
||||
$productstatic->ref=$objp->pref;
|
||||
$productstatic->entity=$objp->pentity;
|
||||
print $productstatic->getNomUrl(1,'',20);
|
||||
print $objp->label?' - '.dol_trunc($objp->label,16):'';
|
||||
print $productstatic->getNomUrl(1,'',32);
|
||||
print $objp->label?' - '.dol_trunc($objp->label,32):'';
|
||||
print '<br>';
|
||||
}
|
||||
else
|
||||
@ -1786,7 +1820,7 @@ else
|
||||
'text' => $langs->trans("ConfirmMoveToAnotherContractQuestion"),
|
||||
array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid));
|
||||
|
||||
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'),$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'),$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion);
|
||||
print '<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>';
|
||||
}
|
||||
|
||||
@ -1798,7 +1832,7 @@ else
|
||||
$dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||
$dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
|
||||
$comment = GETPOST('comment','alpha');
|
||||
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment),$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",dol_print_date($dateactstart,"%A %d %B %Y")),"confirm_active", '', 0, 1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment),$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",dol_print_date($dateactstart,"%A %d %B %Y")),"confirm_active", '', 0, 1);
|
||||
print '<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>';
|
||||
}
|
||||
|
||||
@ -1817,7 +1851,7 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne','int')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService",dol_print_date($dateactend,"%A %d %B %Y")), "confirm_closeline", '', 0, 1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne','int')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService",dol_print_date($dateactend,"%A %d %B %Y")), "confirm_closeline", '', 0, 1);
|
||||
}
|
||||
print '<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>';
|
||||
}
|
||||
@ -1993,9 +2027,10 @@ else
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
$cursorline++;
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
// Form to add new line
|
||||
if ($user->rights->contrat->creer && ($object->statut == 0))
|
||||
|
||||
@ -386,7 +386,11 @@ class Contrat extends CommonObject
|
||||
$result=$this->thirdparty->set_as_client();
|
||||
|
||||
// Define new ref
|
||||
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
|
||||
if ($force_number)
|
||||
{
|
||||
$num = $force_number;
|
||||
}
|
||||
else if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
|
||||
{
|
||||
$num = $this->getNextNumRef($this->thirdparty);
|
||||
}
|
||||
@ -877,7 +881,6 @@ class Contrat extends CommonObject
|
||||
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat");
|
||||
|
||||
|
||||
// Load object modContract
|
||||
$module=(! empty($conf->global->CONTRACT_ADDON)?$conf->global->CONTRACT_ADDON:'mod_contract_serpis');
|
||||
if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php')
|
||||
@ -1201,7 +1204,7 @@ class Contrat extends CommonObject
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user=null, $notrigger=0)
|
||||
function update($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
@ -1264,26 +1267,14 @@ class Contrat extends CommonObject
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// 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}
|
||||
//// End call triggers
|
||||
// Call triggers
|
||||
$result=$this->call_trigger('CONTRACT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
@ -2868,6 +2859,9 @@ class ContratLigne extends CommonObjectLine
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->oldcopy = new ContratLigne($this->db);
|
||||
$this->oldcopy->fetch($this->id);
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
|
||||
$sql.= " fk_contrat=".$this->fk_contrat.",";
|
||||
@ -2907,22 +2901,14 @@ class ContratLigne extends CommonObjectLine
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$contrat=new Contrat($this->db);
|
||||
$contrat->fetch($this->fk_contrat);
|
||||
$result=$contrat->update_statut($user);
|
||||
}
|
||||
else
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
$error++;
|
||||
//return -1;
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||
{
|
||||
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -2930,19 +2916,52 @@ class ContratLigne extends CommonObjectLine
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
if (! $notrigger)
|
||||
// If we change a planned date (start or end), sync dates for all services
|
||||
if (! $error && ! empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES))
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINECONTRACT_UPDATE',$user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// End call triggers
|
||||
}
|
||||
if ($this->date_ouverture_prevue != $this->oldcopy->date_ouverture_prevue)
|
||||
{
|
||||
$sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET';
|
||||
$sql.= " date_ouverture_prevue = ".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null");
|
||||
$sql.= " WHERE fk_contrat = ".$this->fk_contrat;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error++;
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
if ($this->date_fin_validite != $this->oldcopy->date_fin_validite)
|
||||
{
|
||||
$sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET';
|
||||
$sql.= " date_fin_validite = ".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null");
|
||||
$sql.= " WHERE fk_contrat = ".$this->fk_contrat;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error++;
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINECONTRACT_UPDATE', $user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
$this->errors[]=$this->error;
|
||||
@ -3034,7 +3053,16 @@ class ContratLigne extends CommonObjectLine
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'contratdet');
|
||||
|
||||
// FIXME Missing insert of extrafields
|
||||
// Insert of extrafields
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$notrigger)
|
||||
{
|
||||
|
||||
@ -75,7 +75,7 @@ $opclotureyear=GETPOST('opclotureyear');
|
||||
$filter_opcloture=GETPOST('filter_opcloture');
|
||||
|
||||
// Initialize context for list
|
||||
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'servicelist'.$mode;
|
||||
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'contractservicelist'.$mode;
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array($contextpage));
|
||||
@ -483,7 +483,6 @@ if (! empty($arrayfields['cd.date_cloture']['checked']))
|
||||
print '</td>';
|
||||
}
|
||||
// Extra fields
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
// Fields from hook
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2018 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
|
||||
@ -50,10 +51,22 @@ foreach($linkedObjectBlock as $key => $objectlink)
|
||||
<td><?php echo $objectlink->getNomUrl(1); ?></td>
|
||||
<td></td>
|
||||
<td align="center"><?php echo dol_print_date($objectlink->date_contrat,'day'); ?></td>
|
||||
<td align="right"><?php // var_dump($objectlink->total_ttc); ?></td>
|
||||
<td align="right"><?php
|
||||
// Price of contract is not shown by default because a contract is a list of service with
|
||||
// start and end date that change with time andd that may be different that the period of reference for price.
|
||||
// So price of a contract does often means nothing. Prices is on the different invoices done on same contract.
|
||||
if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE))
|
||||
{
|
||||
$totalcontrat = 0;
|
||||
foreach ($objectlink->lines as $linecontrat) {
|
||||
$totalcontrat = $totalcontrat + $linecontrat->total_ht;
|
||||
$total = $total + $linecontrat->total_ht;
|
||||
}
|
||||
echo price($totalcontrat);
|
||||
} ?></td>
|
||||
<td align="right"><?php echo $objectlink->getLibStatut(7); ?></td>
|
||||
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
<!-- END PHP TEMPLATE -->
|
||||
|
||||
@ -33,14 +33,14 @@ if (GETPOST('formfilteraction') == 'listafterchangingselectedfields')
|
||||
$tabparam=array();
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
|
||||
|
||||
if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields");
|
||||
else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]='';
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
|
||||
$result=dol_set_user_param($db, $conf, $user, $tabparam);
|
||||
|
||||
|
||||
//$action='list';
|
||||
//var_dump($tabparam);exit;
|
||||
}
|
||||
|
||||
@ -40,7 +40,13 @@ if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtas
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($object->error) && ! count($object->errors)) setEventMessages('Fetch on object return an error without filling $object->error nor $object->errors', null, 'errors');
|
||||
if (empty($object->error) && ! count($object->errors))
|
||||
{
|
||||
if ($ret < 0) // if $ret == 0, it means not found.
|
||||
{
|
||||
setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors');
|
||||
}
|
||||
}
|
||||
else setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
|
||||
@ -182,37 +182,70 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
|
||||
$filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0); // Do not remove accents
|
||||
$filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0); // Do not remove accents
|
||||
|
||||
// Security:
|
||||
// Disallow file with some extensions. We rename them.
|
||||
// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
|
||||
if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
|
||||
if ($filenamefrom != $filenameto)
|
||||
{
|
||||
$filenameto.= '.noexe';
|
||||
}
|
||||
// Security:
|
||||
// Disallow file with some extensions. We rename them.
|
||||
// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
|
||||
if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
|
||||
{
|
||||
$filenameto.= '.noexe';
|
||||
}
|
||||
|
||||
if ($filenamefrom && $filenameto)
|
||||
{
|
||||
$srcpath = $upload_dir.'/'.$filenamefrom;
|
||||
$destpath = $upload_dir.'/'.$filenameto;
|
||||
if ($filenamefrom && $filenameto)
|
||||
{
|
||||
$srcpath = $upload_dir.'/'.$filenamefrom;
|
||||
$destpath = $upload_dir.'/'.$filenameto;
|
||||
|
||||
$result = dol_move($srcpath, $destpath);
|
||||
if ($result)
|
||||
{
|
||||
if ($object->id)
|
||||
{
|
||||
$object->addThumbs($destpath);
|
||||
}
|
||||
$result = dol_move($srcpath, $destpath);
|
||||
if ($result)
|
||||
{
|
||||
if ($object->id)
|
||||
{
|
||||
$object->addThumbs($destpath);
|
||||
}
|
||||
|
||||
// TODO Add revert function of addThumbs to remove for old name
|
||||
//$object->delThumbs($srcpath);
|
||||
// TODO Add revert function of addThumbs to remove for old name
|
||||
//$object->delThumbs($srcpath);
|
||||
|
||||
setEventMessages($langs->trans("FileRenamed"), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
|
||||
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
|
||||
}
|
||||
setEventMessages($langs->trans("FileRenamed"), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
|
||||
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update properties in ECM table
|
||||
if (GETPOST('ecmfileid', 'int') > 0)
|
||||
{
|
||||
$shareenabled = GETPOST('shareenabled', 'alpha');
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(GETPOST('ecmfileid', 'int'));
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($shareenabled)
|
||||
{
|
||||
if (empty($ecmfile->share))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$ecmfile->share = getRandomPassword(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ecmfile->share = '';
|
||||
}
|
||||
$result = $ecmfile->update($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,10 +102,10 @@ if (GETPOST('removAll','alpha'))
|
||||
*/
|
||||
if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
|
||||
{
|
||||
$trackid = GETPOST('trackid','aZ09');
|
||||
if (empty($trackid)) $trackid = GETPOST('trackid','aZ09');
|
||||
|
||||
$subject='';$actionmsg='';$actionmsg2='';
|
||||
|
||||
if (! empty($conf->dolimail->enabled)) $langs->load("dolimail@dolimail");
|
||||
$langs->load('mails');
|
||||
|
||||
if (is_object($object))
|
||||
@ -320,6 +320,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
|
||||
|
||||
// Feature to push mail sent into Sent folder
|
||||
/* This code must be now included into the hook mail, method sendMailAfter
|
||||
if (! empty($conf->dolimail->enabled))
|
||||
{
|
||||
$mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
|
||||
@ -328,7 +329,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
{
|
||||
$mbid = $mailfromid[1];
|
||||
|
||||
/*IMAP Postbox*/
|
||||
// IMAP Postbox
|
||||
$mailboxconfig = new IMAP($db);
|
||||
$mailboxconfig->fetch($mbid);
|
||||
if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
|
||||
@ -360,6 +361,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Make substitution in email content
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
|
||||
@ -392,7 +394,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
{
|
||||
// FIXME This must be moved into the trigger for action $trigger_name
|
||||
// Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required
|
||||
/*
|
||||
if (! empty($conf->dolimail->enabled))
|
||||
{
|
||||
$mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ?
|
||||
@ -410,7 +413,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs');
|
||||
else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings');
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// Initialisation of datas
|
||||
if (is_object($object))
|
||||
@ -445,12 +448,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
// This avoid sending mail twice if going out and then back to page
|
||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
setEventMessages($mesg, null, 'mesgs');
|
||||
if ($conf->dolimail->enabled)
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val);
|
||||
exit;
|
||||
}
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:''));
|
||||
|
||||
$moreparam='';
|
||||
if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
|
||||
@ -59,7 +59,7 @@ if (empty($img))
|
||||
}
|
||||
|
||||
// Define mime type
|
||||
top_httphead('image/png');
|
||||
top_httphead('image/png', 1);
|
||||
|
||||
$background_color = imagecolorallocate($img, 250, 250, 250);
|
||||
$ecriture_color = imagecolorallocate($img, 0, 0, 0);
|
||||
|
||||
@ -111,7 +111,7 @@ class box_activity extends ModeleBoxes
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
|
||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= ")";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('propal').")";
|
||||
$sql.= " AND p.fk_soc = s.rowid";
|
||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
|
||||
|
||||
@ -84,7 +84,7 @@ class box_produits extends ModeleBoxes
|
||||
{
|
||||
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||
$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')';
|
||||
$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
|
||||
if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
|
||||
if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
|
||||
// Add where from hooks
|
||||
|
||||
@ -88,7 +88,7 @@ class box_produits_alerte_stock extends ModeleBoxes
|
||||
$sql.= " SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") as total_stock";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
|
||||
$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')';
|
||||
$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
|
||||
$sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
|
||||
if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
|
||||
if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
|
||||
|
||||
@ -108,7 +108,7 @@ class CMailFile
|
||||
* @param string $css Css option
|
||||
* @param string $trackid Tracking string (contains type and id of related element)
|
||||
* @param string $moreinheader More in header. $moreinheader must contains the "\r\n" (TODO not supported for other MAIL_SEND_MODE different than 'phpmail' and 'smtps' for the moment)
|
||||
* @param string $sendcontext 'standard', 'emailing', ...
|
||||
* @param string $sendcontext 'standard', 'emailing', ... (used to define with sending mode and parameters to use)
|
||||
*/
|
||||
function __construct($subject,$to,$from,$msg,$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),$addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='',$css='',$trackid='',$moreinheader='',$sendcontext='standard')
|
||||
{
|
||||
@ -482,7 +482,7 @@ class CMailFile
|
||||
|
||||
|
||||
/**
|
||||
* Send mail that was prepared by constructor
|
||||
* Send mail that was prepared by constructor.
|
||||
*
|
||||
* @return boolean True if mail sent, false otherwise
|
||||
*/
|
||||
@ -495,19 +495,25 @@ class CMailFile
|
||||
|
||||
$res=false;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS))
|
||||
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($db);
|
||||
$hookmanager->initHooks(array('maildao'));
|
||||
$reshook = $hookmanager->executeHooks('doactions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if (! empty($reshook))
|
||||
$hookmanager->initHooks(array('mail'));
|
||||
|
||||
$parameters=array(); $action='';
|
||||
$reshook = $hookmanager->executeHooks('sendMail', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0)
|
||||
{
|
||||
$this->error = "Error in hook maildao doactions " . $reshook;
|
||||
$this->error = "Error in hook maildao sendMail " . $reshook;
|
||||
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR);
|
||||
|
||||
return $reshook;
|
||||
}
|
||||
if ($reshook == 1) // Hook replace standard code
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
|
||||
if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL=10;
|
||||
@ -557,6 +563,12 @@ class CMailFile
|
||||
$keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING';
|
||||
$keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
|
||||
}
|
||||
|
||||
if(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) {
|
||||
$this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO;
|
||||
$this->addr_cc = '';
|
||||
$this->addr_bcc = '';
|
||||
}
|
||||
|
||||
// Action according to choosed sending method
|
||||
if ($this->sendmode == 'mail')
|
||||
@ -760,13 +772,21 @@ class CMailFile
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Send mail method not correctly defined
|
||||
// --------------------------------------
|
||||
|
||||
return 'Bad value for sendmode';
|
||||
}
|
||||
|
||||
$parameters=array(); $action='';
|
||||
$reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0)
|
||||
{
|
||||
$this->error = "Error in hook maildao sendMailAfter " . $reshook;
|
||||
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR);
|
||||
|
||||
return $reshook;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -425,7 +425,7 @@ abstract class CommonDocGenerator
|
||||
{
|
||||
$object->fetch_projet();
|
||||
}
|
||||
|
||||
|
||||
$resarray[$array_key.'_project_ref'] = $object->project->ref;
|
||||
$resarray[$array_key.'_project_title'] = $object->project->title;
|
||||
$resarray[$array_key.'_project_description'] = $object->project->description;
|
||||
@ -510,7 +510,7 @@ abstract class CommonDocGenerator
|
||||
'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs),
|
||||
'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs),
|
||||
);
|
||||
|
||||
|
||||
// Units
|
||||
if ($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
@ -528,6 +528,15 @@ abstract class CommonDocGenerator
|
||||
|
||||
$resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
|
||||
|
||||
// Load product data optional fields to the line -> enables to use "line_options_{extrafield}"
|
||||
if (isset($line->fk_product) && $line->fk_product > 0)
|
||||
{
|
||||
$tmpproduct = new Product($this->db);
|
||||
$result = $tmpproduct->fetch($line->fk_product);
|
||||
foreach($tmpproduct->array_options as $key=>$label)
|
||||
$resarray["line_".$key] = $label;
|
||||
}
|
||||
|
||||
return $resarray;
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* Copyright (C) 2016 Bahfir abbes <dolipar@dolipar.org>
|
||||
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||
* Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2018 Frederic France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -78,7 +79,7 @@ abstract class CommonObject
|
||||
*/
|
||||
public $array_options=array();
|
||||
/**
|
||||
* @var int[] Array of linked objects ids. Loaded by ->fetchObjectLinked
|
||||
* @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked
|
||||
*/
|
||||
public $linkedObjectsIds;
|
||||
/**
|
||||
@ -1273,14 +1274,15 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object from specific field
|
||||
*
|
||||
* @param string $table Table element or element line
|
||||
* @param string $field Field selected
|
||||
* @param string $key Import key
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetchObjectFrom($table,$field,$key)
|
||||
* Load object from specific field
|
||||
*
|
||||
* @param string $table Table element or element line
|
||||
* @param string $field Field selected
|
||||
* @param string $key Import key
|
||||
* @param string $element Element name
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetchObjectFrom($table, $field, $key, $element = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -1288,14 +1290,21 @@ abstract class CommonObject
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table;
|
||||
$sql.= " WHERE ".$field." = '".$key."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
if (! empty($element)) {
|
||||
$sql.= " AND entity IN (".getEntity($element).")";
|
||||
} else {
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this).'::fetchObjectFrom', LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$result = $this->fetch($row[0]);
|
||||
// Test for avoid error -1
|
||||
if ($row[0] > 0) {
|
||||
$result = $this->fetch($row[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -1340,6 +1349,7 @@ abstract class CommonObject
|
||||
* @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none'
|
||||
* @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY')
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @see updateExtraField
|
||||
*/
|
||||
function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='')
|
||||
{
|
||||
@ -1789,29 +1799,57 @@ abstract class CommonObject
|
||||
* Change the shipping method
|
||||
*
|
||||
* @param int $shipping_method_id Id of shipping method
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @param User $userused Object user
|
||||
*
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function setShippingMethod($shipping_method_id)
|
||||
function setShippingMethod($shipping_method_id, $notrigger=false, $userused=null)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (empty($userused)) $userused=$user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (! $this->table_element) {
|
||||
dol_syslog(get_class($this)."::setShippingMethod was called on objet with property table_element not defined",LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($shipping_method_id<0) $shipping_method_id='NULL';
|
||||
dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')');
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= " SET fk_shipping_method = ".$shipping_method_id;
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
$this->shipping_method_id = ($shipping_method_id=='NULL')?null:$shipping_method_id;
|
||||
return 1;
|
||||
} else {
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
dol_syslog(get_class($this).'::setShippingMethod Error ', LOG_DEBUG);
|
||||
$this->error=$this->db->error();
|
||||
return 0;
|
||||
}
|
||||
$this->error = $this->db->lasterror();
|
||||
$error++;
|
||||
} else {
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$this->context=array('shippingmethodupdate'=>1);
|
||||
$result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused);
|
||||
if ($result < 0) $error++;
|
||||
// End call trigger
|
||||
}
|
||||
}
|
||||
if ($error)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->shipping_method_id = ($shipping_method_id=='NULL')?null:$shipping_method_id;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1887,14 +1925,24 @@ abstract class CommonObject
|
||||
* Change the bank account
|
||||
*
|
||||
* @param int $fk_account Id of bank account
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @param User $userused Object user
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function setBankAccount($fk_account)
|
||||
function setBankAccount($fk_account, $notrigger=false, $userused=null)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (empty($userused)) $userused=$user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (! $this->table_element) {
|
||||
dol_syslog(get_class($this)."::setBankAccount was called on objet with property table_element not defined",LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
$this->db->begin();
|
||||
|
||||
if ($fk_account<0) $fk_account='NULL';
|
||||
dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')');
|
||||
|
||||
@ -1902,15 +1950,37 @@ abstract class CommonObject
|
||||
$sql.= " SET fk_account = ".$fk_account;
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
$this->fk_account = ($fk_account=='NULL')?null:$fk_account;
|
||||
return 1;
|
||||
} else {
|
||||
dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error());
|
||||
$this->error = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$this->context=array('bankaccountupdate'=>1);
|
||||
$result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused);
|
||||
if ($result < 0) $error++;
|
||||
// End call trigger
|
||||
}
|
||||
}
|
||||
if ($error)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fk_account = ($fk_account=='NULL')?null:$fk_account;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: Move line related operations to CommonObjectLine?
|
||||
|
||||
@ -3426,7 +3496,7 @@ abstract class CommonObject
|
||||
|
||||
/**
|
||||
* Return if a country is inside the EEC (European Economic Community)
|
||||
* @deprecated
|
||||
* @deprecated Use function isInEEC function instead
|
||||
*
|
||||
* @return boolean true = country inside EEC, false = country outside EEC
|
||||
*/
|
||||
@ -4391,7 +4461,7 @@ abstract class CommonObject
|
||||
* @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters.
|
||||
* @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded
|
||||
*/
|
||||
function fetch_optionals($rowid=null,$optionsArray=null)
|
||||
function fetch_optionals($rowid=null, $optionsArray=null)
|
||||
{
|
||||
if (empty($rowid)) $rowid=$this->id;
|
||||
|
||||
@ -4506,8 +4576,9 @@ abstract class CommonObject
|
||||
* @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY)
|
||||
* @param User $userused Object user
|
||||
* @return int -1=error, O=did nothing, 1=OK
|
||||
* @see updateExtraField, setValueFrom
|
||||
*/
|
||||
function insertExtraFields($trigger='',$userused=null)
|
||||
function insertExtraFields($trigger='', $userused=null)
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
|
||||
@ -4536,16 +4607,30 @@ abstract class CommonObject
|
||||
|
||||
foreach($new_array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||
$attributeParam = $extrafields->attribute_param[$attributeKey];
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||
$attributeParam = $extrafields->attribute_param[$attributeKey];
|
||||
$attributeRequired = $extrafields->attribute_required[$attributeKey];
|
||||
|
||||
if ($attributeRequired)
|
||||
{
|
||||
$mandatorypb=false;
|
||||
if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb=true;
|
||||
if ($this->array_options[$key] === '') $mandatorypb=true;
|
||||
if ($mandatorypb)
|
||||
{
|
||||
$this->errors[]=$langs->trans('ErrorFieldRequired', $attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($attributeType)
|
||||
{
|
||||
case 'int':
|
||||
if (!is_numeric($value) && $value!='')
|
||||
{
|
||||
$this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
|
||||
$this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
elseif ($value=='')
|
||||
@ -4569,23 +4654,27 @@ abstract class CommonObject
|
||||
$new_array_options[$key] = $this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
case 'link':
|
||||
$param_list=array_keys($attributeParam ['options']);
|
||||
$param_list=array_keys($attributeParam['options']);
|
||||
// 0 : ObjectName
|
||||
// 1 : classPath
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
if ($value)
|
||||
if ($value == '-1') // -1 is key for no defined in combo list of objects
|
||||
{
|
||||
$new_array_options[$key]='';
|
||||
}
|
||||
elseif ($value)
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
if (is_numeric($value)) $res=$object->fetch($value);
|
||||
else $res=$object->fetch('',$value);
|
||||
|
||||
if ($res > 0) $new_array_options[$key]=$object->id;
|
||||
else
|
||||
{
|
||||
$this->error="Ref '".$value."' for object '".$object->element."' not found";
|
||||
$this->error="Id/Ref '".$value."' for object '".$object->element."' not found";
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -4598,6 +4687,7 @@ abstract class CommonObject
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$table_element = $this->table_element;
|
||||
@ -4642,16 +4732,14 @@ abstract class CommonObject
|
||||
$this->error=$this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
|
||||
if (! $error && $trigger)
|
||||
{
|
||||
if ($trigger)
|
||||
{
|
||||
// Call trigger
|
||||
$this->context=array('extrafieldaddupdate'=>1);
|
||||
$result=$this->call_trigger($trigger, $userused);
|
||||
if ($result < 0) $error++;
|
||||
// End call trigger
|
||||
}
|
||||
// Call trigger
|
||||
$this->context=array('extrafieldaddupdate'=>1);
|
||||
$result=$this->call_trigger($trigger, $userused);
|
||||
if ($result < 0) $error++;
|
||||
// End call trigger
|
||||
}
|
||||
|
||||
if ($error)
|
||||
@ -4670,15 +4758,19 @@ abstract class CommonObject
|
||||
|
||||
/**
|
||||
* Update an exta field value for the current object.
|
||||
* Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
|
||||
* This function delte record with all extrafields and insert them again from the array $this->array_options.
|
||||
* Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
|
||||
*
|
||||
* @param string $key Key of the extrafield
|
||||
* @return int -1=error, O=did nothing, 1=OK
|
||||
* @param string $key Key of the extrafield
|
||||
* @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY)
|
||||
* @param User $userused Object user
|
||||
* @return int -1=error, O=did nothing, 1=OK
|
||||
* @see setValueFrom
|
||||
*/
|
||||
function updateExtraField($key)
|
||||
function updateExtraField($key, $trigger, $userused)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $conf,$langs,$user;
|
||||
|
||||
if (empty($userused)) $userused=$user;
|
||||
|
||||
$error=0;
|
||||
|
||||
@ -4730,9 +4822,9 @@ abstract class CommonObject
|
||||
// 1 : classPath
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
if ($value)
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
$object->fetch(0,$value);
|
||||
$this->array_options["options_".$key]=$object->id;
|
||||
}
|
||||
@ -4745,7 +4837,21 @@ abstract class CommonObject
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error++;
|
||||
$this->error=$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error && $trigger)
|
||||
{
|
||||
// Call trigger
|
||||
$this->context=array('extrafieldupdate'=>1);
|
||||
$result=$this->call_trigger($trigger, $userused);
|
||||
if ($result < 0) $error++;
|
||||
// End call trigger
|
||||
}
|
||||
|
||||
if ($error)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -5849,7 +5955,7 @@ abstract class CommonObject
|
||||
* @param int $dest_id New thirdparty id (the thirdparty that will received element of the other)
|
||||
* @param string[] $tables Tables that need to be changed
|
||||
* @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old thirdparty may already exists on new one)
|
||||
* @return bool
|
||||
* @return bool True if success, False if error
|
||||
*/
|
||||
public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
|
||||
{
|
||||
@ -6254,12 +6360,14 @@ abstract class CommonObject
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
||||
}
|
||||
|
||||
// Create extrafields
|
||||
if (! $error)
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0) $error++;
|
||||
}
|
||||
|
||||
// Triggers
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call triggers
|
||||
@ -6321,13 +6429,13 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function updateCommon(User $user, $notrigger = false)
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
|
||||
@ -6375,7 +6483,22 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! $notrigger) {
|
||||
// Update extrafield
|
||||
if (! $error)
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Triggers
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call triggers
|
||||
$result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY',$user);
|
||||
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
|
||||
@ -6414,6 +6537,19 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element."_extrafields";
|
||||
$sql.= " WHERE fk_object=" . $this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
|
||||
|
||||
@ -259,9 +259,6 @@ class Conf
|
||||
// Load translation object with current language
|
||||
if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US";
|
||||
|
||||
//if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1;
|
||||
//if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1;
|
||||
|
||||
$rootfordata = DOL_DATA_ROOT;
|
||||
$rootforuser = DOL_DATA_ROOT;
|
||||
// If multicompany module is enabled, we redefine the root of data
|
||||
|
||||
@ -594,7 +594,7 @@ class DolGraph
|
||||
* @param string $fileurl Url path to show image if saved onto disk
|
||||
* @return integer|null
|
||||
*/
|
||||
function draw($file,$fileurl='')
|
||||
function draw($file, $fileurl='')
|
||||
{
|
||||
if (empty($file))
|
||||
{
|
||||
@ -602,12 +602,17 @@ class DolGraph
|
||||
dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
|
||||
return -2;
|
||||
}
|
||||
if (! is_array($this->data) || count($this->data) < 1)
|
||||
if (! is_array($this->data))
|
||||
{
|
||||
$this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
|
||||
dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
if (count($this->data) < 1)
|
||||
{
|
||||
$this->error="Call to draw method was made but SetData was is an empty dataset";
|
||||
dol_syslog(get_class($this)."::draw ".$this->error, LOG_WARNING);
|
||||
}
|
||||
$call = "draw_".$this->_library;
|
||||
call_user_func_array(array($this,$call), array($file,$fileurl));
|
||||
}
|
||||
@ -822,7 +827,7 @@ class DolGraph
|
||||
|
||||
$legends=array();
|
||||
$nblot=count($this->data[0])-1; // -1 to remove legend
|
||||
if ($nblot < 0) dol_print_error('', 'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw');
|
||||
if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
|
||||
$firstlot=0;
|
||||
// Works with line but not with bars
|
||||
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
|
||||
|
||||
@ -111,6 +111,9 @@ class ExtraFields
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->error = array();
|
||||
$this->attributes = array();
|
||||
|
||||
// For old usage
|
||||
$this->attribute_elementtype = array();
|
||||
$this->attribute_type = array();
|
||||
$this->attribute_label = array();
|
||||
@ -140,15 +143,15 @@ class ExtraFields
|
||||
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visibilty
|
||||
* @param int $ishidden Deprecated. Use visibility instead.
|
||||
* @param int $list Visibilty (0=never visible, 1=visible on list+forms, 2=list onyl, 3=form only)
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $computed Computed value
|
||||
* @param string $entity Entity of extrafields (for multicompany modules)
|
||||
* @param string $langfile Language file
|
||||
* @param string $enabled Condition to have the field enabled or not
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $computed='', $entity='', $langfile='', $enabled='1')
|
||||
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $computed='', $entity='', $langfile='', $enabled='1')
|
||||
{
|
||||
if (empty($attrname)) return -1;
|
||||
if (empty($label)) return -1;
|
||||
@ -165,7 +168,7 @@ class ExtraFields
|
||||
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate')
|
||||
{
|
||||
// Add declaration of field into table
|
||||
$result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $ishidden, $default, $computed, $entity, $langfile, $enabled);
|
||||
$result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $notused, $default_value, $computed, $entity, $langfile, $enabled);
|
||||
$err2=$this->errno;
|
||||
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS'))
|
||||
{
|
||||
@ -282,7 +285,7 @@ class ExtraFields
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visibily
|
||||
* @param int $ishidden Deprecated. Use visibility instead.
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $default Default value (in database. use the default_value feature for default value on screen).
|
||||
* @param string $computed Computed value
|
||||
* @param string $entity Entity of extrafields
|
||||
@ -290,7 +293,7 @@ class ExtraFields
|
||||
* @param string $enabled Condition to have the field enabled or not
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $default='', $computed='',$entity='', $langfile='', $enabled='1')
|
||||
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1')
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@ -306,9 +309,9 @@ class ExtraFields
|
||||
|
||||
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
|
||||
{
|
||||
if(is_array($param) && count($param) > 0)
|
||||
if (is_array($param) && count($param) > 0)
|
||||
{
|
||||
$params = $this->db->escape(serialize($param));
|
||||
$params = serialize($param);
|
||||
}
|
||||
elseif (strlen($param) > 0)
|
||||
{
|
||||
@ -490,7 +493,7 @@ class ExtraFields
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visibility
|
||||
* @param int $ishidden Deprecated. Use visiblity instead.
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $default Default value (in database. use the default_value feature for default value on screen).
|
||||
* @param string $computed Computed value
|
||||
* @param string $entity Entity of extrafields
|
||||
@ -498,7 +501,7 @@ class ExtraFields
|
||||
* @param string $enabled Condition to have the field enabled or not
|
||||
* @return int >0 if OK, <=0 if KO
|
||||
*/
|
||||
function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $ishidden=0, $default='', $computed='', $entity='', $langfile='', $enabled='1')
|
||||
function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $notused=0, $default='', $computed='', $entity='', $langfile='', $enabled='1')
|
||||
{
|
||||
if ($elementtype == 'thirdparty') $elementtype='societe';
|
||||
if ($elementtype == 'contact') $elementtype='socpeople';
|
||||
@ -546,7 +549,7 @@ class ExtraFields
|
||||
{
|
||||
if ($label)
|
||||
{
|
||||
$result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$ishidden,$default,$computed,$entity,$langfile,$enabled);
|
||||
$result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$notused,$default,$computed,$entity,$langfile,$enabled);
|
||||
}
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -597,7 +600,7 @@ class ExtraFields
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visiblity
|
||||
* @param int $ishidden Deprecated. Use visility instead.
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $default Default value (in database. use the default_value feature for default value on screen).
|
||||
* @param string $computed Computed value
|
||||
* @param string $entity Entity of extrafields
|
||||
@ -605,10 +608,10 @@ class ExtraFields
|
||||
* @param string $enabled Condition to have the field enabled or not
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$ishidden=0,$default='',$computed='',$entity='',$langfile='',$enabled='1')
|
||||
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1')
|
||||
{
|
||||
global $conf, $user;
|
||||
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$ishidden.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled);
|
||||
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled);
|
||||
|
||||
// Clean parameters
|
||||
if ($elementtype == 'thirdparty') $elementtype='societe';
|
||||
@ -624,10 +627,17 @@ class ExtraFields
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
if (is_array($param))
|
||||
if (is_array($param) && count($param) > 0)
|
||||
{
|
||||
if (count($param) > 0) $param = $this->db->escape(serialize($param));
|
||||
else $param='';
|
||||
$params = serialize($param);
|
||||
}
|
||||
elseif (strlen($param) > 0)
|
||||
{
|
||||
$params = trim($param);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params='';
|
||||
}
|
||||
|
||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
|
||||
@ -671,7 +681,7 @@ class ExtraFields
|
||||
$sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").",";
|
||||
$sql.= " ".$pos.",";
|
||||
$sql.= " '".$this->db->escape($alwayseditable)."',";
|
||||
$sql.= " '".$this->db->escape($param)."',";
|
||||
$sql.= " '".$this->db->escape($params)."',";
|
||||
$sql.= " ".$list.", ";
|
||||
$sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").",";
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
|
||||
@ -819,11 +829,11 @@ class ExtraFields
|
||||
* @param string $moreparam To add more parametes on html input tag
|
||||
* @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names)
|
||||
* @param mixed $showsize Value for css to define size. May also be a numeric.
|
||||
* @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric)
|
||||
* @param int $objectid Current object id
|
||||
* @return string
|
||||
*/
|
||||
function showInputField($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0)
|
||||
function showInputField($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss='', $objectid=0)
|
||||
{
|
||||
global $conf,$langs,$form;
|
||||
|
||||
@ -856,45 +866,41 @@ class ExtraFields
|
||||
else return '';
|
||||
}
|
||||
|
||||
if (empty($showsize))
|
||||
if (empty($morecss))
|
||||
{
|
||||
if ($type == 'date')
|
||||
{
|
||||
//$showsize=10;
|
||||
$showsize = 'minwidth100imp';
|
||||
$morecss = 'minwidth100imp';
|
||||
}
|
||||
elseif ($type == 'datetime')
|
||||
{
|
||||
//$showsize=19;
|
||||
$showsize = 'minwidth200imp';
|
||||
$morecss = 'minwidth200imp';
|
||||
}
|
||||
elseif (in_array($type,array('int','integer','double','price')))
|
||||
{
|
||||
//$showsize=10;
|
||||
$showsize = 'maxwidth75';
|
||||
$morecss = 'maxwidth75';
|
||||
}
|
||||
elseif ($type == 'url')
|
||||
{
|
||||
$showsize='minwidth400';
|
||||
$morecss='minwidth400';
|
||||
}
|
||||
elseif ($type == 'boolean')
|
||||
{
|
||||
$showsize='';
|
||||
$morecss='';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (round($size) < 12)
|
||||
{
|
||||
$showsize = 'minwidth100';
|
||||
$morecss = 'minwidth100';
|
||||
}
|
||||
else if (round($size) <= 48)
|
||||
{
|
||||
$showsize = 'minwidth200';
|
||||
$morecss = 'minwidth200';
|
||||
}
|
||||
else
|
||||
{
|
||||
//$showsize=48;
|
||||
$showsize = 'minwidth400';
|
||||
$morecss = 'minwidth400';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -916,15 +922,15 @@ class ExtraFields
|
||||
{
|
||||
$tmp=explode(',',$size);
|
||||
$newsize=$tmp[0];
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
|
||||
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
elseif (preg_match('/varchar/', $type))
|
||||
{
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
|
||||
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
elseif (in_array($type, array('mail', 'phone', 'url')))
|
||||
{
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
|
||||
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
elseif ($type == 'text')
|
||||
{
|
||||
@ -936,7 +942,7 @@ class ExtraFields
|
||||
}
|
||||
else
|
||||
{
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
|
||||
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
}
|
||||
elseif ($type == 'boolean')
|
||||
@ -947,21 +953,21 @@ class ExtraFields
|
||||
} else {
|
||||
$checked=' value="1" ';
|
||||
}
|
||||
$out='<input type="checkbox" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
|
||||
$out='<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
elseif ($type == 'price')
|
||||
{
|
||||
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
||||
$value=price($value);
|
||||
}
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
|
||||
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
|
||||
}
|
||||
elseif ($type == 'double')
|
||||
{
|
||||
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
||||
$value=price($value);
|
||||
}
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
|
||||
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
|
||||
}
|
||||
elseif ($type == 'select')
|
||||
{
|
||||
@ -972,7 +978,7 @@ class ExtraFields
|
||||
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
||||
}
|
||||
|
||||
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
||||
$out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
||||
$out.='<option value="0"> </option>';
|
||||
foreach ($param['options'] as $key => $val)
|
||||
{
|
||||
@ -994,7 +1000,7 @@ class ExtraFields
|
||||
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
||||
}
|
||||
|
||||
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
||||
$out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
||||
if (is_array($param['options']))
|
||||
{
|
||||
$param_list=array_keys($param['options']);
|
||||
@ -1163,7 +1169,7 @@ class ExtraFields
|
||||
$out='';
|
||||
foreach ($param['options'] as $keyopt => $val)
|
||||
{
|
||||
$out.='<input class="flat '.$showsize.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
|
||||
$out.='<input class="flat '.$morecss.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
|
||||
$out.=' value="'.$keyopt.'"';
|
||||
$out.=' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
|
||||
$out.= ($value==$keyopt?'checked':'');
|
||||
@ -1325,7 +1331,7 @@ class ExtraFields
|
||||
elseif ($type == 'password')
|
||||
{
|
||||
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
||||
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
||||
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
if (!empty($hidden)) {
|
||||
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
|
||||
@ -1341,28 +1347,48 @@ class ExtraFields
|
||||
/**
|
||||
* Return HTML string to put an output field into a page
|
||||
*
|
||||
* @param string $key Key of attribute
|
||||
* @param string $value Value to show
|
||||
* @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering)
|
||||
* @return string Formated value
|
||||
* @param string $key Key of attribute
|
||||
* @param string $value Value to show
|
||||
* @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering)
|
||||
* @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data
|
||||
* @return string Formated value
|
||||
*/
|
||||
function showOutputField($key,$value,$moreparam='')
|
||||
function showOutputField($key, $value, $moreparam='', $extrafieldsobjectkey='')
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$elementtype=$this->attribute_elementtype[$key]; // seems not used
|
||||
$label=$this->attribute_label[$key];
|
||||
$type=$this->attribute_type[$key];
|
||||
$size=$this->attribute_size[$key];
|
||||
$default=$this->attribute_default[$key];
|
||||
$computed=$this->attribute_computed[$key];
|
||||
$unique=$this->attribute_unique[$key];
|
||||
$required=$this->attribute_required[$key];
|
||||
$param=$this->attribute_param[$key];
|
||||
$perms=$this->attribute_perms[$key];
|
||||
$langfile=$this->attribute_langfile[$key];
|
||||
$list=$this->attribute_list[$key];
|
||||
$hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
|
||||
if (! empty($extrafieldsobjectkey))
|
||||
{
|
||||
$elementtype=$this->attributes[$extrafieldsobjectkey]['elementtype'][$key]; // seems not used
|
||||
$label=$this->attributes[$extrafieldsobjectkey]['label'][$key];
|
||||
$type=$this->attributes[$extrafieldsobjectkey]['type'][$key];
|
||||
$size=$this->attributes[$extrafieldsobjectkey]['size'][$key];
|
||||
$default=$this->attributes[$extrafieldsobjectkey]['default'][$key];
|
||||
$computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key];
|
||||
$unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key];
|
||||
$required=$this->attributes[$extrafieldsobjectkey]['required'][$key];
|
||||
$param=$this->attributes[$extrafieldsobjectkey]['param'][$key];
|
||||
$perms=$this->attributes[$extrafieldsobjectkey]['perms'][$key];
|
||||
$langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key];
|
||||
$list=$this->attributes[$extrafieldsobjectkey]['list'][$key];
|
||||
$hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
|
||||
}
|
||||
else
|
||||
{
|
||||
$elementtype=$this->attribute_elementtype[$key]; // seems not used
|
||||
$label=$this->attribute_label[$key];
|
||||
$type=$this->attribute_type[$key];
|
||||
$size=$this->attribute_size[$key];
|
||||
$default=$this->attribute_default[$key];
|
||||
$computed=$this->attribute_computed[$key];
|
||||
$unique=$this->attribute_unique[$key];
|
||||
$required=$this->attribute_required[$key];
|
||||
$param=$this->attribute_param[$key];
|
||||
$perms=$this->attribute_perms[$key];
|
||||
$langfile=$this->attribute_langfile[$key];
|
||||
$list=$this->attribute_list[$key];
|
||||
$hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
|
||||
}
|
||||
|
||||
if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method.
|
||||
|
||||
@ -1590,8 +1616,9 @@ class ExtraFields
|
||||
elseif ($type == 'link')
|
||||
{
|
||||
$out='';
|
||||
// only if something to display (perf)
|
||||
if ($value)
|
||||
|
||||
// Only if something to display (perf)
|
||||
if ($value) // If we have -1 here, pb is into sert, not into ouptu
|
||||
{
|
||||
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
|
||||
|
||||
@ -1638,14 +1665,16 @@ class ExtraFields
|
||||
/**
|
||||
* Return tag to describe alignement to use for this extrafield
|
||||
*
|
||||
* @param string $key Key of attribute
|
||||
* @return string Formated value
|
||||
* @param string $key Key of attribute
|
||||
* @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data
|
||||
* @return string Formated value
|
||||
*/
|
||||
function getAlignFlag($key)
|
||||
function getAlignFlag($key, $extrafieldsobjectkey='')
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$type=$this->attribute_type[$key];
|
||||
if (! empty($extrafieldsobjectkey)) $type=$this->attributes[$extrafieldsobjectkey]['type'][$key];
|
||||
else $type=$this->attribute_type[$key];
|
||||
|
||||
$align='';
|
||||
|
||||
|
||||
@ -139,6 +139,9 @@ class HookManager
|
||||
'addMoreMassActions',
|
||||
'addSearchEntry',
|
||||
'addStatisticLine',
|
||||
'createDictionaryFieldList',
|
||||
'editDictionaryFieldlist',
|
||||
'getFormMail',
|
||||
'deleteFile',
|
||||
'doActions',
|
||||
'doMassActions',
|
||||
@ -175,10 +178,9 @@ class HookManager
|
||||
'formatEvent',
|
||||
'printObjectLine',
|
||||
'printObjectSubLine',
|
||||
'createDictionaryFieldList',
|
||||
'editDictionaryFieldlist',
|
||||
'getFormMail',
|
||||
'showLinkToObjectBlock'
|
||||
'showLinkToObjectBlock',
|
||||
'sendMail',
|
||||
'sendMailAfter'
|
||||
)
|
||||
)) $hooktype='addreplace';
|
||||
|
||||
|
||||
@ -646,9 +646,10 @@ class Form
|
||||
* @param integer $maxlength Max length for labels (0=no limit)
|
||||
* @param string $morecss More css class
|
||||
* @param string $usecodeaskey 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key
|
||||
* @param int $showempty Show empty choice
|
||||
* @return string HTML string with select
|
||||
*/
|
||||
function select_country($selected='',$htmlname='country_id',$htmloption='',$maxlength=0,$morecss='minwidth300',$usecodeaskey='')
|
||||
function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@ -693,20 +694,22 @@ class Form
|
||||
|
||||
foreach ($countryArray as $row)
|
||||
{
|
||||
if (empty($showempty) && empty($row['rowid'])) continue;
|
||||
|
||||
if ($row['favorite'] && $row['code_iso']) $atleastonefavorite++;
|
||||
if (empty($row['favorite']) && $atleastonefavorite)
|
||||
{
|
||||
$atleastonefavorite=0;
|
||||
$out.= '<option a value="" disabled class="selectoptiondisabledwhite">----------------------</option>';
|
||||
$out.= '<option value="" disabled class="selectoptiondisabledwhite">----------------------</option>';
|
||||
}
|
||||
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']) )
|
||||
{
|
||||
$foundselected=true;
|
||||
$out.= '<option b value="'.($usecodeaskey?($usecodeaskey=='code2'?$row['code_iso']:$row['code_iso3']):$row['rowid']).'" selected>';
|
||||
$out.= '<option value="'.($usecodeaskey?($usecodeaskey=='code2'?$row['code_iso']:$row['code_iso3']):$row['rowid']).'" selected>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= '<option c value="'.($usecodeaskey?($usecodeaskey=='code2'?$row['code_iso']:$row['code_iso3']):$row['rowid']).'">';
|
||||
$out.= '<option value="'.($usecodeaskey?($usecodeaskey=='code2'?$row['code_iso']:$row['code_iso3']):$row['rowid']).'">';
|
||||
}
|
||||
if ($row['label']) $out.= dol_trunc($row['label'],$maxlength,'middle');
|
||||
else $out.= ' ';
|
||||
@ -1726,7 +1729,7 @@ class Form
|
||||
* @param int $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
|
||||
* @param int $limit Limit on number of returned lines
|
||||
* @param int $price_level Level of price to show
|
||||
* @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell
|
||||
* @param int $status Sell status -1=Return all products, 0=Products not on sell, 1=Products on sell
|
||||
* @param int $finished 2=all, 1=finished, 0=raw material
|
||||
* @param string $selected_input_value Value of preselected input text (for use with ajax)
|
||||
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
|
||||
@ -1740,7 +1743,7 @@ class Form
|
||||
* 'warehouseopen' = select products from open warehouses,
|
||||
* 'warehouseclosed' = select products from closed warehouses,
|
||||
* 'warehouseinternal' = select products from warehouses for internal correct/transfer only
|
||||
* @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...])
|
||||
* @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...])
|
||||
* @return void
|
||||
*/
|
||||
function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array(), $socid=0, $showempty='1', $forcecombo=0, $morecss='', $hidepriceinlabel=0, $warehouseStatus='', $selected_combinations = array())
|
||||
@ -2390,7 +2393,7 @@ class Form
|
||||
* Return list of suppliers products
|
||||
*
|
||||
* @param int $socid Id societe fournisseur (0 pour aucun filtre)
|
||||
* @param int $selected Produit pre-selectionne
|
||||
* @param int $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD')
|
||||
* @param string $htmlname Nom de la zone select
|
||||
* @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
|
||||
* @param string $filtre Pour filtre sql
|
||||
@ -5275,7 +5278,7 @@ class Form
|
||||
$confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
|
||||
|
||||
$fieldstoshow='t.ref';
|
||||
if (! empty($objecttmp->fields))
|
||||
if (! empty($objecttmp->fields)) // For object that declare it, it is better to use declared fields ( like societe, contact, ...)
|
||||
{
|
||||
$tmpfieldstoshow='';
|
||||
foreach($objecttmp->fields as $key => $val)
|
||||
@ -6252,8 +6255,11 @@ class Form
|
||||
$navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/','/tasks.php',$navurl);
|
||||
$paramid='ref';
|
||||
}
|
||||
$previous_ref = $object->ref_previous?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>':'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
|
||||
$next_ref = $object->ref_next?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>':'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
|
||||
|
||||
// accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox
|
||||
// accesskey is for Mac: CTRL + key for all browsers
|
||||
$previous_ref = $object->ref_previous?'<a accesskey="p" href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>':'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
|
||||
$next_ref = $object->ref_next?'<a accesskey="n" href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>':'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
|
||||
}
|
||||
|
||||
//print "xx".$previous_ref."x".$next_ref;
|
||||
|
||||
@ -266,10 +266,10 @@ class FormCompany
|
||||
$out.= '<option value="'.$obj->rowid.'">';
|
||||
}
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||
if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE) && $conf->global->MAIN_SHOW_REGION_IN_STATE == 2) {
|
||||
if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2) {
|
||||
$out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:''));
|
||||
}
|
||||
else if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE) && $conf->global->MAIN_SHOW_REGION_IN_STATE == 1) {
|
||||
else if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) {
|
||||
$out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:''));
|
||||
}
|
||||
else {
|
||||
|
||||
@ -938,7 +938,7 @@ class FormFile
|
||||
* @param string $url Full url to use for click links ('' = autodetect)
|
||||
* @param int $showrelpart 0=Show only filename (default), 1=Show first level 1 dir
|
||||
* @param int $permtoeditline Permission to edit document line (You must provide a value, -1 is deprecated and must not be used any more)
|
||||
* @param string $upload_dir Full path directory so we can know dir relative to MAIN_DATA_ROOT. Fill this if you want to complete file data with database indexes.
|
||||
* @param string $upload_dir Full path directory so we can know dir relative to MAIN_DATA_ROOT. Fill this to complete file data with database indexes.
|
||||
* @param string $sortfield Sort field ('name', 'size', 'position', ...)
|
||||
* @param string $sortorder Sort order ('ASC' or 'DESC')
|
||||
* @param int $disablemove 1=Disable move button, 0=Position move is possible.
|
||||
@ -951,6 +951,7 @@ class FormFile
|
||||
global $user, $conf, $langs, $hookmanager;
|
||||
global $bc,$bcdd;
|
||||
global $sortfield, $sortorder, $maxheightmini;
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
// Define relative path used to store the file
|
||||
if (empty($relativepath))
|
||||
@ -1038,6 +1039,7 @@ class FormFile
|
||||
print '<td></td>';
|
||||
if (empty($useinecm)) print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
if (! $disablemove) print '<td></td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
@ -1047,7 +1049,8 @@ class FormFile
|
||||
print_liste_field_titre('Documents2',$url,"name","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('Size',$url,"size","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('Date',$url,"date","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"');
|
||||
if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"'); // Preview
|
||||
print_liste_field_titre('');
|
||||
print_liste_field_titre('');
|
||||
if (! $disablemove) print_liste_field_titre('');
|
||||
print "</tr>\n";
|
||||
@ -1063,7 +1066,6 @@ class FormFile
|
||||
//var_dump($sortfield);
|
||||
$filearray=dol_sort_array($filearray, $sortfield, $sortorder);
|
||||
}
|
||||
//var_dump($filearray);
|
||||
}
|
||||
|
||||
$nboffiles=count($filearray);
|
||||
@ -1146,6 +1148,48 @@ class FormFile
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Hash of file (only if we are in a mode where a scan of dir were done and we have id of file in ECM table)
|
||||
print '<td align="center">';
|
||||
if ($relativedir && $filearray[$key]['rowid'] > 0)
|
||||
{
|
||||
if ($editline)
|
||||
{
|
||||
print $langs->trans("FileSharedViaALink").' ';
|
||||
print '<input class="inline-block" type="checkbox" name="shareenabled"'.($file['share']?' checked="checked"':'').' /> ';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($file['share'])
|
||||
{
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
//print '<span class="opacitymedium">'.$langs->trans("Hash").' : '.$file['share'].'</span>';
|
||||
$forcedownload=0;
|
||||
$paramlink='';
|
||||
if (! empty($file['share'])) $paramlink.=($paramlink?'&':'').'hashp='.$file['share']; // Hash for public share
|
||||
if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1';
|
||||
|
||||
$fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:'');
|
||||
//if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path
|
||||
//elseif (! empty($object->label)) $fulllink.='&hashc='.$object->label; // Hash of file content
|
||||
|
||||
print img_picto($langs->trans("FileSharedViaALink"),'object_globe.png').' ';
|
||||
print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">';
|
||||
//print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>'; // No target here
|
||||
}
|
||||
else
|
||||
{
|
||||
//print '<span class="opacitymedium">'.$langs->trans("FileNotShared").'</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Actions buttons
|
||||
if (! $editline)
|
||||
{
|
||||
// Delete or view link
|
||||
@ -1215,6 +1259,7 @@ class FormFile
|
||||
else
|
||||
{
|
||||
print '<td class="right">';
|
||||
print '<input type="hidden" name="ecmfileid" value="'.$filearray[$key]['rowid'].'">';
|
||||
print '<input type="submit" class="button" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||
print '</td>';
|
||||
@ -1227,9 +1272,9 @@ class FormFile
|
||||
}
|
||||
if ($nboffiles == 0)
|
||||
{
|
||||
$colspan=(empty($useinecm)?'5':'5');
|
||||
if (empty($disablemove)) $colspan++;
|
||||
print '<tr '.$bc[false].'><td colspan="'.$colspan.'" class="opacitymedium">';
|
||||
$colspan=(empty($useinecm)?'6':'6');
|
||||
if (empty($disablemove)) $colspan++; // 6 columns or 7
|
||||
print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">';
|
||||
if (empty($textifempty)) print $langs->trans("NoFileFound");
|
||||
else print $textifempty;
|
||||
print '</td></tr>';
|
||||
@ -1244,6 +1289,8 @@ class FormFile
|
||||
}
|
||||
}
|
||||
|
||||
print ajax_autoselect('downloadlink');
|
||||
|
||||
if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline)
|
||||
{
|
||||
print '</form>';
|
||||
@ -1297,8 +1344,8 @@ class FormFile
|
||||
if (! empty($addfilterfields))
|
||||
{
|
||||
print '<tr class="liste_titre nodrag nodrop">';
|
||||
print '<td><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
|
||||
print '<td></td>';
|
||||
print '<td><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
// Action column
|
||||
|
||||
@ -993,7 +993,7 @@ class FormMail extends Form
|
||||
$sql = "SELECT label, topic, joinfiles, content, content_lines, lang";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
|
||||
$sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')";
|
||||
$sql.= " AND entity IN (".getEntity('c_email_templates', 0).")";
|
||||
$sql.= " AND entity IN (".getEntity('c_email_templates').")";
|
||||
$sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned
|
||||
if ($active >= 0) $sql.=" AND active = ".$active;
|
||||
if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
|
||||
@ -1065,7 +1065,7 @@ class FormMail extends Form
|
||||
$sql = "SELECT label, topic, content, lang";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
|
||||
$sql.= " WHERE type_template='".$this->db->escape($type_template)."'";
|
||||
$sql.= " AND entity IN (".getEntity('c_email_templates', 0).")";
|
||||
$sql.= " AND entity IN (".getEntity('c_email_templates').")";
|
||||
$sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
|
||||
if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
|
||||
$sql.= $this->db->order("lang,label","ASC");
|
||||
@ -1102,7 +1102,7 @@ class FormMail extends Form
|
||||
$sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
|
||||
$sql.= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')";
|
||||
$sql.= " AND entity IN (".getEntity('c_email_templates', 1).")";
|
||||
$sql.= " AND entity IN (".getEntity('c_email_templates').")";
|
||||
$sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own.
|
||||
if ($active >= 0) $sql.=" AND active = ".$active;
|
||||
//if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; // Return all languages
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user