Merge branch 'develop' into bug-4875

This commit is contained in:
Laurent Destailleur
2018-02-03 17:42:17 +01:00
committed by GitHub
1497 changed files with 46068 additions and 36757 deletions

327
ChangeLog
View File

@@ -2,39 +2,267 @@
English Dolibarr ChangeLog
--------------------------------------------------------------
***** 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 *****
***** ChangeLog for 7.0.0 compared to 6.0.* *****
WARNING:
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: 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 const ABC
NEW: Accountancy Add variant on sell 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:
@@ -60,6 +288,57 @@ Following changes may create regressions for some external modules, but were nec
and add 'td.' to the beginning of the dragHandle match string.
* IE8 and earlier and Firefox 12 and earlier (< 2012) are no more supported.
* 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 *****
FIX: #7211 Update qty dispatched on qty change

View File

@@ -442,7 +442,7 @@ SORT_BY_SCOPE_NAME = NO
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
GENERATE_TODOLIST = NO
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
@@ -639,7 +639,7 @@ EXCLUDE_SYMBOLS =
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH = ../../dev/skeletons
EXAMPLE_PATH = ../../htdocs/modulebuilder/template
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp

View File

@@ -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

View File

@@ -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",

View File

@@ -162,4 +162,11 @@ PARSEDOWN
if (function_exists('mb_strlen')) $len = mb_strlen($line, 'utf-8');
else $len = strlen($line);
$shortage = 4 - $len % 4;
JEDITABLE.JS
------------
* <button type="submit" /> => <button class="button" type="submit" />
* <button type="cancel" /> => <button class="button" type="cancel" />

View File

@@ -0,0 +1,2 @@
# File(s) into root medias directory are provide by Pixabay with Licence "CC0 Creative Commons"
# https://creativecommons.org/publicdomain/zero/1.0/

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

File diff suppressed because one or more lines are too long

View File

@@ -131,7 +131,7 @@
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="10" />
<property name="nestingLevel" value="12" />
<property name="absoluteNestingLevel" value="50" />
</properties>
</rule>

View File

@@ -39,6 +39,7 @@ $mesg = '';
$action = GETPOST('action','aZ09');
$backtopage = GETPOST('backtopage','alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$rowid = GETPOST('rowid', 'int');
$cancel = GETPOST('cancel','alpha');
@@ -261,8 +262,10 @@ if ($action == 'create') {
print '</div>';
print '</form>';
} else if ($id) {
$result = $object->fetch($id);
}
else if ($id > 0 || $ref) {
$result = $object->fetch($id, $ref, 1);
if ($result > 0) {
dol_htmloutput_mesg($mesg);
@@ -329,17 +332,18 @@ if ($action == 'create') {
// View mode
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php">' . $langs->trans("BackToList") . '</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
dol_banner_tab($object, 'ref', $linkback, 1, 'account_number', 'ref');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Account number
print '<tr><td class="titlefield">' . $langs->trans("AccountNumber") . '</td>';
print '<td>' . $object->account_number . '</td>';
print '<td align="right" width="25%">' . $linkback . '</td></tr>';
// Label
print '<tr><td>' . $langs->trans("Label") . '</td>';
print '<tr><td class="titlefield">' . $langs->trans("Label") . '</td>';
print '<td colspan="2">' . $object->label . '</td></tr>';
// Account parent
@@ -361,20 +365,10 @@ if ($action == 'create') {
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td colspan="2">' . $object->pcg_subtype . '</td></tr>';
// Active
print '<tr><td>' . $langs->trans("Status") . '</td>';
print '<td colspan="2">';
print $object->getLibStatut(4);
/*if (empty($object->active)) {
print img_picto($langs->trans("Disabled"), 'switch_off');
} else {
print img_picto($langs->trans("Activated"), 'switch_on');
}*/
print '</td></tr>';
print '</table>';
print '</div>';
dol_fiche_end();
/*
@@ -397,7 +391,7 @@ if ($action == 'create') {
print '</div>';
}
} else {
dol_print_error($db);
dol_print_error($db, $object->error, $object->errors);
}
}

View File

@@ -31,14 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$langs->load("errors");
$langs->load("admin");
$langs->load("main");
$langs->load("companies");
$langs->load("resource");
$langs->load("holiday");
$langs->load("accountancy");
$langs->load("hrm");
$langs->loadLangs(array("errors","admin","companies","resource","holiday","accountancy","hrm"));
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha');
@@ -418,7 +411,7 @@ if ($action == 'disable_favorite')
$form = new Form($db);
$formadmin=new FormAdmin($db);
llxHeader('', $langs->trans('AccountingCategory'));
llxHeader('', $langs->trans('DictionaryAccountancyCategory'));
$titre=$langs->trans($tablib[$id]);
$linkback='';

View File

@@ -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>';
}
}

View File

@@ -57,6 +57,7 @@ if (GETPOST("exportcsv")) $action = 'export_csv';
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit;
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
@@ -66,19 +67,29 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
if (empty($search_date_start))
if (empty($search_date_start) && ! GETPOSTISSET('formfilteraction'))
{
$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--;
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql.= $db->plimit(1);
$res = $db->query($sql);
if ($res->num_rows > 0) {
$fiscalYear = $db->fetch_object($res);
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$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--;
}
$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);
}
if ($sortorder == "")
$sortorder = "ASC";
@@ -115,6 +126,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$search_accountancy_code_end = '';
$search_date_start = '';
$search_date_end = '';
$filter = array();
}
@@ -135,7 +147,8 @@ if ($action == 'export_csv') {
setEventMessages($object->error, $object->errors, 'errors');
}
foreach ($object->lines as $line) {
foreach ($object->lines as $line)
{
print length_accountg($line->numero_compte) . $sep;
print $object->get_compte_desc($line->numero_compte) . $sep;
print price($line->debit) . $sep;
@@ -153,7 +166,8 @@ else {
// List
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -166,6 +180,13 @@ else {
}
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">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$button = '<input type="submit" name="exportcsv" class="butAction" value="' . $langs->trans("Export") . ' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button);
@@ -174,9 +195,9 @@ else {
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateStart') . ': ';
$moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1);
$moreforfilter .= $form->select_date($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1, '', 1, 0, 1);
$moreforfilter .= $langs->trans('DateEnd') . ': ';
$moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1);
$moreforfilter .= $form->select_date($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1, '', 1, 0, 1);
$moreforfilter .= '</div>';
if (! empty($moreforfilter)) {
@@ -220,7 +241,8 @@ else {
$sous_total_credit = 0;
$displayed_account = "";
foreach ($object->lines as $line) {
foreach ($object->lines as $line)
{
$link = '';
$total_debit += $line->debit;
$total_credit += $line->credit;
@@ -280,4 +302,5 @@ else {
llxFooter();
}
$db->close();

View File

@@ -648,7 +648,10 @@ if ($action == 'create')
print "</tr>\n";
}
if (price2num($total_debit) != price2num($total_credit))
$total_debit = price2num($total_debit);
$total_credit = price2num($total_credit);
if ($total_debit != $total_credit)
{
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings');
}

View File

@@ -35,9 +35,6 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs
$langs->load("accountancy");
$page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$action = GETPOST('action', 'alpha');
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_doc_type = GETPOST("search_doc_type");
@@ -49,7 +46,7 @@ $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmo
$search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int'));
$search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification_startmonth', 'int'), GETPOST('date_modification_startday', 'int'), GETPOST('date_modification_startyear', 'int'));
$search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int'));
//var_dump($search_date_start);exit;
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
$action = 'delbookkeepingyear';
}
@@ -85,7 +82,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -99,22 +96,31 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page))
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int'))
{
$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--;
$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');
$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);
}
$arrayfields=array(
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
@@ -316,7 +322,8 @@ if ($action == 'delmouvconfirm') {
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
Header("Location: list.php");
Header("Location: list.php?noreset=1".($param?'&'.$param:''));
exit;
}
}
@@ -368,7 +375,7 @@ if ($result < 0) {
$num=count($object->lines);
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;
}
if ($action == 'delbookkeepingyear') {
@@ -448,11 +455,11 @@ if (! empty($arrayfields['t.doc_date']['checked']))
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
print $form->select_date($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $form->select_date($search_date_end, 'date_end', 0, 0, 1);
print $form->select_date($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1);
print '</div>';
print '</td>';
}

View File

@@ -40,34 +40,18 @@ $page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$action = GETPOST('action', 'alpha');
if (empty($search_date_start))
{
$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--;
}
$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, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_accountancy_code = GETPOST("search_accountancy_code");
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
if ($search_accountancy_code_start == - 1) {
$search_accountancy_code_start = '';
}
$search_label_account = GETPOST('search_label_account', 'alpha');
$search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
@@ -77,15 +61,37 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.rowid";
if (empty($search_date_start)) $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
if (empty($search_date_start)) {
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql.= $db->plimit(1);
$res = $db->query($sql);
if ($res->num_rows > 0) {
$fiscalYear = $db->fetch_object($res);
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$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--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
}
}
$object = new BookKeeping($db);
@@ -95,39 +101,38 @@ $filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$options .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
$options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$options .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
$options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int');
}
if (! empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$options .= '&amp;doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&amp;doc_dateday=' . GETPOST('doc_dateday', 'int') . '&amp;doc_dateyear=' . GETPOST('doc_dateyear', 'int');
$options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int');
}
if (! GETPOST('button_removefilter_x','alpha') && ! GETPOST('button_removefilter.x','alpha') && ! GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
if (! empty($search_accountancy_code_start)) {
$filter['t.numero_compte'] = $search_accountancy_code_start;
$options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
$options .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
}
if (! empty($search_label_account)) {
$filter['t.label_operation'] = $search_label_account;
$options .= '&amp;search_label_account=' . $search_label_account;
$options .= '&search_label_account=' . urlencode($search_label_account);
}
if (! empty($search_mvt_label)) {
$filter['t.label_operation'] = $search_mvt_label;
$options .= '&amp;search_mvt_label=' . $search_mvt_label;
$options .= '&search_mvt_label=' . urlencode($search_mvt_label);
}
if (! empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$options .= '&amp;search_direction=' . $search_direction;
$options .= '&search_direction=' . urlencode($search_direction);
}
if (! empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$options .= '&amp;search_ledger_code=' . $search_ledger_code;
$options .= '&search_ledger_code=' . urlencode($search_ledger_code);
}
}
@@ -174,6 +179,7 @@ $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By"
llxHeader('', $title_page);
// List
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
@@ -184,6 +190,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
}
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
@@ -225,7 +232,11 @@ 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>';
$addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,$viewflat.$addbutton,'', $limit);
$param=$options;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$addbutton, '', $limit);
// Reverse sort order
if ( preg_match('/^asc/i', $sortorder) )

View File

@@ -1,295 +0,0 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/bookkeeping/listbyyear.php
* \ingroup Advanced accountancy
* \brief Book keeping by year
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs
$langs->load("accountancy");
$page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit;
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_doc_type = GETPOST('search_doc_type', 'alpha');
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
$search_numero_compte = GETPOST('search_numero_compte', 'alpha');
$search_numero_compte_start = GETPOST('search_numero_compte_start', 'alpha');
if ($search_numero_compte_start == - 1) {
$search_numero_compte_start = '';
}
$search_numero_compte_end = GETPOST('search_numero_compte_end', 'alpha');
if ($search_numero_compte_end == - 1) {
$search_numero_compte_end = '';
}
$search_subledger_account = GETPOST('search_subledger_account', 'alpha');
$search_subledger_account_start = GETPOST('search_subledger_account_start', 'alpha');
if ($search_subledger_account_start == - 1) {
$search_subledger_account_start = '';
}
$search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha');
if ($search_subledger_account_end == - 1) {
$search_subledger_account_end = '';
}
$search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_sens = GETPOST('search_sens', 'alpha');
$search_code_journal = GETPOST('search_code_journal', 'alpha');
$object = new BookKeeping($db);
$form = new Form($db);
$formaccounting = new FormAccounting($db);
// Filter
if (empty($search_date_start)) {
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
}
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "t.rowid";
$offset = $limit * $page;
/*
* Actions
*/
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$search_doc_type = "";
$search_doc_date = "";
$search_doc_ref = "";
$search_numero_compte = "";
$search_subledger_account = "";
$search_label_operation = "";
$search_sens = "";
$search_code_journal = "";
}
$options = '';
$filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$options .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$options .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
}
if (! empty($search_doc_type)) {
$filter['t.doc_type'] = $search_doc_type;
$options .= '&amp;search_doc_type=' . $search_doc_type;
}
if (! empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$options .= '&amp;doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&amp;doc_dateday=' . GETPOST('doc_dateday', 'int') . '&amp;doc_dateyear=' . GETPOST('doc_dateyear', 'int');
}
if (! empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$options .= '&amp;search_doc_ref=' . $search_doc_ref;
}
if (! empty($search_numero_compte)) {
$filter['t.numero_compte'] = $search_numero_compte;
$options .= '&amp;search_numero_compte=' . $search_numero_compte;
}
if (! empty($search_numero_compte_start)) {
$filter['t.numero_compte>='] = $search_numero_compte_start;
$options .= '&amp;search_numero_compte_start=' . $search_numero_compte_start;
}
if (! empty($search_numero_compte_end)) {
$filter['t.numero_compte<='] = $search_numero_compte_end;
$options .= '&amp;search_numero_compte_end=' . $search_numero_compte_end;
}
if (! empty($search_subledger_account)) {
$filter['t.subledger_account'] = $search_subledger_account;
$options .= '&amp;search_subledger_account=' . $search_subledger_account;
}
if (! empty($search_subledger_account_start)) {
$filter['t.subledger_account>='] = $search_subledger_account_start;
$options .= '&amp;search_subledger_account_start=' . $search_subledger_account_start;
}
if (! empty($search_subledger_account_end)) {
$filter['t.subledger_account<='] = $search_subledger_account_end;
$options .= '&amp;search_subledger_account_end=' . $search_subledger_account_end;
}
if (! empty($search_label_operation)) {
$filter['t.label_operation'] = $search_label_operation;
$options .= '&amp;search_label_operation=' . $search_label_operation;
}
if (! empty($search_sens)) {
$filter['t.sens'] = $search_sens;
$options .= '&amp;search_sens=' . $search_sens;
}
if (! empty($search_code_journal)) {
$filter['t.code_journal'] = $search_code_journal;
$options .= '&amp;search_code_journal=' . $search_code_journal;
}
/*
* Actions
*/
llxHeader('', $langs->trans("Bookkeeping"));
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0);
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
print_barre_liste($langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy');
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<div class="liste_titre">';
print $langs->trans('DateStart') . ': ';
print $form->select_date($search_date_start, 'date_start');
print $langs->trans('DateEnd') . ': ';
print $form->select_date($search_date_end, 'date_end');
print '</div>';
print '<div class="liste_titre">';
print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': ';
print $formaccounting->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, '');
print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': ';
print $formaccounting->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, '');
print '</div>';
print '<div class="liste_titre">';
print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
print $formaccounting->select_auxaccount($search_subledger_account_start, 'search_subledger_account_start', 1);
print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
print $formaccounting->select_auxaccount($search_subledger_account_end, 'search_subledger_account_end', 1);
print '</div>';
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre("NumPiece", $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("Doctype", $_SERVER['PHP_SELF'], "t.doc_type", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Docref", $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("ThirdPartyAccount", $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Sens", $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<input type="text" size=4 class="flat" name="search_piece_num" value="' . $search_piece_num . '"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=7 class="flat" name="search_doc_type" value="' . $search_doc_type . '"/>';
print '</td>';
print '<td class="liste_titre">';
print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1);
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_doc_ref" value="' . $search_doc_ref . '"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_numero_compte" value="' . $search_numero_compte . '"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_subledger_account" value="' . $search_subledger_account . '"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_label_operation" value="' . $search_label_operation . '"/>';
print '</td>';
print '<td class="liste_titre">';
print '</td>';
print '<td class="liste_titre">';
print '</td>';
print '<td class="liste_titre">';
print '</td>';
print '<td class="liste_titre" align="center">';
print '<input type="text" size=2 class="flat" name="search_sens" value="' . $search_sens . '"/>';
print '</td>';
print '<td class="liste_titre" align="center">';
print '<input type="text" size=3 class="flat" name="search_code_journal" value="' . $search_code_journal . '"/>';
print '</td>';
print '<td align="right" colspan="2" class="liste_titre">';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '&nbsp;';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</td>';
print "</tr>\n";
foreach ( $object->lines as $line ) {
print '<tr class="oddeven">';
print '<td>' . $line->piece_num . '</td>' . "\n";
print '<td>' . $line->doc_type . '</td>' . "\n";
print '<td align="center">' . dol_print_date($line->doc_date) . '</td>';
print '<td>' . $line->doc_ref . '</td>';
print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_operation . '</td>';
print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($line->montant) . '</td>';
print '<td align="center">' . $line->sens . '</td>';
print '<td align="right">' . $line->code_journal . '</td>';
print '<td align="center"><a href="./card.php?action=update&amp;piece_num=' . $line->piece_num . '">' . img_edit() . '</a></td>';
print "</tr>\n";
}
print "</table>";
print '</form>';
llxFooter();
$db->close();

View File

@@ -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);

View File

@@ -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);

