Merge remote-tracking branch 'upstream/develop' into 14a5

This commit is contained in:
Alexandre SPANGARO 2020-12-28 03:30:41 +01:00
commit 9eaeab1208
373 changed files with 6585 additions and 4007 deletions

View File

@ -50,6 +50,9 @@ jobs:
- if: type = push AND branch = develop - if: type = push AND branch = develop
php: nightly php: nightly
env: DB=mysql env: DB=mysql
- if: type = push AND branch = 14.0
php: nightly
env: DB=mysql
notifications: notifications:
email: email:
@ -268,7 +271,7 @@ script:
# Ensure we catch errors # Ensure we catch errors
set -e set -e
#parallel-lint --exclude htdocs/includes --blame . #parallel-lint --exclude htdocs/includes --blame .
parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ parallel-lint --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \
--exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \
--exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \
--exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \
@ -398,9 +401,13 @@ script:
php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log
php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
php upgrade.php 13.0.0 14.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade13001400.log
php upgrade2.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-2.log
php step5.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-3.log
# Enable modules not enabled into original dump # Enable modules not enabled into original dump
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log
echo $? echo $?
cd - cd -
set +e set +e

View File

@ -29,7 +29,7 @@ PHPoAuthLib 0.8.2 MIT License Yes
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
PSR/Logs 1.0 Library for logs (used by DebugBar) PSR/Logs 1.0 Library for logs (used by DebugBar)
PSR/simple-cache ? Library for cache (used by PHPSpreadSheet) PSR/simple-cache ? Library for cache (used by PHPSpreadSheet)
Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Restler 3.1.1 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
Sabre 3.2.2 BSD Yes DAV support Sabre 3.2.2 BSD Yes DAV support
Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP
Stripe 6.43.1 MIT licence Yes Library for Stripe module Stripe 6.43.1 MIT licence Yes Library for Stripe module

View File

@ -18,6 +18,7 @@ NEW: Accountancy - change menu disposition
NEW: Accountancy - on transfers, select the periodicity by default NEW: Accountancy - on transfers, select the periodicity by default
NEW: Accountancy - Add export for Gestinum (v3 & v5) NEW: Accountancy - Add export for Gestinum (v3 & v5)
NEW: new currency rate editor NEW: new currency rate editor
NEW: Solve blocking feature. Can increase stock of a Kit without changing subproduct stock.
NEW: add a widget to show the customers with outstanding limits reached NEW: add a widget to show the customers with outstanding limits reached
NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr
NEW: add a counter of number of words for pages in website module NEW: add a counter of number of words for pages in website module
@ -181,8 +182,8 @@ NEW: Add option "If the feature to manage kits of module Stock is used, show det
For developers: For developers:
--------------- ---------------
NEW: add __MEMBER_TYPE__ substitution key NEW: add substitution key __MEMBER_TYPE__
NEW: add __TYPE__ substitution key NEW: add substitution key __TYPE__
NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open page into a popup NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open page into a popup
NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER)
NEW: Add some fields to link website page to an other object NEW: Add some fields to link website page to an other object
@ -192,14 +193,9 @@ NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
NEW: can force the antivirus from conf file or autoprepend ini setup NEW: can force the antivirus from conf file or autoprepend ini setup
NEW: can add event to log into blockedlog module with a constant NEW: can add event to log into blockedlog module with a constant
NEW: add property cssview when declaring fields of an object NEW: add property cssview when declaring fields of an object
NEW: Can use dynamic code into the 'enabled' property of DAO fields NEW: can use dynamic code into the 'enabled' property of DAO fields
NEW: allow to edit "demand reason" field though API
NEW: fetch contact by email with REST API
NEW: field ref_ext in llx_commandedet NEW: field ref_ext in llx_commandedet
NEW: fields ref_ext for Attributes and Combinations NEW: field ref_ext for Attributes and Combinations
NEW: get state by REST API
NEW: get state dictionnary by REST API
NEW: improve Product API for variant products
NEW: OAuth SCOPE for Admin SDK NEW: OAuth SCOPE for Admin SDK
NEW: retrieve discount from invoice from API NEW: retrieve discount from invoice from API
NEW: standardizes API thirdparties by email like other object NEW: standardizes API thirdparties by email like other object
@ -220,6 +216,11 @@ NEW: API can update a payment
NEW: API get member by thirdparty NEW: API get member by thirdparty
NEW: API get thirdparty by barcode NEW: API get thirdparty by barcode
NEW: API get users by email / login NEW: API get users by email / login
NEW: allow to edit field "demand reason" through API
NEW: fetch contact by email with REST API
NEW: get state by REST API
NEW: get state dictionary by REST API
NEW: improve Product API for product variants
HOOKs HOOKs
NEW: Hook on propal card NEW: Hook on propal card

View File

@ -60,18 +60,19 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities). * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities).
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
* The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly. * The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly.
* CSRF attacks are accepted for all when using a POST URL, but when using GET URL, they are validated only for creating or updating data resctricted to the admin user. * CSRF attacks are accepted when using a POST URL, but when using GET URL, they are validated only for creating, updating or deleting data resctricted from pages restricted to admin users.
* Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user. * Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user.
Scope is the web application (back office) and the APIs. Scope is the web application (back office) and the APIs.
## Qualifying vulnerabilities for Bug bounty programs ## Qualifying vulnerabilities for Bug bounty programs
* Remote code execution (RCE) * Remote code execution (RCE)
* Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA) * Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA)
* Code injections (HTML, JS, SQL, PHP, ...) * Code injections (HTML, JS, SQL, PHP, ...)
* Cross-Site Scripting (XSS) * Cross-Site Scripting (XSS)
* Cross-Site Requests Forgery (CSRF) with real security impact * Cross-Site Requests Forgery (CSRF) with real security impact (when using GET URLs, CSRF are qualified only for creating, updating or deleting data from pages restricted to admin users)
* Open redirect * Open redirect
* Broken authentication & session management * Broken authentication & session management
* Insecure direct object references * Insecure direct object references
@ -83,6 +84,7 @@ Scope is the web application (back office) and the APIs.
## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting ## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting
* "Self" XSS * "Self" XSS
* SSL/TLS best practices * SSL/TLS best practices
* Denial of Service attacks * Denial of Service attacks

View File

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

View File

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

View File

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

View File

@ -50,6 +50,13 @@ Replace call to serialize_val with no bugged value
* In all files, replace constructor names into __construct. Replace also parent::constructor_name with parent::__construct * In all files, replace constructor names into __construct. Replace also parent::constructor_name with parent::__construct
* Line 4222 of file nusoap.php
$rev = array();
preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev);
$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")";
TCPDF: TCPDF:
@ -229,11 +236,21 @@ Change content of file htdocs/includes/restler/framework/Luracast/Restler/explor
public static function getShortName($className) public static function getShortName($className)
{ {
// @CHANGE LDR // @CHANGE LDR
if (! is_string($className)) return; if (!is_string($className)) return;
//var_dump($className); //var_dump($className);
* Add line into Data/Text.php to complete function
public static function endsWith($haystack, $needle)
{
$length = strlen($needle);
if ($length == 0) {
return true;
}
// @CHANGE LDR
if (!is_string($haystack)) return false;
PARSEDOWN PARSEDOWN
--------- ---------
@ -299,7 +316,7 @@ SELECT2
Edit CSS to restore line removed between 4.0.5 and 4.0.6. It generates this bug: https://github.com/select2/select2/issues/5832 Edit CSS to restore line removed between 4.0.5 and 4.0.6. It generates this bug: https://github.com/select2/select2/issues/5832
.select2-hidden-accessible { .select2-hidden-accessible {
margin: -1px !important; /* line to restore */ margin: -10000px !important; /* line to restore */
} }

View File

@ -12,6 +12,11 @@ The script initdemo.sh will erase current database with data into mysqldump_doli
Do a chmod 700 initdemo.sh Do a chmod 700 initdemo.sh
then run ./initdemo.sh to launch Graphic User Interface. then run ./initdemo.sh to launch Graphic User Interface.
After loading the demo files, admin login may be:
- admin / admin
or
- admin / adminadmin
*** Save demo *** Save demo

View File

@ -53,7 +53,7 @@ then
DIALOG="$DIALOG --ascii-lines" DIALOG="$DIALOG --ascii-lines"
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
trap "rm -f $fichtemp" 0 1 2 5 15 trap "rm -f $fichtemp" 0 1 2 5 15
$DIALOG --title "Init Dolibarr with demo values" --clear \ $DIALOG --title "Reset login password" --clear \
--inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp --inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp
valret=$? valret=$?
case $valret in case $valret in
@ -70,7 +70,7 @@ then
DIALOG=${DIALOG=dialog} DIALOG=${DIALOG=dialog}
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
trap "rm -f $fichtemp" 0 1 2 5 15 trap "rm -f $fichtemp" 0 1 2 5 15
$DIALOG --title "Init Dolibarr with demo values" --clear \ $DIALOG --title "Reset login password" --clear \
--inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp --inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp
valret=$? valret=$?
@ -128,7 +128,7 @@ then
# ---------------------------- confirmation # ---------------------------- confirmation
DIALOG=${DIALOG=dialog} DIALOG=${DIALOG=dialog}
$DIALOG --title "Init demo login with demo values" --clear \ $DIALOG --title "Reset login password" --clear \
--yesno "Do you confirm ? \n Mysql database : '$base' \n Mysql port : '$port' \n Demo login: '$demologin' \n Demo password : '$demopass'" 15 55 --yesno "Do you confirm ? \n Mysql database : '$base' \n Mysql port : '$port' \n Demo login: '$demologin' \n Demo password : '$demopass'" 15 55
case $? in case $? in

Binary file not shown.

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="INSTAT">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Envelope"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Envelope">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="envelopeId"/>
<xsd:element ref="DateTime"/>
<xsd:element ref="Party"/>
<xsd:element ref="softwareUsed" minOccurs="0"/>
<xsd:element ref="Declaration" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="envelopeId" type="xsd:string"/>
<xsd:element name="DateTime">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="date"/>
<xsd:element ref="time" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Party">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="partyId"/>
<xsd:element ref="partyName"/>
</xsd:sequence>
<xsd:attribute name="partyType" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="PSI"/>
<xsd:enumeration value="TDP"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="partyRole" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="sender"/>
<xsd:enumeration value="PSI"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="partyId" type="xsd:string"/>
<xsd:element name="partyName" type="xsd:string"/>
<xsd:element name="softwareUsed" type="xsd:string"/>
<xsd:element name="Declaration">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="declarationId"/>
<xsd:element ref="referencePeriod"/>
<xsd:element ref="PSIId"/>
<xsd:element ref="Function"/>
<xsd:element ref="declarationTypeCode"/>
<xsd:element ref="flowCode"/>
<xsd:element ref="currencyCode"/>
<xsd:element ref="Item" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="declarationId" type="xsd:string"/>
<xsd:element name="referencePeriod" type="xsd:string"/>
<xsd:element name="PSIId" type="xsd:string"/>
<xsd:element name="Function">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="functionCode"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="functionCode" type="xsd:string"/>
<xsd:element name="declarationTypeCode" type="xsd:string"/>
<xsd:element name="flowCode" type="xsd:string"/>
<xsd:element name="currencyCode" type="xsd:string"/>
<xsd:element name="Item">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="itemNumber"/>
<xsd:element ref="CN8" minOccurs="0"/>
<xsd:element ref="MSConsDestCode" minOccurs="0"/>
<xsd:element ref="countryOfOriginCode" minOccurs="0"/>
<xsd:element ref="netMass" minOccurs="0"/>
<xsd:element ref="quantityInSU" minOccurs="0"/>
<xsd:element ref="invoicedAmount"/>
<xsd:element ref="partnerId" minOccurs="0"/>
<xsd:element ref="invoicedNumber" minOccurs="0"/>
<xsd:element ref="statisticalProcedureCode" />
<xsd:element ref="NatureOfTransaction" minOccurs="0"/>
<xsd:element ref="modeOfTransportCode" minOccurs="0"/>
<xsd:element ref="regionCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="itemNumber" type="xsd:integer"/>
<xsd:element name="CN8">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="CN8Code" minOccurs="0"/>
<xsd:element ref="SUCode" minOccurs="0"/>
<xsd:element ref="additionalGoodsCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CN8Code" type="xsd:string"/>
<xsd:element name="SUCode" type="xsd:string"/>
<xsd:element name="additionalGoodsCode" type="xsd:string"/>
<xsd:element name="MSConsDestCode" type="xsd:string"/>
<xsd:element name="countryOfOriginCode" type="xsd:string"/>
<xsd:element name="netMass" type="xsd:integer"/>
<xsd:element name="quantityInSU" type="xsd:integer"/>
<xsd:element name="invoicedAmount" type="xsd:integer"/>
<xsd:element name="partnerId" type="xsd:string"/>
<xsd:element name="invoicedNumber" type="xsd:string"/>
<xsd:element name="statisticalProcedureCode" type="xsd:integer"/>
<xsd:element name="NatureOfTransaction">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="natureOfTransactionACode"/>
<xsd:element ref="natureOfTransactionBCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="natureOfTransactionACode" type="xsd:string"/>
<xsd:element name="natureOfTransactionBCode" type="xsd:string"/>
<xsd:element name="modeOfTransportCode" type="xsd:string"/>
<xsd:element name="regionCode" type="xsd:string"/>
<xsd:element name="date" type="xsd:date"/>
<xsd:element name="time" type="xsd:time"/>
</xsd:schema>

View File

@ -6,7 +6,7 @@
<exclude-pattern type="relative">build/html</exclude-pattern> <exclude-pattern type="relative">build/html</exclude-pattern>
<exclude-pattern type="relative">build/aps</exclude-pattern> <exclude-pattern type="relative">build/aps</exclude-pattern>
<exclude-pattern type="relative">dev/namespacemig</exclude-pattern> <exclude-pattern type="relative">dev/tools/test/namespacemig</exclude-pattern>
<exclude-pattern type="relative">dev/initdata/dbf/includes</exclude-pattern> <exclude-pattern type="relative">dev/initdata/dbf/includes</exclude-pattern>
<exclude-pattern type="relative">documents</exclude-pattern> <exclude-pattern type="relative">documents</exclude-pattern>
<exclude-pattern type="relative">htdocs/core/class/lessc.class.php</exclude-pattern> <exclude-pattern type="relative">htdocs/core/class/lessc.class.php</exclude-pattern>

View File

@ -15,6 +15,9 @@ function faaa()
return 'faaa'; return 'faaa';
} }
/**
* Class Aaa
*/
class Aaa class Aaa
{ {
const AAA='aaa'; const AAA='aaa';

View File

@ -12,6 +12,9 @@ function fbbb()
return 'fbbb'; return 'fbbb';
} }
/**
* Class Bbb
*/
class Bbb class Bbb
{ {
const BBB='bbb'; const BBB='bbb';

View File

@ -314,7 +314,6 @@ if ($action != 'export_csv')
if (empty($accountingaccountstatic->account_number)) { if (empty($accountingaccountstatic->account_number)) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>'; $link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
} }
print '<tr class="oddeven">';
if (!empty($show_subgroup)) if (!empty($show_subgroup))
{ {
@ -343,6 +342,7 @@ if ($action != 'export_csv')
} }
} }
print '<tr class="oddeven">';
print '<td>'.$accounting_account.'</td>'; print '<td>'.$accounting_account.'</td>';
print '<td class="nowraponall right">'.price($opening_balance).'</td>'; print '<td class="nowraponall right">'.price($opening_balance).'</td>';
print '<td class="nowraponall right">'.price($line->debit).'</td>'; print '<td class="nowraponall right">'.price($line->debit).'</td>';

View File

@ -642,6 +642,7 @@ if (empty($reshook)) {
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly'));
$url = './card.php?action=create'; $url = './card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid; if (!empty($socid)) $url .= '&socid='.$socid;
@ -936,6 +937,11 @@ while ($i < min($num, $limit))
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'bank')
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$objectstatic = new AccountLine($db);
$objectstatic->fetch($line->fk_doc);
} else { } else {
// Other type // Other type
} }
@ -950,6 +956,10 @@ while ($i < min($num, $limit))
{ {
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink; print $documentlink;
} elseif ($line->doc_type == 'bank') {
print $objectstatic->getNomUrl(1);
$bank_ref = strstr($line->doc_ref, '-');
print " " . $bank_ref;
} else { } else {
print $line->doc_ref; print $line->doc_ref;
} }

View File

@ -39,8 +39,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array("accountancy", "compta")); $langs->loadLangs(array("accountancy", "compta"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_date_startyear = GETPOST('search_date_startyear', 'int');
$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
$search_date_startday = GETPOST('search_date_startday', 'int');
$search_date_endyear = GETPOST('search_date_endyear', 'int');
$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
$search_date_endday = GETPOST('search_date_endday', 'int');
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
$search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', '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 = GETPOST("search_accountancy_code");
@ -126,9 +132,24 @@ $arrayfields = array(
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
if ($search_date_start && empty($search_date_startyear)) {
$tmparray = dol_getdate($search_date_start);
$search_date_startyear = $tmparray['year'];
$search_date_startmonth = $tmparray['mon'];
$search_date_startday = $tmparray['mday'];
}
if ($search_date_end && empty($search_date_endyear)) {
$tmparray = dol_getdate($search_date_end);
$search_date_endyear = $tmparray['year'];
$search_date_endmonth = $tmparray['mon'];
$search_date_endday = $tmparray['mday'];
}
/* /*
* Action * Action
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
@ -172,11 +193,11 @@ if (empty($reshook))
if (!empty($search_date_start)) { if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start; $filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); $param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear;
} }
if (!empty($search_date_end)) { if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end; $filter['t.doc_date<='] = $search_date_end;
$param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); $param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear;
} }
if (!empty($search_doc_date)) { if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date; $filter['t.doc_date'] = $search_doc_date;
@ -242,7 +263,7 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri
} }
// Make a redirect to avoid to launch the delete later after a back button // Make a redirect to avoid to launch the delete later after a back button
header("Location: listbyaccount.php".($param ? '?'.$param : '')); header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
exit; exit;
} }
} }
@ -267,7 +288,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
} }
// Make a redirect to avoid to launch the delete later after a back button // Make a redirect to avoid to launch the delete later after a back button
header("Location: listbyaccount.php".($param ? '?'.$param : '')); header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
exit; exit;
} else { } else {
setEventMessages("NoRecordDeleted", null, 'warnings'); setEventMessages("NoRecordDeleted", null, 'warnings');
@ -284,7 +305,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} }
header("Location: listbyaccount.php?noreset=1".($param ? '&'.$param : '')); header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
exit; exit;
} }
} }
@ -303,7 +324,6 @@ $title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccou
llxHeader('', $title_page); llxHeader('', $title_page);
// List // List
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
@ -380,10 +400,8 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) { if (empty($reshook)) {
$newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= ' &nbsp; ';
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
} }
@ -524,8 +542,15 @@ while ($i < min($num, $limit))
// Is it a break ? // Is it a break ?
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
$colspan = $totalarray['nbfield'] - 3; if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colspanend = $totalarray['nbfield'] - 7; $colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
// Show a subtotal by accounting account // Show a subtotal by accounting account
if (isset($displayed_account_number)) { if (isset($displayed_account_number)) {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
@ -642,20 +667,29 @@ while ($i < min($num, $limit))
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'bank')
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$objectstatic = new AccountLine($db);
$objectstatic->fetch($line->fk_doc);
} else { } else {
// Other type // Other type
} }
print '<td class="nowrap">'; print '<td class="maxwidth400">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
// Picto + Ref // Picto + Ref
print '<td class="nobordernopadding nowrap">'; print '<td class="nobordernopadding">';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
{ {
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink; print $documentlink;
} elseif ($line->doc_type == 'bank') {
print $objectstatic->getNomUrl(1);
$bank_ref = strstr($line->doc_ref, '-');
print " " . $bank_ref;
} else { } else {
print $line->doc_ref; print $line->doc_ref;
} }
@ -725,8 +759,15 @@ while ($i < min($num, $limit))
} }
// Show sub-total of last shown account // Show sub-total of last shown account
$colspan = $totalarray['nbfield'] - 3; if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colspanend = $totalarray['nbfield'] - 8; $colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>'; print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>'; print '<td class="nowrap right">'.price($sous_total_debit).'</td>';

View File

@ -39,8 +39,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array("accountancy", "compta")); $langs->loadLangs(array("accountancy", "compta"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_date_startyear = GETPOST('search_date_startyear', 'int');
$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
$search_date_startday = GETPOST('search_date_startday', 'int');
$search_date_endyear = GETPOST('search_date_endyear', 'int');
$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
$search_date_endday = GETPOST('search_date_endday', 'int');
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
$search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', '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 = GETPOST("search_accountancy_code");
@ -126,6 +132,20 @@ $arrayfields = array(
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
if ($search_date_start && empty($search_date_startyear)) {
$tmparray = dol_getdate($search_date_start);
$search_date_startyear = $tmparray['year'];
$search_date_startmonth = $tmparray['mon'];
$search_date_startday = $tmparray['mday'];
}
if ($search_date_end && empty($search_date_endyear)) {
$tmparray = dol_getdate($search_date_end);
$search_date_endyear = $tmparray['year'];
$search_date_endmonth = $tmparray['mon'];
$search_date_endday = $tmparray['mday'];
}
/* /*
* Action * Action
*/ */
@ -172,11 +192,11 @@ if (empty($reshook))
if (!empty($search_date_start)) { if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start; $filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); $param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear;
} }
if (!empty($search_date_end)) { if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end; $filter['t.doc_date<='] = $search_date_end;
$param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); $param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear;
} }
if (!empty($search_doc_date)) { if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date; $filter['t.doc_date'] = $search_doc_date;
@ -242,7 +262,7 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri
} }
// Make a redirect to avoid to launch the delete later after a back button // Make a redirect to avoid to launch the delete later after a back button
header("Location: listbyaccount.php".($param ? '?'.$param : '')); header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
exit; exit;
} }
} }
@ -380,14 +400,19 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) { if (empty($reshook)) {
$newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
} }
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded"));
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
@ -521,8 +546,15 @@ while ($i < min($num, $limit))
// Is it a break ? // Is it a break ?
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
$colspan = $totalarray['nbfield'] - 3; if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colspanend = $totalarray['nbfield'] - 7; $colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
// Show a subtotal by accounting account // Show a subtotal by accounting account
if (isset($displayed_account_number)) { if (isset($displayed_account_number)) {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
@ -554,8 +586,16 @@ while ($i < min($num, $limit))
// Show the break account // Show the break account
print "<tr>"; print "<tr>";
print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 9).'" style="font-weight:bold; border-bottom: 1pt solid black;">'; print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 9).'" style="font-weight:bold; border-bottom: 1pt solid black;">';
if ($line->subledger_account != "" && $line->subledger_account != '-1') print length_accounta($line->subledger_account).' : '.$object->get_compte_desc($line->numero_compte); if ($line->subledger_account != "" && $line->subledger_account != '-1') {
else print '<span class="error">'.$langs->trans("Unknown").'</span>'; print $object->get_compte_desc($line->numero_compte).' : '.length_accounta($line->subledger_account);
} else {
// Should not happen: subledger account must be null or a non empty value
print '<span class="error">'.$langs->trans("Unknown");
if ($line->subledger_label) print ' ('.$line->subledger_label.')';
$htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
print $form->textwithpicto('', $htmltext);
print '</span>';
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -639,20 +679,29 @@ while ($i < min($num, $limit))
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'bank')
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$objectstatic = new AccountLine($db);
$objectstatic->fetch($line->fk_doc);
} else { } else {
// Other type // Other type
} }
print '<td class="nowrap">'; print '<td class="maxwidth400">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
// Picto + Ref // Picto + Ref
print '<td class="nobordernopadding nowrap">'; print '<td class="nobordernopadding">';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
{ {
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink; print $documentlink;
} elseif ($line->doc_type == 'bank') {
print $objectstatic->getNomUrl(1);
$bank_ref = strstr($line->doc_ref, '-');
print " " . $bank_ref;
} else { } else {
print $line->doc_ref; print $line->doc_ref;
} }
@ -722,8 +771,15 @@ while ($i < min($num, $limit))
} }
// Show sub-total of last shown account // Show sub-total of last shown account
$colspan = $totalarray['nbfield'] - 3; if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colspanend = $totalarray['nbfield'] - 8; $colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>'; print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>'; print '<td class="nowrap right">'.price($sous_total_debit).'</td>';

