Merge branch 'develop' into email_smtp_allow_auto_signed
This commit is contained in:
commit
1f5f784b75
@ -15,6 +15,10 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* Rename property $paiementid in API api_supplier_invoices into $payment_mode_id
|
||||
* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in
|
||||
your email templates.
|
||||
* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom
|
||||
days of holiday.
|
||||
* Property num_paiement has been renamed num_payment everywhere for better code consistency.
|
||||
|
||||
|
||||
***** ChangeLog for 12.0.2 compared to 12.0.1 *****
|
||||
FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet
|
||||
|
||||
@ -65,9 +65,9 @@ No vulnerability disclosure, including partial is allowed for the moment.
|
||||
ONLY vulnerabilities discovered, when the following setup on tested platform is used, are accepted:
|
||||
|
||||
* $dolibarr_main_prod must be set to 1 into conf.php
|
||||
* $dolibarr_nocsrfcheck must be kept to the default value 1 into conf.php
|
||||
* $dolibarr_nocsrfcheck must be kept to the value 1 into conf.php (this is the default value)
|
||||
* The module DebugBar must NOT be enabled (by default, this module is not enabled)
|
||||
* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be switched soon to 1 by default)
|
||||
* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be enabled soon by default)
|
||||
* ONLY security reports on "stable" modules are allowed (troubles into "experimental" and "developement" modules are not accepted).
|
||||
|
||||
Scope is the web application (back office) and the APIs.
|
||||
@ -93,11 +93,9 @@ Scope is the web application (back office) and the APIs.
|
||||
* "Self" XSS
|
||||
* Missing cookie flags
|
||||
* SSL/TLS best practices
|
||||
* Mixed content warnings
|
||||
* Denial of Service attacks
|
||||
* Clickjacking/UI redressing
|
||||
* Physical or social engineering attempts
|
||||
* Recently disclosed 0-day vulnerabilities
|
||||
* Presence of autocomplete attribute on web forms
|
||||
* Vulnerabilities affecting outdated browsers or platforms
|
||||
* Issues that require physical access to a victim’s computer/device
|
||||
|
||||
36
build/README
36
build/README
@ -19,30 +19,34 @@ Note: Prerequisites to build autoexe DoliWamp package:
|
||||
> Launch "wine cmd" to check a drive Z: pointing to / exists.
|
||||
> Install InnoSetup
|
||||
For example by running isetup-5.3.9.exe (http://www.jrsoftware.org)
|
||||
> Install WampServer into "C:\Program Files\Wamp"
|
||||
For example by running wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe (http://www.wampserver.com)
|
||||
> Install WampServer addon to have versions: Mysql5.0.45
|
||||
For example by running WampServer2-MYSQL5045.exe (http://www.wampserver.com)
|
||||
> To build from Windows (running from makepack-dolibarr.pl script is however
|
||||
recommanded), open file build/exe/doliwamp.iss and click on button "Compile".
|
||||
The .exe file will be build into directory build.
|
||||
> Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB
|
||||
For example by running wampserver3.2.0_x64.exe (http://www.wampserver.com). See file build/exe/doliwamp.iss to know the doliwamp version currently setup.
|
||||
> Add path to ISCC into PATH windows var:
|
||||
Launch wine cmd, then regedit and add entry int HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATH
|
||||
> To build manually the .exe from Windows (running from makepack-dolibarr.pl script is however recommanded),
|
||||
open file build/exe/doliwamp.iss and click on button "Compile".
|
||||
The .exe file will be build into directory build.
|
||||
|
||||
|
||||
|
||||
- To build a theme package, launch the script
|
||||
> perl makepack-dolibarrtheme.pl
|
||||
|
||||
|
||||
|
||||
- To build a package for a module, launch the script
|
||||
> perl makepack-dolibarrmodule.pl
|
||||
|
||||
|
||||
|
||||
- To build developper documentation, launch the script
|
||||
> perl dolibarr-doxygen-build.pl
|
||||
|
||||
|
||||
|
||||
Note:
|
||||
The build directory and all its contents is absolutely not required to make
|
||||
Dolibarr working. It is here only to build Dolibarr packages, and those
|
||||
generated packages will not contains this "build" directory.
|
||||
The build directory and all its contents is absolutely not required to make Dolibarr working.
|
||||
It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory.
|
||||
|
||||
|
||||
You can find in "build", following sub-directories:
|
||||
@ -59,6 +63,9 @@ To build Mac OS package (not ready yet).
|
||||
* doap:
|
||||
To build Doap descriptor to promote/describe Dolibarr releases.
|
||||
|
||||
* docker:
|
||||
To deploy Dolibarr with docker.
|
||||
|
||||
* doxygen:
|
||||
Dir with config file to build doxygen documentation.
|
||||
|
||||
@ -66,12 +73,12 @@ Dir with config file to build doxygen documentation.
|
||||
To build exe package for Windows that distribute Dolibarr sources or
|
||||
to build the complete DoliWamp package.
|
||||
|
||||
* gource:
|
||||
To build the video of history of git changes.
|
||||
|
||||
* launchpad:
|
||||
Doc file to explain how to use launchpad.
|
||||
|
||||
* live:
|
||||
Doc file to explain how to create a demo live CD.
|
||||
|
||||
* obs:
|
||||
Doc file to explain how to push release onto OBS.
|
||||
|
||||
@ -90,5 +97,8 @@ To build Redhat, Opensuse or Mandriva package.
|
||||
* tgz:
|
||||
To build a tgz package.
|
||||
|
||||
* travis-ci:
|
||||
Used by travis to make CI.
|
||||
|
||||
* zip:
|
||||
To build a zip package.
|
||||
|
||||
@ -1,38 +1,50 @@
|
||||
FROM php:7.2-apache
|
||||
FROM php:7.3-apache
|
||||
|
||||
ENV HOST_USER_ID 33
|
||||
ENV PHP_INI_DATE_TIMEZONE 'UTC'
|
||||
ENV PHP_INI_MEMORY_LIMIT 256M
|
||||
|
||||
RUN apt-get update && apt-get install -y libpng16-16 libpng-dev libjpeg62-turbo libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++\
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
|
||||
&& docker-php-ext-install gd \
|
||||
&& docker-php-ext-install zip \
|
||||
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
|
||||
&& docker-php-ext-install ldap \
|
||||
&& docker-php-ext-install mysqli \
|
||||
&& docker-php-ext-install calendar \
|
||||
&& docker-php-ext-configure intl \
|
||||
&& docker-php-ext-install intl \
|
||||
&& apt-get autoremove --purge -y libpng-dev libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++
|
||||
RUN apt-get update -y \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libjpeg62-turbo \
|
||||
libpng-dev \
|
||||
libpng16-16 \
|
||||
libldap2-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev \
|
||||
zlib1g-dev \
|
||||
libicu-dev \
|
||||
g++ \
|
||||
default-mysql-client \
|
||||
unzip \
|
||||
curl \
|
||||
apt-utils \
|
||||
&& apt-get autoremove -y \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
|
||||
&& docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \
|
||||
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
|
||||
&& docker-php-ext-install -j$(nproc) ldap && \
|
||||
mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini
|
||||
|
||||
RUN mkdir /var/documents
|
||||
RUN chown www-data /var/documents
|
||||
RUN chown www-data:www-data /var/documents
|
||||
|
||||
COPY docker-run.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-run.sh
|
||||
|
||||
RUN pecl install xdebug && docker-php-ext-enable xdebug
|
||||
RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.remote_autostart=0' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.default_enable=0' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.remote_host=docker.host' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.remote_port=9000' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.remote_connect_back=0' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.profiler_enable=0' >> /usr/local/etc/php/php.ini
|
||||
RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> /usr/local/etc/php/php.ini
|
||||
RUN echo '172.17.0.1 docker.host' >> /etc/hosts
|
||||
RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"' >> ${PHP_INI_DIR}/php.ini
|
||||
RUN echo 'xdebug.remote_autostart=1' >> ${PHP_INI_DIR}/php.ini
|
||||
RUN echo 'xdebug.remote_enable=1' >> ${PHP_INI_DIR}/php.ini
|
||||
RUN echo 'xdebug.default_enable=1' >> ${PHP_INI_DIR}/php.ini
|
||||
#RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini
|
||||
RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini
|
||||
RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini
|
||||
RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini
|
||||
RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini
|
||||
#RUN echo '172.17.0.1 docker.host' >> /etc/hosts
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
# How to use it ?
|
||||
|
||||
The docker-compose.yml file is used to build and run Dolibarr in the current workspace.
|
||||
This docker image intended for developpement usage.
|
||||
For production usage you should consider other contributor reference like https://hub.docker.com/r/tuxgasy/dolibarr
|
||||
|
||||
Before build/run, define the variable HOST_USER_ID as following:
|
||||
|
||||
@ -26,3 +28,4 @@ The URL to go to PhpMyAdmin is (login/password is root/root) :
|
||||
|
||||
Setup the database connection during the installation process, please use mariad
|
||||
b (name of the database container) as database host.
|
||||
Setup documents folder, during the installation process, to /var/documents
|
||||
|
||||
@ -1,32 +1,51 @@
|
||||
mariadb:
|
||||
build: mariadb
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: dolibarr
|
||||
version: '3'
|
||||
|
||||
phpmyadmin:
|
||||
image: phpmyadmin/phpmyadmin
|
||||
environment:
|
||||
PMA_HOST: mariadb
|
||||
links:
|
||||
- mariadb
|
||||
ports:
|
||||
- "8080:80"
|
||||
networks:
|
||||
internal-pod:
|
||||
internal: true
|
||||
external-pod:
|
||||
internal: false
|
||||
|
||||
web:
|
||||
build: .
|
||||
environment:
|
||||
HOST_USER_ID: $HOST_USER_ID
|
||||
volumes:
|
||||
- ../../htdocs:/var/www/html
|
||||
links:
|
||||
- mariadb
|
||||
- mail
|
||||
ports:
|
||||
- "80:80"
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:latest
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: dolibarr
|
||||
networks:
|
||||
- internal-pod
|
||||
|
||||
mail:
|
||||
image: maildev/maildev
|
||||
ports:
|
||||
- "8081:80"
|
||||
- "25:25"
|
||||
phpmyadmin:
|
||||
image: phpmyadmin/phpmyadmin
|
||||
environment:
|
||||
PMA_HOST: mariadb
|
||||
depends_on:
|
||||
- mariadb
|
||||
ports:
|
||||
- "8080:80"
|
||||
networks:
|
||||
- internal-pod
|
||||
- external-pod
|
||||
|
||||
web:
|
||||
build: .
|
||||
environment:
|
||||
HOST_USER_ID: $HOST_USER_ID
|
||||
volumes:
|
||||
- ../../htdocs:/var/www/html/
|
||||
- ../../documents:/var/documents
|
||||
ports:
|
||||
- "80:80"
|
||||
- "9000:9000"
|
||||
depends_on:
|
||||
- mariadb
|
||||
- mail
|
||||
networks:
|
||||
- internal-pod
|
||||
- external-pod
|
||||
|
||||
mail:
|
||||
image: maildev/maildev
|
||||
ports:
|
||||
- "8081:80"
|
||||
- "25:25"
|
||||
|
||||
@ -1,15 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
usermod -u $HOST_USER_ID www-data
|
||||
groupmod -g $HOST_USER_ID www-data
|
||||
usermod -u ${HOST_USER_ID} www-data
|
||||
groupmod -g ${HOST_USER_ID} www-data
|
||||
|
||||
chgrp -hR www-data /var/www/html
|
||||
chmod g+rwx /var/www/html/conf
|
||||
|
||||
if [ ! -d /var/documents ]; then
|
||||
echo "[docker-run] => create volume directory /var/documents ..."
|
||||
mkdir -p /var/documents
|
||||
fi
|
||||
echo "[docker-run] => Set Permission to www-data for /var/documents"
|
||||
chown -R www-data:www-data /var/documents
|
||||
|
||||
if [ ! -f /usr/local/etc/php/php.ini ]; then
|
||||
cat <<EOF > /usr/local/etc/php/php.ini
|
||||
date.timezone = $PHP_INI_DATE_TIMEZONE
|
||||
display_errors = On
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ It's a dedicated Dolibarr version for Windows newbies with no technical knowledg
|
||||
|
||||
This directory contains files used by *makepack-dolibarr.pl* script to build the all-in-on .EXE package DoliWamp, ready
|
||||
to be distributed (for Windows).
|
||||
The build of .exe files need to have some windows executable files already installed (Apache, MariaDb). The package to install to get this files are defined into the file *doliwamp.iss* (searhc line starting with "; Value OK:")
|
||||
|
||||
If you have technical knowledge in web administration and plan to share your server instance (Apache, Mysql or PHP) with other projects than Dolibarr or want to use Dolibarr other components (PostgreSQL), you should not use this assistant and make a manual installation of Dolibarr on your existing server by downloading the standard package (.tgz or .zip file).
|
||||
|
||||
|
||||
@ -104,8 +104,8 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi
|
||||
; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45
|
||||
; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45
|
||||
; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe)
|
||||
; Value To test: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe)
|
||||
Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange"
|
||||
; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe)
|
||||
Source: "C:\wamp64\apps\phpmyadmin4.9.2\*.*"; DestDir: "{app}\apps\phpmyadmin4.9.2"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange"
|
||||
;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log"
|
||||
Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log"
|
||||
;Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log"
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
To make htmldoc working from wiki.dolibarr.org, them must be modified to have
|
||||
To make htmldoc working from wiki.dolibarr.org, the wiki must be modified to have
|
||||
|
||||
$_SERVER["HTTP_USER_AGENT"] is "HTMLDOC/x.y.z"
|
||||
$_COOKIE["htmldoc"] may also be defined if set on command line.
|
||||
|
||||
To disable part, add
|
||||
class="htmldoc-ignore" with css
|
||||
To disable part of content, add:
|
||||
class="htmldoc-ignore"
|
||||
with css
|
||||
.htmldoc-ignore { display: none; }
|
||||
|
||||
Note:
|
||||
$_SERVER["HTTP_USER_AGENT"] is "HTMLDOC/x.y.z"
|
||||
$_COOKIE["htmldoc"] may also be defined if set on command line.
|
||||
|
||||
@ -1 +1 @@
|
||||
http://wiki.dolibarr.org/
|
||||
https://wiki.dolibarr.org/
|
||||
|
||||
@ -390,7 +390,7 @@ if ($resql)
|
||||
if (!empty($arrayfields['aa.account_number']['checked']))
|
||||
{
|
||||
print "<td>";
|
||||
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1);
|
||||
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard');
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -44,6 +44,8 @@ $cancel = GETPOST('cancel', 'alpha');
|
||||
$accountingaccount = GETPOST('accountingaccount', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if (!$user->rights->accounting->chartofaccount) accessforbidden();
|
||||
|
||||
|
||||
$object = new AccountingAccount($db);
|
||||
|
||||
@ -75,7 +75,7 @@ if ($mysoc->isInEEC()) {
|
||||
$list_account[] = 'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT';
|
||||
}
|
||||
$list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT';
|
||||
$list_account[] = '---Other---';
|
||||
$list_account[] = '---Others---';
|
||||
$list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT';
|
||||
$list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT';
|
||||
$list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT';
|
||||
@ -94,6 +94,9 @@ if ($conf->loan->enabled) {
|
||||
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST';
|
||||
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE';
|
||||
}
|
||||
if ($conf->societe->enabled) {
|
||||
$list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT';
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
||||
@ -297,12 +297,12 @@ print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
@ -310,12 +310,12 @@ print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
@ -385,9 +385,9 @@ foreach ($list_binding as $key)
|
||||
if ($key == 'ACCOUNTING_DATE_START_BINDING') {
|
||||
print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1);
|
||||
} elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
|
||||
$array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
|
||||
print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER)?$conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER:0));
|
||||
} else {
|
||||
$array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
|
||||
print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0));
|
||||
} else {
|
||||
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
|
||||
}
|
||||
|
||||
|
||||
@ -252,8 +252,8 @@ if ($action != 'export_csv')
|
||||
print $langs->trans('to');
|
||||
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
|
||||
print '</td>';
|
||||
print '<td class="liste_titre right">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print '<td class="liste_titre center">';
|
||||
$searchpicto = $form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
|
||||
@ -276,8 +276,12 @@ if ($action != 'export_csv')
|
||||
|
||||
$accountingaccountstatic = new AccountingAccount($db);
|
||||
|
||||
$sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity;
|
||||
$sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte";
|
||||
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
|
||||
$sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features
|
||||
$sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'";
|
||||
$sql .= " GROUP BY t.numero_compte";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
$nrows = $resql->num_rows;
|
||||
$opening_balances = array();
|
||||
@ -290,7 +294,7 @@ if ($action != 'export_csv')
|
||||
{
|
||||
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
|
||||
if (!empty($accountingaccountstatic->account_number)) {
|
||||
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
|
||||
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
|
||||
} else {
|
||||
$accounting_account = length_accountg($line->numero_compte);
|
||||
}
|
||||
@ -340,7 +344,7 @@ if ($action != 'export_csv')
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Comptabilise le sous-total
|
||||
// Records the sub-total
|
||||
$sous_total_debit += $line->debit;
|
||||
$sous_total_credit += $line->credit;
|
||||
}
|
||||
|
||||
@ -809,8 +809,8 @@ class AccountancyExport
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
|
||||
$date_doc = dol_print_date($line->doc_date, '%Y%m%d');
|
||||
$date_valid = dol_print_date($line->date_validated, '%Y%m%d');
|
||||
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
|
||||
$date_validation = dol_print_date($line->date_validated, '%Y%m%d');
|
||||
|
||||
// FEC:JournalCode
|
||||
print $line->code_journal.$separator;
|
||||
@ -822,25 +822,25 @@ class AccountancyExport
|
||||
print $line->piece_num.$separator;
|
||||
|
||||
// FEC:EcritureDate
|
||||
print $date_creation.$separator;
|
||||
print $date_document . $separator;
|
||||
|
||||
// FEC:CompteNum
|
||||
print $line->numero_compte.$separator;
|
||||
|
||||
// FEC:CompteLib
|
||||
print $line->label_compte.$separator;
|
||||
print dol_string_unaccent($line->label_compte) . $separator;
|
||||
|
||||
// FEC:CompAuxNum
|
||||
print $line->subledger_account.$separator;
|
||||
|
||||
// FEC:CompAuxLib
|
||||
print $line->subledger_label.$separator;
|
||||
print dol_string_unaccent($line->subledger_label) . $separator;
|
||||
|
||||
// FEC:PieceRef
|
||||
print $line->doc_ref.$separator;
|
||||
|
||||
// FEC:PieceDate
|
||||
print $date_doc.$separator;
|
||||
print dol_string_unaccent($date_creation) . $separator;
|
||||
|
||||
// FEC:EcritureLib
|
||||
print $line->label_operation.$separator;
|
||||
@ -858,7 +858,7 @@ class AccountancyExport
|
||||
print $line->date_lettering.$separator;
|
||||
|
||||
// FEC:ValidDate
|
||||
print $date_valid.$separator;
|
||||
print $date_validation . $separator;
|
||||
|
||||
// FEC:Montantdevise
|
||||
print $line->multicurrency_amount.$separator;
|
||||
|
||||
@ -448,7 +448,7 @@ class AccountingAccount extends CommonObject
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label)
|
||||
* @param int $option 'bookkeeping', 'bookkeepinglistbyaccount', 'accountcard'
|
||||
* @param string $option 'bookkeeping', 'bookkeepinglistbyaccount', 'accountcard'
|
||||
* @return string String with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '')
|
||||
@ -460,12 +460,15 @@ class AccountingAccount extends CommonObject
|
||||
|
||||
$result = '';
|
||||
|
||||
if (empty($option)) {
|
||||
if (empty($option) || $option == 'bookkeeping') {
|
||||
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
|
||||
$labelurl = $langs->trans("ShowAccountingAccountInBookKeeping");
|
||||
} elseif ($option == 'bookkeepinglistbyaccount') {
|
||||
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
|
||||
$labelurl = $langs->trans("ShowAccountingAccountInBookKeepingByAccount");
|
||||
} elseif ($option == 'accountcard') {
|
||||
$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
|
||||
$labelurl = $langs->trans("ShowAccountingAccount");
|
||||
}
|
||||
|
||||
// Add param to save lastsearch_values or not
|
||||
@ -483,7 +486,7 @@ class AccountingAccount extends CommonObject
|
||||
$labeltoshow = $this->labelshort;
|
||||
}
|
||||
|
||||
$label = '<u>'.$langs->trans("ShowAccountingAccount").'</u>';
|
||||
$label = '<u>'.$labelurl.'</u>';
|
||||
if (!empty($this->account_number))
|
||||
$label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
|
||||
if (!empty($labeltoshow))
|
||||
@ -495,7 +498,7 @@ class AccountingAccount extends CommonObject
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$label = $langs->trans("ShowAccountingAccount");
|
||||
$label = $labelurl;
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
|
||||
@ -140,48 +140,48 @@ if (empty($reshook))
|
||||
|
||||
|
||||
if ($massaction == 'ventil') {
|
||||
$msg = '';
|
||||
$msg = '';
|
||||
|
||||
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (!empty($mesCasesCochees)) {
|
||||
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
|
||||
$msg .= '<div class="detail">';
|
||||
$cpt = 0;
|
||||
$ok = 0;
|
||||
$ko = 0;
|
||||
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (!empty($mesCasesCochees)) {
|
||||
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
|
||||
$msg .= '<div class="detail">';
|
||||
$cpt = 0;
|
||||
$ok = 0;
|
||||
$ko = 0;
|
||||
|
||||
foreach ($mesCasesCochees as $maLigneCochee) {
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monCompte = GETPOST('codeventil'.$monId);
|
||||
foreach ($mesCasesCochees as $maLigneCochee) {
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monCompte = GETPOST('codeventil'.$monId);
|
||||
|
||||
if ($monCompte <= 0)
|
||||
{
|
||||
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
|
||||
$ko++;
|
||||
} else {
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
|
||||
$sql .= " SET fk_code_ventilation = ".$monCompte;
|
||||
$sql .= " WHERE rowid = ".$monId;
|
||||
if ($monCompte <= 0)
|
||||
{
|
||||
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
|
||||
$ko++;
|
||||
} else {
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
|
||||
$sql .= " SET fk_code_ventilation = ".$monCompte;
|
||||
$sql .= " WHERE rowid = ".$monId;
|
||||
|
||||
$accountventilated = new AccountingAccount($db);
|
||||
$accountventilated->fetch($monCompte, '');
|
||||
$accountventilated = new AccountingAccount($db);
|
||||
$accountventilated->fetch($monCompte, '');
|
||||
|
||||
dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
|
||||
$ok++;
|
||||
} else {
|
||||
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></font></div>';
|
||||
$ko++;
|
||||
}
|
||||
}
|
||||
dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
|
||||
$ok++;
|
||||
} else {
|
||||
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></font></div>';
|
||||
$ko++;
|
||||
}
|
||||
}
|
||||
|
||||
$cpt++;
|
||||
}
|
||||
$msg .= '</div>';
|
||||
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
|
||||
}
|
||||
$cpt++;
|
||||
}
|
||||
$msg .= '</div>';
|
||||
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -199,8 +199,8 @@ if (empty($chartaccountcode))
|
||||
{
|
||||
print $langs->trans("ErrorChartOfAccountSystemNotSelected");
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
llxFooter();
|
||||
$db->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -236,28 +236,28 @@ if ($search_societe) {
|
||||
$sql .= natural_search('s.nom', $search_societe);
|
||||
}
|
||||
if ($search_lineid) {
|
||||
$sql .= natural_search("l.rowid", $search_lineid, 1);
|
||||
$sql .= natural_search("l.rowid", $search_lineid, 1);
|
||||
}
|
||||
if (strlen(trim($search_invoice))) {
|
||||
$sql .= natural_search("f.ref", $search_invoice);
|
||||
$sql .= natural_search("f.ref", $search_invoice);
|
||||
}
|
||||
if (strlen(trim($search_ref))) {
|
||||
$sql .= natural_search("p.ref", $search_ref);
|
||||
$sql .= natural_search("p.ref", $search_ref);
|
||||
}
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= natural_search("p.label", $search_label);
|
||||
$sql .= natural_search("p.label", $search_label);
|
||||
}
|
||||
if (strlen(trim($search_desc))) {
|
||||
$sql .= natural_search("l.description", $search_desc);
|
||||
$sql .= natural_search("l.description", $search_desc);
|
||||
}
|
||||
if (strlen(trim($search_amount))) {
|
||||
$sql .= natural_search("l.total_ht", $search_amount, 1);
|
||||
$sql .= natural_search("l.total_ht", $search_amount, 1);
|
||||
}
|
||||
if (strlen(trim($search_account))) {
|
||||
$sql .= natural_search("aa.account_number", $search_account);
|
||||
$sql .= natural_search("aa.account_number", $search_account);
|
||||
}
|
||||
if (strlen(trim($search_vat))) {
|
||||
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
|
||||
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
|
||||
}
|
||||
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
|
||||
if (strlen(trim($search_country))) {
|
||||
@ -295,13 +295,13 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
@ -336,9 +336,9 @@ if ($result) {
|
||||
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
|
||||
|
||||
$arrayofmassactions = array(
|
||||
'ventil'=>$langs->trans("Ventilate")
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
'ventil'=>$langs->trans("Ventilate")
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
|
||||
@ -376,8 +376,8 @@ if ($result) {
|
||||
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
|
||||
print '<td class="liste_titre center nowraponall minwidth100imp">';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
|
||||
}
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
|
||||
}
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
|
||||
$formother->select_year($search_year, 'search_year', 1, 20, 5);
|
||||
print '</td>';
|
||||
@ -425,7 +425,7 @@ if ($result) {
|
||||
|
||||
$isSellerInEEC = isInEEC($mysoc);
|
||||
|
||||
$accountingaccount_codetotid_cache = array();
|
||||
$accountingaccount_codetotid_cache = array();
|
||||
|
||||
while ($i < min($num_lines, $limit)) {
|
||||
$objp = $db->fetch_object($result);
|
||||
@ -464,29 +464,29 @@ if ($result) {
|
||||
$code_sell_p_notset = '';
|
||||
$objp->aarowid_suggest = ''; // Will be set later
|
||||
|
||||
$isBuyerInEEC = isInEEC($objp);
|
||||
$isBuyerInEEC = isInEEC($objp);
|
||||
|
||||
// Search suggested default account for product/service
|
||||
$suggestedaccountingaccountbydefaultfor = '';
|
||||
if ($objp->type_l == 1) {
|
||||
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = '';
|
||||
} else {
|
||||
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
|
||||
// Search suggested default account for product/service
|
||||
$suggestedaccountingaccountbydefaultfor = '';
|
||||
if ($objp->type_l == 1) {
|
||||
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = '';
|
||||
} else {
|
||||
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = 'eecwithvat';
|
||||
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
|
||||
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
|
||||
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = 'eec';
|
||||
} else { // Foreign sale
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = 'export';
|
||||
}
|
||||
}
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = 'eec';
|
||||
} else { // Foreign sale
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : '');
|
||||
$suggestedaccountingaccountbydefaultfor = 'export';
|
||||
}
|
||||
}
|
||||
} elseif ($objp->type_l == 0) {
|
||||
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
|
||||
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
|
||||
@ -512,28 +512,36 @@ if ($result) {
|
||||
// Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
|
||||
$suggestedaccountingaccountfor = '';
|
||||
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
|
||||
$objp->code_sell_p = $objp->code_sell;
|
||||
$objp->aarowid_suggest = $objp->aarowid;
|
||||
$suggestedaccountingaccountfor = '';
|
||||
} else {
|
||||
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
|
||||
$objp->code_sell_p = $objp->code_sell;
|
||||
$objp->aarowid_suggest = $objp->aarowid;
|
||||
$suggestedaccountingaccountfor = '';
|
||||
} else {
|
||||
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
|
||||
$objp->code_sell_p = $objp->code_sell;
|
||||
$objp->aarowid_suggest = $objp->aarowid;
|
||||
$suggestedaccountingaccountfor = 'eecwithvat';
|
||||
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
|
||||
$objp->code_sell_p = $objp->code_sell;
|
||||
$objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
|
||||
$suggestedaccountingaccountfor = 'eecwithoutvatnumber';
|
||||
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
|
||||
$objp->code_sell_p = $objp->code_sell;
|
||||
$objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
|
||||
$suggestedaccountingaccountfor = 'eecwithoutvatnumber';
|
||||
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
|
||||
$objp->code_sell_p = $objp->code_sell_intra;
|
||||
$objp->aarowid_suggest = $objp->aarowid_intra;
|
||||
$suggestedaccountingaccountfor = 'eec';
|
||||
} else { // Foreign sale
|
||||
$objp->code_sell_p = $objp->code_sell_export;
|
||||
$objp->aarowid_suggest = $objp->aarowid_export;
|
||||
$suggestedaccountingaccountfor = 'export';
|
||||
}
|
||||
}
|
||||
$objp->code_sell_p = $objp->code_sell_intra;
|
||||
$objp->aarowid_suggest = $objp->aarowid_intra;
|
||||
$suggestedaccountingaccountfor = 'eec';
|
||||
} else { // Foreign sale
|
||||
$objp->code_sell_p = $objp->code_sell_export;
|
||||
$objp->aarowid_suggest = $objp->aarowid_export;
|
||||
$suggestedaccountingaccountfor = 'export';
|
||||
}
|
||||
}
|
||||
|
||||
// Manage Deposit
|
||||
if ($objp->description == "(DEPOSIT)") {
|
||||
$accountdeposittoventilated = new AccountingAccount($db);
|
||||
$accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1);
|
||||
$objp->code_sell_l = $accountdeposittoventilated->ref;
|
||||
$objp->aarowid_suggest = $accountdeposittoventilated->rowid;
|
||||
}
|
||||
|
||||
if (!empty($objp->code_sell_p)) {
|
||||
// Value was defined previously
|
||||
@ -585,32 +593,32 @@ if ($result) {
|
||||
print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
|
||||
|
||||
// Country
|
||||
print '<td>';
|
||||
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
|
||||
print $labelcountry;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
|
||||
print $labelcountry;
|
||||
print '</td>';
|
||||
|
||||
print '<td>'.$objp->tva_intra.'</td>';
|
||||
|
||||
// Found accounts
|
||||
print '<td>';
|
||||
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
|
||||
$shelp = '';
|
||||
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
|
||||
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
|
||||
$s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>');
|
||||
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
|
||||
if ($objp->product_id > 0)
|
||||
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
|
||||
$shelp = '';
|
||||
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
|
||||
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
|
||||
$s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>');
|
||||
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
|
||||
if ($objp->product_id > 0)
|
||||
{
|
||||
print '<br>';
|
||||
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
|
||||
$shelp = '';
|
||||
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
|
||||
elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
|
||||
elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
|
||||
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
|
||||
$s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p));
|
||||
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
|
||||
print '<br>';
|
||||
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
|
||||
$shelp = '';
|
||||
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
|
||||
elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
|
||||
elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
|
||||
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
|
||||
$s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p));
|
||||
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
@ -264,7 +264,7 @@ if ($result) {
|
||||
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
|
||||
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
print '<td class="liste_titre center">';
|
||||
@ -287,7 +287,7 @@ if ($result) {
|
||||
print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
|
||||
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
@ -341,7 +341,7 @@ if ($result) {
|
||||
print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
|
||||
|
||||
// Date validation
|
||||
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
|
||||
}
|
||||
|
||||
|
||||
@ -303,7 +303,7 @@ if ($result) {
|
||||
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
|
||||
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
print '<td class="liste_titre center nowraponall minwidth100imp">';
|
||||
@ -327,7 +327,7 @@ if ($result) {
|
||||
print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
|
||||
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
@ -381,7 +381,7 @@ if ($result) {
|
||||
print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
|
||||
|
||||
// Date validation
|
||||
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
|
||||
print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
|
||||
}
|
||||
|
||||
|
||||
@ -144,48 +144,48 @@ if (empty($reshook))
|
||||
|
||||
|
||||
if ($massaction == 'ventil') {
|
||||
$msg = '';
|
||||
$msg = '';
|
||||
|
||||
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (!empty($mesCasesCochees)) {
|
||||
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
|
||||
$msg .= '<div class="detail">';
|
||||
$cpt = 0;
|
||||
$ok = 0;
|
||||
$ko = 0;
|
||||
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (!empty($mesCasesCochees)) {
|
||||
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
|
||||
$msg .= '<div class="detail">';
|
||||
$cpt = 0;
|
||||
$ok = 0;
|
||||
$ko = 0;
|
||||
|
||||
foreach ($mesCasesCochees as $maLigneCochee) {
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monCompte = GETPOST('codeventil'.$monId);
|
||||
foreach ($mesCasesCochees as $maLigneCochee) {
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monCompte = GETPOST('codeventil'.$monId);
|
||||
|
||||
if ($monCompte <= 0)
|
||||
{
|
||||
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
|
||||
$ko++;
|
||||
} else {
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = ".$monCompte;
|
||||
$sql .= " WHERE rowid = ".$monId;
|
||||
if ($monCompte <= 0)
|
||||
{
|
||||
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
|
||||
$ko++;
|
||||
} else {
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = ".$monCompte;
|
||||
$sql .= " WHERE rowid = ".$monId;
|
||||
|
||||
$accountventilated = new AccountingAccount($db);
|
||||
$accountventilated->fetch($monCompte, '');
|
||||
$accountventilated = new AccountingAccount($db);
|
||||
$accountventilated->fetch($monCompte, '');
|
||||
|
||||
dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
|
||||
$ok++;
|
||||
} else {
|
||||
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
|
||||
$ko++;
|
||||
}
|
||||
}
|
||||
dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
|
||||
$ok++;
|
||||
} else {
|
||||
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
|
||||
$ko++;
|
||||
}
|
||||
}
|
||||
|
||||
$cpt++;
|
||||
}
|
||||
$msg .= '</div>';
|
||||
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
|
||||
}
|
||||
$cpt++;
|
||||
}
|
||||
$msg .= '</div>';
|
||||
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -203,8 +203,8 @@ if (empty($chartaccountcode))
|
||||
{
|
||||
print $langs->trans("ErrorChartOfAccountSystemNotSelected");
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
llxFooter();
|
||||
$db->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -240,28 +240,28 @@ if ($search_societe) {
|
||||
$sql .= natural_search('s.nom', $search_societe);
|
||||
}
|
||||
if ($search_lineid) {
|
||||
$sql .= natural_search("l.rowid", $search_lineid, 1);
|
||||
$sql .= natural_search("l.rowid", $search_lineid, 1);
|
||||
}
|
||||
if (strlen(trim($search_invoice))) {
|
||||
$sql .= natural_search("f.ref", $search_invoice);
|
||||
$sql .= natural_search("f.ref", $search_invoice);
|
||||
}
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= natural_search("f.libelle", $search_label);
|
||||
}
|
||||
if (strlen(trim($search_ref))) {
|
||||
$sql .= natural_search("p.ref", $search_ref);
|
||||
$sql .= natural_search("p.ref", $search_ref);
|
||||
}
|
||||
if (strlen(trim($search_desc))) {
|
||||
$sql .= natural_search("l.description", $search_desc);
|
||||
$sql .= natural_search("l.description", $search_desc);
|
||||
}
|
||||
if (strlen(trim($search_amount))) {
|
||||
$sql .= natural_search("l.total_ht", $search_amount, 1);
|
||||
$sql .= natural_search("l.total_ht", $search_amount, 1);
|
||||
}
|
||||
if (strlen(trim($search_account))) {
|
||||
$sql .= natural_search("aa.account_number", $search_account);
|
||||
$sql .= natural_search("aa.account_number", $search_account);
|
||||
}
|
||||
if (strlen(trim($search_vat))) {
|
||||
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
|
||||
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
|
||||
}
|
||||
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
|
||||
if (strlen(trim($search_country))) {
|
||||
@ -299,13 +299,13 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
@ -337,9 +337,9 @@ if ($result) {
|
||||
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
|
||||
|
||||
$arrayofmassactions = array(
|
||||
'ventil'=>$langs->trans("Ventilate")
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
'ventil'=>$langs->trans("Ventilate")
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
|
||||
@ -572,12 +572,12 @@ if ($result) {
|
||||
print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
|
||||
|
||||
// Country
|
||||
print '<td>';
|
||||
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
|
||||
print $labelcountry;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
|
||||
print $labelcountry;
|
||||
print '</td>';
|
||||
|
||||
// VAT Num
|
||||
// VAT Num
|
||||
print '<td>'.$objp->tva_intra.'</td>';
|
||||
|
||||
// Found accounts
|
||||
|
||||
@ -1738,7 +1738,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
$genallowed = $user->rights->adherent->lire;
|
||||
$delallowed = $user->rights->adherent->creer;
|
||||
|
||||
print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object);
|
||||
print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object);
|
||||
$somethingshown = $formfile->numoffiles;
|
||||
|
||||
// Show links to link elements
|
||||
|
||||
@ -1724,7 +1724,7 @@ class Adherent extends CommonObject
|
||||
// Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
|
||||
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
|
||||
$invoice->generateDocument($invoice->modelpdf, $outputlangs);
|
||||
$invoice->generateDocument($invoice->model_pdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2257,8 +2257,8 @@ class Adherent extends CommonObject
|
||||
if (!dol_strlen($modele)) {
|
||||
$modele = 'standard';
|
||||
|
||||
if ($this->modelpdf) {
|
||||
$modele = $this->modelpdf;
|
||||
if ($this->model_pdf) {
|
||||
$modele = $this->model_pdf;
|
||||
} elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) {
|
||||
$modele = $conf->global->ADHERENT_ADDON_PDF;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ class AdherentStats extends Stats
|
||||
|
||||
$this->field = 'subscription';
|
||||
|
||||
$this->where .= " m.statut != 0";
|
||||
$this->where .= " m.statut != -1";
|
||||
$this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")";
|
||||
//if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->memberid) {
|
||||
|
||||
@ -293,7 +293,7 @@ class MembersTypes extends DolibarrApi
|
||||
unset($object->cond_reglement);
|
||||
unset($object->fk_delivery_address);
|
||||
unset($object->shipping_method_id);
|
||||
unset($object->modelpdf);
|
||||
unset($object->model_pdf);
|
||||
unset($object->fk_account);
|
||||
unset($object->note_public);
|
||||
unset($object->note_private);
|
||||
|
||||
@ -61,16 +61,16 @@ print load_fiche_titre($title, '', 'object_group');
|
||||
|
||||
dol_mkdir($dir);
|
||||
|
||||
$tab = 'byproperties';
|
||||
|
||||
$data = array();
|
||||
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code";
|
||||
|
||||
$sql = "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions,";
|
||||
$sql .= " MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate,";
|
||||
$sql .= " d.morphy as code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
$sql .= " AND d.statut = 1";
|
||||
$sql .= " AND d.statut != -1"; // Not draft
|
||||
$sql .= " GROUP BY d.morphy";
|
||||
|
||||
$foundphy = $foundmor = 0;
|
||||
|
||||
// Define $data array
|
||||
@ -85,7 +85,38 @@ if ($resql) {
|
||||
if ($obj->code == 'phy') $foundphy++;
|
||||
if ($obj->code == 'mor') $foundmor++;
|
||||
|
||||
$data[] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
|
||||
$data[$obj->code] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'nbsubscriptions'=>$obj->nbsubscriptions, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions,";
|
||||
$sql .= " MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate,";
|
||||
$sql .= " d.morphy as code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0)
|
||||
$sql .= " GROUP BY d.morphy";
|
||||
$foundphy = $foundmor = 0;
|
||||
|
||||
// Define $data array
|
||||
dol_syslog("Count member still active", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
if ($obj->code == 'phy') $foundphy++;
|
||||
if ($obj->code == 'mor') $foundmor++;
|
||||
|
||||
$data[$obj->code]['nbactive'] = $obj->nb;
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -102,30 +133,38 @@ dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'use
|
||||
|
||||
// Print title
|
||||
if (!count($data)) {
|
||||
print $langs->trans("NoValidatedMemberYet").'<br>';
|
||||
print '<span class="opacitymedium">'.$langs->trans("NoValidatedMemberYet").'</span><br>';
|
||||
print '<br>';
|
||||
} else {
|
||||
print $langs->trans("MembersByNature").'<br>';
|
||||
print '<span class="opacitymedium">'.$langs->trans("MembersByNature").'</span><br>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
// Print array
|
||||
print '<table class="liste centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Nature").'</td>';
|
||||
print '<td class="right">'.$langs->trans("NbOfMembers").'</td>';
|
||||
print '<td>'.$langs->trans("MemberNature").'</td>';
|
||||
print '<td class="right">'.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')</td>';
|
||||
print '<td class="right">'.$langs->trans("NbOfActiveMembers").'</td>';
|
||||
print '<td class="center">'.$langs->trans("LastMemberDate").'</td>';
|
||||
print '<td class="right">'.$langs->trans("NbOfSubscriptions").'</td>';
|
||||
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
||||
if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
||||
if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
||||
if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
||||
|
||||
foreach ($data as $val) {
|
||||
$nb = $val['nb'];
|
||||
$nbsubscriptions = $val['nbsubscriptions'];
|
||||
$nbactive = $val['nbactive'];
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$memberstatic->getmorphylib($val['label']).'</td>';
|
||||
print '<td class="right">'.$val['nb'].'</td>';
|
||||
print '<td class="right">'.$nb.'</td>';
|
||||
print '<td class="right">'.$nbactive.'</td>';
|
||||
print '<td class="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>';
|
||||
print '<td class="right">'.$nbsubscriptions.'</td>';
|
||||
print '<td class="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -74,12 +74,12 @@ if ($mode) {
|
||||
$tab = 'statscountry';
|
||||
|
||||
$data = array();
|
||||
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
|
||||
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
|
||||
$sql .= " FROM ".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."subscription as s ON s.fk_adherent = d.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
$sql .= " AND d.statut = 1";
|
||||
$sql .= " AND d.statut != -1";
|
||||
$sql .= " GROUP BY c.label, c.code";
|
||||
//print $sql;
|
||||
}
|
||||
@ -90,14 +90,14 @@ if ($mode) {
|
||||
$tab = 'statsstate';
|
||||
|
||||
$data = array();
|
||||
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
|
||||
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
$sql .= " AND d.statut = 1";
|
||||
$sql .= " AND d.statut != -1";
|
||||
$sql .= " GROUP BY co.label, co.code, c.nom";
|
||||
//print $sql;
|
||||
}
|
||||
@ -107,14 +107,14 @@ if ($mode) {
|
||||
$tab = 'statsregion'; //onglet
|
||||
|
||||
$data = array(); //tableau de donnée
|
||||
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
|
||||
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
$sql .= " AND d.statut = 1";
|
||||
$sql .= " AND d.statut != -1";
|
||||
$sql .= " GROUP BY co.label, co.code, r.nom"; //+
|
||||
//print $sql;
|
||||
}
|
||||
@ -124,12 +124,12 @@ if ($mode) {
|
||||
$tab = 'statstown';
|
||||
|
||||
$data = array();
|
||||
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
|
||||
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
|
||||
$sql .= " FROM ".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."subscription as s ON s.fk_adherent = d.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
$sql .= " AND d.statut = 1";
|
||||
$sql .= " AND d.statut != -1";
|
||||
$sql .= " GROUP BY c.label, c.code, d.town";
|
||||
//print $sql;
|
||||
}
|
||||
@ -204,12 +204,12 @@ if ($mode && !count($data)) {
|
||||
print $langs->trans("NoValidatedMemberYet").'<br>';
|
||||
print '<br>';
|
||||
} else {
|
||||
if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'<br>';
|
||||
elseif ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'<br>';
|
||||
elseif ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'<br>';
|
||||
elseif ($mode == 'memberbyregion') print $langs->trans("MembersByRegion").'<br>'; //+
|
||||
if ($mode == 'memberbycountry') print '<span class="opacitymedium">'.$langs->trans("MembersByCountryDesc").'</span><br>';
|
||||
elseif ($mode == 'memberbystate') print '<span class="opacitymedium">'.$langs->trans("MembersByStateDesc").'</span><br>';
|
||||
elseif ($mode == 'memberbytown') print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>';
|
||||
elseif ($mode == 'memberbyregion') print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>'; //+
|
||||
else {
|
||||
print $langs->trans("MembersStatisticsDesc").'<br>';
|
||||
print '<span class="opacitymedium">'.$langs->trans("MembersStatisticsDesc").'</span><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
|
||||
print '<br>';
|
||||
@ -277,7 +277,7 @@ if ($mode) {
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$label.'</td>';
|
||||
if ($label2) print '<td class="center">'.$label2.'</td>';
|
||||
print '<td class="right">'.$langs->trans("NbOfMembers").'</td>';
|
||||
print '<td class="right">'.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')</td>';
|
||||
print '<td class="center">'.$langs->trans("LastMemberDate").'</td>';
|
||||
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -176,9 +176,9 @@ foreach ($data as $val) {
|
||||
$oldyear--;
|
||||
print '<tr class="oddeven" height="24">';
|
||||
print '<td class="center">';
|
||||
print '<a href="month.php?year='.$oldyear.'&mode='.$mode.'">';
|
||||
//print '<a href="month.php?year='.$oldyear.'&mode='.$mode.'">';
|
||||
print $oldyear;
|
||||
print '</a>';
|
||||
//print '</a>';
|
||||
print '</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '<td class="right">0</td>';
|
||||
|
||||
@ -370,7 +370,7 @@ if ($rowid && $action != 'edit') {
|
||||
$genallowed = $user->rights->facture->lire;
|
||||
$delallowed = $user->rights->facture->creer;
|
||||
|
||||
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
$somethingshown = $formfile->numoffiles;
|
||||
*/
|
||||
// Show links to link elements
|
||||
|
||||
@ -51,147 +51,147 @@ $type = 'bankaccount';
|
||||
|
||||
// Order display of bank account
|
||||
if ($action == 'setbankorder') {
|
||||
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Auto report last num releve on conciliate
|
||||
if ($action == 'setreportlastnumreleve') {
|
||||
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
} elseif ($action == 'unsetreportlastnumreleve') {
|
||||
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Colorize movements
|
||||
if ($action == 'setbankcolorizemovement') {
|
||||
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
} elseif ($action == 'unsetbankcolorizemovement') {
|
||||
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
if ($actionsave)
|
||||
{
|
||||
$db->begin();
|
||||
$db->begin();
|
||||
|
||||
$i = 1; $errorsaved = 0;
|
||||
$error = 0;
|
||||
$i = 1; $errorsaved = 0;
|
||||
$error = 0;
|
||||
|
||||
// Save colors
|
||||
while ($i <= 2)
|
||||
{
|
||||
$color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha');
|
||||
if ($color == '-1') $color = '';
|
||||
// Save colors
|
||||
while ($i <= 2)
|
||||
{
|
||||
$color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha');
|
||||
if ($color == '-1') $color = '';
|
||||
|
||||
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) $error++;
|
||||
$i++;
|
||||
}
|
||||
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) $error++;
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
if ($modele == 'sepamandate') {
|
||||
$object = new CompanyBankAccount($db);
|
||||
} else {
|
||||
$object = new Account($db);
|
||||
}
|
||||
$object->initAsSpecimen();
|
||||
if ($modele == 'sepamandate') {
|
||||
$object = new CompanyBankAccount($db);
|
||||
} else {
|
||||
$object = new Account($db);
|
||||
}
|
||||
$object->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($object, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
if ($module->write_file($object, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
if ($action == 'set') {
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
} elseif ($action == 'del') {
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0) {
|
||||
if ($conf->global->BANKADDON_PDF == "$value")
|
||||
dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity);
|
||||
}
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0) {
|
||||
if ($conf->global->BANKADDON_PDF == "$value")
|
||||
dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity);
|
||||
}
|
||||
}
|
||||
// Set default model
|
||||
elseif ($action == 'setdoc') {
|
||||
if (dolibarr_set_const($db, "BANKADDON_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->BANKADDON_PDF = $value;
|
||||
}
|
||||
if (dolibarr_set_const($db, "BANKADDON_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->BANKADDON_PDF = $value;
|
||||
}
|
||||
|
||||
// On active le modele
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0) {
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
}
|
||||
// On active le modele
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0) {
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -670,12 +670,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// Clone
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=order">'.$langs->trans("ToClone").'</a></div>';
|
||||
|
||||
// Collect now
|
||||
if (count($object->actions) > 0) {
|
||||
// Collect now
|
||||
if (count($object->actions) > 0) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=collect">'.$langs->trans("CollectNow").'</a></div>';
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoOperations")).'">'.$langs->trans("CollectNow").'</a></div>';
|
||||
}
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoOperations")).'">'.$langs->trans("CollectNow").'</a></div>';
|
||||
}
|
||||
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>';
|
||||
}
|
||||
@ -705,7 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||
$genallowed = $user->rights->emailcollector->read; // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->rights->emailcollector->create; // If you can create/edit, you can remove a file on card
|
||||
print $formfile->showdocuments('emailcollector', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
print $formfile->showdocuments('emailcollector', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
*/
|
||||
/*
|
||||
// Show links to link elements
|
||||
|
||||
@ -35,13 +35,11 @@ $langs->loadLangs(array("admin", "trips", "errors", "other", "dict"));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
//Init error
|
||||
$error = false;
|
||||
$message = false;
|
||||
$error = 0;
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$id = GETPOST('id', 'int');
|
||||
$offset = GETPOST('offset', 'int');
|
||||
$ikoffset = GETPOST('ikoffset', 'int');
|
||||
$coef = GETPOST('coef', 'int');
|
||||
|
||||
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
|
||||
@ -59,10 +57,13 @@ if ($action == 'updateik')
|
||||
$expIk->setValues($_POST);
|
||||
$result = $expIk->create($user);
|
||||
|
||||
if ($result > 0) setEventMessages('SetupSaved', null, 'mesgs');
|
||||
|
||||
header('Location: '.$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
if ($result > 0) {
|
||||
setEventMessages('SetupSaved', null, 'mesgs');
|
||||
header('Location: '.$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($expIk->error, $expIk->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'delete') // TODO add confirm
|
||||
{
|
||||
$expIk = new ExpenseReportIk($db);
|
||||
@ -81,6 +82,7 @@ if ($action == 'updateik')
|
||||
|
||||
$rangesbycateg = ExpenseReportIk::getAllRanges();
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -90,12 +92,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup"));
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("ExpenseReportsIkSetup"), $linkback, 'title_setup');
|
||||
print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
|
||||
|
||||
$head = expensereport_admin_prepare_head();
|
||||
dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip');
|
||||
|
||||
echo $langs->trans('ExpenseReportIkDesc');
|
||||
echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportIkDesc').'</span>';
|
||||
print '<br><br>';
|
||||
|
||||
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
|
||||
|
||||
@ -136,21 +139,23 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
|
||||
echo '<tr class="oddeven">';
|
||||
|
||||
// Label
|
||||
echo '<td width="20%"><b>['.$langs->trans('RangeNum', $tranche++).']</b> - '.$label.'</td>';
|
||||
echo '<td class="nowraponall"><b>['.$langs->trans('RangeNum', $tranche++).']</b> - '.$label.'</td>';
|
||||
|
||||
// Offset
|
||||
echo '<td width="20%">';
|
||||
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" name="offset" value="'.$range->ik->offset.'" />';
|
||||
else echo $range->ik->offset;
|
||||
echo '<td class="nowraponall">';
|
||||
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" class="maxwidth100" name="ikoffset" value="'.$range->ik->ikoffset.'" />';
|
||||
else {
|
||||
echo $range->ik->ikoffset;
|
||||
}
|
||||
echo '</td>';
|
||||
// Coef
|
||||
echo '<td width="20%">';
|
||||
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" name="coef" value="'.$range->ik->coef.'" />';
|
||||
echo '<td class="nowraponall">';
|
||||
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" class="maxwidth100" name="coef" value="'.$range->ik->coef.'" />';
|
||||
else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined'));
|
||||
echo '</td>';
|
||||
|
||||
// Total for one
|
||||
echo '<td width="30%">'.$langs->trans('expenseReportPrintExample', price($range->ik->offset + 5 * $range->ik->coef)).'</td>';
|
||||
echo '<td class="nowraponall">'.$langs->trans('expenseReportPrintExample', price($range->ik->ikoffset + 5 * $range->ik->coef)).'</td>';
|
||||
|
||||
// Action
|
||||
echo '<td class="right">';
|
||||
@ -161,8 +166,8 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
|
||||
echo '<input id="" class="button" name="save" value="'.$langs->trans('Save').'" type="submit" />';
|
||||
echo '<input class="button" value="'.$langs->trans('Cancel').'" onclick="javascript:history.go(-1)" type="button" />';
|
||||
} else {
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$range->ik->id.'&fk_c_exp_tax_cat='.$range->fk_c_exp_tax_cat.'&fk_range='.$range->rowid.'">'.img_edit().'</a>';
|
||||
if (!empty($range->ik->id)) echo '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$range->ik->id.'">'.img_delete().'</a>';
|
||||
echo '<a class="editfielda marginrightonly paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$range->ik->id.'&fk_c_exp_tax_cat='.$range->fk_c_exp_tax_cat.'&fk_range='.$range->rowid.'">'.img_edit().'</a>';
|
||||
if (!empty($range->ik->id)) echo '<a class="paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$range->ik->id.'">'.img_delete().'</a>';
|
||||
// TODO add delete link
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,6 +138,7 @@ $rules = ExpenseReportRule::getAllRule();
|
||||
$tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User'));
|
||||
$tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense'));
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -147,12 +148,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup"));
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup');
|
||||
print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
|
||||
|
||||
$head = expensereport_admin_prepare_head();
|
||||
dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
|
||||
|
||||
echo $langs->trans('ExpenseReportRulesDesc');
|
||||
echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportRulesDesc').'</span>';
|
||||
print '<br><br>';
|
||||
|
||||
if ($action != 'edit')
|
||||
{
|
||||
@ -164,7 +166,7 @@ if ($action != 'edit')
|
||||
|
||||
echo '<tr class="liste_titre">';
|
||||
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportDomain').'</th>';
|
||||
echo '<th>'.$langs->trans('Type').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>';
|
||||
@ -184,7 +186,7 @@ if ($action != 'edit')
|
||||
echo '<td>'.$form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0).'</td>';
|
||||
echo '<td>'.$form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0).'</td>';
|
||||
echo '<td>'.$form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0).'</td>';
|
||||
echo '<td><input type="text" value="" name="amount" class="amount" />'.$conf->currency.'</td>';
|
||||
echo '<td><input type="text" value="" class="maxwidth100" name="amount" class="amount" /> '.$conf->currency.'</td>';
|
||||
echo '<td>'.$form->selectyesno('restrictive', 0, 1).'</td>';
|
||||
echo '<td class="right"><input type="submit" class="button" value="'.$langs->trans('Add').'" /></td>';
|
||||
echo '</tr>';
|
||||
@ -207,7 +209,7 @@ echo '<table class="noborder centpercent">';
|
||||
|
||||
echo '<tr class="liste_titre">';
|
||||
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportDomain').'</th>';
|
||||
echo '<th>'.$langs->trans('Type').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>';
|
||||
echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>';
|
||||
@ -300,11 +302,11 @@ foreach ($rules as $rule)
|
||||
echo '</td>';
|
||||
|
||||
|
||||
echo '<td>';
|
||||
echo '<td class="center">';
|
||||
if ($object->id != $rule->id)
|
||||
{
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$rule->id.'">'.img_edit().'</a> ';
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$rule->id.'">'.img_delete().'</a>';
|
||||
echo '<a class="editfielda paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$rule->id.'">'.img_edit().'</a> ';
|
||||
echo '<a class="paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$rule->id.'">'.img_delete().'</a>';
|
||||
} else {
|
||||
echo '<input type="submit" class="button" value="'.$langs->trans('Update').'" /> ';
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'" class="button">'.$langs->trans('Cancel').'</a>';
|
||||
|
||||
@ -280,14 +280,12 @@ if ($action == 'edit')
|
||||
print '<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO) ? $conf->global->MAIN_MAIL_FORCE_SENDTO : '').'" />';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
//Add user to select destinaries list
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>';
|
||||
print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', $conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT, 1);
|
||||
print '</td></tr>';
|
||||
print '<br>';
|
||||
|
||||
// Separator
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td></td></tr>';
|
||||
|
||||
// Method
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
|
||||
@ -456,8 +454,12 @@ if ($action == 'edit')
|
||||
print '<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY : '').'</textarea>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Separator
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
|
||||
|
||||
// From
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'</td>';
|
||||
@ -473,9 +475,6 @@ if ($action == 'edit')
|
||||
print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE, 0);
|
||||
print '</td></tr>';
|
||||
|
||||
// Separator
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
|
||||
// From
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
|
||||
print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : '');
|
||||
@ -486,6 +485,11 @@ if ($action == 'edit')
|
||||
print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) ? $conf->global->MAIN_MAIL_AUTOCOPY_TO : '');
|
||||
print '"></td></tr>';
|
||||
|
||||
// Add user to select destinaries list
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>';
|
||||
print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', $conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
@ -520,17 +524,23 @@ if ($action == 'edit')
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
//Add user to select destinaries list
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>'.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
// Separator
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td></td></tr>';
|
||||
|
||||
// Method
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
|
||||
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
|
||||
if (empty($text)) $text = $langs->trans("Undefined").img_warning();
|
||||
print $text;
|
||||
|
||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
|
||||
print $form->textwithpicto('', $langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC"), 1, 'warning');
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Host server
|
||||
@ -624,8 +634,16 @@ if ($action == 'edit')
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Separator
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
print '</table>';
|
||||
|
||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
|
||||
print info_admin($langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC"), 0, 0, 'warning');
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
|
||||
|
||||
// From
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'</td>';
|
||||
@ -678,9 +696,6 @@ if ($action == 'edit')
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Separator
|
||||
print '<tr class="oddeven"><td colspan="2"> </td></tr>';
|
||||
|
||||
// Errors To
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
|
||||
print '<td>'.$conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
@ -699,6 +714,9 @@ if ($action == 'edit')
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
//Add user to select destinaries list
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>'.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
@ -750,7 +768,7 @@ if ($action == 'edit')
|
||||
$text = '';
|
||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
|
||||
{
|
||||
$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS
|
||||
//$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS
|
||||
}
|
||||
|
||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
|
||||
|
||||
@ -121,7 +121,7 @@ $listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
|
||||
$listofmethods['mail'] = 'PHP mail function';
|
||||
//$listofmethods['simplemail']='Simplemail class';
|
||||
$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
|
||||
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
|
||||
if (version_compare(phpversion(), '7.0', '>=')) $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
|
||||
|
||||
|
||||
if ($action == 'edit')
|
||||
|
||||
@ -120,7 +120,7 @@ $listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
|
||||
$listofmethods['mail'] = 'PHP mail function';
|
||||
//$listofmethods['simplemail']='Simplemail class';
|
||||
$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
|
||||
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
|
||||
if (version_compare(phpversion(), '7.0', '>=')) $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
|
||||
|
||||
|
||||
if ($action == 'edit')
|
||||
|
||||
@ -40,8 +40,8 @@ $dirsmartphone = array();
|
||||
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
|
||||
foreach ($dirmenus as $dirmenu)
|
||||
{
|
||||
$dirstandard[] = $dirmenu.'standard';
|
||||
$dirsmartphone[] = $dirmenu.'smartphone';
|
||||
$dirstandard[] = $dirmenu.'standard';
|
||||
$dirsmartphone[] = $dirmenu.'smartphone';
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -66,192 +66,192 @@ if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler");
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
if (!$cancel)
|
||||
{
|
||||
$leftmenu = ''; $mainmenu = '';
|
||||
if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha')))
|
||||
{
|
||||
$tmp = explode('&', GETPOST('menuIdParent', 'alpha'));
|
||||
foreach ($tmp as $s)
|
||||
{
|
||||
if (preg_match('/fk_mainmenu=/', $s))
|
||||
{
|
||||
$mainmenu = preg_replace('/fk_mainmenu=/', '', $s);
|
||||
}
|
||||
if (preg_match('/fk_leftmenu=/', $s))
|
||||
{
|
||||
$leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$cancel)
|
||||
{
|
||||
$leftmenu = ''; $mainmenu = '';
|
||||
if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha')))
|
||||
{
|
||||
$tmp = explode('&', GETPOST('menuIdParent', 'alpha'));
|
||||
foreach ($tmp as $s)
|
||||
{
|
||||
if (preg_match('/fk_mainmenu=/', $s))
|
||||
{
|
||||
$mainmenu = preg_replace('/fk_mainmenu=/', '', $s);
|
||||
}
|
||||
if (preg_match('/fk_leftmenu=/', $s))
|
||||
{
|
||||
$leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$menu = new Menubase($db);
|
||||
$result = $menu->fetch(GETPOST('menuId', 'int'));
|
||||
if ($result > 0)
|
||||
{
|
||||
$menu->title = GETPOST('titre', 'alpha');
|
||||
$menu->leftmenu = GETPOST('leftmenu', 'aZ09');
|
||||
$menu->url = GETPOST('url', 'alpha');
|
||||
$menu->langs = GETPOST('langs', 'alpha');
|
||||
$menu->position = GETPOST('position', 'int');
|
||||
$menu->enabled = GETPOST('enabled', 'alpha');
|
||||
$menu->perms = GETPOST('perms', 'alpha');
|
||||
$menu->target = GETPOST('target', 'alpha');
|
||||
$menu->user = GETPOST('user', 'alpha');
|
||||
$menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
|
||||
if (is_numeric(GETPOST('menuIdParent', 'alpha')))
|
||||
{
|
||||
$menu->fk_menu = GETPOST('menuIdParent', 'alpha');
|
||||
} else {
|
||||
if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
|
||||
else $menu->fk_menu = -1;
|
||||
$menu->fk_mainmenu = $mainmenu;
|
||||
$menu->fk_leftmenu = $leftmenu;
|
||||
}
|
||||
$menu = new Menubase($db);
|
||||
$result = $menu->fetch(GETPOST('menuId', 'int'));
|
||||
if ($result > 0)
|
||||
{
|
||||
$menu->title = GETPOST('titre', 'alpha');
|
||||
$menu->leftmenu = GETPOST('leftmenu', 'aZ09');
|
||||
$menu->url = GETPOST('url', 'alpha');
|
||||
$menu->langs = GETPOST('langs', 'alpha');
|
||||
$menu->position = GETPOST('position', 'int');
|
||||
$menu->enabled = GETPOST('enabled', 'alpha');
|
||||
$menu->perms = GETPOST('perms', 'alpha');
|
||||
$menu->target = GETPOST('target', 'alpha');
|
||||
$menu->user = GETPOST('user', 'alpha');
|
||||
$menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
|
||||
if (is_numeric(GETPOST('menuIdParent', 'alpha')))
|
||||
{
|
||||
$menu->fk_menu = GETPOST('menuIdParent', 'alpha');
|
||||
} else {
|
||||
if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
|
||||
else $menu->fk_menu = -1;
|
||||
$menu->fk_mainmenu = $mainmenu;
|
||||
$menu->fk_leftmenu = $leftmenu;
|
||||
}
|
||||
|
||||
$result = $menu->update($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($menu->error, $menu->errors, 'errors');
|
||||
}
|
||||
} else {
|
||||
setEventMessages($menu->error, $menu->errors, 'errors');
|
||||
}
|
||||
$action = "edit";
|
||||
$result = $menu->update($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($menu->error, $menu->errors, 'errors');
|
||||
}
|
||||
} else {
|
||||
setEventMessages($menu->error, $menu->errors, 'errors');
|
||||
}
|
||||
$action = "edit";
|
||||
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
|
||||
exit;
|
||||
} else {
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
|
||||
exit;
|
||||
}
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
|
||||
exit;
|
||||
} else {
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'add')
|
||||
{
|
||||
if ($cancel)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
|
||||
exit;
|
||||
}
|
||||
if ($cancel)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
|
||||
exit;
|
||||
}
|
||||
|
||||
$leftmenu = ''; $mainmenu = '';
|
||||
if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3)))
|
||||
{
|
||||
$tmp = explode('&', GETPOST('menuId', 'alpha', 3));
|
||||
foreach ($tmp as $s)
|
||||
{
|
||||
if (preg_match('/fk_mainmenu=/', $s))
|
||||
{
|
||||
$leftmenu = ''; $mainmenu = '';
|
||||
if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3)))
|
||||
{
|
||||
$tmp = explode('&', GETPOST('menuId', 'alpha', 3));
|
||||
foreach ($tmp as $s)
|
||||
{
|
||||
if (preg_match('/fk_mainmenu=/', $s))
|
||||
{
|
||||
$mainmenu = preg_replace('/fk_mainmenu=/', '', $s);
|
||||
}
|
||||
if (preg_match('/fk_leftmenu=/', $s))
|
||||
{
|
||||
$leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (preg_match('/fk_leftmenu=/', $s))
|
||||
{
|
||||
$leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$langs->load("errors");
|
||||
$langs->load("errors");
|
||||
|
||||
$error = 0;
|
||||
if (!$error && !$_POST['menu_handler'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['type'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['url'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['titre'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && $_POST['menuId'] && $_POST['type'] == 'top')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
$error = 0;
|
||||
if (!$error && !$_POST['menu_handler'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['type'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['url'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['titre'])
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && $_POST['menuId'] && $_POST['type'] == 'top')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$menu = new Menubase($db);
|
||||
$menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09'));
|
||||
$menu->type = GETPOST('type', 'alpha');
|
||||
$menu->title = GETPOST('titre', 'alpha');
|
||||
$menu->url = GETPOST('url', 'alpha');
|
||||
$menu->langs = GETPOST('langs', 'alpha');
|
||||
$menu->position = GETPOST('position', 'int');
|
||||
$menu->enabled = GETPOST('enabled', 'alpha');
|
||||
$menu->perms = GETPOST('perms', 'alpha');
|
||||
$menu->target = GETPOST('target', 'alpha');
|
||||
$menu->user = GETPOST('user', 'alpha');
|
||||
$menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
|
||||
if (is_numeric(GETPOST('menuId', 'alpha', 3)))
|
||||
{
|
||||
$menu->fk_menu = GETPOST('menuId', 'alpha', 3);
|
||||
} else {
|
||||
if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
|
||||
else $menu->fk_menu = -1;
|
||||
$menu->fk_mainmenu = $mainmenu;
|
||||
$menu->fk_leftmenu = $leftmenu;
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
$menu = new Menubase($db);
|
||||
$menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09'));
|
||||
$menu->type = GETPOST('type', 'alpha');
|
||||
$menu->title = GETPOST('titre', 'alpha');
|
||||
$menu->url = GETPOST('url', 'alpha');
|
||||
$menu->langs = GETPOST('langs', 'alpha');
|
||||
$menu->position = GETPOST('position', 'int');
|
||||
$menu->enabled = GETPOST('enabled', 'alpha');
|
||||
$menu->perms = GETPOST('perms', 'alpha');
|
||||
$menu->target = GETPOST('target', 'alpha');
|
||||
$menu->user = GETPOST('user', 'alpha');
|
||||
$menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
|
||||
if (is_numeric(GETPOST('menuId', 'alpha', 3)))
|
||||
{
|
||||
$menu->fk_menu = GETPOST('menuId', 'alpha', 3);
|
||||
} else {
|
||||
if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
|
||||
else $menu->fk_menu = -1;
|
||||
$menu->fk_mainmenu = $mainmenu;
|
||||
$menu->fk_leftmenu = $leftmenu;
|
||||
}
|
||||
|
||||
$result = $menu->create($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09'));
|
||||
exit;
|
||||
} else {
|
||||
$action = 'create';
|
||||
setEventMessages($menu->error, $menu->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$result = $menu->create($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09'));
|
||||
exit;
|
||||
} else {
|
||||
$action = 'create';
|
||||
setEventMessages($menu->error, $menu->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete
|
||||
if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||
{
|
||||
$this->db->begin();
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
|
||||
$result = $db->query($sql);
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result == 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
if ($result == 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
llxHeader();
|
||||
setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
|
||||
llxFooter();
|
||||
exit;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
llxHeader();
|
||||
setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
|
||||
llxFooter();
|
||||
exit;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
|
||||
$reload = 0;
|
||||
$_GET["action"] = '';
|
||||
}
|
||||
$reload = 0;
|
||||
$_GET["action"] = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -268,7 +268,7 @@ llxHeader('', $langs->trans("Menu"));
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
function init_topleft()
|
||||
{
|
||||
@ -292,231 +292,231 @@ if ($action == 'create')
|
||||
});
|
||||
</script>';
|
||||
|
||||
print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup');
|
||||
print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup');
|
||||
|
||||
print '<form action="./edit.php?action=add&menuId='.GETPOST('menuId', 'int').'" method="post" name="formmenucreate">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<form action="./edit.php?action=add&menuId='.GETPOST('menuId', 'int').'" method="post" name="formmenucreate">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
dol_fiche_head();
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Id
|
||||
$parent_rowid = GETPOST('menuId', 'int');
|
||||
if (GETPOST('menuId', 'int'))
|
||||
{
|
||||
$sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int');
|
||||
$res = $db->query($sql);
|
||||
if ($res)
|
||||
{
|
||||
while ($menu = $db->fetch_array($res))
|
||||
{
|
||||
$parent_rowid = $menu['rowid'];
|
||||
$parent_mainmenu = $menu['mainmenu'];
|
||||
$parent_leftmenu = $menu['leftmenu'];
|
||||
$parent_langs = $menu['langs'];
|
||||
$parent_level = $menu['level'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Id
|
||||
$parent_rowid = GETPOST('menuId', 'int');
|
||||
if (GETPOST('menuId', 'int'))
|
||||
{
|
||||
$sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int');
|
||||
$res = $db->query($sql);
|
||||
if ($res)
|
||||
{
|
||||
while ($menu = $db->fetch_array($res))
|
||||
{
|
||||
$parent_rowid = $menu['rowid'];
|
||||
$parent_mainmenu = $menu['mainmenu'];
|
||||
$parent_leftmenu = $menu['leftmenu'];
|
||||
$parent_langs = $menu['langs'];
|
||||
$parent_level = $menu['level'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handler
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
|
||||
print '<td>';
|
||||
$formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone));
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
|
||||
// Handler
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
|
||||
print '<td>';
|
||||
$formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone));
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
|
||||
|
||||
// User
|
||||
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td>';
|
||||
print '<td><select class="flat" name="user">';
|
||||
print '<option value="2" selected>'.$langs->trans("AllMenus").'</option>';
|
||||
print '<option value="0">'.$langs->trans('Internal').'</option>';
|
||||
print '<option value="1">'.$langs->trans('External').'</option>';
|
||||
print '</select></td>';
|
||||
print '<td>'.$langs->trans('DetailUser').'</td></tr>';
|
||||
// User
|
||||
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td>';
|
||||
print '<td><select class="flat" name="user">';
|
||||
print '<option value="2" selected>'.$langs->trans("AllMenus").'</option>';
|
||||
print '<option value="0">'.$langs->trans('Internal').'</option>';
|
||||
print '<option value="1">'.$langs->trans('External').'</option>';
|
||||
print '</select></td>';
|
||||
print '<td>'.$langs->trans('DetailUser').'</td></tr>';
|
||||
|
||||
// Type
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>';
|
||||
if ($parent_rowid)
|
||||
{
|
||||
print $langs->trans('Left');
|
||||
print '<input type="hidden" name="type" value="left">';
|
||||
} else {
|
||||
print '<select name="type" class="flat" id="topleft">';
|
||||
print '<option value=""> </option>';
|
||||
print '<option value="top"'.($_POST["type"] && $_POST["type"] == 'top' ? ' selected' : '').'>'.$langs->trans('Top').'</option>';
|
||||
print '<option value="left"'.($_POST["type"] && $_POST["type"] == 'left' ? ' selected' : '').'>'.$langs->trans('Left').'</option>';
|
||||
print '</select>';
|
||||
}
|
||||
print '</td><td>'.$langs->trans('DetailType').'</td></tr>';
|
||||
// Type
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>';
|
||||
if ($parent_rowid)
|
||||
{
|
||||
print $langs->trans('Left');
|
||||
print '<input type="hidden" name="type" value="left">';
|
||||
} else {
|
||||
print '<select name="type" class="flat" id="topleft">';
|
||||
print '<option value=""> </option>';
|
||||
print '<option value="top"'.($_POST["type"] && $_POST["type"] == 'top' ? ' selected' : '').'>'.$langs->trans('Top').'</option>';
|
||||
print '<option value="left"'.($_POST["type"] && $_POST["type"] == 'left' ? ' selected' : '').'>'.$langs->trans('Left').'</option>';
|
||||
print '</select>';
|
||||
}
|
||||
print '</td><td>'.$langs->trans('DetailType').'</td></tr>';
|
||||
|
||||
// Mainmenu code
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
|
||||
// Mainmenu code
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
|
||||
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : '').'"></td>';
|
||||
print '<td>';
|
||||
print $langs->trans("Example").': mytopmenukey';
|
||||
print '</td></tr>';
|
||||
print '<td>';
|
||||
print $langs->trans("Example").': mytopmenukey';
|
||||
print '</td></tr>';
|
||||
|
||||
// MenuId Parent
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent').'</td>';
|
||||
if ($parent_rowid)
|
||||
{
|
||||
print '<td>'.$parent_rowid.'<input type="hidden" name="menuId" value="'.$parent_rowid.'"></td>';
|
||||
} else {
|
||||
print '<td><input type="text" class="minwidth300" id="menuId" name="menuId" value="'.(GETPOST("menuId", 'int') ?GETPOST("menuId", 'int') : '').'"></td>';
|
||||
}
|
||||
print '<td>'.$langs->trans('DetailMenuIdParent');
|
||||
print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
|
||||
print '</td></tr>';
|
||||
// MenuId Parent
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent').'</td>';
|
||||
if ($parent_rowid)
|
||||
{
|
||||
print '<td>'.$parent_rowid.'<input type="hidden" name="menuId" value="'.$parent_rowid.'"></td>';
|
||||
} else {
|
||||
print '<td><input type="text" class="minwidth300" id="menuId" name="menuId" value="'.(GETPOST("menuId", 'int') ?GETPOST("menuId", 'int') : '').'"></td>';
|
||||
}
|
||||
print '<td>'.$langs->trans('DetailMenuIdParent');
|
||||
print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
|
||||
print '</td></tr>';
|
||||
|
||||
// Title
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag(GETPOST("titre", 'alpha')).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
|
||||
// Title
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag(GETPOST("titre", 'alpha')).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
|
||||
|
||||
// URL
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="minwidth500" name="url" value="'.GETPOST("url", 'alpha').'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
|
||||
// URL
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="minwidth500" name="url" value="'.GETPOST("url", 'alpha').'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
|
||||
|
||||
// Langs
|
||||
print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" class="minwidth300" name="langs" value="'.$parent_langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
|
||||
// Langs
|
||||
print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" class="minwidth300" name="langs" value="'.$parent_langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
|
||||
|
||||
// Position
|
||||
print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(isset($_POST["position"]) ? $_POST["position"] : 100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
|
||||
// Position
|
||||
print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(isset($_POST["position"]) ? $_POST["position"] : 100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
|
||||
|
||||
// Target
|
||||
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
|
||||
print '<option value=""'.($menu->target == "" ? ' selected' : '').'> </option>';
|
||||
print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
|
||||
print '</select></td></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
|
||||
// Target
|
||||
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
|
||||
print '<option value=""'.($menu->target == "" ? ' selected' : '').'> </option>';
|
||||
print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
|
||||
print '</select></td></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
|
||||
|
||||
// Enabled
|
||||
print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled') ?GETPOST("enabled", 'alpha') : '1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
|
||||
// Enabled
|
||||
print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled') ?GETPOST("enabled", 'alpha') : '1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
|
||||
|
||||
// Perms
|
||||
print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms') ?GETPOST('perms', 'alpha') : '1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
|
||||
// Perms
|
||||
print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms') ?GETPOST('perms', 'alpha') : '1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center">';
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
} elseif ($action == 'edit')
|
||||
{
|
||||
print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup');
|
||||
print '<br>';
|
||||
print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup');
|
||||
print '<br>';
|
||||
|
||||
print '<form action="./edit.php?action=update" method="POST" name="formmenuedit">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="handler_origine" value="'.$menu_handler.'">';
|
||||
print '<input type="hidden" name="menuId" value="'.GETPOST('menuId', 'int').'">';
|
||||
print '<form action="./edit.php?action=update" method="POST" name="formmenuedit">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="handler_origine" value="'.$menu_handler.'">';
|
||||
print '<input type="hidden" name="menuId" value="'.GETPOST('menuId', 'int').'">';
|
||||
|
||||
dol_fiche_head();
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
$menu = new Menubase($db);
|
||||
$result = $menu->fetch(GETPOST('menuId', 'int'));
|
||||
//var_dump($menu);
|
||||
$menu = new Menubase($db);
|
||||
$result = $menu->fetch(GETPOST('menuId', 'int'));
|
||||
//var_dump($menu);
|
||||
|
||||
// Id
|
||||
print '<tr><td>'.$langs->trans('Id').'</td><td>'.$menu->id.'</td><td>'.$langs->trans('DetailId').'</td></tr>';
|
||||
// Id
|
||||
print '<tr><td>'.$langs->trans('Id').'</td><td>'.$menu->id.'</td><td>'.$langs->trans('DetailId').'</td></tr>';
|
||||
|
||||
// Module
|
||||
print '<tr><td>'.$langs->trans('MenuModule').'</td><td>'.$menu->module.'</td><td>'.$langs->trans('DetailMenuModule').'</td></tr>';
|
||||
// Module
|
||||
print '<tr><td>'.$langs->trans('MenuModule').'</td><td>'.$menu->module.'</td><td>'.$langs->trans('DetailMenuModule').'</td></tr>';
|
||||
|
||||
// Handler
|
||||
if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus');
|
||||
else $handler = $menu->menu_handler;
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td><td>'.$handler.'</td><td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
|
||||
// Handler
|
||||
if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus');
|
||||
else $handler = $menu->menu_handler;
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td><td>'.$handler.'</td><td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
|
||||
|
||||
// User
|
||||
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td><td><select class="flat" name="user">';
|
||||
print '<option value="2"'.($menu->user == 2 ? ' selected' : '').'>'.$langs->trans("AllMenus").'</option>';
|
||||
print '<option value="0"'.($menu->user == 0 ? ' selected' : '').'>'.$langs->trans('Internal').'</option>';
|
||||
print '<option value="1"'.($menu->user == 1 ? ' selected' : '').'>'.$langs->trans('External').'</option>';
|
||||
print '</select></td><td>'.$langs->trans('DetailUser').'</td></tr>';
|
||||
// User
|
||||
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td><td><select class="flat" name="user">';
|
||||
print '<option value="2"'.($menu->user == 2 ? ' selected' : '').'>'.$langs->trans("AllMenus").'</option>';
|
||||
print '<option value="0"'.($menu->user == 0 ? ' selected' : '').'>'.$langs->trans('Internal').'</option>';
|
||||
print '<option value="1"'.($menu->user == 1 ? ' selected' : '').'>'.$langs->trans('External').'</option>';
|
||||
print '</select></td><td>'.$langs->trans('DetailUser').'</td></tr>';
|
||||
|
||||
// Type
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>'.$langs->trans(ucfirst($menu->type)).'</td><td>'.$langs->trans('DetailType').'</td></tr>';
|
||||
// Type
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>'.$langs->trans(ucfirst($menu->type)).'</td><td>'.$langs->trans('DetailType').'</td></tr>';
|
||||
|
||||
// Mainmenu code
|
||||
if ($menu->type == 'top')
|
||||
{
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
|
||||
/*if ($parent_rowid)
|
||||
// Mainmenu code
|
||||
if ($menu->type == 'top')
|
||||
{
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
|
||||
/*if ($parent_rowid)
|
||||
{
|
||||
print '<td>'.$parent_rowid.'<input type="hidden" name="propertyleftmenu" value="'.$parent_rowid.'"></td>';
|
||||
}
|
||||
else
|
||||
{*/
|
||||
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : $menu->mainmenu).'"></td>';
|
||||
//}
|
||||
print '<td>';
|
||||
print $langs->trans("Example").': mytopmenukey';
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : $menu->mainmenu).'"></td>';
|
||||
//}
|
||||
print '<td>';
|
||||
print $langs->trans("Example").': mytopmenukey';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// MenuId Parent
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent');
|
||||
print '</td>';
|
||||
$valtouse = $menu->fk_menu;
|
||||
if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu;
|
||||
if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu;
|
||||
print '<td><input type="text" name="menuIdParent" value="'.$valtouse.'" class="minwidth300"></td>';
|
||||
print '<td>'.$langs->trans('DetailMenuIdParent');
|
||||
print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
|
||||
print '</td></tr>';
|
||||
// MenuId Parent
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent');
|
||||
print '</td>';
|
||||
$valtouse = $menu->fk_menu;
|
||||
if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu;
|
||||
if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu;
|
||||
print '<td><input type="text" name="menuIdParent" value="'.$valtouse.'" class="minwidth300"></td>';
|
||||
print '<td>'.$langs->trans('DetailMenuIdParent');
|
||||
print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
|
||||
print '</td></tr>';
|
||||
|
||||
// Niveau
|
||||
//print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
|
||||
// Niveau
|
||||
//print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
|
||||
|
||||
// Title
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
|
||||
// Title
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
|
||||
|
||||
// Url
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
|
||||
// Url
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
|
||||
|
||||
// Langs
|
||||
print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" class="minwidth300" name="langs" value="'.dol_escape_htmltag($menu->langs).'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
|
||||
// Langs
|
||||
print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" class="minwidth300" name="langs" value="'.dol_escape_htmltag($menu->langs).'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
|
||||
|
||||
// Position
|
||||
print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="minwidth100" name="position" value="'.$menu->position.'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
|
||||
// Position
|
||||
print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="minwidth100" name="position" value="'.$menu->position.'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
|
||||
|
||||
// Target
|
||||
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
|
||||
print '<option value=""'.($menu->target == "" ? ' selected' : '').'> </option>';
|
||||
print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
|
||||
print '</select></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
|
||||
// Target
|
||||
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
|
||||
print '<option value=""'.($menu->target == "" ? ' selected' : '').'> </option>';
|
||||
print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
|
||||
print '</select></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
|
||||
|
||||
// Enabled
|
||||
print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.dol_escape_htmltag($menu->enabled).'"></td><td>'.$langs->trans('DetailEnabled');
|
||||
if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
|
||||
print '</td></tr>';
|
||||
// Enabled
|
||||
print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.dol_escape_htmltag($menu->enabled).'"></td><td>'.$langs->trans('DetailEnabled');
|
||||
if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
|
||||
print '</td></tr>';
|
||||
|
||||
// Perms
|
||||
print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.dol_escape_htmltag($menu->perms).'"></td><td>'.$langs->trans('DetailRight');
|
||||
if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
|
||||
print '</td></tr>';
|
||||
// Perms
|
||||
print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.dol_escape_htmltag($menu->perms).'"></td><td>'.$langs->trans('DetailRight');
|
||||
if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
dol_fiche_end();
|
||||
|
||||
// Bouton
|
||||
print '<div class="center">';
|
||||
// Bouton
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
@ -367,8 +367,7 @@ foreach ($configfileparameters as $key => $value)
|
||||
print "<td>";
|
||||
if ($newkey == 'dolibarr_main_db_pass') print preg_replace('/./i', '*', ${$newkey});
|
||||
elseif ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/', ${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT');
|
||||
elseif ($newkey == 'dolibarr_main_document_root_alt')
|
||||
{
|
||||
elseif ($newkey == 'dolibarr_main_document_root_alt') {
|
||||
$tmparray = explode(',', ${$newkey});
|
||||
$i = 0;
|
||||
foreach ($tmparray as $value2)
|
||||
@ -382,8 +381,7 @@ foreach ($configfileparameters as $key => $value)
|
||||
}
|
||||
++$i;
|
||||
}
|
||||
} elseif ($newkey == 'dolibarr_main_instance_unique_id')
|
||||
{
|
||||
} elseif ($newkey == 'dolibarr_main_instance_unique_id') {
|
||||
//print $conf->file->instance_unique_id;
|
||||
global $dolibarr_main_cookie_cryptkey;
|
||||
$valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey
|
||||
@ -392,6 +390,13 @@ foreach ($configfileparameters as $key => $value)
|
||||
print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id');
|
||||
}
|
||||
print ' <span class="opacitymedium">('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')</span>';
|
||||
} elseif ($newkey == 'dolibarr_main_prod') {
|
||||
print ${$newkey};
|
||||
|
||||
$valuetoshow = ${$newkey};
|
||||
if (empty($valuetoshow)) {
|
||||
print img_warning($langs->trans('SwitchThisForABetterSecurity'));
|
||||
}
|
||||
} else {
|
||||
print ${$newkey};
|
||||
}
|
||||
|
||||
@ -25,68 +25,93 @@
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("install", "other", "admin"));
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
$optioncss = GETPOST('optioncss', 'alpha');
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview';
|
||||
|
||||
$search_name = GETPOST("search_name", 'alpha');
|
||||
$search_id = GETPOST("search_id", 'alpha');
|
||||
$search_version = GETPOST("search_version", 'alpha');
|
||||
$search_permission = GETPOST("search_permission", 'alpha');
|
||||
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
|
||||
if (!$sortfield) $sortfield = "id";
|
||||
if (!$sortorder) $sortorder = "asc";
|
||||
|
||||
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
|
||||
$hookmanager->initHooks(array('moduleoverview'));
|
||||
$form = new Form($db);
|
||||
$object = new stdClass();
|
||||
|
||||
// Definition of fields for lists
|
||||
$arrayfields = array(
|
||||
'name'=>array('label'=>$langs->trans("Modules"), 'checked'=>1, 'position'=>10),
|
||||
'version'=>array('label'=>$langs->trans("Version"), 'checked'=>1, 'position'=>20),
|
||||
'id'=>array('label'=>$langs->trans("IdModule"), 'checked'=>1, 'position'=>30),
|
||||
'permission'=>array('label'=>$langs->trans("IdPermissions"), 'checked'=>1, 'position'=>40)
|
||||
);
|
||||
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
/*
|
||||
* View
|
||||
* Actions
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
print load_fiche_titre($langs->trans("AvailableModules"), '', 'title_setup');
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
}
|
||||
|
||||
print '<span class="opacitymedium">'.$langs->trans("ToActivateModule").'</span><br>';
|
||||
print "<br>\n";
|
||||
|
||||
// Load list of modules
|
||||
$moduleList = array();
|
||||
$modules = array();
|
||||
$modules_names = array();
|
||||
$modules_files = array();
|
||||
$modules_fullpath = array();
|
||||
$modulesdir = dolGetModulesDirs();
|
||||
$rights_ids = array();
|
||||
|
||||
// Load list of modules
|
||||
$i = 0;
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
foreach ($modulesdir as $dir) {
|
||||
$handle = @opendir(dol_osencode($dir));
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
|
||||
$modName = substr($file, 0, dol_strlen($file) - 10);
|
||||
|
||||
if ($modName)
|
||||
{
|
||||
if ($modName) {
|
||||
//print 'xx'.$dir.$file.'<br>';
|
||||
if (in_array($file, $modules_files))
|
||||
{
|
||||
if (in_array($file, $modules_files)) {
|
||||
// File duplicate
|
||||
print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")<br>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// File to load
|
||||
$res = include_once $dir.$file;
|
||||
if (class_exists($modName))
|
||||
{
|
||||
if (class_exists($modName)) {
|
||||
try {
|
||||
$objMod = new $modName($db);
|
||||
|
||||
$modules[$objMod->numero] = $objMod;
|
||||
$modules_names[$objMod->numero] = $objMod->name;
|
||||
$modules_files[$objMod->numero] = $file;
|
||||
$modules_fullpath[$file] = $dir.$file;
|
||||
$picto[$objMod->numero] = (isset($objMod->picto) && $objMod->picto) ? $objMod->picto : 'generic';
|
||||
} catch (Exception $e)
|
||||
{
|
||||
}
|
||||
catch (Exception $e) {
|
||||
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
|
||||
}
|
||||
}
|
||||
@ -97,60 +122,280 @@ foreach ($modulesdir as $dir)
|
||||
}
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Modules").'</td>';
|
||||
print '<td>'.$langs->trans("Version").'</td>';
|
||||
print '<td class="center">'.$langs->trans("IdModule").'</td>';
|
||||
print '<td>'.$langs->trans("IdPermissions").'</td>';
|
||||
print '</tr>';
|
||||
$var = false;
|
||||
$sortorder = $modules_names;
|
||||
ksort($sortorder);
|
||||
$rights_ids = array();
|
||||
foreach ($sortorder as $numero=>$name)
|
||||
{
|
||||
$idperms = "";
|
||||
// Module
|
||||
print '<tr class="oddeven"><td width="300" class="nowrap">';
|
||||
$alt = $name.' - '.$modules_files[$numero];
|
||||
if (!empty($picto[$numero]))
|
||||
{
|
||||
if (preg_match('/^\//', $picto[$numero])) print img_picto($alt, $picto[$numero], 'width="14px"', 1);
|
||||
else print img_object($alt, $picto[$numero], 'width="14px"');
|
||||
} else {
|
||||
print img_object($alt, $picto[$numero], 'width="14px"');
|
||||
// create pre-filtered list for modules
|
||||
foreach ($modules as $key=>$module) {
|
||||
$newModule = new stdClass();
|
||||
|
||||
$newModule->name = $module->getName();
|
||||
$newModule->version = $module->getVersion();
|
||||
$newModule->id = $key;
|
||||
|
||||
$alt = $module->name.' - '.$modules_files[$key];
|
||||
|
||||
if (!empty($module->picto)) {
|
||||
if (preg_match('/^\//', $module->picto)) $newModule->picto = img_picto($alt, $module->picto, 'width="14px"', 1);
|
||||
else $newModule->picto = img_object($alt, $module->picto, 'width="14px"');
|
||||
}
|
||||
print ' '.$modules[$numero]->getName();
|
||||
print "</td>";
|
||||
// Version
|
||||
print '<td>'.$modules[$numero]->getVersion().'</td>';
|
||||
// Id
|
||||
print '<td class="center">'.$numero.'</td>';
|
||||
// Permissions
|
||||
if ($modules[$numero]->rights)
|
||||
{
|
||||
foreach ($modules[$numero]->rights as $rights)
|
||||
{
|
||||
$idperms .= ($idperms ? ", " : "").$rights[0];
|
||||
else {
|
||||
$newModule->picto = img_object($alt, 'generic', 'width="14px"');
|
||||
}
|
||||
|
||||
$permission = array();
|
||||
if ($module->rights) {
|
||||
foreach ($module->rights as $rights) {
|
||||
if (empty($rights[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$permission[] = $rights[0];
|
||||
|
||||
array_push($rights_ids, $rights[0]);
|
||||
}
|
||||
}
|
||||
print '<td>'.($idperms ? $idperms : " ").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$newModule->permission = $permission;
|
||||
|
||||
// pre-filter list
|
||||
if ($search_name && !stristr($newModule->name, $search_name)) continue;
|
||||
if ($search_version && !stristr($newModule->version, $search_version)) continue;
|
||||
if ($search_id && !stristr($newModule->id, $search_id)) continue;
|
||||
|
||||
if ($search_permission) {
|
||||
$found = false;
|
||||
|
||||
foreach ($newModule->permission as $permission) {
|
||||
if (stristr($permission, $search_permission)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) continue;
|
||||
}
|
||||
|
||||
$moduleList[] = $newModule;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
print_barre_liste($langs->trans("AvailableModules"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $massactionbutton, -1, '', 'title_setup', 0, '', '', 0, 1, 1);
|
||||
|
||||
print '<span class="opacitymedium">'.$langs->trans("ToActivateModule").'</span>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
// Lines with input filters
|
||||
print '<tr class="liste_titre_filter">';
|
||||
|
||||
if ($arrayfields['name']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_name" size="8" value="'.$search_name.'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['version']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_version" size="8" value="'.$search_version.'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['id']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_id" size="8" value="'.$search_id.'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['permission']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_permission" size="8" value="'.$search_permission.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td class="liste_titre center maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
if ($arrayfields['name']['checked']) {
|
||||
print_liste_field_titre($arrayfields['name']['label'], $_SERVER["PHP_SELF"], "name", "", "", "", $sortfield, $sortorder);
|
||||
}
|
||||
if ($arrayfields['version']['checked']) {
|
||||
print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder);
|
||||
}
|
||||
if ($arrayfields['id']['checked']) {
|
||||
print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder);
|
||||
}
|
||||
if ($arrayfields['permission']['checked']) {
|
||||
print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder);
|
||||
}
|
||||
|
||||
// Fields from hook
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print '</tr>';
|
||||
|
||||
// sort list
|
||||
if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) {
|
||||
return strcasecmp($a->name, $b->name); });
|
||||
if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) {
|
||||
return strcasecmp($b->name, $a->name); });
|
||||
if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) {
|
||||
return strcasecmp($a->version, $b->version); });
|
||||
if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) {
|
||||
return strcasecmp($b->version, $a->version); });
|
||||
if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc");
|
||||
if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc");
|
||||
if ($sortfield == "permission" && $sortorder == "asc") usort($moduleList, "comparePermissionIdsAsc");
|
||||
if ($sortfield == "permission" && $sortorder == "desc") usort($moduleList, "comparePermissionIdsDesc");
|
||||
|
||||
foreach ($moduleList as $module) {
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
if ($arrayfields['name']['checked']) {
|
||||
print '<td width="300" class="nowrap">';
|
||||
print $module->picto;
|
||||
print ' '.$module->name;
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
if ($arrayfields['version']['checked']) {
|
||||
print '<td>'.$module->version.'</td>';
|
||||
}
|
||||
|
||||
if ($arrayfields['id']['checked']) {
|
||||
print '<td class="center">'.$module->id.'</td>';
|
||||
}
|
||||
|
||||
if ($arrayfields['permission']['checked']) {
|
||||
$idperms = '';
|
||||
|
||||
foreach ($module->permission as $permission) {
|
||||
$idperms .= ($idperms ? ", " : "").$permission;
|
||||
$translationKey = "Permission".$permission;
|
||||
|
||||
if (!empty($conf->global->MAIN_SHOW_PERMISSION)) {
|
||||
if (empty($langs->tab_translate[$translationKey])) {
|
||||
$tooltip = 'Missing translation (key '.$translationkey.' not found in admin.lang)';
|
||||
$idperms .= ' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.'">';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '<td>'.($idperms ? $idperms : " ").'</td>';
|
||||
}
|
||||
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
|
||||
sort($rights_ids);
|
||||
$old = '';
|
||||
foreach ($rights_ids as $right_id)
|
||||
{
|
||||
if ($old == $right_id) print "Warning duplicate id on permission : ".$right_id."<br>";
|
||||
|
||||
foreach ($rights_ids as $right_id) {
|
||||
if ($old == $right_id) {
|
||||
print "Warning duplicate id on permission : ".$right_id."<br>";
|
||||
}
|
||||
|
||||
$old = $right_id;
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
|
||||
/**
|
||||
* Compare two modules by their ID for a ascending order
|
||||
*
|
||||
* @param stdClass $a First module
|
||||
* @param stdClass $b Second module
|
||||
* @return int Compare result (-1, 0, 1)
|
||||
*/
|
||||
function compareIdAsc(stdClass $a, stdClass $b)
|
||||
{
|
||||
if ($a->id == $b->id) return 0;
|
||||
|
||||
return $a->id > $b->id ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two modules by their ID for a descending order
|
||||
*
|
||||
* @param stdClass $a First module
|
||||
* @param stdClass $b Second module
|
||||
* @return int Compare result (-1, 0, 1)
|
||||
*/
|
||||
function compareIdDesc(stdClass $a, stdClass $b)
|
||||
{
|
||||
if ($a->id == $b->id) return 0;
|
||||
|
||||
return $b->id > $a->id ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two modules by their ID for a ascending order
|
||||
*
|
||||
* @param stdClass $a First module
|
||||
* @param stdClass $b Second module
|
||||
* @return int Compare result (-1, 0, 1)
|
||||
*/
|
||||
function comparePermissionIdsAsc(stdClass $a, stdClass $b)
|
||||
{
|
||||
if (empty($a->permission) && empty($b->permission)) return compareIdAsc($a, $b);
|
||||
|
||||
if (empty($a->permission)) return 1;
|
||||
if (empty($b->permission)) return -1;
|
||||
|
||||
if ($a->permission[0] == $b->permission[0]) return 0;
|
||||
|
||||
return $a->permission[0] > $b->permission[0] ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two modules by their permissions for a descending order
|
||||
*
|
||||
* @param stdClass $a First module
|
||||
* @param stdClass $b Second module
|
||||
* @return int Compare result (-1, 0, 1)
|
||||
*/
|
||||
function comparePermissionIdsDesc(stdClass $a, stdClass $b)
|
||||
{
|
||||
if (empty($a->permission) && empty($b->permission)) return compareIdDesc($a, $b);
|
||||
|
||||
if (empty($a->permission)) return -1;
|
||||
if (empty($b->permission)) return 1;
|
||||
|
||||
if ($a->permission[0] == $b->permission[0]) return 0;
|
||||
|
||||
return $a->permission[0] > $b->permission[0] ? 1 : -1;
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -19,19 +19,20 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/admin/workflow.php
|
||||
* \ingroup company
|
||||
* \brief Workflows setup page
|
||||
* \file htdocs/admin/workflow.php
|
||||
* \ingroup company
|
||||
* \brief Workflows setup page
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions"));
|
||||
|
||||
// security check
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions", "errors"));
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
|
||||
@ -39,157 +40,199 @@ $action = GETPOST('action', 'alpha');
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (preg_match('/set(.*)/', $action, $reg))
|
||||
{
|
||||
if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (preg_match('/set(.*)/', $action, $reg)) {
|
||||
if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/del(.*)/', $action, $reg))
|
||||
{
|
||||
if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (preg_match('/del(.*)/', $action, $reg)) {
|
||||
if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// List of workflow we can enable
|
||||
clearstatcache();
|
||||
|
||||
$workflowcodes = array(
|
||||
// Automatic creation
|
||||
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array(
|
||||
'family'=>'create',
|
||||
'position'=>10,
|
||||
'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)),
|
||||
'picto'=>'order'
|
||||
),
|
||||
'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array(
|
||||
'family'=>'create',
|
||||
'position'=>20,
|
||||
'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)),
|
||||
'picto'=>'bill'
|
||||
),
|
||||
|
||||
'separator1'=>array('family'=>'separator', 'position'=>25),
|
||||
|
||||
// Automatic classification of proposal
|
||||
'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array(
|
||||
'family'=>'classify_proposal',
|
||||
'position'=>30,
|
||||
'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)),
|
||||
'picto'=>'propal',
|
||||
'warning'=>''
|
||||
),
|
||||
'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array(
|
||||
'family'=>'classify_proposal',
|
||||
'position'=>31,
|
||||
'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->facture->enabled)),
|
||||
'picto'=>'propal',
|
||||
'warning'=>''
|
||||
),
|
||||
|
||||
// Automatic classification of order
|
||||
'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array(
|
||||
'family'=>'classify_order',
|
||||
'position'=>40,
|
||||
'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)),
|
||||
'picto'=>'order'
|
||||
),
|
||||
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array(
|
||||
'family'=>'classify_order',
|
||||
'position'=>41,
|
||||
'enabled'=>(!empty($conf->facture->enabled) && !empty($conf->commande->enabled)),
|
||||
'picto'=>'order',
|
||||
'warning'=>''
|
||||
), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card.
|
||||
|
||||
'separator2'=>array('family'=>'separator', 'position'=>50),
|
||||
|
||||
// Automatic classification supplier proposal
|
||||
'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array(
|
||||
'family'=>'classify_supplier_proposal',
|
||||
'position'=>60,
|
||||
'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))),
|
||||
'picto'=>'propal',
|
||||
'warning'=>''
|
||||
),
|
||||
|
||||
// Automatic classification supplier order
|
||||
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array(
|
||||
'family'=>'classify_supplier_order',
|
||||
'position'=>62,
|
||||
'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)),
|
||||
'picto'=>'order',
|
||||
'warning'=>''
|
||||
),
|
||||
|
||||
// Automatic classification reception
|
||||
'WORKFLOW_BILL_ON_RECEPTION'=>array(
|
||||
'family'=>'classify_reception',
|
||||
'position'=>64,
|
||||
'enabled'=>(!empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))),
|
||||
'picto'=>'bill'
|
||||
),
|
||||
);
|
||||
|
||||
if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) {
|
||||
foreach ($conf->modules_parts['workflow'] as $workflow) {
|
||||
$workflowcodes = array_merge($workflowcodes, $workflow);
|
||||
}
|
||||
}
|
||||
|
||||
// remove not available workflows (based on activated modules and global defined keys)
|
||||
$workflowcodes = array_filter($workflowcodes, function ($var) {
|
||||
return $var['enabled']; });
|
||||
|
||||
/*
|
||||
* View
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('', $langs->trans("WorkflowSetup"), '');
|
||||
llxHeader('', $langs->trans("WorkflowSetup"), "EN:Module_Workflow_En|FR:Module_Workflow|ES:Módulo_Workflow");
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("WorkflowSetup"), $linkback, 'title_setup');
|
||||
|
||||
print '<span class="opacitymedium">'.$langs->trans("WorkflowDesc").'</span><br>';
|
||||
print "<br>";
|
||||
print '<span class="opacitymedium">'.$langs->trans("WorkflowDesc").'</span>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
// List of workflow we can enable
|
||||
// current module setup don't support any automatic workflow of this module
|
||||
if (count($workflowcodes) < 1) {
|
||||
print $langs->trans("ThereIsNoWorkflowToModify");
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$workflowcodes = array(
|
||||
// Automatic creation
|
||||
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
|
||||
'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
|
||||
'separator1'=>array('family'=>'separator', 'position'=>25),
|
||||
// Automatic classification of proposal
|
||||
'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal', 'warning'=>''),
|
||||
'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal', 'warning'=>''),
|
||||
'separator2'=>array('family'=>'separator', 'position'=>35),
|
||||
// Automatic classification of order
|
||||
'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
|
||||
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order', 'warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card.
|
||||
'separator3'=>array('family'=>'separator', 'position'=>50),
|
||||
// Automatic classification supplier proposal
|
||||
'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, '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))', 'picto'=>'propal', 'warning'=>''),
|
||||
'separator4'=>array('family'=>'separator', 'position'=>61),
|
||||
// Automatic classification supplier order
|
||||
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)', 'picto'=>'order', 'warning'=>''),
|
||||
'separator5'=>array('family'=>'separator', 'position'=>63),
|
||||
// Automatic classification reception
|
||||
'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>64, 'enabled'=>'! empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', 'picto'=>'bill'),
|
||||
'separator6'=>array('family'=>'separator', 'position'=>90),
|
||||
// Automatic classification of intervention
|
||||
'WORKFLOW_TICKET_CLOSE_INTERVENTION'=>array('family'=>'classify_intervention', 'position'=>100, 'enabled'=>'! empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)', 'picto'=>'intervention'),
|
||||
);
|
||||
|
||||
if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
|
||||
{
|
||||
foreach ($conf->modules_parts['workflow'] as $workflow)
|
||||
{
|
||||
$workflowcodes = array_merge($workflowcodes, $workflow);
|
||||
}
|
||||
llxFooter();
|
||||
$db->close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Sort on position
|
||||
$workflowcodes = dol_sort_array($workflowcodes, 'position');
|
||||
|
||||
$nbqualified = 0;
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
$oldfamily = '';
|
||||
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
|
||||
foreach ($workflowcodes as $key => $params)
|
||||
{
|
||||
$picto = $params['picto'];
|
||||
$enabled = $params['enabled'];
|
||||
$family = $params['family'];
|
||||
|
||||
if ($family == 'separator')
|
||||
{
|
||||
print '</table><br>';
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
foreach ($workflowcodes as $key => $params) {
|
||||
if ($params['family'] == 'separator') {
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!verifCond($enabled)) continue;
|
||||
|
||||
$nbqualified++;
|
||||
|
||||
|
||||
if ($oldfamily != $family)
|
||||
{
|
||||
print '<tr class="liste_titre">'."\n";
|
||||
print ' <td>';
|
||||
$reg = array();
|
||||
if ($family == 'create') {
|
||||
print $langs->trans("AutomaticCreation");
|
||||
} elseif (preg_match('/classify_(.*)/', $family, $reg))
|
||||
{
|
||||
print $langs->trans("AutomaticClassification");
|
||||
if ($reg[1] == 'proposal') print ' - '.$langs->trans('Proposal');
|
||||
if ($reg[1] == 'order') print ' - '.$langs->trans('Order');
|
||||
if ($reg[1] == 'supplier_proposal') print ' - '.$langs->trans('SupplierProposal');
|
||||
if ($reg[1] == 'supplier_order') print ' - '.$langs->trans('SupplierOrder');
|
||||
if ($reg[1] == 'reception') print ' - '.$langs->trans('Reception');
|
||||
if ($reg[1] == 'intervention') print ' - '.$langs->trans('Intervention');
|
||||
if ($oldfamily != $params['family']) {
|
||||
if ($params['family'] == 'create') {
|
||||
$header = $langs->trans("AutomaticCreation");
|
||||
} elseif (preg_match('/classify_(.*)/', $params['family'], $reg)) {
|
||||
$header = $langs->trans("AutomaticClassification");
|
||||
if ($reg[1] == 'proposal') $header .= ' - '.$langs->trans('Proposal');
|
||||
if ($reg[1] == 'order') $header .= ' - '.$langs->trans('Order');
|
||||
if ($reg[1] == 'supplier_proposal') $header .= ' - '.$langs->trans('SupplierProposal');
|
||||
if ($reg[1] == 'supplier_order') $header .= ' - '.$langs->trans('SupplierOrder');
|
||||
if ($reg[1] == 'reception') $header .= ' - '.$langs->trans('Reception');
|
||||
} else {
|
||||
print $langs->trans("Description");
|
||||
$header = $langs->trans("Description");
|
||||
}
|
||||
print '</td>';
|
||||
print ' <td class="center" width="90px">'.$langs->trans("Status").'</td>';
|
||||
print "</tr>\n";
|
||||
$oldfamily = $family;
|
||||
}
|
||||
|
||||
print "<tr class=\"oddeven\">\n";
|
||||
print "<td>".img_object('', $picto, 'class="paddingright"').$langs->trans('desc'.$key);
|
||||
if (!empty($params['warning']))
|
||||
{
|
||||
$langs->load("errors");
|
||||
print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
|
||||
}
|
||||
print "</td>\n";
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print ajax_constantonoff($key);
|
||||
} else {
|
||||
if (!empty($conf->global->$key))
|
||||
{
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=set'.$key.'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$header.'</th>';
|
||||
print '<th align="center">'.$langs->trans("Status").'</th>';
|
||||
print '</tr>';
|
||||
|
||||
$oldfamily = $params['family'];
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print img_object('', $params['picto']);
|
||||
print ' '.$langs->trans('desc'.$key);
|
||||
|
||||
if (!empty($params['warning'])) {
|
||||
print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
print '<td class="center">';
|
||||
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print ajax_constantonoff($key);
|
||||
} else {
|
||||
if (!empty($conf->global->$key)) {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=set'.$key.'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if ($nbqualified == 0)
|
||||
{
|
||||
print '<tr><td colspan="3">'.$langs->trans("ThereIsNoWorkflowToModify");
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
// End of page
|
||||
|
||||
@ -32,7 +32,7 @@ class DolibarrApi
|
||||
/**
|
||||
* @var DoliDb $db Database object
|
||||
*/
|
||||
protected static $db;
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var Restler $r Restler object
|
||||
|
||||
@ -196,7 +196,7 @@ class Documents extends DolibarrApi
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
$templateused = $doctemplate ? $doctemplate : $this->invoice->modelpdf;
|
||||
$templateused = $doctemplate ? $doctemplate : $this->invoice->model_pdf;
|
||||
$result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0) {
|
||||
throw new RestException(500, 'Error generating document');
|
||||
@ -210,7 +210,7 @@ class Documents extends DolibarrApi
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Order not found');
|
||||
}
|
||||
$templateused = $doctemplate ? $doctemplate : $this->order->modelpdf;
|
||||
$templateused = $doctemplate ? $doctemplate : $this->order->model_pdf;
|
||||
$result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0) {
|
||||
throw new RestException(500, 'Error generating document');
|
||||
@ -224,7 +224,7 @@ class Documents extends DolibarrApi
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Proposal not found');
|
||||
}
|
||||
$templateused = $doctemplate ? $doctemplate : $this->propal->modelpdf;
|
||||
$templateused = $doctemplate ? $doctemplate : $this->propal->model_pdf;
|
||||
$result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0) {
|
||||
throw new RestException(500, 'Error generating document');
|
||||
|
||||
@ -1413,7 +1413,7 @@ class Setup extends DolibarrApi
|
||||
* @url GET conf/{constantname}
|
||||
*
|
||||
* @throws RestException 403 Forbidden
|
||||
* @throws RestException 500 Error Bad or unknown value for constantname
|
||||
* @throws RestException 404 Error Bad or unknown value for constantname
|
||||
*/
|
||||
public function getConf($constantname)
|
||||
{
|
||||
@ -1425,7 +1425,7 @@ class Setup extends DolibarrApi
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
|
||||
throw new RestException(500, 'Error Bad or unknown value for constantname');
|
||||
throw new RestException(404, 'Error Bad or unknown value for constantname');
|
||||
}
|
||||
if (preg_match('/(_pass|_pw|password|secret|_key|key$)/i', $constantname)) {
|
||||
throw new RestException(403, 'Forbidden');
|
||||
|
||||
@ -346,7 +346,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||
$genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->rights->asset->create; // If you can create/edit, you can remove a file on card
|
||||
print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
*/
|
||||
|
||||
// Show links to link elements
|
||||
|
||||
@ -368,7 +368,7 @@ class BlockedLog
|
||||
$this->object_data = new stdClass();
|
||||
// Add fields to exclude
|
||||
$arrayoffieldstoexclude = array(
|
||||
'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id',
|
||||
'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'model_pdf', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id',
|
||||
'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged',
|
||||
'linkedObjectsIds',
|
||||
'linkedObjects',
|
||||
@ -476,7 +476,7 @@ class BlockedLog
|
||||
$this->object_data->ref = $object->ref;
|
||||
$this->object_data->date = $datepayment;
|
||||
$this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code');
|
||||
$this->object_data->payment_num = ($object->num_paiement ? $object->num_paiement : $object->num_payment);
|
||||
$this->object_data->payment_num = $object->num_payment;
|
||||
//$this->object_data->fk_account = $object->fk_account;
|
||||
$this->object_data->note = $object->note;
|
||||
//var_dump($this->object_data);exit;
|
||||
|
||||
@ -707,7 +707,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card
|
||||
print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
|
||||
print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
|
||||
|
||||
@ -745,7 +745,7 @@ class BOM extends CommonObject
|
||||
|
||||
$result = '';
|
||||
|
||||
$label = '<u>'.$langs->trans("BillOfMaterials").'</u>';
|
||||
$label = img_picto('', $this->picto).' <u>'.$langs->trans("BillOfMaterials").'</u>';
|
||||
$label .= '<br>';
|
||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
if (isset($this->status)) {
|
||||
@ -934,8 +934,8 @@ class BOM extends CommonObject
|
||||
if (!dol_strlen($modele)) {
|
||||
$modele = 'standard';
|
||||
|
||||
if ($this->modelpdf) {
|
||||
$modele = $this->modelpdf;
|
||||
if ($this->model_pdf) {
|
||||
$modele = $this->model_pdf;
|
||||
} elseif (!empty($conf->global->BOM_ADDON_PDF)) {
|
||||
$modele = $conf->global->BOM_ADDON_PDF;
|
||||
}
|
||||
|
||||
@ -294,9 +294,8 @@ switch ($action)
|
||||
// Add the payment
|
||||
$payment = new Paiement($db);
|
||||
$payment->datepaye = $now;
|
||||
$payment->bank_account = $conf_fkaccount;
|
||||
$payment->amounts[$invoice->id] = $obj_facturation->amountWithTax();
|
||||
$payment->note = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
|
||||
$payment->note_public = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
|
||||
$payment->paiementid = $invoice->mode_reglement_id;
|
||||
$payment->num_paiement = '';
|
||||
$payment->num_payment = '';
|
||||
|
||||
@ -1043,7 +1043,7 @@ if ($action == 'create')
|
||||
}*/
|
||||
print '</td></tr>';
|
||||
|
||||
// Realised by
|
||||
// Done by
|
||||
if (!empty($conf->global->AGENDA_ENABLE_DONEBY))
|
||||
{
|
||||
print '<tr><td class="nowrap">'.$langs->trans("ActionDoneBy").'</td><td>';
|
||||
|
||||
@ -33,9 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage agenda events (actions)
|
||||
*/
|
||||
@ -498,7 +495,7 @@ class ActionComm extends CommonObject
|
||||
$sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", ";
|
||||
$sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", ";
|
||||
$sql .= " '".$this->db->escape($this->note_private)."', ";
|
||||
$sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned
|
||||
$sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned
|
||||
$sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", ";
|
||||
$sql .= ($userownerid > 0 ? $userownerid : "null").", ";
|
||||
$sql .= ($userdoneid > 0 ? $userdoneid : "null").", ";
|
||||
@ -632,173 +629,173 @@ class ActionComm extends CommonObject
|
||||
//$this->fetch_userassigned();
|
||||
$this->fetchResources();
|
||||
|
||||
$this->id = 0;
|
||||
$this->id = 0;
|
||||
|
||||
// Create clone
|
||||
// Create clone
|
||||
$this->context['createfromclone'] = 'createfromclone';
|
||||
$result = $this->create($fuser);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Hook of thirdparty module
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters = array('objFrom'=>$objFrom);
|
||||
$action = '';
|
||||
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) $error++;
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
// Hook of thirdparty module
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters = array('objFrom'=>$objFrom);
|
||||
$action = '';
|
||||
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) $error++;
|
||||
}
|
||||
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ACTION_CLONE', $fuser);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ACTION_CLONE', $fuser);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
unset($this->context['createfromclone']);
|
||||
unset($this->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// End
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object from database
|
||||
*
|
||||
* @param int $id Id of action to get
|
||||
* @param string $ref Ref of action to get
|
||||
* @param string $ref_ext Ref ext to get
|
||||
/**
|
||||
* Load object from database
|
||||
*
|
||||
* @param int $id Id of action to get
|
||||
* @param string $ref Ref of action to get
|
||||
* @param string $ref_ext Ref ext to get
|
||||
* @param string $email_msgid Email msgid
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '')
|
||||
{
|
||||
global $langs;
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT a.id,";
|
||||
$sql .= " a.id as ref,";
|
||||
$sql .= " a.entity,";
|
||||
$sql .= " a.ref_ext,";
|
||||
$sql .= " a.datep,";
|
||||
$sql .= " a.datep2,";
|
||||
$sql .= " a.durationp,"; // deprecated
|
||||
$sql .= " a.datec,";
|
||||
$sql .= " a.tms as datem,";
|
||||
$sql .= " a.code, a.label, a.note,";
|
||||
$sql .= " a.fk_soc,";
|
||||
$sql .= " a.fk_project,";
|
||||
$sql .= " a.fk_user_author, a.fk_user_mod,";
|
||||
$sql .= " a.fk_user_action, a.fk_user_done,";
|
||||
$sql .= " a.fk_contact, a.percent as percentage,";
|
||||
$sql .= " a.fk_element as elementid, a.elementtype,";
|
||||
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency,";
|
||||
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
|
||||
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,";
|
||||
$sql .= " s.nom as socname,";
|
||||
$sql .= " u.firstname, u.lastname as lastname";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a ";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id ";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
|
||||
$sql .= " WHERE ";
|
||||
if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id
|
||||
elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||
elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'";
|
||||
else $sql .= " a.id = ".((int) $id);
|
||||
$sql = "SELECT a.id,";
|
||||
$sql .= " a.id as ref,";
|
||||
$sql .= " a.entity,";
|
||||
$sql .= " a.ref_ext,";
|
||||
$sql .= " a.datep,";
|
||||
$sql .= " a.datep2,";
|
||||
$sql .= " a.durationp,"; // deprecated
|
||||
$sql .= " a.datec,";
|
||||
$sql .= " a.tms as datem,";
|
||||
$sql .= " a.code, a.label, a.note,";
|
||||
$sql .= " a.fk_soc,";
|
||||
$sql .= " a.fk_project,";
|
||||
$sql .= " a.fk_user_author, a.fk_user_mod,";
|
||||
$sql .= " a.fk_user_action, a.fk_user_done,";
|
||||
$sql .= " a.fk_contact, a.percent as percentage,";
|
||||
$sql .= " a.fk_element as elementid, a.elementtype,";
|
||||
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency,";
|
||||
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
|
||||
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,";
|
||||
$sql .= " s.nom as socname,";
|
||||
$sql .= " u.firstname, u.lastname as lastname";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a ";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id ";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
|
||||
$sql .= " WHERE ";
|
||||
if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id
|
||||
elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||
elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'";
|
||||
else $sql .= " a.id = ".((int) $id);
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->id;
|
||||
$this->id = $obj->id;
|
||||
$this->entity = $obj->entity;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_ext = $obj->ref_ext;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_ext = $obj->ref_ext;
|
||||
|
||||
// Properties of parent table llx_c_actioncomm
|
||||
$this->type_id = $obj->type_id;
|
||||
$this->type_code = $obj->type_code;
|
||||
$this->type_color = $obj->type_color;
|
||||
$this->type_picto = $obj->type_picto;
|
||||
$transcode = $langs->trans("Action".$obj->type_code);
|
||||
$this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label);
|
||||
$transcode = $langs->trans("Action".$obj->type_code.'Short');
|
||||
$this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : '');
|
||||
// Properties of parent table llx_c_actioncomm
|
||||
$this->type_id = $obj->type_id;
|
||||
$this->type_code = $obj->type_code;
|
||||
$this->type_color = $obj->type_color;
|
||||
$this->type_picto = $obj->type_picto;
|
||||
$transcode = $langs->trans("Action".$obj->type_code);
|
||||
$this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label);
|
||||
$transcode = $langs->trans("Action".$obj->type_code.'Short');
|
||||
$this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : '');
|
||||
|
||||
$this->code = $obj->code;
|
||||
$this->label = $obj->label;
|
||||
$this->datep = $this->db->jdate($obj->datep);
|
||||
$this->datef = $this->db->jdate($obj->datep2);
|
||||
$this->label = $obj->label;
|
||||
$this->datep = $this->db->jdate($obj->datep);
|
||||
$this->datef = $this->db->jdate($obj->datep2);
|
||||
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->datem = $this->db->jdate($obj->datem);
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->datem = $this->db->jdate($obj->datem);
|
||||
|
||||
$this->note = $obj->note; // deprecated
|
||||
$this->note_private = $obj->note;
|
||||
$this->percentage = $obj->percentage;
|
||||
$this->note = $obj->note; // deprecated
|
||||
$this->note_private = $obj->note;
|
||||
$this->percentage = $obj->percentage;
|
||||
|
||||
$this->authorid = $obj->fk_user_author;
|
||||
$this->usermodid = $obj->fk_user_mod;
|
||||
$this->authorid = $obj->fk_user_author;
|
||||
$this->usermodid = $obj->fk_user_mod;
|
||||
|
||||
if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning
|
||||
$this->author->id = $obj->fk_user_author; // deprecated
|
||||
$this->author->firstname = $obj->firstname; // deprecated
|
||||
$this->author->lastname = $obj->lastname; // deprecated
|
||||
if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning
|
||||
$this->usermod->id = $obj->fk_user_mod; // deprecated
|
||||
if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning
|
||||
$this->author->id = $obj->fk_user_author; // deprecated
|
||||
$this->author->firstname = $obj->firstname; // deprecated
|
||||
$this->author->lastname = $obj->lastname; // deprecated
|
||||
if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning
|
||||
$this->usermod->id = $obj->fk_user_mod; // deprecated
|
||||
|
||||
$this->userownerid = $obj->fk_user_action;
|
||||
$this->userdoneid = $obj->fk_user_done;
|
||||
$this->priority = $obj->priority;
|
||||
$this->fulldayevent = $obj->fulldayevent;
|
||||
$this->location = $obj->location;
|
||||
$this->transparency = $obj->transparency;
|
||||
$this->userownerid = $obj->fk_user_action;
|
||||
$this->userdoneid = $obj->fk_user_done;
|
||||
$this->priority = $obj->priority;
|
||||
$this->fulldayevent = $obj->fulldayevent;
|
||||
$this->location = $obj->location;
|
||||
$this->transparency = $obj->transparency;
|
||||
|
||||
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
|
||||
$this->contact_id = $obj->fk_contact; // To have fetch_contact method working
|
||||
$this->fk_project = $obj->fk_project; // To have fetch_projet method working
|
||||
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
|
||||
$this->contact_id = $obj->fk_contact; // To have fetch_contact method working
|
||||
$this->fk_project = $obj->fk_project; // To have fetch_projet method working
|
||||
|
||||
//$this->societe->id = $obj->fk_soc; // deprecated
|
||||
//$this->contact->id = $obj->fk_contact; // deprecated
|
||||
//$this->societe->id = $obj->fk_soc; // deprecated
|
||||
//$this->contact->id = $obj->fk_contact; // deprecated
|
||||
|
||||
$this->fk_element = $obj->elementid;
|
||||
$this->elementid = $obj->elementid;
|
||||
$this->elementtype = $obj->elementtype;
|
||||
$this->fk_element = $obj->elementid;
|
||||
$this->elementid = $obj->elementid;
|
||||
$this->elementtype = $obj->elementtype;
|
||||
|
||||
$this->fetchResources();
|
||||
}
|
||||
$this->db->free($resql);
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
$this->fetchResources();
|
||||
}
|
||||
$this->db->free($resql);
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchResources()
|
||||
{
|
||||
$this->userassigned = array();
|
||||
$this->socpeopleassigned = array();
|
||||
/**
|
||||
* Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchResources()
|
||||
{
|
||||
$this->userassigned = array();
|
||||
$this->socpeopleassigned = array();
|
||||
|
||||
$sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
|
||||
$sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources';
|
||||
$sql .= ' WHERE fk_actioncomm = '.$this->id;
|
||||
$sql .= " AND element_type IN ('user', 'socpeople')";
|
||||
@ -1390,7 +1387,7 @@ class ActionComm extends CommonObject
|
||||
if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL');
|
||||
}
|
||||
|
||||
$tooltip = '<u>'.$langs->trans('Action').'</u>';
|
||||
$tooltip = img_picto('', $this->picto).' <u>'.$langs->trans('Action').'</u>';
|
||||
if (!empty($this->ref))
|
||||
$tooltip .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
if (!empty($label))
|
||||
@ -1937,168 +1934,168 @@ class ActionComm extends CommonObject
|
||||
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the action delayed?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDelay()
|
||||
{
|
||||
global $conf;
|
||||
/**
|
||||
* Is the action delayed?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDelay()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$now = dol_now();
|
||||
$now = dol_now();
|
||||
|
||||
return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay));
|
||||
}
|
||||
return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send reminders by emails
|
||||
* CAN BE A CRON TASK
|
||||
*
|
||||
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
|
||||
*/
|
||||
public function sendEmailsReminder()
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
/**
|
||||
* Send reminders by emails
|
||||
* CAN BE A CRON TASK
|
||||
*
|
||||
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
|
||||
*/
|
||||
public function sendEmailsReminder()
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$this->error = '';
|
||||
$nbMailSend = 0;
|
||||
$errorsMsg = array();
|
||||
|
||||
if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible.
|
||||
if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible.
|
||||
{
|
||||
$langs->load("agenda");
|
||||
$this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda"));
|
||||
return 0;
|
||||
}
|
||||
if (empty($conf->global->AGENDA_REMINDER_EMAIL))
|
||||
{
|
||||
$langs->load("agenda");
|
||||
$this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda"));
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
$langs->load("agenda");
|
||||
$this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
$now = dol_now();
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$this->db->begin();
|
||||
$this->db->begin();
|
||||
|
||||
//Select all action comm reminder
|
||||
$sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder";
|
||||
//Select all action comm reminder
|
||||
$sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder";
|
||||
$sql .= " WHERE typeremind = 'email' AND status = 0";
|
||||
$sql .= " AND dateremind <= '".$this->db->idate(dol_now())."'";
|
||||
$sql .= $this->db->order("dateremind", "ASC");
|
||||
$resql = $this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql) {
|
||||
$formmail = new FormMail($this->db);
|
||||
$actionCommReminder = new ActionCommReminder($this->db);
|
||||
if ($resql) {
|
||||
$formmail = new FormMail($this->db);
|
||||
$actionCommReminder = new ActionCommReminder($this->db);
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql)){
|
||||
$res = $actionCommReminder->fetch($obj->id);
|
||||
if ($res < 0) {
|
||||
$error++;
|
||||
$errorsMsg[] = "Failed to load invoice ActionComm Reminder";
|
||||
}
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$res = $actionCommReminder->fetch($obj->id);
|
||||
if ($res < 0) {
|
||||
$error++;
|
||||
$errorsMsg[] = "Failed to load invoice ActionComm Reminder";
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
//Select email template
|
||||
$arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
|
||||
if (!$error)
|
||||
{
|
||||
//Select email template
|
||||
$arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
|
||||
|
||||
// Load event
|
||||
$res = $this->fetch($actionCommReminder->fk_actioncomm);
|
||||
if ($res > 0)
|
||||
{
|
||||
// PREPARE EMAIL
|
||||
// Load event
|
||||
$res = $this->fetch($actionCommReminder->fk_actioncomm);
|
||||
if ($res > 0)
|
||||
{
|
||||
// PREPARE EMAIL
|
||||
|
||||
// Make substitution in email content
|
||||
$substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this);
|
||||
// Make substitution in email content
|
||||
$substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this);
|
||||
|
||||
complete_substitutions_array($substitutionarray, $langs, $this);
|
||||
complete_substitutions_array($substitutionarray, $langs, $this);
|
||||
|
||||
// Content
|
||||
$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
|
||||
// Content
|
||||
$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
|
||||
|
||||
//Topic
|
||||
$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
|
||||
//Topic
|
||||
$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
|
||||
|
||||
// Recipient
|
||||
$recipient = new User($this->db);
|
||||
$res = $recipient->fetch($actionCommReminder->fk_user);
|
||||
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
|
||||
else {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
// Recipient
|
||||
$recipient = new User($this->db);
|
||||
$res = $recipient->fetch($actionCommReminder->fk_user);
|
||||
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
|
||||
else {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Sender
|
||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
if (empty($from)) {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
// Sender
|
||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
if (empty($from)) {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Errors Recipient
|
||||
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
// Errors Recipient
|
||||
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
|
||||
// Mail Creation
|
||||
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');
|
||||
// Mail Creation
|
||||
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');
|
||||
|
||||
// Sending Mail
|
||||
if ($cMailFile->sendfile())
|
||||
{
|
||||
$actionCommReminder->status = $actionCommReminder::STATUS_DONE;
|
||||
$res = $actionCommReminder->update($user);
|
||||
if ($res < 0)
|
||||
{
|
||||
$errorsMsg[] = "Failed to update status of ActionComm Reminder";
|
||||
$error++;
|
||||
break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first.
|
||||
} else {
|
||||
$nbMailSend++;
|
||||
}
|
||||
} else {
|
||||
$errorsMsg[] = $cMailFile->error.' : '.$to;
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
// Sending Mail
|
||||
if ($cMailFile->sendfile())
|
||||
{
|
||||
$actionCommReminder->status = $actionCommReminder::STATUS_DONE;
|
||||
$res = $actionCommReminder->update($user);
|
||||
if ($res < 0)
|
||||
{
|
||||
$errorsMsg[] = "Failed to update status of ActionComm Reminder";
|
||||
$error++;
|
||||
break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first.
|
||||
} else {
|
||||
$nbMailSend++;
|
||||
}
|
||||
} else {
|
||||
$errorsMsg[] = $cMailFile->error.' : '.$to;
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Delete also very old past events (we do not keep more than 1 month record in past)
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder";
|
||||
if (!$error)
|
||||
{
|
||||
// Delete also very old past events (we do not keep more than 1 month record in past)
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder";
|
||||
$sql .= " WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32))."'";
|
||||
$resql = $this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if (!$resql) {
|
||||
$errorsMsg[] = 'Failed to delete old reminders';
|
||||
//$error++; // If this fails, we must not rollback other SQL requests already done. Never mind.
|
||||
}
|
||||
}
|
||||
if (!$resql) {
|
||||
$errorsMsg[] = 'Failed to delete old reminders';
|
||||
//$error++; // If this fails, we must not rollback other SQL requests already done. Never mind.
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->output = 'Nb of emails sent : '.$nbMailSend;
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
$this->db->rollback();
|
||||
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error;
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
if (!$error) {
|
||||
$this->output = 'Nb of emails sent : '.$nbMailSend;
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
$this->db->rollback();
|
||||
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error;
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Udpate the percent value of a event with the given id
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -429,7 +429,7 @@ if ($resql)
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
|
||||
// Local calendar
|
||||
$newtitle = '<div class="nowrap clear inline-block minheight30">';
|
||||
$newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">';
|
||||
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' ';
|
||||
$newtitle .= '</div>';
|
||||
//$newtitle=$langs->trans($title);
|
||||
|
||||
@ -41,9 +41,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
|
||||
|
||||
$filter = GETPOST("filter", 'alpha', 3);
|
||||
$filtert = GETPOST("filtert", "int", 3);
|
||||
$usergroup = GETPOST("usergroup", "int", 3);
|
||||
$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
|
||||
$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
|
||||
$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
|
||||
//if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
|
||||
//$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
|
||||
$showbirthday = 0;
|
||||
@ -64,7 +64,7 @@ if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "a.datec";
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid", "int");
|
||||
$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int");
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
|
||||
if ($socid < 0) $socid = '';
|
||||
@ -79,22 +79,23 @@ if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no per
|
||||
|
||||
//$action=GETPOST('action','alpha');
|
||||
$action = 'show_pertype';
|
||||
$resourceid = GETPOST("resourceid", "int");
|
||||
$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
|
||||
$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y");
|
||||
$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m");
|
||||
$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
|
||||
$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
|
||||
$pid = GETPOST("projectid", "int", 3);
|
||||
$status = GETPOST("status", 'alpha');
|
||||
$type = GETPOST("type", 'alpha');
|
||||
$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
|
||||
$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha');
|
||||
$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha');
|
||||
$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
|
||||
if (GETPOST('actioncode', 'array'))
|
||||
if (GETPOST('search_actioncode', 'array'))
|
||||
{
|
||||
$actioncode = GETPOST('actioncode', 'array', 3);
|
||||
$actioncode = GETPOST('search_actioncode', 'array', 3);
|
||||
if (!count($actioncode)) $actioncode = '0';
|
||||
} else {
|
||||
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
|
||||
$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
|
||||
}
|
||||
if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
|
||||
|
||||
@ -107,6 +108,7 @@ if ($dateselect > 0)
|
||||
}
|
||||
|
||||
$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS;
|
||||
$tmp = str_replace(' ', '', $tmp); // FIX 7533
|
||||
$tmparray = explode('-', $tmp);
|
||||
$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9);
|
||||
$end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18);
|
||||
@ -115,14 +117,15 @@ if ($end_h < 1 || $end_h > 24) $end_h = 18;
|
||||
if ($end_h <= $begin_h) $end_h = $begin_h + 1;
|
||||
|
||||
$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
|
||||
$tmp = str_replace(' ', '', $tmp); // FIX 7533
|
||||
$tmparray = explode('-', $tmp);
|
||||
$begin_d = 1;
|
||||
$end_d = 53;
|
||||
$end_d = 53;
|
||||
|
||||
if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
|
||||
if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
|
||||
|
||||
if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
|
||||
if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
|
||||
$action = 'show_month'; $day = '';
|
||||
} // View by month
|
||||
if (GETPOST('viewweek', 'alpha') || $action == 'show_week') {
|
||||
@ -150,6 +153,10 @@ if ($action == 'delete_action')
|
||||
{
|
||||
$event = new ActionComm($db);
|
||||
$event->fetch($actionid);
|
||||
$event->fetch_optionals();
|
||||
$event->fetch_userassigned();
|
||||
$event->oldcopy = clone $event;
|
||||
|
||||
$result = $event->delete();
|
||||
}
|
||||
|
||||
@ -159,6 +166,27 @@ if ($action == 'delete_action')
|
||||
* View
|
||||
*/
|
||||
|
||||
$parameters = array(
|
||||
'socid' => $socid,
|
||||
'status' => $status,
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'day' => $day,
|
||||
'type' => $type,
|
||||
'maxprint' => $maxprint,
|
||||
'filter' => $filter,
|
||||
'filtert' => $filtert,
|
||||
'showbirthday' => $showbirthday,
|
||||
'canedit' => $canedit,
|
||||
'optioncss' => $optioncss,
|
||||
'actioncode' => $actioncode,
|
||||
'pid' => $pid,
|
||||
'resourceid' => $resourceid,
|
||||
'usergroup' => $usergroup,
|
||||
);
|
||||
$reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
$form = new Form($db);
|
||||
$companystatic = new Societe($db);
|
||||
|
||||
@ -199,18 +227,26 @@ if ($status == 'done') $title = $langs->trans("DoneActions");
|
||||
if ($status == 'todo') $title = $langs->trans("ToDoActions");
|
||||
|
||||
$param = '';
|
||||
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param .= "&actioncode=".$actioncode;
|
||||
if ($resourceid > 0) $param .= "&resourceid=".$resourceid;
|
||||
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&status=".$status;
|
||||
if ($filter) $param .= "&filter=".$filter;
|
||||
if ($filtert) $param .= "&filtert=".$filtert;
|
||||
if ($usergroup) $param .= "&usergroup=".$usergroup;
|
||||
if ($socid) $param .= "&socid=".$socid;
|
||||
if ($showbirthday) $param .= "&showbirthday=1";
|
||||
if ($pid) $param .= "&projectid=".$pid;
|
||||
if ($type) $param .= "&type=".$type;
|
||||
if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param .= '&action='.$action;
|
||||
$param .= "&maxprint=".$maxprint;
|
||||
if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) {
|
||||
if (is_array($actioncode)) {
|
||||
foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action);
|
||||
} else $param .= "&search_actioncode=".urlencode($actioncode);
|
||||
}
|
||||
if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid);
|
||||
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status);
|
||||
if ($filter) $param .= "&search_filter=".urlencode($filter);
|
||||
if ($filtert) $param .= "&search_filtert=".urlencode($filtert);
|
||||
if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup);
|
||||
if ($socid) $param .= "&search_socid=".urlencode($socid);
|
||||
if ($showbirthday) $param .= "&search_showbirthday=1";
|
||||
if ($pid) $param .= "&search_projectid=".urlencode($pid);
|
||||
if ($type) $param .= "&search_type=".urlencode($type);
|
||||
if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action);
|
||||
if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h);
|
||||
if ($end_h != '') $param .= '&end_h='.urlencode($end_h);
|
||||
if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d);
|
||||
if ($end_d != '') $param .= '&end_d='.urlencode($end_d);
|
||||
$param .= "&maxprint=".urlencode($maxprint);
|
||||
|
||||
$prev = dol_get_first_day($year, 1);
|
||||
$prev_year = $year - 1;
|
||||
@ -238,6 +274,7 @@ $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
|
||||
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
|
||||
|
||||
$tmpday = $first_day;
|
||||
$picto = 'calendartype';
|
||||
|
||||
$nav = "<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n";
|
||||
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y")."</span> \n";
|
||||
@ -245,7 +282,7 @@ $nav .= "<a href=\"?year=".$next_year."&month=".$next_month."&day=".$nex
|
||||
$nav .= " (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
|
||||
$picto = 'calendarweek';
|
||||
|
||||
$nav .= ' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
|
||||
/*$nav .= ' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
|
||||
$nav .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$nav .= '<input type="hidden" name="action" value="'.$action.'">';
|
||||
$nav .= '<input type="hidden" name="filtert" value="'.$filtert.'">';
|
||||
@ -260,27 +297,30 @@ $nav .= '<input type="hidden" name="end_h" value="'.$end_h.'">';
|
||||
$nav .= '<input type="hidden" name="begin_d" value="'.$begin_d.'">';
|
||||
$nav .= '<input type="hidden" name="end_d" value="'.$end_d.'">';
|
||||
$nav .= '<input type="hidden" name="showbirthday" value="'.$showbirthday.'">';
|
||||
|
||||
*/
|
||||
$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
|
||||
$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
|
||||
$nav .= '</form>';
|
||||
//$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
|
||||
$nav .= ' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
|
||||
//$nav .= '</form>';
|
||||
|
||||
// Must be after the nav definition
|
||||
$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : '');
|
||||
$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : '');
|
||||
//print 'x'.$param;
|
||||
|
||||
|
||||
|
||||
|
||||
$tabactive = 'cardpertype';
|
||||
$tabactive = '';
|
||||
if ($action == 'show_month') $tabactive = 'cardmonth';
|
||||
if ($action == 'show_week') $tabactive = 'cardweek';
|
||||
if ($action == 'show_day') $tabactive = 'cardday';
|
||||
if ($action == 'show_list') $tabactive = 'cardlist';
|
||||
if ($action == 'show_peruser') $tabactive = 'cardperuser';
|
||||
if ($action == 'show_pertype') $tabactive = 'cardpertype';
|
||||
|
||||
$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
|
||||
|
||||
$head = calendars_prepare_head($paramnoaction);
|
||||
|
||||
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
|
||||
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
|
||||
dol_fiche_end();
|
||||
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
|
||||
$showextcals = $listofextcals;
|
||||
// Legend
|
||||
@ -334,10 +374,73 @@ if ($conf->use_javascript_ajax)
|
||||
}
|
||||
}
|
||||
|
||||
$massactionbutton = '';
|
||||
|
||||
$viewmode = '';
|
||||
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
|
||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||
$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"');
|
||||
//$viewmode .= '</span>';
|
||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
|
||||
|
||||
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
|
||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||
$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"');
|
||||
//$viewmode .= '</span>';
|
||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
|
||||
|
||||
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
|
||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||
$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
|
||||
//$viewmode .= '</span>';
|
||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
|
||||
|
||||
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
|
||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||
$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
|
||||
//$viewmode .= '</span>';
|
||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
|
||||
|
||||
$viewmode .= '<a class="btnTitle btnTitleSelected reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
|
||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||
$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
|
||||
//$viewmode .= '</span>';
|
||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
|
||||
|
||||
$viewmode .= '<span class="marginrightonly"></span>';
|
||||
|
||||
|
||||
$newcardbutton = '';
|
||||
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
|
||||
{
|
||||
$tmpforcreatebutton = dol_getdate(dol_now(), true);
|
||||
|
||||
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
|
||||
|
||||
//$param='month='.$monthshown.'&year='.$year;
|
||||
$hourminsec = '100000';
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
|
||||
}
|
||||
|
||||
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
|
||||
|
||||
|
||||
$link = '';
|
||||
print load_fiche_titre($s, $link.' '.$nav, '');
|
||||
//print load_fiche_titre('', $link.' '.$nav.' '.$newcardbutton, '');
|
||||
|
||||
// Local calendar
|
||||
$newtitle = '<div class="nowrap clear inline-block minheight30">';
|
||||
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' ';
|
||||
$newtitle .= '</div>';
|
||||
//$newtitle=$langs->trans($title);
|
||||
|
||||
$s = $newtitle;
|
||||
|
||||
print $s;
|
||||
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
|
||||
print '</div>';
|
||||
|
||||
|
||||
// Get event in an array
|
||||
@ -377,7 +480,12 @@ if (!empty($actioncode))
|
||||
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
|
||||
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
|
||||
else {
|
||||
$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
|
||||
if (is_array($actioncode))
|
||||
{
|
||||
$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
|
||||
} else {
|
||||
$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -430,7 +538,7 @@ if ($filtert > 0 || $usergroup > 0)
|
||||
$sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action
|
||||
//print $sql;
|
||||
|
||||
dol_syslog("comm/action/index.php", LOG_DEBUG);
|
||||
dol_syslog("comm/action/pertype.php", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -529,6 +637,7 @@ if ($resql)
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
@ -536,6 +645,7 @@ if ($resql)
|
||||
$maxnbofchar = 18;
|
||||
$cachethirdparties = array();
|
||||
$cachecontacts = array();
|
||||
$cacheusers = array();
|
||||
|
||||
// Define theme_datacolor array
|
||||
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
|
||||
@ -557,11 +667,10 @@ $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam);
|
||||
$newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
|
||||
$newparam .= '&viewweek=1';
|
||||
|
||||
echo '<form id="move_event" action="" method="POST"><input type="hidden" name="action" value="mupdate">';
|
||||
print '<input type="hidden" name="action" value="mupdate">';
|
||||
echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
|
||||
echo '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
echo '<input type="hidden" name="newdate" id="newdate">';
|
||||
echo '</form>';
|
||||
|
||||
|
||||
// Line header with list of days
|
||||
@ -603,6 +712,7 @@ $sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm
|
||||
$resql = $db->query($sql);
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
$typeofevents[$obj->code] = $obj->code;
|
||||
$colorsbytype[$obj->code] = $obj->color;
|
||||
$labelbytype[$obj->code] = $obj->label;
|
||||
}
|
||||
@ -616,7 +726,7 @@ foreach ($typeofevents as $typeofevent)
|
||||
{
|
||||
$var = !$var;
|
||||
echo "<tr>";
|
||||
echo '<td class="cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">'.$username->getNomUrl(1).'</td>';
|
||||
echo '<td class="cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">'.$typeofevent.'</td>';
|
||||
$tmpday = $sav;
|
||||
|
||||
// Lopp on each day of week
|
||||
@ -642,7 +752,7 @@ foreach ($typeofevents as $typeofevent)
|
||||
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1;
|
||||
if ($today) $style = 'cal_today_peruser';
|
||||
|
||||
show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
|
||||
show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, $mont, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -651,7 +761,7 @@ foreach ($typeofevents as $typeofevent)
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
|
||||
echo "<br>";
|
||||
|
||||
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
@ -678,6 +788,9 @@ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
*/
|
||||
}
|
||||
|
||||
print "\n".'</form>';
|
||||
print "\n";
|
||||
|
||||
// Add js code to manage click on a box
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
@ -746,13 +859,13 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
|
||||
global $user, $conf, $langs, $hookmanager, $action;
|
||||
global $filter, $filtert, $status, $actioncode; // Filters used into search form
|
||||
global $theme_datacolor; // Array with a list of different we can use (come from theme)
|
||||
global $cachethirdparties, $cachecontacts, $cacheprojects, $colorindexused;
|
||||
global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
|
||||
global $begin_h, $end_h;
|
||||
|
||||
$cases1 = array(); // Color first half hour
|
||||
$cases2 = array(); // Color second half hour
|
||||
|
||||
$curtime = dol_mktime(0, 0, 0, $month, $day, $year);
|
||||
$curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0);
|
||||
|
||||
$i = 0; $nummytasks = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
|
||||
$ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
|
||||
@ -812,7 +925,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
|
||||
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color;
|
||||
}
|
||||
|
||||
if ($color < 0) // Color was not forced. Set color according to color index.
|
||||
if ($color < 0) // Color was not set on user card. Set color according to color index.
|
||||
{
|
||||
// Define color index if not yet defined
|
||||
$idusertouse = ($event->userownerid ? $event->userownerid : 0);
|
||||
@ -857,8 +970,8 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
|
||||
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour');
|
||||
else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour');
|
||||
}
|
||||
$cases1[$h][$event->id]['string'] .= ' - '.$event->label;
|
||||
$cases1[$h][$event->id]['typecode'] = $event->type_code;
|
||||
if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label;
|
||||
$cases1[$h][$event->id]['typecode'] = $event->type_code;
|
||||
$cases1[$h][$event->id]['color'] = $color;
|
||||
if ($event->fk_project > 0)
|
||||
{
|
||||
@ -903,7 +1016,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
|
||||
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour');
|
||||
else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour');
|
||||
}
|
||||
$cases2[$h][$event->id]['string'] .= ' - '.$event->label;
|
||||
if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label;
|
||||
$cases2[$h][$event->id]['typecode'] = $event->type_code;
|
||||
$cases2[$h][$event->id]['color'] = $color;
|
||||
if ($event->fk_project > 0)
|
||||
|
||||
@ -41,9 +41,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
|
||||
|
||||
$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
|
||||
$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
|
||||
$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
|
||||
$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
|
||||
$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
|
||||
$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
|
||||
//if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
|
||||
//$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
|
||||
$showbirthday = 0;
|
||||
@ -165,6 +165,7 @@ if ($action == 'delete_action')
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$parameters = array(
|
||||
'socid' => $socid,
|
||||
'status' => $status,
|
||||
@ -319,6 +320,7 @@ if ($action == 'show_week') $tabactive = 'cardweek';
|
||||
if ($action == 'show_day') $tabactive = 'cardday';
|
||||
if ($action == 'show_list') $tabactive = 'cardlist';
|
||||
if ($action == 'show_peruser') $tabactive = 'cardperuser';
|
||||
if ($action == 'show_pertype') $tabactive = 'cardpertype';
|
||||
|
||||
$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
|
||||
|
||||
@ -1294,7 +1296,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
}
|
||||
print 'class="';
|
||||
print ($style1 ? $style1.' ' : '');
|
||||
print 'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>';
|
||||
print 'onclickopenref'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>';
|
||||
print $string1;
|
||||
print '</td><td ';
|
||||
if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2 ? $color2 : "888").' !important" ';
|
||||
@ -1304,7 +1306,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
}
|
||||
print 'class="';
|
||||
print ($style2 ? $style2.' ' : '');
|
||||
print 'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2 ? $ids2 : 'none').'"'.($title2 ? ' title="'.$title2.'"' : '').'>';
|
||||
print 'onclickopenref'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2 ? $ids2 : 'none').'"'.($title2 ? ' title="'.$title2.'"' : '').'>';
|
||||
print $string2;
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -231,7 +231,7 @@ if (empty($reshook))
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
if ($ret > 0) $object->fetch_thirdparty();
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
@ -252,7 +252,7 @@ if (empty($reshook))
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
if ($ret > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
@ -353,7 +353,7 @@ if (empty($reshook))
|
||||
$object->socid = GETPOST('socid', 'int');
|
||||
$object->contact_id = GETPOST('contactid', 'int');
|
||||
$object->fk_project = GETPOST('projectid', 'int');
|
||||
$object->modelpdf = GETPOST('model');
|
||||
$object->model_pdf = GETPOST('model');
|
||||
$object->author = $user->id; // deprecated
|
||||
$object->note_private = GETPOST('note_private', 'none');
|
||||
$object->note_public = GETPOST('note_public', 'none');
|
||||
@ -381,7 +381,7 @@ if (empty($reshook))
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->contact_id = GETPOST('contactid', 'int');
|
||||
$object->fk_project = GETPOST('projectid', 'int');
|
||||
$object->modelpdf = GETPOST('model');
|
||||
$object->model_pdf = GETPOST('model');
|
||||
$object->author = $user->id; // deprecated
|
||||
$object->note_private = GETPOST('note_private', 'none');
|
||||
$object->note_public = GETPOST('note_public', 'none');
|
||||
@ -578,7 +578,7 @@ if (empty($reshook))
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -769,7 +769,7 @@ if (empty($reshook))
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
if ($ret > 0) $object->fetch_thirdparty();
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
} elseif ($action == "setabsolutediscount" && $usercancreate) {
|
||||
if ($_POST["remise_id"]) {
|
||||
@ -1101,7 +1101,7 @@ if (empty($reshook))
|
||||
if ($ret > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST['prod_entry_mode']);
|
||||
@ -1243,7 +1243,7 @@ if (empty($reshook))
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
if ($ret > 0) $object->fetch_thirdparty();
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST['qty']);
|
||||
@ -2521,7 +2521,7 @@ if ($action == 'create')
|
||||
$genallowed = $usercanread;
|
||||
$delallowed = $usercancreate;
|
||||
|
||||
print $formfile->showdocuments('propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object);
|
||||
print $formfile->showdocuments('propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object);
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('propal'));
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2019 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2017 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
@ -1061,7 +1061,7 @@ class Propal extends CommonObject
|
||||
$sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "NULL");
|
||||
$sql .= ", '".$this->db->escape($this->note_private)."'";
|
||||
$sql .= ", '".$this->db->escape($this->note_public)."'";
|
||||
$sql .= ", '".$this->db->escape($this->modelpdf)."'";
|
||||
$sql .= ", '".$this->db->escape($this->model_pdf)."'";
|
||||
$sql .= ", ".($this->fin_validite != '' ? "'".$this->db->idate($this->fin_validite)."'" : "NULL");
|
||||
$sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL');
|
||||
$sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL');
|
||||
@ -1494,7 +1494,7 @@ class Propal extends CommonObject
|
||||
$this->project = null; // Clear if another value was already set by fetch_projet
|
||||
|
||||
$this->model_pdf = $obj->model_pdf;
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
$this->modelpdf = $obj->model_pdf; // deprecated
|
||||
$this->last_main_doc = $obj->last_main_doc;
|
||||
$this->note = $obj->note_private; // TODO deprecated
|
||||
$this->note_private = $obj->note_private;
|
||||
@ -1599,7 +1599,7 @@ class Propal extends CommonObject
|
||||
if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client);
|
||||
if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note));
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf);
|
||||
if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf);
|
||||
if (isset($this->import_key)) $this->import_key = trim($this->import_key);
|
||||
if (!empty($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
|
||||
|
||||
@ -2527,13 +2527,13 @@ class Propal extends CommonObject
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf;
|
||||
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf;
|
||||
$triggerName = 'PROPAL_CLOSE_REFUSED';
|
||||
|
||||
if ($status == self::STATUS_SIGNED)
|
||||
{
|
||||
$triggerName = 'PROPAL_CLOSE_SIGNED';
|
||||
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf;
|
||||
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->model_pdf;
|
||||
|
||||
// The connected company is classified as a client
|
||||
$soc = new Societe($this->db);
|
||||
@ -2911,9 +2911,9 @@ class Propal extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$main = MAIN_DB_PREFIX.'propaldet';
|
||||
$ef = $main."_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")";
|
||||
$main = MAIN_DB_PREFIX.'propaldet';
|
||||
$ef = $main."_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||
if ($this->db->query($sqlef) && $this->db->query($sql))
|
||||
{
|
||||
@ -2930,6 +2930,9 @@ class Propal extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
|
||||
$this->deleteEcmFiles();
|
||||
|
||||
// We remove directory
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref))
|
||||
@ -3541,7 +3544,7 @@ class Propal extends CommonObject
|
||||
|
||||
if ($user->rights->propal->lire)
|
||||
{
|
||||
$label = '<u>'.$langs->trans("Proposal").'</u>';
|
||||
$label = img_picto('', $this->picto).' <u>'.$langs->trans("Proposal").'</u>';
|
||||
if (!empty($this->ref))
|
||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
if (!empty($this->ref_client))
|
||||
@ -3671,8 +3674,8 @@ class Propal extends CommonObject
|
||||
if (!dol_strlen($modele)) {
|
||||
$modele = 'azur';
|
||||
|
||||
if ($this->modelpdf) {
|
||||
$modele = $this->modelpdf;
|
||||
if ($this->model_pdf) {
|
||||
$modele = $this->model_pdf;
|
||||
} elseif (!empty($conf->global->PROPALE_ADDON_PDF)) {
|
||||
$modele = $conf->global->PROPALE_ADDON_PDF;
|
||||
}
|
||||
|
||||
@ -1291,21 +1291,21 @@ if ($resql)
|
||||
foreach ($toselect as $checked) {
|
||||
if ($tmpproposal->fetch($checked)) {
|
||||
if ($tmpproposal->statut == 0) {
|
||||
if ($tmpproposal->valid($user)){
|
||||
setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs');
|
||||
if ($tmpproposal->valid($user)) {
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs');
|
||||
} else {
|
||||
setEventMessage($langs->trans('CantBeValidated'), 'errors');
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors');
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
dol_print_error($db);
|
||||
$error++;
|
||||
}
|
||||
if ($error){
|
||||
if ($error) {
|
||||
$db->rollback();
|
||||
} else {
|
||||
$db->commit();
|
||||
@ -1323,13 +1323,13 @@ if ($resql)
|
||||
if ($tmpproposal->statut == 1) {
|
||||
$tmpproposal->statut = 2;
|
||||
if ($tmpproposal->update($user)) {
|
||||
setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs');
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs');
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors');
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors');
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
@ -1337,7 +1337,7 @@ if ($resql)
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if ($error){
|
||||
if ($error) {
|
||||
$db->rollback();
|
||||
} else {
|
||||
$db->commit();
|
||||
|
||||
@ -221,7 +221,7 @@ if (empty($reshook))
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$ret = $object->fetch($object->id); // Reload to get new records
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
@ -268,7 +268,7 @@ if (empty($reshook))
|
||||
$object->source = GETPOST('source_id');
|
||||
$object->fk_project = GETPOST('projectid', 'int');
|
||||
$object->ref_client = GETPOST('ref_client', 'alpha');
|
||||
$object->modelpdf = GETPOST('model');
|
||||
$object->model_pdf = GETPOST('model');
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
@ -584,7 +584,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
$ret = $object->fetch($object->id); // Reload to get new records
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -940,7 +940,7 @@ if (empty($reshook))
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST['prod_entry_mode']);
|
||||
@ -1084,7 +1084,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
$ret = $object->fetch($object->id); // Reload to get new records
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST['qty']);
|
||||
@ -1158,7 +1158,7 @@ if (empty($reshook))
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -1207,7 +1207,7 @@ if (empty($reshook))
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -2627,7 +2627,7 @@ if ($action == 'create' && $usercancreate)
|
||||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed = $usercanread;
|
||||
$delallowed = $usercancreate;
|
||||
print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object);
|
||||
print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object);
|
||||
|
||||
|
||||
// Show links to link elements
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
@ -99,13 +99,13 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public $ref_client;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @var string Internal ref for order
|
||||
* @deprecated
|
||||
*/
|
||||
public $ref_int;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @var int Contact ID
|
||||
*/
|
||||
public $contactid;
|
||||
@ -121,15 +121,15 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public $billed;
|
||||
|
||||
/**
|
||||
* @var int Draft Status of the order
|
||||
*/
|
||||
public $brouillon;
|
||||
public $cond_reglement_code;
|
||||
/**
|
||||
* @var int Draft Status of the order
|
||||
*/
|
||||
public $brouillon;
|
||||
public $cond_reglement_code;
|
||||
|
||||
/**
|
||||
* @var int bank account ID
|
||||
*/
|
||||
* @var int bank account ID
|
||||
*/
|
||||
public $fk_account;
|
||||
|
||||
/**
|
||||
@ -168,12 +168,12 @@ class Commande extends CommonOrder
|
||||
public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...)
|
||||
public $demand_reason_code;
|
||||
/**
|
||||
* @var int Date of order
|
||||
* @var int Date of order
|
||||
*/
|
||||
public $date;
|
||||
|
||||
/**
|
||||
* @var int Date of order
|
||||
* @var int Date of order
|
||||
* @deprecated
|
||||
* @see $date
|
||||
*/
|
||||
@ -182,8 +182,8 @@ class Commande extends CommonOrder
|
||||
public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_remise_except;
|
||||
|
||||
public $remise_percent;
|
||||
@ -197,13 +197,13 @@ class Commande extends CommonOrder
|
||||
public $linked_objects = array();
|
||||
|
||||
/**
|
||||
* @var int User author ID
|
||||
*/
|
||||
* @var int User author ID
|
||||
*/
|
||||
public $user_author_id;
|
||||
|
||||
/**
|
||||
* @var int User validator ID
|
||||
*/
|
||||
/**
|
||||
* @var int User validator ID
|
||||
*/
|
||||
public $user_valid;
|
||||
|
||||
/**
|
||||
@ -213,8 +213,8 @@ class Commande extends CommonOrder
|
||||
|
||||
// Multicurrency
|
||||
/**
|
||||
* @var int Currency ID
|
||||
*/
|
||||
* @var int Currency ID
|
||||
*/
|
||||
public $fk_multicurrency;
|
||||
|
||||
public $multicurrency_code;
|
||||
@ -223,9 +223,9 @@ class Commande extends CommonOrder
|
||||
public $multicurrency_total_tva;
|
||||
public $multicurrency_total_ttc;
|
||||
|
||||
/**
|
||||
* @var Commande clone of order object
|
||||
*/
|
||||
/**
|
||||
* @var Commande clone of order object
|
||||
*/
|
||||
public $oldcopy;
|
||||
|
||||
//! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...)
|
||||
@ -394,11 +394,11 @@ class Commande extends CommonOrder
|
||||
$mybool |= @include_once $dir.$file;
|
||||
}
|
||||
|
||||
if ($mybool === false)
|
||||
{
|
||||
dol_print_error('', "Failed to include file ".$file);
|
||||
return '';
|
||||
}
|
||||
if ($mybool === false)
|
||||
{
|
||||
dol_print_error('', "Failed to include file ".$file);
|
||||
return '';
|
||||
}
|
||||
|
||||
$obj = new $classname();
|
||||
$numref = $obj->getNextValue($soc, $this);
|
||||
@ -568,7 +568,7 @@ class Commande extends CommonOrder
|
||||
{
|
||||
$this->ref = $num;
|
||||
$this->statut = self::STATUS_VALIDATED;
|
||||
$this->brouillon = 0;
|
||||
$this->brouillon = 0;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
@ -589,9 +589,9 @@ class Commande extends CommonOrder
|
||||
* @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setDraft($user, $idwarehouse = -1)
|
||||
{
|
||||
//phpcs:enable
|
||||
public function setDraft($user, $idwarehouse = -1)
|
||||
{
|
||||
//phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
@ -619,12 +619,12 @@ class Commande extends CommonOrder
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if (!$error)
|
||||
{
|
||||
$this->oldcopy = clone $this;
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
$this->oldcopy = clone $this;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
$result = 0;
|
||||
@ -665,7 +665,7 @@ class Commande extends CommonOrder
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
@ -678,7 +678,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function set_reopen($user)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$error = 0;
|
||||
|
||||
if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED)
|
||||
@ -943,7 +943,7 @@ class Commande extends CommonOrder
|
||||
$sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null");
|
||||
$sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null");
|
||||
$sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null");
|
||||
$sql .= ", '".$this->db->escape($this->modelpdf)."'";
|
||||
$sql .= ", '".$this->db->escape($this->model_pdf)."'";
|
||||
$sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : "null");
|
||||
$sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "null");
|
||||
$sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL');
|
||||
@ -958,7 +958,7 @@ class Commande extends CommonOrder
|
||||
$sql .= ", ".(int) $this->fk_incoterms;
|
||||
$sql .= ", '".$this->db->escape($this->location_incoterms)."'";
|
||||
$sql .= ", ".setEntity($this);
|
||||
$sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null");
|
||||
$sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null");
|
||||
$sql .= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null");
|
||||
$sql .= ", ".(int) $this->fk_multicurrency;
|
||||
$sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
@ -1009,7 +1009,7 @@ class Commande extends CommonOrder
|
||||
$line->ref_ext = '';
|
||||
}
|
||||
|
||||
$result = $this->addline(
|
||||
$result = $this->addline(
|
||||
$line->desc,
|
||||
$line->subprice,
|
||||
$line->qty,
|
||||
@ -1033,10 +1033,10 @@ class Commande extends CommonOrder
|
||||
$line->label,
|
||||
$line->array_options,
|
||||
$line->fk_unit,
|
||||
$origintype,
|
||||
$originid,
|
||||
$origintype,
|
||||
$originid,
|
||||
0,
|
||||
$line->ref_ext
|
||||
$line->ref_ext
|
||||
);
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -1357,8 +1357,8 @@ class Commande extends CommonOrder
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN))
|
||||
{
|
||||
$this->note_private = $object->note_private;
|
||||
$this->note_public = $object->note_public;
|
||||
$this->note_private = $object->note_private;
|
||||
$this->note_public = $object->note_public;
|
||||
}
|
||||
|
||||
$this->origin = $object->element;
|
||||
@ -1502,7 +1502,7 @@ class Commande extends CommonOrder
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
$this->db->begin();
|
||||
|
||||
$product_type = $type;
|
||||
if (!empty($fk_product))
|
||||
@ -1681,7 +1681,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf, $mysoc;
|
||||
|
||||
if (!$qty) $qty = 1;
|
||||
@ -1780,7 +1780,7 @@ class Commande extends CommonOrder
|
||||
$sql .= ', c.fk_incoterms, c.location_incoterms';
|
||||
$sql .= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc";
|
||||
$sql .= ", c.module_source, c.pos_source";
|
||||
$sql .= ", i.libelle as label_incoterms";
|
||||
$sql .= ", i.libelle as label_incoterms";
|
||||
$sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql .= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
|
||||
$sql .= ', ca.code as availability_code, ca.label as availability_label';
|
||||
@ -1843,7 +1843,7 @@ class Commande extends CommonOrder
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->model_pdf = $obj->model_pdf;
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
$this->modelpdf = $obj->model_pdf; // deprecated
|
||||
$this->last_main_doc = $obj->last_main_doc;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->mode_reglement_code = $obj->mode_reglement_code;
|
||||
@ -1917,7 +1917,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function insert_discount($idremise)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
@ -1992,7 +1992,7 @@ class Commande extends CommonOrder
|
||||
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$this->lines = array();
|
||||
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,';
|
||||
@ -2086,13 +2086,13 @@ class Commande extends CommonOrder
|
||||
$line->fetch_optionals();
|
||||
|
||||
// multilangs
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) {
|
||||
$line = new Product($this->db);
|
||||
$line->fetch($objp->fk_product);
|
||||
$line->getMultiLangs();
|
||||
}
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) {
|
||||
$line = new Product($this->db);
|
||||
$line->fetch($objp->fk_product);
|
||||
$line->getMultiLangs();
|
||||
}
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -2224,7 +2224,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function nb_expedition()
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$sql = 'SELECT count(*)';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
|
||||
$sql .= ', '.MAIN_DB_PREFIX.'element_element as el';
|
||||
@ -2251,7 +2251,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function stock_array($filtre_statut = self::STATUS_CANCELED)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$this->stocks = array();
|
||||
|
||||
// Tableau des id de produit de la commande
|
||||
@ -2359,7 +2359,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function set_remise($user, $remise, $notrigger = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$remise = trim($remise) ?trim($remise) : 0;
|
||||
|
||||
if ($user->rights->commande->creer)
|
||||
@ -2425,7 +2425,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function set_remise_absolue($user, $remise, $notrigger = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$remise = trim($remise) ?trim($remise) : 0;
|
||||
|
||||
if ($user->rights->commande->creer)
|
||||
@ -2491,7 +2491,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function set_date($user, $date, $notrigger = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
if ($user->rights->commande->creer)
|
||||
{
|
||||
$error = 0;
|
||||
@ -2553,7 +2553,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function set_date_livraison($user, $date_livraison, $notrigger = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
if ($user->rights->commande->creer)
|
||||
{
|
||||
$error = 0;
|
||||
@ -2620,7 +2620,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC')
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $user;
|
||||
|
||||
$ga = array();
|
||||
@ -2750,7 +2750,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function demand_reason($demand_reason_id, $notrigger = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $user;
|
||||
|
||||
dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
|
||||
@ -2819,7 +2819,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function set_ref_client($user, $ref_client, $notrigger = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
if ($user->rights->commande->creer)
|
||||
{
|
||||
$error = 0;
|
||||
@ -3211,7 +3211,7 @@ class Commande extends CommonOrder
|
||||
if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client);
|
||||
if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note));
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf);
|
||||
if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf);
|
||||
if (isset($this->import_key)) $this->import_key = trim($this->import_key);
|
||||
|
||||
// Check parameters
|
||||
@ -3321,9 +3321,9 @@ class Commande extends CommonOrder
|
||||
if (!$error)
|
||||
{
|
||||
// Delete extrafields of order details
|
||||
$main = MAIN_DB_PREFIX.'commandedet';
|
||||
$ef = $main."_extrafields";
|
||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")";
|
||||
$main = MAIN_DB_PREFIX.'commandedet';
|
||||
$ef = $main."_extrafields";
|
||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")";
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
@ -3380,6 +3380,9 @@ class Commande extends CommonOrder
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
|
||||
$this->deleteEcmFiles();
|
||||
|
||||
// Remove directory with files
|
||||
$comref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref))
|
||||
@ -3432,7 +3435,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function load_board($user)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
$clause = " WHERE";
|
||||
@ -3521,45 +3524,45 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function LibStatut($status, $billed, $mode, $donotshowbilled = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
$billedtext = '';
|
||||
if (empty($donotshowbilled)) $billedtext .= ($billed ? ' - '.$langs->trans("Billed") : '');
|
||||
|
||||
if ($status == self::STATUS_CANCELED) {
|
||||
$labelStatus = $langs->trans('StatusOrderCanceled');
|
||||
$labelStatusShort = $langs->trans('StatusOrderCanceledShort');
|
||||
$statusType = 'status9';
|
||||
$labelStatus = $langs->trans('StatusOrderCanceled');
|
||||
$labelStatusShort = $langs->trans('StatusOrderCanceledShort');
|
||||
$statusType = 'status9';
|
||||
} elseif ($status == self::STATUS_DRAFT) {
|
||||
$labelStatus = $langs->trans('StatusOrderDraft');
|
||||
$labelStatusShort = $langs->trans('StatusOrderDraftShort');
|
||||
$statusType = 'status0';
|
||||
$labelStatus = $langs->trans('StatusOrderDraft');
|
||||
$labelStatusShort = $langs->trans('StatusOrderDraftShort');
|
||||
$statusType = 'status0';
|
||||
} elseif ($status == self::STATUS_VALIDATED) {
|
||||
$labelStatus = $langs->trans('StatusOrderValidated').$billedtext;
|
||||
$labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext;
|
||||
$statusType = 'status1';
|
||||
$labelStatus = $langs->trans('StatusOrderValidated').$billedtext;
|
||||
$labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext;
|
||||
$statusType = 'status1';
|
||||
} elseif ($status == self::STATUS_SHIPMENTONPROCESS) {
|
||||
$labelStatus = $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
$labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
$statusType = 'status4';
|
||||
$labelStatus = $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
$labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
$statusType = 'status4';
|
||||
} elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
|
||||
$labelStatus = $langs->trans('StatusOrderToBill');
|
||||
$labelStatusShort = $langs->trans('StatusOrderToBillShort');
|
||||
$statusType = 'status4';
|
||||
$labelStatus = $langs->trans('StatusOrderToBill');
|
||||
$labelStatusShort = $langs->trans('StatusOrderToBillShort');
|
||||
$statusType = 'status4';
|
||||
} elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
|
||||
$labelStatus = $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
$labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
$statusType = 'status6';
|
||||
$labelStatus = $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
$labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
$statusType = 'status6';
|
||||
} elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
|
||||
$labelStatus = $langs->trans('StatusOrderDelivered');
|
||||
$labelStatusShort = $langs->trans('StatusOrderDelivered');
|
||||
$statusType = 'status6';
|
||||
$labelStatus = $langs->trans('StatusOrderDelivered');
|
||||
$labelStatusShort = $langs->trans('StatusOrderDelivered');
|
||||
$statusType = 'status6';
|
||||
} else {
|
||||
$labelStatus = $langs->trans('Unknown');
|
||||
$labelStatusShort = '';
|
||||
$statusType = '';
|
||||
$mode = 0;
|
||||
$labelStatus = $langs->trans('Unknown');
|
||||
$labelStatusShort = '';
|
||||
$statusType = '';
|
||||
$mode = 0;
|
||||
}
|
||||
|
||||
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
|
||||
@ -3605,7 +3608,7 @@ class Commande extends CommonOrder
|
||||
$label = '';
|
||||
|
||||
if ($user->rights->commande->lire) {
|
||||
$label = '<u>'.$langs->trans("Order").'</u>';
|
||||
$label = img_picto('', $this->picto).' <u>'.$langs->trans("Order").'</u>';
|
||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
$label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
|
||||
if (!empty($this->total_ht)) {
|
||||
@ -3825,7 +3828,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function load_state_board()
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $user;
|
||||
|
||||
$this->nb = array();
|
||||
@ -4024,10 +4027,10 @@ class OrderLine extends CommonOrderLine
|
||||
*
|
||||
* @param DoliDB $db handler d'acces base de donnee
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load line order
|
||||
@ -4125,32 +4128,32 @@ class OrderLine extends CommonOrderLine
|
||||
|
||||
$error = 0;
|
||||
|
||||
// check if order line is not in a shipment line before deleting
|
||||
$sqlCheckShipmentLine = "SELECT";
|
||||
$sqlCheckShipmentLine .= " ed.rowid";
|
||||
$sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed";
|
||||
$sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid;
|
||||
// check if order line is not in a shipment line before deleting
|
||||
$sqlCheckShipmentLine = "SELECT";
|
||||
$sqlCheckShipmentLine .= " ed.rowid";
|
||||
$sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed";
|
||||
$sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid;
|
||||
|
||||
$resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine);
|
||||
if (!$resqlCheckShipmentLine) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
} else {
|
||||
$langs->load('errors');
|
||||
$num = $this->db->num_rows($resqlCheckShipmentLine);
|
||||
if ($num > 0) {
|
||||
$error++;
|
||||
$objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine);
|
||||
$this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid;
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
$this->db->free($resqlCheckShipmentLine);
|
||||
}
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
$resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine);
|
||||
if (!$resqlCheckShipmentLine) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
} else {
|
||||
$langs->load('errors');
|
||||
$num = $this->db->num_rows($resqlCheckShipmentLine);
|
||||
if ($num > 0) {
|
||||
$error++;
|
||||
$objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine);
|
||||
$this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid;
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
$this->db->free($resqlCheckShipmentLine);
|
||||
}
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -4482,7 +4485,7 @@ class OrderLine extends CommonOrderLine
|
||||
*/
|
||||
public function update_total()
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$this->db->begin();
|
||||
|
||||
// Clean parameters
|
||||
|
||||
@ -65,10 +65,10 @@ $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
|
||||
$search_company = GETPOST('search_company', 'alpha');
|
||||
$search_town = GETPOST('search_town', 'alpha');
|
||||
$search_zip = GETPOST('search_zip', 'alpha');
|
||||
$search_state = GETPOST("search_state");
|
||||
$search_state = GETPOST("search_state", 'alpha');
|
||||
$search_country = GETPOST("search_country", 'int');
|
||||
$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
|
||||
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||
$socid = GETPOST('socid', 'int');
|
||||
$search_user = GETPOST('search_user', 'int');
|
||||
$search_sale = GETPOST('search_sale', 'int');
|
||||
@ -84,7 +84,7 @@ $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc',
|
||||
$search_login = GETPOST('search_login', 'alpha');
|
||||
$search_categ_cus = GETPOST("search_categ_cus", 'int');
|
||||
$optioncss = GETPOST('optioncss', 'alpha');
|
||||
$billed = GETPOST('billed', 'int');
|
||||
$search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int');
|
||||
$search_status = GETPOST('search_status', 'int');
|
||||
$search_btn = GETPOST('button_search', 'alpha');
|
||||
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
|
||||
@ -224,7 +224,7 @@ if (empty($reshook))
|
||||
$search_project_ref = '';
|
||||
$search_project = '';
|
||||
$search_status = '';
|
||||
$billed = '';
|
||||
$search_billed = '';
|
||||
$toselect = '';
|
||||
$search_array_options = array();
|
||||
$search_categ_cus = 0;
|
||||
@ -309,7 +309,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc
|
||||
if ($search_ref) $sql .= natural_search('c.ref', $search_ref);
|
||||
if ($search_ref_customer) $sql .= natural_search('c.ref_client', $search_ref_customer);
|
||||
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
if ($billed != '' && $billed >= 0) $sql .= ' AND c.facture = '.$billed;
|
||||
if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND c.facture = '.$search_billed;
|
||||
if ($search_status <> '')
|
||||
{
|
||||
if ($search_status < 4 && $search_status > -3)
|
||||
@ -466,7 +466,7 @@ if ($resql)
|
||||
if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
|
||||
if ($show_files) $param .= '&show_files='.urlencode($show_files);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($billed != '') $param .= '&billed='.urlencode($billed);
|
||||
if ($search_billed != '') $param .= '&search_billed='.urlencode($search_billed);
|
||||
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
@ -755,7 +755,7 @@ if ($resql)
|
||||
}
|
||||
if (!empty($arrayfields['c.multicurrency_total_vat']['checked']))
|
||||
{
|
||||
// Amount
|
||||
// Amount VAT
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
|
||||
print '</td>';
|
||||
@ -817,7 +817,7 @@ if ($resql)
|
||||
if (!empty($arrayfields['c.facture']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
|
||||
print $form->selectyesno('billed', $billed, 1, 0, 1);
|
||||
print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
|
||||
print '</td>';
|
||||
}
|
||||
// Action column
|
||||
|
||||
@ -167,7 +167,7 @@ if (($action == 'create' || $action == 'add') && !$error)
|
||||
$object->note_public = trim($_POST['note_public']);
|
||||
$object->note = trim($_POST['note']);
|
||||
$object->ref_client = $_POST['ref_client'];
|
||||
$object->modelpdf = $_POST['model'];
|
||||
$object->model_pdf = $_POST['model'];
|
||||
$object->fk_project = $_POST['projectid'];
|
||||
$object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']);
|
||||
$object->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
|
||||
@ -472,7 +472,7 @@ class Account extends CommonObject
|
||||
* @param string $oper 'VIR','PRE','LIQ','VAD','CB','CHQ'...
|
||||
* @param string $label Descripton
|
||||
* @param float $amount Amount
|
||||
* @param string $num_chq Numero cheque ou virement
|
||||
* @param string $num_chq Numero cheque or transfer
|
||||
* @param int $categorie Category id (optionnal)
|
||||
* @param User $user User that create
|
||||
* @param string $emetteur Name of cheque writer
|
||||
@ -566,15 +566,18 @@ class Account extends CommonObject
|
||||
if (!$result) {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
return $accline->id;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
@ -1353,7 +1356,7 @@ class Account extends CommonObject
|
||||
global $conf, $langs, $user;
|
||||
|
||||
$result = '';
|
||||
$label = '<u>'.$langs->trans("BankAccount").'</u>';
|
||||
$label = img_picto('', $this->picto).' <u>'.$langs->trans("BankAccount").'</u>';
|
||||
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
|
||||
$label .= '<br><b>'.$langs->trans('AccountNumber').':</b> '.$this->number;
|
||||
$label .= '<br><b>'.$langs->trans('IBAN').':</b> '.$this->iban;
|
||||
|
||||
@ -95,6 +95,37 @@ class PaymentVarious extends CommonObject
|
||||
public $fk_user_modif;
|
||||
|
||||
|
||||
/**
|
||||
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
|
||||
* 'position' is the sort order of field.
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'noteditable' says if field is not editable (1 or 0)
|
||||
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
||||
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
|
||||
* 'css' is the CSS style to use on field. For example: 'maxwidth200'
|
||||
* 'help' is a string visible as a tooltip on field
|
||||
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
||||
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
||||
* 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
|
||||
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
|
||||
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
|
||||
*
|
||||
* Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
|
||||
*/
|
||||
|
||||
// BEGIN MODULEBUILDER PROPERTIES
|
||||
public $fields = array(
|
||||
// TODO: fill this array
|
||||
);
|
||||
// END MODULEBUILDER PROPERTIES
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -29,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("compta", "banks", "bills", "accountancy"));
|
||||
@ -44,11 +46,14 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$search_ref = GETPOST('search_ref', 'int');
|
||||
$search_user = GETPOST('search_user', 'alpha');
|
||||
$search_label = GETPOST('search_label', 'alpha');
|
||||
$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_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
|
||||
$search_datep_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
|
||||
$search_datep_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
|
||||
$search_datev_start = dol_mktime(0, 0, 0, GETPOST('search_date_value_startmonth', 'int'), GETPOST('search_date_value_startday', 'int'), GETPOST('search_date_value_startyear', 'int'));
|
||||
$search_datev_end = dol_mktime(23, 59, 59, GETPOST('search_date_value_endmonth', 'int'), GETPOST('search_date_value_endday', 'int'), GETPOST('search_date_value_endyear', 'int'));
|
||||
$search_amount_deb = GETPOST('search_amount_deb', 'alpha');
|
||||
$search_amount_cred = GETPOST('search_amount_cred', 'alpha');
|
||||
$search_account = GETPOST('search_account', 'int');
|
||||
$search_bank_account = GETPOST('search_account', 'int');
|
||||
$search_bank_entry = GETPOST('search_bank_entry', 'int');
|
||||
$search_accountancy_account = GETPOST("search_accountancy_account");
|
||||
if ($search_accountancy_account == - 1) $search_accountancy_account = '';
|
||||
$search_accountancy_subledger = GETPOST("search_accountancy_subledger");
|
||||
@ -81,31 +86,97 @@ if (!GETPOST('typeid'))
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
|
||||
{
|
||||
$search_ref = "";
|
||||
$search_label = "";
|
||||
$search_date_start = '';
|
||||
$search_date_end = '';
|
||||
$search_amount_deb = "";
|
||||
$search_amount_cred = "";
|
||||
$search_account = '';
|
||||
$search_ref = '';
|
||||
$search_label = '';
|
||||
$search_datep_start = '';
|
||||
$search_datep_end = '';
|
||||
$search_datev_start = '';
|
||||
$search_datev_end = '';
|
||||
$search_amount_deb = '';
|
||||
$search_amount_cred = '';
|
||||
$search_bank_account = '';
|
||||
$search_bank_entry = '';
|
||||
$search_accountancy_account = '';
|
||||
$search_accountancy_subledger = '';
|
||||
$typeid = "";
|
||||
$typeid = '';
|
||||
}
|
||||
|
||||
$search_all = GETPOSTISSET("search_all") ? trim(GETPOST("search_all", 'alpha')) : trim(GETPOST('sall'));
|
||||
|
||||
/*
|
||||
* TODO: fill array "$fields" in "/compta/bank/class/paymentvarious.class.php" and use
|
||||
*
|
||||
*
|
||||
* $object = new PaymentVarious($db);
|
||||
*
|
||||
* $search = array();
|
||||
* foreach ($object->fields as $key => $val)
|
||||
* {
|
||||
* if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
* }
|
||||
|
||||
* $fieldstosearchall = array();
|
||||
* foreach ($object->fields as $key => $val)
|
||||
* {
|
||||
* if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array(
|
||||
'v.rowid'=>"Ref",
|
||||
'v.label'=>"Label",
|
||||
'v.datep'=>"DatePayment",
|
||||
'v.datev'=>"DateValue",
|
||||
'v.amount'=>$langs->trans("Debit").", ".$langs->trans("Credit"),
|
||||
);
|
||||
|
||||
// Definition of fields for lists
|
||||
$arrayfields = array(
|
||||
'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100),
|
||||
'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110),
|
||||
'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120),
|
||||
'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130),
|
||||
'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140),
|
||||
'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)),
|
||||
'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)),
|
||||
'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)),
|
||||
'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)),
|
||||
'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)),
|
||||
'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500),
|
||||
'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510),
|
||||
);
|
||||
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
$formaccounting = new FormAccounting($db);
|
||||
$variousstatic = new PaymentVarious($db);
|
||||
$accountstatic = new Account($db);
|
||||
if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db);
|
||||
if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db);
|
||||
if ($arrayfields['ref']['checked']) $variousstatic = new PaymentVarious($db);
|
||||
if ($arrayfields['bank']['checked']) $accountstatic = new Account($db);
|
||||
if ($arrayfields['project']['checked']) $proj = new Project($db);
|
||||
if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db);
|
||||
if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($db);
|
||||
|
||||
$sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account,";
|
||||
$sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project,";
|
||||
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
|
||||
$sql .= " pst.code as payment_code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
|
||||
@ -117,11 +188,14 @@ $sql .= " WHERE v.entity IN (".getEntity('payment_various').")";
|
||||
// Search criteria
|
||||
if ($search_ref) $sql .= " AND v.rowid=".$db->escape($search_ref);
|
||||
if ($search_label) $sql .= natural_search(array('v.label'), $search_label);
|
||||
if ($search_date_start) $sql .= " AND v.datep >= '".$db->idate($search_date_start)."'";
|
||||
if ($search_date_end) $sql .= " AND v.datep <= '".$db->idate($search_date_end)."'";
|
||||
if ($search_datep_start) $sql .= " AND v.datep >= '".$db->idate($search_datep_start)."'";
|
||||
if ($search_datep_end) $sql .= " AND v.datep <= '".$db->idate($search_datep_end)."'";
|
||||
if ($search_datev_start) $sql .= " AND v.datev >= '".$db->idate($search_datev_start)."'";
|
||||
if ($search_datev_end) $sql .= " AND v.datev <= '".$db->idate($search_datev_end)."'";
|
||||
if ($search_amount_deb) $sql .= natural_search("v.amount", $search_amount_deb, 1);
|
||||
if ($search_amount_cred) $sql .= natural_search("v.amount", $search_amount_cred, 1);
|
||||
if ($search_account > 0) $sql .= " AND b.fk_account=".$db->escape($search_account);
|
||||
if ($search_bank_account > 0) $sql .= " AND b.fk_account=".$db->escape($search_bank_account);
|
||||
if ($search_bank_entry > 0) $sql .= " AND b.fk_account=".$db->escape($search_bank_account);
|
||||
if ($search_accountancy_account > 0) $sql .= " AND v.accountancy_code=".$db->escape($search_accountancy_account);
|
||||
if ($search_accountancy_subledger > 0) $sql .= " AND v.subledger_account=".$db->escape($search_accountancy_subledger);
|
||||
if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid;
|
||||
@ -129,6 +203,7 @@ if ($filtre) {
|
||||
$filtre = str_replace(":", "=", $filtre);
|
||||
$sql .= " AND ".$filtre;
|
||||
}
|
||||
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
@ -144,6 +219,19 @@ $result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
// Direct jump if only one record found
|
||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$id = $obj->rowid;
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
// must be place behind the last "header(...)" call
|
||||
llxHeader();
|
||||
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
|
||||
@ -154,10 +242,10 @@ if ($result)
|
||||
if ($search_label) $param .= '&search_label='.urlencode($search_label);
|
||||
if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start);
|
||||
if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end);
|
||||
if ($typeid > 0) $param .= '&typeid='.urlencode($typeid);
|
||||
if ($search_amount_deb) $param .= '&search_amount_deb='.urlencode($search_amount_deb);
|
||||
if ($search_amount_cred) $param .= '&search_amount_cred='.urlencode($search_amount_cred);
|
||||
if ($search_account > 0) $param .= '&search_amount='.urlencode($search_account);
|
||||
if ($typeid > 0) $param .= '&typeid='.urlencode($typeid);
|
||||
if ($search_amount_deb) $param .= '&search_amount_deb='.urlencode($search_amount_deb);
|
||||
if ($search_amount_cred) $param .= '&search_amount_cred='.urlencode($search_amount_cred);
|
||||
if ($search_bank_account > 0) $param .= '&search_amount='.urlencode($search_bank_account);
|
||||
if ($search_accountancy_account > 0) $param .= '&search_accountancy_account='.urlencode($search_accountancy_account);
|
||||
if ($search_accountancy_subledger > 0) $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger);
|
||||
|
||||
@ -177,59 +265,110 @@ if ($result)
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||
|
||||
if ($search_all)
|
||||
{
|
||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Ref
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||
print '</td>';
|
||||
if ($arrayfields['ref']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Label
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
|
||||
|
||||
// Date
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From').' ';
|
||||
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to').' ';
|
||||
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1);
|
||||
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
|
||||
// Type
|
||||
print '<td class="liste_titre left">';
|
||||
$form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16);
|
||||
print '</td>';
|
||||
|
||||
// Account
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if ($arrayfields['label']['checked']) {
|
||||
print '<td class="liste_titre">';
|
||||
$form->select_comptes($search_account, 'search_account', 0, '', 1);
|
||||
print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment date
|
||||
if ($arrayfields['datep']['checked']) {
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From').' ';
|
||||
print $form->selectDate($search_datep_start ? $search_datep_start : -1, 'search_date_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to').' ';
|
||||
print $form->selectDate($search_datep_end ? $search_datep_end : -1, 'search_date_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Value date
|
||||
if ($arrayfields['datev']['checked']) {
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From').' ';
|
||||
print $form->selectDate($search_datev_start ? $search_datev_start : -1, 'search_date_value_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to').' ';
|
||||
print $form->selectDate($search_datev_end ? $search_datev_end : -1, 'search_date_value_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment type
|
||||
if ($arrayfields['type']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
$form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Project
|
||||
if ($arrayfields['project']['checked']) {
|
||||
print '<td class="liste_titre">';
|
||||
// TODO
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Bank account
|
||||
if ($arrayfields['bank']['checked']) {
|
||||
print '<td class="liste_titre">';
|
||||
$form->select_comptes($search_bank_account, 'search_account', 0, '', 1);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Bank entry
|
||||
if ($arrayfields['entry']['checked']) {
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input name="search_bank_entry" class="flat" type="text" size="8" value="'.$search_bank_entry.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Accounting account
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
// Accounting account
|
||||
if ($arrayfields['account']['checked']) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200');
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Subledger account
|
||||
// Subledger account
|
||||
if ($arrayfields['subledger']['checked']) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200');
|
||||
@ -238,31 +377,50 @@ if ($result)
|
||||
}
|
||||
|
||||
// Debit
|
||||
print '<td class="liste_titre right"><input name="search_amount_deb" class="flat" type="text" size="8" value="'.$search_amount_deb.'"></td>';
|
||||
if ($arrayfields['debit']['checked']) {
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input name="search_amount_deb" class="flat" type="text" size="8" value="'.$search_amount_deb.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Credit
|
||||
print '<td class="liste_titre right"><input name="search_amount_cred" class="flat" type="text" size="8" value="'.$search_amount_cred.'"></td>';
|
||||
if ($arrayfields['credit']['checked']) {
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input name="search_amount_cred" class="flat" type="text" size="8" value="'.$search_amount_cred.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "v.rowid", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "v.label", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "v.datep,v.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccountingShort", $_SERVER["PHP_SELF"], "v.accountancy_code", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
if (!empty($conf->accounting->enabled)) print_liste_field_titre("SubledgerAccount", $_SERVER["PHP_SELF"], "v.subledger_account", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
|
||||
|
||||
if ($arrayfields['ref']['checked']) print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], 'v.rowid', '', $param, '', $sortfield, $sortorder);
|
||||
if ($arrayfields['label']['checked']) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], 'v.label', '', $param, '', $sortfield, $sortorder, 'left ');
|
||||
if ($arrayfields['datep']['checked']) print_liste_field_titre($arrayfields['datep']['label'], $_SERVER["PHP_SELF"], 'v.datep,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
if ($arrayfields['datev']['checked']) print_liste_field_titre($arrayfields['datev']['label'], $_SERVER["PHP_SELF"], 'v.datev,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
if ($arrayfields['type']['checked']) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], 'type', '', $param, '', $sortfield, $sortorder, 'left ');
|
||||
if ($arrayfields['project']['checked']) print_liste_field_titre($arrayfields['project']['label'], $_SERVER["PHP_SELF"], 'fk_project', '', $param, '', $sortfield, $sortorder);
|
||||
if ($arrayfields['bank']['checked']) print_liste_field_titre($arrayfields['bank']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
|
||||
if ($arrayfields['entry']['checked']) print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
|
||||
if ($arrayfields['account']['checked']) print_liste_field_titre($arrayfields['account']['label'], $_SERVER["PHP_SELF"], 'v.accountancy_code', '', $param, '', $sortfield, $sortorder, 'left ');
|
||||
if ($arrayfields['subledger']['checked']) print_liste_field_titre($arrayfields['subledger']['label'], $_SERVER["PHP_SELF"], 'v.subledger_account', '', $param, '', $sortfield, $sortorder, 'left ');
|
||||
if ($arrayfields['debit']['checked']) print_liste_field_titre($arrayfields['debit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
if ($arrayfields['credit']['checked']) print_liste_field_titre($arrayfields['credit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
|
||||
// Fields from hook
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$totalarray = array();
|
||||
@ -272,28 +430,53 @@ if ($result)
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
$variousstatic->id = $obj->rowid;
|
||||
$variousstatic->ref = $obj->rowid;
|
||||
// No
|
||||
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
|
||||
print '<td>'.(($offset * $limit) + $i).'</td>';
|
||||
}
|
||||
|
||||
// Ref
|
||||
print "<td>".$variousstatic->getNomUrl(1)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if ($arrayfields['ref']['checked']) {
|
||||
$variousstatic->id = $obj->rowid;
|
||||
$variousstatic->ref = $obj->rowid;
|
||||
print "<td>".$variousstatic->getNomUrl(1)."</td>";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Label payment
|
||||
print "<td>".dol_trunc($obj->label, 40)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if ($arrayfields['label']['checked']) {
|
||||
print "<td>".dol_trunc($obj->label, 40)."</td>";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Date payment
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if ($arrayfields['datep']['checked']) {
|
||||
print '<td class="center">'.dol_print_date($obj->datep, 'day')."</td>";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
|
||||
// Date value
|
||||
if ($arrayfields['datev']['checked']) {
|
||||
print '<td class="center">'.dol_print_date($obj->datev, 'day')."</td>";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Type
|
||||
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if ($arrayfields['type']['checked']) {
|
||||
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Account
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
// Project
|
||||
if ($arrayfields['project']['checked']) {
|
||||
$proj->fetch($obj->fk_project);
|
||||
print '<td>'.$proj->getNomUrl(1).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Bank account
|
||||
if ($arrayfields['bank']['checked']) {
|
||||
print '<td>';
|
||||
if ($obj->bid > 0)
|
||||
{
|
||||
@ -303,22 +486,28 @@ if ($result)
|
||||
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountstatic->account_number = $obj->bank_account_number;
|
||||
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$accountingjournal->fetch($obj->accountancy_journal);
|
||||
$accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
|
||||
}
|
||||
|
||||
$accountstatic->label = $obj->blabel;
|
||||
print $accountstatic->getNomUrl(1);
|
||||
} else print ' ';
|
||||
print '</td>';
|
||||
} else {
|
||||
print ' ';
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Bank entry
|
||||
if ($arrayfields['entry']['checked']) {
|
||||
$bankline->fetch($obj->fk_bank);
|
||||
print '<td>'.$bankline->getNomUrl(1).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Accounting account
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
if ($arrayfields['account']['checked']) {
|
||||
$accountingaccount->fetch('', $obj->accountancy_code, 1);
|
||||
|
||||
print '<td>'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).'</td>';
|
||||
@ -326,38 +515,42 @@ if ($result)
|
||||
}
|
||||
|
||||
// Accounting subledger account
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if ($arrayfields['subledger']['checked']) {
|
||||
print '<td>'.length_accounta($obj->subledger_account).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Debit
|
||||
print '<td class="nowrap right">';
|
||||
if ($obj->sens == 0)
|
||||
{
|
||||
print price($obj->amount);
|
||||
$totalarray['val']['total_deb'] += $obj->amount;
|
||||
if ($arrayfields['debit']['checked']) {
|
||||
print '<td class="nowrap right">';
|
||||
if ($obj->sens == 0)
|
||||
{
|
||||
print price($obj->amount);
|
||||
$totalarray['val']['total_deb'] += $obj->amount;
|
||||
}
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_deb';
|
||||
print '</td>';
|
||||
}
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_deb';
|
||||
print '</td>';
|
||||
|
||||
// Credit
|
||||
print '<td class="nowrap right">';
|
||||
if ($obj->sens == 1)
|
||||
{
|
||||
print price($obj->amount);
|
||||
$totalarray['val']['total_cred'] += $obj->amount;
|
||||
if ($arrayfields['credit']['checked']) {
|
||||
print '<td class="nowrap right">';
|
||||
if ($obj->sens == 1)
|
||||
{
|
||||
print price($obj->amount);
|
||||
$totalarray['val']['total_cred'] += $obj->amount;
|
||||
}
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_cred';
|
||||
print '</td>';
|
||||
}
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_cred';
|
||||
print '</td>';
|
||||
|
||||
print '<td></td>';
|
||||
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
|
||||
print "</tr>\n";
|
||||
print "</tr>";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ if (empty($reshook))
|
||||
$object->title = GETPOST('titre', 'nohtml');
|
||||
$object->note_private = GETPOST('note_private', 'none');
|
||||
$object->note_public = GETPOST('note_public', 'none');
|
||||
$object->modelpdf = GETPOST('modelpdf', 'alpha');
|
||||
$object->model_pdf = GETPOST('modelpdf', 'alpha');
|
||||
$object->usenewprice = GETPOST('usenewprice', 'alpha');
|
||||
|
||||
$object->frequency = $frequency;
|
||||
@ -650,7 +650,7 @@ if (empty($reshook))
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
$model=$object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -861,7 +861,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}*/
|
||||
|
||||
$object->fetch($object->id); // Reload lines
|
||||
@ -1425,9 +1425,9 @@ if ($action == 'create')
|
||||
$list[] = str_replace(':', '|', $k).':'.$model;
|
||||
}
|
||||
$select = 'select;'.implode(',', $list);
|
||||
print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select);
|
||||
print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select);
|
||||
} else {
|
||||
print $object->modelpdf;
|
||||
print $object->model_pdf;
|
||||
}
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
@ -251,7 +251,7 @@ if (empty($reshook))
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
if ($result >= 0) {
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
|
||||
@ -458,7 +458,7 @@ if (empty($reshook))
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -530,7 +530,7 @@ if (empty($reshook))
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'setref' && $usercancreate)
|
||||
@ -644,7 +644,7 @@ if (empty($reshook))
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -728,7 +728,7 @@ if (empty($reshook))
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -991,7 +991,7 @@ if (empty($reshook))
|
||||
// We do not copy the private note
|
||||
$object->ref_client = $_POST['ref_client'];
|
||||
$object->ref_int = $_POST['ref_int'];
|
||||
$object->modelpdf = $_POST['model'];
|
||||
$object->model_pdf = $_POST['model'];
|
||||
$object->fk_project = $_POST['projectid'];
|
||||
$object->cond_reglement_id = $_POST['cond_reglement_id'];
|
||||
$object->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
@ -1048,7 +1048,7 @@ if (empty($reshook))
|
||||
// We do not copy the private note
|
||||
$object->ref_client = $_POST['ref_client'];
|
||||
$object->ref_int = $_POST['ref_int'];
|
||||
$object->modelpdf = $_POST['model'];
|
||||
$object->model_pdf = $_POST['model'];
|
||||
$object->fk_project = $_POST['projectid'];
|
||||
$object->cond_reglement_id = 0;
|
||||
$object->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
@ -1264,7 +1264,7 @@ if (empty($reshook))
|
||||
$object->note_private = trim(GETPOST('note_private', 'none'));
|
||||
$object->ref_client = $_POST['ref_client'];
|
||||
$object->ref_int = $_POST['ref_int'];
|
||||
$object->modelpdf = $_POST['model'];
|
||||
$object->model_pdf = $_POST['model'];
|
||||
$object->fk_project = $_POST['projectid'];
|
||||
$object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']);
|
||||
$object->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
@ -1316,7 +1316,7 @@ if (empty($reshook))
|
||||
$object->note_private = trim(GETPOST('note_private', 'none'));
|
||||
$object->ref_client = $_POST['ref_client'];
|
||||
$object->ref_int = $_POST['ref_int'];
|
||||
$object->modelpdf = $_POST['model'];
|
||||
$object->model_pdf = $_POST['model'];
|
||||
$object->fk_project = $_POST['projectid'];
|
||||
$object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']);
|
||||
$object->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
@ -1806,7 +1806,7 @@ if (empty($reshook))
|
||||
$object->note_private = trim(GETPOST('note', 'none'));
|
||||
$object->ref_client = GETPOST('ref_client', 'alpha');
|
||||
$object->ref_int = GETPOST('ref_int', 'alpha');
|
||||
$object->modelpdf = GETPOST('model', 'alpha');
|
||||
$object->model_pdf = GETPOST('model', 'alpha');
|
||||
$object->fk_project = GETPOST('projectid', 'int');
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
|
||||
@ -1851,7 +1851,7 @@ if (empty($reshook))
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -2145,7 +2145,7 @@ if (empty($reshook))
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('products');
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -2356,7 +2356,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST['qty']);
|
||||
@ -5311,7 +5311,7 @@ if ($action == 'create')
|
||||
|
||||
print $formfile->showdocuments(
|
||||
'facture', $filename, $filedir, $urlsource, $genallowed,
|
||||
$delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '',
|
||||
$delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '',
|
||||
$soc->default_lang, '', $object, 0, 'remove_file_comfirm');
|
||||
|
||||
$somethingshown = $formfile->numoffiles;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -265,8 +265,6 @@ if (empty($reshook))
|
||||
$paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
|
||||
$paiement->num_payment = GETPOST('num_paiement', 'alpha');
|
||||
$paiement->note_private = GETPOST('comment', 'alpha');
|
||||
$paiement->num_paiement = $paiement->num_payment; // For bacward compatibility
|
||||
$paiement->note = $paiement->note_private; // For bacward compatibility
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
@ -851,7 +849,7 @@ if (!GETPOST('action', 'aZ09'))
|
||||
if (!$sortfield) $sortfield = 'p.datep';
|
||||
|
||||
$sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
|
||||
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
|
||||
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
|
||||
$sql .= ', '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql .= ' WHERE p.fk_facture = f.rowid';
|
||||
@ -887,7 +885,7 @@ if (!GETPOST('action', 'aZ09'))
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n";
|
||||
print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_payment."</td>\n";
|
||||
print '<td class="right">'.price($objp->amount).'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -90,13 +90,6 @@ class Paiement extends CommonObject
|
||||
*/
|
||||
public $type_code;
|
||||
|
||||
/**
|
||||
* @var string Numero du CHQ, VIR, etc...
|
||||
* @deprecated
|
||||
* @see $num_payment
|
||||
*/
|
||||
public $numero;
|
||||
|
||||
/**
|
||||
* @var string Numero du CHQ, VIR, etc...
|
||||
* @deprecated
|
||||
@ -143,6 +136,10 @@ class Paiement extends CommonObject
|
||||
*/
|
||||
public $fk_paiement; // Type of payment
|
||||
|
||||
/**
|
||||
* @var string payment external reference
|
||||
*/
|
||||
public $ref_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -164,7 +161,7 @@ class Paiement extends CommonObject
|
||||
*/
|
||||
public function fetch($id, $ref = '', $fk_bank = '')
|
||||
{
|
||||
$sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,';
|
||||
$sql = 'SELECT p.rowid, p.ref, p.ref_ext, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,';
|
||||
$sql .= ' c.code as type_code, c.libelle as type_label,';
|
||||
$sql .= ' p.num_paiement as num_payment, p.note,';
|
||||
$sql .= ' b.fk_account';
|
||||
@ -187,9 +184,9 @@ class Paiement extends CommonObject
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->ref ? $obj->ref : $obj->rowid;
|
||||
$this->ref_ext = $obj->ref_ext;
|
||||
$this->date = $this->db->jdate($obj->dp);
|
||||
$this->datepaye = $this->db->jdate($obj->dp);
|
||||
$this->num_paiement = $obj->num_payment; // deprecated
|
||||
$this->num_payment = $obj->num_payment;
|
||||
$this->montant = $obj->amount; // deprecated
|
||||
$this->amount = $obj->amount;
|
||||
@ -279,6 +276,10 @@ class Paiement extends CommonObject
|
||||
|
||||
$this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
|
||||
|
||||
if (empty($this->ref_ext)) {
|
||||
$this->ref_ext = '';
|
||||
}
|
||||
|
||||
if ($way == 'dolibarr')
|
||||
{
|
||||
$total = $totalamount;
|
||||
@ -288,11 +289,11 @@ class Paiement extends CommonObject
|
||||
$mtotal = $totalamount;
|
||||
}
|
||||
|
||||
$num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement);
|
||||
$note = ($this->note_public ? $this->note_public : $this->note);
|
||||
$num_payment = $this->num_payment;
|
||||
$note = ($this->note_private ? $this->note_private : $this->note);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
|
||||
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", ";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
|
||||
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", ";
|
||||
$sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@ -707,7 +708,7 @@ class Paiement extends CommonObject
|
||||
$bank_line_id,
|
||||
$this->id_prelevement,
|
||||
DOL_URL_ROOT.'/compta/prelevement/card.php?id=',
|
||||
$this->num_paiement,
|
||||
$this->num_payment,
|
||||
'withdraw'
|
||||
);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($o
|
||||
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
|
||||
|
||||
// Numero
|
||||
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_paiement.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_payment.'</td></tr>';
|
||||
|
||||
// Montant
|
||||
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
@ -507,7 +507,6 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
|
||||
$paiement->num_payment = $this->ref; // Set ref of direct debit note
|
||||
$paiement->num_paiement = $this->ref; // For backward compatibility
|
||||
$paiement->id_prelevement = $this->id;
|
||||
|
||||
$paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode
|
||||
@ -1303,7 +1302,7 @@ class BonPrelevement extends CommonObject
|
||||
|
||||
$result = '';
|
||||
|
||||
$labeltoshow = 'Withdraw';
|
||||
$labeltoshow = 'PaymentByDirectDebit';
|
||||
if ($this->type == 'bank-transfer') {
|
||||
$labeltoshow = 'PaymentByBankTransfer';
|
||||
}
|
||||
|
||||
@ -153,7 +153,6 @@ class RejetPrelevement
|
||||
$pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1);
|
||||
$pai->datepaye = $date_rejet;
|
||||
$pai->paiementid = 3; // type of payment: withdrawal
|
||||
$pai->num_paiement = $fac->ref;
|
||||
$pai->num_payment = $fac->ref;
|
||||
|
||||
if ($pai->create($this->user) < 0) // we call with no_commit
|
||||
|
||||
@ -134,9 +134,8 @@ class PaymentSocialContribution extends CommonObject
|
||||
if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge;
|
||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
||||
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
|
||||
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
|
||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
||||
if (isset($this->note)) $this->note = trim($this->note);
|
||||
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
@ -265,9 +264,8 @@ class PaymentSocialContribution extends CommonObject
|
||||
$this->datep = $this->db->jdate($obj->datep);
|
||||
$this->amount = $obj->amount;
|
||||
$this->fk_typepaiement = $obj->fk_typepaiement;
|
||||
$this->num_paiement = $obj->num_payment;
|
||||
$this->num_payment = $obj->num_payment;
|
||||
$this->note = $obj->note;
|
||||
$this->note_private = $obj->note;
|
||||
$this->fk_bank = $obj->fk_bank;
|
||||
$this->fk_user_creat = $obj->fk_user_creat;
|
||||
$this->fk_user_modif = $obj->fk_user_modif;
|
||||
@ -305,9 +303,8 @@ class PaymentSocialContribution extends CommonObject
|
||||
if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge;
|
||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
||||
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
|
||||
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
|
||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
||||
if (isset($this->note)) $this->note = trim($this->note);
|
||||
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
@ -326,7 +323,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
$sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
|
||||
$sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
|
||||
$sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").",";
|
||||
$sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").",";
|
||||
$sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
|
||||
$sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
|
||||
$sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").",";
|
||||
$sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").",";
|
||||
@ -504,7 +501,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
global $conf;
|
||||
|
||||
// Clean data
|
||||
$this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
|
||||
$this->num_payment = trim($this->num_payment);
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
@ -100,16 +100,16 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
$object->label = GETPOST("label", 'alpha');
|
||||
$object->note = GETPOST("note", 'none');
|
||||
|
||||
if (empty($object->datev))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateValue")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->datep))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->datev))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PeriodEndDate")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->type_payment) || $object->type_payment < 0)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
|
||||
|
||||
@ -499,6 +499,7 @@ class Tva extends CommonObject
|
||||
$this->amount = price2num(trim($this->amount));
|
||||
$this->label = trim($this->label);
|
||||
$this->note = trim($this->note);
|
||||
$this->num_payment = trim($this->num_payment);
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
@ -583,9 +584,9 @@ class Tva extends CommonObject
|
||||
if ($result <= 0) dol_print_error($this->db);
|
||||
|
||||
if ($this->amount > 0) {
|
||||
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), '', '', $user);
|
||||
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user);
|
||||
} else {
|
||||
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), '', '', $user);
|
||||
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user);
|
||||
}
|
||||
|
||||
// Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
|
||||
|
||||
@ -106,7 +106,7 @@ if ($object->id)
|
||||
|
||||
$head = vat_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'bill');
|
||||
dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment');
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Label of social contribution
|
||||
|
||||
@ -177,10 +177,10 @@ if (empty($reshook))
|
||||
if ($canvas) $object->canvas = $canvas;
|
||||
|
||||
$object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity);
|
||||
$object->socid = GETPOST("socid", 'int');
|
||||
$object->socid = GETPOST("socid", 'int');
|
||||
$object->lastname = GETPOST("lastname", 'alpha');
|
||||
$object->firstname = GETPOST("firstname", 'alpha');
|
||||
$object->civility_code = GETPOST("civility_code", 'alpha');
|
||||
$object->civility_code = GETPOST("civility_code", 'alpha');
|
||||
$object->poste = GETPOST("poste", 'alpha');
|
||||
$object->address = GETPOST("address", 'alpha');
|
||||
$object->zip = GETPOST("zipcode", 'alpha');
|
||||
@ -1355,7 +1355,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
|
||||
if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
|
||||
if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3)
|
||||
{
|
||||
print '<br>';
|
||||
@ -1368,11 +1368,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('ProspectLevel');
|
||||
print '<td>';
|
||||
if ($action != 'editlevel' && $user->rights->societe->contact->creer) print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editlevel&id=' . $object->id . '">' . img_edit($langs->trans('Modify'), 1) . '</a></td>';
|
||||
if ($action != 'editlevel' && $user->rights->societe->contact->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&id='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editlevel') {
|
||||
$formcompany->formProspectContactLevel($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_prospectlevel, 'prospect_contact_level_id', 1);
|
||||
$formcompany->formProspectContactLevel($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_prospectlevel, 'prospect_contact_level_id', 1);
|
||||
} else {
|
||||
print $object->getLibProspLevel();
|
||||
}
|
||||
@ -1381,13 +1381,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
// Status of prospection
|
||||
$object->loadCacheOfProspStatus();
|
||||
print '<tr><td>' . $langs->trans("StatusProsp") . '</td><td>' . $object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
|
||||
print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
|
||||
print ' ';
|
||||
print '<div class="floatright">';
|
||||
foreach ($object->cacheprospectstatus as $key => $val) {
|
||||
$titlealt = 'default';
|
||||
if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
|
||||
if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&stcomm=' . $val['code'] . '&action=setstcomm">' . img_action($titlealt, $val['code'], $val['picto']) . '</a>';
|
||||
if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
|
||||
}
|
||||
print '</div></td></tr>';
|
||||
|
||||
|
||||
@ -1284,7 +1284,7 @@ class Contact extends CommonObject
|
||||
$label .= '</div><div style="clear: both;"></div>';
|
||||
}
|
||||
|
||||
$label .= '<u>'.$langs->trans("Contact").'</u>';
|
||||
$label .= img_picto('', $this->picto).' <u>'.$langs->trans("Contact").'</u>';
|
||||
$label .= '<br><b>'.$langs->trans("Name").':</b> '.$this->getFullName($langs);
|
||||
//if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code
|
||||
if (!empty($this->poste)) $label .= '<br><b>'.$langs->trans("Poste").':</b> '.$this->poste;
|
||||
|
||||
@ -158,8 +158,8 @@ $fieldstosearchall = array(
|
||||
'p.phone_perso'=>"PhonePerso",
|
||||
'p.phone_mobile'=>"PhoneMobile",
|
||||
'p.fax'=>"Fax",
|
||||
'p.note_public'=>"NotePublic",
|
||||
'p.note_private'=>"NotePrivate",
|
||||
'p.note_public'=>"NotePublic",
|
||||
'p.note_private'=>"NotePrivate",
|
||||
);
|
||||
|
||||
// Definition of fields for list
|
||||
@ -541,7 +541,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
$newcardbutton = '';
|
||||
if ($user->rights->societe->contact->creer)
|
||||
{
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create');
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create');
|
||||
}
|
||||
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
|
||||
@ -734,9 +734,9 @@ if (!empty($arrayfields['p.thirdparty']['checked']))
|
||||
if (!empty($arrayfields['p.priv']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center">';
|
||||
$selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
|
||||
print $form->selectarray('search_priv', $selectarray, $search_priv, 1);
|
||||
print '</td>';
|
||||
$selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
|
||||
print $form->selectarray('search_priv', $selectarray, $search_priv, 1);
|
||||
print '</td>';
|
||||
}
|
||||
// Prospect level
|
||||
if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
|
||||
@ -808,7 +808,7 @@ if (!empty($arrayfields['p.town']['checked'])) print_liste_field_
|
||||
//if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
|
||||
//if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
|
||||
if (!empty($arrayfields['country.code_iso']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder);
|
||||
@ -831,24 +831,24 @@ if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) print_liste_field_
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters = array(
|
||||
'arrayfields'=>$arrayfields,
|
||||
'param'=>$param,
|
||||
'sortfield'=>$sortfield,
|
||||
'sortorder'=>$sortorder,
|
||||
'arrayfields'=>$arrayfields,
|
||||
'param'=>$param,
|
||||
'sortfield'=>$sortfield,
|
||||
'sortorder'=>$sortorder,
|
||||
);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (!empty($arrayfields['p.datec']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
}
|
||||
if (!empty($arrayfields['p.tms']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
}
|
||||
if (!empty($arrayfields['p.statut']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['p.import_key']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
@ -986,15 +986,15 @@ while ($i < min($num, $limit))
|
||||
}
|
||||
}
|
||||
}
|
||||
// Company
|
||||
// Company
|
||||
if (!empty($arrayfields['p.thirdparty']['checked']))
|
||||
{
|
||||
print '<td>';
|
||||
if ($obj->socid)
|
||||
{
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($obj->socid);
|
||||
print $objsoc->getNomUrl(1);
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($obj->socid);
|
||||
print $objsoc->getNomUrl(1);
|
||||
} else print ' ';
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
|
||||
@ -568,7 +568,7 @@ if (empty($reshook))
|
||||
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST['prod_entry_mode']);
|
||||
@ -743,7 +743,7 @@ if (empty($reshook))
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -2126,7 +2126,7 @@ if ($action == 'create')
|
||||
$delallowed = $user->rights->contrat->creer;
|
||||
|
||||
|
||||
print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
|
||||
print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
|
||||
|
||||
|
||||
// Show links to link elements
|
||||
|
||||
@ -1968,7 +1968,7 @@ class Contrat extends CommonObject
|
||||
$label = '';
|
||||
|
||||
if ($user->rights->contrat->lire) {
|
||||
$label = '<u>'.$langs->trans("ShowContract").'</u>';
|
||||
$label = img_picto('', $this->picto).' <u>'.$langs->trans("Contract").'</u>';
|
||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.($this->ref ? $this->ref : $this->id);
|
||||
$label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
|
||||
$label .= '<br><b>'.$langs->trans('RefSupplier').':</b> '.$this->ref_supplier;
|
||||
|
||||
@ -270,7 +270,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
if (method_exists($object, 'generateDocument')) {
|
||||
$ret = $object->fetch($object->id); // Reload to get new records
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd)
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -327,7 +327,7 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd)
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -367,7 +367,7 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
@ -82,7 +82,7 @@ if ($action == 'builddoc' && $permissiontoadd)
|
||||
if (empty($hideref)) $hideref = 0;
|
||||
if (empty($moreparams)) $moreparams = null;
|
||||
|
||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
$result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
if ($result <= 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
|
||||
@ -43,7 +43,7 @@ if ($action == 'up' && $permissiontoedit)
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
|
||||
@ -64,7 +64,7 @@ if ($action == 'down' && $permissiontoedit)
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
|
||||
|
||||
@ -49,7 +49,7 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel',
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$model = $object->model_pdf;
|
||||
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
|
||||
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
|
||||
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Sergio Sanchis <sergiosanchis@hotmail.com>
|
||||
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -18,14 +18,73 @@
|
||||
*/
|
||||
|
||||
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
|
||||
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
|
||||
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
|
||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
|
||||
//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
|
||||
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
|
||||
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
|
||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
|
||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
|
||||
//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
||||
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
|
||||
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
|
||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
|
||||
//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
|
||||
//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
|
||||
//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
|
||||
//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', '1'); // The main.inc.php does not make a redirect if not logged, instead show simple error message
|
||||
//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL'
|
||||
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late
|
||||
//$time=dol_now();
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$listofreminderids = GETPOST('listofreminderids', 'aZ09');
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'stopreminder') {
|
||||
dol_syslog("Clear notification for listofreminderids=".$listofreminderids);
|
||||
$listofreminderidsarray = explode('-', GETPOST('listofreminderids', 'aZ09'));
|
||||
|
||||
// Set the reminder as done
|
||||
foreach ($listofreminderidsarray as $listofreminderid) {
|
||||
if (empty($listofreminderid)) continue;
|
||||
//$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'action_reminder WHERE rowid = '.$listofreminderid.' AND fk_user = '.$user->id;
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'actioncomm_reminder SET status = 1';
|
||||
$sql .= ' WHERE status = 0 AND rowid = '.$listofreminderid.' AND fk_user = '.$user->id.' AND entity = '.$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
// Clean database
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'actioncomm_reminder';
|
||||
$sql .= " WHERE dateremind < '".$db->idate(dol_time_plus_duree(dol_now(), -1, 'm'))."'";
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -35,10 +94,6 @@ top_httphead('text/html'); // TODO Use a json mime type
|
||||
|
||||
global $user, $db, $langs, $conf;
|
||||
|
||||
$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late
|
||||
//$time=dol_now();
|
||||
|
||||
|
||||
$eventfound = array();
|
||||
//Uncomment this to force a test
|
||||
//$eventfound[]=array('type'=>'agenda', 'id'=>1, 'tipo'=>'eee', 'location'=>'aaa');
|
||||
@ -46,7 +101,8 @@ $eventfound = array();
|
||||
//dol_syslog('time='.$time.' $_SESSION[auto_ck_events_not_before]='.$_SESSION['auto_check_events_not_before']);
|
||||
|
||||
// TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
|
||||
if ($time >= $_SESSION['auto_check_events_not_before'])
|
||||
// This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet).
|
||||
if ($time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow', 'int'))
|
||||
{
|
||||
$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined
|
||||
if (!empty($_SESSION['auto_check_events_not_before']))
|
||||
@ -66,7 +122,7 @@ if ($time >= $_SESSION['auto_check_events_not_before'])
|
||||
|
||||
$_SESSION['auto_check_events_not_before'] = $time + $time_update;
|
||||
|
||||
// Force save of session change we did.
|
||||
// Force save of the session change we did.
|
||||
// WARNING: Any change in sessions after that will not be saved !
|
||||
session_write_close();
|
||||
|
||||
@ -75,35 +131,36 @@ if ($time >= $_SESSION['auto_check_events_not_before'])
|
||||
|
||||
dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
|
||||
|
||||
$sql = 'SELECT id';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm a, '.MAIN_DB_PREFIX.'actioncomm_resources ar';
|
||||
$sql .= ' WHERE a.id = ar.fk_actioncomm';
|
||||
// TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
|
||||
// This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet).
|
||||
$sql .= " AND datep BETWEEN '".$db->idate($starttime)."' AND '".$db->idate($time + $time_update - 1)."'";
|
||||
$sql .= ' AND a.code <> "AC_OTH_AUTO"';
|
||||
$sql .= ' AND ar.element_type = "user"';
|
||||
$sql .= ' AND ar.fk_element = '.$user->id;
|
||||
$sql = 'SELECT a.id, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
|
||||
if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) {
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id;
|
||||
$sql .= ' WHERE a.code <> "AC_OTH_AUTO"';
|
||||
$sql .= ' AND (';
|
||||
$sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity;
|
||||
$sql .= " OR (a.datep BETWEEN '".$db->idate($starttime)."' AND '".$db->idate($time + $time_update - 1)."')";
|
||||
$sql .= ' )';
|
||||
} else {
|
||||
$sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id;
|
||||
$sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity;
|
||||
}
|
||||
$sql .= ' LIMIT 10'; // Avoid too many notification at once
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$actionmod = new ActionComm($db);
|
||||
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('agenda', 'commercial'));
|
||||
|
||||
$actionmod->fetch($obj->id);
|
||||
|
||||
// Message must be formated and translated to be used with javascript directly
|
||||
$event = array();
|
||||
$event['type'] = 'agenda';
|
||||
$event['id'] = $actionmod->id;
|
||||
$event['tipo'] = $langs->transnoentities('Action'.$actionmod->code);
|
||||
$event['titulo'] = $actionmod->label;
|
||||
$event['location'] = $langs->transnoentities('Location').': '.$actionmod->location;
|
||||
$event['id'] = $obj->id;
|
||||
$event['id_reminder'] = $obj->id_reminder;
|
||||
$event['id_user'] = $obj->id_user_reminder;
|
||||
$event['code'] = $obj->code;
|
||||
$event['label'] = $obj->label;
|
||||
$event['location'] = $obj->location;
|
||||
$event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard');
|
||||
$event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard');
|
||||
|
||||
$eventfound[] = $event;
|
||||
}
|
||||
|
||||
@ -119,6 +119,17 @@ if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFOR
|
||||
$arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
|
||||
}
|
||||
|
||||
// Miscellaneous payments
|
||||
if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire)
|
||||
{
|
||||
$arrayresult['searchintomiscpayments'] = array(
|
||||
'position'=>180,
|
||||
'img'=>'object_payment',
|
||||
'label'=>$langs->trans("SearchIntoMiscPayments", $search_boxvalue),
|
||||
'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue),
|
||||
'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
|
||||
}
|
||||
|
||||
if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire)
|
||||
{
|
||||
$arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
|
||||
|
||||
@ -133,66 +133,6 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
$WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320';
|
||||
$HEIGHT = '192';
|
||||
|
||||
if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
|
||||
{
|
||||
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
|
||||
if ($showinvoicenb)
|
||||
{
|
||||
$langs->load("bills");
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
|
||||
|
||||
$showpointvalue = 1; $nocolor = 0;
|
||||
$mode = 'customer';
|
||||
$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
|
||||
$data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5);
|
||||
|
||||
if (empty($data1))
|
||||
{
|
||||
$showpointvalue = 0;
|
||||
$nocolor = 1;
|
||||
$data1 = array(array(0=>$langs->trans("None"), 1=>1));
|
||||
}
|
||||
$filenamenb = $dir."/prodserforinvoice-".$year.".png";
|
||||
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png';
|
||||
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
if (!$mesg)
|
||||
{
|
||||
$i = 0; $legend = array();
|
||||
|
||||
foreach ($data1 as $key => $val)
|
||||
{
|
||||
$data1[$key][0] = dol_trunc($data1[$key][0], 32);
|
||||
$legend[] = $data1[$key][0];
|
||||
$i++;
|
||||
}
|
||||
|
||||
$px1->SetData($data1);
|
||||
unset($data1);
|
||||
|
||||
if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220)));
|
||||
$px1->SetLegend($legend);
|
||||
$px1->setShowLegend(2);
|
||||
$px1->setShowPointValue($showpointvalue);
|
||||
$px1->setShowPercent(0);
|
||||
$px1->SetMaxValue($px1->GetCeilMaxValue());
|
||||
//$px1->SetWidth($WIDTH);
|
||||
$px1->SetHeight($HEIGHT);
|
||||
//$px1->SetYLabel($langs->trans("NumberOfBills"));
|
||||
$px1->SetShading(3);
|
||||
$px1->SetHorizTickIncrement(1);
|
||||
$px1->SetCssPrefix("cssboxes");
|
||||
//$px1->mode='depth';
|
||||
$px1->SetType(array('pie'));
|
||||
$px1->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Invoices")));
|
||||
$px1->combine = 0.05;
|
||||
|
||||
$px1->draw($filenamenb, $fileurlnb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
|
||||
{
|
||||
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
|
||||
@ -312,6 +252,67 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
|
||||
{
|
||||
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
|
||||
if ($showinvoicenb)
|
||||
{
|
||||
$langs->load("bills");
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
|
||||
|
||||
$showpointvalue = 1; $nocolor = 0;
|
||||
$mode = 'customer';
|
||||
$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
|
||||
$data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5);
|
||||
|
||||
if (empty($data1))
|
||||
{
|
||||
$showpointvalue = 0;
|
||||
$nocolor = 1;
|
||||
$data1 = array(array(0=>$langs->trans("None"), 1=>1));
|
||||
}
|
||||
$filenamenb = $dir."/prodserforinvoice-".$year.".png";
|
||||
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png';
|
||||
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
if (!$mesg)
|
||||
{
|
||||
$i = 0; $legend = array();
|
||||
|
||||
foreach ($data1 as $key => $val)
|
||||
{
|
||||
$data1[$key][0] = dol_trunc($data1[$key][0], 32);
|
||||
$legend[] = $data1[$key][0];
|
||||
$i++;
|
||||
}
|
||||
|
||||
$px1->SetData($data1);
|
||||
unset($data1);
|
||||
|
||||
if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220)));
|
||||
$px1->SetLegend($legend);
|
||||
$px1->setShowLegend(2);
|
||||
$px1->setShowPointValue($showpointvalue);
|
||||
$px1->setShowPercent(0);
|
||||
$px1->SetMaxValue($px1->GetCeilMaxValue());
|
||||
//$px1->SetWidth($WIDTH);
|
||||
$px1->SetHeight($HEIGHT);
|
||||
//$px1->SetYLabel($langs->trans("NumberOfBills"));
|
||||
$px1->SetShading(3);
|
||||
$px1->SetHorizTickIncrement(1);
|
||||
$px1->SetCssPrefix("cssboxes");
|
||||
//$px1->mode='depth';
|
||||
$px1->SetType(array('pie'));
|
||||
$px1->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Invoices")));
|
||||
$px1->combine = 0.05;
|
||||
|
||||
$px1->draw($filenamenb, $fileurlnb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($nbofgraph))
|
||||
{
|
||||
$langs->load("errors");
|
||||
@ -339,11 +340,6 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
|
||||
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
|
||||
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
|
||||
if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire))
|
||||
{
|
||||
$stringtoshow .= '<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb ? ' checked' : '').'> '.$langs->trans("ForCustomersInvoices");
|
||||
$stringtoshow .= ' ';
|
||||
}
|
||||
if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire))
|
||||
{
|
||||
$stringtoshow .= '<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb ? ' checked' : '').'> '.$langs->trans("ForProposals");
|
||||
@ -353,6 +349,11 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
{
|
||||
$stringtoshow .= '<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb ? ' checked' : '').'> '.$langs->trans("ForCustomersOrders");
|
||||
}
|
||||
if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire))
|
||||
{
|
||||
$stringtoshow .= '<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb ? ' checked' : '').'> '.$langs->trans("ForCustomersInvoices");
|
||||
$stringtoshow .= ' ';
|
||||
}
|
||||
$stringtoshow .= '<br>';
|
||||
$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
|
||||
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto('', 'refresh.png', '', '', 1).'">';
|
||||
@ -361,29 +362,29 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
|
||||
if ($nbofgraph == 1)
|
||||
{
|
||||
if ($showinvoicenb) $stringtoshow .= $px1->show();
|
||||
elseif ($showpropalnb) $stringtoshow .= $px2->show();
|
||||
else $stringtoshow .= $px3->show();
|
||||
if ($showpropalnb) $stringtoshow .= $px2->show();
|
||||
elseif ($showordernb) $stringtoshow .= $px3->show();
|
||||
else $stringtoshow .= $px1->show();
|
||||
}
|
||||
if ($nbofgraph == 2)
|
||||
{
|
||||
$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
|
||||
if ($showinvoicenb) $stringtoshow .= $px1->show();
|
||||
elseif ($showpropalnb) $stringtoshow .= $px2->show();
|
||||
if ($showpropalnb) $stringtoshow .= $px2->show();
|
||||
elseif ($showordernb) $stringtoshow .= $px3->show();
|
||||
$stringtoshow .= '</div><div class="fichehalfright">';
|
||||
if ($showordernb) $stringtoshow .= $px3->show();
|
||||
elseif ($showpropalnb) $stringtoshow .= $px2->show();
|
||||
if ($showinvoicenb) $stringtoshow .= $px1->show();
|
||||
elseif ($showordernb) $stringtoshow .= $px3->show();
|
||||
$stringtoshow .= '</div></div></div>';
|
||||
}
|
||||
if ($nbofgraph == 3)
|
||||
{
|
||||
$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
|
||||
$stringtoshow .= $px1->show();
|
||||
$stringtoshow .= '</div><div class="fichehalfright">';
|
||||
$stringtoshow .= $px2->show();
|
||||
$stringtoshow .= '</div><div class="fichehalfright">';
|
||||
$stringtoshow .= $px3->show();
|
||||
$stringtoshow .= '</div></div></div>';
|
||||
$stringtoshow .= '<div class="fichecenter"><div class="containercenter">';
|
||||
$stringtoshow .= $px3->show();
|
||||
$stringtoshow .= $px1->show();
|
||||
$stringtoshow .= '</div></div>';
|
||||
}
|
||||
$this->info_box_contents[0][0] = array(
|
||||
|
||||
@ -90,7 +90,7 @@ class box_services_contracts extends ModeleBoxes
|
||||
|
||||
$sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,";
|
||||
$sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type, cd.date_fin_validite as date_line,";
|
||||
$sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut as contractline_status, cd.product_type as type, cd.date_fin_validite as date_line,";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell";
|
||||
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
|
||||
@ -125,6 +125,7 @@ class box_services_contracts extends ModeleBoxes
|
||||
$contractlinestatic->type = $objp->type;
|
||||
$contractlinestatic->product_id = $objp->product_id;
|
||||
$contractlinestatic->product_ref = $objp->product_ref;
|
||||
$contractlinestatic->statut = $objp->contractline_status;
|
||||
|
||||
$contractstatic->id = $objp->rowid;
|
||||
$contractstatic->ref = $objp->ref;
|
||||
@ -143,24 +144,7 @@ class box_services_contracts extends ModeleBoxes
|
||||
$thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
|
||||
|
||||
$dateline = $this->db->jdate($objp->date_line);
|
||||
if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->statut == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
|
||||
|
||||
// Multilangs
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on
|
||||
{
|
||||
$sqld = "SELECT label";
|
||||
$sqld .= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||
$sqld .= " WHERE fk_product=".$objp->product_id;
|
||||
$sqld .= " AND lang='".$langs->getDefaultLang()."'";
|
||||
$sqld .= " LIMIT 1";
|
||||
|
||||
$resultd = $this->db->query($sqld);
|
||||
if ($resultd)
|
||||
{
|
||||
$objtp = $this->db->fetch_object($resultd);
|
||||
if ($objtp->label != '') $contractlinestatic->label = $objtp->label;
|
||||
}
|
||||
}
|
||||
if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->contractline_status == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
|
||||
|
||||
// Label
|
||||
if ($objp->product_id > 0)
|
||||
@ -190,7 +174,7 @@ class box_services_contracts extends ModeleBoxes
|
||||
$description = ''; // Already added into main visible desc
|
||||
}
|
||||
|
||||
$s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : ''));
|
||||
$s = $form->textwithtooltip($text, $description, 3, '', '', '', 0, (!empty($objp->fk_parent_line) ?img_picto('', 'rightarrow') : ''));
|
||||
} else {
|
||||
$s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description);
|
||||
}
|
||||
@ -222,7 +206,7 @@ class box_services_contracts extends ModeleBoxes
|
||||
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="right" width="18"',
|
||||
'text' => $contractlinestatic->LibStatut($objp->statut, 3)
|
||||
'text' => $contractlinestatic->getLibStatut(3)
|
||||
);
|
||||
|
||||
$i++;
|
||||
|
||||
@ -189,7 +189,7 @@ class box_task extends ModeleBoxes
|
||||
$projectstatic->ref = $objp->project_ref;
|
||||
$projectstatic->title = $objp->project_title;
|
||||
|
||||
$label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label);
|
||||
$label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label);
|
||||
|
||||
$boxcontent = getTaskProgressView($taskstatic, $label, true, false, false);
|
||||
|
||||
|
||||
195
htdocs/core/boxes/box_validated_projects.php
Normal file
195
htdocs/core/boxes/box_validated_projects.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012-2014 Charles-François BENKE <charles.fr@benke.fr>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
||||
* Copyright (C) 2016 Juan José Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/boxes/box_validated_projects.php
|
||||
* \ingroup projet
|
||||
* \brief Module to show validated projects whose tasks are assigned to the connected person, without any time entered by the connected person
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
|
||||
|
||||
/**
|
||||
* Class to manage the box to show last projet
|
||||
*/
|
||||
class box_validated_projects extends ModeleBoxes
|
||||
{
|
||||
public $boxcode="validated_project";
|
||||
public $boximg="object_projectpub";
|
||||
public $boxlabel;
|
||||
//var $depends = array("projet");
|
||||
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
public $param;
|
||||
|
||||
public $info_box_head = array();
|
||||
public $info_box_contents = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $param More parameters
|
||||
*/
|
||||
public function __construct($db, $param = '')
|
||||
{
|
||||
global $user, $langs;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('boxes', 'projects'));
|
||||
|
||||
$this->db = $db;
|
||||
$this->boxlabel = "ValidatedProjects";
|
||||
|
||||
$this->hidden = ! ($user->rights->projet->lire);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data for box to show them later
|
||||
*
|
||||
* @param int $max Maximum number of records to load
|
||||
* @return void
|
||||
*/
|
||||
public function loadBox($max = 5)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$this->max=$max;
|
||||
|
||||
$totalMnt = 0;
|
||||
$totalnb = 0;
|
||||
$totalnbTask=0;
|
||||
|
||||
$textHead = $langs->trans("ValidatedProjects");
|
||||
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
|
||||
|
||||
// list the summary of the orders
|
||||
if ($user->rights->projet->lire) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$projectstatic = new Project($this->db);
|
||||
|
||||
$socid=0;
|
||||
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
|
||||
|
||||
// Get list of project id allowed to user (in a string list separated by coma)
|
||||
$projectsListId='';
|
||||
if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,";
|
||||
$sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id";
|
||||
$sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")) AS 'taskNumber'";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet AS p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id";
|
||||
$sql.= " WHERE p.fk_statut = 1"; // Only open projects
|
||||
$sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")";
|
||||
$sql.= " AND c.fk_socpeople = ".$user->id;
|
||||
$sql.= " GROUP BY p.ref";
|
||||
$sql.= " ORDER BY p.dateo ASC";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="nowraponall"',
|
||||
'text' => "Reference projet",
|
||||
);
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="center"',
|
||||
'text' => 'Client',
|
||||
);
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="center"',
|
||||
'text' => 'Date debut de projet',
|
||||
);
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="center"',
|
||||
'text' => 'Nombre de mes tâches sans temps saisi',
|
||||
);
|
||||
$i++;
|
||||
|
||||
while ($i < min($num+1, $max+1)) {
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$projectstatic->id = $objp->rowid;
|
||||
$projectstatic->ref = $objp->Ref;
|
||||
$projectstatic->customer = $objp->Client;
|
||||
$projectstatic->startDate = $objp->startDate;
|
||||
$projectstatic->taskNumber = $objp->taskNumber;
|
||||
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="nowraponall"',
|
||||
'text' => $projectstatic->getNomUrl(1),
|
||||
'asis' => 1
|
||||
);
|
||||
|
||||
$sql = 'SELECT rowid, nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql){
|
||||
$socstatic = new Societe($this->db);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"',
|
||||
'text' => $obj->nom,
|
||||
'asis' => 1,
|
||||
'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj->rowid
|
||||
);
|
||||
}
|
||||
else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="center"',
|
||||
'text' => $objp->startDate,
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][] = array(
|
||||
'td' => 'class="center"',
|
||||
'text' => $objp->taskNumber." ".$langs->trans("Tasks"),
|
||||
'asis' => 1,
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to show box
|
||||
*
|
||||
* @param array $head Array with properties of box title
|
||||
* @param array $contents Array with properties of box lines
|
||||
* @param int $nooutput No print, only return string
|
||||
* @return string
|
||||
*/
|
||||
public function showBox($head = null, $contents = null, $nooutput = 0)
|
||||
{
|
||||
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ class CMailFile
|
||||
$this->sendmode = '';
|
||||
if (!empty($this->sendcontext)) {
|
||||
$smtpContextKey = strtoupper($this->sendcontext);
|
||||
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey;
|
||||
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey;
|
||||
$smtpContextSendMode = $conf->global->{$keyForSMTPSendMode};
|
||||
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
|
||||
$this->sendmode = $smtpContextSendMode;
|
||||
@ -454,9 +454,9 @@ class CMailFile
|
||||
|
||||
// Set the From address with an associative array
|
||||
//$this->message->setFrom(array('john@doe.com' => 'John Doe'));
|
||||
if (! empty($this->addr_from)) {
|
||||
if (!empty($this->addr_from)) {
|
||||
try {
|
||||
if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
|
||||
if (!empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
|
||||
// Prevent email spoofing for smtp server with a strict configuration
|
||||
$regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string
|
||||
$emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom);
|
||||
@ -476,7 +476,7 @@ class CMailFile
|
||||
}
|
||||
|
||||
// Set the To addresses with an associative array
|
||||
if (! empty($this->addr_to)) {
|
||||
if (!empty($this->addr_to)) {
|
||||
try {
|
||||
$result = $this->message->setTo($this->getArrayAddress($this->addr_to));
|
||||
} catch (Exception $e) {
|
||||
@ -484,7 +484,7 @@ class CMailFile
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($this->reply_to)) {
|
||||
if (!empty($this->reply_to)) {
|
||||
try {
|
||||
$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
|
||||
} catch (Exception $e) {
|
||||
@ -536,12 +536,15 @@ class CMailFile
|
||||
{
|
||||
//$this->message->attach(Swift_Attachment::fromPath($filename_list[$i],$mimetype_list[$i]));
|
||||
$attachment = Swift_Attachment::fromPath($filename_list[$i], $mimetype_list[$i]);
|
||||
if (!empty($mimefilename_list[$i])) {
|
||||
$attachment->setFilename($mimefilename_list[$i]);
|
||||
}
|
||||
$this->message->attach($attachment);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc));
|
||||
if (! empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc));
|
||||
if (!empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc));
|
||||
if (!empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc));
|
||||
//if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to));
|
||||
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
|
||||
} else {
|
||||
@ -653,7 +656,7 @@ class CMailFile
|
||||
$keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
|
||||
if (!empty($this->sendcontext)) {
|
||||
$smtpContextKey = strtoupper($this->sendcontext);
|
||||
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey;
|
||||
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey;
|
||||
$smtpContextSendMode = $conf->global->{$keyForSMTPSendMode};
|
||||
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
|
||||
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey;
|
||||
|
||||
@ -297,6 +297,7 @@ abstract class CommonInvoice extends CommonObject
|
||||
$table2 = 'paiement';
|
||||
$field = 'fk_facture';
|
||||
$field2 = 'fk_paiement';
|
||||
$field3=', p.ref_ext';
|
||||
$sharedentity = 'facture';
|
||||
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||
{
|
||||
@ -304,10 +305,11 @@ abstract class CommonInvoice extends CommonObject
|
||||
$table2 = 'paiementfourn';
|
||||
$field = 'fk_facturefourn';
|
||||
$field2 = 'fk_paiementfourn';
|
||||
$field3='';
|
||||
$sharedentity = 'facture_fourn';
|
||||
}
|
||||
|
||||
$sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code';
|
||||
$sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'.$field3;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t';
|
||||
$sql .= ' WHERE pf.'.$field.' = '.$this->id;
|
||||
//$sql.= ' WHERE pf.'.$field.' = 1';
|
||||
@ -325,7 +327,11 @@ abstract class CommonInvoice extends CommonObject
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
|
||||
$tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
|
||||
if (!empty($field3)) {
|
||||
$tmp['ref_ext'] = $obj->ref_ext;
|
||||
}
|
||||
$retarray[]=$tmp;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2011-2019 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
@ -3893,6 +3893,7 @@ abstract class CommonObject
|
||||
{
|
||||
// phpcs:enable
|
||||
$out = '';
|
||||
|
||||
$this->label_incoterms = '';
|
||||
if (!empty($this->fk_incoterms))
|
||||
{
|
||||
@ -3905,7 +3906,7 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
$out .= (($res->code && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms;
|
||||
$out .= (($out && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms;
|
||||
|
||||
return $out;
|
||||
}
|
||||
@ -4567,245 +4568,245 @@ abstract class CommonObject
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
|
||||
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
|
||||
|
||||
// Increase limit for PDF build
|
||||
$err = error_reporting();
|
||||
error_reporting(0);
|
||||
@set_time_limit(120);
|
||||
error_reporting($err);
|
||||
// Increase limit for PDF build
|
||||
$err = error_reporting();
|
||||
error_reporting(0);
|
||||
@set_time_limit(120);
|
||||
error_reporting($err);
|
||||
|
||||
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
|
||||
$tmp = explode(':', $modele, 2);
|
||||
if (!empty($tmp[1]))
|
||||
{
|
||||
$modele = $tmp[0];
|
||||
$srctemplatepath = $tmp[1];
|
||||
}
|
||||
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
|
||||
$tmp = explode(':', $modele, 2);
|
||||
if (!empty($tmp[1]))
|
||||
{
|
||||
$modele = $tmp[0];
|
||||
$srctemplatepath = $tmp[1];
|
||||
}
|
||||
|
||||
// Search template files
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$filefound = '';
|
||||
$dirmodels = array('/');
|
||||
if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('doc', 'pdf') as $prefix)
|
||||
{
|
||||
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
|
||||
else $file = $prefix."_".$modele.".modules.php";
|
||||
$dirmodels = array('/');
|
||||
if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('doc', 'pdf') as $prefix)
|
||||
{
|
||||
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
|
||||
else $file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($reldir.$modelspath.$file, 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound = $file;
|
||||
$classname = $prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($reldir.$modelspath.$file, 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound = $file;
|
||||
$classname = $prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
|
||||
// If generator was found
|
||||
if ($filefound)
|
||||
{
|
||||
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
|
||||
// If generator was found
|
||||
if ($filefound)
|
||||
{
|
||||
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
|
||||
|
||||
require_once $file;
|
||||
require_once $file;
|
||||
|
||||
$obj = new $classname($this->db);
|
||||
$obj = new $classname($this->db);
|
||||
|
||||
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
|
||||
if ($obj->type == 'odt' && empty($srctemplatepath))
|
||||
{
|
||||
$varfortemplatedir = $obj->scandir;
|
||||
if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir))
|
||||
{
|
||||
$dirtoscan = $conf->global->$varfortemplatedir;
|
||||
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
|
||||
if ($obj->type == 'odt' && empty($srctemplatepath))
|
||||
{
|
||||
$varfortemplatedir = $obj->scandir;
|
||||
if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir))
|
||||
{
|
||||
$dirtoscan = $conf->global->$varfortemplatedir;
|
||||
|
||||
$listoffiles = array();
|
||||
$listoffiles = array();
|
||||
|
||||
// Now we add first model found in directories scanned
|
||||
$listofdir = explode(',', $dirtoscan);
|
||||
foreach ($listofdir as $key => $tmpdir)
|
||||
{
|
||||
$tmpdir = trim($tmpdir);
|
||||
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (!$tmpdir) { unset($listofdir[$key]); continue; }
|
||||
if (is_dir($tmpdir))
|
||||
{
|
||||
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
|
||||
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
// Now we add first model found in directories scanned
|
||||
$listofdir = explode(',', $dirtoscan);
|
||||
foreach ($listofdir as $key => $tmpdir)
|
||||
{
|
||||
$tmpdir = trim($tmpdir);
|
||||
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (!$tmpdir) { unset($listofdir[$key]); continue; }
|
||||
if (is_dir($tmpdir))
|
||||
{
|
||||
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
|
||||
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($listoffiles))
|
||||
{
|
||||
foreach ($listoffiles as $record)
|
||||
{
|
||||
$srctemplatepath = $record['fullname'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($listoffiles))
|
||||
{
|
||||
foreach ($listoffiles as $record)
|
||||
{
|
||||
$srctemplatepath = $record['fullname'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($srctemplatepath))
|
||||
{
|
||||
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (empty($srctemplatepath))
|
||||
{
|
||||
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($obj->type == 'odt' && !empty($srctemplatepath))
|
||||
{
|
||||
if (!dol_is_file($srctemplatepath))
|
||||
{
|
||||
dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING);
|
||||
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if ($obj->type == 'odt' && !empty($srctemplatepath))
|
||||
{
|
||||
if (!dol_is_file($srctemplatepath))
|
||||
{
|
||||
dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING);
|
||||
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output = $outputlangs->charset_output;
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output = $outputlangs->charset_output;
|
||||
|
||||
if (in_array(get_class($this), array('Adherent')))
|
||||
{
|
||||
$arrayofrecords = array(); // The write_file of templates of adherent class need this var
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
|
||||
} else {
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
}
|
||||
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
|
||||
if (in_array(get_class($this), array('Adherent')))
|
||||
{
|
||||
$arrayofrecords = array(); // The write_file of templates of adherent class need this var
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
|
||||
} else {
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
}
|
||||
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
|
||||
|
||||
if ($resultwritefile > 0)
|
||||
{
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
if ($resultwritefile > 0)
|
||||
{
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
|
||||
// We delete old preview
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_delete_preview($this);
|
||||
// We delete old preview
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_delete_preview($this);
|
||||
|
||||
// Index file in database
|
||||
if (!empty($obj->result['fullpath']))
|
||||
{
|
||||
$destfull = $obj->result['fullpath'];
|
||||
$upload_dir = dirname($destfull);
|
||||
$destfile = basename($destfull);
|
||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
|
||||
// Index file in database
|
||||
if (!empty($obj->result['fullpath']))
|
||||
{
|
||||
$destfull = $obj->result['fullpath'];
|
||||
$upload_dir = dirname($destfull);
|
||||
$destfile = basename($destfull);
|
||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
|
||||
|
||||
if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
||||
{
|
||||
$filename = basename($destfile);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
||||
{
|
||||
$filename = basename($destfile);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile = new EcmFiles($this->db);
|
||||
$result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename);
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile = new EcmFiles($this->db);
|
||||
$result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename);
|
||||
|
||||
// Set the public "share" key
|
||||
$setsharekey = false;
|
||||
if ($this->element == 'propal')
|
||||
{
|
||||
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
|
||||
if ($useonlinesignature) $setsharekey = true;
|
||||
if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
// Set the public "share" key
|
||||
$setsharekey = false;
|
||||
if ($this->element == 'propal')
|
||||
{
|
||||
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
|
||||
if ($useonlinesignature) $setsharekey = true;
|
||||
if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
|
||||
if ($setsharekey) {
|
||||
if (empty($ecmfile->share)) // Because object not found or share not set yet
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$ecmfile->share = getRandomPassword(true);
|
||||
}
|
||||
}
|
||||
if ($setsharekey) {
|
||||
if (empty($ecmfile->share)) // Because object not found or share not set yet
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$ecmfile->share = getRandomPassword(true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->update($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
} else {
|
||||
$ecmfile->entity = $conf->entity;
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$ecmfile->src_object_type = $this->table_element;
|
||||
$ecmfile->src_object_id = $this->id;
|
||||
if ($result > 0)
|
||||
{
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->update($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
} else {
|
||||
$ecmfile->entity = $conf->entity;
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$ecmfile->src_object_type = $this->table_element;
|
||||
$ecmfile->src_object_id = $this->id;
|
||||
|
||||
$result = $ecmfile->create($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
$result = $ecmfile->create($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
|
||||
/*$this->result['fullname']=$destfull;
|
||||
/*$this->result['fullname']=$destfull;
|
||||
$this->result['filepath']=$ecmfile->filepath;
|
||||
$this->result['filename']=$ecmfile->filename;*/
|
||||
//var_dump($obj->update_main_doc_field);exit;
|
||||
//var_dump($obj->update_main_doc_field);exit;
|
||||
|
||||
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
|
||||
$update_main_doc_field = 0;
|
||||
if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1;
|
||||
if ($update_main_doc_field && !empty($this->table_element))
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
||||
$sql .= ' WHERE rowid = '.$this->id;
|
||||
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
|
||||
$update_main_doc_field = 0;
|
||||
if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1;
|
||||
if ($update_main_doc_field && !empty($this->table_element))
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
||||
$sql .= ' WHERE rowid = '.$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
dol_print_error($this->db);
|
||||
} else {
|
||||
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
|
||||
}
|
||||
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
|
||||
}
|
||||
|
||||
// Success in building document. We build meta file.
|
||||
dol_meta_create($this);
|
||||
// Success in building document. We build meta file.
|
||||
dol_meta_create($this);
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (!$filefound) {
|
||||
$this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele;
|
||||
dol_print_error('', $this->error);
|
||||
} else {
|
||||
$this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound);
|
||||
dol_print_error('', $this->error);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (!$filefound) {
|
||||
$this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele;
|
||||
dol_print_error('', $this->error);
|
||||
} else {
|
||||
$this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound);
|
||||
dol_print_error('', $this->error);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
} else return $reshook;
|
||||
}
|
||||
|
||||
@ -6706,7 +6707,7 @@ abstract class CommonObject
|
||||
$value = implode('<br>', $value);
|
||||
}
|
||||
|
||||
//print $type.'-'.$size;
|
||||
//print $type.'-'.$size.'-'.$value;
|
||||
$out = $value;
|
||||
|
||||
return $out;
|
||||
@ -7987,46 +7988,46 @@ abstract class CommonObject
|
||||
|
||||
// Delete cascade first
|
||||
if (is_array($this->childtablesoncascade) && !empty($this->childtablesoncascade)) {
|
||||
foreach ($this->childtablesoncascade as $table)
|
||||
{
|
||||
$deleteFromObject = explode(':', $table);
|
||||
if (count($deleteFromObject) >= 2) {
|
||||
$className = str_replace('@', '', $deleteFromObject[0]);
|
||||
$filePath = $deleteFromObject[1];
|
||||
$columnName = $deleteFromObject[2];
|
||||
if (dol_include_once($filePath)) {
|
||||
$childObject = new $className($this->db);
|
||||
if (method_exists($childObject, 'deleteByParentField')) {
|
||||
$result = $childObject->deleteByParentField($this->id, $columnName);
|
||||
if ($result < 0) {
|
||||
foreach ($this->childtablesoncascade as $table)
|
||||
{
|
||||
$deleteFromObject = explode(':', $table);
|
||||
if (count($deleteFromObject) >= 2) {
|
||||
$className = str_replace('@', '', $deleteFromObject[0]);
|
||||
$filePath = $deleteFromObject[1];
|
||||
$columnName = $deleteFromObject[2];
|
||||
if (dol_include_once($filePath)) {
|
||||
$childObject = new $className($this->db);
|
||||
if (method_exists($childObject, 'deleteByParentField')) {
|
||||
$result = $childObject->deleteByParentField($this->id, $columnName);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->errors[] = $childObject->error;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $childObject->error;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[] = "You defined a cascade delete on an object $childObject but there is no method deleteByParentField for it";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[] = 'Cannot include child class file '.$filePath;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Delete record in child table
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
$this->errors[] = 'Cannot include child class file '.$filePath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Delete record in child table
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
@ -8414,4 +8415,49 @@ abstract class CommonObject
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete related files of object in database
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteEcmFiles()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
switch ($this->element){
|
||||
case 'propal':
|
||||
$element = 'propale';
|
||||
break;
|
||||
case 'product':
|
||||
$element = 'produit';
|
||||
break;
|
||||
case 'order_supplier':
|
||||
$element ='fournisseur/commande';
|
||||
break;
|
||||
case 'invoice_supplier':
|
||||
$element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier');
|
||||
break;
|
||||
case 'shipping':
|
||||
$element = 'expedition/sending';
|
||||
break;
|
||||
default:
|
||||
$element = $this->element;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files";
|
||||
$sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
|
||||
$sql.= " AND filepath = '".$element."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity;
|
||||
|
||||
if (!$this->db->query($sql)) {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,11 +61,11 @@ abstract class CommonObjectLine extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translation key from units dictionary.
|
||||
* Returns the label, shot_label or code found in units dictionary from ->fk_unit.
|
||||
* A langs->trans() must be called on result to get translated value.
|
||||
*
|
||||
* @param string $type Label type (long or short). This can be a translation key.
|
||||
* @return string|int <0 if ko, label if ok
|
||||
* @param string $type Label type ('long', 'short' or 'code'). This can be a translation key.
|
||||
* @return string|int <0 if KO, label if OK (Example: 'long', 'short' or 'unitCODE')
|
||||
*/
|
||||
public function getLabelOfUnit($type = 'long')
|
||||
{
|
||||
@ -79,17 +79,16 @@ abstract class CommonObjectLine extends CommonObject
|
||||
|
||||
$label_type = 'label';
|
||||
|
||||
if ($type == 'short')
|
||||
{
|
||||
$label_type = 'short_label';
|
||||
}
|
||||
$label_type = 'label';
|
||||
if ($type == 'short') $label_type = 'short_label';
|
||||
elseif ($type == 'code') $label_type = 'code';
|
||||
|
||||
$sql = 'select '.$label_type.',code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
|
||||
$sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql && $this->db->num_rows($resql) > 0)
|
||||
{
|
||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||
$res = $this->db->fetch_array($resql);
|
||||
$label = ($label_type == 'short' ? $res[$label_type] : 'unit'.$res['code']);
|
||||
if ($label_type == 'code') $label = 'unit'.$res['code'];
|
||||
else $label = $res[$label_type];
|
||||
$this->db->free($resql);
|
||||
return $label;
|
||||
} else {
|
||||
|
||||
@ -31,385 +31,385 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
*/
|
||||
class CoreObject extends CommonObject
|
||||
{
|
||||
public $withChild = true;
|
||||
public $withChild = true;
|
||||
|
||||
/**
|
||||
* @var Array $_fields Fields to synchronize with Database
|
||||
*/
|
||||
protected $fields = array();
|
||||
/**
|
||||
* @var Array $_fields Fields to synchronize with Database
|
||||
*/
|
||||
protected $fields = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB &$db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB &$db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to init fields
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->id = 0;
|
||||
$this->datec = 0;
|
||||
$this->tms = 0;
|
||||
/**
|
||||
* Function to init fields
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->id = 0;
|
||||
$this->datec = 0;
|
||||
$this->tms = 0;
|
||||
|
||||
if (!empty($this->fields))
|
||||
{
|
||||
foreach ($this->fields as $field=>$info)
|
||||
{
|
||||
if ($this->isDate($info)) $this->{$field} = time();
|
||||
elseif ($this->isArray($info)) $this->{$field} = array();
|
||||
elseif ($this->isInt($info)) $this->{$field} = (int) 0;
|
||||
elseif ($this->isFloat($info)) $this->{$field} = (double) 0;
|
||||
else $this->{$field} = '';
|
||||
}
|
||||
if (!empty($this->fields))
|
||||
{
|
||||
foreach ($this->fields as $field=>$info)
|
||||
{
|
||||
if ($this->isDate($info)) $this->{$field} = time();
|
||||
elseif ($this->isArray($info)) $this->{$field} = array();
|
||||
elseif ($this->isInt($info)) $this->{$field} = (int) 0;
|
||||
elseif ($this->isFloat($info)) $this->{$field} = (double) 0;
|
||||
else $this->{$field} = '';
|
||||
}
|
||||
|
||||
$this->to_delete = false;
|
||||
$this->is_clone = false;
|
||||
$this->to_delete = false;
|
||||
$this->is_clone = false;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test type of field
|
||||
*
|
||||
* @param string $field name of field
|
||||
* @param string $type type of field to test
|
||||
* @return boolean value of field or false
|
||||
*/
|
||||
private function checkFieldType($field, $type)
|
||||
{
|
||||
if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type))
|
||||
{
|
||||
return $this->{'is_'.$type}($this->fields[$field]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Test type of field
|
||||
*
|
||||
* @param string $field name of field
|
||||
* @param string $type type of field to test
|
||||
* @return boolean value of field or false
|
||||
*/
|
||||
private function checkFieldType($field, $type)
|
||||
{
|
||||
if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type))
|
||||
{
|
||||
return $this->{'is_'.$type}($this->fields[$field]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object and children from database
|
||||
*
|
||||
* @param int $id Id of object to load
|
||||
* @param bool $loadChild used to load children from database
|
||||
* @return int >0 if OK, <0 if KO, 0 if not found
|
||||
*/
|
||||
public function fetch($id, $loadChild = true)
|
||||
{
|
||||
$res = $this->fetchCommon($id);
|
||||
if ($res > 0) {
|
||||
if ($loadChild) $this->fetchChild();
|
||||
}
|
||||
/**
|
||||
* Get object and children from database
|
||||
*
|
||||
* @param int $id Id of object to load
|
||||
* @param bool $loadChild used to load children from database
|
||||
* @return int >0 if OK, <0 if KO, 0 if not found
|
||||
*/
|
||||
public function fetch($id, $loadChild = true)
|
||||
{
|
||||
$res = $this->fetchCommon($id);
|
||||
if ($res > 0) {
|
||||
if ($loadChild) $this->fetchChild();
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to instantiate a new child
|
||||
*
|
||||
* @param string $tabName Table name of child
|
||||
* @param int $id If id is given, we try to return his key if exist or load if we try_to_load
|
||||
* @param string $key Attribute name of the object id
|
||||
* @param bool $try_to_load Force the fetch if an id is given
|
||||
* @return int
|
||||
*/
|
||||
public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false)
|
||||
{
|
||||
if (!empty($id))
|
||||
{
|
||||
foreach ($this->{$tabName} as $k=>&$object)
|
||||
{
|
||||
if ($object->{$key} === $id) return $k;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Function to instantiate a new child
|
||||
*
|
||||
* @param string $tabName Table name of child
|
||||
* @param int $id If id is given, we try to return his key if exist or load if we try_to_load
|
||||
* @param string $key Attribute name of the object id
|
||||
* @param bool $try_to_load Force the fetch if an id is given
|
||||
* @return int
|
||||
*/
|
||||
public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false)
|
||||
{
|
||||
if (!empty($id))
|
||||
{
|
||||
foreach ($this->{$tabName} as $k=>&$object)
|
||||
{
|
||||
if ($object->{$key} === $id) return $k;
|
||||
}
|
||||
}
|
||||
|
||||
$k = count($this->{$tabName});
|
||||
$k = count($this->{$tabName});
|
||||
|
||||
$className = ucfirst($tabName);
|
||||
$this->{$tabName}[$k] = new $className($this->db);
|
||||
if ($id > 0 && $key === 'id' && $try_to_load)
|
||||
{
|
||||
$this->{$tabName}[$k]->fetch($id);
|
||||
}
|
||||
$className = ucfirst($tabName);
|
||||
$this->{$tabName}[$k] = new $className($this->db);
|
||||
if ($id > 0 && $key === 'id' && $try_to_load)
|
||||
{
|
||||
$this->{$tabName}[$k]->fetch($id);
|
||||
}
|
||||
|
||||
return $k;
|
||||
}
|
||||
return $k;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to set a child as to delete
|
||||
*
|
||||
* @param string $tabName Table name of child
|
||||
* @param int $id Id of child to set as to delete
|
||||
* @param string $key Attribute name of the object id
|
||||
* @return bool
|
||||
*/
|
||||
public function removeChild($tabName, $id, $key = 'id')
|
||||
{
|
||||
foreach ($this->{$tabName} as &$object)
|
||||
{
|
||||
if ($object->{$key} == $id)
|
||||
{
|
||||
$object->to_delete = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Function to set a child as to delete
|
||||
*
|
||||
* @param string $tabName Table name of child
|
||||
* @param int $id Id of child to set as to delete
|
||||
* @param string $key Attribute name of the object id
|
||||
* @return bool
|
||||
*/
|
||||
public function removeChild($tabName, $id, $key = 'id')
|
||||
{
|
||||
foreach ($this->{$tabName} as &$object)
|
||||
{
|
||||
if ($object->{$key} == $id)
|
||||
{
|
||||
$object->to_delete = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to fetch children objects
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fetchChild()
|
||||
{
|
||||
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
|
||||
{
|
||||
foreach ($this->childtables as &$childTable)
|
||||
{
|
||||
$className = ucfirst($childTable);
|
||||
/**
|
||||
* Function to fetch children objects
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fetchChild()
|
||||
{
|
||||
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
|
||||
{
|
||||
foreach ($this->childtables as &$childTable)
|
||||
{
|
||||
$className = ucfirst($childTable);
|
||||
|
||||
$this->{$className} = array();
|
||||
$this->{$className} = array();
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
$res = $this->db->query($sql);
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
$res = $this->db->query($sql);
|
||||
|
||||
if ($res)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($res))
|
||||
{
|
||||
$o = new $className($this->db);
|
||||
$o->fetch($obj->rowid);
|
||||
if ($res)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($res))
|
||||
{
|
||||
$o = new $className($this->db);
|
||||
$o->fetch($obj->rowid);
|
||||
|
||||
$this->{$className}[] = $o;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->{$className}[] = $o;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update children data
|
||||
*
|
||||
* @param User $user user object
|
||||
* @return void
|
||||
*/
|
||||
public function saveChild(User &$user)
|
||||
{
|
||||
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
|
||||
{
|
||||
foreach ($this->childtables as &$childTable)
|
||||
{
|
||||
$className = ucfirst($childTable);
|
||||
if (!empty($this->{$className}))
|
||||
{
|
||||
foreach ($this->{$className} as $i => &$object)
|
||||
{
|
||||
$object->{$this->fk_element} = $this->id;
|
||||
/**
|
||||
* Function to update children data
|
||||
*
|
||||
* @param User $user user object
|
||||
* @return void
|
||||
*/
|
||||
public function saveChild(User &$user)
|
||||
{
|
||||
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
|
||||
{
|
||||
foreach ($this->childtables as &$childTable)
|
||||
{
|
||||
$className = ucfirst($childTable);
|
||||
if (!empty($this->{$className}))
|
||||
{
|
||||
foreach ($this->{$className} as $i => &$object)
|
||||
{
|
||||
$object->{$this->fk_element} = $this->id;
|
||||
|
||||
$object->update($user);
|
||||
if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$object->update($user);
|
||||
if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to update object or create or delete if needed
|
||||
*
|
||||
* @param User $user User object
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
public function update(User &$user)
|
||||
{
|
||||
if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed
|
||||
elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user);
|
||||
/**
|
||||
* Function to update object or create or delete if needed
|
||||
*
|
||||
* @param User $user User object
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
public function update(User &$user)
|
||||
{
|
||||
if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed
|
||||
elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user);
|
||||
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$res = $this->updateCommon($user);
|
||||
if ($res)
|
||||
{
|
||||
$result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
else $this->saveChild($user);
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
$res = $this->updateCommon($user);
|
||||
if ($res)
|
||||
{
|
||||
$result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
else $this->saveChild($user);
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to create object in database
|
||||
*
|
||||
* @param User $user user object
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
public function create(User &$user)
|
||||
{
|
||||
if ($this->id > 0) return $this->update($user);
|
||||
/**
|
||||
* Function to create object in database
|
||||
*
|
||||
* @param User $user User object
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
if ($this->id > 0) return $this->update($user);
|
||||
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$res = $this->createCommon($user);
|
||||
if ($res)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id($this->table_element);
|
||||
$res = $this->createCommon($user);
|
||||
if ($res)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id($this->table_element);
|
||||
|
||||
$result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
else $this->saveChild($user);
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
$result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
else $this->saveChild($user);
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to delete object in database
|
||||
*
|
||||
* @param User $user user object
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
public function delete(User &$user)
|
||||
{
|
||||
if ($this->id <= 0) return 0;
|
||||
/**
|
||||
* Function to delete object in database
|
||||
*
|
||||
* @param User $user user object
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
public function delete(User &$user)
|
||||
{
|
||||
if ($this->id <= 0) return 0;
|
||||
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
$result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$this->deleteCommon($user);
|
||||
if ($this->withChild && !empty($this->childtables))
|
||||
{
|
||||
foreach ($this->childtables as &$childTable)
|
||||
{
|
||||
$className = ucfirst($childTable);
|
||||
if (!empty($this->{$className}))
|
||||
{
|
||||
foreach ($this->{$className} as &$object)
|
||||
{
|
||||
$object->delete($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
$this->deleteCommon($user);
|
||||
if ($this->withChild && !empty($this->childtables))
|
||||
{
|
||||
foreach ($this->childtables as &$childTable)
|
||||
{
|
||||
$className = ucfirst($childTable);
|
||||
if (!empty($this->{$className}))
|
||||
{
|
||||
foreach ($this->{$className} as &$object)
|
||||
{
|
||||
$object->delete($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to get a formatted date
|
||||
*
|
||||
* @param string $field Attribute to return
|
||||
* @param string $format Output date format
|
||||
* @return string
|
||||
*/
|
||||
public function getDate($field, $format = '')
|
||||
{
|
||||
if (empty($this->{$field})) return '';
|
||||
else {
|
||||
return dol_print_date($this->{$field}, $format);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Function to get a formatted date
|
||||
*
|
||||
* @param string $field Attribute to return
|
||||
* @param string $format Output date format
|
||||
* @return string
|
||||
*/
|
||||
public function getDate($field, $format = '')
|
||||
{
|
||||
if (empty($this->{$field})) return '';
|
||||
else {
|
||||
return dol_print_date($this->{$field}, $format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to set date in field
|
||||
*
|
||||
* @param string $field field to set
|
||||
* @param string $date formatted date to convert
|
||||
* @return mixed
|
||||
*/
|
||||
public function setDate($field, $date)
|
||||
{
|
||||
if (empty($date))
|
||||
{
|
||||
$this->{$field} = 0;
|
||||
} else {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
$this->{$field} = dol_stringtotime($date);
|
||||
}
|
||||
/**
|
||||
* Function to set date in field
|
||||
*
|
||||
* @param string $field field to set
|
||||
* @param string $date formatted date to convert
|
||||
* @return mixed
|
||||
*/
|
||||
public function setDate($field, $date)
|
||||
{
|
||||
if (empty($date))
|
||||
{
|
||||
$this->{$field} = 0;
|
||||
} else {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
$this->{$field} = dol_stringtotime($date);
|
||||
}
|
||||
|
||||
return $this->{$field};
|
||||
}
|
||||
return $this->{$field};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to update current object
|
||||
*
|
||||
* @param array $Tab Array of values
|
||||
* @return int
|
||||
*/
|
||||
public function setValues(&$Tab)
|
||||
{
|
||||
foreach ($Tab as $key => $value)
|
||||
{
|
||||
if ($this->checkFieldType($key, 'date'))
|
||||
{
|
||||
$this->setDate($key, $value);
|
||||
} elseif ($this->checkFieldType($key, 'float'))
|
||||
{
|
||||
$this->{$key} = (double) price2num($value);
|
||||
} elseif ($this->checkFieldType($key, 'int')) {
|
||||
$this->{$key} = (int) price2num($value);
|
||||
} else {
|
||||
$this->{$key} = dol_string_nohtmltag($value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Function to update current object
|
||||
*
|
||||
* @param array $Tab Array of values
|
||||
* @return int
|
||||
*/
|
||||
public function setValues(&$Tab)
|
||||
{
|
||||
foreach ($Tab as $key => $value)
|
||||
{
|
||||
if ($this->checkFieldType($key, 'date'))
|
||||
{
|
||||
$this->setDate($key, $value);
|
||||
} elseif ($this->checkFieldType($key, 'float'))
|
||||
{
|
||||
$this->{$key} = (double) price2num($value);
|
||||
} elseif ($this->checkFieldType($key, 'int')) {
|
||||
$this->{$key} = (int) price2num($value);
|
||||
} else {
|
||||
$this->{$key} = dol_string_nohtmltag($value);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user