View File

@@ -30,6 +30,21 @@
*/
class AccountingAccount extends CommonObject
{
public $element='accounting_account';
public $table_element='accounting_account';
public $picto = 'billr';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
*/
public $restrictiononfksoc = 1;
var $db;
var $error;
var $errors;
@@ -48,13 +63,17 @@ class AccountingAccount extends CommonObject
var $active; // duplicate with status
var $status;
/**
* Constructor
*
* @param DoliDB $db Database handle
*/
function __construct($db) {
global $conf;
$this->db = $db;
$this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; // Used to add a filter in Form::showrefnav method
}
/**
@@ -63,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;
@@ -91,6 +110,7 @@ class AccountingAccount extends CommonObject
if ($obj) {
$this->id = $obj->rowid;
$this->rowid = $obj->rowid;
$this->ref = $obj->account_number;
$this->datec = $obj->datec;
$this->tms = $obj->tms;
$this->fk_pcg_version = $obj->fk_pcg_version;
@@ -115,7 +135,7 @@ class AccountingAccount extends CommonObject
$this->errors[] = "Error " . $this->db->lasterror();
}
}
return - 1;
return -1;
}
/**

View File

@@ -628,13 +628,15 @@ class BookKeeping extends CommonObject
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
* @return int <0 if KO, >=0 if OK
*/
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$this->lines = array();
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.doc_date,";
@@ -695,7 +697,6 @@ class BookKeeping extends CommonObject
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array ();
$resql = $this->db->query($sql);
if ($resql) {
@@ -737,7 +738,7 @@ class BookKeeping extends CommonObject
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
return -1;
}
}
@@ -875,9 +876,12 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
global $conf;
$this->lines = array();
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
@@ -920,7 +924,6 @@ class BookKeeping extends CommonObject
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array ();
$resql = $this->db->query($sql);
if ($resql) {

View File

@@ -56,18 +56,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) ";
@@ -94,13 +94,13 @@ class lettering extends BookKeeping
$sql .= " AND code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4) ";
$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 .= " ) ";
@@ -121,13 +121,13 @@ class lettering extends BookKeeping
$sql .= " WHERE bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=3) ";
$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 .= " ) ";
@@ -152,13 +152,13 @@ class lettering extends BookKeeping
$sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4) ";
$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 .= " ) ";
@@ -179,13 +179,13 @@ class lettering extends BookKeeping
$sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2) ";
$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 .= " ) ";

View File

@@ -64,7 +64,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if ($page < 0) $page = 0;
if (empty($page) || $page < 0) $page = 0;
$pageprev = $page - 1;
$pagenext = $page + 1;
$offset = $limit * $page;

View File