View File

@ -60,6 +60,7 @@ class AccountancyExport
public static $EXPORT_TYPE_GESTINUMV3 = 130; public static $EXPORT_TYPE_GESTINUMV3 = 130;
public static $EXPORT_TYPE_GESTINUMV5 = 135; public static $EXPORT_TYPE_GESTINUMV5 = 135;
public static $EXPORT_TYPE_FEC = 1000; public static $EXPORT_TYPE_FEC = 1000;
public static $EXPORT_TYPE_FEC2 = 1010;
/** /**
@ -121,6 +122,7 @@ class AccountancyExport
self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'),
self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'),
self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
self::$EXPORT_TYPE_FEC2 => $langs->trans('Modelcsv_FEC2'),
); );
ksort($listofexporttypes, SORT_NUMERIC); ksort($listofexporttypes, SORT_NUMERIC);
@ -155,6 +157,7 @@ class AccountancyExport
self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3',
self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5',
self::$EXPORT_TYPE_FEC => 'fec', self::$EXPORT_TYPE_FEC => 'fec',
self::$EXPORT_TYPE_FEC2 => 'fec2',
); );
return $formatcode[$type]; return $formatcode[$type];
@ -234,6 +237,10 @@ class AccountancyExport
'label' => $langs->trans('Modelcsv_FEC'), 'label' => $langs->trans('Modelcsv_FEC'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt', 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
), ),
self::$EXPORT_TYPE_FEC2 => array(
'label' => $langs->trans('Modelcsv_FEC2'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
),
), ),
'cr'=> array( 'cr'=> array(
'1' => $langs->trans("Unix"), '1' => $langs->trans("Unix"),
@ -322,6 +329,9 @@ class AccountancyExport
case self::$EXPORT_TYPE_FEC : case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData); $this->exportFEC($TData);
break; break;
case self::$EXPORT_TYPE_FEC2 :
$this->exportFEC2($TData);
break;
default: default:
$this->errors[] = $langs->trans('accountancy_error_modelnotfound'); $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
break; break;
@ -505,9 +515,9 @@ class AccountancyExport
$end_line = "\r\n"; $end_line = "\r\n";
//We should use dol_now function not time however this is wrong date to transfert in accounting // We should use dol_now function not time however this is wrong date to transfert in accounting
//$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy // $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
//$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy // $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
foreach ($TData as $data) { foreach ($TData as $data) {
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (!empty($data->subledger_account)) if (!empty($data->subledger_account))
@ -519,36 +529,46 @@ class AccountancyExport
$Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2); $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
$Tab['folio'] = '000'; $Tab['folio'] = '000';
//We use invoice date $data->doc_date not $date_ecriture which is the transfert date // We use invoice date $data->doc_date not $date_ecriture which is the transfert date
//maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ? // maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
//$Tab['date_ecriture'] = $date_ecriture; //$Tab['date_ecriture'] = $date_ecriture;
$Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y'); $Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
$Tab['filler'] = ' '; $Tab['filler'] = ' ';
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
//elarifr le montant doit etre en centimes sans point decimal ! // Credit invoice - invert sens
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount if ($data->montant < 0) {
// $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount if ($data->sens == 'C') {
$Tab['sens'] = 'D';
} else {
$Tab['sens'] = 'C';
}
$Tab['signe_montant'] = '-';
} else {
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
}
// The amount must be in centimes without decimal points.
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT);
$Tab['contrepartie'] = str_repeat(' ', 8); $Tab['contrepartie'] = str_repeat(' ', 8);
// elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting // Force date format : %d%m%y
if (!empty($data->date_echeance)) { if (!empty($data->date_echeance)) {
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // Format must be ddmmyy
} else { } else {
$Tab['date_echeance'] = '000000'; $Tab['date_echeance'] = '000000';
} }
//elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5) // Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
//$Tab['lettrage'] = str_repeat(' ', 5); // $Tab['lettrage'] = str_repeat(' ', 5);
$Tab['lettrage'] = str_repeat(' ', 2); $Tab['lettrage'] = str_repeat(' ', 2);
$Tab['codestat'] = str_repeat(' ', 3); $Tab['codestat'] = str_repeat(' ', 3);
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
//elarifr keep correct quadra named field instead of anon filler // Keep correct quadra named field instead of anon filler
//$Tab['filler2'] = str_repeat(' ', 20); // $Tab['filler2'] = str_repeat(' ', 20);
$Tab['affaire'] = str_repeat(' ', 10); $Tab['affaire'] = str_repeat(' ', 10);
$Tab['quantity1'] = str_repeat(' ', 10); $Tab['quantity1'] = str_repeat(' ', 10);
$Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8); $Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
@ -556,17 +576,17 @@ class AccountancyExport
$Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
$Tab['filler3'] = str_repeat(' ', 3); $Tab['filler3'] = str_repeat(' ', 3);
//elarifr keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!! // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
//as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec // as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec
//todo we should filter more than only accent to avoid wrong line size // TODO: we should filter more than only accent to avoid wrong line size
//TODO: remove invoice number doc_ref in libelle, // TODO: remove invoice number doc_ref in libelle,
//TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software
//$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30); //$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30);
$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 30), 30); $Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 30), 30);
$Tab['codetva'] = str_repeat(' ', 2); $Tab['codetva'] = str_repeat(' ', 2);
//elarifr we need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
//$Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
$Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10); $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
$Tab['filler4'] = str_repeat(' ', 73); $Tab['filler4'] = str_repeat(' ', 73);
@ -891,6 +911,105 @@ class AccountancyExport
} }
} }
/**
* Export format : FEC2
*
* @param array $objectLines data
* @return void
*/
public function exportFEC2($objectLines)
{
$separator = "\t";
$end_line = "\r\n";
print "JournalCode".$separator;
print "JournalLib".$separator;
print "EcritureNum".$separator;
print "EcritureDate".$separator;
print "CompteNum".$separator;
print "CompteLib".$separator;
print "CompAuxNum".$separator;
print "CompAuxLib".$separator;
print "PieceRef".$separator;
print "PieceDate".$separator;
print "EcritureLib".$separator;
print "Debit".$separator;
print "Credit".$separator;
print "EcritureLet".$separator;
print "DateLet".$separator;
print "ValidDate".$separator;
print "Montantdevise".$separator;
print "Idevise";
print $end_line;
foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]);
} else {
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d');
// FEC:JournalCode
print $line->code_journal . $separator;
// FEC:JournalLib
print $line->journal_label . $separator;
// FEC:EcritureNum
print $line->piece_num . $separator;
// FEC:EcritureDate
print $date_creation . $separator;
// FEC:CompteNum
print $line->numero_compte . $separator;
// FEC:CompteLib
print dol_string_unaccent($line->label_compte) . $separator;
// FEC:CompAuxNum
print $line->subledger_account . $separator;
// FEC:CompAuxLib
print dol_string_unaccent($line->subledger_label) . $separator;
// FEC:PieceRef
print $line->doc_ref . $separator;
// FEC:PieceDate
print $date_document . $separator;
// FEC:EcritureLib
print dol_string_unaccent($line->label_operation) . $separator;
// FEC:Debit
print price2fec($line->debit) . $separator;
// FEC:Credit
print price2fec($line->credit) . $separator;
// FEC:EcritureLet
print $line->lettering_code . $separator;
// FEC:DateLet
print $date_lettering . $separator;
// FEC:ValidDate
print $date_validation . $separator;
// FEC:Montantdevise
print $line->multicurrency_amount . $separator;
// FEC:Idevise
print $line->multicurrency_code;
print $end_line;
}
}
}
/** /**
* Export format : SAGE50SWISS * Export format : SAGE50SWISS
* *

View File

@ -825,6 +825,10 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') { } elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1); $sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') {
$sqlwhere[] = 't.lettering_code IS NULL';
} elseif ($key == 't.code_journal' && !empty($value)) {
$sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
} else { } else {
$sqlwhere[] = natural_search($key, $value, 0, 1); $sqlwhere[] = natural_search($key, $value, 0, 1);
} }

View File

@ -1064,7 +1064,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Ref // Ref
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->id.'</td></tr>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->ref.'</td></tr>';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {

View File

@ -63,19 +63,24 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
$arrayofmembers = array(); $arrayofmembers = array();
// request taking into account member with up to date subscriptions // request taking into account member with up to date subscriptions
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; $sql = "SELECT d.rowid, d.ref, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
$sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
$sql .= " t.libelle as type,"; $sql .= " t.libelle as type,";
$sql .= " c.code as country_code, c.label as country"; $sql .= " c.code as country_code, c.label as country";
// Add fields from extrafields // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
}
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
}
$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
$sql .= " AND d.entity IN (".getEntity('adherent').")"; $sql .= " AND d.entity IN (".getEntity('adherent').")";
if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; if (is_numeric($foruserid)) $sql .= " AND d.rowid=".(int) $foruserid;
if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'";
$sql .= " ORDER BY d.rowid ASC"; $sql .= " ORDER BY d.rowid ASC";
@ -90,6 +95,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
if ($objp->country == '-') $objp->country = ''; if ($objp->country == '-') $objp->country = '';
$adherentstatic->id = $objp->rowid; $adherentstatic->id = $objp->rowid;
$adherentstatic->ref = $objp->ref;
$adherentstatic->lastname = $objp->lastname; $adherentstatic->lastname = $objp->lastname;
$adherentstatic->firstname = $objp->firstname; $adherentstatic->firstname = $objp->firstname;
@ -110,6 +116,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
// List of values to scan for a replacement // List of values to scan for a replacement
$substitutionarray = array( $substitutionarray = array(
'__ID__'=>$objp->rowid, '__ID__'=>$objp->rowid,
'__REF__'=>$objp->ref,
'__LOGIN__'=>$objp->login, '__LOGIN__'=>$objp->login,
'__FIRSTNAME__'=>$objp->firstname, '__FIRSTNAME__'=>$objp->firstname,
'__LASTNAME__'=>$objp->lastname, '__LASTNAME__'=>$objp->lastname,
@ -149,6 +156,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
'textfooter'=>$textfooter, 'textfooter'=>$textfooter,
'textright'=>$textright, 'textright'=>$textright,
'id'=>$objp->rowid, 'id'=>$objp->rowid,
'ref'=>$objp->ref,
'photo'=>$objp->photo 'photo'=>$objp->photo
); );
} }
@ -159,6 +167,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
'textfooter'=>$textfooter, 'textfooter'=>$textfooter,
'textright'=>$textright, 'textright'=>$textright,
'id'=>$objp->rowid, 'id'=>$objp->rowid,
'ref'=>$objp->ref,
'photo'=>$objp->photo 'photo'=>$objp->photo
); );
} }
@ -172,12 +181,15 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
$textfooter = ''; $textfooter = '';
$textright = ''; $textright = '';
$arrayofmembers[] = array('textleft'=>$textleft, $arrayofmembers[] = array(
'textheader'=>$textheader, 'textleft'=>$textleft,
'textfooter'=>$textfooter, 'textheader'=>$textheader,
'textright'=>$textright, 'textfooter'=>$textfooter,
'id'=>$objp->rowid, 'textright'=>$textright,
'photo'=>$objp->photo); 'id'=>$objp->rowid,
'ref'=>$objp->ref,
'photo'=>$objp->photo,
);
} }
$i++; $i++;

View File

@ -288,6 +288,7 @@ class Adherent extends CommonObject
*/ */
public $fields = array( public $fields = array(
'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10),
'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'default' => 1, 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 12, 'index' => 1),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), 'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20),
'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25), 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25),
@ -417,6 +418,7 @@ class Adherent extends CommonObject
$infos = ''; $infos = '';
if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n";
$infos .= $langs->transnoentities("id").": ".$this->id."\n"; $infos .= $langs->transnoentities("id").": ".$this->id."\n";
$infos .= $langs->transnoentities("ref").": ".$this->ref."\n";
$infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; $infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
$infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; $infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n";
$infos .= $langs->transnoentities("Company").": ".$this->company."\n"; $infos .= $langs->transnoentities("Company").": ".$this->company."\n";
@ -438,15 +440,20 @@ class Adherent extends CommonObject
// Substitutions // Substitutions
$substitutionarray = array( $substitutionarray = array(
'__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), '__ID__' => $this->id,
'__REF__' => $this->ref,
'__MEMBER_ID__' => $this->id,
'__CIVILITY__' => $this->getCivilityLabel(),
'__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''), '__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''),
'__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''), '__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''),
'__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs), '__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs),
'__COMPANY__' => $msgishtml ? dol_htmlentitiesbr($this->company) : ($this->company ? $this->company : ''), '__COMPANY__' => $msgishtml ? dol_htmlentitiesbr($this->company) : ($this->company ? $this->company : ''),
'__ADDRESS__' => $msgishtml ? dol_htmlentitiesbr($this->address) : ($this->address ? $this->address : ''), '__ADDRESS__' => $msgishtml ? dol_htmlentitiesbr($this->address) : ($this->address ? $this->address : ''),
'__ZIP__' => $msgishtml ? dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip : ''), '__TOWN__' => $msgishtml ? dol_htmlentitiesbr($this->town) : ($this->town ? $this->town : ''), '__ZIP__' => $msgishtml ? dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip : ''),
'__TOWN__' => $msgishtml ? dol_htmlentitiesbr($this->town) : ($this->town ? $this->town : ''),
'__COUNTRY__' => $msgishtml ? dol_htmlentitiesbr($this->country) : ($this->country ? $this->country : ''), '__COUNTRY__' => $msgishtml ? dol_htmlentitiesbr($this->country) : ($this->country ? $this->country : ''),
'__EMAIL__' => $msgishtml ? dol_htmlentitiesbr($this->email) : ($this->email ? $this->email : ''), '__BIRTH__' => $msgishtml ? dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''), '__EMAIL__' => $msgishtml ? dol_htmlentitiesbr($this->email) : ($this->email ? $this->email : ''),
'__BIRTH__' => $msgishtml ? dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''),
'__PHOTO__' => $msgishtml ? dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo : ''), '__PHOTO__' => $msgishtml ? dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo : ''),
'__LOGIN__' => $msgishtml ? dol_htmlentitiesbr($this->login) : ($this->login ? $this->login : ''), '__LOGIN__' => $msgishtml ? dol_htmlentitiesbr($this->login) : ($this->login ? $this->login : ''),
'__PASSWORD__' => $msgishtml ? dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass : ''), '__PASSWORD__' => $msgishtml ? dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass : ''),
@ -519,9 +526,10 @@ class Adherent extends CommonObject
// Insert member // Insert member
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent";
$sql .= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)"; $sql .= " (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)";
$sql .= " VALUES ("; $sql .= " VALUES (";
$sql .= " '".$this->db->idate($this->datec)."'"; $sql .= " '(PROV)'";
$sql .= ", '".$this->db->idate($this->datec)."'";
$sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); $sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null");
$sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script
$sql .= ", null, null, '".$this->db->escape($this->morphy)."'"; $sql .= ", null, null, '".$this->db->escape($this->morphy)."'";
@ -635,7 +643,8 @@ class Adherent extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql .= " civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null"); $sql .= " ref = '".$this->db->escape($this->ref)."'";
$sql .= ", civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null");
$sql .= ", firstname = ".($this->firstname ? "'".$this->db->escape($this->firstname)."'" : "null"); $sql .= ", firstname = ".($this->firstname ? "'".$this->db->escape($this->firstname)."'" : "null");
$sql .= ", lastname = ".($this->lastname ? "'".$this->db->escape($this->lastname)."'" : "null"); $sql .= ", lastname = ".($this->lastname ? "'".$this->db->escape($this->lastname)."'" : "null");
$sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
@ -752,6 +761,7 @@ class Adherent extends CommonObject
// 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 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; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login = $this->login;
$luser->ref = $this->ref;
$luser->civility_id = $this->civility_id; $luser->civility_id = $this->civility_id;
$luser->firstname = $this->firstname; $luser->firstname = $this->firstname;
$luser->lastname = $this->lastname; $luser->lastname = $this->lastname;
@ -1242,7 +1252,8 @@ class Adherent extends CommonObject
{ {
global $langs; global $langs;
$sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql = "SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
$sql .= " d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
$sql .= " d.note_public,"; $sql .= " d.note_public,";
$sql .= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql .= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
$sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
@ -1268,7 +1279,7 @@ class Adherent extends CommonObject
} elseif ($ref || $fk_soc) { } elseif ($ref || $fk_soc) {
$sql .= " AND d.entity IN (".getEntity('adherent').")"; $sql .= " AND d.entity IN (".getEntity('adherent').")";
if ($ref) { if ($ref) {
$sql .= " AND d.rowid='".$this->db->escape($ref)."'"; $sql .= " AND d.ref='".$this->db->escape($ref)."'";
} elseif ($fk_soc > 0) { } elseif ($fk_soc > 0) {
$sql .= " AND d.fk_soc=".((int) $fk_soc); $sql .= " AND d.fk_soc=".((int) $fk_soc);
} }
@ -1283,8 +1294,8 @@ class Adherent extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->entity = $obj->entity; $this->entity = $obj->entity;
$this->ref = $obj->rowid;
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->ref_ext = $obj->ref_ext; $this->ref_ext = $obj->ref_ext;
$this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility
@ -2072,7 +2083,7 @@ class Adherent extends CommonObject
if ($mode == 'login') { if ($mode == 'login') {
$result .= dol_trunc($this->login, $maxlen); $result .= dol_trunc($this->login, $maxlen);
} elseif ($mode == 'ref') { } elseif ($mode == 'ref') {
$result .= $this->id; $result .= $this->ref;
} else { } else {
$result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen); $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen);
} }
@ -2317,6 +2328,7 @@ class Adherent extends CommonObject
// Initialise parametres // Initialise parametres
$this->id = 0; $this->id = 0;
$this->ref = 'ABC001';
$this->entity = 1; $this->entity = 1;
$this->specimen = 1; $this->specimen = 1;
$this->civility_id = 0; $this->civility_id = 0;

View File

@ -101,7 +101,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array( $fieldstosearchall = array(
'd.rowid'=>'Ref', 'd.ref'=>'Ref',
'd.login'=>'Login', 'd.login'=>'Login',
'd.lastname'=>'Lastname', 'd.lastname'=>'Lastname',
'd.firstname'=>'Firstname', 'd.firstname'=>'Firstname',
@ -146,12 +146,7 @@ $arrayfields = array(
'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
/* /*
@ -251,7 +246,7 @@ $memberstatic = new Adherent($db);
$now = dol_now(); $now = dol_now();
$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; $sql = "SELECT d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,";
$sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,";
$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
@ -268,8 +263,13 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql); $sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
}
if (!empty($search_categ) || !empty($catid)) {
// We need this table joined to the select in order to filter by categ
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
@ -285,10 +285,12 @@ if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type);
if ($search_filter == 'withoutsubscription') $sql .= " AND (datefin IS NULL OR t.subscription = 0)"; if ($search_filter == 'withoutsubscription') $sql .= " AND (datefin IS NULL OR t.subscription = 0)";
if ($search_filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; if ($search_filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
if ($search_filter == 'outofdate') $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; if ($search_filter == 'outofdate') $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
if ($search_status != '') $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($search_status != '') {
// Peut valoir un nombre ou liste de nombre separes par virgules
$sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
}
if ($search_ref) { if ($search_ref) {
if (is_numeric($search_ref)) $sql .= " AND (d.rowid = ".$db->escape($search_ref).")"; $sql .= natural_search("d.ref", $search_ref);
else $sql .= " AND 1 = 2"; // Always wrong
} }
if ($search_civility) $sql .= natural_search("d.civility", $search_civility); if ($search_civility) $sql .= natural_search("d.civility", $search_civility);
if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname); if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname);
@ -607,7 +609,7 @@ print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); 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.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $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.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); if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
@ -647,7 +649,7 @@ while ($i < min($num, $limit)) {
$datefin = $db->jdate($obj->datefin); $datefin = $db->jdate($obj->datefin);
$memberstatic->id = $obj->rowid; $memberstatic->id = $obj->rowid;
$memberstatic->ref = $obj->rowid; $memberstatic->ref = $obj->ref;
$memberstatic->civility_id = $obj->civility; $memberstatic->civility_id = $obj->civility;
$memberstatic->lastname = $obj->lastname; $memberstatic->lastname = $obj->lastname;
$memberstatic->firstname = $obj->firstname; $memberstatic->firstname = $obj->firstname;

View File

@ -300,57 +300,75 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
if (!$error) { if (!$error) {
// Send confirmation Email // Send confirmation Email
if ($object->email && $sendalsoemail) { // $object is 'Adherent' if ($object->email && $sendalsoemail) { // $object is 'Adherent'
$subject = ''; $parameters = array(
$msg = ''; 'datesubscription' => $datesubscription,
'amount' => $amount,
// Send subscription email 'ccountid' => $accountid,
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; 'operation' => $operation,
$formmail = new FormMail($db); 'label' => $label,
// Set output language 'num_chq' => $num_chq,
$outputlangs = new Translate('', $conf); 'emetteur_nom' => $emetteur_nom,
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); 'emetteur_banque' => $emetteur_banque,
// Load traductions files required by page 'datesubend' => $datesubend
$outputlangs->loadLangs(array("main", "members")); );
$reshook = $hookmanager->executeHooks('sendMail', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Get email content from template if ($reshook < 0) {
$arraydefaultmessage = null; setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
} }
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); if (empty($reshook)) {
complete_substitutions_array($substitutionarray, $outputlangs, $object); $subject = '';
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $msg = '';
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
// Attach a file ? // Send subscription email
$file = ''; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$listofpaths = array(); $formmail = new FormMail($db);
$listofnames = array(); // Set output language
$listofmimes = array(); $outputlangs = new Translate('', $conf);
if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) { $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$invoicediroutput = $conf->facture->dir_output; // Load traductions files required by page
$fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); $outputlangs->loadLangs(array("main", "members"));
$file = $fileparams['fullname'];
$listofpaths = array($file); // Get email content from template
$listofnames = array(basename($file)); $arraydefaultmessage = null;
$listofmimes = array(dol_mimetype($file)); $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
}
$moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
$result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
if ($result < 0) { $subject = $arraydefaultmessage->topic;
$errmsg = $object->error; $msg = $arraydefaultmessage->content;
setEventMessages($object->error, $object->errors, 'errors'); }
} else {
setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
// Attach a file ?
$file = '';
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
$invoicediroutput = $conf->facture->dir_output;
$fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
$listofpaths = array($file);
$listofnames = array(basename($file));
$listofmimes = array(dol_mimetype($file));
}
$moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n";
$result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader);
if ($result < 0) {
$errmsg = $object->error;
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs');
}
} }
} else { } else {
setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs');

View File

@ -187,10 +187,18 @@ print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n"; print '<td class="right">'."\n";
if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>'; if (! getIsHTTPS()) {
$langs->load("errors");
print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
}
print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>'; if (! getIsHTTPS()) {
$langs->load("errors");
print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
}
print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";

View File

@ -111,11 +111,9 @@ if ($action == 'updateMask')
} }
// Activate a model // Activate a model
elseif ($action == 'set') elseif ($action == 'set') {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
@ -124,8 +122,7 @@ elseif ($action == 'set')
} }
// Set default model // Set default model
elseif ($action == 'setdoc') elseif ($action == 'setdoc') {
{
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{ {
// The constant that was read before the new set // The constant that was read before the new set
@ -139,8 +136,7 @@ elseif ($action == 'setdoc')
{ {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Check if numbering module chosen can be activated // TODO Check if numbering module chosen can be activated
// by calling method canBeActivated // by calling method canBeActivated
@ -254,6 +250,7 @@ print dol_get_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order')
print load_fiche_titre($langs->trans("OrdersNumberingModules"), '', ''); print load_fiche_titre($langs->trans("OrdersNumberingModules"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("Name").'</td>';
@ -346,7 +343,7 @@ foreach ($dirmodels as $reldir)
} }
} }
} }
print "</table><br>\n"; print "</table></div><br>\n";
/* /*
@ -377,6 +374,7 @@ if ($resql)
} }
print '<div class="div-table-responsive-no-min">';
print "<table class=\"noborder\" width=\"100%\">\n"; print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n"; print "<tr class=\"liste_titre\">\n";
print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("Name").'</td>';
@ -501,6 +499,7 @@ foreach ($dirmodels as $reldir)
} }
print '</table>'; print '</table>';
print '</div>';
/* /*

View File

@ -135,12 +135,13 @@ if ($action == 'deletefilter')
{ {
$emailcollectorfilter = new EmailCollectorFilter($db); $emailcollectorfilter = new EmailCollectorFilter($db);
$emailcollectorfilter->fetch(GETPOST('filterid', 'int')); $emailcollectorfilter->fetch(GETPOST('filterid', 'int'));
$result = $emailcollectorfilter->delete($user); if ($emailcollectorfilter->id > 0) {
if ($result > 0) $result = $emailcollectorfilter->delete($user);
{ if ($result > 0) {
$object->fetchFilters(); $object->fetchFilters();
} else { } else {
setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors'); setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
}
} }
} }
@ -153,13 +154,26 @@ if (GETPOST('addoperation', 'alpha'))
$emailcollectoroperation->status = 1; $emailcollectoroperation->status = 1;
$emailcollectoroperation->position = 50; $emailcollectoroperation->position = 50;
$result = $emailcollectoroperation->create($user); if ($emailcollectoroperation->type == '-1') {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Operation")), null, 'errors');
}
if ($result > 0) if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty'))
{ && empty($emailcollectoroperation->actionparam)) {
$object->fetchActions(); $error++;
} else { setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors');
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); }
if (!$error) {
$result = $emailcollectoroperation->create($user);
if ($result > 0) {
$object->fetchActions();
} else {
$error++;
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
}
} }
} }
@ -170,25 +184,35 @@ if ($action == 'updateoperation')
$emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml'); $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml');
$result = $emailcollectoroperation->update($user); if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty'))
&& empty($emailcollectoroperation->actionparam)) {
$error++;
setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors');
}
if ($result > 0) if (!$error) {
{ $result = $emailcollectoroperation->update($user);
$object->fetchActions();
} else { if ($result > 0)
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); {
$object->fetchActions();
} else {
$error++;
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
}
} }
} }
if ($action == 'deleteoperation') if ($action == 'deleteoperation')
{ {
$emailcollectoroperation = new EmailCollectorAction($db); $emailcollectoroperation = new EmailCollectorAction($db);
$emailcollectoroperation->fetch(GETPOST('operationid', 'int')); $emailcollectoroperation->fetch(GETPOST('operationid', 'int'));
$result = $emailcollectoroperation->delete($user); if ($emailcollectoroperation->id > 0) {
if ($result > 0) $result = $emailcollectoroperation->delete($user);
{ if ($result > 0) {
$object->fetchActions(); $object->fetchActions();
} else { } else {
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
}
} }
} }
@ -458,7 +482,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Filters").'</td><td></td><td></td>'; print '<td>'.$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'</td><td></td><td></td>';
print '</tr>'; print '</tr>';
// Add filter // Add filter
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -491,7 +515,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1),
'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1)
); );
print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 0, '', 2); print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 1, '', 2);
print "\n"; print "\n";
print '<script>'; print '<script>';
@ -544,7 +568,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table id="tablelines" class="noborder noshadow tableforfield">'; print '<table id="tablelines" class="noborder noshadow tableforfield">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("EmailcollectorOperations").'</td><td></td><td></td><td></td>'; print '<td>'.$form->textwithpicto($langs->trans("EmailcollectorOperations"), $langs->trans("EmailcollectorOperationsDesc")).'</td><td></td><td></td><td></td>';
print '</tr>'; print '</tr>';
// Add operation // Add operation
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -561,13 +585,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$parameters = array('arrayoftypes' => $arrayoftypes); $parameters = array('arrayoftypes' => $arrayoftypes);
$res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action); $res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action);
if ($res) if ($res) {
$arrayoftypes = $hookmanager->resArray; $arrayoftypes = $hookmanager->resArray;
else foreach ($hookmanager->resArray as $k=>$desc) } else {
foreach ($hookmanager->resArray as $k=>$desc) {
$arrayoftypes[$k] = $desc; $arrayoftypes[$k] = $desc;
}
}
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300', 1);
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300');
print '</td><td>'; print '</td><td>';
print '<input type="text" name="operationparam">'; print '<input type="text" name="operationparam">';
print '</td>'; print '</td>';

View File

@ -21,7 +21,7 @@
/** /**
* \file htdocs/admin/fckeditor.php * \file htdocs/admin/fckeditor.php
* \ingroup fckeditor * \ingroup fckeditor
* \brief Page d'activation du module FCKeditor dans les autres modules * \brief Activation page for the FCKeditor module in the other modules
*/ */
require '../main.inc.php'; require '../main.inc.php';
@ -43,35 +43,41 @@ $mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes';
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
// Constante et traduction de la description du module // Constant and translation of the module description
$modules = array( $modules = array(
'SOCIETE' => 'FCKeditorForCompany', 'SOCIETE' => 'FCKeditorForCompany',
'PRODUCTDESC' => 'FCKeditorForProduct', 'PRODUCTDESC' => 'FCKeditorForProduct',
'DETAILS' => 'FCKeditorForProductDetails', 'DETAILS' => 'FCKeditorForProductDetails',
'USERSIGN' => 'FCKeditorForUserSignature', 'USERSIGN' => 'FCKeditorForUserSignature',
'MAILING' => 'FCKeditorForMailing', 'MAILING' => 'FCKeditorForMailing',
'MAIL' => 'FCKeditorForMail', 'MAIL' => 'FCKeditorForMail',
'TICKET' => 'FCKeditorForTicket' 'TICKET' => 'FCKeditorForTicket',
'NOTE_PUBLIC' => 'FCKeditorForNotePublic',
'NOTE_PRIVATE' => 'FCKeditorForNotePrivate',
); );
// Conditions pour que l'option soit proposee // Conditions for the option to be offered
$conditions = array( $conditions = array(
'SOCIETE' => 1, 'SOCIETE' => 1,
'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)),
'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), 'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)),
'USERSIGN' => 1, 'USERSIGN' => 1,
'MAILING' => !empty($conf->mailing->enabled), 'MAILING' => !empty($conf->mailing->enabled),
'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)), 'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)),
'TICKET' => !empty($conf->ticket->enabled) 'TICKET' => !empty($conf->ticket->enabled),
'NOTE_PUBLIC' => 1,
'NOTE_PRIVATE' => 1,
); );
// Picto // Picto
$picto = array( $picto = array(
'SOCIETE' => 'generic', 'SOCIETE' => 'generic',
'PRODUCTDESC' => 'product', 'PRODUCTDESC' => 'product',
'DETAILS' => 'product', 'DETAILS' => 'product',
'USERSIGN' => 'user', 'USERSIGN' => 'user',
'MAILING' => 'email', 'MAILING' => 'email',
'MAIL' => 'email', 'MAIL' => 'email',
'TICKET' => 'ticket' 'TICKET' => 'ticket',
'NOTE_PUBLIC' => 'generic',
'NOTE_PRIVATE' => 'generic',
); );
@ -85,7 +91,7 @@ foreach ($modules as $const => $desc)
if ($action == 'activate_'.strtolower($const)) if ($action == 'activate_'.strtolower($const))
{ {
dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity);
// Si fckeditor est active dans la description produit/service, on l'active dans les formulaires // If fckeditor is active in the product/service description, it is activated in the forms
if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM))
{ {
dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity);
@ -154,7 +160,7 @@ if (empty($conf->use_javascript_ajax))
// Modules // Modules
foreach ($modules as $const => $desc) foreach ($modules as $const => $desc)
{ {
// Si condition non remplie, on ne propose pas l'option // If this condition is not met, the option is not offered
if (!$conditions[$const]) continue; if (!$conditions[$const]) continue;
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@ -123,7 +123,7 @@ print '</td></tr>';
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("MailingDelay").'</td><td>'; print $langs->trans("MailingDelay").'</td><td>';
print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">'; print '<input class="width75" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
print '</td></tr>'; print '</td></tr>';

View File

@ -131,8 +131,12 @@ if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $
$form = new Form($db); $form = new Form($db);
$linuxlike = 1; $linuxlike = 1;
if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; if (preg_match('/^win/i', PHP_OS)) {
if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; $linuxlike = 0;
}
if (preg_match('/^mac/i', PHP_OS)) {
$linuxlike = 0;
}
if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE = 'mail'; if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE = 'mail';
$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port'); $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port');

View File

@ -39,6 +39,8 @@ if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$type = 'paymentorder'; $type = 'paymentorder';
$error = 0;
/* /*
* Actions * Actions
@ -73,30 +75,25 @@ if ($action == "set")
} else $error++; } else $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (! ($res > 0)) $error++;
if (GETPOST("PRELEVEMENT_USER") > 0) if (GETPOST("PRELEVEMENT_USER") > 0) {
{ $res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity); if (! ($res > 0)) $error++;
if (!$res > 0) $error++; }
} if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END") == "") {
if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END") == "") $res = dolibarr_set_const($db, "PRELEVEMENT_END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"), 'chaine', 0, '', $conf->entity);
{ if (! ($res > 0)) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"), 'chaine', 0, '', $conf->entity); }
if (!$res > 0) $error++; if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD") == "") {
} $res = dolibarr_set_const($db, "PRELEVEMENT_USTRD", GETPOST("PRELEVEMENT_USTRD"), 'chaine', 0, '', $conf->entity);
if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD") == "") if (! ($res > 0)) $error++;
{ }
$res = dolibarr_set_const($db, "PRELEVEMENT_USTRD", GETPOST("PRELEVEMENT_USTRD"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
}
if (GETPOST("PRELEVEMENT_ADDDAYS") || GETPOST("PRELEVEMENT_ADDDAYS") == "") $res = dolibarr_set_const($db, "PRELEVEMENT_ADDDAYS", GETPOST("PRELEVEMENT_ADDDAYS"), 'chaine', 0, '', $conf->entity);
{ if (! ($res > 0)) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_ADDDAYS", GETPOST("PRELEVEMENT_ADDDAYS"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (! $error) {
} elseif (!$error)
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -193,9 +190,10 @@ print '</td></tr>';
//ADDDAYS //ADDDAYS
print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>';
print '<td class="left">'; print '<td class="left">';
if (!$conf->global->PRELEVEMENT_ADDDAYS) $conf->global->PRELEVEMENT_ADDDAYS = 0; if (empty($conf->global->PRELEVEMENT_ADDDAYS)) $conf->global->PRELEVEMENT_ADDDAYS = 0;
print '<input type="text" name="PRELEVEMENT_ADDDAYS" value="'.$conf->global->PRELEVEMENT_ADDDAYS.'" size="5" ></td>'; print '<input type="text" name="PRELEVEMENT_ADDDAYS" value="'.$conf->global->PRELEVEMENT_ADDDAYS.'" size="5" ></td>';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';

View File

@ -153,7 +153,7 @@ if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING);
} }
} }
print '<input type="text" '.(defined('MAIN_ANTIVIRUS_COMMAND') ? 'disabled' : '').' name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND) : '').'">'; print '<input type="text" '.(defined('MAIN_ANTIVIRUS_COMMAND') ? 'disabled ' : '').'name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND) : '').'">';
if (defined('MAIN_ANTIVIRUS_COMMAND')) { if (defined('MAIN_ANTIVIRUS_COMMAND')) {
print '<br><span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>'; print '<br><span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
} }
@ -167,7 +167,7 @@ print '<td colspan="2">'.$langs->trans("AntiVirusParam").'<br>';
print '<span class="opacitymedium">'.$langs->trans("AntiVirusParamExample").'</span>'; print '<span class="opacitymedium">'.$langs->trans("AntiVirusParamExample").'</span>';
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '<input type="text" name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_PARAM) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_PARAM) : '').'">'; print '<input type="text" '.(defined('MAIN_ANTIVIRUS_PARAM') ? 'disabled ' : '').'name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_PARAM) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_PARAM) : '').'">';
if (defined('MAIN_ANTIVIRUS_PARAM')) { if (defined('MAIN_ANTIVIRUS_PARAM')) {
print '<br><span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>'; print '<br><span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
} }

View File

@ -29,7 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("companies", "admin", "products", "sms", "other", "errors")); $langs->loadLangs(array("companies", "admin", "products", "sms", "other", "errors"));
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
if (!$user->admin) { if (!$user->admin) {
accessforbidden(); accessforbidden();
@ -43,8 +44,6 @@ $substitutionarrayfortest = array(
'__FIRSTNAME__' => 'TESTFirstname' '__FIRSTNAME__' => 'TESTFirstname'
); );
$action = GETPOST('action', 'aZ09');
/* /*
* Actions * Actions
@ -62,9 +61,7 @@ if ($action == 'update' && !$cancel) {
} }
/* // Send sms
* Send sms
*/
if ($action == 'send' && !$_POST['cancel']) { if ($action == 'send' && !$_POST['cancel']) {
$error = 0; $error = 0;
@ -135,6 +132,8 @@ if ($action == 'send' && !$_POST['cancel']) {
* View * View
*/ */
$form = new Form($db);
$linuxlike = 1; $linuxlike = 1;
if (preg_match('/^win/i', PHP_OS)) { if (preg_match('/^win/i', PHP_OS)) {
$linuxlike = 0; $linuxlike = 0;
@ -162,8 +161,6 @@ if (!count($listofmethods)) {
} }
if ($action == 'edit') { if ($action == 'edit') {
$form = new Form($db);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -274,30 +271,6 @@ if ($action == 'edit') {
} }
print '</div>'; print '</div>';
// Run the test to connect
/*
if ($_GET["action"] == 'testconnect')
{
print '<br>';
print load_fiche_titre($langs->trans("DoTestServerAvailability"));
// If we use SSL/TLS
if (! empty($conf->global->MAIN_MAIL_EMAIL_TLS) && function_exists('openssl_open')) $server='ssl://'.$server;
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mail = new CSMSFile('','','','');
$result=$mail->check_server_port($server,$port);
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort",$server,$port).'</div>';
else
{
print '<div class="error">'.$langs->trans("ServerNotAvailableOnIPOrPort",$server,$port);
if ($mail->error) print ' - '.$mail->error;
print '</div>';
}
print '<br>';
}*/
// Affichage formulaire de TEST simple // Affichage formulaire de TEST simple
if ($action == 'test') { if ($action == 'test') {
print '<br>'; print '<br>';
@ -308,12 +281,12 @@ if ($action == 'edit') {
$formsms = new FormSms($db); $formsms = new FormSms($db);
$formsms->fromtype = 'user'; $formsms->fromtype = 'user';
$formsms->fromid = $user->id; $formsms->fromid = $user->id;
$formsms->fromsms = (GETPOSTISSET('fromsms') ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); $formsms->fromsms = (GETPOSTISSET('fromsms') ? GETPOST('fromsms') : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile));
$formsms->withfromreadonly = 0; $formsms->withfromreadonly = 0;
$formsms->withsubstit = 0; $formsms->withsubstit = 0;
$formsms->withfrom = 1; $formsms->withfrom = 1;
$formsms->withto = (GETPOSTISSET('sendto') ? $_POST['sendto'] : ($user->user_mobile ? $user->user_mobile : 1)); $formsms->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto') : ($user->user_mobile ? $user->user_mobile : 1));
$formsms->withbody = (GETPOSTISSET('message') ? (empty($_POST['message']) ? 1 : $_POST['message']) : $langs->trans("ThisIsATestMessage")); $formsms->withbody = (GETPOSTISSET('message') ? (!GETPOST('message') ? 1 : GETPOST('message')) : $langs->trans("ThisIsATestMessage"));
$formsms->withbodyreadonly = 0; $formsms->withbodyreadonly = 0;
$formsms->withcancel = 1; $formsms->withcancel = 1;
// Tableau des substitutions // Tableau des substitutions

View File

@ -1,118 +0,0 @@
<?php
/* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/socialnetworks.php
* \ingroup socialnetworks
* \brief Page to setup the module Social Networks
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin", "errors"));
if (!$user->admin) accessforbidden();
$type = array('yesno', 'texte', 'chaine');
$action = GETPOST('action', 'aZ09');
/*
* Action
*/
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{
$code = $reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
dol_print_error($db);
}
}
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
{
$code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
dol_print_error($db);
}
}
/*
* View
*/
$help_url = '';
llxHeader('', $langs->trans("SocialNetworkSetup"), $help_url);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("SocialNetworkSetup"), $linkback, 'title_setup');
//$head = socialnetworks_admin_prepare_head();
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/admin/socialnetworks.php';
$head[$h][1] = $langs->trans("Setup");
$head[$h][2] = 'setup';
$h++;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print dol_get_fiche_head($head, 'setup', '', 0, 'user');
print '<br>';
$arrayofsocialnetworks = array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn');
foreach ($arrayofsocialnetworks as $snkey => $snlabel) {
$consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey);
if ($conf->use_javascript_ajax) {
$link = ajax_constantonoff($consttocheck);
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
$link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck);
}
print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>';
}
print dol_get_fiche_end();
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@ -45,15 +45,15 @@ print load_fiche_titre($langs->trans("InfoDatabase"), '', 'title_setup');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n"; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Version").'</td><td>'.$db::LABEL.' '.$db->getVersion().'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("Version").'</td><td>'.$db::LABEL.' '.$db->getVersion().'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port) ? $langs->trans("Default") : $conf->db->port).'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port) ? $langs->trans("Default") : $conf->db->port).'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DriverType").'</td><td>'.$conf->db->type.($db->getDriverInfo() ? ' ('.$db->getDriverInfo().')' : '').'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("DriverType").'</td><td>'.$conf->db->type.($db->getDriverInfo() ? ' ('.$db->getDriverInfo().')' : '').'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("User").'</td><td>'.$conf->db->user.'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("User").'</td><td>'.$conf->db->user.'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase().'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase().'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>'.$db->getDefaultCollationDatabase().'</td></tr>'."\n"; print '<tr class="oddeven"><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>'.$db->getDefaultCollationDatabase().'</td></tr>'."\n";
print '</table>'; print '</table>';
print '</div>'; print '</div>';
@ -62,7 +62,7 @@ print '<br>';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Tables").'</td></tr>'."\n"; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Tables").'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300"><a href="'.DOL_URL_ROOT.'/admin/system/database-tables.php?mainmenu=home">'.$langs->trans("List").'</a></td></tr>'."\n"; print '<tr class="oddeven"><td width="300"><a href="'.DOL_URL_ROOT.'/admin/system/database-tables.php?mainmenu=home">'.$langs->trans("List").'</a></td></tr>'."\n";
print '</table>'; print '</table>';
print '</div>'; print '</div>';
@ -104,7 +104,7 @@ if (!count($listofvars) && !count($listofstatus))
print '<td>'; print '<td>';
print $param; print $param;
print '</td>'; print '</td>';
print '<td>'; print '<td class="wordbreak">';
$show = 0; $text = ''; $show = 0; $text = '';
foreach ($arraytest as $key => $val) foreach ($arraytest as $key => $val)
{ {

View File

@ -44,10 +44,13 @@ $type = 'ticket';
$error = 0; $error = 0;
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') { if ($action == 'updateMask') {
$maskconstticket = GETPOST('maskconstticket', 'alpha'); $maskconstticket = GETPOST('maskconstticket', 'alpha');
$maskticket = GETPOST('maskticket', 'alpha'); $maskticket = GETPOST('maskticket', 'alpha');
@ -66,7 +69,37 @@ if ($action == 'updateMask') {
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setmod') { }
// Activate a model
elseif ($action == 'set') {
$ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') {
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($conf->global->TICKET_ADDON_PDF == "$value") dolibarr_del_const($db, 'TICKET_ADDON_PDF', $conf->entity);
}
}
// Set default model
elseif ($action == 'setdoc') {
if (dolibarr_set_const($db, "TICKET_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that was read before the new set
// We therefore requires a variable to have a coherent view
$conf->global->TICKET_ADDON_PDF = $value;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
elseif ($action == 'setmod') {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
@ -190,7 +223,7 @@ print dol_get_fiche_end();
/* /*
* Projects Numbering model * Tickets numbering model
*/ */
print load_fiche_titre($langs->trans("TicketNumberingModules"), '', ''); print load_fiche_titre($langs->trans("TicketNumberingModules"), '', '');
@ -291,6 +324,162 @@ print '</table>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
/*
* Document templates generators
*/
print load_fiche_titre($langs->trans("TicketsModelModule"), '', '');
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
}
} else {
dol_print_error($db);
}
print '<div class="div-table-responsive-no-min">';
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/ticket".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified)
{
print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
print '</td>';
// Active
if (in_array($name, $def))
{
print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
} else {
print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
// Default
print '<td class="center">';
if ($conf->global->TICKET_ADDON_PDF == $name)
{
print img_picto($langs->trans("Default"), 'on');
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
//$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
//$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
//$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
// Preview
print '<td class="center">';
if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
}
print '</td>';
print "</tr>\n";
}
}
}
}
}
}
}
}
print '</table>';
print '</div><br>';
if (!$conf->use_javascript_ajax) { if (!$conf->use_javascript_ajax) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';

View File

@ -91,7 +91,7 @@ print '<table class="border centpercent">';
print '<tr class="border"><td style="padding: 4px">'; print '<tr class="border"><td style="padding: 4px">';
if (!empty($conf->syslog->enabled)) { if (!empty($conf->syslog->enabled)) {
print '<input type="radio" name="choice" value="logfile"'; print '<input type="radio" name="choice" id="choicelogfile" value="logfile"';
print ($choice && $choice == 'logfile') ? ' checked' : ''; print ($choice && $choice == 'logfile') ? ' checked' : '';
$filelogparam = $filelog; $filelogparam = $filelog;
if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) { if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) {
@ -101,17 +101,17 @@ if (!empty($conf->syslog->enabled)) {
} }
$desc = $langs->trans("PurgeDeleteLogFile", '{filelogparam}'); $desc = $langs->trans("PurgeDeleteLogFile", '{filelogparam}');
$desc = str_replace('{filelogparam}', $filelogparam, $desc); $desc = str_replace('{filelogparam}', $filelogparam, $desc);
print '> '.$desc; print '> <label for="choicelogfile">'.$desc.'</label>';
print '<br><br>'; print '<br><br>';
} }
print '<input type="radio" name="choice" value="tempfiles"'; print '<input type="radio" name="choice" id="choicetempfiles" value="tempfiles"';
print (!$choice || $choice == 'tempfiles' || $choice == 'allfiles') ? ' checked' : ''; print (!$choice || $choice == 'tempfiles' || $choice == 'allfiles') ? ' checked' : '';
print '> '.$langs->trans("PurgeDeleteTemporaryFiles").'<br><br>'; print '> <label for="choicetempfiles">'.$langs->trans("PurgeDeleteTemporaryFiles").'</label><br><br>';
print '<input type="radio" name="choice" value="confirm_allfiles"'; print '<input type="radio" name="choice" id="choiceallfiles" value="confirm_allfiles"';
print ($choice && $choice == 'confirm_allfiles') ? ' checked' : ''; print ($choice && $choice == 'confirm_allfiles') ? ' checked' : '';
print '> '.$langs->trans("PurgeDeleteAllFilesInDocumentsDir", $dolibarr_main_data_root).'<br>'; print '> <label for="choiceallfiles">'.$langs->trans("PurgeDeleteAllFilesInDocumentsDir", $dolibarr_main_data_root).'</label><br>';
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -190,7 +190,7 @@ $formadmin = new FormAdmin($db);
$wikihelp = 'EN:Setup Translation|FR:Paramétrage traduction|ES:Configuración'; $wikihelp = 'EN:Setup Translation|FR:Paramétrage traduction|ES:Configuración';
llxHeader('', $langs->trans("Setup"), $wikihelp); llxHeader('', $langs->trans("Setup"), $wikihelp);
$param = '&mode='.$mode; $param = '&mode='.urlencode($mode);
$enabledisablehtml = ''; $enabledisablehtml = '';
$enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' '; $enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' ';
@ -246,7 +246,7 @@ if ($mode == 'overwrite')
print '<div class="justify"><span class="opacitymedium">'; print '<div class="justify"><span class="opacitymedium">';
print img_info().' '.$langs->trans("SomeTranslationAreUncomplete"); print img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
$urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation'; $urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation';
print ' ('.$langs->trans("SeeAlso", '<a href="'.$urlwikitranslatordoc.'" target="_blank">'.$langs->trans("Here").'</a>').')<br>'; print ' ('.str_replace('{s1}', '<a href="'.$urlwikitranslatordoc.'" target="_blank">'.$langs->trans("Here").'</a>', $langs->trans("SeeAlso", '{s1}')).')<br>';
print $langs->trans("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("Key"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n"; print $langs->trans("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("Key"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n"; print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
print '</span></div>'; print '</span></div>';
@ -338,16 +338,15 @@ if ($mode == 'overwrite')
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) {
{
print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">'; print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">';
print '<input type="submit" class="button buttongen button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; print '<input type="submit" class="button buttongen button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; '; print ' &nbsp; ';
print '<input type="submit" class="button buttongen button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; print '<input type="submit" class="button buttongen button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
} else { } else {
print '<a class="reposition editfielda paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=edit'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>'; print '<a class="reposition editfielda paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.urlencode($mode).'&action=edit'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
print ' &nbsp; '; print ' &nbsp; ';
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>'; print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
} }
print '</td>'; print '</td>';
@ -493,14 +492,12 @@ if ($mode == 'searchkey')
print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td>'; print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td>';
print dol_escape_htmltag($val); print dol_escape_htmltag($val);
print '</td><td class="right nowraponall">'; print '</td><td class="right nowraponall">';
if (!empty($newlangfileonly->tab_translate[$key])) if (!empty($newlangfileonly->tab_translate[$key])) {
{ if ($val != $newlangfileonly->tab_translate[$key]) {
if ($val != $newlangfileonly->tab_translate[$key])
{
// retrieve rowid // retrieve rowid
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
$sql .= " WHERE transkey = '".$key."'"; $sql .= " WHERE transkey = '".$db->escape($key)."'";
$sql .= " AND entity IN (".getEntity('overwrite_trans').")"; $sql .= " AND entity IN (".getEntity('overwrite_trans').")";
dol_syslog("translation::select from table", LOG_DEBUG); dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
@ -508,16 +505,15 @@ if ($mode == 'searchkey')
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
} }
print '<a class="editfielda reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=edit">'.img_edit().'</a>'; print '<a class="editfielda reposition marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode=overwrite&action=edit">'.img_edit().'</a>';
print ' '; print ' ';
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=delete&token='.newToken().'">'.img_delete().'</a>'; print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode='.urlencode($mode).'&action=delete&mode='.urlencode($mode).'&token='.newToken().'">'.img_delete().'</a>';
print '&nbsp;&nbsp;'; print '&nbsp;&nbsp;';
$htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>'); $htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>');
print $form->textwithpicto('', $htmltext, 1, 'info'); print $form->textwithpicto('', $htmltext, 1, 'info');
} elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) } elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) {
{
//print $key.'-'.$val; //print $key.'-'.$val;
print '<a class="reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=overwrite&amp;langcode='.$langcode.'&amp;transkey='.$key.'">'.img_edit_add($langs->trans("Overwrite")).'</a>'; print '<a class="reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=overwrite&langcode='.urlencode($langcode).'&transkey='.urlencode($key).'">'.img_edit_add($langs->trans("Overwrite")).'</a>';
} }
if (!empty($conf->global->MAIN_FEATURES_LEVEL)) if (!empty($conf->global->MAIN_FEATURES_LEVEL))