@@ -73,7 +73,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -505,4 +505,4 @@ jQuery(document).ready(function() {
</script>';
llxFooter();
$db->close();
$db->close();

View File

@@ -106,7 +106,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent','int');
$sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1);

View File

@@ -71,7 +71,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -200,7 +200,7 @@ $sql.= " aa.rowid as aarowid";
$sql.= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
$sql.= " WHERE er.fk_statut > 4 AND erd.fk_code_ventilation <= 0";
// Add search filter like
if (strlen(trim($search_expensereport))) {

View File

@@ -94,7 +94,7 @@ if ($pastmonth == 0) {
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@@ -225,7 +225,7 @@ if ($result) {
'accountancy_code' => $compta_user,
);
// Variable bookkeeping
// Variable bookkeeping ($obj->rowid is Bank Id)
$tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ...
$tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later
@@ -786,7 +786,7 @@ if (empty($action) || $action == 'view') {
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal;
@@ -932,7 +932,14 @@ if (empty($action) || $action == 'view') {
if ($tabtype[$key] == 'unknown')
{
// We will accept writing, but into a waiting account
print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will a waiting account
if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1')
{
print '<span class="error">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>';
}
else
{
print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will a waiting account
}
}
else
{
@@ -1094,7 +1101,7 @@ function getSourceDocRef($val, $typerecord)
$sqlmid = 'SELECT payd.fk_donation as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd";
$sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"];
$ref = $langs->trans("Donation").' ';
$ref = $langs->trans("Donation");
}
elseif ($typerecord == 'payment_various')
{
@@ -1103,15 +1110,25 @@ function getSourceDocRef($val, $typerecord)
$sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"];
$ref = $langs->trans("VariousPayment");
}
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
// Add warning
if (empty($sqlmid))
{
dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING);
}
else dol_print_error($db);
if ($sqlmid)
{
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
}
$ref = dol_trunc($langs->trans("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 ... i< < than max size of 300
return $ref;
}

View File

@@ -77,7 +77,7 @@ if ($pastmonth == 0) {
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@@ -528,7 +528,7 @@ if (empty($action) || $action == 'view') {
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal;
@@ -554,14 +554,15 @@ if (empty($action) || $action == 'view') {
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche form input[name=\"action\"]").val("exportcsv");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");
}
function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
console.log("click on writebookkeeping");
$("div.fiche form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");
}
</script>';

View File

@@ -86,7 +86,7 @@ if ($pastmonth == 0) {
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@@ -94,7 +94,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$idpays = $mysoc->country_id;
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, ";
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,";
$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";
@@ -180,9 +180,9 @@ if ($result) {
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
$tabfac[$obj->rowid]["refsologest"] = $obj->ref;
$tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier;
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->description;
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
//$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
// Avoid warnings
@@ -219,6 +219,9 @@ if ($action == 'writebookkeeping') {
$now = dol_now();
$error = 0;
$companystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db);
foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0;
@@ -228,22 +231,37 @@ if ($action == 'writebookkeeping') {
$db->begin();
$companystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db);
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client'];
$companystatic->fournisseur = 1;
$invoicestatic->id = $key;
$invoicestatic->ref = (string) $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->ref_supplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$invoicestatic->close_code = $val["close_code"];
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1)
{
continue;
}
// Thirdparty
if (! $errorforline)
@@ -262,7 +280,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->subledger_label = ''; // TODO To complete
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount");
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount");
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
@@ -313,7 +331,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
@@ -370,7 +388,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
@@ -420,7 +438,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' NPR';
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT").' NPR';
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
@@ -523,65 +541,84 @@ if ($action == 'exportcsv') {
foreach ( $tabfac as $key => $val )
{
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->ref = $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = dol_trunc($val["description"], 32);
$invoicestatic->id = $key;
$invoicestatic->ref = $val["refsologest"];
$invoicestatic->ref_supplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = dol_trunc(html_entity_decode($val["description"]), 32);
$invoicestatic->close_code = $val["close_code"];
$date = dol_print_date($val["date"], 'day');
$date = dol_print_date($val["date"], 'day');
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1)
{
continue;
}
// 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";
}
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
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 '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '""' . $sep;
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $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) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["refsologest"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '""' . $sep;
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print "\n";
}
}
// VAT
$listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
// VAT
$listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
foreach ($arrayofvat[$key] as $k => $mt) {
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
@@ -600,21 +637,24 @@ if ($action == 'exportcsv') {
}
// VAT counterpart for NPR
foreach ( $tabother[$key] as $k => $mt ) {
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 '"' . length_accounta(html_entity_decode($k)) . '"' . $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("VAT") . ' NPR"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print "\n";
if (is_array($tabother[$key]))
{
foreach ( $tabother[$key] as $k => $mt ) {
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 '"' . length_accounta(html_entity_decode($k)) . '"' . $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("VAT") . ' NPR"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print "\n";
}
}
}
}
@@ -638,7 +678,7 @@ if (empty($action) || $action == 'view') {
}
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal;
@@ -669,6 +709,7 @@ if (empty($action) || $action == 'view') {
$("div.fiche form input[name=\"action\"]").val("");
}
function writebookkeeping() {
console.log("click on writebookkeeping");
$("div.fiche form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");
@@ -699,27 +740,62 @@ if (empty($action) || $action == 'view') {
$invoicestatic = new FactureFournisseur($db);
$companystatic = new Fournisseur($db);
foreach ( $tabfac as $key => $val ) {
foreach ( $tabfac as $key => $val )
{
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];
$invoicestatic->ref = $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$invoicestatic->ref_supplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = dol_trunc(html_entity_decode($val["description"]), 32);
$invoicestatic->close_code = $val["close_code"];
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1)
{
print '<tr class="oddeven">';
print "<td><!-- Replaced invoice --></td>";
print "<td>" . $date . "</td>";
print "<td><strike>" . $invoicestatic->getNomUrl(1) . "</strike></td>";
// Account
print "<td>";
print $langs->trans("Replaced");
print '</td>';
// Subledger account
print "<td>";
print '</td>';
print "<td>";
print "</td>";
print '<td align="right"></td>';
print '<td align="right"></td>';
print "</tr>";
continue;
}
// 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>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->supplier_code = $tabcompany[$key]['code_supplier'];
// Account
print "<td>";
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
@@ -738,7 +814,7 @@ if (empty($action) || $action == 'view') {
}
else print $accountoshow;
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</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>";
@@ -768,7 +844,7 @@ if (empty($action) || $action == 'view') {
print '</td>';
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $accountingaccount->label . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
@@ -801,7 +877,7 @@ if (empty($action) || $action == 'view') {
print "<td>";
print '</td>';
print "<td>";
print $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
print $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
print "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
@@ -811,32 +887,32 @@ if (empty($action) || $action == 'view') {
}
// VAT counterpart for NPR
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>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->supplier_code = $tabcompany[$key]['code_supplier'];
// 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->refsupplier . ' - ' . $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>";
}
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>';
}
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>";
}
}
}
print "</table>";

View File

@@ -81,7 +81,7 @@ if ($pastmonth == 0) {
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@@ -89,7 +89,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$idpays = $mysoc->country_id;
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr,";
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,";
$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";
@@ -115,10 +115,12 @@ if ($date_start && $date_end)
if ($in_bookkeeping == 'already')
{
$sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
// $sql .= " AND fd.rowid IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
}
if ($in_bookkeeping == 'notyet')
{
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
// $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
}
$sql .= " ORDER BY f.datef";
@@ -188,6 +190,7 @@ if ($result) {
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
//$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
// Avoid warnings
@@ -220,6 +223,9 @@ if ($action == 'writebookkeeping') {
$now = dol_now();
$error = 0;
$companystatic = new Societe($db);
$invoicestatic = new Facture($db);
foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0;
@@ -229,19 +235,35 @@ if ($action == 'writebookkeeping') {
$db->begin();
$companystatic = new Societe($db);
$invoicestatic = new Facture($db);
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client'];
$companystatic->client = 3;
$invoicestatic->id = $key;
$invoicestatic->ref = (string) $val["ref"];
$invoicestatic->type = $val["type"];
$invoicestatic->close_code = $val["close_code"];
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1)
{
continue;
}
// Thirdparty
if (! $errorforline)
@@ -478,13 +500,34 @@ if ($action == 'exportcsv') {
{
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = 3;
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->ref = (string) $val["ref"];
$invoicestatic->type = $val["type"];
$invoicestatic->close_code = $val["close_code"];
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1)
{
continue;
}
// Third party
foreach ($tabttc[$key] as $k => $mt) {
print '"' . $key . '"' . $sep;
@@ -569,7 +612,7 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DepositsAreIncluded");
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal;
@@ -600,6 +643,7 @@ if (empty($action) || $action == 'view') {
$("div.fiche form input[name=\"action\"]").val("");
}
function writebookkeeping() {
console.log("click on writebookkeeping");
$("div.fiche form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");
@@ -627,25 +671,64 @@ if (empty($action) || $action == 'view') {
$r = '';
$invoicestatic = new Facture($db);
$companystatic = new Client($db);
$invoicestatic = new Facture($db);
foreach ( $tabfac as $key => $val )
{
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = 3;
foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->ref = (string) $val["ref"];
$invoicestatic->type = $val["type"];
$invoicestatic->close_code = $val["close_code"];
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1)
{
print '<tr class="oddeven">';
print "<td><!-- Replaced invoice --></td>";
print "<td>" . $date . "</td>";
print "<td><strike>" . $invoicestatic->getNomUrl(1) . "</strike></td>";
// Account
print "<td>";
print $langs->trans("Replaced");
print '</td>';
// Subledger account
print "<td>";
print '</td>';
print "<td>";
print "</td>";
print '<td align="right"></td>';
print '<td align="right"></td>';
print "</tr>";
continue;
}
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
foreach ($tabttc[$key] as $k => $mt)
{
print '<tr class="oddeven">';
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->customer_code = $tabcompany[$key]['code_client'];
// Account
print "<td>";
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
@@ -671,7 +754,8 @@ if (empty($action) || $action == 'view') {
}
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
foreach ($tabht[$key] as $k => $mt)
{
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
@@ -703,7 +787,8 @@ if (empty($action) || $action == 'view') {
// VAT
$listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) {
foreach ($listoftax as $numtax)
{
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;

View File

@@ -114,7 +114,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1);

View File

@@ -73,7 +73,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@@ -15,6 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
}
$prefix = $conf->global->ACCOUNTING_EXPORT_PREFIX_SPEC;
$format = $conf->global->ACCOUNTING_EXPORT_FORMAT;
$nodateexport = $conf->global->ACCOUNTING_EXPORT_NO_DATE_IN_FILENAME;

View File

@@ -53,7 +53,7 @@ if ($action == 'updateall')
{
$db->begin();
$res1=$res2=$res3=$res4=$res5=$res6=0;
$res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha')?0:1, 'chaine', 0, '', $conf->entity);
$res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
$res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
@@ -162,7 +162,7 @@ print "</tr>\n";
// Login/Pass required for members
print '<tr class="oddeven"><td>'.$langs->trans("AdherentLoginRequired").'</td><td>';
print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED',(! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?0:1),1);
print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?0:1), 1);
print "</td></tr>\n";
// Mail required for members

View File

@@ -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();

View File

@@ -14,8 +14,15 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
}
?>
<!-- BEGIN PHP TEMPLATE ADHERENTCARD_CREATE.TPL.PHP DEFAULT -->

View File

@@ -14,9 +14,16 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
}
$contact = $GLOBALS['objcanvas']->control->object;
?>

View File

@@ -14,10 +14,18 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
}
$contact = $GLOBALS['objcanvas']->control->object;
?>
<!-- BEGIN PHP TEMPLATE ADHERENTCARD_VIEW.TPL.PHP DEFAULT -->

View File

@@ -528,7 +528,10 @@ class Adherent extends CommonObject
{
//var_dump($this->user_login);exit;
//var_dump($this->login);exit;
$luser->login=$this->login;
// If option ADHERENT_LOGIN_NOT_REQUIRED is on, there is no login of member, so we do not overwrite user login to keep existing one.
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login=$this->login;
$luser->civility_id=$this->civility_id;
$luser->firstname=$this->firstname;
$luser->lastname=$this->lastname;
@@ -1303,11 +1306,6 @@ class Adherent extends CommonObject
$this->last_subscription_amount=$montant;
$this->last_subscription_date_start=$date;
$this->last_subscription_date_end=$datefin;
// Call trigger
$result=$this->call_trigger('MEMBER_SUBSCRIPTION',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)

View File

@@ -225,13 +225,13 @@ class Members extends DolibarrApi
// If there is no error, update() returns the number of affected rows
// so if the update is a no op, the return value is zero.
if($member->update(DolibarrApiAccess::$user) >= 0)
if ($member->update(DolibarrApiAccess::$user) >= 0)
{
return $this->get($id);
}
else
{
throw new RestException(500, $this->task->error);
throw new RestException(500, $member->error);
}
}

View File

@@ -209,7 +209,7 @@ class MembersTypes extends DolibarrApi
}
else
{
throw new RestException(500, $this->task->error);
throw new RestException(500, $membertype->error);
}
}

View File

@@ -198,7 +198,7 @@ class Subscriptions extends DolibarrApi
}
else
{
throw new RestException(500, $this->task->error);
throw new RestException(500, $subscription->error);
}
}

View File

@@ -59,13 +59,16 @@ class Subscription extends CommonObject
/**
* Function who permitted cretaion of the subscription
*
* @param int $userid userid de celui qui insere
* @return int <0 if KO, Id subscription created if OK
* @param User $user User that create
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id subscription created if OK
*/
function create($userid)
function create($user, $notrigger = false)
{
global $langs;
$error = 0;
$now=dol_now();
// Check parameters
@@ -75,6 +78,8 @@ class Subscription extends CommonObject
return -1;
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, datec, dateadh, datef, subscription, note)";
$sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($now)."',";
$sql.= " '".$this->db->idate($this->dateh)."',";
@@ -82,17 +87,32 @@ class Subscription extends CommonObject
$sql.= " ".$this->amount.",";
$sql.= " '".$this->db->escape($this->note)."')";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."subscription");
return $this->id;
if (! $resql) {
$error++;
$this->errors[] = $this->db->lasterror();
}
else
if (! $error)
{
$this->error=$this->db->lasterror();
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
}
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
@@ -154,8 +174,10 @@ class Subscription extends CommonObject
* @param int $notrigger 0=Disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user,$notrigger=0)
function update($user, $notrigger=0)
{
$error = 0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
@@ -177,14 +199,26 @@ class Subscription extends CommonObject
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
$this->db->commit();
return 1;
if (! $error && ! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY',$user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
else
{
$this->db->rollback();
$error++;
$this->error=$this->db->lasterror();
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
@@ -192,10 +226,13 @@ class Subscription extends CommonObject
* Delete a subscription
*
* @param User $user User that delete
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, 0 if not found, >0 if OK
*/
function delete($user)
function delete($user, $notrigger=false)
{
$error = 0;
// It subscription is linked to a bank transaction, we get it
if ($this->fk_bank > 0)
{
@@ -206,51 +243,71 @@ class Subscription extends CommonObject
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->affected_rows($resql);
if ($num)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
if (! $error) {
if (! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined)
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->affected_rows($resql);
if ($num)
{
$result=$accountline->delete($user); // Return false if refused because line is conciliated
if ($result > 0)
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined)
{
$this->db->commit();
return 1;
$result=$accountline->delete($user); // Return false if refused because line is conciliated
if ($result > 0)
{
$this->db->commit();
return 1;
}
else
{
$this->error=$accountline->error;
$this->db->rollback();
return -1;
}
}
else
{
$this->error=$accountline->error;
$this->db->rollback();
return -1;
$this->db->commit();
return 1;
}
}
else
{
$this->db->commit();
return 1;
return 0;
}
}
else
{
$this->db->commit();
return 0;
$error++;
$this->error=$this->db->lasterror();
}
}
else
{
$this->error=$this->db->lasterror();
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return 1;
}
}

View File

@@ -42,10 +42,6 @@ $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check
if ($user->societe_id > 0)
{
$id = $user->societe_id;
}
$result=restrictedArea($user,'adherent',$id);
// Get parameters

View File

@@ -401,7 +401,7 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre_filter">';
// Line numbering
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
{
print '<td class="liste_titre">&nbsp;</td>';
}
@@ -552,10 +552,7 @@ print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
{
print '<td colspan="1" align="center">'.$langs->trans("NumberingShort").'</td>';
}
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID",$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder);
@@ -611,9 +608,9 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
{
print '<td align="center">'.($i+1).'</td>';
print '<td align="center">'.$obj->rowid.'</td>';
}
// Ref

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
@@ -36,18 +36,28 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
$langs->load("companies");
$langs->load("bills");
$langs->load("members");
$langs->load("users");
$langs->load("mails");
$langs->load('other');
$langs->loadLangs(array("companies","bills","members","users","mails",'other'));
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$rowid=GETPOST('rowid','int');
$rowid=GETPOST('rowid','int')?GETPOST('rowid','int'):GETPOST('id','int');
$typeid=GETPOST('typeid','int');
// 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;
// Default sort order (if not yet defined by previous GETPOST)
if (! $sortfield) $sortfield="c.rowid";
if (! $sortorder) $sortorder="DESC";
// Security check
$result=restrictedArea($user,'adherent',$rowid,'','cotisation');
@@ -98,6 +108,7 @@ $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') :
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
/*
* Actions
*/
@@ -582,6 +593,16 @@ $title=$langs->trans("Member") . " - " . $langs->trans("Subscriptions");
$helpurl="EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
llxHeader("",$title,$helpurl);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
$param.= '&id='.$rowid;
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
if ($rowid > 0)
{
$res=$object->fetch($rowid);
@@ -776,7 +797,7 @@ if ($rowid > 0)
/*
* Hotbar
* Action buttons
*/
// Button to create a new subscription if member no draft neither resiliated
@@ -810,6 +831,7 @@ if ($rowid > 0)
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
$sql.= $db->order($sortfield, $sortorder);
$result = $db->query($sql);
if ($result)
@@ -822,7 +844,7 @@ if ($rowid > 0)
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print_liste_field_titre('Ref',$_SERVER["PHP_SELF"],'c.rowid','',$param,'',$sortfield,$sortorder);
print '<td align="center">'.$langs->trans("DateCreation").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
@@ -1016,8 +1038,9 @@ if ($rowid > 0)
$paymentdate=dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
}
print '<tr>';
// Date start subscription
print '<tr><td width="30%" class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
print '<td class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
if (GETPOST('reday'))
{
$datefrom=dol_mktime(0,0,0,GETPOST('remonth'),GETPOST('reday'),GETPOST('reyear'));

View File

@@ -36,7 +36,7 @@ $langs->load("users");
if (!$user->rights->adherent->lire)
accessforbidden();
$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
$rowid=GETPOST("rowid",'int');
@@ -44,10 +44,10 @@ $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
* View
*/
llxHeader();
$form = new Form($db);
llxHeader();
$object = new Subscription($db);
$result = $object->fetch($rowid);

View File

@@ -15,8 +15,15 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
}
?>
<!-- BEGIN PHP TEMPLATE -->
@@ -33,7 +40,7 @@ $var=true;
$total=0;
foreach($linkedObjectBlock as $key => $objectlink)
{
?>
<tr <?php echo $GLOBALS['bc'][$var]; ?> >
<td><?php echo $langs->trans("Subscription"); ?></td>

View File

@@ -262,17 +262,17 @@ if ($action == 'removelogo')
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$logofile=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
dol_delete_file($logofile);
if ($mysoc->logo != '') dol_delete_file($logofile);
dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO",$conf->entity);
$mysoc->logo='';
$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
dol_delete_file($logosmallfile);
if ($mysoc->logo_small != '') dol_delete_file($logosmallfile);
dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity);
$mysoc->logo_small='';
$logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini;
dol_delete_file($logominifile);
if ($mysoc->logo_mini != '') dol_delete_file($logominifile);
dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$conf->entity);
$mysoc->logo_mini='';
}
@@ -370,7 +370,6 @@ if ($action == 'edit' || $action == 'updateedit')
print '</td></tr>'."\n";
// Web
print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
print '<input name="web" id="web" class="minwidth300" value="'. $conf->global->MAIN_INFO_SOCIETE_WEB . '"></td></tr>';
print '</td></tr>'."\n";
@@ -384,8 +383,7 @@ if ($action == 'edit' || $action == 'updateedit')
}
// Logo
print '<tr'.dol_bc($var,'hideonsmartphone').'><td><label for="logo">'.$langs->trans("Logo").' (png,jpg)</label></td><td>';
print '<tr class="oddeven hideonsmartphone"><td><label for="logo">'.$langs->trans("Logo").' (png,jpg)</label></td><td>';
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
print '<input type="file" class="flat class=minwidth200" name="logo" id="logo">';
print '</td><td class="nocellnopadd" valign="middle" align="right">';
@@ -402,7 +400,6 @@ if ($action == 'edit' || $action == 'updateedit')
print '</td></tr>';
// Note
print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(GETPOST('note','none') ? GETPOST('note','none') : $conf->global->MAIN_INFO_SOCIETE_NOTE).'</textarea></td></tr>';
print '</td></tr>';

View File

@@ -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";
@@ -197,7 +197,7 @@ $tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREF
$tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")";
$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
@@ -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";
@@ -275,7 +275,7 @@ $tabfield[19]= "code,libelle";
$tabfield[20]= "code,libelle";
$tabfield[21]= "code,label";
$tabfield[22]= "code,label";
$tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[24]= "code,label";
//$tabfield[25]= "label,type_template,private,position,topic,content_lines,content";
$tabfield[26]= "code,label,short_label";
@@ -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";
@@ -314,7 +314,7 @@ $tabfieldvalue[19]= "code,libelle";
$tabfieldvalue[20]= "code,libelle";
$tabfieldvalue[21]= "code,label";
$tabfieldvalue[22]= "code,label";
$tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[24]= "code,label";
//$tabfieldvalue[25]= "label,type_template,private,position,topic,content_lines,content";
$tabfieldvalue[26]= "code,label,short_label";
@@ -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";
@@ -353,7 +353,7 @@ $tabfieldinsert[19]= "code,libelle";
$tabfieldinsert[20]= "code,libelle";
$tabfieldinsert[21]= "code,label";
$tabfieldinsert[22]= "code,label";
$tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[24]= "code,label";
//$tabfieldinsert[25]= "label,type_template,private,position,topic,content_lines,content,entity";
$tabfieldinsert[26]= "code,label,short_label";
@@ -472,7 +472,7 @@ $tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[23] = array();
$tabhelp[23] = array('revenuestamp_type'=>'FixedOfPercent');
$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
//$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'content_lines'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
@@ -651,6 +651,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated';
if ($fieldnamekey == 'revenuestamp_type') $fieldnamekey = 'TypeOfRevenueStamp';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
@@ -1117,7 +1118,8 @@ if ($id)
if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); }
if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); }
if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat'){ $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); }
if ($id == 2) // Special cas for state page
{
@@ -1343,7 +1345,8 @@ if ($id)
if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); }
if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); }
if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat'){ $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); }
// Affiche nom du champ
if ($showfield)