View File

@ -167,7 +167,13 @@ class DolibarrApi
unset($object->libelle_statut); unset($object->libelle_statut);
unset($object->libelle_paiement); unset($object->libelle_paiement);
if ($object->table_element != 'ticket') { unset($object->prefix_comm);
unset($object->sendtoid);
unset($object->name_bis);
unset($object->newref);
if (!isset($object->table_element) || $object->table_element != 'ticket') {
unset($object->comments); unset($object->comments);
} }

View File

@ -535,13 +535,14 @@ class Documents extends DolibarrApi
* Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }. * Test sample for medias file: { "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 $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 $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 $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 $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)
* @param int $overwriteifexists Overwrite file if exists (1 by default) * @param int $overwriteifexists Overwrite file if exists (1 by default)
* @param int $createdirifnotexists Create subdirectories if the doesn't exists (1 by default)
* @return string * @return string
* *
* @throws RestException 400 * @throws RestException 400
@ -551,7 +552,7 @@ class Documents extends DolibarrApi
* *
* @url POST /upload * @url POST /upload
*/ */
public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0) public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0, $createdirifnotexists = 1)
{ {
global $db, $conf; global $db, $conf;
@ -578,6 +579,8 @@ class Documents extends DolibarrApi
// Define $uploadir // Define $uploadir
$object = null; $object = null;
$entity = DolibarrApiAccess::$user->entity; $entity = DolibarrApiAccess::$user->entity;
if (empty($entity)) $entity = 1;
if ($ref) if ($ref)
{ {
$tmpreldir = ''; $tmpreldir = '';
@ -663,8 +666,7 @@ class Documents extends DolibarrApi
} }
} }
if (!($object->id > 0)) if (!($object->id > 0)) {
{
throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found."); throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found.");
} }
@ -681,29 +683,32 @@ class Documents extends DolibarrApi
if (empty($upload_dir) || $upload_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.'); throw new RestException(500, 'This value of modulepart ('.$modulepart.') does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
} }
} else { } else {
if ($modulepart == 'invoice') $modulepart = 'facture'; if ($modulepart == 'invoice') $modulepart = 'facture';
if ($modulepart == 'member') $modulepart = 'adherent'; if ($modulepart == 'member') $modulepart = 'adherent';
$relativefile = $subdir; $relativefile = $subdir;
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write'); $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 $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 == '/') if (empty($upload_dir) || $upload_dir == '/') {
{ if (!empty($tmp['error'])) {
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.'); throw new RestException(401, 'Error returned by dol_check_secure_access_document: '.$tmp['error']);
} else {
throw new RestException(500, 'This value of modulepart ('.$modulepart.') is not allowed with this value of subdir ('.$relativefile.')');
}
} }
} }
// $original_file here is still value of filename without any dir. // $original_file here is still value of filename without any dir.
$upload_dir = dol_sanitizePathName($upload_dir); $upload_dir = dol_sanitizePathName($upload_dir);
if (dol_mkdir($upload_dir) < 0) // needed by products if (!empty($createdirifnotexists)) {
{ if (dol_mkdir($upload_dir) < 0) { // needed by products
throw new RestException(500, 'Error while trying to create directory.'); throw new RestException(500, 'Error while trying to create directory '.$upload_dir);
}
} }
$destfile = $upload_dir.'/'.$original_file; $destfile = $upload_dir.'/'.$original_file;
@ -715,8 +720,7 @@ class Documents extends DolibarrApi
throw new RestException(401, 'Directory not exists : '.dirname($destfile)); throw new RestException(401, 'Directory not exists : '.dirname($destfile));
} }
if (!$overwriteifexists && dol_is_file($destfile)) if (!$overwriteifexists && dol_is_file($destfile)) {
{
throw new RestException(500, "File with name '".$original_file."' already exists."); throw new RestException(500, "File with name '".$original_file."' already exists.");
} }

View File

@ -48,8 +48,8 @@ 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) * @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 * @return array Response status and user token
* *
* @throws RestException 403 * @throws RestException 403 Access denied
* @throws RestException 500 * @throws RestException 500 System error
* *
* @url GET / * @url GET /
* @url POST / * @url POST /
@ -109,7 +109,7 @@ class Login
} }
// Generate token for user // Generate token for user
$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1); $token = dol_hash($login.uniqid().(empty($conf->global->MAIN_API_KEY)?'':$conf->global->MAIN_API_KEY), 1);
// We store API token into database // We store API token into database
$sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql = "UPDATE ".MAIN_DB_PREFIX."user";
@ -132,7 +132,7 @@ class Login
'code' => 200, 'code' => 200,
'token' => $token, 'token' => $token,
'entity' => $tmpuser->entity, 'entity' => $tmpuser->entity,
'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (recorded for your user). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
) )
); );
} }

View File

@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/cstate.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/cstate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
/** /**
* API class for dictionaries * API class for dictionaries
* *
@ -74,10 +75,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -111,70 +110,68 @@ class Setup extends DolibarrApi
return $list; return $list;
} }
/** /**
* Get the list of ordering origins. * Get the list of ordering origins.
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Number of items per page * @param int $limit Number of items per page
* @param int $page Page number {@min 0} * @param int $page Page number {@min 0}
* @param int $active Payment type is active or not {@min 0} {@max 1} * @param int $active Payment type is active or not {@min 0} {@max 1}
* @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')"
* *
* @url GET dictionary/ordering_origins * @url GET dictionary/ordering_origins
* *
* @return array [List of ordering reasons] * @return array [List of ordering reasons]
* *
* @throws RestException 400 * @throws RestException 400
*/ */
public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
if (!DolibarrApiAccess::$user->rights->commande->lire) { if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT rowid, code, label, module"; $sql = "SELECT rowid, code, label, module";
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters)) throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
{ }
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
} $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; }
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) { if ($page < 0) {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset); $sql .= $this->db->plimit($limit, $offset);
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) { for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result); $list[] = $this->db->fetch_object($result);
} }
} else { } else {
throw new RestException(400, $this->db->lasterror()); throw new RestException(400, $this->db->lasterror());
} }
return $list; return $list;
} }
/** /**
* Get the list of payments types. * Get the list of payments types.
@ -205,10 +202,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_paiement').")"; $sql .= " WHERE t.entity IN (".getEntity('c_paiement').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -271,10 +266,8 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t";
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -373,10 +366,8 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -439,7 +430,7 @@ class Setup extends DolibarrApi
/** /**
* Get country by Code. * Get country by Code.
* *
* @param string $code Code of country * @param string $code Code of country (2 characters)
* @param string $lang Code of the language the name of the * @param string $lang Code of the language the name of the
* country must be translated to * country must be translated to
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
@ -456,7 +447,7 @@ class Setup extends DolibarrApi
/** /**
* Get country by Iso. * Get country by Iso.
* *
* @param string $iso ISO of country * @param string $iso ISO of country (3 characters)
* @param string $lang Code of the language the name of the * @param string $lang Code of the language the name of the
* country must be translated to * country must be translated to
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
@ -497,8 +488,8 @@ class Setup extends DolibarrApi
* Get country. * Get country.
* *
* @param int $id ID of country * @param int $id ID of country
* @param string $code Code of country * @param string $code Code of country (2 characters)
* @param string $iso ISO of country * @param string $iso ISO of country (3 characters)
* @param string $lang Code of the language the name of the * @param string $lang Code of the language the name of the
* country must be translated to * country must be translated to
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
@ -510,10 +501,11 @@ class Setup extends DolibarrApi
$country = new Ccountry($this->db); $country = new Ccountry($this->db);
$result = $country->fetch($id, $code, $iso); $result = $country->fetch($id, $code, $iso);
if ($result < 0) { if ($result < 0) {
throw new RestException(503, 'Error when retrieving country : '.$country->error); throw new RestException(503, 'Error when retrieving country : '.$country->error);
} elseif ($result == 0) { } elseif ($result == 0) {
throw new RestException(404, 'country not found'); throw new RestException(404, 'Country not found');
} }
$this->translateLabel($country, $lang, 'Country'); $this->translateLabel($country, $lang, 'Country');
@ -549,10 +541,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -657,10 +647,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -718,13 +706,15 @@ class Setup extends DolibarrApi
$sql = "SELECT id, code, type, libelle as label, module"; $sql = "SELECT id, code, type, libelle as label, module";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; if ($type) {
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
}
if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -782,12 +772,12 @@ class Setup extends DolibarrApi
$sql = "SELECT id, code, label, accountancy_code, active, module, position"; $sql = "SELECT id, code, label, accountancy_code, active, module, position";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -846,13 +836,15 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid, code, element as type, libelle as label, source, module, position"; $sql = "SELECT rowid, code, element as type, libelle as label, source, module, position";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($type) $sql .= " AND type LIKE '%".$this->db->escape($type)."%'"; if ($type) {
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; $sql .= " AND type LIKE '%".$this->db->escape($type)."%'";
}
if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -909,12 +901,12 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid, code, label, module"; $sql = "SELECT rowid, code, label, module";
$sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -968,7 +960,9 @@ class Setup extends DolibarrApi
{ {
$list = array(); $list = array();
$sql = "SELECT t.code_iso, t.label, t.unicode"; $sql = "SELECT t.code_iso, t.label, t.unicode";
if (!empty($multicurrency)) $sql .= " , cr.date_sync, cr.rate "; if (!empty($multicurrency)) {
$sql .= " , cr.date_sync, cr.rate ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t";
if (!empty($multicurrency)) { if (!empty($multicurrency)) {
$sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso"; $sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso";
@ -983,10 +977,8 @@ class Setup extends DolibarrApi
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1041,18 +1033,22 @@ class Setup extends DolibarrApi
throw new RestException(401, 'Only an admin user can get list of extrafields'); throw new RestException(401, 'Only an admin user can get list of extrafields');
} }
if ($type == 'thirdparty') $type = 'societe'; if ($type == 'thirdparty') {
if ($type == 'contact') $type = 'socpeople'; $type = 'societe';
}
if ($type == 'contact') {
$type = 'socpeople';
}
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed"; $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed";
$sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t"; $sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t";
$sql .= " WHERE t.entity IN (".getEntity('extrafields').")"; $sql .= " WHERE t.entity IN (".getEntity('extrafields').")";
if (!empty($type)) $sql .= " AND t.elementtype = '".$this->db->escape($type)."'"; if (!empty($type)) {
$sql .= " AND t.elementtype = '".$this->db->escape($type)."'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1062,12 +1058,9 @@ class Setup extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->num_rows($resql)) {
if ($this->db->num_rows($resql)) while ($tab = $this->db->fetch_object($resql)) {
{
while ($tab = $this->db->fetch_object($resql))
{
// New usage // New usage
$list[$tab->elementtype][$tab->name]['type'] = $tab->type; $list[$tab->elementtype][$tab->name]['type'] = $tab->type;
$list[$tab->elementtype][$tab->name]['label'] = $tab->label; $list[$tab->elementtype][$tab->name]['label'] = $tab->label;
@ -1088,8 +1081,7 @@ class Setup extends DolibarrApi
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
} }
if (!count($list)) if (!count($list)) {
{
throw new RestException(404, 'No extrafield found'); throw new RestException(404, 'No extrafield found');
} }
@ -1121,13 +1113,15 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
if ($zipcode) $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'"; if ($zipcode) {
if ($town) $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'"; $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'";
}
if ($town) {
$sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1190,10 +1184,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")"; $sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1250,10 +1242,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")"; $sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1305,15 +1295,14 @@ class Setup extends DolibarrApi
public function getListOfMeasuringUnits($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getListOfMeasuringUnits($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
//TODO link with multicurrency module //TODO link with multicurrency module
$sql = "SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type"; $sql = "SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
$sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1377,10 +1366,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")"; $sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1437,10 +1424,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1497,10 +1482,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1559,10 +1542,8 @@ class Setup extends DolibarrApi
// if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; // if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
// if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; // if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1601,21 +1582,58 @@ class Setup extends DolibarrApi
* *
* @url GET /company * @url GET /company
* *
* @return array|mixed Data without useless information * @return array|mixed Mysoc object
* *
* @throws RestException 403 Forbidden
*/ */
public function getCompany() public function getCompany()
{ {
global $mysoc; global $conf, $mysoc;
if (!DolibarrApiAccess::$user->admin
&& (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_COMPANY');
}
unset($mysoc->skype); unset($mysoc->skype);
unset($mysoc->twitter); unset($mysoc->twitter);
unset($mysoc->facebook); unset($mysoc->facebook);
unset($mysoc->linkedin); unset($mysoc->linkedin);
unset($mysoc->pays);
unset($mysoc->note); unset($mysoc->note);
unset($mysoc->nom);
unset($mysoc->lines); unset($mysoc->lines);
unset($mysoc->effectif);
unset($mysoc->effectif_id);
unset($mysoc->forme_juridique_code);
unset($mysoc->forme_juridique);
unset($mysoc->mode_reglement_supplier_id);
unset($mysoc->cond_reglement_supplier_id);
unset($mysoc->transport_mode_supplier_id);
unset($mysoc->fk_prospectlevel);
unset($mysoc->total_ht);
unset($mysoc->total_tva);
unset($mysoc->total_localtax1);
unset($mysoc->total_localtax2);
unset($mysoc->total_ttc);
unset($mysoc->lastname);
unset($mysoc->firstname);
unset($mysoc->civility_id);
unset($mysoc->client);
unset($mysoc->prospect);
unset($mysoc->fournisseur);
unset($mysoc->contact_id);
unset($mysoc->fk_incoterms);
unset($mysoc->label_incoterms);
unset($mysoc->location_incoterms);
return $this->_cleanObjectDatas($mysoc); return $this->_cleanObjectDatas($mysoc);
} }
@ -1660,6 +1678,7 @@ class Setup extends DolibarrApi
* *
* @url GET checkintegrity * @url GET checkintegrity
* *
* @throws RestException 403 Forbidden
* @throws RestException 404 Signature file not found * @throws RestException 404 Signature file not found
* @throws RestException 500 Technical error * @throws RestException 500 Technical error
* @throws RestException 503 Forbidden * @throws RestException 503 Forbidden
@ -1669,9 +1688,8 @@ class Setup extends DolibarrApi
global $langs, $conf; global $langs, $conf;
if (!DolibarrApiAccess::$user->admin if (!DolibarrApiAccess::$user->admin
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) && (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) {
{ throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK');
throw new RestException(503, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK');
} }
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -1690,15 +1708,19 @@ class Setup extends DolibarrApi
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
// Remote file to compare to // Remote file to compare to
$xmlremote = ($target == 'default' ? '' : $target); $xmlremote = ($target == 'default' ? '' : $target);
if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
$xmlremote = $conf->global->MAIN_FILECHECK_URL;
}
$param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; $param = 'MAIN_FILECHECK_URL_'.DOL_VERSION;
if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param; if (empty($xmlremote) && !empty($conf->global->$param)) {
if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; $xmlremote = $conf->global->$param;
}
if (empty($xmlremote)) {
$xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
}
if ($target == 'local') if ($target == 'local') {
{ if (dol_is_file($xmlfile)) {
if (dol_is_file($xmlfile))
{
$xml = simplexml_load_file($xmlfile); $xml = simplexml_load_file($xmlfile);
} else { } else {
throw new RestException(500, $langs->trans('XmlNotFound').': '.$xmlfile); throw new RestException(500, $langs->trans('XmlNotFound').': '.$xmlfile);
@ -1707,8 +1729,7 @@ class Setup extends DolibarrApi
$xmlarray = getURLContent($xmlremote); $xmlarray = getURLContent($xmlremote);
// Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') {
{
$xmlfile = $xmlarray['content']; $xmlfile = $xmlarray['content'];
//print "xmlfilestart".$xmlfile."endxmlfile"; //print "xmlfilestart".$xmlfile."endxmlfile";
$xml = simplexml_load_string($xmlfile); $xml = simplexml_load_string($xmlfile);
@ -1718,17 +1739,13 @@ class Setup extends DolibarrApi
} }
} }
if ($xml) {
if ($xml)
{
$checksumconcat = array(); $checksumconcat = array();
$file_list = array(); $file_list = array();
$out = ''; $out = '';
// Forced constants // Forced constants
if (is_object($xml->dolibarr_constants[0])) if (is_object($xml->dolibarr_constants[0])) {
{
$out .= load_fiche_titre($langs->trans("ForcedConstants")); $out .= load_fiche_titre($langs->trans("ForcedConstants"));
$out .= '<div class="div-table-responsive-no-min">'; $out .= '<div class="div-table-responsive-no-min">';
@ -1741,14 +1758,15 @@ class Setup extends DolibarrApi
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$i = 0; $i = 0;
foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement foreach ($xml->dolibarr_constants[0]->constant as $constant) { // $constant is a simpleXMLElement
{
$constname = $constant['name']; $constname = $constant['name'];
$constvalue = (string) $constant; $constvalue = (string) $constant;
$constvalue = (empty($constvalue) ? '0' : $constvalue); $constvalue = (empty($constvalue) ? '0' : $constvalue);
// Value found // Value found
$value = ''; $value = '';
if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; if ($constname && $conf->global->$constname != '') {
$value = $conf->global->$constname;
}
$valueforchecksum = (empty($value) ? '0' : $value); $valueforchecksum = (empty($value) ? '0' : $value);
$checksumconcat[] = $valueforchecksum; $checksumconcat[] = $valueforchecksum;
@ -1762,8 +1780,7 @@ class Setup extends DolibarrApi
$out .= "</tr>\n"; $out .= "</tr>\n";
} }
if ($i == 0) if ($i == 0) {
{
$out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; $out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
$out .= '</table>'; $out .= '</table>';
@ -1773,9 +1790,7 @@ class Setup extends DolibarrApi
} }
// Scan htdocs // Scan htdocs
if (is_object($xml->dolibarr_htdocs_dir[0])) if (is_object($xml->dolibarr_htdocs_dir[0])) {
{
//var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit;
$includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']);
// Defined qualified files (must be same than into generate_filelist_xml.php) // Defined qualified files (must be same than into generate_filelist_xml.php)
@ -1786,11 +1801,9 @@ class Setup extends DolibarrApi
// Fill file_list with files in signature, new files, modified files // Fill file_list with files in signature, new files, modified files
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list
// Complete with list of new files // Complete with list of new files
foreach ($scanfiles as $keyfile => $valfile) foreach ($scanfiles as $keyfile => $valfile) {
{
$tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
if (!in_array($tmprelativefilename, $file_list['insignature'])) if (!in_array($tmprelativefilename, $file_list['insignature'])) {
{
$md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file
$file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
} }
@ -1807,11 +1820,9 @@ class Setup extends DolibarrApi
$out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>'; $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>';
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); $tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
if (is_array($tmpfilelist) && count($tmpfilelist)) if (is_array($tmpfilelist) && count($tmpfilelist)) {
{
$i = 0; $i = 0;
foreach ($tmpfilelist as $file) foreach ($tmpfilelist as $file) {
{
$i++; $i++;
$out .= '<tr class="oddeven">'; $out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n"; $out .= '<td>'.$i.'</td>'."\n";
@ -1842,11 +1853,9 @@ class Setup extends DolibarrApi
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>'; $out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
if (is_array($tmpfilelist2) && count($tmpfilelist2)) if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
{
$i = 0; $i = 0;
foreach ($tmpfilelist2 as $file) foreach ($tmpfilelist2 as $file) {
{
$i++; $i++;
$out .= '<tr class="oddeven">'; $out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n"; $out .= '<td>'.$i.'</td>'."\n";
@ -1890,11 +1899,9 @@ class Setup extends DolibarrApi
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>'; $out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename');
if (is_array($tmpfilelist3) && count($tmpfilelist3)) if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
{
$i = 0; $i = 0;
foreach ($tmpfilelist3 as $file) foreach ($tmpfilelist3 as $file) {
{
$i++; $i++;
$out .= '<tr class="oddeven">'; $out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n"; $out .= '<td>'.$i.'</td>'."\n";
@ -1923,8 +1930,7 @@ class Setup extends DolibarrApi
// Show warning // Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
{
//setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); //setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
} else { } else {
//setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); //setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
@ -1935,18 +1941,13 @@ class Setup extends DolibarrApi
// Scan scripts // Scan scripts
asort($checksumconcat); // Sort list of checksum asort($checksumconcat); // Sort list of checksum
//var_dump($checksumconcat);
$checksumget = md5(join(',', $checksumconcat)); $checksumget = md5(join(',', $checksumconcat));
$checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum);
$outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown"));
if ($checksumget == $checksumtoget) if ($checksumget == $checksumtoget) {
{ if (count($file_list['added'])) {
if (count($file_list['added']))
{
$resultcode = 'warning'; $resultcode = 'warning';
$resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; $resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
//$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>'; //$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>';
@ -1969,4 +1970,28 @@ class Setup extends DolibarrApi
return array('resultcode'=>$resultcode, 'resultcomment'=>$resultcomment, 'expectedchecksum'=> $outexpectedchecksum, 'currentchecksum'=> $outcurrentchecksum, 'out'=>$out); return array('resultcode'=>$resultcode, 'resultcomment'=>$resultcomment, 'expectedchecksum'=> $outexpectedchecksum, 'currentchecksum'=> $outcurrentchecksum, 'out'=>$out);
} }
/**
* Get list of enabled modules
*
* @url GET /modules
*
* @return array|mixed Data without useless information
*
* @throws RestException 403 Forbidden
*/
public function getModules()
{
global $conf;
if (!DolibarrApiAccess::$user->admin
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) {
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_GET_MODULES');
}
sort($conf->modules);
return $this->_cleanObjectDatas($conf->modules);
}
} }

View File

@ -28,20 +28,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
if ($action == 'setvalue') if ($action == 'setvalue') {
{
$showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha'); $showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha');
$res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU", $showmenu, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU", $showmenu, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {

View File

@ -38,20 +38,23 @@ function printDropdownBookmarksList()
$url = $_SERVER["PHP_SELF"]; $url = $_SERVER["PHP_SELF"];
if (!empty($_SERVER["QUERY_STRING"])) if (!empty($_SERVER["QUERY_STRING"])) {
{
$url .= (dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''); $url .= (dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '');
} else { } else {
global $sortfield, $sortorder; global $sortfield, $sortorder;
$tmpurl = ''; $tmpurl = '';
// No urlencode, all param $url will be urlencoded later // No urlencode, all param $url will be urlencoded later
if ($sortfield) $tmpurl .= ($tmpurl ? '&' : '').'sortfield='.$sortfield; if ($sortfield) {
if ($sortorder) $tmpurl .= ($tmpurl ? '&' : '').'sortorder='.$sortorder; $tmpurl .= ($tmpurl ? '&' : '').'sortfield='.$sortfield;
if (is_array($_POST)) }
{ if ($sortorder) {
foreach ($_POST as $key => $val) $tmpurl .= ($tmpurl ? '&' : '').'sortorder='.$sortorder;
{ }
if (preg_match('/^search_/', $key) && $val != '') $tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val; if (is_array($_POST)) {
foreach ($_POST as $key => $val) {
if (preg_match('/^search_/', $key) && $val != '') {
$tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val;
}
} }
} }
$url .= ($tmpurl ? '?'.$tmpurl : ''); $url .= ($tmpurl ? '?'.$tmpurl : '');
@ -68,8 +71,7 @@ function printDropdownBookmarksList()
// Url to go on create new bookmark page // Url to go on create new bookmark page
$newbtn = ''; $newbtn = '';
if (!empty($user->rights->bookmark->creer)) if (!empty($user->rights->bookmark->creer)) {
{
//$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url); //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url);
$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
$newbtn .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >'; $newbtn .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >';
@ -81,13 +83,11 @@ function printDropdownBookmarksList()
$sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)"; $sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
$sql .= " AND entity IN (".getEntity('bookmarks').")"; $sql .= " AND entity IN (".getEntity('bookmarks').")";
$sql .= " ORDER BY position"; $sql .= " ORDER BY position";
if ($resql = $db->query($sql)) if ($resql = $db->query($sql)) {
{
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$bookmarkList = '<div id="dropdown-bookmarks-list" >'; $bookmarkList = '<div id="dropdown-bookmarks-list" >';
$i = 0; $i = 0;
while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {
{
$bookmarkList .= '<a class="dropdown-item bookmark-item'.(strpos($obj->url, 'http') === 0 ? ' bookmark-item-external' : '').'" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' href="'.dol_escape_htmltag($obj->url).'" >'; $bookmarkList .= '<a class="dropdown-item bookmark-item'.(strpos($obj->url, 'http') === 0 ? ' bookmark-item-external' : '').'" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' href="'.dol_escape_htmltag($obj->url).'" >';
$bookmarkList .= dol_escape_htmltag($obj->title); $bookmarkList .= dol_escape_htmltag($obj->title);
$bookmarkList .= '</a>'; $bookmarkList .= '</a>';
@ -104,15 +104,13 @@ function printDropdownBookmarksList()
$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">'; $searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">';
$searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>'; $searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>';
// Url to go on create new bookmark page // Url to go on create new bookmark page
if (!empty($user->rights->bookmark->creer)) if (!empty($user->rights->bookmark->creer)) {
{
$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
$searchForm .= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"'; $searchForm .= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"';
$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>'; $searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>';
} }
$i = 0; $i = 0;
while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {
{
$searchForm .= '<option name="bookmark'.$obj->rowid.'" value="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' rel="'.dol_escape_htmltag($obj->url).'" >'; $searchForm .= '<option name="bookmark'.$obj->rowid.'" value="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' rel="'.dol_escape_htmltag($obj->url).'" >';
$searchForm .= dol_escape_htmltag($obj->title); $searchForm .= dol_escape_htmltag($obj->title);
$searchForm .= '</option>'; $searchForm .= '</option>';
@ -132,74 +130,74 @@ function printDropdownBookmarksList()
$html .= '<!-- script to open selected choice --> $html .= '<!-- script to open selected choice -->
<script> <script>
$(document).ready(function () { $(document).ready(function () {
jQuery("#boxbookmark").change(function() { jQuery("#boxbookmark").change(function() {
var urlselected = jQuery("#boxbookmark option:selected").attr("rel"); var urlselected = jQuery("#boxbookmark option:selected").attr("rel");
if (! urlselected) console.log("Error, failed to get the URL to jump to from the rel attribute"); if (! urlselected) console.log("Error, failed to get the URL to jump to from the rel attribute");
var urltarget = jQuery("#boxbookmark option:selected").attr("target"); var urltarget = jQuery("#boxbookmark option:selected").attr("target");
if (! urltarget) { urltarget=""; } if (! urltarget) { urltarget=""; }
jQuery("form#top-menu-action-bookmark").attr("target",urltarget); jQuery("form#top-menu-action-bookmark").attr("target",urltarget);
jQuery("form#top-menu-action-bookmark").attr("action",urlselected); jQuery("form#top-menu-action-bookmark").attr("action",urlselected);
console.log("We change select bookmark. We choose urlselected="+urlselected+" with target="+urltarget); console.log("We change select bookmark. We choose urlselected="+urlselected+" with target="+urltarget);
// Method is POST for internal link, GET for external // Method is POST for internal link, GET for external
if (urlselected.startsWith(\'http\')) if (urlselected.startsWith(\'http\'))
{ {
var newmethod=\'GET\'; var newmethod=\'GET\';
jQuery("form#top-menu-action-bookmark").attr("method", newmethod); jQuery("form#top-menu-action-bookmark").attr("method", newmethod);
console.log("We change method to newmethod="+newmethod); console.log("We change method to newmethod="+newmethod);
jQuery("form#top-menu-action-bookmark").submit(); jQuery("form#top-menu-action-bookmark").submit();
console.log("We restore method to POST"); console.log("We restore method to POST");
jQuery("form#top-menu-action-bookmark").attr("method", \'POST\'); jQuery("form#top-menu-action-bookmark").attr("method", \'POST\');
} }
else else
{ {
jQuery("form#top-menu-action-bookmark").submit(); jQuery("form#top-menu-action-bookmark").submit();
} }
}); });
}) })
</script>'; </script>';
} else { } else {
$html = ' $html = '
<!-- search input --> <!-- search input -->
<div class="dropdown-header bookmark-header"> <div class="dropdown-header bookmark-header">
' . $searchForm.' ' . $searchForm.'
</div> </div>
'; ';
$html .= ' $html .= '
<!-- Menu Body --> <!-- Menu Body -->
<div class="bookmark-body dropdown-body"> <div class="bookmark-body dropdown-body">
'.$bookmarkList.' '.$bookmarkList.'
</div> </div>
'; ';
$html .= ' $html .= '
<!-- Menu Footer--> <!-- Menu Footer-->
<div class="bookmark-footer"> <div class="bookmark-footer">
'.$newbtn.$listbtn.' '.$newbtn.$listbtn.'
<div style="clear:both;"></div> <div style="clear:both;"></div>
</div> </div>
'; ';
$html .= '<!-- script to open/close the popup --> $html .= '<!-- script to open/close the popup -->
<script> <script>
$( document ).on("keyup", "#top-bookmark-search-input", function () { $( document ).on("keyup", "#top-bookmark-search-input", function () {
var filter = $(this).val(), count = 0; var filter = $(this).val(), count = 0;
$("#dropdown-bookmarks-list .bookmark-item").each(function () { $("#dropdown-bookmarks-list .bookmark-item").each(function () {
if ($(this).text().search(new RegExp(filter, "i")) < 0) { if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).addClass("hidden-search-result"); $(this).addClass("hidden-search-result");
} else { } else {
$(this).removeClass("hidden-search-result"); $(this).removeClass("hidden-search-result");
count++; count++;
} }
}); });
$("#top-bookmark-search-filter-count").text(count); $("#top-bookmark-search-filter-count").text(count);
}); });
</script>'; </script>';
} }
return $html; return $html;

View File

@ -83,8 +83,14 @@ class Bookmark extends CommonObject
*/ */
public $title; public $title;
/**
* @var int position of bookmark
*/
public $position; public $position;
/**
* @var string favicon
*/
public $favicon; public $favicon;
@ -116,8 +122,7 @@ class Bookmark extends CommonObject
dol_syslog("Bookmark::fetch", LOG_DEBUG); dol_syslog("Bookmark::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
@ -151,7 +156,9 @@ class Bookmark extends CommonObject
// Clean parameters // Clean parameters
$this->url = trim($this->url); $this->url = trim($this->url);
$this->title = trim($this->title); $this->title = trim($this->title);
if (empty($this->position)) $this->position = 0; if (empty($this->position)) {
$this->position = 0;
}
$now = dol_now(); $now = dol_now();
@ -164,17 +171,15 @@ class Bookmark extends CommonObject
$sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").",";
$sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($now)."',";
$sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',";
$sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', ".(int) $this->position;
$sql .= ", ".$this->db->escape($conf->entity); $sql .= ", ".(int) $conf->entity;
$sql .= ")"; $sql .= ")";
dol_syslog("Bookmark::create", LOG_DEBUG); dol_syslog("Bookmark::create", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark");
if ($id > 0) if ($id > 0) {
{
$this->id = $id; $this->id = $id;
$this->db->commit(); $this->db->commit();
return $id; return $id;
@ -202,7 +207,9 @@ class Bookmark extends CommonObject
// Clean parameters // Clean parameters
$this->url = trim($this->url); $this->url = trim($this->url);
$this->title = trim($this->title); $this->title = trim($this->title);
if (empty($this->position)) $this->position = 0; if (empty($this->position)) {
$this->position = 0;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark";
$sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0");
@ -211,12 +218,11 @@ class Bookmark extends CommonObject
$sql .= " ,target = '".$this->db->escape($this->target)."'"; $sql .= " ,target = '".$this->db->escape($this->target)."'";
$sql .= " ,title = '".$this->db->escape($this->title)."'"; $sql .= " ,title = '".$this->db->escape($this->title)."'";
$sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'";
$sql .= " ,position = '".$this->db->escape($this->position)."'"; $sql .= " ,position = ".(int) $this->position;
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
dol_syslog("Bookmark::update", LOG_DEBUG); dol_syslog("Bookmark::update", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql)) {
{
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
@ -237,8 +243,7 @@ class Bookmark extends CommonObject
dol_syslog("Bookmark::remove", LOG_DEBUG); dol_syslog("Bookmark::remove", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
@ -288,7 +293,9 @@ class Bookmark extends CommonObject
{ {
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
@ -298,33 +305,40 @@ class Bookmark extends CommonObject
$url = DOL_URL_ROOT.'/bookmarks/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/bookmarks/card.php?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowBookmark"); $label = $langs->trans("ShowBookmark");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) {
if ($withpicto != 2) $result .= $this->ref; $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -332,8 +346,11 @@ class Bookmark extends CommonObject
$hookmanager->initHooks(array('mybookmarkdao')); $hookmanager->initHooks(array('mybookmarkdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint; if ($reshook > 0) {
else $result .= $hookmanager->resPrint; $result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -98,6 +98,7 @@ class Categorie extends CommonObject
8 => 'bank_line', 8 => 'bank_line',
9 => 'warehouse', 9 => 'warehouse',
10 => 'actioncomm', 10 => 'actioncomm',
11 => 'website_page'
); );
/** /**
@ -221,7 +222,6 @@ class Categorie extends CommonObject
/** /**
* @var string Category type * @var string Category type
* *
* @see Categorie::TYPE_ACCOUNT
* @see Categorie::TYPE_PRODUCT * @see Categorie::TYPE_PRODUCT
* @see Categorie::TYPE_SUPPLIER * @see Categorie::TYPE_SUPPLIER
* @see Categorie::TYPE_CUSTOMER * @see Categorie::TYPE_CUSTOMER
@ -229,9 +229,11 @@ class Categorie extends CommonObject
* @see Categorie::TYPE_CONTACT * @see Categorie::TYPE_CONTACT
* @see Categorie::TYPE_USER * @see Categorie::TYPE_USER
* @see Categorie::TYPE_PROJECT * @see Categorie::TYPE_PROJECT
* @see Categorie::TYPE_ACCOUNT
* @see Categorie::TYPE_BANK_LINE * @see Categorie::TYPE_BANK_LINE
* @see Categorie::TYPE_WAREHOUSE * @see Categorie::TYPE_WAREHOUSE
* @see Categorie::TYPE_ACTIONCOMM * @see Categorie::TYPE_ACTIONCOMM
* @see Categorie::TYPE_WEBSITE_PAGE
*/ */
public $type; public $type;
@ -312,7 +314,7 @@ class Categorie extends CommonObject
// Check parameters // Check parameters
if (empty($id) && empty($label) && empty($ref_ext)) return -1; if (empty($id) && empty($label) && empty($ref_ext)) return -1;
if (!is_numeric($type)) $type = $this->MAP_ID[$type]; if (!is_null($type) && !is_numeric($type)) $type = $this->MAP_ID[$type];
$sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext";
$sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif";
@ -1058,7 +1060,7 @@ class Categorie extends CommonObject
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
// Init $this->cats array // Init $this->cats array
$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates
if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ", t.label as label_trans, t.description as description_trans"; 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"; $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='".$this->db->escape($current_lang)."'"; 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='".$this->db->escape($current_lang)."'";

View File

@ -35,10 +35,10 @@ $langs->load("categories");
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alphanohtml'); $ref = GETPOST('ref', 'alphanohtml');
$type = GETPOST('type', 'aZ09'); // Can be int or string
$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit'); $action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit');
$confirm = GETPOST('confirm'); $confirm = GETPOST('confirm');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$socid = (int) GETPOST('socid', 'int'); $socid = (int) GETPOST('socid', 'int');
$label = (string) GETPOST('label', 'alphanohtml'); $label = (string) GETPOST('label', 'alphanohtml');
@ -56,10 +56,14 @@ if ($id == "") {
$result = restrictedArea($user, 'categorie', $id, '&category'); $result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db); $object = new Categorie($db);
if ($id > 0) { $result = $object->fetch($id, $label);
$result = $object->fetch($id); if ($result <= 0) {
dol_print_error($db, $object->error); exit;
} }
$type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
@ -74,8 +78,13 @@ $error = 0;
*/ */
if ($cancel) { if ($cancel) {
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); if ($backtopage) {
exit; header("Location: ".$backtopage);
exit;
} else {
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
exit;
}
} }
// Action mise a jour d'une categorie // Action mise a jour d'une categorie
@ -98,9 +107,15 @@ if ($action == 'update' && $user->rights->categorie->creer) {
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error && $object->update($user) > 0) { if (!$error && $object->update($user) > 0)
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); {
exit; if ($backtopage) {
header("Location: ".$backtopage);
exit;
} else {
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
exit;
}
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
@ -131,6 +146,7 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="type" value="'.$type.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(''); print dol_get_fiche_head('');

View File

@ -109,7 +109,7 @@ if (empty($nosearch)) {
foreach ($cats as $cat) foreach ($cats as $cat)
{ {
$color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #bbb"'; $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
print "\t".'<tr class="oddeven">'."\n"; print "\t".'<tr class="oddeven">'."\n";
print "\t\t<td>"; print "\t\t<td>";
@ -160,26 +160,45 @@ foreach ($fulltree as $key => $val)
$categstatic->ref = $val['label']; $categstatic->ref = $val['label'];
$categstatic->color = $val['color']; $categstatic->color = $val['color'];
$categstatic->type = $type; $categstatic->type = $type;
$li = $categstatic->getNomUrl(1, '', 60, $moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam));
$desc = dol_htmlcleanlastbr($val['description']); $desc = dol_htmlcleanlastbr($val['description']);
$counter = ''; $counter = '';
if ($conf->global->CATEGORY_SHOW_COUNTS) if ($conf->global->CATEGORY_SHOW_COUNTS)
{ {
// we need only a count of the elements, so it is enough to consume only the id's from the database // we need only a count of the elements, so it is enough to consume only the id's from the database
$elements = $categstatic->getObjectsInCateg($type, 1); $elements = $type == Categorie::TYPE_ACCOUNT
? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
: $categstatic->getObjectsInCateg($type, 1);
$counter = "<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) : '0')."</td>"; $counter = "<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) : '0')."</td>";
} }
$color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
$li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam));
$data[] = array( $entry = '<table class="nobordernopadding centpercent">';
'rowid'=>$val['rowid'], $entry .= '<tr>';
'fk_menu'=>$val['fk_parent'],
'entry'=>'<table class="nobordernopadding centpercent"><tr><td><span class="noborderoncategories"'.$color.'>'.$li.'</span></td>'.$counter. $entry .= '<td>';
'<td class="right" width="20px;"><a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.$moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam).'">'.img_view().'</a></td></tr></table>' $entry .= '<span class="noborderoncategories" '.$color.'>'.$li.'</span>';
); $entry .= '</td>';
$entry .= $counter;
$entry .= '<td class="right" width="20px;">';
$entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.$moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type).'">'.img_view().'</a>';
$entry .= '</td>';
$entry .= '<td class="right" width="20px;">';
$entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.$type.$moreparam.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type).'">'.img_edit().'</a>';
$entry .= '</td>';
$entry .= '<td class="right" width="20px;">';
$entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.$type.$moreparam.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam).'">'.img_delete().'</a>';
$entry .= '</td>';
$entry .= '</tr>';
$entry .= '</table>';
$data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
} }
@ -194,7 +213,6 @@ if (!empty($conf->use_javascript_ajax))
print '</td></tr>'; print '</td></tr>';
$nbofentries = (count($data) - 1); $nbofentries = (count($data) - 1);
if ($nbofentries > 0) if ($nbofentries > 0)
{ {
print '<tr class="pair"><td colspan="3">'; print '<tr class="pair"><td colspan="3">';

View File

@ -37,16 +37,18 @@ $langs->loadLangs(array('categories', 'sendings'));
$socid = 0; $socid = 0;
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$label = GETPOST('label', 'alpha');
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'categorie', $id, '&category'); $result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db); $object = new Categorie($db);
if (!$object->fetch($id) > 0) { $result = $object->fetch($id, $label);
dol_print_error($db); if ($result <= 0) {
exit; dol_print_error($db, $object->error); exit;
} }
$type = $object->type; $type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
@ -63,11 +65,11 @@ llxHeader('', $langs->trans('Categories'), '');
$title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
$head = categories_prepare_head($object, $type); $head = categories_prepare_head($object, $type);
print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category'); print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category');
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type);
$linkback = '<a href="'.$backtolist.'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.$backtolist.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter = ' type = '.$type; $object->next_prev_filter = ' type = '.$object->type;
$object->ref = $object->label; $object->ref = $object->label;
$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> '; $morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
$ways = $object->print_all_ways(" &gt;&gt; ", '', 1); $ways = $object->print_all_ways(" &gt;&gt; ", '', 1);

View File

@ -38,7 +38,6 @@ $langs->loadlangs(array('categories', 'bills'));
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$label = GETPOST('label', 'alpha'); $label = GETPOST('label', 'alpha');
$type = GETPOST('type');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm'); $confirm = GETPOST('confirm');
@ -52,18 +51,16 @@ if ($id == '' && $label == '')
$result = restrictedArea($user, 'categorie', $id, '&category'); $result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db); $object = new Categorie($db);
$result = $object->fetch($id, $label, $type); $result = $object->fetch($id, $label);
if ($result <= 0) { if ($result <= 0) {
dol_print_error($db, $object->error); exit; dol_print_error($db, $object->error); exit;
} }
$object->fetch_optionals();
if ($result <= 0) {
dol_print_error($db, $object->error); exit;
}
$upload_dir = $conf->categorie->multidir_output[$object->entity];
$type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
$upload_dir = $conf->categorie->multidir_output[$object->entity];
/* /*
* Actions * Actions
*/ */
@ -115,8 +112,6 @@ if ($object->id)
$title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
$head = categories_prepare_head($object, $type); $head = categories_prepare_head($object, $type);
print dol_get_fiche_head($head, 'photos', $langs->trans($title), -1, 'category'); print dol_get_fiche_head($head, 'photos', $langs->trans($title), -1, 'category');
$linkback = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>';

View File

@ -39,7 +39,6 @@ $id = GETPOST('id', 'int');
$label = GETPOST('label', 'alpha'); $label = GETPOST('label', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$type = GETPOST('type', 'aZ09');
if ($id == '' && $label == '') if ($id == '' && $label == '')
{ {
@ -51,15 +50,12 @@ if ($id == '' && $label == '')
$result = restrictedArea($user, 'categorie', $id, '&category'); $result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db); $object = new Categorie($db);
$result = $object->fetch($id, $label, $type); $result = $object->fetch($id, $label);
if ($result <= 0) {
dol_print_error($db, $object->error); exit;
}
$object->fetch_optionals();
if ($result <= 0) { if ($result <= 0) {
dol_print_error($db, $object->error); exit; dol_print_error($db, $object->error); exit;
} }
$type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
/* /*

View File

@ -38,7 +38,6 @@ $langs->load("categories");
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$label = GETPOST('label', 'alpha'); $label = GETPOST('label', 'alpha');
$type = GETPOST('type', 'aZ09');
$removeelem = GETPOST('removeelem', 'int'); $removeelem = GETPOST('removeelem', 'int');
$elemid = GETPOST('elemid', 'int'); $elemid = GETPOST('elemid', 'int');
@ -73,19 +72,12 @@ if ($id == "" && $label == "")
$result = restrictedArea($user, 'categorie', $id, '&category'); $result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db); $object = new Categorie($db);
$result = $object->fetch($id, $label, $type); $result = $object->fetch($id, $label);
if ($result <= 0) {
dol_print_error($db, $object->error); exit;
}
$object->fetch_optionals();
if ($result <= 0) { if ($result <= 0) {
dol_print_error($db, $object->error); exit; dol_print_error($db, $object->error); exit;
} }
$objecttype = $object->type; $type = $object->type;
if (is_numeric($objecttype)) $objecttype = Categorie::$MAP_ID_TO_CODE[$objecttype];
if ($type === '') $type = $objecttype;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -94,16 +86,18 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard', 'globalcard')); $hookmanager->initHooks(array('categorycard', 'globalcard'));
// Protection when type provided is not similare to type of category
if ($objecttype != $type) {
print 'Error: Value for type parameter does not match value of the type of the category with id='.$id;
exit;
}
/* /*
* Actions * Actions
*/ */
if ($confirm == 'no')
{
if ($backtopage) {
header("Location: ".$backtopage);
exit;
}
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Remove element from category // Remove element from category
@ -164,8 +158,13 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
{ {
if ($object->delete($user) >= 0) if ($object->delete($user) >= 0)
{ {
header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type); if ($backtopage) {
exit; header("Location: ".$backtopage);
exit;
} else {
header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
exit;
}
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
@ -226,9 +225,8 @@ llxHeader("", $langs->trans("Categories"), $helpurl, '', 0, 0, $arrayofjs, $arra
$title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
$head = categories_prepare_head($object, $type); $head = categories_prepare_head($object, $type);
print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category'); print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type);
$linkback = '<a href="'.$backtolist.'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.$backtolist.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter = ' type = '.$object->type; $object->next_prev_filter = ' type = '.$object->type;
@ -250,7 +248,11 @@ dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'la
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1); if ($backtopage) {
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
} else {
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
}
} }
print '<br>'; print '<br>';
@ -294,7 +296,7 @@ if ($user->rights->categorie->creer)
if ($user->rights->categorie->supprimer) if ($user->rights->categorie->supprimer)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.$type.'">'.$langs->trans("Delete").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").'</a>';
} }
print "</div>"; print "</div>";
@ -376,8 +378,7 @@ if ($cats < 0)
$categstatic->type = $type; $categstatic->type = $type;
$desc = dol_htmlcleanlastbr($val['description']); $desc = dol_htmlcleanlastbr($val['description']);
$counter = 0; $counter = '';
if ($conf->global->CATEGORY_SHOW_COUNTS) if ($conf->global->CATEGORY_SHOW_COUNTS)
{ {
// we need only a count of the elements, so it is enough to consume only the id's from the database // we need only a count of the elements, so it is enough to consume only the id's from the database
@ -385,22 +386,29 @@ if ($cats < 0)
? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
: $categstatic->getObjectsInCateg($type, 1); : $categstatic->getObjectsInCateg($type, 1);
$counter = is_countable($elements) ? count($elements) : 0; $counter = "<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) : '0')."</td>";
} }
$color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"'; $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
$li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type));
$entry = '<table class="nobordernopadding centpercent">'; $entry = '<table class="nobordernopadding centpercent">';
$entry .= '<tr>'; $entry .= '<tr>';
$entry .= '<td>'; $entry .= '<td>';
$entry .= '<span class="noborderoncategories" '.$color.'>'.$categstatic->getNomUrl(1, '', 60).'</span>'; $entry .= '<span class="noborderoncategories" '.$color.'>'.$li.'</span>';
$entry .= '</td>'; $entry .= '</td>';
$entry .= '<td class="left" width="40px;">'.$counter.'</td>'; $entry .= $counter;
$entry .= '<td class="right" width="20px;">'; $entry .= '<td class="right" width="20px;">';
$entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'">'.img_view().'</a>'; $entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_view().'</a>';
$entry .= '</td>';
$entry .= '<td class="right" width="20px;">';
$entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_edit().'</a>';
$entry .= '</td>';
$entry .= '<td class="right" width="20px;">';
$entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_delete().'</a>';
$entry .= '</td>'; $entry .= '</td>';
$entry .= '</tr>'; $entry .= '</tr>';
@ -409,7 +417,8 @@ if ($cats < 0)
$data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry); $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
} }
if ((count($data) - 1)) $nbofentries = (count($data) - 1);
if ($nbofentries > 0)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
print '<tr class="pair">'; print '<tr class="pair">';

View File

@ -141,14 +141,8 @@ $arrayfields = array(
'a.tms'=>array('label'=>'DateModification', 'checked'=>0) 'a.tms'=>array('label'=>'DateModification', 'checked'=>0)
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');

View File

@ -286,7 +286,10 @@ if ($object->id > 0)
print '<tr><td>'; print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td>'; print $langs->trans('CustomerCode').'</td><td>';
print $object->code_client; print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; $tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
}
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';

File diff suppressed because it is too large Load Diff

View File

@ -463,24 +463,51 @@ if ($object->fetch($id) >= 0)
$sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.fk_mailing=".$object->id; $sql .= " WHERE mc.fk_mailing=".$object->id;
if ($search_lastname) $sql .= natural_search("mc.lastname", $search_lastname); $asearchcriteriahasbeenset = 0;
if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname); if ($search_lastname) {
if ($search_email) $sql .= natural_search("mc.email", $search_email); $sql .= natural_search("mc.lastname", $search_lastname);
if ($search_other) $sql .= natural_search("mc.other", $search_other); $asearchcriteriahasbeenset++;
if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." "; }
if ($search_firstname) {
$sql .= natural_search("mc.firstname", $search_firstname);
$asearchcriteriahasbeenset++;
}
if ($search_email) {
$sql .= natural_search("mc.email", $search_email);
$asearchcriteriahasbeenset++;
}
if ($search_other) {
$sql .= natural_search("mc.other", $search_other);
$asearchcriteriahasbeenset++;
}
if ($search_dest_status != '' && $search_dest_status >= -1) {
$sql .= " AND mc.statut=".$db->escape($search_dest_status)." ";
$asearchcriteriahasbeenset++;
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{ $page = 0;
$page = 0; $offset = 0;
$offset = 0; }
}
// Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
if (empty($asearchcriteriahasbeenset)) {
if ($nbtotalofrecords != $object->email) {
dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
//print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
$resultrefresh = $object->refreshNbOfTargets();
if ($resultrefresh < 0) {
dol_print_error($db, $object->error, $object->errors);
}
}
}
} }
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets

View File

@ -118,36 +118,48 @@ class Mailing extends CommonObject
/** /**
* @var int id of user create * @var int id of user create
* @deprecated
*/ */
public $user_creation; public $user_creation;
/** /**
* @var int id of user create * @var int id of user create
* @deprecated
*/ */
public $user_creat; public $user_creat;
/** /**
* @var int id of user validate * @var int id of user validate
* @deprecated
*/ */
public $user_validation; public $user_validation;
/** /**
* @var int id of user validate * @var int id of user validate
* @deprecated
*/ */
public $user_valid; public $user_valid;
/** /**
* @var integer|string date_creation * @var integer|string date_creation
* @deprecated
*/ */
public $date_creat; public $date_creat;
/**
* @var integer|string date_creation
*/
public $date_creation;
/** /**
* @var int date validate * @var int date validate
* @deprecated
*/ */
public $date_valid; public $date_valid;
/**
* @var int date validate
*/
public $date_validation;
/** /**
* @var array extraparams * @var array extraparams
*/ */
@ -314,10 +326,14 @@ class Mailing extends CommonObject
$this->email_errorsto = $obj->email_errorsto; $this->email_errorsto = $obj->email_errorsto;
$this->user_creat = $obj->fk_user_creat; $this->user_creat = $obj->fk_user_creat;
$this->user_creation = $obj->fk_user_creat;
$this->user_valid = $obj->fk_user_valid; $this->user_valid = $obj->fk_user_valid;
$this->user_validation = $obj->fk_user_valid;
$this->date_creat = $this->db->jdate($obj->date_creat); $this->date_creat = $this->db->jdate($obj->date_creat);
$this->date_creation = $this->db->jdate($obj->date_creat);
$this->date_valid = $this->db->jdate($obj->date_valid); $this->date_valid = $this->db->jdate($obj->date_valid);
$this->date_validation = $this->db->jdate($obj->date_valid);
$this->date_envoi = $this->db->jdate($obj->date_envoi); $this->date_envoi = $this->db->jdate($obj->date_envoi);
$this->extraparams = (array) json_decode($obj->extraparams, true); $this->extraparams = (array) json_decode($obj->extraparams, true);
@ -510,6 +526,8 @@ class Mailing extends CommonObject
dol_syslog("Mailing::delete_targets", LOG_DEBUG); dol_syslog("Mailing::delete_targets", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$this->refreshNbOfTargets();
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
@ -577,6 +595,38 @@ class Mailing extends CommonObject
return 0; return 0;
} }
/**
* Refresh denormalized value ->nbemail into emailing record
* Note: There is also the method update_nb into modules_mailings that is used for this.
*
* @return int <0 if KO, >0 if OK
*/
public function refreshNbOfTargets()
{
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".$this->id;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj) {
$nbforupdate = $obj->nb;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
$sql .= ' WHERE rowid = '.$this->id;
$resqlupdate = $this->db->query($sql);
if (! $resqlupdate) {
$this->error = $this->db->lasterror();
return -1;
}
}
} else {
$this->error = $this->db->lasterror();
return -1;
}
return 1;
}
/** /**
* Return a link to the object card (with optionally the picto) * Return a link to the object card (with optionally the picto)

View File

@ -33,8 +33,9 @@ $id = GETPOST('id', 'int');
$langs->load("mails"); $langs->load("mails");
// Security check // Security check
if (!$user->rights->mailing->lire || $user->socid > 0) if (!$user->rights->mailing->lire || $user->socid > 0) {
accessforbidden(); accessforbidden();
}
@ -48,8 +49,7 @@ $form = new Form($db);
$object = new Mailing($db); $object = new Mailing($db);
if ($object->fetch($id) >= 0) if ($object->fetch($id) >= 0) {
{
$head = emailing_prepare_head($object); $head = emailing_prepare_head($object);
print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email'); print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email');
@ -58,13 +58,14 @@ if ($object->fetch($id) >= 0)
$morehtmlright = ''; $morehtmlright = '';
$nbtry = $nbok = 0; $nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3) if ($object->statut == 2 || $object->statut == 3) {
{
$nbtry = $object->countNbOfTargets('alreadysent'); $nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko'); $nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); if ($nbko) {
$morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
}
$morehtmlright .= ') &nbsp; '; $morehtmlright .= ') &nbsp; ';
} }
@ -73,10 +74,6 @@ if ($object->fetch($id) >= 0)
print '<div class="underbanner clearboth"></div><br>'; print '<div class="underbanner clearboth"></div><br>';
//print '<table width="100%"><tr><td>'; //print '<table width="100%"><tr><td>';
$object->user_creation = $object->user_creat;
$object->date_creation = $object->date_creat;
$object->user_validation = $object->user_valid;
$object->date_validation = $object->date_valid;
dol_print_object_info($object, 0); dol_print_object_info($object, 0);
//print '</td></tr></table>'; //print '</td></tr></table>';

View File

@ -1660,7 +1660,7 @@ if ($action == 'create')
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top">'; print '<td valign="top">';
$note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc) ? $objectsrc->note_public : null)); $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc) ? $objectsrc->note_public : null));
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// Private note // Private note
@ -1670,7 +1670,7 @@ if ($action == 'create')
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top">'; print '<td valign="top">';
$note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null)); $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null));
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea> // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>'; print '</td></tr>';

View File

@ -598,6 +598,7 @@ class Propal extends CommonObject
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code // Clean vat code
$reg = array();
$vat_src_code = ''; $vat_src_code = '';
if (preg_match('/\((.*)\)/', $txtva, $reg)) if (preg_match('/\((.*)\)/', $txtva, $reg))
{ {

View File

@ -1736,7 +1736,7 @@ if ($action == 'create' && $usercancreate)
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_public.'</textarea>'; // print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
print '</td></tr>'; print '</td></tr>';
@ -1747,7 +1747,7 @@ if ($action == 'create' && $usercancreate)
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'</textarea>'; // print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
print '</td></tr>'; print '</td></tr>';

View File

@ -492,26 +492,21 @@ class Commande extends CommonOrder
$error++; $error++;
} }
if (!$error) if (!$error) {
{
// If stock is incremented on validate order, we must increment it // If stock is incremented on validate order, we must increment it
if ($result >= 0 && !empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if ($result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) {
{
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
$langs->load("agenda"); $langs->load("agenda");
// Loop on each line // Loop on each line
$cpt = count($this->lines); $cpt = count($this->lines);
for ($i = 0; $i < $cpt; $i++) for ($i = 0; $i < $cpt; $i++) {
{ if ($this->lines[$i]->fk_product > 0) {
if ($this->lines[$i]->fk_product > 0)
{
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this; $mouvP->origin = &$this;
// We decrement stock of product (and sub-products) // We decrement stock of product (and sub-products)
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num)); $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num));
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
$this->error = $mouvP->error; $this->error = $mouvP->error;
} }
@ -521,16 +516,14 @@ class Commande extends CommonOrder
} }
} }
if (!$error && !$notrigger) if (!$error && !$notrigger) {
{
// Call trigger // Call trigger
$result = $this->call_trigger('ORDER_VALIDATE', $user); $result = $this->call_trigger('ORDER_VALIDATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
if (!$error) if (!$error) {
{
$this->oldref = $this->ref; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
@ -631,7 +624,7 @@ class Commande extends CommonOrder
} }
// If stock is decremented on validate order, we must reincrement it // If stock is decremented on validate order, we must reincrement it
if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{ {
$result = 0; $result = 0;
@ -817,7 +810,7 @@ class Commande extends CommonOrder
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
// If stock is decremented on validate order, we must reincrement it // If stock is decremented on validate order, we must reincrement it
if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{ {
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
$langs->load("agenda"); $langs->load("agenda");
@ -3166,8 +3159,8 @@ class Commande extends CommonOrder
$this->line->tva_tx = $txtva; $this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1; $this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2; $this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
$this->line->remise_percent = $remise_percent; $this->line->remise_percent = $remise_percent;
$this->line->subprice = $subprice; $this->line->subprice = $subprice;
$this->line->info_bits = $info_bits; $this->line->info_bits = $info_bits;

View File

@ -675,7 +675,7 @@ if ($resql)
if (!empty($arrayfields['s.nom']['checked'])) if (!empty($arrayfields['s.nom']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">'; print '<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
print '</td>'; print '</td>';
} }
// Town // Town

View File

@ -529,7 +529,7 @@ print '<span class="opacitymedium">'.$langs->trans("ExportAccountingSourceDocHel
print '<br>'; print '<br>';
print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0);
print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n</a>"; print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n";
// Export is for current company only // Export is for current company only
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc))
@ -560,7 +560,7 @@ $listofchoices = array(
); );
foreach ($listofchoices as $choice => $val) { foreach ($listofchoices as $choice => $val) {
$checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : '');
print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" name="'.$choice.'" value="1"'.$checked.'> '.$langs->trans($val['label']).'</div>'; print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.'> <label for="'.$choice.'">'.$langs->trans($val['label']).'</label></div>';
} }
print '<input class="button" type="submit" name="search" value="'.$langs->trans("Search").'">'; print '<input class="button" type="submit" name="search" value="'.$langs->trans("Search").'">';

View File

@ -155,14 +155,8 @@ $arrayfields = array(
'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020), 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020),
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');
@ -496,7 +490,7 @@ if (dol_strlen($search_dv_end) > 0) $sql .= " AND b.datev <= '".$db->idate($sear
if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1); if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1);
if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb); if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb);
if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve); if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve);
if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".$search_conciliated; if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".urlencode($search_conciliated);
if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty); if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty);
if ($search_description) if ($search_description)
{ {
@ -861,6 +855,10 @@ if ($resql)
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
// When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation).
if ($action == 'reconcile') {
$arrayfields['b.num_releve']['checked'] = 1;
}
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
@ -993,9 +991,8 @@ if ($resql)
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
// If we are in a situation where we need/can show balance, we calculate the start of balance // If we are in a situation where we need/can show balance, we calculate the start of balance
if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && $mode_balance_ok) if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0'))
{ {
if (!$search_account) if (!$search_account)
{ {
@ -1016,11 +1013,9 @@ if ($resql)
$sqlforbalance .= " AND (b.datev < '".$db->idate($db->jdate($objp->dv))."' OR (b.datev = '".$db->idate($db->jdate($objp->dv))."' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; $sqlforbalance .= " AND (b.datev < '".$db->idate($db->jdate($objp->dv))."' OR (b.datev = '".$db->idate($db->jdate($objp->dv))."' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))";
$resqlforbalance = $db->query($sqlforbalance); $resqlforbalance = $db->query($sqlforbalance);
//print $sqlforbalance; //print $sqlforbalance;
if ($resqlforbalance) if ($resqlforbalance) {
{
$objforbalance = $db->fetch_object($resqlforbalance); $objforbalance = $db->fetch_object($resqlforbalance);
if ($objforbalance) if ($objforbalance) {
{
// If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc')
{ {
@ -1081,24 +1076,30 @@ if ($resql)
if (!empty($arrayfields['balancebefore']['checked'])) if (!empty($arrayfields['balancebefore']['checked']))
{ {
print '<td class="right">'; print '<td class="right">';
print price(price2num($balance, 'MT'), 1, $langs); if ($search_conciliated !== '0') {
print price(price2num($balance, 'MT'), 1, $langs);
}
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['balance']['checked'])) if (!empty($arrayfields['balance']['checked']))
{ {
print '<td class="right">'; print '<td class="right">';
print price(price2num($balance, 'MT'), 1, $langs); if ($search_conciliated !== '0') {
print price(price2num($balance, 'MT'), 1, $langs);
}
print '</td>';
}
if (!empty($arrayfields['b.num_releve']['checked']))
{
print '<td class="center">';
print '<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans("SelectAll")).'" />';
print ' <script type="text/javascript">
$("input#selectAll").change(function() {
$("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
});
</script>';
print '</td>'; print '</td>';
} }
print '<td class="center">';
print '<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans("SelectAll")).'" />';
print ' <script type="text/javascript">
$("input#selectAll").change(function() {
$("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
});
</script>';
print '</td>';
print '<td colspan="'.($tmpnbfieldafterbalance + 2).'">'; print '<td colspan="'.($tmpnbfieldafterbalance + 2).'">';
print '&nbsp;'; print '&nbsp;';
print '</td>'; print '</td>';

View File

@ -1741,13 +1741,6 @@ class AccountLine extends CommonObject
public $amount; public $amount;
/**
* @var string bank transaction lines label
*/
public $label;
public $note;
/** /**
* @var int ID * @var int ID
*/ */
@ -1763,11 +1756,6 @@ class AccountLine extends CommonObject
*/ */
public $fk_type; public $fk_type;
public $rappro; // Is it conciliated
public $num_releve; // If conciliated, what is bank statement
public $num_chq; // Num of cheque
public $bank_chq; // Bank of cheque
/** /**
* @var int ID of cheque receipt * @var int ID of cheque receipt
*/ */
@ -1778,16 +1766,40 @@ class AccountLine extends CommonObject
*/ */
public $fk_account; public $fk_account;
/**
* @var string Ref of bank account
*/
public $bank_account_ref;
/** /**
* @var string Label of bank account * @var string Label of bank account
*/ */
public $bank_account_label; public $bank_account_label;
/**
* @var string Bank account numero
*/
public $numero_compte;
/** /**
* @var string Name of check issuer * @var string Name of check issuer
*/ */
public $emetteur; public $emetteur;
public $rappro; // Is it conciliated
public $num_releve; // If conciliated, what is bank statement
public $num_chq; // Num of cheque
public $bank_chq; // Bank of cheque
/**
* @var string bank transaction lines label
*/
public $label;
public $note;
/** /**
* Constructor * Constructor
* *

View File

@ -93,7 +93,18 @@ class PaymentVarious extends CommonObject
public $fk_project; public $fk_project;
/** /**
* @var int ID * @var int Bank account ID
*/
public $fk_account;
/**
* @var int Bank account ID
* @deprecated See fk_account
*/
public $accountid;
/**
* @var int ID record into llx_bank
*/ */
public $fk_bank; public $fk_bank;
@ -102,11 +113,6 @@ class PaymentVarious extends CommonObject
*/ */
public $categorie_transaction; public $categorie_transaction;
/**
* @var int Account ID
*/
public $accountid;
/** /**
* @var int ID * @var int ID
*/ */
@ -397,6 +403,10 @@ class PaymentVarious extends CommonObject
$this->fk_bank = (int) $this->fk_bank; $this->fk_bank = (int) $this->fk_bank;
$this->fk_user_author = (int) $this->fk_user_author; $this->fk_user_author = (int) $this->fk_user_author;
$this->fk_user_modif = (int) $this->fk_user_modif; $this->fk_user_modif = (int) $this->fk_user_modif;
$this->fk_account = (int) $this->fk_account;
if (empty($this->fk_account) && isset($this->accountid)) { // For compatibility
$this->fk_account = $this->accountid;
}
// Check parameters // Check parameters
if (!$this->label) if (!$this->label)
@ -409,9 +419,9 @@ class PaymentVarious extends CommonObject
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5; return -5;
} }
if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) if (!empty($conf->banque->enabled) && (empty($this->fk_account) || $this->fk_account <= 0))
{ {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount"));
return -6; return -6;
} }
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
@ -454,7 +464,7 @@ class PaymentVarious extends CommonObject
$sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0);
$sql .= ", ".$user->id; $sql .= ", ".$user->id;
$sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'";
$sql .= ", NULL"; $sql .= ", NULL"; // Filled later
$sql .= ", ".$conf->entity; $sql .= ", ".$conf->entity;
$sql .= ")"; $sql .= ")";
@ -473,7 +483,7 @@ class PaymentVarious extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db); $acc = new Account($this->db);
$result = $acc->fetch($this->accountid); $result = $acc->fetch($this->fk_account);
if ($result <= 0) dol_print_error($this->db); if ($result <= 0) dol_print_error($this->db);
// Insert payment into llx_bank // Insert payment into llx_bank
@ -495,7 +505,7 @@ class PaymentVarious extends CommonObject
$this->datev $this->datev
); );
// Update fk_bank into llx_paiement. // Update fk_bank into llx_payment_various
// So we know the payment which has generate the banking ecriture // So we know the payment which has generate the banking ecriture
if ($bank_line_id > 0) { if ($bank_line_id > 0) {
$this->update_fk_bank($bank_line_id); $this->update_fk_bank($bank_line_id);

View File

@ -106,14 +106,8 @@ $arrayfields = array(
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010),
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');

View File

@ -491,7 +491,7 @@ if ($id)
); );
$formquestion[] = array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1); $formquestion[] = array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1);
$formquestion[] = array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1);
$formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1)); $formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1, '', 0, 'minwidth200', 1));
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 300); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 300);
} }