103
htdocs/admin/export.php Normal file
View 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">&nbsp;</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">&nbsp;</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();

View File

@@ -127,7 +127,7 @@ if ($_POST["delete"])
// Supprime boite box_external_rss de definition des boites
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE file = 'box_external_rss.php' AND note LIKE '".GETPOST("norss")." %'";
$sql.= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss"))." %'";
$resql=$db->query($sql);
if ($resql)
@@ -268,19 +268,19 @@ if ($resql)
print '</td>';
print "</tr>";
print '<tr class="oddeven">';
print "<td width=\"100px\">".$langs->trans("Title")."</td>";
print "<td><input type=\"text\" class=\"flat minwidth300\" name=\"external_rss_title_" . $idrss . "\" value=\"" . $conf->global->$keyrsstitle . "\"></td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td>".$langs->trans("URL")."</td>";
print "<td><input type=\"text\" class=\"flat minwidth300\" name=\"external_rss_urlrss_" . $idrss . "\" value=\"" . $conf->global->$keyrssurl . "\"></td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td>".$langs->trans("Status")."</td>";
print "<td>";
@@ -301,7 +301,7 @@ if ($resql)
// Logo
if ($result > 0 && empty($rss->error))
{
print '<tr class="oddeven">';
print "<td>".$langs->trans("Logo")."</td>";
print '<td>';

View File

@@ -80,8 +80,8 @@ print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'
if (! empty($setupcompanynotcomplete))
{
$langs->load("errors");
$warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete"));
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit').'">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
$warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"');
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit').'">'.$warnpicto.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
}
print '<br>';
print '<br>';
@@ -92,8 +92,8 @@ print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'
if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled
{
$langs->load("errors");
$warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete"));
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
$warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"');
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$warnpicto.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
}
print '<br>';
print '<br>';

View File

@@ -189,8 +189,10 @@ foreach($listofnotifiedevents as $notifiedevent)
print '</td></tr>';
print '</table>';
print '<div class="opacitymedium">';
print '* '.$langs->trans("GoOntoUserCardToAddMore").'<br>';
if (! empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>';
print '</div>';
print '<br><br>';

View File

@@ -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"

View File

@@ -186,7 +186,7 @@ foreach($configfileparameters as $key)
if ($newkey == 'dolibarr_main_db_pass') print preg_replace('/./i','*',${$newkey});
else if ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/',${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT');
else print ${$newkey};
if ($newkey == 'dolibarr_main_url_root' && $newkey != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')';
if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')';
print "</td>";
}
print "</tr>\n";

View File

@@ -389,7 +389,7 @@ foreach($configfileparameters as $key => $value)
}
}
else print ${$newkey};
if ($newkey == 'dolibarr_main_url_root' && $newkey != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')';
if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')';
print "</td>";
}
print "</tr>\n";

View File