View File

@ -466,14 +466,18 @@ if ($result)
// Project // Project
if ($arrayfields['project']['checked']) { if ($arrayfields['project']['checked']) {
$proj->fetch($obj->fk_project); print '<td class="nowraponall">';
print '<td class="nowraponall">'.$proj->getNomUrl(1).'</td>'; if ($obj->fk_project > 0) {
$proj->fetch($obj->fk_project);
print $proj->getNomUrl(1);
}
print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Bank account // Bank account
if ($arrayfields['bank']['checked']) { if ($arrayfields['bank']['checked']) {
print '<td>'; print '<td class="nowraponall">';
if ($obj->bid > 0) if ($obj->bid > 0)
{ {
$accountstatic->id = $obj->bid; $accountstatic->id = $obj->bid;

View File

@ -120,14 +120,8 @@ foreach ($object->fields as $key => $val)
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
} }
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');

View File

@ -133,7 +133,8 @@ if ($resql) {
print "<center><h2>"; print "<center><h2>";
if ($cashcontrol->status != $cashcontrol::STATUS_DRAFT) print $langs->trans("CashControl")." ".$cashcontrol->id; if ($cashcontrol->status != $cashcontrol::STATUS_DRAFT) print $langs->trans("CashControl")." ".$cashcontrol->id;
else print $langs->trans("CashControl")." - ".$langs->trans("Draft"); else print $langs->trans("CashControl")." - ".$langs->trans("Draft");
print "<br>".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour')."</h2></center>"; print "<br>".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour');
print "</h2></center>";
$invoicetmp = new Facture($db); $invoicetmp = new Facture($db);
@ -156,8 +157,6 @@ if ($resql) {
print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, 'right ');
print "</tr>\n"; print "</tr>\n";
$posconciliatecol = 0;
// Loop on each record // Loop on each record
$sign = 1; $sign = 1;
$cash = $bank = $cheque = $other = 0; $cash = $bank = $cheque = $other = 0;
@ -263,7 +262,7 @@ if ($resql) {
print "</table>"; print "</table>";
//$cash = $amountpertype['LIQ'] + $cashcontrol->opening; //$cash = $amountpertype['LIQ'] + $cashcontrol->opening;
$cash = $cash + $cashcontrol->opening; $cash = price2num($cash + $cashcontrol->opening, 'MT');
print "<div style='text-align: right'><h2>"; print "<div style='text-align: right'><h2>";
print $langs->trans("Cash").": ".price($cash); print $langs->trans("Cash").": ".price($cash);

View File

@ -252,7 +252,7 @@ if ($action == 'create')
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
@ -264,7 +264,7 @@ if ($action == 'create')
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
@ -349,7 +349,7 @@ if ($action == 'create')
print '<tr><td class="tdtop">'.$langs->trans("NotePublic").'</td>'; print '<tr><td class="tdtop">'.$langs->trans("NotePublic").'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print "</td></tr>"; print "</td></tr>";
@ -360,7 +360,7 @@ if ($action == 'create')
print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td>'; print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print "</td></tr>"; print "</td></tr>";

View File

@ -156,7 +156,7 @@ if (empty($reshook))
// Create predefined invoice // Create predefined invoice
if ($action == 'add') if ($action == 'add')
{ {
if (!GETPOST('titre', 'nohtml')) if (!GETPOST('title', 'alphanohtml'))
{ {
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors');
$action = "create"; $action = "create";
@ -289,7 +289,7 @@ if (empty($reshook))
elseif ($action == 'setref' && $user->rights->facture->creer) elseif ($action == 'setref' && $user->rights->facture->creer)
{ {
//var_dump(GETPOST('ref', 'alpha'));exit; //var_dump(GETPOST('ref', 'alpha'));exit;
$result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY'); $result = $object->setValueFrom('title', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY');
if ($result > 0) if ($result > 0)
{ {
$object->titre = GETPOST('ref', 'alpha'); // deprecated $object->titre = GETPOST('ref', 'alpha'); // deprecated
@ -967,7 +967,7 @@ if ($action == 'create')
// Title // Title
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>'; print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>';
print '<input class="flat quatrevingtpercent" type="text" name="titre" value="'.dol_escape_htmltag(GETPOST("titre", 'alphanohtml')).'">'; print '<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("titre", 'alphanohtml')).'">';
print '</td></tr>'; print '</td></tr>';
// Third party // Third party
@ -1008,7 +1008,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// Private note // Private note
@ -1019,7 +1019,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea> // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>'; print '</td></tr>';
@ -1237,7 +1237,7 @@ if ($action == 'create')
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright); dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';

View File

@ -2433,22 +2433,22 @@ if (empty($reshook))
{ {
$object->fetch($id, '', '', '', true); $object->fetch($id, '', '', '', true);
if ($object->statut == Facture::STATUS_VALIDATED if (in_array($object->statut, array(Facture::STATUS_CLOSED, Facture::STATUS_VALIDATED))
&& $object->type == Facture::TYPE_SITUATION && $object->type == Facture::TYPE_SITUATION
&& $usercancreate && $usercancreate
&& !$objectidnext && !$objectidnext
&& $object->is_last_in_cycle() && $object->is_last_in_cycle()
&& $usercanunvalidate && $usercanunvalidate
) )
{ {
$outingError = 0; $outingError = 0;
$newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle
if ($newCycle > 1) if ($newCycle > 1)
{ {
// Search credit notes // Search credit notes
$lastCycle = $object->situation_cycle_ref; $lastCycle = $object->situation_cycle_ref;
$lastSituationCounter = $object->situation_counter; $lastSituationCounter = $object->situation_counter;
$linkedCreditNotesList = array(); $linkedCreditNotesList = array();
if (count($object->tab_next_situation_invoice) > 0) { if (count($object->tab_next_situation_invoice) > 0) {
foreach ($object->tab_next_situation_invoice as $next_invoice) { foreach ($object->tab_next_situation_invoice as $next_invoice) {
@ -3534,7 +3534,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext); print $form->textwithpicto($langs->trans('NotePublic'), $htmltext);
print '</td>'; print '</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// Private note // Private note
@ -3545,7 +3545,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext); print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext);
print '</td>'; print '</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea> // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>'; print '</td></tr>';
@ -3764,18 +3764,18 @@ if ($action == 'create')
// Confirmation to remove invoice from cycle // Confirmation to remove invoice from cycle
if ($action == 'situationout') { if ($action == 'situationout') {
$text = $langs->trans('ConfirmRemoveSituationFromCycle', $object->ref); $text = $langs->trans('ConfirmRemoveSituationFromCycle', $object->ref);
$label = $langs->trans("ConfirmOuting"); $label = $langs->trans("ConfirmOuting");
$formquestion = array(); $formquestion = array();
// remove situation from cycle // remove situation from cycle
if ($object->statut == Facture::STATUS_VALIDATED if (in_array($object->statut, array(Facture::STATUS_CLOSED, Facture::STATUS_VALIDATED))
&& $usercancreate && $usercancreate
&& !$objectidnext && !$objectidnext
&& $object->is_last_in_cycle() && $object->is_last_in_cycle()
&& $usercanunvalidate && $usercanunvalidate
) )
{ {
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $label, $text, 'confirm_situationout', $formquestion, "yes", 1); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $label, $text, 'confirm_situationout', $formquestion, "yes", 1);
} }
} }
@ -5278,12 +5278,12 @@ if ($action == 'create')
} }
// Remove situation from cycle // Remove situation from cycle
if ($object->statut > Facture::STATUS_DRAFT if (in_array($object->statut, array(Facture::STATUS_CLOSED, Facture::STATUS_VALIDATED))
&& $object->type == Facture::TYPE_SITUATION && $object->type == Facture::TYPE_SITUATION
&& $usercancreate && $usercancreate
&& !$objectidnext && !$objectidnext
&& $object->situation_counter > 1 && $object->situation_counter > 1
&& $object->is_last_in_cycle() && $object->is_last_in_cycle()
&& $usercanunvalidate && $usercanunvalidate
) )
{ {

View File

@ -215,7 +215,7 @@ class FactureRec extends CommonInvoice
$now = dol_now(); $now = dol_now();
// Clean parameters // Clean parameters
$this->titre = trim($this->titre); // deprecated $this->titre = trim(isset($this->titre) ? $this->titre : $this->title); // deprecated
$this->title = trim($this->title); $this->title = trim($this->title);
$this->usenewprice = empty($this->usenewprice) ? 0 : $this->usenewprice; $this->usenewprice = empty($this->usenewprice) ? 0 : $this->usenewprice;
if (empty($this->suspended)) $this->suspended = 0; if (empty($this->suspended)) $this->suspended = 0;
@ -366,7 +366,7 @@ class FactureRec extends CommonInvoice
} }
// Add object linked // Add object linked
if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects))
{ {
foreach ($this->linked_objects as $origin => $tmp_origin_id) foreach ($this->linked_objects as $origin => $tmp_origin_id)
{ {
@ -702,7 +702,7 @@ class FactureRec extends CommonInvoice
$line->total_ht = $objp->total_ht; $line->total_ht = $objp->total_ht;
$line->total_tva = $objp->total_tva; $line->total_tva = $objp->total_tva;
$line->total_ttc = $objp->total_ttc; $line->total_ttc = $objp->total_ttc;
$line->code_ventilation = $objp->fk_code_ventilation; //$line->code_ventilation = $objp->fk_code_ventilation;
$line->fk_fournprice = $objp->fk_fournprice; $line->fk_fournprice = $objp->fk_fournprice;
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
$line->pa_ht = $marginInfos[0]; $line->pa_ht = $marginInfos[0];
@ -935,9 +935,9 @@ class FactureRec extends CommonInvoice
$sql .= ", ".price2num($txtva); $sql .= ", ".price2num($txtva);
$sql .= ", '".$this->db->escape($vat_src_code)."'"; $sql .= ", '".$this->db->escape($vat_src_code)."'";
$sql .= ", ".price2num($txlocaltax1); $sql .= ", ".price2num($txlocaltax1);
$sql .= ", '".$this->db->escape($localtaxes_type[0])."'"; $sql .= ", '".$this->db->escape(isset($localtaxes_type[0]) ? $localtaxes_type[0] : '')."'";
$sql .= ", ".price2num($txlocaltax2); $sql .= ", ".price2num($txlocaltax2);
$sql .= ", '".$this->db->escape($localtaxes_type[2])."'"; $sql .= ", '".$this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '')."'";
$sql .= ", ".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); $sql .= ", ".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null");
$sql .= ", ".$product_type; $sql .= ", ".$product_type;
$sql .= ", ".price2num($remise_percent); $sql .= ", ".price2num($remise_percent);
@ -1996,7 +1996,7 @@ class FactureLigneRec extends CommonInvoiceLine
$this->localtax1_type = $objp->localtax1_type; $this->localtax1_type = $objp->localtax1_type;
$this->localtax2_type = $objp->localtax2_type; $this->localtax2_type = $objp->localtax2_type;
$this->remise_percent = $objp->remise_percent; $this->remise_percent = $objp->remise_percent;
$this->fk_remise_except = $objp->fk_remise_except; //$this->fk_remise_except = $objp->fk_remise_except;
$this->fk_product = $objp->fk_product; $this->fk_product = $objp->fk_product;
$this->date_start_fill = $objp->date_start_fill; $this->date_start_fill = $objp->date_start_fill;
$this->date_end_fill = $objp->date_end_fill; $this->date_end_fill = $objp->date_end_fill;
@ -2004,7 +2004,7 @@ class FactureLigneRec extends CommonInvoiceLine
$this->total_ht = $objp->total_ht; $this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva; $this->total_tva = $objp->total_tva;
$this->total_ttc = $objp->total_ttc; $this->total_ttc = $objp->total_ttc;
$this->code_ventilation = $objp->fk_code_ventilation; //$this->code_ventilation = $objp->fk_code_ventilation;
$this->rang = $objp->rang; $this->rang = $objp->rang;
$this->special_code = $objp->special_code; $this->special_code = $objp->special_code;
$this->fk_unit = $objp->fk_unit; $this->fk_unit = $objp->fk_unit;

View File

@ -868,7 +868,7 @@ class Facture extends CommonInvoice
$line->situation_percent, $line->situation_percent,
$line->fk_prev_id, $line->fk_prev_id,
$line->fk_unit, $line->fk_unit,
$line->pu_ht_devise, $line->multicurrency_subprice,
$line->ref_ext $line->ref_ext
); );
if ($result < 0) if ($result < 0)
@ -968,7 +968,7 @@ class Facture extends CommonInvoice
$_facrec->lines[$i]->situation_percent, $_facrec->lines[$i]->situation_percent,
'', '',
$_facrec->lines[$i]->fk_unit, $_facrec->lines[$i]->fk_unit,
$_facrec->lines[$i]->pu_ht_devise $_facrec->lines[$i]->multicurrency_subprice
); );
if ($result_insert < 0) if ($result_insert < 0)
@ -2971,7 +2971,7 @@ class Facture extends CommonInvoice
* @param int $situation_percent Situation advance percentage * @param int $situation_percent Situation advance percentage
* @param int $fk_prev_id Previous situation line id reference * @param int $fk_prev_id Previous situation line id reference
* @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency * @param double $pu_ht_devise Unit price in foreign currency
* @param string $ref_ext External reference of the line * @param string $ref_ext External reference of the line
* @return int <0 if KO, Id of line if OK * @return int <0 if KO, Id of line if OK
*/ */
@ -3136,8 +3136,8 @@ class Facture extends CommonInvoice
$this->line->tva_tx = $txtva; $this->line->tva_tx = $txtva;
$this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0);
$this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0);
$this->line->localtax1_type = isset($localtaxes_type[0]) ? $localtaxes_type[0] : ''; $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
$this->line->localtax2_type = isset($localtaxes_type[2]) ? $localtaxes_type[2] : ''; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
$this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative
$this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative
@ -3375,8 +3375,8 @@ class Facture extends CommonInvoice
$this->line->tva_tx = $txtva; $this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1; $this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2; $this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
$this->line->remise_percent = $remise_percent; $this->line->remise_percent = $remise_percent;
$this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise

View File

@ -135,14 +135,8 @@ $arrayfields = array(
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');

View File

@ -213,7 +213,7 @@ if ($object->id > 0)
$head = facture_prepare_head($object); $head = facture_prepare_head($object);
} }
print dol_get_fiche_head($head, 'standingorders', $title, -1, 'bill'); print dol_get_fiche_head($head, 'standingorders', $title, -1, ($type == 'bank-transfer' ? 'supplier_invoice' : 'bill'));
// Invoice content // Invoice content
if ($type == 'bank-transfer') { if ($type == 'bank-transfer') {

View File

@ -229,6 +229,8 @@ if ($modecompta == 'BOOKKEEPING')
print "</tr>\n"; print "</tr>\n";
$total_ht_outcome = $total_ttc_outcome = $total_ht_income = $total_ttc_income = 0;
if ($modecompta == 'BOOKKEEPING') if ($modecompta == 'BOOKKEEPING')
{ {
@ -438,16 +440,97 @@ if ($modecompta == 'BOOKKEEPING')
if ($total_ttc == 0) if ($total_ttc == 0)
{ {
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '</tr>'; print '</tr>';
} }
$total_ht_income += $total_ht;
$total_ttc_income += $total_ttc;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price($total_ht).'</td>'; print '<td colspan="3" class="right">'.price($total_ht).'</td>';
print '<td colspan="3" class="right">'.price($total_ttc).'</td>'; print '<td colspan="3" class="right">'.price($total_ttc).'</td>';
print '</tr>'; print '</tr>';
/*
* Donations
*/
if (!empty($conf->don->enabled))
{
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
{
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
$sql .= " AND fk_statut in (1,2)";
} else {
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
$sql .= " AND fk_statut >= 2";
}
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
}
$sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get dunning");
$result = $db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
$total_ht += $obj->amount;
$total_ttc += $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
print '<td class="right">'.price($obj->amount).'</td>';
print '</tr>';
$i++;
}
} else {
print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '</tr>';
}
} else {
dol_print_error($db);
}
$total_ht_income += $subtotal_ht;
$total_ttc_income += $subtotal_ttc;
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
print '</tr>';
}
/* /*
* Suppliers invoices * Suppliers invoices
@ -515,7 +598,7 @@ if ($modecompta == 'BOOKKEEPING')
} }
} else { } else {
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '</tr>'; print '</tr>';
} }
@ -523,6 +606,9 @@ if ($modecompta == 'BOOKKEEPING')
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_outcome += $subtotal_ht;
$total_ttc_outcome += $subtotal_ttc;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
@ -530,7 +616,6 @@ if ($modecompta == 'BOOKKEEPING')
print '</tr>'; print '</tr>';
/* /*
* Charges sociales non deductibles * Charges sociales non deductibles
*/ */
@ -592,12 +677,15 @@ if ($modecompta == 'BOOKKEEPING')
} }
} else { } else {
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_outcome += $subtotal_ht;
$total_ttc_outcome += $subtotal_ttc;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
@ -667,36 +755,21 @@ if ($modecompta == 'BOOKKEEPING')
} }
} else { } else {
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_outcome += $subtotal_ht;
$total_ttc_outcome += $subtotal_ttc;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>'; print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
if ($mysoc->tva_assuj == 'franchise') // Non assujetti
{
// Total
print '<tr>';
print '<td colspan="4">&nbsp;</td>';
print '</tr>';
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td class="border right">'.price($total_ht).'</td>';
print '<td class="right">'.price($total_ttc).'</td>';
print '</tr>';
print '<tr>';
print '<td colspan="4">&nbsp;</td>';
print '</tr>';
}
/* /*
* Salaries * Salaries
@ -759,12 +832,15 @@ if ($modecompta == 'BOOKKEEPING')
} }
} else { } else {
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_outcome += $subtotal_ht;
$total_ttc_outcome += $subtotal_ttc;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
@ -841,98 +917,26 @@ if ($modecompta == 'BOOKKEEPING')
} }
} else { } else {
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_outcome += $subtotal_ht;
$total_ttc_outcome += $subtotal_ttc;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>'; if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>'; print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
} }
/*
* Donations
*/
if (!empty($conf->don->enabled))
{
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
{
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
$sql .= " AND fk_statut in (1,2)";
} else {
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
$sql .= " AND fk_statut >= 2";
}
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
}
$sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get dunning");
$result = $db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
$total_ht += $obj->amount;
$total_ttc += $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
print '<td class="right">'.price($obj->amount).'</td>';
print '</tr>';
$i++;
}
} else {
print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
print '</tr>';
}
} else {
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
print '</tr>';
}
/* /*
* Various Payments * Various Payments
*/ */
//$conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY = 1;
if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
{ {
@ -953,12 +957,14 @@ if ($modecompta == 'BOOKKEEPING')
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
// Debit // Debit (payment of suppliers for example)
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if (isset($obj->amount)) if (isset($obj->amount))
{ {
$subtotal_ht += -$obj->amount; $subtotal_ht += -$obj->amount;
$subtotal_ttc += -$obj->amount; $subtotal_ttc += -$obj->amount;
$total_ht_outcome += $obj->amount;
$total_ttc_outcome += $obj->amount;
} }
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("Debit")."</td>\n"; print "<td>".$langs->trans("Debit")."</td>\n";
@ -966,12 +972,14 @@ if ($modecompta == 'BOOKKEEPING')
print '<td class="right">'.price(-$obj->amount)."</td>\n"; print '<td class="right">'.price(-$obj->amount)."</td>\n";
print "</tr>\n"; print "</tr>\n";
// Credit // Credit (payment received from customer for example)
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if (isset($obj->amount)) if (isset($obj->amount))
{ {
$subtotal_ht += $obj->amount; $subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount; $subtotal_ttc += $obj->amount;
$total_ht_income += $obj->amount;
$total_ttc_income += $obj->amount;
} }
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("Credit")."</td>\n"; print "<td>".$langs->trans("Credit")."</td>\n";
@ -1030,6 +1038,8 @@ if ($modecompta == 'BOOKKEEPING')
} }
$total_ht += $subtotal_ht; $total_ht += $subtotal_ht;
$total_ttc += $subtotal_ttc; $total_ttc += $subtotal_ttc;
$total_ht_income += $subtotal_ht;
$total_ttc_income += $subtotal_ttc;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>'; print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
@ -1050,7 +1060,7 @@ if ($modecompta == 'BOOKKEEPING')
{ {
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
{ {
// TVA a payer // VAT to pay
$amount = 0; $amount = 0;
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount"; $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
@ -1091,13 +1101,15 @@ if ($modecompta == 'BOOKKEEPING')
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_outcome -= 0;
$total_ttc_outcome -= $amount;
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("VATToPay")."</td>\n"; print "<td>".$langs->trans("VATToPay")."</td>\n";
print '<td class="right">&nbsp;</td>'."\n"; print '<td class="right">&nbsp;</td>'."\n";
print '<td class="right">'.price($amount)."</td>\n"; print '<td class="right">'.price($amount)."</td>\n";
print "</tr>\n"; print "</tr>\n";
// TVA a recuperer // VAT to retreive
$amount = 0; $amount = 0;
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount"; $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
@ -1139,6 +1151,9 @@ if ($modecompta == 'BOOKKEEPING')
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_income += 0;
$total_ttc_income += $amount;
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td>'.$langs->trans("VATToCollect")."</td>\n"; print '<td>'.$langs->trans("VATToCollect")."</td>\n";
print '<td class="right">&nbsp;</td>'."\n"; print '<td class="right">&nbsp;</td>'."\n";
@ -1182,10 +1197,12 @@ if ($modecompta == 'BOOKKEEPING')
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_outcome -= 0;
$total_ttc_outcome -= $amount;
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("VATPaid")."</td>\n"; print "<td>".$langs->trans("VATPaid")."</td>\n";
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td <class="right">'.price($amount)."</td>\n"; print '<td <class="right"></td>'."\n";
print '<td class="right">'.price($amount)."</td>\n"; print '<td class="right">'.price($amount)."</td>\n";
print "</tr>\n"; print "</tr>\n";
@ -1226,16 +1243,18 @@ if ($modecompta == 'BOOKKEEPING')
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$total_ht_income += 0;
$total_ttc_income += $amount;
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("VATCollected")."</td>\n"; print "<td>".$langs->trans("VATCollected")."</td>\n";
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td class="right">'.price($amount)."</td>\n"; print '<td class="right"></td>'."\n";
print '<td class="right">'.price($amount)."</td>\n"; print '<td class="right">'.price($amount)."</td>\n";
print "</tr>\n"; print "</tr>\n";
} }
} }
if ($mysoc->tva_assuj != 'franchise') // Assujetti if ($mysoc->tva_assuj != '0') // Assujetti
{ {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
@ -1250,25 +1269,31 @@ $object = array(&$total_ht, &$total_ttc);
$parameters["mode"] = $modecompta; $parameters["mode"] = $modecompta;
$parameters["date_start"] = $date_start; $parameters["date_start"] = $date_start;
$parameters["date_end"] = $date_end; $parameters["date_end"] = $date_end;
$parameters["bc"] = $bc;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance')); $hookmanager->initHooks(array('externalbalance'));
$reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint; print $hookmanager->resPrint;
if ($mysoc->tva_assuj != 'franchise') // Assujetti // Total
{ print '<tr>';
// Total print '<td colspan="4">&nbsp;</td>';
print '<tr>'; print '</tr>';
print '<td colspan="4">&nbsp;</td>';
print '</tr>';
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>'; print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Outcome").'</td>';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>'; print '<td class="liste_total right">'.price(price2num(-$total_ht_outcome, 'MT')).'</td>';
print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>'; print '<td class="liste_total right">'.price(price2num(-$total_ttc_outcome, 'MT')).'</td>';
print '</tr>'; print '</tr>';
} print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Income").'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td class="liste_total right">'.price(price2num($total_ht_income, 'MT')).'</td>';
print '<td class="liste_total right">'.price(price2num($total_ttc_income, 'MT')).'</td>';
print '</tr>';
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>';
print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>';
print '</tr>';
print "</table>"; print "</table>";
print '<br>'; print '<br>';

View File

@ -512,13 +512,13 @@ class ChargeSociales extends CommonObject
* Return a link to the object card (with optionaly the picto) * Return a link to the object card (with optionaly the picto)
* *
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param int $maxlen Max length of label * @param string $option On what the link point to ('nolink', ...)
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param int $short 1=Return just URL * @param int $short 1=Return just URL
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with link * @return string String with link
*/ */
public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $short = 0, $save_lastsearch_value = -1)
{ {
global $langs, $conf, $user, $form; global $langs, $conf, $user, $form;
@ -569,7 +569,7 @@ class ChargeSociales extends CommonObject
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); if ($withpicto != 2) $result .= $this->ref;
$result .= $linkend; $result .= $linkend;
return $result; return $result;

View File

@ -1129,13 +1129,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Note Public // Note Public
print '<tr><td class="tdtop"><label for="note_public">'.$langs->trans("NotePublic").'</label></td><td colspan="3">'; print '<tr><td class="tdtop"><label for="note_public">'.$langs->trans("NotePublic").'</label></td><td colspan="3">';
$doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
// Note Private // Note Private
print '<tr><td class="tdtop"><label for="note_private">'.$langs->trans("NotePrivate").'</label></td><td colspan="3">'; print '<tr><td class="tdtop"><label for="note_private">'.$langs->trans("NotePrivate").'</label></td><td colspan="3">';
$doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';

View File

@ -1174,14 +1174,14 @@ if ($action == 'create')
} }
print '<tr><td>'.$langs->trans("NotePublic").'</td><td class="tdtop">'; print '<tr><td>'.$langs->trans("NotePublic").'</td><td class="tdtop">';
$doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
if (empty($user->socid)) if (empty($user->socid))
{ {
print '<tr><td>'.$langs->trans("NotePrivate").'</td><td class="tdtop">'; print '<tr><td>'.$langs->trans("NotePrivate").'</td><td class="tdtop">';
$doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -131,14 +131,8 @@ $arrayfields = array(
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');
@ -208,7 +202,7 @@ $contracttmp = new Contrat($db);
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; $sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= ' s.rowid as socid, s.nom as name, s.name_alias, s.email, s.town, s.zip, s.fk_pays as country_id, s.client, s.code_client, s.status as company_status, s.logo as company_logo,';
$sql .= " typent.code as typent_code,"; $sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,"; $sql .= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,";
@ -263,7 +257,7 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; $sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
$sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.status, s.logo,';
$sql .= " typent.code,"; $sql .= " typent.code,";
$sql .= " state.code_departement, state.nom"; $sql .= " state.code_departement, state.nom";
// Add fields from extrafields // Add fields from extrafields
@ -341,7 +335,7 @@ if ($socid > 0)
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($sall != '') $param .= '&sall='.urlencode($sall); if ($sall != '') $param .= '&sall='.urlencode($sall);
if ($search_contract != '') $param .= '&search_contract='.urlencode($search_contract); if ($search_contract != '') $param .= '&search_contract='.urlencode($search_contract);
if ($search_name != '') $param .= '&search_name='.urlencode($search_name); if ($search_name != '') $param .= '&search_name='.urlencode($search_name);
@ -596,6 +590,10 @@ if (!empty($arrayfields['status']['checked'])) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
$totalarray = array();
$typenArray = array();
$cacheCountryIDCode = array();
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
@ -608,6 +606,24 @@ while ($i < min($num, $limit))
if ($obj->socid > 0) { if ($obj->socid > 0) {
$result = $socstatic->fetch($obj->socid); $result = $socstatic->fetch($obj->socid);
} }
/*$socstatic->id = $obj->socid;
$socstatic->name = $obj->name;
$socstatic->name_alias = $obj->name_alias;
$socstatic->email = $obj->email;
$socstatic->status = $obj->company_status;
$socstatic->logo = $obj->logo;
$socstatic->country_id = $obj->country_id;
$socstatic->country_code = '';
$socstatic->country = '';*/
if ($obj->country_id > 0) {
if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) {
$tmparray = getCountry($obj->country_id, 'all');
$cacheCountryIDCode[$obj->country_id] = array('code'=> empty($tmparray['code']) ? '' : $tmparray['code'], 'label' => empty($tmparray['label']) ? '' : $tmparray['label']);
}
$socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code'];
$socstatic->country = $cacheCountryIDCode[$obj->country_id]['label'];
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -643,9 +659,8 @@ while ($i < min($num, $limit))
if (!empty($arrayfields['s.nom']['checked'])) if (!empty($arrayfields['s.nom']['checked']))
{ {
print '<td>'; print '<td>';
//print '<a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a>'; if ($obj->socid > 0) {
if ($obj->socid > 0) // TODO Use a cache for this string
{
print $socstatic->getNomUrl(1, ''); print $socstatic->getNomUrl(1, '');
} }
print '</td>'; print '</td>';
@ -680,8 +695,7 @@ while ($i < min($num, $limit))
if (!empty($arrayfields['country.code_iso']['checked'])) if (!empty($arrayfields['country.code_iso']['checked']))
{ {
print '<td class="center">'; print '<td class="center">';
$tmparray = getCountry($obj->fk_pays, 'all'); print $socstatic->country;
print $tmparray['label'];
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }

View File

@ -130,14 +130,8 @@ $arrayfields = array(
'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) 'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position'); $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');

View File

@ -261,7 +261,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete))
// Remove a line // Remove a line
if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
{ {
if (method_exists('deleteline', $object)) { if (method_exists($object, 'deleteline')) {
$result = $object->deleteline($user, $lineid); // For backward compatibility $result = $object->deleteline($user, $lineid); // For backward compatibility
} else { } else {
$result = $object->deleteLine($user, $lineid); $result = $object->deleteLine($user, $lineid);

View File

@ -61,9 +61,9 @@ class box_funnel_of_prospection extends ModeleBoxes
$this->db = $db; $this->db = $db;
$this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1); // Not enabled by default, still need some work $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1 ? 1 : 0); // Not enabled by default, still need some work
$this->hidden = !($user->rights->projet->lire); $this->hidden = empty($user->rights->projet->lire);
} }
/** /**

View File

@ -71,7 +71,7 @@ class box_scheduled_jobs extends ModeleBoxes
*/ */
public function loadBox($max = 5) public function loadBox($max = 5)
{ {
global $user, $langs, $conf; global $user, $langs, $conf, $form;
$langs->load("cron"); $langs->load("cron");
$this->info_box_head = array('text' => $langs->trans("BoxScheduledJobs", $max)); $this->info_box_head = array('text' => $langs->trans("BoxScheduledJobs", $max));
@ -117,7 +117,7 @@ class box_scheduled_jobs extends ModeleBoxes
$cronstatic->getNomUrl(1), $cronstatic->getNomUrl(1),
$cronstatic->datelastrun, $cronstatic->datelastrun,
$cronstatic->status, $cronstatic->status,
$cronstatic->getLibStatut(2) $cronstatic->getLibStatut(3)
); );
$line++; $line++;
} }
@ -135,37 +135,37 @@ class box_scheduled_jobs extends ModeleBoxes
$cronstatic->getNomUrl(1), $cronstatic->getNomUrl(1),
$cronstatic->datenextrun, $cronstatic->datenextrun,
$cronstatic->status, $cronstatic->status,
$cronstatic->getLibStatut(2) $cronstatic->getLibStatut(3)
); );
} }
foreach ($resultarray as $line => $value) { foreach ($resultarray as $line => $value) {
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="left"', 'td' => 'class="tdoverflowmax200"',
'text' => $resultarray[$line][0] 'text' => $resultarray[$line][0]
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="left"', 'td' => 'class="nowraponall"',
'textnoformat' => $resultarray[$line][1] 'textnoformat' => $resultarray[$line][1]
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="right"', 'td' => 'class="right"',
'textnoformat' => dol_print_date($resultarray[$line][2], "dayhoursec") 'textnoformat' => (empty($resultarray[$line][2]) ? '' : $form->textwithpicto(dol_print_date($resultarray[$line][2], "dayhoursec"), $langs->trans("CurrentTimeZone")))
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="right" ', 'td' => 'class="center" ',
'textnoformat' => $resultarray[$line][4] 'textnoformat' => $resultarray[$line][4]
); );
$line++; $line++;
} }
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="left" colspan="2"', 'td' => 'class="tdoverflowmax300" colspan="3"',
'text' => $langs->trans("NumberScheduledJobError") 'text' => $langs->trans("NumberScheduledJobError")
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="right" colspan="2"', 'td' => 'class="center"',
'textnoformat' => ($nbjobsinerror ? '<span class="error"><a href="'.DOL_URL_ROOT.'/cron/list.php?search_lastresult='.urlencode('<>0').'">'.$nbjobsinerror.'</a></span>'.img_error() : '<span class="opacitymedium">'.$langs->trans("None").'<span>') 'textnoformat' => ($nbjobsinerror ? '<a href="'.DOL_URL_ROOT.'/cron/list.php?search_lastresult='.urlencode('<>0').'"><div class="badge badge-danger"><i class="fa fa-exclamation-triangle"></i> '.$nbjobsinerror.'</div></a>' : '<div class="center badge-status4">0</div>')
); );
} else { } else {
$this->info_box_contents[0][0] = array( $this->info_box_contents[0][0] = array(

View File

@ -56,7 +56,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
/** /**
* @var boolean Condition to have widget visible (in most cases, permissions) * @var boolean Condition to have widget visible (in most cases, permissions)
*/ */
public $hidden = 0; public $hidden = false;
/** /**
* @var int Box definition database ID * @var int Box definition database ID

View File

@ -162,9 +162,9 @@ class Ccountry // extends CommonObject
$sql .= " t.label,"; $sql .= " t.label,";
$sql .= " t.active"; $sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t";
if ($id) $sql .= " WHERE t.rowid = ".$id; if ($id) $sql .= " WHERE t.rowid = ".((int) $id);
elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape(strtoupper($code))."'";
elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape(strtoupper($code_iso))."'";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -174,11 +174,13 @@ class Ccountry // extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; if ($obj) {
$this->code = $obj->code; $this->id = $obj->rowid;
$this->code_iso = $obj->code_iso; $this->code = $obj->code;
$this->label = $obj->label; $this->code_iso = $obj->code_iso;
$this->active = $obj->active; $this->label = $obj->label;
$this->active = $obj->active;
}
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;

View File

@ -210,6 +210,11 @@ abstract class CommonObject
*/ */
public $ref_next; public $ref_next;
/**
* @var string Ref to store on object to save the new ref to use for example when making a validate() of an object
*/
public $newref;
/** /**
* @var int The object's status * @var int The object's status
* @see setStatut() * @see setStatut()
@ -350,7 +355,7 @@ abstract class CommonObject
public $last_main_doc; public $last_main_doc;
/** /**
* @var int Bank account ID * @var int Bank account ID sometimes, ID of record into llx_bank sometimes
* @deprecated * @deprecated
* @see $fk_account * @see $fk_account
*/ */
@ -2949,18 +2954,25 @@ abstract class CommonObject
// Special cas // Special cas
if ($this->table_element == 'product' && $newsuffix == '_private') $newsuffix = ''; if ($this->table_element == 'product' && $newsuffix == '_private') $newsuffix = '';
if (in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) {
$fieldusermod = "fk_user_mod";
} elseif ($this->table_element == 'ecm_files') {
$fieldusermod = "fk_user_m";
} else {
$fieldusermod = "fk_user_modif";
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL"); $sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL");
$sql .= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment')) ? "fk_user_mod" : "fk_user_modif")." = ".$user->id; $sql .= " ,".$fieldusermod." = ".$user->id;
$sql .= " WHERE rowid =".$this->id; $sql .= " WHERE rowid =".$this->id;
dol_syslog(get_class($this)."::update_note", LOG_DEBUG); dol_syslog(get_class($this)."::update_note", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql)) {
{ if ($suffix == '_public') {
if ($suffix == '_public') $this->note_public = $note; $this->note_public = $note;
elseif ($suffix == '_private') $this->note_private = $note; } elseif ($suffix == '_private') {
else { $this->note_private = $note;
} else {
$this->note = $note; // deprecated $this->note = $note; // deprecated
$this->note_private = $note; $this->note_private = $note;
} }
@ -3287,7 +3299,7 @@ abstract class CommonObject
/** /**
* Fetch array of objects linked to current object (object of enabled modules only). Links are loaded into * Fetch array of objects linked to current object (object of enabled modules only). Links are loaded into
* this->linkedObjectsIds array and * this->linkedObjectsIds array +
* this->linkedObjects array if $loadalsoobjects = 1 * this->linkedObjects array if $loadalsoobjects = 1
* Possible usage for parameters: * Possible usage for parameters:
* - all parameters empty -> we look all link to current object (current object can be source or target) * - all parameters empty -> we look all link to current object (current object can be source or target)
@ -3400,6 +3412,7 @@ abstract class CommonObject
{ {
// Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...)
$module = $element = $subelement = $objecttype; $module = $element = $subelement = $objecttype;
$regs = array();
if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier' if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier'
&& preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) && preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
{ {
@ -7154,20 +7167,20 @@ abstract class CommonObject
$dir = $sdir.'/'; $dir = $sdir.'/';
$pdir = '/'; $pdir = '/';
$dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; $dir .= get_exdir(0, 0, 0, 0, $this, $modulepart);
$pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; $pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart);
// For backward compatibility // For backward compatibility
if ($modulepart == 'product' && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) if ($modulepart == 'product') {
{ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
$dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/"; $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/";
$pdir = '/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/"; $pdir = '/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/";
}
} }
// Defined relative dir to DOL_DATA_ROOT // Defined relative dir to DOL_DATA_ROOT
$relativedir = ''; $relativedir = '';
if ($dir) if ($dir) {
{
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $dir); $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $dir);
$relativedir = preg_replace('/^[\\/]/', '', $relativedir); $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
$relativedir = preg_replace('/[\\/]$/', '', $relativedir); $relativedir = preg_replace('/[\\/]$/', '', $relativedir);
@ -7189,23 +7202,19 @@ abstract class CommonObject
completeFileArrayWithDatabaseInfo($filearray, $relativedir); completeFileArrayWithDatabaseInfo($filearray, $relativedir);
if (count($filearray)) if (count($filearray)) {
{ if ($sortfield && $sortorder) {
if ($sortfield && $sortorder)
{
$filearray = dol_sort_array($filearray, $sortfield, $sortorder); $filearray = dol_sort_array($filearray, $sortfield, $sortorder);
} }
foreach ($filearray as $key => $val) foreach ($filearray as $key => $val) {
{
$photo = ''; $photo = '';
$file = $val['name']; $file = $val['name'];
//if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory //if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory
//if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) //if (dol_is_file($dir.$file) && image_format_supported($file) >= 0)
if (image_format_supported($file) >= 0) if (image_format_supported($file) >= 0) {
{
$nbphoto++; $nbphoto++;
$photo = $file; $photo = $file;
$viewfilename = $file; $viewfilename = $file;
@ -7242,12 +7251,9 @@ abstract class CommonObject
$alt .= ' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; $alt .= ' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
if ($notitle) $alt = ''; if ($notitle) $alt = '';
if ($usesharelink) if ($usesharelink) {
{ if ($val['share']) {
if ($val['share']) if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) {
{
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
{
$return .= '<!-- Show original file (thumb not yet available with shared links) -->'; $return .= '<!-- Show original file (thumb not yet available with shared links) -->';
$return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
} else { } else {
@ -7259,10 +7265,9 @@ abstract class CommonObject
$return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">'; $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">';
} }
} else { } else {
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) {
{
$return .= '<!-- Show thumb -->'; $return .= '<!-- Show thumb -->';
$return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; $return .= '<img class="photo photowithmargin maxwidth150onsmartphone" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
} else { } else {
$return .= '<!-- Show original file -->'; $return .= '<!-- Show original file -->';
$return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';

View File

@ -52,9 +52,11 @@ class Conf
public $disable_compute; public $disable_compute;
//! Used to store current currency (ISO code like 'USD', 'EUR', ...) //! Used to store current currency (ISO code like 'USD', 'EUR', ...)
public $currency; public $currency;
//! Used to store current css (from theme) //! Used to store current css (from theme)
public $theme; // Contains current theme ("eldy", "auguria", ...) public $theme; // Contains current theme ("eldy", "auguria", ...)
public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
//! Used to store current menu handler //! Used to store current menu handler
public $standard_menu; public $standard_menu;
// List of activated modules // List of activated modules
@ -98,6 +100,8 @@ class Conf
public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone
public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url
public $liste_limit;
/** /**
* Constructor * Constructor

View File

@ -891,7 +891,6 @@ class DolGraph
$color1 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]); $color1 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
$color2 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]); $color2 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
$this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 . '", "#' . $color2 . '"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' . "\n"; $this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 . '", "#' . $color2 . '"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' . "\n";
//$this->stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this
$this->stringtoshow .= '});' . "\n"; $this->stringtoshow .= '});' . "\n";
$this->stringtoshow .= '}' . "\n"; $this->stringtoshow .= '}' . "\n";
} }
@ -1215,6 +1214,7 @@ class DolGraph
} else { } else {
$textoflegend = $this->Legend[$i]; $textoflegend = $this->Legend[$i];
} }
if ($usecolorvariantforgroupby) { if ($usecolorvariantforgroupby) {
$newcolor = $this->datacolor[$arrayofgroupslegend[$i]['stacknum']]; $newcolor = $this->datacolor[$arrayofgroupslegend[$i]['stacknum']];
// If we change the stack // If we change the stack
@ -1243,6 +1243,7 @@ class DolGraph
$bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')'; $bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')';
} else { // We do not use a 'group by' } else { // We do not use a 'group by'
if ($isfunnel) { if ($isfunnel) {
$bordercolor == 'null';
if (is_array($this->datacolor[$i])) { if (is_array($this->datacolor[$i])) {
$color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; // If datacolor is array(R, G, B) $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; // If datacolor is array(R, G, B)
} else { } else {
@ -1262,9 +1263,9 @@ class DolGraph
if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123' if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123'
else $bordercolor = 'null'; // If $val is '123' or '#123' else $bordercolor = 'null'; // If $val is '123' or '#123'
} }
$bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'";
} }
} }
$bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'";
} else { } else {
$color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].', 0.9)'; $color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].', 0.9)';
$bordercolor = $color; $bordercolor = $color;

View File

@ -991,32 +991,23 @@ class ExtraFields
else return ''; else return '';
} }
if (empty($morecss)) if (empty($morecss)) {
{ if ($type == 'date') {
if ($type == 'date')
{
$morecss = 'minwidth100imp'; $morecss = 'minwidth100imp';
} elseif ($type == 'datetime' || $type == 'link') } elseif ($type == 'datetime' || $type == 'link') {
{
$morecss = 'minwidth200imp'; $morecss = 'minwidth200imp';
} elseif (in_array($type, array('int', 'integer', 'double', 'price'))) } elseif (in_array($type, array('int', 'integer', 'double', 'price'))) {
{
$morecss = 'maxwidth75'; $morecss = 'maxwidth75';
} elseif ($type == 'password') } elseif ($type == 'password') {
{
$morecss = 'maxwidth100'; $morecss = 'maxwidth100';
} elseif ($type == 'url') } elseif ($type == 'url') {
{
$morecss = 'minwidth400'; $morecss = 'minwidth400';
} elseif ($type == 'boolean') } elseif ($type == 'boolean') {
{
$morecss = ''; $morecss = '';
} else { } else {
if (round($size) < 12) if (empty($size) || round($size) < 12) {
{
$morecss = 'minwidth100'; $morecss = 'minwidth100';
} elseif (round($size) <= 48) } elseif (round($size) <= 48) {
{
$morecss = 'minwidth200'; $morecss = 'minwidth200';
} else { } else {
$morecss = 'minwidth400'; $morecss = 'minwidth400';
@ -1024,8 +1015,7 @@ class ExtraFields
} }
} }
if (in_array($type, array('date', 'datetime'))) if (in_array($type, array('date', 'datetime'))) {
{
$tmp = explode(',', $size); $tmp = explode(',', $size);
$newsize = $tmp[0]; $newsize = $tmp[0];

View File

@ -3611,15 +3611,14 @@ class Form
* *
* @param string $selected Id pre-selectionne * @param string $selected Id pre-selectionne
* @param string $htmlname Nom de la zone select * @param string $htmlname Nom de la zone select
* @param string $addjscombo Add js combo
* @return string Code of HTML select to chose tax or not * @return string Code of HTML select to chose tax or not
*/ */
public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type', $addjscombo = 0)
{ {
global $langs; global $langs;
$return = ''; $return = '<select class="flat maxwidth100" id="select_'.$htmlname.'" name="'.$htmlname.'">';
$return .= '<select class="flat maxwidth75" id="select_'.$htmlname.'" name="'.$htmlname.'">';
$options = array( $options = array(
'HT'=>$langs->trans("HT"), 'HT'=>$langs->trans("HT"),
'TTC'=>$langs->trans("TTC") 'TTC'=>$langs->trans("TTC")
@ -3635,6 +3634,7 @@ class Form
$return .= '</option>'; $return .= '</option>';
} }
$return .= '</select>'; $return .= '</select>';
if ($addjscombo) $return .= ajax_combobox('select_'.$htmlname);
return $return; return $return;
} }
@ -3939,13 +3939,16 @@ class Form
* @param string $moreattrib To add more attribute on select * @param string $moreattrib To add more attribute on select
* @param int $showcurrency Show currency in label * @param int $showcurrency Show currency in label
* @param string $morecss More CSS * @param string $morecss More CSS
* @param int $nooutput 1=Return string, do not send to output
* @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...)
*/ */
public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '', $nooutput = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs, $conf; global $langs, $conf;
$out = '';
$langs->load("admin"); $langs->load("admin");
$num = 0; $num = 0;
@ -3964,10 +3967,10 @@ class Form
$i = 0; $i = 0;
if ($num) if ($num)
{ {
print '<select id="select'.$htmlname.'" class="flat selectbankaccount'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>'; $out .= '<select id="select'.$htmlname.'" class="flat selectbankaccount'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
if ($useempty == 1 || ($useempty == 2 && $num > 1)) if ($useempty == 1 || ($useempty == 2 && $num > 1))
{ {
print '<option value="-1">&nbsp;</option>'; $out .= '<option value="-1">&nbsp;</option>';
} }
while ($i < $num) while ($i < $num)
@ -3975,26 +3978,30 @@ class Form
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected)))
{ {
print '<option value="'.$obj->rowid.'" selected>'; $out .= '<option value="'.$obj->rowid.'" selected>';
} else { } else {
print '<option value="'.$obj->rowid.'">'; $out .= '<option value="'.$obj->rowid.'">';
} }
print trim($obj->label); $out .= trim($obj->label);
if ($showcurrency) print ' ('.$obj->currency_code.')'; if ($showcurrency) $out .= ' ('.$obj->currency_code.')';
if ($status == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')'; if ($status == 2 && $obj->status == 1) $out .= ' ('.$langs->trans("Closed").')';
print '</option>'; $out .= '</option>';
$i++; $i++;
} }
print "</select>"; $out .= "</select>";
print ajax_combobox('select'.$htmlname); $out .= ajax_combobox('select'.$htmlname);
} else { } else {
if ($status == 0) print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>'; if ($status == 0) $out .= '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
else print '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>'; else $out .= '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
} }
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
// Output or return
if (empty($nooutput)) print $out;
else return $out;
return $num; return $num;
} }
@ -4709,7 +4716,7 @@ class Form
$ret .= '<tr><td>'; $ret .= '<tr><td>';
$ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0); $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0);
$ret .= '</td>'; $ret .= '</td>';
$ret .= '<td class="left"><input type="submit smallpaddingimp" class="button" value="'.$langs->trans("Modify").'"></td>'; $ret .= '<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans("Modify").'"></td>';
$ret .= '</tr></table></form>'; $ret .= '</tr></table></form>';
} else { } else {
if ($displayhour) $ret .= dol_print_date($selected, 'dayhour'); if ($displayhour) $ret .= dol_print_date($selected, 'dayhour');
@ -6259,12 +6266,6 @@ class Form
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
if (!$forcecombo)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode);
}
// Construct $out and $outarray // Construct $out and $outarray
$out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n"; $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n";
@ -6310,6 +6311,11 @@ class Form
} }
$out .= '</select>'."\n"; $out .= '</select>'."\n";
if (!$forcecombo) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode);
}
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }

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