@@ -180,7 +180,7 @@ jQuery(document).ready(function() {
var compcssstring;
getcssurl = $.ajax({
type: "GET",
url: \''.DOL_URL_ROOT.'/includes/jquery/css/smoothness/jquery-ui.css\',
url: \''.DOL_URL_ROOT.'/includes/jquery/css/base/jquery-ui.css\',
cache: false,
/* async: false, */
/*crossDomain: true, */

View File

@@ -428,14 +428,14 @@ if ($mode == 'searchkey')
$filearray=dol_dir_list($dir_lang_osencoded,'files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1);
foreach($filearray as $file)
{
$tmpfile=preg_replace('/.lang/i', '', basename($file['name']));
$moduledirname =(basename(dirname(dirname($dir_lang))));
$tmpfile=preg_replace('/.lang/i', '', basename($file['name']));
$moduledirname =(basename(dirname(dirname($dir_lang))));
$langkey=$tmpfile;
if ($i > 0) $langkey.='@'.$moduledirname;
//var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
$langkey=$tmpfile;
if ($i > 0) $langkey.='@'.$moduledirname;
//var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
$result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
$result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
$result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
if ($result < 0) print 'Failed to load language file '.$tmpfile.'<br>'."\n";
else $nbtotaloffiles++;
@@ -447,8 +447,8 @@ if ($mode == 'searchkey')
// Now search into translation array
foreach($newlang->tab_translate as $key => $val)
{
if ($transkey && ! preg_match('/'.preg_quote($transkey).'/i', $key)) continue;
if ($transvalue && ! preg_match('/'.preg_quote($transvalue).'/i', $val)) continue;
if ($transkey && ! preg_match('/'.preg_quote($transkey,'/').'/i', $key)) continue;
if ($transvalue && ! preg_match('/'.preg_quote($transvalue,'/').'/i', $val)) continue;
$recordtoshow[$key]=$val;
}
}

View File

@@ -26,6 +26,7 @@ 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';
@@ -75,7 +76,7 @@ $tablib[1] = "Websites";
// Requests to extract data
$tabsql=array();
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.status FROM ".MAIN_DB_PREFIX."website as f";
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.status FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
// Criteria to sort dictionaries
$tabsqlsort=array();
@@ -116,6 +117,11 @@ $tabfieldcheck[1] = array();
$elementList = array();
$sourceList=array();
/*
* Actions
*/
// Actions add or modify a website
if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha'))
{
@@ -128,19 +134,20 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha'))
$ok=1;
foreach ($listfield as $f => $value)
{
if ((! isset($_POST[$value]) || $_POST[$value]=='')
&& (! in_array($listfield[$f], array('virtualhost')))) // Fields that are not mandatory
{
$ok=0;
$fieldnamekey=$listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
if ($value == 'ref' && ! preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
{
if ($value == 'ref' && (! isset($_POST[$value]) || $_POST[$value]==''))
{
$ok=0;
$fieldnamekey=$listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
break;
}
elseif ($value == 'ref' && ! preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
{
$ok=0;
$fieldnamekey=$listfield[$f];
$fieldnamekey=$listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
break;
}
}
// Clean parameters
@@ -206,29 +213,6 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha'))
$result = $db->query($sql);
if ($result) // Add is ok
{
global $dolibarr_main_data_root;
$pathofwebsite=$dolibarr_main_data_root.'/website/'.$websitekey;
$filehtmlheader=$pathofwebsite.'/htmlheader.html';
$filecss=$pathofwebsite.'/styles.css.php';
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
$fileindex=$pathofwebsite.'/index.php';
// Css file
$csscontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
$csscontent.= '<!-- File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THE FILE styles.css.php. Change affects all pages of website. -->'."\n";
$csscontent.= '<?php '."\n";
$csscontent.= "header('Content-type: text/css');\n";
$csscontent.= "?>"."\n";
$csscontent.= '<!-- END -->'."\n";
$csscontent.= 'body { margin: 0; }'."\n";
dol_syslog("Save file css into ".$filecss);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filecss, $csscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
unset($_POST); // Clean $_POST array, we keep only
}
@@ -335,21 +319,36 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
$sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'";
$result = $db->query($sql);
$website = new Website($db);
$website->fetch($rowid);
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
$result = $db->query($sql);
if (! $result)
if ($website->id > 0)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
}
else
{
dol_print_error($db);
}
$sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'";
$result = $db->query($sql);
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
$result = $db->query($sql);
if (! $result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
}
else
{
dol_print_error($db);
}
}
if ($website->ref)
{
dol_delete_dir_recursive($conf->website->dir_output.'/'.$website->ref);
}
}
else
{
dol_print_error($db, 'Failed to load website with id '.$rowid);
}
}
@@ -523,7 +522,6 @@ if ($id)
print '</form>';
// List of websites in database
$resql=$db->query($sql);
if ($resql)
@@ -618,7 +616,8 @@ if ($id)
}
// Can an entry be erased or disabled ?
$iserasable=1;$isdisable=1; // true by default
$iserasable=1; $isdisable=1; // true by default
if ($obj->status) $iserasable=0; // We can't delete a website on. Disable it first.
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;';
@@ -628,12 +627,11 @@ if ($id)
print "</td>";
// Modify link
if ($iserasable) print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
else print '<td>&nbsp;</td>';
print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
// Delete link
if ($iserasable) print '<td align="center"><a href="'.$url.'action=delete">'.img_delete().'</a></td>';
else print '<td>&nbsp;</td>';
else print '<td align="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>';
print "</tr>\n";
}

View File

@@ -97,6 +97,7 @@ class DolibarrApi
// Remove $db object property for object
unset($object->db);
unset($object->ismultientitymanaged);
unset($object->restrictiononfksoc);
// Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses
unset($object->linkedObjects);
@@ -104,7 +105,6 @@ class DolibarrApi
unset($object->lignes); // we don't want lignes, we want only ->lines
unset($object->fields);
unset($object->oldline);
unset($object->error);
@@ -141,6 +141,8 @@ class DolibarrApi
unset($object->picto);
unset($object->facturee); // Replace with billed
unset($object->fieldsforcombobox);
unset($object->comments);
unset($object->skip_update_total);
unset($object->context);
@@ -157,23 +159,48 @@ class DolibarrApi
unset($object->oldcopy);
// If object has lines, remove $db property
if(isset($object->lines) && count($object->lines) > 0) {
if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) {
$nboflines = count($object->lines);
for ($i=0; $i < $nboflines; $i++)
{
$this->_cleanObjectDatas($object->lines[$i]);
unset($object->lines[$i]->contact);
unset($object->lines[$i]->contact_id);
unset($object->lines[$i]->country);
unset($object->lines[$i]->country_id);
unset($object->lines[$i]->country_code);
unset($object->lines[$i]->mode_reglement_id);
unset($object->lines[$i]->mode_reglement_code);
unset($object->lines[$i]->mode_reglement);
unset($object->lines[$i]->cond_reglement_id);
unset($object->lines[$i]->cond_reglement_code);
unset($object->lines[$i]->cond_reglement);
unset($object->lines[$i]->fk_delivery_address);
unset($object->lines[$i]->fk_projet);
unset($object->lines[$i]->thirdparty);
unset($object->lines[$i]->user);
unset($object->lines[$i]->model_pdf);
unset($object->lines[$i]->modelpdf);
unset($object->lines[$i]->note_public);
unset($object->lines[$i]->note_private);
unset($object->lines[$i]->fk_incoterms);
unset($object->lines[$i]->libelle_incoterms);
unset($object->lines[$i]->location_incoterms);
unset($object->lines[$i]->name);
unset($object->lines[$i]->lastname);
unset($object->lines[$i]->firstname);
unset($object->lines[$i]->civility_id);
unset($object->lines[$i]->fk_multicurrency);
unset($object->lines[$i]->multicurrency_code);
unset($object->lines[$i]->shipping_method_id);
}
}
// If object has linked objects, remove $db property
/*
if(isset($object->linkedObjects) && count($object->linkedObjects) > 0) {
foreach($object->linkedObjects as $type_object => $linked_object) {
foreach($linked_object as $object2clean) {
$this->_cleanObjectDatas($object2clean);
}
}
}*/
if (! empty($object->thirdparty) && is_object($object->thirdparty))
{
$this->_cleanObjectDatas($object->thirdparty);
}
return $object;
}

View File

@@ -58,19 +58,16 @@ class Documents extends DolibarrApi
*
* @param string $module_part Name of module or area concerned by file download ('facture', ...)
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf)
* @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases.
* Also, note that setting this to 1 nead write access on object.
* @return array List of documents
*
* @throws 500
* @throws 501
* @throws 400
* @throws 401
* @throws 404
* @throws 200
*
* @url GET /download
*/
public function index($module_part, $original_file='', $regeneratedoc=0)
public function index($module_part, $original_file='')
{
global $conf, $langs;
@@ -78,13 +75,13 @@ class Documents extends DolibarrApi
throw new RestException(400, 'bad value for parameter modulepart');
}
if (empty($original_file)) {
throw new RestException(400, 'bad value for parameter ref or subdir');
throw new RestException(400, 'bad value for parameter original_file');
}
//--- Finds and returns the document
$entity=$conf->entity;
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', ($regeneratedoc ? 'write' : 'read'));
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
$accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file'];
@@ -97,42 +94,6 @@ class Documents extends DolibarrApi
throw new RestException(401);
}
// --- Generates the document
if ($regeneratedoc)
{
$hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1;
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
if ($module_part == 'facture' || $module_part == 'invoice')
{
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$this->invoice = new Facture($this->db);
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->generateDocument($this->invoice->modelpdf, $langs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) {
throw new RestException(500, 'Error generating document');
}
}
if ($module_part == 'commande' || $module_part == 'order')
{
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$this->order = new Commande($this->db);
$result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$result = $this->order->generateDocument($this->order->modelpdf, $langs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) {
throw new RestException(500, 'Error generating document');
}
}
}
$filename = basename($original_file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
@@ -145,17 +106,143 @@ class Documents extends DolibarrApi
return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' );
}
/**
* Build a document.
*
* Test sample 1: { "module_part": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }.
*
* @param string $module_part Name of module or area concerned by file download ('invoice', 'order', ...).
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf).
* @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template).
* @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language).
* @return array List of documents
*
* @throws 500
* @throws 501
* @throws 400
* @throws 401
* @throws 404
* @throws 200
*
* @url PUT /builddoc
*/
public function builddoc($module_part, $original_file='', $doctemplate='', $langcode='')
{
global $conf, $langs;
if (empty($module_part)) {
throw new RestException(400, 'bad value for parameter modulepart');
}
if (empty($original_file)) {
throw new RestException(400, 'bad value for parameter original_file');
}
$outputlangs = $langs;
if ($langcode && $langs->defaultlang != $langcode)
{
$outputlangs=new Translate('', $conf);
$outputlangs->setDefaultLang($langcode);
}
//--- Finds and returns the document
$entity=$conf->entity;
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'write');
$accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file'];
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) {
throw new RestException(401);
}
if (!$accessallowed) {
throw new RestException(401);
}
// --- Generates the document
$hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1;
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
$templateused='';
if ($module_part == 'facture' || $module_part == 'invoice')
{
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$this->invoice = new Facture($this->db);
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
$templateused = $doctemplate?$doctemplate:$this->invoice->modelpdf;
$result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) {
throw new RestException(500, 'Error generating document');
}
}
elseif ($module_part == 'commande' || $module_part == 'order')
{
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$this->order = new Commande($this->db);
$result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$templateused = $doctemplate?$doctemplate:$this->order->modelpdf;
$result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) {
throw new RestException(500, 'Error generating document');
}
}
elseif ($module_part == 'propal' || $module_part == 'proposal')
{
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$this->propal = new Propal($this->db);
$result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
$templateused = $doctemplate?$doctemplate:$this->propal->modelpdf;
$result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) {
throw new RestException(500, 'Error generating document');
}
}
else
{
throw new RestException(403, 'Generation not available for this modulepart');
}
$filename = basename($original_file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
if (! file_exists($original_file_osencoded))
{
throw new RestException(404, 'File not found');
}
$file_content=file_get_contents($original_file_osencoded);
return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' );
}
/**
* Return the list of documents of a dedicated element (from its ID or Ref)
*
* @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'facture', 'project', ...)
* @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'shipment', 'project', ...)
* @param int $id ID of element
* @param string $ref Ref of element
* @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size')
* @param string $sortorder Sort order ('asc' or 'desc')
* @return array Array of documents with path
*
* @throws RestException
* @throws 200
* @throws 400
* @throws 401
* @throws 404
* @throws 500
*
* @url GET /
*/
@@ -205,6 +292,70 @@ class Documents extends DolibarrApi
$upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member');
}
else if ($modulepart == 'propal' || $modulepart == 'proposal')
{
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
$object = new Propal($this->db);
$result=$object->fetch($id, $ref);
if ( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
$upload_dir = $conf->propal->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'propal');
}
else if ($modulepart == 'commande' || $modulepart == 'order')
{
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
$object = new Commande($this->db);
$result=$object->fetch($id, $ref);
if ( ! $result ) {
throw new RestException(404, 'Order not found');
}
$upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande');
}
else if ($modulepart == 'shipment' || $modulepart == 'expedition')
{
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
if (!DolibarrApiAccess::$user->rights->expedition->lire) {
throw new RestException(401);
}
$object = new Expedition($this->db);
$result=$object->fetch($id, $ref);
if ( ! $result ) {
throw new RestException(404, 'Shipment not found');
}
$upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment');
}
else if ($modulepart == 'facture' || $modulepart == 'invoice')
{
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401);
}
$object = new Facture($this->db);
$result=$object->fetch($id, $ref);
if ( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
$upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice');
}
else
{
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
@@ -212,7 +363,7 @@ class Documents extends DolibarrApi
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
if (empty($filearray)) {
throw new RestException(404, 'Modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' and Ref '.$object->ref:'').' does not have any documents.');
throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.');
}
return $filearray;
@@ -237,19 +388,23 @@ class Documents extends DolibarrApi
* Upload a file.
*
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }.
*
* @param string $filename Name of file to create ('FA1705-0123.txt')
* @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...)
* @param string $ref Reference of object (This will define subdir automatically and store submited file into it)
* @param string $subdir Subdirectory (Only if ref not provided)
* @param string $subdir Subdirectory (Only if ref not provided)
* @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided)
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64)
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'}
* @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return bool State of copy
* @throws RestException
*
* @url GET /upload
* @throws 200
* @throws 400
* @throws 401
* @throws 404
* @throws 500
*
* @url POST /upload
*/
public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0)
{
@@ -303,7 +458,7 @@ class Documents extends DolibarrApi
$task_result = $object->fetch('', $ref);
// Fetching the tasks project is required because its out_dir might be a subdirectory of the project
// Fetching the tasks project is required because its out_dir might be a sub-directory of the project
if($task_result > 0)
{
$project_result = $object->fetch_projet();
@@ -330,7 +485,7 @@ class Documents extends DolibarrApi
if($result == 0)
{
throw new RestException(500, "Object with ref '".$ref.'" was not found.');
throw new RestException(404, "Object with ref '".$ref."' was not found.");
}
elseif ($result < 0)
{
@@ -340,11 +495,13 @@ class Documents extends DolibarrApi
if (! ($object->id > 0))
{
throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found.");
throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found.");
}
$tmp = dol_check_secure_access_document($modulepart, $tmpreldir.dol_sanitizeFileName($object->ref), $entity, DolibarrApiAccess::$user, $ref, 'write');
$upload_dir = $tmp['original_file'];
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref);
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
if (empty($upload_dir) || $upload_dir == '/')
{
@@ -355,24 +512,27 @@ class Documents extends DolibarrApi
{
if ($modulepart == 'invoice') $modulepart ='facture';
$tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write');
$upload_dir = $tmp['original_file'];
$relativefile = $subdir;
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
if (empty($upload_dir) || $upload_dir == '/')
{
throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
}
}
// $original_file here is still value of filename without any dir.
$upload_dir = dol_sanitizePathName($upload_dir);
$destfile = $upload_dir . '/' . $original_file;
$destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file;
dol_delete_file($destfiletmp);
//var_dump($original_file);exit;
if (!dol_is_dir($upload_dir)) {
throw new RestException(401,'Directory not exists : '.$upload_dir);
if (!dol_is_dir(dirname($destfile))) {
throw new RestException(401, 'Directory not exists : '.dirname($destfile));
}
if (! $overwriteifexists && dol_is_file($destfile))
@@ -393,8 +553,12 @@ class Documents extends DolibarrApi
}
$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
if (! $result)
{
throw new RestException(500, "Failed to move file into '".$destfile."'");
}
return $result;
return dol_basename($destfile);
}
/**

View File

@@ -36,7 +36,7 @@ class Login
*
* Request the API token for a couple username / password.
* Using method POST is recommanded for security reasons (method GET is often logged by default by web servers with parameters so with login and pass into server log file).
* Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "DOLAPIKEY" into field at the top right of page. Note: Tha API key (DOLAPIKEY) can be found/set on the user page.
* Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "DOLAPIKEY" into field at the top right of page. Note: The API key (DOLAPIKEY) can be found/set on the user page.
*
* @param string $login User login
* @param string $password User password
@@ -44,7 +44,9 @@ class Login
* @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access)
* @return array Response status and user token
*
* @throws RestException
* @throws 200
* @throws 403
* @throws 500
*
* @url GET /
* @url POST /
@@ -86,10 +88,20 @@ class Login
$tmpuser=new User($this->db);
$tmpuser->fetch(0, $login, 0, 0, $entity);
if (empty($tmpuser->id))
{
throw new RestException(500, 'Failed to load user');
}
// Renew the hash
if (empty($tmpuser->api_key) || $reset)
{
$tmpuser->getrights();
if (empty($tmpuser->rights->user->self->creer))
{
throw new RestException(403, 'User need write permission on itself to reset its API token');
}
// Generate token for user
$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1);

View File

@@ -628,7 +628,6 @@ class Setup extends DolibarrApi
else
{
throw new RestException(500, $langs->trans('XmlNotFound') . ': ' . $xmlfile);
$error++;
}
}
else
@@ -646,13 +645,12 @@ class Setup extends DolibarrApi
{
$errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
throw new RestException(500, $errormsg);
$error++;
}
}
if (! $error && $xml)
if ($xml)
{
$checksumconcat = array();
$file_list = array();
@@ -873,7 +871,6 @@ class Setup extends DolibarrApi
else
{
throw new RestException(500, 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
$error++;
}

View File

@@ -79,6 +79,9 @@ if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($
}
// This 2 lines are usefull only if we want to exclude some Urls from the explorer
//use Luracast\Restler\Explorer;
//Explorer::$excludedPaths = array('/categories');
// Analyze URLs

View File

@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
* Copyright (C) 2017-2018 Laurent Destailleur <eldy@destailleur.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
@@ -26,9 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$langs->load("admin");
$langs->load("other");
$langs->load("blockedlog");
$langs->loadLangs(array("admin","other","blockedlog"));
if (! $user->admin || empty($conf->blockedlog->enabled)) accessforbidden();
@@ -143,7 +142,7 @@ if ($resql)
{
while ($obj = $db->fetch_object($resql))
{
$countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
}
}
@@ -162,7 +161,7 @@ print $langs->trans("ListOfTrackedEvents").'</td><td>';
$arrayoftrackedevents=$block_static->trackedevents;
foreach($arrayoftrackedevents as $key => $val)
{
print $key.'-'.$val.'<br>';
print $key.' - '.$langs->trans($val).'<br>';
}
print '</td></tr>';

View File

@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
* Copyright (C) 2017-2018 Laurent Destailleur <eldy@destailleur.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
@@ -26,26 +27,30 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
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'):'myobjectlist'; // To manage different context of search
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'blockedloglist'; // To manage different context of search
$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
$showonlyerrors = GETPOST('showonlyerrors','int');
$search_showonlyerrors = GETPOST('search_showonlyerrors','int');
if ($search_showonlyerrors < 0) $search_showonlyerrors=0;
$search_fk_user=GETPOST('search_fk_user','intcomma');
$search_start = -1;
if(GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));
if (GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));
$search_end = -1;
if(GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear'));
if (GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear'));
$search_code = GETPOST('search_code', 'alpha');
$search_ref = GETPOST('search_ref', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
if (($search_start == -1 || empty($search_start)) && ! GETPOSTISSET('search_startmonth')) $search_start = dol_time_plus_duree(dol_now(), '-1', 'w');
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
@@ -76,8 +81,10 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$search_fk_user = '';
$search_start = -1;
$search_end = -1;
$search_code = '';
$search_ref = '';
$search_amount = '';
$search_showonlyerrors = 0;
$toselect='';
$search_array_options=array();
}
@@ -96,57 +103,148 @@ 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";
$res = $db->query($sql);
$previoushash='';
$firstid='';
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('FullData')
."\n";
while($obj = $db->fetch_object($res)) {
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
.';"'.str_replace('"','""',$obj->object_data).'"'
."\n";
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)
{
$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);
exit;
}
else{
setEventMessage($db->lasterror, 'errors');
$res = $db->query($sql);
if($res)
{
// Make the first fetch to get first line
$obj = $db->fetch_object($res);
$previoushash = $block_static->getPreviousHash(0, $obj->rowid);
$firstid = $obj->rowid;
}
else
{
$error++;
setEventMessage($db->lasterror, 'errors');
}
}
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";
$loweridinerror = 0;
$i = 0;
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');
}
}
}
@@ -156,13 +254,31 @@ else if($action === 'downloadcsv') {
$form=new Form($db);
llxHeader('',$langs->trans("BlockedLogSetup"));
if (GETPOST('withtab','alpha'))
{
$title=$langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
}
else
{
$title=$langs->trans("BrowseBlockedLog");
}
$blocks = $block_static->getLog('all', 0, GETPOST('all','alpha') ? 0 : 50, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount);
llxHeader('',$langs->trans("BrowseBlockedLog"));
$MAXLINES = 10000;
$blocks = $block_static->getLog('all', 0, $MAXLINES, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code);
if (! is_array($blocks))
{
dol_print_error($block_static->db);
exit;
if ($blocks == -2)
{
setEventMessages($langs->trans("TooManyRecordToScanRestrictFilters", $MAXLINES), null, 'errors');
}
else
{
dol_print_error($block_static->db, $block_static->error, $block_static->errors);
exit;
}
}
$linkback='';
@@ -171,7 +287,7 @@ if (GETPOST('withtab','alpha'))
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
}
print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback);
print load_fiche_titre($title, $linkback);
if (GETPOST('withtab','alpha'))
{
@@ -186,45 +302,72 @@ print '<br>';
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_fk_user > 0) $param.='&search_fk_user='.urlencode($search_fk_user);
if ($search_start > 0) $param.='&search_startyear='.urlencode(GETPOST('search_startyear','int')).'&search_startmonth='.urlencode(GETPOST('search_startmonth','int')).'&search_startday='.urlencode(GETPOST('search_startday','int'));
if ($search_end > 0) $param.='&search_endyear='.urlencode(GETPOST('search_endyear','int')).'&search_endmonth='.urlencode(GETPOST('search_endmonth','int')).'&search_endday='.urlencode(GETPOST('search_endday','int'));
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($search_fk_user > 0) $param.='&search_fk_user='.urlencode($search_fk_user);
if ($search_startyear > 0) $param.='&search_startyear='.urlencode(GETPOST('search_startyear','int'));
if ($search_startmonth > 0) $param.='&search_startmonth='.urlencode(GETPOST('search_startmonth','int'));
if ($search_startday > 0) $param.='&search_startday='.urlencode(GETPOST('search_startday','int'));
if ($search_endyear > 0) $param.='&search_endyear='.urlencode(GETPOST('search_endyear','int'));
if ($search_endmonth > 0) $param.='&search_endmonth='.urlencode(GETPOST('search_endmonth','int'));
if ($search_endday > 0) $param.='&search_endday='.urlencode(GETPOST('search_endday','int'));
if ($search_showonlyerrors > 0) $param.='&search_showonlyerrors='.urlencode($search_showonlyerrors);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if (GETPOST('withtab','alpha')) $param.='&withtab='.urlencode(GETPOST('withtab','alpha'));
// 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&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">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="withtab" value="'.GETPOST('withtab','alpha').'">';
print '<table class="noborder" width="100%">';
// Line of filters
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">';
print $form->select_date($search_start,'search_start');
print $form->select_date($search_end,'search_end');
//print $langs->trans("from").': ';
$form->select_date($search_start,'search_start');
//print '<br>';
//print $langs->trans("to").': ';
$form->select_date($search_end,'search_end');
print '</td>';
// User
print '<td class="liste_titre">';
print $form->select_users($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>';
print '<td class="liste_titre"></td>';
// Actions code
$langs->load("blockedlog");
print '<td class="liste_titre">';
print $form->selectarray('search_code', $block_static->trackedevents, $search_code, 1, 0, 0, '', 1, 0, 0, 'ASC', 'maxwidth200', 1);
print '</td>';
// Ref
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
@@ -234,7 +377,19 @@ print '<td class="liste_titre"></td>';
// Amount
print '<td class="liste_titre right"><input type="text" class="maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
// Full data
print '<td class="liste_titre"></td>';
// Fingerprint
print '<td class="liste_titre"></td>';
// Status
print '<td class="liste_titre">';
$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
@@ -255,71 +410,124 @@ print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield
print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder,'')."\n";
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>';
$loweridinerror=0;
$checkresult=array();
foreach($blocks as &$block) {
$checksignature = $block->checkSignature();
$checkresult[$block->id]=$checksignature; // false if error
if (! $checksignature)
{
if (empty($loweridinerror)) $loweridinerror=$block->id;
else $loweridinerror = min($loweridinerror, $block->id);
}
if (! empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR))
{
// This is version that is faster but require more memory and report errors that are outside the filter range
// TODO Make a full scan of table in reverse order of id of $block, so we can use the parameter $previoushash into checkSignature to save requests
// to find the $loweridinerror.
}
foreach($blocks as &$block) {
$object_link = $block->getObjectLink();
if (empty($showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
else
{
// This is version that optimize the memory (but will not report errors that are outside the filter range)
$loweridinerror=0;
$checkresult=array();
if (is_array($blocks))
{
print '<tr class="oddeven">';
print '<td>'.$block->id.'</td>';
print '<td>'.dol_print_date($block->tms,'dayhour').'</td>';
print '<td>';
//print $block->getUser()
print $block->user_fullname;
print '</td>';
print '<td>'.$langs->trans('log'.$block->action).'</td>';
print '<td>'.$block->ref_object.'</td>';
print '<td>'.$object_link.'</td>';
print '<td align="right">'.price($block->amounts).'</td>';
print '<td align="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
foreach($blocks as &$block)
{
$checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various
$checkresult[$block->id]=$checksignature; // false if error
if (! $checksignature)
{
if (empty($loweridinerror)) $loweridinerror=$block->id;
else $loweridinerror = min($loweridinerror, $block->id);
}
}
}
}
print '<td>';
print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature);
print '</td>';
if (is_array($blocks))
{
foreach($blocks as &$block)
{
$object_link = $block->getObjectLink();
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');
else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
}
else
{
print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4');
}
//if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
if (empty($search_showonlyerrors) || ! $checkresult[$block->id])
{
print '<tr class="oddeven">';
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>';
// ID
print '<td>'.$block->id.'</td>';
print '</tr>';
// 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, 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'), 'statut4');
else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
}
else
{
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></td>';
print '</tr>';
}
}
}
print '</table>';
print '</form>';
print '</div>';
print '</form>';
// Javascript to manage the showinfo popup
print '<script type="text/javascript">
jQuery(document).ready(function () {
@@ -331,63 +539,44 @@ 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+" &gt;&gt; ");
}
}
}
})
</script>'."\n";
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL))
{
?>
<script type="text/javascript">
<script type="text/javascript">
$.ajax({
url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
,dataType:"html"
}).done(function(data) {
$.ajax({
url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
,dataType:"html"
}).done(function(data) {
if(data == 'hashisok') {
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
}
else{
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
}
if(data == 'hashisok') {
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
}
else{
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
}
});
</script>
});
</script>
<?php
}
if (GETPOST('withtab','alpha'))

View File

@@ -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;
}

View File

@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
* Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.fr>
*
* This program is free software; you can redistribute it and/or modify
@@ -82,6 +82,9 @@ class BlockedLog
*/
public $fk_user = 0;
public $date_creation;
public $date_modification;
public $date_object = 0;
public $ref_object = '';
@@ -109,47 +112,51 @@ class BlockedLog
$this->trackedevents = array();
if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='BillValidate';
if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='BillDelete';
if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='BillSentByEmail';
if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BillDownload';
if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BillPreview';
if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='logBILL_VALIDATE';
if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='logBILL_DELETE';
if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='logBILL_SENTBYMAIL';
if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BlockedLogBillDownload';
if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BlockedLogBillPreview';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='BillPaymentCreate';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='BillPaymentDelete';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='logPAYMENT_CUSTOMER_CREATE';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='logPAYMENT_CUSTOMER_DELETE';
/* Supplier
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='SupplierBillValidate';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_DELETE']='SupplierBillDelete';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='SupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='SupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_PREVIEW']='SupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='BlockedLogSupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_PREVIEW']='BlockedLogSupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='SupplierBillPaymentCreate';
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='supplierBillPaymentCreate';
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='BlockedLogSupplierBillPaymentCreate';
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate';
*/
if ($conf->don->enabled) $this->trackedevents['DON_CREATE']='DonationCreate';
if ($conf->don->enabled) $this->trackedevents['DON_MODIFY']='DonationModify';
if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='DonationDelete';
if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE']='logDON_VALIDATE';
if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='logDON_DELETE';
//if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL';
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE']='logDONATION_PAYMENT_CREATE';
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE']='logDONATION_PAYMENT_DELETE';
/*
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='SalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_MODIFY']='SalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='SalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate';
*/
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION']='MemberSubscription';
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE']='logMEMBER_SUBSCRIPTION_CREATE';
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']='VariousPaymentCreate';
$trackedevents['PAYMENT_VARIOUS_MODIFY']='VariousPaymentModify';
$trackedevents['PAYMENT_VARIOUS_DELETE']='VariousPaymentDelete';
*/
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';
}
/**
* try to retrieve logged object link
* Try to retrieve source object (it it still exists)
*/
public function getObjectLink()
{
@@ -159,7 +166,7 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($this->db);
if($object->fetch($this->fk_object)>0) {
if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -170,7 +177,7 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$object = new FactureFournisseur($this->db);
if($object->fetch($this->fk_object)>0) {
if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -181,7 +188,7 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
$object = new Paiement($this->db);
if($object->fetch($this->fk_object)>0) {
if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -192,7 +199,40 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
$object = new PaiementFourn($this->db);
if($object->fetch($this->fk_object)>0) {
if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
$this->error++;
}
}
else if($this->element === 'payment_donation') {
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
$object = new PaymentDonation($this->db);
if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
$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';
$object = new Don($this->db);
if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -269,6 +309,10 @@ class BlockedLog
{
$this->date_object = $object->datev;
}
elseif ($object->element == 'payment_donation' || $object->element == 'payment_various')
{
$this->date_object = $object->datepaid?$object->datepaid:$object->datep;
}
else {
$this->date_object = $object->date;
}
@@ -315,8 +359,11 @@ class BlockedLog
}
// Add user info
$this->fk_user = $user->id;
$this->user_fullname = $user->getFullName($langs);
if (! empty($user))
{
$this->fk_user = $user->id;
$this->user_fullname = $user->getFullName($langs);
}
// Field specific to object
@@ -326,10 +373,30 @@ 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;
}
elseif ($this->element == 'invoice_supplier')
{
@@ -337,87 +404,143 @@ 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'|| $object->element == 'payment_supplier')
elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various')
{
//var_dump($object);
$datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep);
$paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment);
$this->object_data->ref = $object->ref;
$this->object_data->date = $object->datepaye;
$this->object_data->type_code = dol_getIdFromCode($this->db, $object->paiementid, 'c_paiement', 'id', 'code');
$this->object_data->payment_num = $object->num_paiement;
$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?$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 $invoiceid => $amount)
foreach($object->amounts as $objid => $amount)
{
if (empty($amount)) continue;
$totalamount += $amount;
$tmpobject = null;
if ($this->element == 'payment_supplier')
{
$tmpinvoice = new FactureFournisseur($this->db);
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$tmpobject = new FactureFournisseur($this->db);
}
else
elseif ($this->element == 'payment')
{
$tmpinvoice = new Facture($this->db);
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$tmpobject = new Facture($this->db);
}
$result = $tmpinvoice->fetch($invoiceid);
elseif ($this->element == 'payment_donation')
{
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 = $tmpinvoice->error;
$this->errors = $tmpinvoice->errors;
return -1;
}
$result = $tmpinvoice->fetch_thirdparty();
if ($result <= 0)
{
$this->error = $tmpinvoice->error;
$this->errors = $tmpinvoice->errors;
$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;
$paymentpart->thirdparty = new stdClass();
foreach($tmpinvoice->thirdparty as $key=>$value)
if (! in_array($this->element, array('payment_donation', 'payment_various')))
{
if (in_array($key, array('fields'))) continue; // Discard some properties
if (! in_array($key, array(
'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode',
'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
))) continue; // Discard if not into a dedicated list
if (!is_object($value)) $paymentpart->thirdparty->{$key} = $value;
$result = $tmpobject->fetch_thirdparty();
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;
return -1;
}
$paymentpart->thirdparty = new stdClass();
foreach($tmpobject->thirdparty as $key=>$value)
{
if (in_array($key, array('fields'))) continue; // Discard some properties
if (! in_array($key, array(
'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode',
'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
))) continue; // Discard if not into a dedicated list
if (!is_object($value)) $paymentpart->thirdparty->{$key} = $value;
}
}
$paymentpart->invoice = new stdClass();
foreach($tmpinvoice as $key=>$value)
{
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)) $paymentpart->invoice->{$key} = $value;
}
// Init object to avoid warnings
if ($this->element == 'payment_donation') $paymentpart->donation = new stdClass();
else $paymentpart->invoice = new stdClass();
$paymentpartnumber++;
$this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
if ($this->element != 'payment_various')
{
foreach($tmpobject as $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++; // first payment will be 1
$this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
}
}
$this->object_data->amount = $totalamount;
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
}
elseif($this->element == 'payment_salary')
{
$this->object_data->amounts = array($object->amount);
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
}
return 1;
@@ -554,7 +677,7 @@ class BlockedLog
$this->db->begin();
$previoushash = $this->getPreviousHash(1); // This get last record and lock database until insert is done
$previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done
$keyforsignature = $this->buildKeyForSignature();
@@ -625,19 +748,20 @@ class BlockedLog
}
/**
* Check if current signature still correct compare to the chain
* Check if current signature still correct compared to the value in chain
*
* @return boolean True if OK, False if KO
* @param string $previoushash If previous signature hash is known, we can provide it to avoid to make a search of it in database.
* @return boolean True if OK, False if KO
*/
public function checkSignature()
public function checkSignature($previoushash='')
{
//$oldblockedlog = new BlockedLog($this->db);
//$previousrecord = $oldblockedlog->fetch($this->id - 1);
$previoushash = $this->getPreviousHash(0, $this->id);
if (empty($previoushash))
{
$previoushash = $this->getPreviousHash(0, $this->id);
}
// Recalculate hash
$keyforsignature = $this->buildKeyForSignature();
$signature_line = dol_hash($keyforsignature, '5'); // Not really usefull
$signature = dol_hash($previoushash . $keyforsignature, '5');
//var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature);
@@ -652,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
*/
@@ -667,10 +793,10 @@ class BlockedLog
* Get previous signature/hash in chain
*
* @param int $withlock 1=With a lock
* @param int $beforeid Before id
* @return string Hash of last record
* @param int $beforeid ID of a record
* @return string Hash of previous record (if beforeid is defined) or hash of last record (if beforeid is 0)
*/
private function getPreviousHash($withlock=0, $beforeid=0)
public function getPreviousHash($withlock=0, $beforeid=0)
{
global $conf;
@@ -718,9 +844,10 @@ class BlockedLog
* @param int $search_end end time limit
* @param string $search_ref search ref
* @param string $search_amount search amount
* @return array array of object log
* @param string $search_code search code
* @return array|int Array of object log or <0 if error
*/
public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref='', $search_amount='')
public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref='', $search_amount='', $search_code='')
{
global $conf, $cachedlogs;
@@ -748,25 +875,33 @@ class BlockedLog
WHERE entity=".$conf->entity." AND element='".$element."' AND fk_object=".(int) $fk_object;
}
if ($search_fk_user > 0) $sql.=" AND fk_user IN (".$this->db->escape($search_fk_user).")";
if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'";
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref);
if ($search_fk_user > 0) $sql.=natural_search("fk_user", $search_fk_user, 2);
if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'";
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref);
if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1);
if ($search_code != '' && $search_code != '-1') $sql.=natural_search("action", $search_code, 3);
$sql.=$this->db->order($sortfield, $sortorder);
if($limit > 0 )$sql.=' LIMIT '.$limit;
$sql.=$this->db->plimit($limit+1); // We want more, because we will stop into loop later with error if we reach max
$res = $this->db->query($sql);
if($res) {
$results=array();
while ($obj = $this->db->fetch_object($res)) {
$i = 0;
while ($obj = $this->db->fetch_object($res))
{
$i++;
if ($i > $limit)
{
// Too many record, we will consume too much memory
return -2;
}
if (!isset($cachedlogs[$obj->rowid])) {
if (!isset($cachedlogs[$obj->rowid]))
{
$b=new BlockedLog($this->db);
$b->fetch($obj->rowid);
@@ -778,9 +913,8 @@ class BlockedLog
return $results;
}
else{
return false;
}
return -1;
}
/**
@@ -795,6 +929,7 @@ class BlockedLog
if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$fingerprint = dol_hash(print_r($mysoc,true).getRandomPassword(1), '5');

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2017 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
@@ -103,7 +103,7 @@ print "</tr>\n";
print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
print '<td colspan="2">';
print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',1,0,1,array(),0);
print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3) AND s.status = 1',1,0,1,array(),0);
print '</td></tr>';
if (! empty($conf->banque->enabled))
{

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -105,7 +105,7 @@ print '<td>';
$disabled=0;
$langs->load("companies");
if (! empty($conf->global->CASHDESK_ID_THIRDPARTY)) $disabled=1; // If a particular third party is defined, we disable choice
print $form->select_company(GETPOST('socid','int')?GETPOST('socid','int'):$conf->global->CASHDESK_ID_THIRDPARTY, 'socid', 's.client in (1,3)', !$disabled, 0, 0);
print $form->select_company(GETPOST('socid','int')?GETPOST('socid','int'):$conf->global->CASHDESK_ID_THIRDPARTY, 'socid', 's.client in (1,3) AND s.status = 1', !$disabled, $disabled, 1);
//print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />';
print '</td>';
print "</tr>\n";

View File

@@ -19,6 +19,14 @@
*
*/
// Protection to avoid direct call of template
if (empty($langs) || ! is_object($langs))
{
print "Error, template page can't be called as URL";
exit;
}
$langs->load("main");
$langs->load("bills");
$langs->load("cashdesk");

View File

@@ -17,6 +17,14 @@
*
*/
// Protection to avoid direct call of template
if (empty($langs) || ! is_object($langs))
{
print "Error, template page can't be called as URL";
exit;
}
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';

View File

@@ -2,7 +2,7 @@
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2010 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -19,6 +19,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Protection to avoid direct call of template
if (empty($langs) || ! is_object($langs))
{
print "Error, template page can't be called as URL";
exit;
}
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
@@ -71,7 +79,7 @@ print '<li class="menu_choix0">'.$langs->trans("User").': '.$_SESSION['firstname
print ' <a href="deconnexion.php">'.img_picto($langs->trans('Logout'), 'logout.png').'</a><br>';
print '<form id="frmThirdparty" class="formulaire1 inline-block" method="post" action="facturation_verif.php?action=change_thirdparty">';
print $langs->trans("CashDeskThirdParty").': ';
print $form->select_company($_SESSION["CASHDESK_ID_THIRDPARTY"], 'CASHDESK_ID_THIRDPARTY', 's.client IN (1,3)', '', 0, 0, null, 0, 'valignmiddle inline-block');
print $form->select_company($_SESSION["CASHDESK_ID_THIRDPARTY"], 'CASHDESK_ID_THIRDPARTY', 's.client IN (1,3) AND s.status = 1', '', 0, 0, null, 0, 'valignmiddle inline-block');
print '<input class="button bouton_change_thirdparty inline-block valignmiddle" type="submit" id="bouton_change_thirdparty" value="'.$langs->trans("Modify").'">';
//print $companyLink;
print '<br>';

View File

@@ -16,6 +16,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Protection to avoid direct call of template
if (empty($langs) || ! is_object($langs))
{
print "Error, template page can't be called as URL";
exit;
}
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$langs->load("main");

View File

@@ -16,6 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Protection to avoid direct call of template
if (empty($langs) || ! is_object($langs))
{
print "Error, template page can't be called as URL";
exit;
}
$langs->load("main");
$langs->load("bills");
$langs->load("banks");

View File

@@ -17,6 +17,14 @@
*
*/
// Protection to avoid direct call of template
if (empty($langs) || ! is_object($langs))
{
print "Error, template page can't be called as URL";
exit;
}
$langs->load("main");
$langs->load("bills");

View File

@@ -223,7 +223,7 @@ class Categories extends DolibarrApi
}
else
{
throw new RestException(500, $this->task->error);
throw new RestException(500, $this->category->error);
}
}

View File

@@ -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";
@@ -1066,7 +1066,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 +1481,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 +1542,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)

View File

@@ -353,7 +353,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 +402,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 +451,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 +507,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 +558,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 +613,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 +666,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)
{

View File

@@ -36,8 +36,17 @@ class ActionComm extends CommonObject
public $element='action';
public $table_element = 'actioncomm';
public $table_rowid = 'id';
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='action';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user, 2=Same than 1 but accept record if fksoc is empty
* @var integer
*/
public $restrictiononfksoc = 2;
/**
* Id of the event

View File

@@ -127,7 +127,7 @@ $arrayfields=array(
'a.datep2'=>array('label'=>"DateEnd", 'checked'=>1),
's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
'a.fk_contact'=>array('label'=>"Contact", 'checked'=>1),
'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))),
'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))),
'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
);
@@ -427,7 +427,7 @@ if ($resql)
if (! empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"></td>';
if (! empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>';
if (! empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>';
if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" name="search_title" value="'.$search_title.'"></td>';
if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
if (! empty($arrayfields['a.datep']['checked'])) {
print '<td class="liste_titre" align="center">';
print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
@@ -454,6 +454,7 @@ if ($resql)
if (! empty($arrayfields['a.percent']['checked'])) {
print '<td class="liste_titre center">';
print $formactions->form_select_status_action('formaction',$status,1,'status',1,2);
print ajax_combobox('selectstatus');
print '</td>';
}
// Action column
@@ -560,14 +561,14 @@ if ($resql)
// Label
if (! empty($arrayfields['a.label']['checked'])) {
print '<td class="tdoverflowmax300">';
print '<td class="tdoverflowmax200">';
print $actionstatic->label;
print '</td>';
}
// Start date
if (! empty($arrayfields['a.datep']['checked'])) {
print '<td align="center" class="nowrap">';
print '<td align="center">';
print dol_print_date($db->jdate($obj->dp),"dayhour");
$late=0;
if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1;
@@ -580,7 +581,7 @@ if ($resql)
// End date
if (! empty($arrayfields['a.datep2']['checked'])) {
print '<td align="center" class="nowrap">';
print '<td align="center">';
print dol_print_date($db->jdate($obj->dp2),"dayhour");
print '</td>';
}

View File

@@ -211,7 +211,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 +220,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);
@@ -773,7 +773,7 @@ if ($id > 0)
}
/*
* Last sendings
* Last shipments
*/
if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
$sendingstatic = new Expedition($db);
@@ -1245,7 +1245,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 +1271,8 @@ if ($id > 0)
}
else
{
dol_print_error($db,'Bad value for socid parameter');
$langs->load("errors");
print $langs->trans('ErrorRecordNotFound');
}
// End of page

View File

@@ -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";
@@ -768,7 +768,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity IN (".getEntity('commande').")";
$sql.= " AND c.fk_statut = 1";
$sql.= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")";
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 c.rowid DESC";

View File

@@ -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.=') &nbsp; ';
}
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>';
}
@@ -1095,7 +1110,7 @@ else
$htmltext.='</i>';
// Print mail content
print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic');
print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto('<span class="hideonsmartphone">'.$langs->trans("AvailableVariables").'</span>', $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic');
dol_fiche_head('', '', '', -1);
@@ -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>';

View File

@@ -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&oacute;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.=') &nbsp; ';
}
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 = "&amp;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.= "&amp;search_lastname=".urlencode($search_lastname);
if ($search_firstname) $param.= "&amp;search_firstname=".urlencode($search_firstname);
if ($search_email) $param.= "&amp;search_email=".urlencode($search_email);
@@ -443,6 +470,7 @@ if ($object->fetch($id) >= 0)
if ($page) $param.= "&amp;page=".$page;
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';
// Ligne des champs de filtres
@@ -551,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">&nbsp;</td>';
@@ -562,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>';
@@ -590,6 +622,7 @@ if ($object->fetch($id) >= 0)
}
}
print "</table><br>";
print '</div>';
print '</form>';

View File

@@ -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

View File

@@ -30,7 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$langs->load("orders");
$langs->load("companies");
$_socid = $_GET["id"];
$id = GETPOST('id','int');
$_socid = GETPOST("id",'int');
// Security check
if ($user->societe_id > 0)
{
@@ -45,10 +46,10 @@ if ($user->societe_id > 0)
if ($_POST["action"] == 'setpricelevel')
{
$soc = New Societe($db);
$soc->fetch($_GET["id"]);
$soc->fetch($id);
$soc->set_price_level($_POST["price_level"],$user);
header("Location: multiprix.php?id=".$_GET["id"]);
header("Location: multiprix.php?id=".$id);
exit;
}
@@ -87,7 +88,7 @@ if ($_socid > 0)
print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setpricelevel">';
dol_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company');
print '<table width="100%" border="0">';
@@ -122,12 +123,12 @@ if ($_socid > 0)
print "</table>";
dol_fiche_end();
print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
print "</form>";
print '<br><br>';

View File

@@ -774,12 +774,13 @@ if (empty($reshook))
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
if (empty($tva_tx)) $tva_npr=0;
// Price unique per product
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
$price_base_type = $prod->price_base_type;
// On defini prix unitaire
// If price per segment
if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level)
{
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
@@ -792,6 +793,7 @@ if (empty($reshook))
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
}
}
// If price per customer
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
@@ -814,6 +816,37 @@ if (empty($reshook))
}
}
}
// If price per quantity
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
{
if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity
{
// Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp'].
$pqp = GETPOST('pbq','int');
// Search price into product_price_by_qty from $prod->id
foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray)
{
if ($priceforthequantityarray['rowid'] != $pqp) continue;
// We found the price
if ($priceforthequantityarray['price_base_type'] == 'HT')
{
$pu_ht = $priceforthequantityarray['unitprice'];
}
else
{
$pu_ttc = $priceforthequantityarray['unitprice'];
}
// Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST.
break;
}
}
}
// If price per quantity and customer
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
// TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level
}
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
@@ -1411,16 +1444,13 @@ if ($action == 'create')
}
print '</tr>' . "\n";
// Contacts (ask contact only if thirdparty already defined). TODO do this also into order and invoice.
if ($socid > 0)
{
// Contacts (ask contact only if thirdparty already defined). TODO do this also into order and invoice.
print "<tr><td>" . $langs->trans("DefaultContact") . '</td><td>';
$form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist);
print '</td></tr>';
}
if ($socid > 0)
{
// Ligne info remises tiers
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
if ($soc->remise_percent)
@@ -2100,6 +2130,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))
{
@@ -2240,8 +2286,6 @@ if ($action == 'create')
{
if ($action != 'editline')
{
$var = true;
// Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc);
@@ -2382,8 +2426,6 @@ if ($action == 'create')
$genallowed = $user->rights->propal->lire;
$delallowed = $user->rights->propal->creer;
$var = true;
print $formfile->showdocuments('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object);
// Show links to link elements
@@ -2400,6 +2442,7 @@ if ($action == 'create')
print showOnlineSignatureUrl('proposal', $object->ref).'<br>';
}
// Show direct download link
if ($object->statut != Propal::STATUS_DRAFT && ! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD))
{
print '<br><!-- Link to download main doc -->'."\n";

View File

@@ -38,7 +38,7 @@ class Proposals extends DolibarrApi
);
/**
* @var propal $propal {@type propal}
* @var Propal $propal {@type Propal}
*/
public $propal;
@@ -143,6 +143,7 @@ class Proposals extends DolibarrApi
$sql.= $db->plimit($limit + 1, $offset);
}
dol_syslog("API Rest request");
$result = $db->query($sql);
if ($result)
@@ -173,7 +174,7 @@ class Proposals extends DolibarrApi
* Create commercial proposal object
*
* @param array $request_data Request data
* @return int ID of propal
* @return int ID of proposal
*/
function post($request_data = NULL)
{
@@ -290,8 +291,9 @@ class Proposals extends DolibarrApi
if ($updateRes > 0) {
return $updateRes;
}
return false;
else {
throw new RestException(400, $this->propal->error);
}
}
/**
@@ -388,12 +390,16 @@ class Proposals extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
// TODO Check the lineid $lineid is a line of ojbect
$updateRes = $this->propal->deleteline($lineid);
if ($updateRes > 0) {
return $this->get($id);
}
return false;
else
{
throw new RestException(405, $this->propal->error);
}
}
/**
@@ -422,13 +428,26 @@ class Proposals extends DolibarrApi
$this->propal->$field = $value;
}
// update end of validity date
if (empty($this->propal->fin_validite) && !empty($this->propal->duree_validite) && !empty($this->propal->date_creation))
{
$this->propal->fin_validite = $this->propal->date_creation + ($this->propal->duree_validite * 24 * 3600);
}
if (!empty($this->propal->fin_validite))
{
if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0)
{
throw new RestException(500, $this->propal->error);
}
}
if ($this->propal->update(DolibarrApiAccess::$user) > 0)
{
return $this->get($id);
}
else
{
throw new RestException(500, $this->task->error);
throw new RestException(500, $this->propal->error);
}
}
@@ -466,21 +485,71 @@ class Proposals extends DolibarrApi
}
/**
* Set a proposal to draft
*
* @param int $id Order ID
*
* @url POST {id}/settodraft
*
* @return array
*/
function settodraft($id)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->propal->set_draft(DolibarrApiAccess::$user);
if ($result == 0) {
throw new RestException(304, 'Nothing done. May be object is already draft');
}
if ($result < 0) {
throw new RestException(500, 'Error : '.$this->propal->error);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal);
}
/**
* Validate a commercial proposal
*
* @param int $id Commercial proposal ID
* @param int $notrigger Use {}
*
* @url POST {id}/validate
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* If you get a bad value for param notrigger check that ou provide this in body
* {
* "notrigger": 0
* }
*
* @param int $id Commercial proposal ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @throws 304
* @throws 401
* @throws 404
* @throws 500
*
* @return array
*/
function validate($id, $notrigger=0)
{
@@ -504,12 +573,18 @@ class Proposals extends DolibarrApi
throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Commercial Proposal validated (Ref='.$this->propal->ref.')'
)
);
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal);
}
/**
@@ -546,14 +621,62 @@ class Proposals extends DolibarrApi
throw new RestException(500, 'Error when closing Commercial Proposal: '.$this->propal->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Commercial Proposal closed (Ref='.$this->propal->ref.')'
)
);
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal);
}
/**
* Set a commercial proposal billed. Could be also called setbilled
*
* @param int $id Commercial proposal ID
*
* @url POST {id}/setinvoiced
*
* @return array
*/
function setinvoiced($id)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->propal->classifyBilled(DolibarrApiAccess::$user );
if ($result < 0) {
throw new RestException(500, 'Error : '.$this->propal->error);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal);
}
/**
* Validate fields before create or update object

View File

@@ -48,8 +48,17 @@ class Propal extends CommonObject
public $table_element='propal';
public $table_element_line='propaldet';
public $fk_element='fk_propal';
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='propal';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
*/
public $restrictiononfksoc = 1;
/**
* {@inheritdoc}
@@ -515,8 +524,8 @@ class Propal extends CommonObject
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
$this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
$this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->fk_product=$fk_product;
@@ -795,6 +804,8 @@ class Propal extends CommonObject
if ($this->statut == self::STATUS_DRAFT)
{
$this->db->begin();
$line=new PropaleLigne($this->db);
// For triggers
@@ -804,15 +815,18 @@ class Propal extends CommonObject
{
$this->update_price(1);
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}
else
{
$this->error='ErrorDeleteLineNotAllowedByObjectStatus';
return -2;
}
}
@@ -1559,6 +1573,7 @@ class Propal extends CommonObject
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
$sql.= ' d.fk_unit,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
$sql.= ' p.weight, p.weight_units, p.volume, p.volume_units,';
$sql.= ' d.date_start, d.date_end';
$sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as d';
@@ -1624,6 +1639,10 @@ class Propal extends CommonObject
$line->product_desc = $objp->product_desc; // Description produit
$line->fk_product_type = $objp->fk_product_type;
$line->fk_unit = $objp->fk_unit;
$line->weight = $objp->weight;
$line->weight_units = $objp->weight_units;
$line->volume = $objp->volume;
$line->volume_units = $objp->volume_units;
$line->date_start = $this->db->jdate($objp->date_start);
$line->date_end = $this->db->jdate($objp->date_end);

View File

@@ -4,6 +4,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2017 Ferran Marcet <fmarcet@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
@@ -31,6 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.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/class/html.formfile.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
$langs->load('compta');
$langs->load('other');

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@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
@@ -27,6 +28,9 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
$langs->load('propal');
$langs->load('compta');

View File

@@ -10,7 +10,8 @@
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2017 Charlene Benke <charlie@patas-monkey.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
@@ -62,6 +63,9 @@ $search_user=GETPOST('search_user','int');
$search_sale=GETPOST('search_sale','int');
$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
$search_refcustomer=GETPOST('search_refcustomer','alpha');
$search_refproject=GETPOST('search_refproject','alpha');
$search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha');
$search_montant_vat=GETPOST('search_montant_vat','alpha');
@@ -79,7 +83,7 @@ $search_year=GETPOST("search_year","int");
$viewstatut=GETPOST('viewstatut','alpha');
$optioncss = GETPOST('optioncss','alpha');
$object_statut=GETPOST('propal_statut','alpha');
$object_statut=GETPOST('search_statut','alpha');
$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
@@ -137,6 +141,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)),
'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),
@@ -186,6 +191,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$search_sale='';
$search_ref='';
$search_refcustomer='';
$search_refproject='';
$search_societe='';
$search_montant_ht='';
$search_montant_vat='';
@@ -282,6 +288,8 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_login) $sql .= natural_search("u.login", $search_login);
if ($search_montant_ht != '') $sql.= natural_search("p.total_ht", $search_montant_ht, 1);
@@ -366,6 +374,7 @@ if ($resql)
if ($search_year) $param.='&search_year='.urlencode($search_year);
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer);
if ($search_refprojet) $param.='&search_refprojet='.urlencode($search_refprojet);
if ($search_societe) $param.='&search_societe='.urlencode($search_societe);
if ($search_user > 0) $param.='&search_user='.urlencode($search_user);
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
@@ -476,6 +485,12 @@ if ($resql)
print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">';
print '</td>';
}
if (! empty($arrayfields['pr.ref']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" size="6" type="text" name="search_refproject" value="'.$search_refproject.'">';
print '</td>';
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre" align="left">';
@@ -572,7 +587,7 @@ if ($resql)
if (! empty($arrayfields['p.fk_statut']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone" align="right">';
$formpropal->selectProposalStatus($viewstatut,1);
$formpropal->selectProposalStatus($viewstatut, 1, 0, 1, 'customer', 'search_statut');
print '</td>';
}
// Action column
@@ -588,6 +603,7 @@ if ($resql)
print '<tr class="liste_titre">';
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['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'],$_SERVER["PHP_SELF"],'p.ref_client','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'],$_SERVER["PHP_SELF"],'pr.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);
@@ -670,6 +686,18 @@ if ($resql)
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['pr.ref']['checked']))
{
// Project ref
print '<td class="nocellnopadd nowrap">';
if ($obj->project_id) {
$projectstatic->fetch($obj->project_id);
print $projectstatic->getNomUrl(1);
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
$companystatic->id=$obj->socid;
$companystatic->name=$obj->name;
$companystatic->client=$obj->client;

View File

@@ -4,6 +4,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2017 Ferran Marcet <fmarcet@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
@@ -28,6 +29,9 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
$langs->load('propal');
$langs->load('compta');

View File

@@ -22,6 +22,14 @@
* \ingroup propal
* \brief Template to show objects linked to proposals
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
}
?>
<!-- BEGIN PHP TEMPLATE -->
@@ -40,7 +48,7 @@ $var=true;
foreach($linkedObjectBlock as $key => $objectlink)
{
$ilink++;
$trclass=($var?'pair':'impair');
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total';
?>
@@ -71,7 +79,7 @@ if (count($linkedObjectBlock) > 1)
<td align="right"></td>
<td align="right"></td>
</tr>
<?php
<?php
}
?>

View File

@@ -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&amp;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;

View File

@@ -735,7 +735,7 @@ if (empty($reshook))
$price_min = $prod->price_min;
$price_base_type = $prod->price_base_type;
// multiprix
// If price per segment
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
{
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
@@ -748,6 +748,7 @@ if (empty($reshook))
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
}
}
// If price per customer
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
@@ -775,6 +776,37 @@ if (empty($reshook))
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
}
// If price per quantity
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
{
if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity
{
// Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp'].
$pqp = GETPOST('pbq','int');
// Search price into product_price_by_qty from $prod->id
foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray)
{
if ($priceforthequantityarray['rowid'] != $pqp) continue;
// We found the price
if ($priceforthequantityarray['price_base_type'] == 'HT')
{
$pu_ht = $priceforthequantityarray['unitprice'];
}
else
{
$pu_ttc = $priceforthequantityarray['unitprice'];
}
// Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST.
break;
}
}
}
// If price per quantity and customer
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
// TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level
}
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
@@ -1288,7 +1320,6 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer)
{
if ($action == 'addcontact')
@@ -1593,7 +1624,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// What trigger creation
print '<tr><td>' . $langs->trans('Source') . '</td><td>';
print '<tr><td>' . $langs->trans('Channel') . '</td><td>';
$form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1);
print '</td></tr>';
@@ -1605,7 +1636,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$langs->load("projects");
print '<tr>';
print '<td>' . $langs->trans("Project") . '</td><td>';
$numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0);
$numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print '</td>';
print '</tr>';
@@ -2235,7 +2266,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Source reason (why we have an ordrer)
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Source');
print $langs->trans('Channel');
print '</td>';
if ($action != 'editdemandreason')
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editdemandreason&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . '</a></td>';
@@ -2269,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');
@@ -2439,8 +2473,6 @@ if ($action == 'create' && $user->rights->commande->creer)
{
if ($action != 'editline')
{
$var = true;
// Add free products/services
$object->formAddObjectLine(1, $mysoc, $soc);
@@ -2608,8 +2640,10 @@ if ($action == 'create' && $user->rights->commande->creer)
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Show online signature link
// Show online payment link
//$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
$useonlinepayment = $conf->global->ORDER_SHOW_ONLINE_PAYMENT_ON_ORDER;
if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment)
{
print '<br><!-- Link to pay -->';
@@ -2617,6 +2651,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print showOnlinePaymentUrl('order', $object->ref).'<br>';
}
// Show direct download link
if ($object->statut != Commande::STATUS_DRAFT && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD))
{
print '<br><!-- Link to download main doc -->'."\n";

View File

@@ -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,
@@ -291,7 +292,9 @@ class Orders extends DolibarrApi
return $updateRes;
}
return false;
else {
throw new RestException(400, $this->commande->error);
}
}
/**
@@ -372,19 +375,23 @@ class Orders extends DolibarrApi
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commande not found');
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
// TODO Check the lineid $lineid is a line of ojbect
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes > 0) {
return $this->get($id);
}
return false;
else
{
throw new RestException(405, $this->commande->error);
}
}
/**
@@ -425,7 +432,7 @@ class Orders extends DolibarrApi
}
else
{
throw new RestException(500, $this->task->error);
throw new RestException(500, $this->commande->error);
}
}
@@ -433,7 +440,6 @@ class Orders extends DolibarrApi
* Delete order
*
* @param int $id Order ID
*
* @return array
*/
function delete($id)
@@ -465,21 +471,25 @@ class Orders extends DolibarrApi
/**
* Validate an order
*
* If you get a bad value for param notrigger check that ou provide this in body
* {
* "idwarehouse": 0,
* "notrigger": 0
* }
*
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @throws 304
* @throws 401
* @throws 404
* @throws 500
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "idwarehouse": 0,
* "notrigger": 0
* }
*/
function validate($id, $idwarehouse=0, $notrigger=0)
{
@@ -502,16 +512,103 @@ class Orders extends DolibarrApi
if ($result < 0) {
throw new RestException(500, 'Error when validating Order: '.$this->commande->error);
}
$result = $this->commande->fetch($id);
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
}
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}
/**
* Tag the order as validated (opened)
*
* Function used when order is reopend after being closed.
*
* @param int $id Id of the order
*
* @url POST {id}/reopen
*
* @return int
*
* @throws 304
* @throws 400
* @throws 401
* @throws 404
* @throws 405
*/
function reopen($id) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$result = $this->commande->set_reopen(DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(405, $this->commande->error);
}else if( $result == 0) {
throw new RestException(304);
}
return $result;
}
/**
* Classify the order as invoiced. Could be also called setbilled
*
* @param int $id Id of the order
*
* @url POST {id}/setinvoiced
*
* @return int
*
* @throws 400
* @throws 401
* @throws 404
* @throws 405
*/
function setinvoiced($id) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$result = $this->commande->classifyBilled(DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(400, $this->commande->error);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}
@@ -523,7 +620,7 @@ class Orders extends DolibarrApi
*
* @url POST {id}/close
*
* @return array
* @return int
*/
function close($id, $notrigger=0)
{
@@ -547,12 +644,18 @@ class Orders extends DolibarrApi
throw new RestException(500, 'Error when closing Order: '.$this->commande->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Order closed (Ref='.$this->commande->ref.')'
)
);
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}
/**
@@ -597,6 +700,51 @@ class Orders extends DolibarrApi
}
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}
/**
* Create an order using an existing proposal.
*
*
* @param int $proposalid Id of the proposal
*
* @url POST /createfromproposal/{proposalid}
*
* @return int
* @throws 400
* @throws 401
* @throws 404
* @throws 405
*/
function createOrderFromProposal($proposalid) {
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(empty($proposalid)) {
throw new RestException(400, 'Proposal ID is mandatory');
}
$propal = new Propal($this->db);
$result = $propal->fetch($proposalid);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
$result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(405, $this->commande->error);
}
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}

View File

@@ -46,8 +46,17 @@ class Commande extends CommonOrder
public $table_element_line = 'commandedet';
public $class_element_line = 'OrderLine';
public $fk_element = 'fk_commande';
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto = 'order';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
*/
public $restrictiononfksoc = 1;
/**
* {@inheritdoc}
@@ -1329,6 +1338,14 @@ class Commande extends CommonOrder
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
/*var_dump($txlocaltax1);
var_dump($txlocaltax2);
var_dump($localtaxes_type);
var_dump($tabprice);
var_dump($tabprice[9]);
var_dump($tabprice[10]);
exit;*/
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
@@ -1370,12 +1387,12 @@ class Commande extends CommonOrder
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->vat_src_code=$vat_src_code;
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$localtaxes_type[1];
$this->line->localtax2_tx=$localtaxes_type[3];
$this->line->localtax1_type=$localtaxes_type[0];
$this->line->localtax2_type=$localtaxes_type[2];
$this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
$this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
$this->line->localtax1_type=$localtaxes_type[0];
$this->line->localtax2_type=$localtaxes_type[2];
$this->line->fk_product=$fk_product;
$this->line->product_type=$product_type;
$this->line->fk_remise_except=$fk_remise_except;
@@ -2065,7 +2082,6 @@ class Commande extends CommonOrder
*/
function deleteline($user=null, $lineid=0)
{
if ($this->statut == self::STATUS_DRAFT)
{
$this->db->begin();
@@ -2128,7 +2144,8 @@ class Commande extends CommonOrder
}
else
{
return -1;
$this->error='ErrorDeleteLineNotAllowedByObjectStatus';
return -1;
}
}
@@ -3019,6 +3036,8 @@ class Commande extends CommonOrder
*/
function update(User $user, $notrigger=0)
{
global $conf;
$error=0;
// Clean parameters
@@ -3052,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").",";

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