Merge branch 'develop' into patch-36

This commit is contained in:
Laurent Destailleur 2020-02-21 19:54:15 +01:00 committed by GitHub
commit 0aa4ee9d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
504 changed files with 26391 additions and 17203 deletions

10
.github/ISSUE_TEMPLATE/custom.md vendored Normal file
View File

@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''
---

View File

@ -0,0 +1,13 @@
# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Greetings PR
on: [pull_request]
jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: 'Welcome to the Dolibarr army. You are on the road to become an Admiral (see https://wiki.dolibarr.org/index.php/Dolibarr_Project)'

23
.github/workflows/stale-issues.yml vendored Normal file
View File

@ -0,0 +1,23 @@
# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: "Close stale issues (bugs and feature requests)"
on:
schedule:
- cron: "0 0 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. Without comment, this issue will be closed automatically by stale bot in 15 days.'
stale-issue-label: 'Issue Stale (automatic label)'
exempt-issue-label: 'Priority High / Blocking'
days-before-stale: 365
days-before-close: 10
#stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. If this PR is still mergeable (no conflict, nor Continuous Integration errors), please comment to confirm this merge is still expected. Without comment, this issue will be closed automatically by stale bot in 15 days.'
#stale-pr-label: 'PR Stale (automatic label)'
#exempt-pr-label: 'Priority Top Strategic'

View File

@ -2,8 +2,8 @@
# from Dolibarr GitHub repository.
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/
# We use dist: trusty to have php 5.4+ available
dist: trusty
# We use dist: xenial to have php 5.6+ available
dist: xenial
sudo: required
language: php
@ -11,14 +11,16 @@ language: php
# Start on every boot
services:
- memcached
- mysql
- postgresql
addons:
mariadb: '10.0'
postgresql: '9.3'
# Force postgresql to 9.4 (the oldest availablable on xenial)
postgresql: '9.4'
apt:
sources:
# To use the last version of pgloader, we add repo of postgresql
- pgdg-trusty
# To use the last version of pgloader, we add repo of postgresql with a name available in http://apt.postgresql.org/pub/repos/apt/
- pgdg-xenial
packages:
# We need a webserver to test the webservices
# Let's install Apache with.
@ -29,7 +31,6 @@ addons:
- pgloader
php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
@ -44,11 +45,9 @@ env:
- DEBUG=false
matrix:
# MariaDB overrides MySQL installation so it's not possible to test both yet
#- DB=mysql
- DB=mariadb
#- DB=mariadb
- DB=mysql
- DB=postgresql
# TODO
#- DB=sqlite
# See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP
#- WS=apache
# See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test
@ -60,18 +59,14 @@ matrix:
- php: nightly
# We exclude some combinations not usefull to save Travis CPU
exclude:
- php: '5.6'
env: DB=mariadb
- php: '7.0'
env: DB=mariadb
env: DB=mysql
- php: '7.1'
env: DB=mariadb
env: DB=mysql
- php: '7.2'
env: DB=mariadb
env: DB=mysql
- php: '7.3'
env: DB=mariadb
- php: '5.6'
env: DB=postgresql
env: DB=mysql
- php: '7.0'
env: DB=postgresql
- php: '7.1'
@ -188,32 +183,31 @@ before_script:
# Check Apache version
echo "Apache version"
apache2 -v | head -
# Check MariaDb
echo "MariaDb version"
# Check Database
echo "Database version"
mysql --version | head -
mysql -e "SELECT VERSION();" | head -
psql --version
echo
- |
echo "Setting up database"
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then
echo "MySQL"
mysql -e 'DROP DATABASE IF EXISTS travis;'
mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
mysql -e 'FLUSH PRIVILEGES;'
mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
mysql -u root -e 'DROP DATABASE IF EXISTS travis;'
mysql -u root -e 'CREATE DATABASE IF NOT EXISTS travis;'
mysql -u root -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
mysql -u root -e 'FLUSH PRIVILEGES;'
mysql -u root -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
fi
if [ "$DB" = 'postgresql' ]; then
#pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
#pgloader mysql://root:pass@127.0.0.1/dolibarr_9 postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dev
echo pgloader mysql://root@127.0.0.1/travis postgresql:///travis
pgloader mysql://root@127.0.0.1/travis postgresql:///travis
echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql travis
echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql travis
#echo 'select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'llx_accountingaccount' | psql travis
#echo 'select * from information_schema.table_constraints;' | psql travis
#echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis
#psql -c 'create database travis;' -U postgres
#psql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
#pgloader mysql://root:pass@127.0.0.1/dolibarr_src postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dest
echo pgloader mysql://root@127.0.0.1/travis postgresql://postgres@/travis
pgloader mysql://root@127.0.0.1/travis postgresql://postgres@/travis
echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql -U postgres travis
echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql -U postgres travis
fi
echo
@ -262,10 +256,7 @@ before_script:
- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
- sudo chown -R travis:travis /var/lib/apache2/fastcgi
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
# configure apache virtual hosts for precise
#- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default
#- sudo cat /etc/apache2/sites-available/default
# configure apache virtual hosts for trusty
# configure apache virtual hosts
- sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
- sudo cat /etc/apache2/sites-available/000-default.conf
@ -290,7 +281,7 @@ script:
# Ensure we catch errors
set -e
#parallel-lint --exclude htdocs/includes --blame .
parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer/tests --exclude htdocs/includes/jakub-onderka/php-parallel-lint/tests --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/php-token-stream/tests --exclude htdocs/includes/composer/autoload_static.php --blame .
parallel-lint --exclude dev/namespacemig --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame .
set +e
echo
@ -406,9 +397,12 @@ script:
php upgrade.php 9.0.0 10.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade9001000.log
php upgrade2.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-2.log
php step5.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-3.log
php upgrade.php 10.0.0 11.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade9001000.log
php upgrade2.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-2.log
php step5.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-3.log
php upgrade.php 10.0.0 11.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade10001100.log
php upgrade2.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-2.log
php step5.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-3.log
php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log
php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log
php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log
# Enable modules not enabled into original dump
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log
echo $?
@ -455,7 +449,7 @@ after_failure:
# Dolibarr log file
echo "Debugging informations for file dolibarr.log (latest 50 lines)"
tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log
# MariaDB log file
# Database log file
echo "Debugging informations for file mysql error.log"
sudo tail -n 50 /var/log/mysql/error.log
# TODO: PostgreSQL log file

View File

@ -3,6 +3,24 @@ English Dolibarr ChangeLog
--------------------------------------------------------------
***** ChangeLog for 12.0.0 compared to 11.0.0 *****
For Users:
NEW: Module MO (Manufacturing Order) is available as stable module.
For Developers or integrators:
WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* PHP 5.5 is no more supported. Minimum PHP is now 5.6+.
* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests
with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing
the HTML into content (in such a case, sanitize data later)
* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless.
***** ChangeLog for 11.0.1 compared to 11.0.0 *****
FIX: advanced target emailing sql and ergonomy.
FIX: After import of a website template, home page was not set.
@ -75,6 +93,7 @@ FIX: #13094
FIX: #13096
FIX: #13100
***** ChangeLog for 11.0.0 compared to 10.0.0 *****
For Users:

View File

@ -151,6 +151,7 @@ La documentation utilisateur, développeur et traducteur est disponible sous for
## CONTRIBUER
Ce projet existe grâce à ses nombreux contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)].
<a href="https://github.com/Dolibarr/dolibarr/graphs/contributors"><img src="https://opencollective.com/dolibarr/contributors.svg?width=890&button=false" /></a>
## CREDITS

View File

@ -170,7 +170,8 @@ Administrator, user, developer and translator's documentations are available alo
## CONTRIBUTING
This project exists thanks to all the people who contribute. [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)].
This project exists thanks to all the people who contribute. [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]
<a href="https://github.com/Dolibarr/dolibarr/graphs/contributors"><img src="https://opencollective.com/dolibarr/contributors.svg?width=890&button=false" /></a>
## CREDITS

View File

@ -3,10 +3,11 @@ FROM php:7.2-apache
ENV HOST_USER_ID 33
ENV PHP_INI_DATE_TIMEZONE 'UTC'
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libldap2-dev zlib1g-dev libicu-dev g++\
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libldap2-dev libzip-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 \

View File

@ -253,6 +253,24 @@ PARSEDOWN
$shortage = 4 - $len % 4;
OAUTH
-----
Add into Class Google of file OAuth2/Service/Google:
// LDR CHANGE Add approval_prompt to force the prompt if value is set to 'force' so it force return of a "refresh token" in addition to "standard token"
public $approvalPrompt='auto';
public function setApprouvalPrompt($prompt)
{
if (!in_array($prompt, array('auto', 'force'), true)) {
// @todo Maybe could we rename this exception
throw new InvalidAccessTypeException('Invalid approuvalPrompt, expected either auto or force.');
}
$this->approvalPrompt = $prompt;
}
JEDITABLE.JS
------------

View File

@ -66,8 +66,9 @@ $obj = new Facture($db);
$obj->ref = 'ABCDE';
$obj->socid = 4; // Put id of third party (rowid in llx_societe table)
$obj->date = mktime();
$obj->note = 'A comment';
$obj->date = dol_now();
$obj->note_public = 'A public comment';
$obj->note_private = 'A private comment';
$obj->cond_reglement_id = 1;
$line1=new FactureLigne($db);

View File

@ -66,8 +66,9 @@ $com = new Commande($db);
$com->ref = 'ABCDE';
$com->socid = 4; // Put id of third party (rowid in llx_societe table)
$com->date_commande = mktime();
$com->note = 'A comment';
$com->date = dol_now();
$com->note_public = 'A public comment';
$com->note_private = 'A private comment';
$com->source = 1;
$com->remise_percent = 0;

View File

@ -0,0 +1,231 @@
#!/usr/bin/env php
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* WARNING, THIS WILL LOAD MASS DATA ON YOUR INSTANCE
*/
/**
* \file dev/initdata/import-dbf.php
* \brief Script example to create a table from a large DBF file (openoffice)
* To purge data, you can have a look at purge-data.php
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = dirname(__FILE__) . '/';
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Recupere root dolibarr
$path = dirname($_SERVER["PHP_SELF"]);
require $path . "./../htdocs/master.inc.php";
require $path . "/includes/dbase.class.php";
// Global variables
$version = DOL_VERSION;
$confirmed = 1;
$error = 0;
/*
* Main
*/
@set_time_limit(0);
print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n";
dol_syslog($script_file . " launched with arg " . implode(',', $argv));
$filepath = $argv[1];
$filepatherr = $filepath . '.err';
$startchar = empty($argv[2]) ? 0 : (int) $argv[2];
$deleteTable = empty($argv[3]) ? 1 : 0;
$startlinenb = empty($argv[3]) ? 1 : (int) $argv[3];
$endlinenb = empty($argv[4]) ? 0 : (int) $argv[4];
if (empty($filepath)) {
print "Usage: php $script_file myfilepath.dbf [removeChatColumnName] [startlinenb] [endlinenb]\n";
print "Example: php $script_file myfilepath.dbf 0 2 1002\n";
print "\n";
exit(-1);
}
if (!file_exists($filepath)) {
print "Error: File " . $filepath . " not found.\n";
print "\n";
exit(-1);
}
$ret = $user->fetch('', 'admin');
if (!$ret > 0) {
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
exit;
}
$user->getrights();
// Ask confirmation
if (!$confirmed) {
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
}
// Open input and output files
$fhandle = dbase_open($filepath, 0);
if (!$fhandle) {
print 'Error: Failed to open file ' . $filepath . "\n";
exit(1);
}
$fhandleerr = fopen($filepatherr, 'w');
if (!$fhandleerr) {
print 'Error: Failed to open file ' . $filepatherr . "\n";
exit(1);
}
$langs->setDefaultLang($defaultlang);
$record_numbers = dbase_numrecords($fhandle);
$table_name = substr(basename($filepath), 0, strpos(basename($filepath), '.'));
print 'Info: ' . $record_numbers . " lines in file \n";
$header = dbase_get_header_info($fhandle);
if ($deleteTable) {
$db->query("DROP TABLE IF EXISTS `$table_name`");
}
$sqlCreate = "CREATE TABLE IF NOT EXISTS `$table_name` ( `id` INT(11) NOT NULL AUTO_INCREMENT ";
$fieldArray = array("`id`");
foreach ($header as $value) {
$fieldName = substr(str_replace('_', '', $value['name']), $startchar);
$fieldArray[] = "`$fieldName`";
$sqlCreate .= ", `" . $fieldName . "` VARCHAR({$value['length']}) NULL DEFAULT NULL ";
}
$sqlCreate .= ", PRIMARY KEY (`id`)) ENGINE = InnoDB";
$resql = $db->query($sqlCreate);
if ($resql !== false) {
print "Table $table_name created\n";
} else {
var_dump($db->errno());
print "Impossible : " . $sqlCreate . "\n";
die();
}
$i = 0;
$nboflines++;
$fields = implode(',', $fieldArray);
//var_dump($fieldArray);die();
$maxLength = 0;
for ($i = 1; $i <= $record_numbers; $i++) {
if ($startlinenb && $i < $startlinenb)
continue;
if ($endlinenb && $i > $endlinenb)
continue;
$row = dbase_get_record_with_names($fhandle, $i);
if ($row === false || (isset($row["deleted"]) && $row["deleted"] == '1'))
continue;
$sqlInsert = "INSERT INTO `$table_name`($fields) VALUES (null,";
array_shift($row); // remove delete column
foreach ($row as $value) {
$sqlInsert .= "'" . $db->escape(utf8_encode($value)) . "', ";
}
replaceable_echo(implode("\t", $row));
$sqlInsert = rtrim($sqlInsert, ', ');
$sqlInsert .= ")";
$resql = $db->query($sqlInsert);
if ($resql === false) {
print "Impossible : " . $sqlInsert . "\n";
var_dump($row, $db->errno());
die();
}
// $fields = (object) $row;
// var_dump($fields);
continue;
}
die();
// commit or rollback
print "Nb of lines qualified: " . $nboflines . "\n";
print "Nb of errors: " . $error . "\n";
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
print "Rollback any changes.\n";
$db->rollback();
} else {
print "Commit all changes.\n";
$db->commit();
}
$db->close();
fclose($fhandle);
fclose($fhandleerr);
exit($error);
/**
* replaceable_echo
*
* @param string $message Message
* @param int $force_clear_lines Force clear messages
* @return void
*/
function replaceable_echo($message, $force_clear_lines = null)
{
static $last_lines = 0;
if (!is_null($force_clear_lines)) {
$last_lines = $force_clear_lines;
}
$toss = array();
$status = 0;
$term_width = exec('tput cols', $toss, $status);
if ($status) {
$term_width = 64; // Arbitrary fall-back term width.
}
$line_count = 0;
foreach (explode("\n", $message) as $line) {
$line_count += count(str_split($line, $term_width));
}
// Erasure MAGIC: Clear as many lines as the last output had.
for ($i = 0; $i < $last_lines; $i++) {
// Return to the beginning of the line
echo "\r";
// Erase to the end of the line
echo "\033[K";
// Move cursor Up a line
echo "\033[1A";
// Return to the beginning of the line
echo "\r";
// Erase to the end of the line
echo "\033[K";
// Return to the beginning of the line
echo "\r";
// Can be consolodated into
// echo "\r\033[K\033[1A\r\033[K\r";
}
$last_lines = $line_count;
echo $message . "\n";
}

View File

@ -0,0 +1,241 @@
#!/usr/bin/env php
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* WARNING, THIS WILL LOAD MASS DATA ON YOUR INSTANCE
*/
/**
* \file dev/initdata/import-product.php
* \brief Script example to insert products from a csv file.
* To purge data, you can have a look at purge-data.php
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = dirname(__FILE__) . '/';
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Recupere root dolibarr
$path = preg_replace('/importdb-products.php/i', '', $_SERVER["PHP_SELF"]);
require $path . "../../htdocs/master.inc.php";
require $path . "includes/dbase.class.php";
include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
//$delimiter = ',';
//$enclosure = '"';
//$linelength = 10000;
//$escape = '/';
// Global variables
$version = DOL_VERSION;
$confirmed = 1;
$error = 0;
$tvas = [
'1' => "20.00",
'2' => "5.50",
'3' => "0.00",
'4' => "20.60",
'5' => "19.60",
];
$tvasD = [
'1' => "20",
'2' => "5.5",
'3' => "0",
'4' => "20",
'5' => "20",
];
/*
* Main
*/
@set_time_limit(0);
print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n";
dol_syslog($script_file . " launched with arg " . implode(',', $argv));
$table = $argv[1];
if (empty($argv[1])) {
print "Error: Which table ?\n";
print "\n";
exit(-1);
}
$ret = $user->fetch('', 'admin');
if (!$ret > 0) {
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
exit;
}
$sql = "SELECT * FROM `$table` WHERE 1";
$resql = $db->query($sql);
if ($resql)
while ($fields = $db->fetch_array($resql)) {
$errorrecord = 0;
if ($fields === false)
continue;
$nboflines++;
$produit = new Product($db);
$produit->type = 0;
$produit->status = 1;
$produit->ref = trim($fields['REF']);
if ($produit->ref == '')
continue;
print "Process line nb " . $j . ", ref " . $produit->ref;
$produit->label = trim($fields['LIBELLE']);
if ($produit->label == '')
$produit->label = $produit->ref;
if (empty($produit->label))
continue;
//$produit->description = trim($fields[4] . "\n" . ($fields[5] ? $fields[5] . ' x ' . $fields[6] . ' x ' . $fields[7] : ''));
// $produit->volume = price2num($fields[8]);
// $produit->volume_unit = 0;
$produit->weight = price2num($fields['MASSE']);
$produit->weight_units = 0; // -3 = g
//$produit->customcode = $fields[10];
$produit->barcode = str_pad($fields['CODE'], 12, "0", STR_PAD_LEFT);
$produit->barcode_type = '2';
$produit->import_key = $fields['CODE'];
$produit->status = 1;
$produit->status_buy = 1;
$produit->finished = 1;
// $produit->multiprices[0] = price2num($fields['TARIF0']);
// $produit->multiprices[1] = price2num($fields['TARIF1']);
// $produit->multiprices[2] = price2num($fields['TARIF2']);
// $produit->multiprices[3] = price2num($fields['TARIF3']);
// $produit->multiprices[4] = price2num($fields['TARIF4']);
// $produit->multiprices[5] = price2num($fields['TARIF5']);
// $produit->multiprices[6] = price2num($fields['TARIF6']);
// $produit->multiprices[7] = price2num($fields['TARIF7']);
// $produit->multiprices[8] = price2num($fields['TARIF8']);
// $produit->multiprices[9] = price2num($fields['TARIF9']);
// $produit->price_min = null;
// $produit->price_min_ttc = null;
// $produit->price = price2num($fields[11]);
// $produit->price_ttc = price2num($fields[12]);
// $produit->price_base_type = 'TTC';
// $produit->tva_tx = price2num($fields[13]);
$produit->tva_tx = (int) ($tvas[$fields['CODTVA']]);
$produit->tva_npr = 0;
// $produit->cost_price = price2num($fields[16]);
//compta
$produit->accountancy_code_buy = trim($fields['COMACH']);
$produit->accountancy_code_sell = trim($fields['COMVEN']);
// $produit->accountancy_code_sell_intra=trim($fields['COMVEN']);
// $produit->accountancy_code_sell_export=trim($fields['COMVEN']);
// Extrafields
// $produit->array_options['options_ecotaxdeee'] = price2num($fields[17]);
$produit->seuil_stock_alerte = $fields['STALERTE'];
$ret = $produit->create($user, 0);
if ($ret < 0) {
print " - Error in create result code = " . $ret . " - " . $produit->errorsToString();
$errorrecord++;
} else {
print " - Creation OK with ref " . $produit->ref . " - id = " . $ret;
}
dol_syslog("Add prices");
// If we use price level, insert price for each level
if (!$errorrecord && 1) {
//$ret1 = $produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
$ret1 = false;
for ($i = 0; $i < 10; $i++) {
if ($fields['TARIF' . ($i)] == 0)
continue;
$ret1 = $ret1 || $produit->updatePrice(price2num($fields['TARIF' . ($i)]), 'HT', $user, $produit->tva_tx, $produit->price_min, $i + 1, $produit->tva_npr, 0, 0, array()) < 0;
}
if ($ret1) {
print " - Error in updatePrice result " . $produit->errorsToString();
$errorrecord++;
} else {
print " - updatePrice OK";
}
}
// dol_syslog("Add multilangs");
// Add alternative languages
// if (!$errorrecord && 1) {
// $produit->multilangs['fr_FR'] = array('label' => $produit->label, 'description' => $produit->description, 'note' => $produit->note_private);
// $produit->multilangs['en_US'] = array('label' => $fields[3], 'description' => $produit->description, 'note' => $produit->note_private);
//
// $ret = $produit->setMultiLangs($user);
// if ($ret < 0) {
// print " - Error in setMultiLangs result code = " . $ret . " - " . $produit->errorsToString();
// $errorrecord++;
// } else {
// print " - setMultiLangs OK";
// }
// }
dol_syslog("Add stocks");
// stocks
if (!$errorrecord && $fields['STOCK'] != 0) {
$rets = $produit->correct_stock($user, 1, $fields['STOCK'], 0, 'Stock importé');
if ($rets < 0) {
print " - Error in correct_stock result " . $produit->errorsToString();
$errorrecord++;
} else {
print " - correct_stock OK";
}
}
//update date créa
if (!$errorrecord) {
$date = substr($fields['DATCREA'], 0, 4) . '-' . substr($fields['DATCREA'], 4, 2) . '-' . substr($fields['DATCREA'], 6, 2);
$retd = $db->query("UPDATE `llx_product` SET `datec` = '$date 00:00:00' WHERE `llx_product`.`rowid` = $produit->id");
if ($retd < 1) {
print " - Error in update date créa result " . $produit->errorsToString();
$errorrecord++;
} else {
print " - update date créa OK";
}
}
print "\n";
if ($errorrecord) {
print( 'Error on record nb ' . $i . " - " . $produit->errorsToString() . "\n");
var_dump($db);
die();
$error++; // $errorrecord will be reset
}
$j++;
} else
die("error : $sql");
// commit or rollback
print "Nb of lines qualified: " . $nboflines . "\n";
print "Nb of errors: " . $error . "\n";
$db->close();
exit($error);

View File

@ -0,0 +1,355 @@
#!/usr/bin/env php
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* WARNING, THIS WILL LOAD MASS DATA ON YOUR INSTANCE
*/
/**
* \file dev/initdata/import-product.php
* \brief Script example to insert products from a csv file.
* To purge data, you can have a look at purge-data.php
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = dirname(__FILE__) . '/';
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Recupere root dolibarr
$path = preg_replace('/importdb-thirdparties.php/i', '', $_SERVER["PHP_SELF"]);
require $path . "../../htdocs/master.inc.php";
require $path . "includes/dbase.class.php";
include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
//$delimiter = ',';
//$enclosure = '"';
//$linelength = 10000;
//$escape = '/';
// Global variables
$version = DOL_VERSION;
$confirmed = 1;
$error = 0;
$civilPrivate = array("MLLE",
"MM",
"MM/MADAME",
"MME",
"MME.",
"MME²",
"MMONSIEUR",
"MMR",
"MOBNSIEUR",
"MOMSIEUR",
"MON SIEUR",
"MONDIAL",
"MONIEUR",
"MONJSIEUR",
"MONNSIEUR",
"MONRIEUR",
"MONS",
"MONSIEÕR",
"MONSIER",
"MONSIERU",
"MONSIEU",
"monsieue",
"MONSIEUR",
"Monsieur     \"",
"MONSIEUR    \"",
"MONSIEUR   E",
"MONSIEUR  DENIS",
"MONSIEUR ET MME",
"MONSIEUR!",
"MONSIEUR.",
"MONSIEUR.MADAME",
"MONSIEUR3",
"MONSIEURN",
"MONSIEURT",
"MONSIEUR£",
"MONSIEYR",
"Monsigur",
"MONSIIEUR",
"MONSIUER",
"MONSIZEUR",
"MOPNSIEUR",
"MOSIEUR",
"MR",
"Mr  Mme",
"Mr - MME",
"MR BLANC",
"MR ET MME",
"mr mm",
"MR OU MME",
"Mr.",
"MR/MME",
"MRME",
"MRR",
"Mrs",
"Mademoiselle",
"MADAOME",
"madamme",
"MADAME",
"M0NSIEUR",
"M.et Madame",
"M. ET MR",
"M.",
"M%",
"M MME",
"M ET MME",
"M",
"M CROCE",
"M DIEVART",
);
/*
* Main
*/
@set_time_limit(0);
print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n";
dol_syslog($script_file . " launched with arg " . implode(',', $argv));
$table = $argv[1];
if (empty($argv[1])) {
print "Error: Quelle table ?\n";
print "\n";
exit(-1);
}
$ret = $user->fetch('', 'admin');
if (!$ret > 0) {
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
exit;
}
$sql = "SELECT * FROM `$table` WHERE 1 "; //ORDER BY REMISE DESC,`LCIVIL` DESC";
$resql = $db->query($sql);
//$db->begin();
if ($resql)
while ($fields = $db->fetch_array($resql)) {
$i++;
$errorrecord = 0;
if ($startlinenb && $i < $startlinenb)
continue;
if ($endlinenb && $i > $endlinenb)
continue;
$nboflines++;
$object = new Societe($db);
$object->import_key = $fields['CODE'];
$object->state = 1;
$object->client = 3;
$object->fournisseur = 0;
$object->name = $fields['FCIVIL'] . ' ' . $fields['FNOM'];
//$object->name_alias = $fields[0] != $fields[13] ? trim($fields[0]) : '';
$date = $fields['DATCREA'] ? $fields['DATCREA'] : ($fields['DATMOD'] ? $fields['DATMOD'] : '20200101');
$object->code_client = 'CU' . substr($date, 2, 2) . substr($date, 4, 2) . '-' . str_pad(substr($fields['CODE'], 0, 5), 5, "0", STR_PAD_LEFT);
$object->address = trim($fields['FADR1']);
if ($fields['FADR2'])
$object->address .= "\n" . trim($fields['FADR2']);
if ($fields['FADR3'])
$object->address .= "\n" . trim($fields['FADR3']);
$object->zip = trim($fields['FPOSTE']);
$object->town = trim($fields['FVILLE']);
if ($fields['FPAYS'])
$object->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['FPAYS']))), 'c_country', 'label', 'rowid');
else
$object->country_id = 1;
$object->phone = trim($fields['FTEL']) ? trim($fields['FTEL']) : trim($fields['FCONTACT']);
$object->phone = substr($object->phone, 0, 20);
$object->fax = trim($fields['FFAX']) ? trim($fields['FFAX']) : trim($fields['FCONTACT']);
$object->fax = substr($object->fax, 0, 20);
$object->email = trim($fields['FMAIL']);
// $object->idprof2 = trim($fields[29]);
$object->tva_intra = str_replace(['.', ' '], '', $fields['TVAINTRA']);
$object->tva_intra = substr($object->tva_intra, 0, 20);
$object->default_lang = 'fr_FR';
$object->cond_reglement_id = dol_getIdFromCode($db, 'PT_ORDER', 'c_payment_term', 'code', 'rowid', 1);
$object->multicurrency_code = 'EUR';
if ($fields['REMISE'] != '0.00') {
$object->remise_percent = abs($fields['REMISE']);
}
// $object->code_client = $fields[9];
// $object->code_fournisseur = $fields[10];
if ($fields['FCIVIL']) {
$labeltype = in_array($fields['FCIVIL'], $civilPrivate) ? 'TE_PRIVATE' : 'TE_SMALL';
$object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'code');
}
// Set price level
$object->price_level = $fields['TARIF'] + 1;
// if ($labeltype == 'Revendeur')
// $object->price_level = 2;
print "Process line nb " . $i . ", code " . $fields['CODE'] . ", name " . $object->name;
// Extrafields
$object->array_options['options_banque'] = $fields['BANQUE'];
$object->array_options['options_banque2'] = $fields['BANQUE2'];
$object->array_options['options_banquevalid'] = $fields['VALID'];
if (!$errorrecord) {
$ret = $object->create($user);
if ($ret < 0) {
print " - Error in create result code = " . $ret . " - " . $object->errorsToString();
$errorrecord++;
var_dump($object->code_client, $db);
die();
} else {
print " - Creation OK with name " . $object->name . " - id = " . $ret;
}
}
if (!$errorrecord) {
dol_syslog("Set price level");
$object->set_price_level($object->price_level, $user);
}
if (!$errorrecord && @$object->remise_percent) {
dol_syslog("Set remise client");
$object->set_remise_client($object->remise_percent, 'Importé', $user);
}
dol_syslog("Add contact");
// Insert an invoice contact if there is an invoice email != standard email
if (!$errorrecord && ($fields['LCIVIL'] || $fields['LNOM'])) {
$madame = array("MADAME",
"MADEMOISELLE",
"MELLE",
"MLLE",
"MM",
"Mme",
"MNE",
);
$monsieur = array("M",
"M ET MME",
"M MME",
"M.",
"M. MME",
"M. OU Mme",
"M.ou Madame",
"MONSEUR",
"MONSIER",
"MONSIEU",
"MONSIEUR",
"monsieur:mme",
"MONSIEUR¨",
"MONSIEZUR",
"MONSIUER",
"MONSKIEUR",
"MR",
);
$ret1 = $ret2 = 0;
$contact = new Contact($db);
if (in_array($fields['LCIVIL'], $madame)) {
// une dame
$contact->civility_id = 'MME';
$contact->lastname = $fields['LNOM'];
} elseif (in_array($fields['LCIVIL'], $monsieur)) {
// un monsieur
$contact->civility_id = 'MR';
$contact->lastname = $fields['LNOM'];
} elseif (in_array($fields['LCIVIL'], ['DOCTEUR'])) {
// un monsieur
$contact->civility_id = 'DR';
$contact->lastname = $fields['LNOM'];
} else {
// un a rattraper
$contact->lastname = $fields['LCIVIL'] . " " . $fields['LNOM'];
}
$contact->address = trim($fields['LADR1']);
if ($fields['LADR2'])
$contact->address .= "\n" . trim($fields['LADR2']);
if ($fields['LADR3'])
$contact->address .= "\n" . trim($fields['LADR3']);
$contact->zip = trim($fields['LPOSTE']);
$contact->town = trim($fields['LVILLE']);
if ($fields['FPAYS'])
$contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid');
else
$contact->country_id = 1;
$contact->email = $fields['LMAIL'];
$contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']);
$contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']);
$contact->socid = $object->id;
$ret1 = $contact->create($user);
if ($ret1 > 0) {
//$ret2=$contact->add_contact($object->id, 'BILLING');
}
if ($ret1 < 0 || $ret2 < 0) {
print " - Error in create contact result code = " . $ret1 . " " . $ret2 . " - " . $contact->errorsToString();
$errorrecord++;
} else {
print " - create contact OK";
}
}
//update date créa
if (!$errorrecord) {
$datec = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2);
$retd = $db->query("UPDATE `llx_societe` SET `datec` = '$datec 00:00:00' WHERE `rowid` = $object->id");
if ($retd < 1) {
print " - Error in update date créa result " . $object->errorsToString();
$errorrecord++;
} else {
print " - update date créa OK";
}
}
print "\n";
if ($errorrecord) {
print( 'Error on record nb ' . $i . " - " . $object->errorsToString() . "\n");
var_dump($db, $object, $contact);
// $db->rollback();
die();
$error++; // $errorrecord will be reset
}
$j++;
} else
die("error : $sql");
$db->commit();
// commit or rollback
print "Nb of lines qualified: " . $nboflines . "\n";
print "Nb of errors: " . $error . "\n";
$db->close();
exit($error);

View File

@ -0,0 +1,402 @@
<?php
/**
* \file dev/initdata/dbf/includes/dbase.class.php
* \ingroup dev
* \brief Class to manage DBF databases
*/
// source : https://github.com/donfbecker/php-dbase
define('DBASE_RDONLY', 0);
define('DBASE_WRONLY', 1);
define('DBASE_RDWR', 2);
define('DBASE_TYPE_DBASE', 0);
define('DBASE_TYPE_FOXPRO', 1);
/**
* Class for DBase
*/
class DBase
{
private $fd;
private $headerLength = 0;
private $fields = array();
private $fieldCount = 0;
private $recordLength = 0;
private $recordCount = 0;
//resource dbase_open ( string $filename , int $mode )
public static function open($filename, $mode)
{
if (!file_exists($filename))
return false;
$modes = array('r', 'w', 'r+');
$mode = $modes[$mode];
$fd = fopen($filename, $mode);
if (!$fd)
return false;
return new DBase($fd);
}
//resource dbase_create ( string $filename , array $fields [, int $type = DBASE_TYPE_DBASE ] )
public static function create($filename, $fields, $type = DBASE_TYPE_DBASE)
{
if (file_exists($filename))
return false;
$fd = fopen($filename, 'c+');
if (!$fd)
return false;
// Byte 0 (1 byte): Valid dBASE for DOS file; bits 0-2 indicate version number, bit 3
// indicates the presence of a dBASE for DOS memo file, bits 4-6 indicate the
// presence of a SQL table, bit 7 indicates the presence of any memo file
// (either dBASE m PLUS or dBASE for DOS)
self::putChar8($fd, 5);
// Byte 1-3 (3 bytes): Date of last update; formatted as YYMMDD
self::putChar8($fd, date('Y') - 1900);
self::putChar8($fd, date('m'));
self::putChar8($fd, date('d'));
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
self::putInt32($fd, 0);
// Byte 8-9 (16-bit number): Number of bytes in the header.
self::putInt16($fd, 32 + (32 * count($fields)) + 1);
// Byte 10-11 (16-bit number): Number of bytes in record.
// Make sure the include the byte for deleted flag
$len = 1;
foreach ($fields as &$field)
$len += self::length($field);
self::putInt16($fd, $len);
// Byte 12-13 (2 bytes): Reserved, 0 filled.
self::putInt16($fd, 0);
// Byte 14 (1 byte): Flag indicating incomplete transaction
// The ISMARKEDO function checks this flag. BEGIN TRANSACTION sets it to 1, END TRANSACTION and ROLLBACK reset it to 0.
self::putChar8($fd, 0);
// Byte 15 (1 byte): Encryption flag. If this flag is set to 1, the message Database encrypted appears. Changing this flag to 0 removes the message, but does not decrypt the file.
self::putChar8($fd, 0);
// Byte 16-27 (12 bytes): Reserved for dBASE for DOS in a multi-user environment
self::putInt32($fd, 0);
self::putInt32($fd, 0);
self::putInt32($fd, 0);
// Byte 28 (1 byte): Production .mdx file flag; 0x01 if there is a production .mdx file, 0x00 if not
self::putChar8($fd, 0);
// Byte 29 (1 byte): Language driver ID
// (no clue what this is)
self::putChar8($fd, 0);
// Byte 30-31 (2 bytes): Reserved, 0 filled.
self::putInt16($fd, 0);
// Byte 32 - n (32 bytes each): Field descriptor array
foreach ($fields as &$field) {
self::putString($fd, $field[0], 11); // Byte 0 - 10 (11 bytes): Field name in ASCII (zero-filled)
self::putString($fd, $field[1], 1); // Byte 11 (1 byte): Field type in ASCII (C, D, F, L, M, or N)
self::putInt32($fd, 0); // Byte 12 - 15 (4 bytes): Reserved
self::putChar8($fd, self::length($field)); // Byte 16 (1 byte): Field length in binary. The maximum length of a field is 254 (0xFE).
self::putChar8($fd, $field[3]); // Byte 17 (1 byte): Field decimal count in binary
self::putInt16($fd, 0); // Byte 18 - 19 (2 bytes): Work area ID
self::putChar8($fd, 0); // Byte 20 (1 byte): Example (??)
self::putInt32($fd, 0); // Byte 21 - 30 (10 bytes): Reserved
self::putInt32($fd, 0);
self::putInt16($fd, 0);
self::putChar8($fd, 0); // Byte 31 (1 byte): Production MDX field flag; 1 if field has an index tag in the production MDX file, 0 if not
}
// Byte n + 1 (1 byte): 0x0D as the field descriptor array terminator
self::putChar8($fd, 0x0D);
return new DBase($fd);
}
// Create DBase instance
private function __construct($fd)
{
$this->fd = $fd;
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
fseek($this->fd, 4, SEEK_SET);
$this->recordCount = self::getInt32($fd);
// Byte 8-9 (16-bit number): Number of bytes in the header.
fseek($this->fd, 8, SEEK_SET);
$this->headerLength = self::getInt16($fd);
// Number of fields is (headerLength - 33) / 32)
$this->fieldCount = ($this->headerLength - 33) / 32;
// Byte 10-11 (16-bit number): Number of bytes in record.
fseek($this->fd, 10, SEEK_SET);
$this->recordLength = self::getInt16($fd);
// Byte 32 - n (32 bytes each): Field descriptor array
fseek($fd, 32, SEEK_SET);
for ($i = 0; $i < $this->fieldCount; $i++) {
$data = fread($this->fd, 32);
$field = array_map('trim', unpack('a11name/a1type/c4/c1length/c1precision/s1workid/c1example/c10/c1production', $data));
$this->fields[] = $field;
}
}
//bool dbase_close ( resource $dbase_identifier )
public function close()
{
fclose($this->fd);
}
//array dbase_get_header_info ( resource $dbase_identifier )
public function get_header_info()
{
return $this->fields;
}
//int dbase_numfields ( resource $dbase_identifier )
public function numfields()
{
return $this->fieldCount;
}
//int dbase_numrecords ( resource $dbase_identifier )
public function numrecords()
{
return $this->recordCount;
}
//bool dbase_add_record ( resource $dbase_identifier , array $record )
public function add_record($record)
{
if (count($record) != $this->fieldCount)
return false;
// Seek to end of file, minus the end of file marker
fseek($this->fd, 0, SEEK_END);
// Put the deleted flag
self::putChar8($this->fd, 0x20);
// Put the record
if (!$this->putRecord($record))
return false;
// Update the record count
fseek($this->fd, 4);
self::putInt32($this->fd, ++$this->recordCount);
return true;
}
//bool dbase_replace_record ( resource $dbase_identifier , array $record , int $record_number )
public function replace_record($record, $record_number)
{
if (count($record) != $this->fieldCount)
return false;
if ($record_number < 1 || $record_number > $this->recordCount)
return false;
// Skip to the record location, plus the 1 byte for the deleted flag
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)) + 1);
return $this->putRecord($record);
}
//bool dbase_delete_record ( resource $dbase_identifier , int $record_number )
public function delete_record($record_number)
{
if ($record_number < 1 || $record_number > $this->recordCount)
return false;
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
self::putChar8($this->fd, 0x2A);
return true;
}
//array dbase_get_record ( resource $dbase_identifier , int $record_number )
public function get_record($record_number)
{
if ($record_number < 1 || $record_number > $this->recordCount)
return false;
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
$record = array(
'deleted' => self::getChar8($this->fd) == 0x2A ? 1 : 0
);
foreach ($this->fields as $i => &$field) {
$value = trim(fread($this->fd, $field['length']));
if ($field['type'] == 'L') {
$value = strtolower($value);
if ($value == 't' || $value == 'y')
$value = true;
elseif ($value == 'f' || $value == 'n')
$value = false;
else
$value = null;
}
$record[$i] = $value;
}
return $record;
}
//array dbase_get_record_with_names ( resource $dbase_identifier , int $record_number )
public function get_record_with_names($record_number)
{
if ($record_number < 1 || $record_number > $this->recordCount)
return false;
$record = $this->get_record($record_number);
foreach ($this->fields as $i => &$field) {
$record[$field['name']] = $record[$i];
unset($record[$i]);
}
return $record;
}
//bool dbase_pack ( resource $dbase_identifier )
public function pack()
{
$in_offset = $out_offset = $this->headerLength;
$new_count = 0;
$rec_count = $this->recordCount;
while ($rec_count > 0) {
fseek($this->fd, $in_offset, SEEK_SET);
$record = fread($this->fd, $this->recordLength);
$deleted = substr($record, 0, 1);
if ($deleted != '*') {
fseek($this->fd, $out_offset, SEEK_SET);
fwrite($this->fd, $record);
$out_offset += $this->recordLength;
$new_count++;
}
$in_offset += $this->recordLength;
$rec_count--;
}
ftruncate($this->fd, $out_offset);
// Update the record count
fseek($this->fd, 4);
self::putInt32($this->fd, $new_count);
}
/*
* A few utilitiy functions
*/
private static function length($field)
{
switch ($field[1]) {
case 'D': // Date: Numbers and a character to separate month, day, and year (stored internally as 8 digits in YYYYMMDD format)
return 8;
case 'T': // DateTime (YYYYMMDDhhmmss.uuu) (FoxPro)
return 18;
case 'M': // Memo (ignored): All ASCII characters (stored internally as 10 digits representing a .dbt block number, right justified, padded with whitespaces)
case 'N': // Number: -.0123456789 (right justified, padded with whitespaces)
case 'F': // Float: -.0123456789 (right justified, padded with whitespaces)
case 'C': // String: All ASCII characters (padded with whitespaces up to the field's length)
return $field[2];
case 'L': // Boolean: YyNnTtFf? (? when not initialized)
return 1;
}
return 0;
}
/*
* Functions for reading and writing bytes
*/
private static function getChar8($fd)
{
return ord(fread($fd, 1));
}
private static function putChar8($fd, $value)
{
return fwrite($fd, chr($value));
}
private static function getInt16($fd, $n = 1)
{
$data = fread($fd, 2 * $n);
$i = unpack("S$n", $data);
if ($n == 1)
return (int) $i[1];
else
return array_merge($i);
}
private static function putInt16($fd, $value)
{
return fwrite($fd, pack('S', $value));
}
private static function getInt32($fd, $n = 1)
{
$data = fread($fd, 4 * $n);
$i = unpack("L$n", $data);
if ($n == 1)
return (int) $i[1];
else
return array_merge($i);
}
private static function putInt32($fd, $value)
{
return fwrite($fd, pack('L', $value));
}
private static function putString($fd, $value, $length = 254)
{
$ret = fwrite($fd, pack('A' . $length, $value));
}
private function putRecord($record)
{
foreach ($this->fields as $i => &$field) {
$value = $record[$i];
// Number types are right aligned with spaces
if ($field['type'] == 'N' || $field['type'] == 'F' && strlen($value) < $field['length']) {
$value = str_repeat(' ', $field['length'] - strlen($value)) . $value;
}
self::putString($this->fd, $value, $field['length']);
}
return true;
}
}
if (!function_exists('dbase_open')) {
function dbase_open($filename, $mode)
{
return DBase::open($filename, $mode);
}
function dbase_create($filename, $fields, $type = DBASE_TYPE_DBASE)
{
return DBase::create($filename, $fields, $type);
}
function dbase_close($dbase_identifier)
{
return $dbase_identifier->close();
}
function dbase_get_header_info($dbase_identifier)
{
return $dbase_identifier->get_header_info();
}
function dbase_numfields($dbase_identifier)
{
$dbase_identifier->numfields();
}
function dbase_numrecords($dbase_identifier)
{
return $dbase_identifier->numrecords();
}
function dbase_add_record($dbase_identifier, $record)
{
return $dbase_identifier->add_record($record);
}
function dbase_delete_record($dbase_identifier, $record_number)
{
return $dbase_identifier->delete_record($record_number);
}
function dbase_replace_record($dbase_identifier, $record, $record_number)
{
return $dbase_identifier->replace_record($record, $record_number);
}
function dbase_get_record($dbase_identifier, $record_number)
{
return $dbase_identifier->get_record($record_number);
}
function dbase_get_record_with_names($dbase_identifier, $record_number)
{
return $dbase_identifier->get_record_with_names($record_number);
}
function dbase_pack($dbase_identifier)
{
return $dbase_identifier->pack();
}
}

View File

@ -23,10 +23,14 @@
* \brief Script example to inject random customer invoices (for load tests)
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
// Test si mode batch
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -24,10 +24,14 @@
* \brief Script example to inject random orders (for load tests)
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
// Test si mode batch
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -24,10 +24,14 @@
* \brief Script example to inject random products (for load tests)
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
// Test si mode batch
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -24,10 +24,14 @@
* \brief Script example to inject random proposals (for load tests)
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
// Test si mode batch
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -24,10 +24,14 @@
* \brief Script example to inject random thirdparties (for load tests)
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
// Test si mode batch
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -30,7 +30,7 @@ $sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -30,7 +30,7 @@ $sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -20,7 +20,7 @@
*/
/**
* \file dev/initdata/import-thirdparties.php
* \file dev/initdata/import-users.php
* \brief Script example to insert thirdparties from a csv file.
* To purge data, you can have a look at purge-data.php
*/
@ -30,7 +30,7 @@ $sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -1,13 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT ruleset (description,exclude-pattern*,rule+)>
<!ELEMENT ruleset (description,arg*,exclude-pattern*,rule+)>
<!ATTLIST ruleset name CDATA "">
<!ELEMENT description (#PCDATA)>
<!ELEMENT arg (#PCDATA)>
<!ATTLIST arg name CDATA "">
<!ATTLIST arg value CDATA "">
<!ELEMENT exclude-pattern (#PCDATA)>
<!ATTLIST exclude-pattern type CDATA "">
<!ELEMENT rule (properties*,severity*)>
<!ELEMENT rule (properties*,severity*,exclude*)>
<!ATTLIST rule ref CDATA "">
<!ELEMENT properties (property+)>
<!ELEMENT property (#PCDATA)>
<!ATTLIST property name CDATA "">
<!ATTLIST property value CDATA "">
<!ELEMENT severity (#PCDATA)>
<!ELEMENT exclude (#PCDATA)>
<!ATTLIST exclude name CDATA "">

View File

@ -2,10 +2,12 @@
<!DOCTYPE ruleset SYSTEM "ruleset.dtd">
<ruleset name="Dolibarr">
<description>Dolibarr coding standard.</description>
<arg name="tab-width" value="4"/>
<exclude-pattern type="relative">build/html</exclude-pattern>
<exclude-pattern type="relative">build/aps</exclude-pattern>
<exclude-pattern type="relative">dev/namespacemig</exclude-pattern>
<exclude-pattern type="relative">dev/initdata/dbf/includes</exclude-pattern>
<exclude-pattern type="relative">documents</exclude-pattern>
<exclude-pattern type="relative">htdocs/core/class/lessc.class.php</exclude-pattern>
<exclude-pattern type="relative">htdocs/custom</exclude-pattern>
@ -187,7 +189,6 @@
<!-- Disabled as this does not support tab -->
<!-- <rule ref="Generic.WhiteSpace.ScopeIndent" /> -->
<arg name="tab-width" value="4"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>

View File

@ -0,0 +1,578 @@
#!/usr/bin/env php
<?php
/*
* Copyright (C) 2005-2011 James Grant <james@lightbox.org> Lightbox Technologies Inc.
* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This file is base on pg2mysql provided as Open source by lightbox.org.
* It was enhanced and updated by the Dolibarr team.
*/
/**
* \file dev/tools/dolibarr-postgres2mysql.php
* \brief Script to migrate a postgresql dump into a mysql dump
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = dirname(__FILE__) . '/';
// Test si mode batch
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n";
exit();
}
error_reporting(E_ALL & ~ E_DEPRECATED);
define('PRODUCT', "pg2mysql");
define('VERSION', "2.0");
// this is the default, it can be overridden here, or specified as the third parameter on the command line
$config['engine'] = "InnoDB";
if (! ($argv[1] && $argv[2])) {
echo "Usage: php pg2mysql_cli.php <inputfilename> <outputfilename> [engine]\n";
exit();
} else {
if (isset($argv[3]))
$config['engine'] = $argv[3];
pg2mysql_large($argv[1], $argv[2]);
echo <<<XHTML
Notes:
- No its not perfect
- Yes it discards ALL stored procedures
- Yes it discards ALL queries except for CREATE TABLE and INSERT INTO
- If you're having problems creating your postgres dump, make sure you use "--format p --inserts"
- Default output engine if not specified is InnoDB
XHTML;
}
/**
* getfieldname
*
* @param string $l String
* @return string|null Field name
*/
function getfieldname($l)
{
// first check if its in nice quotes for us
$regs = array();
if (preg_match("/`(.*)`/", $l, $regs)) {
if ($regs[1])
return $regs[1];
else
return null;
} // if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space.
elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) {
if ($regs[1])
return $regs[1];
else
return null;
}
}
/**
* formatsize
*
* @param string $s Size to format
* @return string Formated size
*/
function formatsize($s)
{
if ($s < pow(2, 14))
return "{$s}B";
elseif ($s < pow(2, 20))
return sprintf("%.1f", round($s / 1024, 1)) . "K";
elseif ($s < pow(2, 30))
return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M";
else
return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G";
}
/**
* pg2mysql_large
*
* @param string $infilename Input filename
* @param string $outfilename Output filename
* @return int <0 if KO, >=0 if OK
*/
function pg2mysql_large($infilename, $outfilename)
{
$infp = fopen($infilename, "rt");
$outfp = fopen($outfilename, "wt");
$outputatend = '';
$arrayofprimaryalreadyintabledef = array();
// we read until we get a semicolon followed by a newline (;\n);
$pgsqlchunk = array();
$chunkcount = 1;
$linenum = 0;
$inquotes = false;
$first = true;
if (empty($infp)) {
print 'Failed to open file '.$infilename."\n";
return -1;
}
$fs = filesize($infilename);
echo "Filesize: " . formatsize($fs) . "\n";
while ($instr = fgets($infp)) {
$linenum ++;
$memusage = round(memory_get_usage(true) / 1024 / 1024);
$len = strlen($instr);
$pgsqlchunk[] = $instr;
$c = substr_count($instr, "'");
// we have an odd number of ' marks
if ($c % 2 != 0) {
if ($inquotes)
$inquotes = false;
else
$inquotes = true;
}
if ($linenum % 10000 == 0) {
$currentpos = ftell($infp);
$percent = round($currentpos / $fs * 100);
$position = formatsize($currentpos);
printf("Reading progress: %3d%% position: %7s line: %9d sql chunk: %9d mem usage: %4dM\r", $percent, $position, $linenum, $chunkcount, $memusage);
}
if (strlen($instr) > 3 && ($instr[$len - 3] == ")" && $instr[$len - 2] == ";" && $instr[$len - 1] == "\n") && $inquotes == false) {
$chunkcount ++;
if ($linenum % 10000 == 0) {
$currentpos = ftell($infp);
$percent = round($currentpos / $fs * 100);
$position = formatsize($currentpos);
printf("Processing progress: %3d%% position: %7s line: %9d sql chunk: %9d mem usage: %4dM\r", $percent, $position, $linenum, $chunkcount, $memusage);
}
/*
* echo "sending chunk:\n";
* echo "=======================\n";
* print_r($pgsqlchunk);
* echo "=======================\n";
*/
/*
* foreach ($pgsqlchunk as $aaa) {
* if (preg_match('/MAIN_ENABLE_DEFAULT|MAIN_MAIL_SMTP_SE/', $aaa)) {
* var_dump($pgsqlchunk);
* }
* }
*/
$mysqlchunk = pg2mysql($pgsqlchunk, $arrayofprimaryalreadyintabledef, $first);
fputs($outfp, $mysqlchunk['output']);
/*
* $break = false;
* foreach ($pgsqlchunk as $aaa) {
* if (preg_match('/MAIN_ENABLE_DEFAULT|MAIN_MAIL_SMTP_SE/', $aaa)) {
* var_dump($mysqlchunk);
* }
* if (preg_match('/MAIN_MAIL_SMTP_SE/', $aaa)) {
* $break = true;
* }
* }
* if ($break) break;
*/
$outputatend .= $mysqlchunk['outputatend'];
$first = false;
$pgsqlchunk = array();
$mysqlchunk = "";
}
}
echo "\n\n";
fputs($outfp, $outputatend);
fputs($outfp, "\n");
fputs($outfp, '/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;' . "\n");
fputs($outfp, '/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;' . "\n");
fputs($outfp, '/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;' . "\n");
fputs($outfp, '/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;' . "\n");
fputs($outfp, '/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;' . "\n");
fputs($outfp, '/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;' . "\n");
fputs($outfp, '/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;' . "\n");
printf("Completed! %9d lines %9d sql chunks\n\n", $linenum, $chunkcount);
fclose($infp);
fclose($outfp);
return 0;
}
/**
* pg2mysql
*
* @param array $input Array of input
* @param array $arrayofprimaryalreadyintabledef Array of table already output with a primary key set into definition
* @param boolean $header Boolean
* @return string[] Array of output
*/
function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
{
global $config;
if (is_array($input)) {
$lines = $input;
} else {
$lines = split("\n", $input);
}
if ($header) {
$output = "-- Converted with " . PRODUCT . "-" . VERSION . "\n";
$output .= "-- Converted on " . date("r") . "\n";
$output .= "\n";
$output .= "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n";
$output .= "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n";
$output .= "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n";
$output .= "/*!40101 SET NAMES utf8 */;\n";
$output .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n";
$output .= "/*!40103 SET TIME_ZONE='+00:00' */;\n";
$output .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n";
$output .= "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n";
$output .= "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n";
$output .= "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n";
$output .= "\n";
$outputatend = "";
} else {
$output = "";
$outputatend = "";
}
$in_create_table = $in_insert = false;
$linenumber = 0;
$tbl_extra = "";
while (isset($lines[$linenumber])) {
$line = $lines[$linenumber];
// $line =str_replace('ALTER TABLE public\.', '', $line);
$reg = array();
if (preg_match('/CREATE SEQUENCE (?:public\.)(.*)_(id|rowid|id_comment)_seq/', $line, $reg)) {
$outputatend .= '-- Make field ' . $reg[2] . ' auto_increment for table ' . $reg[1] . "\n";
$outputatend .= 'ALTER TABLE ' . $reg[1] . ' CHANGE COLUMN ' . $reg[2] . ' ' . $reg[2] . ' INTEGER NOT NULL AUTO_INCREMENT;' . "\n\n";
// var_dump($outputatend);
}
if (substr($line, 0, 12) == "CREATE TABLE") {
$in_create_table = true;
$line = str_replace("\"", "`", $line);
$line = str_replace('public.', '', $line);
$reg2 = array();
if (preg_match('/CREATE TABLE ([^\s]+)/', $line, $reg2)) {
$in_create_table = $reg2[1];
}
$reg2 = array();
if (preg_match('/CREATE TABLE ([^\s]+)/', $line, $reg2)) {
$output .= 'DROP TABLE IF EXISTS `' . $reg2[1] . '`;' . "\n";
}
$output .= $line;
$linenumber ++;
continue;
}
if (substr($line, 0, 2) == ");" && $in_create_table) {
$in_create_table = false;
$line = ") ENGINE={$config['engine']};\n\n";
$output .= $tbl_extra;
$output .= $line;
$linenumber ++;
$tbl_extra = "";
continue;
}
if ($in_create_table) {
$regs = array();
$line = str_replace("\"", "`", $line);
$line = str_replace(" integer", " int(11)", $line);
$line = str_replace(" int_unsigned", " int(11) UNSIGNED", $line);
$line = str_replace(" smallint_unsigned", " smallint UNSIGNED", $line);
$line = str_replace(" bigint_unsigned", " bigint UNSIGNED", $line);
$line = str_replace(" serial ", " int(11) auto_increment ", $line);
$line = str_replace(" bytea", " BLOB", $line);
$line = str_replace(" boolean", " bool", $line);
$line = str_replace(" bool DEFAULT true", " bool DEFAULT 1", $line);
$line = str_replace(" bool DEFAULT false", " bool DEFAULT 0", $line);
if (preg_match("/ character varying\(([0-9]*)\)/", $line, $regs)) {
$num = $regs[1];
if ($num <= 255)
$line = preg_replace("/ character varying\([0-9]*\)/", " varchar($num)", $line);
else
$line = preg_replace("/ character varying\([0-9]*\)/", " text", $line);
}
// character varying with no size, we will default to varchar(255)
if (preg_match("/ character varying/", $line)) {
$line = preg_replace("/ character varying/", " varchar(255)", $line);
}
if (preg_match("/ DEFAULT \('([0-9]*)'::int/", $line, $regs) || preg_match("/ DEFAULT \('([0-9]*)'::smallint/", $line, $regs) || preg_match("/ DEFAULT \('([0-9]*)'::bigint/", $line, $regs)) {
$num = $regs[1];
$line = preg_replace("/ DEFAULT \('([0-9]*)'[^ ,]*/", " DEFAULT $num ", $line);
}
if (preg_match("/ DEFAULT \(([0-9\-]*)\)/", $line, $regs)) {
$num = $regs[1];
$line = preg_replace("/ DEFAULT \(([0-9\-]*)\)/", " DEFAULT $num ", $line);
}
$line = preg_replace("/ DEFAULT nextval\(.*\) /", " auto_increment ", $line);
$line = preg_replace("/::.*,/", ",", $line);
$line = preg_replace("/::.*$/", "\n", $line);
if (preg_match("/character\(([0-9]*)\)/", $line, $regs)) {
$num = $regs[1];
if ($num <= 255)
$line = preg_replace("/ character\([0-9]*\)/", " varchar($num)", $line);
else
$line = preg_replace("/ character\([0-9]*\)/", " text", $line);
}
// timestamps
$line = str_replace(" timestamp with time zone", " datetime", $line);
$line = str_replace(" timestamp without time zone", " datetime", $line);
// time
$line = str_replace(" time with time zone", " time", $line);
$line = str_replace(" time without time zone", " time", $line);
$line = str_replace(" timestamp DEFAULT now()", " timestamp DEFAULT CURRENT_TIMESTAMP", $line);
$line = str_replace(" timestamp without time zone DEFAULT now()", " timestamp DEFAULT CURRENT_TIMESTAMP", $line);
if (strstr($line, "auto_increment") || preg_match('/ rowid int/', $line) || preg_match('/ id int/', $line)) {
$field = getfieldname($line);
$tbl_extra .= ", PRIMARY KEY(`$field`)\n";
$arrayofprimaryalreadyintabledef[$in_create_table] = $in_create_table;
}
$specialfields = array("repeat","status","type","call");
$field = getfieldname($line);
if (in_array($field, $specialfields)) {
$line = str_replace("$field ", "`$field` ", $line);
}
// text/blob fields are not allowed to have a default, so if we find a text DEFAULT, change it to varchar(255) DEFAULT
if (strstr($line, "text DEFAULT")) {
$line = str_replace(" text DEFAULT ", " varchar(255) DEFAULT ", $line);
}
// just skip a CONSTRAINT line
if (strstr($line, " CONSTRAINT ")) {
$line = "";
// and if the previous output ended with a , remove the ,
$lastchr = substr($output, - 2, 1);
// echo "lastchr=$lastchr";
if ($lastchr == ",") {
$output = substr($output, 0, - 2) . "\n";
}
}
$output .= $line;
}
if (substr($line, 0, 11) == "INSERT INTO") {
$line = str_replace('public.', '', $line);
if (substr($line, - 3, - 1) == ");") {
// we have a complete insert on one line
list ($before, $after) = explode(" VALUES ", $line, 2);
// we only replace the " with ` in what comes BEFORE the VALUES
// (ie, field names, like INSERT INTO table ("bla","bla2") VALUES ('s:4:"test"','bladata2');
// should convert to INSERT INTO table (`bla`,`bla2`) VALUES ('s:4:"test"','bladata2');
$before = str_replace("\"", "`", $before);
// in after, we need to watch out for escape format strings, ie (E'escaped \r in a string'), and ('bla',E'escaped \r in a string'), but could also be (number, E'string'); so we cant search for the previoous '
// ugh i guess its possible these strings could exist IN the data as well, but the only way to solve that is to process these lines one character
// at a time, and thats just stupid, so lets just hope this doesnt appear anywhere in the actual data
$after = str_replace(" (E'", " ('", $after);
$after = str_replace(", E'", ", '", $after);
$output .= $before . " VALUES " . $after;
$linenumber ++;
continue;
} else {
// this insert spans multiple lines, so keep dumping the lines until we reach a line
// that ends with ");"
list ($before, $after) = explode(" VALUES ", $line, 2);
// we only replace the " with ` in what comes BEFORE the VALUES
// (ie, field names, like INSERT INTO table ("bla","bla2") VALUES ('s:4:"test"','bladata2');
// should convert to INSERT INTO table (`bla`,`bla2`) VALUES ('s:4:"test"','bladata2');
$before = str_replace("\"", "`", $before);
// in after, we need to watch out for escape format strings, ie (E'escaped \r in a string'), and ('bla',E'escaped \r in a string')
// ugh i guess its possible these strings could exist IN the data as well, but the only way to solve that is to process these lines one character
// at a time, and thats just stupid, so lets just hope this doesnt appear anywhere in the actual data
$after = str_replace(" (E'", " ('", $after);
$after = str_replace(", E'", ", '", $after);
$c = substr_count($line, "'");
// we have an odd number of ' marks
if ($c % 2 != 0) {
$inquotes = true;
} else {
$inquotes = false;
}
$output .= $before . " VALUES " . $after;
do {
$linenumber ++;
// in after, we need to watch out for escape format strings, ie (E'escaped \r in a string'), and ('bla',E'escaped \r in a string')
// ugh i guess its possible these strings could exist IN the data as well, but the only way to solve that is to process these lines one character
// at a time, and thats just stupid, so lets just hope this doesnt appear anywhere in the actual data
// after the first line, we only need to check for it in the middle, not at the beginning of an insert (becuase the beginning will be on the first line)
// $after=str_replace(" (E'","' ('",$after);
$line = $lines[$linenumber];
$line = str_replace("', E'", "', '", $line);
$output .= $line;
// printf("inquotes: %d linenumber: %4d line: %s\n",$inquotes,$linenumber,$lines[$linenumber]);
$c = substr_count($line, "'");
// we have an odd number of ' marks
if ($c % 2 != 0) {
if ($inquotes)
$inquotes = false;
else
$inquotes = true;
// echo "inquotes=$inquotes\n";
}
} while (substr($lines[$linenumber], - 3, - 1) != ");" || $inquotes);
}
}
if (substr($line, 0, 16) == "ALTER TABLE ONLY") {
$line = preg_replace('/ ONLY/', '', $line);
$line = str_replace("\"", "`", $line);
$line = str_replace("public.", "", $line);
$pkey = $line;
$linenumber ++;
if (! empty($lines[$linenumber])) {
$line = $lines[$linenumber];
} else {
$line = '';
}
if (strstr($line, " PRIMARY KEY ") && substr($line, - 3, - 1) == ");") {
$reg2 = array();
if (preg_match('/ALTER TABLE ([^\s]+)/', $pkey, $reg2)) {
if (empty($arrayofprimaryalreadyintabledef[$reg2[1]])) {
// looks like we have a single line PRIMARY KEY definition, lets go ahead and add it
$output .= str_replace("\n", "", $pkey);
// the postgres and mysql syntax for this is (at least, in the example im looking at)
// identical, so we can just add it as is.
$output .= $line . "\n";
} else {
$output .= '-- ' . str_replace("\n", "", $pkey);
$output .= '-- ' . $line . "\n";
}
} else {
$output .= '-- ' . str_replace("\n", "", $pkey);
$output .= '-- ' . $line . "\n";
}
}
}
// while we're here, we might as well catch CREATE INDEX as well
if (substr($line, 0, 12) == "CREATE INDEX") {
$matches = array();
preg_match('/CREATE INDEX "?([a-zA-Z0-9_]*)"? ON "?([a-zA-Z0-9_\.]*)"? USING btree \((.*)\);/', $line, $matches);
if (! empty($matches[3])) {
$indexname = $matches[1];
$tablename = str_replace('public.', '', $matches[2]);
$columns = $matches[3];
if ($tablename && $columns) {
$output .= "ALTER TABLE `" . $tablename . "` ADD INDEX " . $indexname . "( {$columns} ) ;\n";
}
}
}
if (substr($line, 0, 19) == "CREATE UNIQUE INDEX") {
$matches = array();
preg_match('/CREATE UNIQUE INDEX "?([a-zA-Z0-9_]*)"? ON "?([a-zA-Z0-9_\.]*)"? USING btree \((.*)\);/', $line, $matches);
if (! empty($matches[3])) {
$indexname = $matches[1];
$tablename = str_replace('public.', '', $matches[2]);
$columns = str_replace('"', '', $matches[3]);
if ($tablename && $columns) {
$output .= "ALTER TABLE `" . $tablename . "` ADD UNIQUE INDEX " . $indexname . " ( {$columns} ) ;\n";
}
}
}
if (substr($line, 0, 13) == 'DROP DATABASE')
$output .= $line;
if (substr($line, 0, 15) == 'CREATE DATABASE') {
$matches = array();
preg_match('/CREATE DATABASE ([a-zA-Z0-9_]*) .* ENCODING = \'(.*)\'/', $line, $matches);
$output .= "CREATE DATABASE `$matches[1]` DEFAULT CHARACTER SET $matches[2];\n\n";
}
if (substr($line, 0, 8) == '\\connect') {
$matches = array();
preg_match('/connect ([a-zA-Z0-9_]*)/', $line, $matches);
$output .= "USE `$matches[1]`;\n\n";
}
if (substr($line, 0, 5) == 'COPY ') {
$matches = array();
preg_match('/COPY (.*) FROM stdin/', $line, $matches);
$heads = str_replace('"', "`", $matches[1]);
$values = array();
$in_insert = true;
} elseif ($in_insert) {
if ($line == "\\.\n") {
$in_insert = false;
if ($values) {
$output .= "INSERT INTO $heads VALUES\n" . implode(",\n", $values) . ";\n\n";
}
} else {
$vals = explode(' ', $line);
foreach ($vals as $i => $val) {
$vals[$i] = ($val == '\\N') ? 'NULL' : "'" . str_replace("'", "\\'", trim($val)) . "'";
}
$values[] = '(' . implode(',', $vals) . ')';
if (count($values) >= 1000) {
$output .= "INSERT INTO $heads VALUES\n" . implode(",\n", $values) . ";\n";
$values = array();
}
}
}
$linenumber ++;
}
return array('output' => $output,'outputatend' => $outputatend);
}

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
@ -42,16 +42,17 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'acc
$search_account = GETPOST('search_account', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_labelshort = GETPOST('search_labelshort', 'alpha');
$search_accountparent = GETPOST('search_accountparent', 'alpha');
$search_pcgtype = GETPOST('search_pcgtype', 'alpha');
$search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha');
// Security check
if ($user->socid > 0) accessforbidden();
if (! $user->rights->accounting->chartofaccount) accessforbidden();
if (!$user->rights->accounting->chartofaccount) accessforbidden();
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -65,6 +66,7 @@ if (!$sortorder) $sortorder = "ASC";
$arrayfields = array(
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'),
@ -96,7 +98,8 @@ if (empty($reshook))
{
$search_account = "";
$search_label = "";
$search_accountparent = "";
$search_labelshort = "";
$search_accountparent = "";
$search_pcgtype = "";
$search_pcgsubtype = "";
$search_array_options = array();
@ -192,7 +195,7 @@ if ($action == 'delete') {
$pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, ";
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.active, ";
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
@ -208,7 +211,7 @@ if (strlen(trim($search_account))) {
$search_account_tmp = $search_account;
$weremovedsomezero = 0;
if (strlen($search_account_tmp) <= $lengthpaddingaccount) {
for($i = 0; $i < $lengthpaddingaccount; $i++) {
for ($i = 0; $i < $lengthpaddingaccount; $i++) {
if (preg_match('/0$/', $search_account_tmp)) {
$weremovedsomezero++;
$search_account_tmp = preg_replace('/0$/', '', $search_account_tmp);
@ -235,6 +238,7 @@ if (strlen(trim($search_account))) {
}
}
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort);
if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2);
if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype);
if (strlen(trim($search_pcgsubtype))) $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype);
@ -267,6 +271,7 @@ if ($resql)
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($search_account) $param .= '&search_account='.urlencode($search_account);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort);
if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent);
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
@ -351,6 +356,7 @@ if ($resql)
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="'.$search_account.'"></td>';
if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
if (!empty($arrayfields['aa.labelshort']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_labelshort" value="'.$search_labelshort.'"></td>';
if (!empty($arrayfields['aa.account_parent']['checked'])) {
print '<td class="liste_titre">';
print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2);
@ -368,8 +374,9 @@ if ($resql)
print '<tr class="liste_titre">';
if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']);
if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
@ -408,6 +415,15 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
// Account label to show (label short)
if (!empty($arrayfields['aa.labelshort']['checked']))
{
print "<td>";
print $obj->labelshort;
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Account parent
if (!empty($arrayfields['aa.account_parent']['checked']))
{

View File

@ -39,31 +39,31 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("errors","admin","companies","resource","holiday","compta","accountancy","hrm"));
$langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "compta", "accountancy", "hrm"));
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view';
$confirm=GETPOST('confirm', 'alpha');
$id=31;
$rowid=GETPOST('rowid', 'alpha');
$code=GETPOST('code', 'alpha');
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
$confirm = GETPOST('confirm', 'alpha');
$id = 31;
$rowid = GETPOST('rowid', 'alpha');
$code = GETPOST('code', 'alpha');
$acts[0] = "activate";
$acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$listoffset=GETPOST('listoffset', 'alpha');
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
$listoffset = GETPOST('listoffset', 'alpha');
$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
$active = 1;
$sortfield = GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page ;
$offset = $listlimit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -72,7 +72,7 @@ $search_country_id = GETPOST('search_country_id', 'int');
// Security check
if ($user->socid > 0) accessforbidden();
if (! $user->rights->accounting->chartofaccount) accessforbidden();
if (!$user->rights->accounting->chartofaccount) accessforbidden();
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -82,56 +82,56 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Name of SQL tables of dictionaries
$tabname=array();
$tabname = array();
$tabname[31]= MAIN_DB_PREFIX."accounting_system";
$tabname[31] = MAIN_DB_PREFIX."accounting_system";
// Dictionary labels
$tablib=array();
$tablib[31]= "Pcg_version";
$tablib = array();
$tablib[31] = "Pcg_version";
// Requests to extract data
$tabsql=array();
$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1";
$tabsql = array();
$tabsql[31] = "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1";
// Criteria to sort dictionaries
$tabsqlsort=array();
$tabsqlsort[31]="pcg_version ASC";
$tabsqlsort = array();
$tabsqlsort[31] = "pcg_version ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
$tabfield[31]= "pcg_version,label,country_id,country";
$tabfield = array();
$tabfield[31] = "pcg_version,label,country_id,country";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
$tabfieldvalue[31]= "pcg_version,label,country";
$tabfieldvalue = array();
$tabfieldvalue[31] = "pcg_version,label,country";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
$tabfieldinsert[31]= "pcg_version,label,fk_country";
$tabfieldinsert = array();
$tabfieldinsert[31] = "pcg_version,label,fk_country";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array();
$tabrowid[31]= "";
$tabrowid = array();
$tabrowid[31] = "";
// Condition to show dictionary in setup page
$tabcond=array();
$tabcond[31]= ! empty($conf->accounting->enabled);
$tabcond = array();
$tabcond[31] = !empty($conf->accounting->enabled);
// List of help for fields
$tabhelp=array();
$tabhelp = array();
$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
$tabfieldcheck = array();
$tabfieldcheck[31] = array();
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
$sourceList=array();
$sourceList = array();
@ -147,38 +147,38 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
// Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{
$listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
$ok = 1;
foreach ($listfield as $f => $value)
{
if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory
if ((! isset($_POST[$value]) || $_POST[$value]==''))
if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory
if ((!GETPOSTISSET($value)) || GETPOST($value) == '')
{
$ok=0;
$fieldnamekey=$listfield[$f];
$ok = 0;
$fieldnamekey = $listfield[$f];
// We take translate key of field
if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'pcg_version') $fieldnamekey = 'Pcg_version';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
}
// Other checks
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system','systemauto'))) {
$ok=0;
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system', 'systemauto'))) {
$ok = 0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
}
if (isset($_POST["pcg_version"]))
if (GETPOSTISSET("pcg_version"))
{
if ($_POST["pcg_version"]=='0')
if (GETPOST("pcg_version") == '0')
{
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
@ -187,9 +187,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/
}
if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2))
if (isset($_POST["country"]) && ($_POST["country"] == '0') && ($id != 2))
{
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
}
@ -199,13 +199,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
$newid = ($obj->newid + 1);
} else {
dol_print_error($db);
}
@ -214,16 +214,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active)";
$sql.= " VALUES(";
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $tabrowid[$id].",";
$sql .= $tabfieldinsert[$id];
$sql .= ",active)";
$sql .= " VALUES(";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $newid.",";
$i=0;
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $newid.",";
$i = 0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
@ -232,19 +232,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
$sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
$_POST = array('id'=>$id); // Clean $_POST array, we keep only
}
else
{
@ -260,16 +260,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
$sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
@ -280,18 +280,18 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
$sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
setEventMessages($db->error(), null, 'errors');
}
@ -306,14 +306,14 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
if (!$result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
@ -329,8 +329,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
@ -349,8 +349,8 @@ if ($action == $acts[0])
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
@ -369,8 +369,8 @@ if ($action == $acts[1])
// favorite
if ($action == 'activate_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
@ -389,8 +389,8 @@ if ($action == 'activate_favorite')
// disable favorite
if ($action == 'disable_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
@ -412,12 +412,12 @@ if ($action == 'disable_favorite')
*/
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
llxHeader();
$titre=$langs->trans($tablib[$id]);
$linkback='';
$titre = $langs->trans($tablib[$id]);
$linkback = '';
print load_fiche_titre($titre, $linkback, 'title_accountancy');
@ -425,7 +425,7 @@ print load_fiche_titre($titre, $linkback, 'title_accountancy');
// Confirmation de la suppression de la ligne
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.urlencode($page).'&':'').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode($page).'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
//var_dump($elementList);
@ -435,22 +435,22 @@ if ($action == 'delete')
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
$sql = $tabsql[$id];
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /', $sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " c.rowid = ".$search_country_id;
if (preg_match('/ WHERE /', $sql)) $sql .= " AND ";
else $sql .= " WHERE ";
$sql .= " c.rowid = ".$search_country_id;
}
// If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code';
$sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($listlimit+1, $offset);
if ($sortfield == 'country') $sortfield = 'country_code';
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset);
//print $sql;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -461,10 +461,10 @@ if ($id)
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$var=false;
$alabelisused = 0;
$var = false;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
@ -472,33 +472,33 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$class="left";
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
$class = "left";
if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label')
{
$valuetoshow=$langs->trans("Label");
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='country') {
if ($fieldlist[$field] == 'country') {
if (in_array('region_id', $fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
$valuetoshow=$langs->trans("Country");
$valuetoshow = $langs->trans("Country");
}
if ($fieldlist[$field]=='country_id') { $valuetoshow=''; }
if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
if ($fieldlist[$field] == 'country_id') { $valuetoshow = ''; }
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); }
if ($valuetoshow != '') {
print '<td class="'.$class.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
} elseif (! empty($tabhelp[$id][$value])) {
} elseif (!empty($tabhelp[$id][$value])) {
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
} else {
print $valuetoshow;
}
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
}
print '<td>';
@ -518,14 +518,14 @@ if ($id)
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val))
$obj->$val=GETPOST($val);
$obj->$val = GETPOST($val);
}
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
@ -537,32 +537,32 @@ if ($id)
print '</td>';
print "</tr>";
$colspan=count($fieldlist)+3;
$colspan = count($fieldlist) + 3;
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
}
// List of available values in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
$paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
// There is several pages
if ($num > $listlimit)
{
print '<tr class="none"><td class="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
@ -570,9 +570,9 @@ if ($id)
print '<tr class="liste_titre liste_titre_add">';
foreach ($fieldlist as $field => $value)
{
$showfield=1; // By defaut
$showfield = 1; // By defaut
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; }
if ($showfield)
{
@ -590,17 +590,17 @@ if ($id)
}
print '<td class="liste_titre"></td>';
print '<td class="liste_titre right" colspan="2">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print '</tr>';
// Title of lines
print '<tr class="liste_titre">';
print getTitleFieldOfList($langs->trans("Pcg_version"), 0, $_SERVER["PHP_SELF"], "pcg_version", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], "label", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Country"), 0, $_SERVER["PHP_SELF"], "country_code", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList($langs->trans("Pcg_version"), 0, $_SERVER["PHP_SELF"], "pcg_version", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], "label", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Country"), 0, $_SERVER["PHP_SELF"], "country_code", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, '');
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print '</tr>';
@ -613,81 +613,81 @@ if ($id)
$obj = $db->fetch_object($resql);
//print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit');
print '<td colspan="3" class="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
}
else
{
$tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$class="left";
$valuetoshow=$obj->{$fieldlist[$field]};
$showfield = 1;
$class = "left";
$valuetoshow = $obj->{$fieldlist[$field]};
if ($value == 'type_template')
{
$valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
}
if ($value == 'element')
{
$valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
}
elseif ($value == 'source')
{
$valuetoshow = isset($sourceList[$valuetoshow])?$sourceList[$valuetoshow]:$valuetoshow;
$valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
}
elseif ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All');
}
elseif ($fieldlist[$field]=='country') {
elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code))
{
$valuetoshow='-';
$valuetoshow = '-';
}
else
{
$key=$langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country);
$key = $langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
}
}
elseif ($fieldlist[$field]=='country_id') {
$showfield=0;
elseif ($fieldlist[$field] == 'country_id') {
$showfield = 0;
}
$class='tddict';
if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto';
$class = 'tddict';
if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto';
// Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
}
// Can an entry be erased or disabled ?
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param;
$url.='&';
$url .= '&';
// Active
print '<td class="center nowrap">';
@ -737,10 +737,10 @@ $db->close();
*/
function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = '')
{
global $conf,$langs,$db;
global $conf, $langs, $db;
global $form;
global $region_id;
global $elementList,$sourceList;
global $elementList, $sourceList;
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
@ -758,15 +758,15 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
continue;
} // For state page, we do not show the country input (we link to region, not country)
print '<td>';
$fieldname='country';
print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
$fieldname = 'country';
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>';
}
elseif ($fieldlist[$field] == 'country_id')
{
if (! in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{
$country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
$country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
print '<td>';
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>';
@ -776,24 +776,24 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
if ($fieldlist[$field] == 'type_cdr') print '<td class="center">';
else print '<td>';
if ($fieldlist[$field] == 'type_cdr') {
print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
} else {
print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
}
print '</td>';
}
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
print '<td><input type="text" class="flat" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
}
else
{
print '<td>';
$size=''; $class='';
if ($fieldlist[$field]=='code') $size='size="8" ';
if ($fieldlist[$field]=='position') $size='size="4" ';
if ($fieldlist[$field]=='libelle') $size='centpercent';
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
print '<input type="text" '.$size.' class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
$size = ''; $class = '';
if ($fieldlist[$field] == 'code') $size = 'size="8" ';
if ($fieldlist[$field] == 'position') $size = 'size="4" ';
if ($fieldlist[$field] == 'libelle') $size = 'centpercent';
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
print '<input type="text" '.$size.' class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>';
}
}

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
@ -97,6 +97,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$object->account_parent = $account_parent;
$object->account_category = GETPOST('account_category', 'alpha');
$object->label = GETPOST('label', 'alpha');
$object->labelshort = GETPOST('labelshort', 'alpha');
$object->active = 1;
$res = $object->create($user);
@ -162,6 +163,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$object->account_parent = $account_parent;
$object->account_category = GETPOST('account_category', 'alpha');
$object->label = GETPOST('label', 'alpha');
$object->labelshort = GETPOST('labelshort', 'alpha');
$result = $object->update($user);
@ -236,6 +238,10 @@ if ($action == 'create') {
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
print '<td><input name="label" size="70" value="'.$object->label.'"></td></tr>';
// Label short
print '<tr><td>' . $langs->trans("LabelToShow") . '</td>';
print '<td><input name="labelshort" size="70" value="' . $object->labelshort . '"></td></tr>';
// Account parent
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td>';
@ -254,7 +260,7 @@ if ($action == 'create') {
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Chart of acounts subtype
// Chart of accounts subtype
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
@ -301,6 +307,10 @@ elseif ($id > 0 || $ref) {
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
print '<td><input name="label" size="70" value="'.$object->label.'"</td></tr>';
// Label short
print '<tr><td>' . $langs->trans("LabelToShow") . '</td>';
print '<td><input name="labelshort" size="70" value="' . $object->labelshort . '"</td></tr>';
// Account parent
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td>';
@ -354,6 +364,10 @@ elseif ($id > 0 || $ref) {
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td>';
print '<td colspan="2">'.$object->label.'</td></tr>';
// Label to show
print '<tr><td class="titlefield">' . $langs->trans("LabelToShow") . '</td>';
print '<td colspan="2">' . $object->labelshort . '</td></tr>';
// Account parent
$accp = new AccountingAccount($db);
if (!empty($object->account_parent)) {

View File

@ -153,7 +153,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($value == 'formula' && empty($_POST['formula'])) continue;
if ($value == 'range_account' && empty($_POST['range_account'])) continue;
if ($value == 'country' || $value == 'country_id') continue;
if (!isset($_POST[$value]) || $_POST[$value] == '')
if (!GETPOSTISSET($value) || GETPOST($value) == '')
{
$ok = 0;
$fieldnamekey = $listfield[$f];

View File

@ -165,9 +165,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal';
}
// Other checks
if (isset($_POST["code"]))
if (GETPOSTISSET("code"))
{
if ($_POST["code"] == '0')
if (GETPOST("code") == '0')
{
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');

View File

@ -98,10 +98,8 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
$search_date_end = dol_get_last_day($year_end, $month_end);
}
}
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "t.numero_compte";
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.numero_compte";
$param = '';
@ -202,6 +200,8 @@ if ($action != 'export_csv')
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$button = '<input type="button" id="exportcsvbutton" name="exportcsvbutton" class="butAction" value="'.$langs->trans("Export").' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#exportcsvbutton").click(function() {
@ -214,9 +214,6 @@ if ($action != 'export_csv')
});
</script>';
$button = '<input type="button" id="exportcsvbutton" name="exportcsvbutton" class="butAction" value="'.$langs->trans("Export").' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
$moreforfilter = '';
@ -240,7 +237,7 @@ if ($action != 'export_csv')
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="5">';
print '<td class="liste_titre" colspan="6">';
print $langs->trans('From');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
print ' ';
@ -257,6 +254,7 @@ if ($action != 'export_csv')
print '<tr class="liste_titre">';
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Opening Balance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
@ -269,6 +267,16 @@ if ($action != 'export_csv')
$sous_total_credit = 0;
$displayed_account = "";
$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";
$resql = $db->query($sql);
$nrows = $resql->num_rows;
$opening_balances = Array();
for ($i = 0; $i < $nrows; $i++) {
$arr = $resql->fetch_array();
$opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance'];
}
foreach ($object->lines as $line)
{
$link = '';
@ -286,14 +294,14 @@ if ($action != 'export_csv')
{
// Affiche un Sous-Total par compte comptable
if ($displayed_account != "") {
print '<tr class="liste_total"><td class="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap right">' . price($sous_total_debit) . '</td><td class="nowrap right">' . price($sous_total_credit) . '</td><td class="nowrap right">' . price(price2num($sous_total_credit - $sous_total_debit)) . '</td>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_credit - $sous_total_debit)).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
}
// Show first line of a break
print '<tr class="trforbreak">';
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">' . $line->numero_compte . ($root_account_description ? ' - ' . $root_account_description : '') . '</td>';
print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '</tr>';
$displayed_account = $root_account_description;
@ -305,6 +313,7 @@ if ($action != 'export_csv')
print '<td>'.length_accountg($line->numero_compte).'</td>';
print '<td>'.$description.'</td>';
print '<td class="nowraponall right">'.price($opening_balances["'".$line->numero_compte."'"]).'</td>';
print '<td class="nowraponall right">'.price($line->debit).'</td>';
print '<td class="nowraponall right">'.price($line->credit).'</td>';
print '<td class="nowraponall right">'.price($line->debit - $line->credit).'</td>';
@ -317,11 +326,11 @@ if ($action != 'export_csv')
$sous_total_credit += $line->credit;
}
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
@ -86,6 +86,7 @@ $search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
@ -202,6 +203,7 @@ if (empty($reshook))
$search_debit = '';
$search_credit = '';
$search_lettering_code = '';
$search_not_reconciled='';
}
// Must be after the remove filter action, before the export.
@ -312,6 +314,10 @@ if (empty($reshook))
$filter['t.lettering_code'] = $search_lettering_code;
$param .= '&search_lettering_code='.urlencode($search_lettering_code);
}
if (! empty($search_not_reconciled)) {
$filter['t.reconciled_option'] = $search_not_reconciled;
$param .= '&search_not_reconciled=' . urlencode($search_not_reconciled);
}
}
if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
@ -444,6 +450,8 @@ if (count($filter) > 0) {
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') {
$sqlwhere[] = 't.lettering_code IS NULL';
} else {
$sqlwhere[] = natural_search($key, $value, 0, 1);
}
@ -758,6 +766,7 @@ if (!empty($arrayfields['t.lettering_code']['checked']))
{
print '<td class="liste_titre center">';
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
print '<br><span class="nowrap"><input type="checkbox" name="search_reconciled_option" value="notreconciled"'.($search_not_reconciled == 'notreconciled'?' checked':'').'>'.$langs->trans("NotReconciled").'</span>';
print '</td>';
}
// Code journal

View File

@ -260,9 +260,9 @@ if ($resql) {
print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td class="right">' . price($obj->debit) . '</td>';
print '<td class="right">' . price($obj->credit) . '</td>';
print '<td class="right">' . price(round($solde, 2)) . '</td>';
print '<td class="nowrap right">' . price($obj->debit) . '</td>';
print '<td class="nowrap right">' . price($obj->credit) . '</td>';
print '<td class="nowrap right">' . price(round($solde, 2)) . '</td>';
// Journal
$accountingjournal = new AccountingJournal($db);
@ -285,15 +285,15 @@ if ($resql) {
print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n";
print '<td class="right"><strong>' . price($debit) . '</strong></td>';
print '<td class="right"><strong>' . price($credit) . '</strong></td>';
print '<td class="nowrap right"><strong>' . price($debit) . '</strong></td>';
print '<td class="nowrap right"><strong>' . price($credit) . '</strong></td>';
print '<td colspan="4"></td>';
print "</tr>\n";
print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n";
print '<td colspan="2">&nbsp;</td>';
print '<td class="right"><strong>' . price($credit - $debit) . '</strong></td>';
print '<td class="nowrap right"><strong>' . price($credit - $debit) . '</strong></td>';
print '<td colspan="6"></td>';
print "</tr>\n";

View File

@ -144,7 +144,7 @@ dol_fiche_end();
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )";
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
@ -257,9 +257,9 @@ if ($resql) {
print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td class="right">' . price($obj->debit) . '</td>';
print '<td class="right">' . price($obj->credit) . '</td>';
print '<td class="right">' . price(round($solde, 2)) . '</td>';
print '<td class="nowrap right">' . price($obj->debit) . '</td>';
print '<td class="nowrap right">' . price($obj->credit) . '</td>';
print '<td class="nowrap right">' . price(round($solde, 2)) . '</td>';
// Journal
$accountingjournal = new AccountingJournal($db);
@ -267,7 +267,7 @@ if ($resql) {
$journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
print '<td class="center">' . $journaltoshow . '</td>';
if (empty($obj->lettering_code)) {
if (empty($obj->lettering_code) && empty($obj->date_validated) ) {
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>';
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $obj->piece_num . '">';
print img_edit();
@ -282,15 +282,15 @@ if ($resql) {
print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n";
print '<td class="right"><strong>' . price($debit) . '</strong></td>';
print '<td class="right"><strong>' . price($credit) . '</strong></td>';
print '<td class="nowrap right"><strong>' . price($debit) . '</strong></td>';
print '<td class="nowrap right"><strong>' . price($credit) . '</strong></td>';
print '<td colspan="6"></td>';
print "</tr>\n";
print '<tr class="oddeven">';
print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n";
print '<td colspan="2">&nbsp;</td>';
print '<td class="right"><strong>' . price($credit - $debit) . '</strong></td>';
print '<td class="nowrap right"><strong>' . price($credit - $debit) . '</strong></td>';
print '<td colspan="4"></td>';
print "</tr>\n";

View File

@ -239,7 +239,7 @@ class AccountancyExport
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
$type_export = 'general_ledger';
global $db; // The tpl file use $db
global $db; // The tpl file use $db
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
@ -983,7 +983,7 @@ class AccountancyExport
$racine_subledger_account = ''; // for records of type E leave this field blank
// }
print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead
print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
// MONT
print price(abs($line->montant), 0, '', 1, 2).$separator;
// CODC

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
@ -120,7 +120,12 @@ class AccountingAccount extends CommonObject
*/
public $label;
/**
/**
* @var string Label short of account
*/
public $labelshort;
/**
* @var int ID
*/
public $fk_user_author;
@ -162,7 +167,7 @@ class AccountingAccount extends CommonObject
global $conf;
if ($rowid || $account_number) {
$sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.pcg_subtype, a.account_number, a.account_parent, a.label, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active";
$sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.pcg_subtype, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active";
$sql .= ", ca.label as category_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
@ -197,6 +202,7 @@ class AccountingAccount extends CommonObject
$this->account_number = $obj->account_number;
$this->account_parent = $obj->account_parent;
$this->label = $obj->label;
$this->labelshort = $obj->labelshort;
$this->account_category = $obj->fk_accounting_category;
$this->account_category_label = $obj->category_label;
$this->fk_user_author = $obj->fk_user_author;
@ -240,6 +246,8 @@ class AccountingAccount extends CommonObject
$this->account_number = trim($this->account_number);
if (isset($this->label))
$this->label = trim($this->label);
if (isset($this->labelshort))
$this->labelshort = trim($this->labelshort);
if (empty($this->pcg_type) || $this->pcg_type == '-1')
{
@ -262,6 +270,7 @@ class AccountingAccount extends CommonObject
$sql .= ", account_number";
$sql .= ", account_parent";
$sql .= ", label";
$sql .= ", labelshort";
$sql .= ", fk_accounting_category";
$sql .= ", fk_user_author";
$sql .= ", active";
@ -274,6 +283,7 @@ class AccountingAccount extends CommonObject
$sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'");
$sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent);
$sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'");
$sql .= ", " . (empty($this->labelshort) ? "''" : "'" . $this->db->escape($this->labelshort) . "'");
$sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= ", " . $user->id;
$sql .= ", " . (int) $this->active;
@ -345,6 +355,7 @@ class AccountingAccount extends CommonObject
$sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'";
$sql .= " , account_parent = " . (int) $this->account_parent;
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''");
$sql .= " , labelshort = " . ($this->labelshort ? "'" . $this->db->escape($this->labelshort) . "'" : "''");
$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = " . (int) $this->active;
@ -462,10 +473,11 @@ class AccountingAccount extends CommonObject
* @param string $moretitle Add more text to title tooltip
* @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)
* @return string String with URL
*/
public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1)
{
public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0)
{
global $langs, $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -483,11 +495,18 @@ class AccountingAccount extends CommonObject
$picto = 'billr';
$label='';
if (empty($this->labelshort) || $withcompletelabel == 1)
{
$labeltoshow = $this->label;
} else {
$labeltoshow = $this->labelshort;
}
$label = '<u>' . $langs->trans("ShowAccountingAccount") . '</u>';
if (! empty($this->account_number))
$label .= '<br><b>'.$langs->trans('AccountAccounting') . ':</b> ' . length_accountg($this->account_number);
if (! empty($this->label))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->label;
if (! empty($labeltoshow))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $labeltoshow;
if ($moretitle) $label.=' - '.$moretitle;
$linkclose='';
@ -514,7 +533,7 @@ class AccountingAccount extends CommonObject
}
$label_link = length_accountg($this->account_number);
if ($withlabel) $label_link .= ' - ' . $this->label;
if ($withlabel) $label_link .= ' - ' . $labeltoshow;
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto && $withpicto != 2) $result .= ' ';

View File

@ -357,25 +357,25 @@ class BookKeeping extends CommonObject
$sql .= ") VALUES (";
$sql .= "'".$this->db->idate($this->doc_date)."'";
$sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'");
$sql .= ",'".$this->db->escape($this->doc_type)."'";
$sql .= ",'".$this->db->escape($this->doc_ref)."'";
$sql .= ",".$this->fk_doc;
$sql .= ",".$this->fk_docdet;
$sql .= ",'".$this->db->escape($this->thirdparty_code)."'";
$sql .= ",'".$this->db->escape($this->subledger_account)."'";
$sql .= ",'".$this->db->escape($this->subledger_label)."'";
$sql .= ",'".$this->db->escape($this->numero_compte)."'";
$sql .= ",'".$this->db->escape($this->label_compte)."'";
$sql .= ",'".$this->db->escape($this->label_operation)."'";
$sql .= ",".$this->debit;
$sql .= ",".$this->credit;
$sql .= ",".$this->montant;
$sql .= ",'".$this->db->escape($this->sens)."'";
$sql .= ",'".$this->db->escape($this->fk_user_author)."'";
$sql .= ",'".$this->db->idate($now)."'";
$sql .= ",'".$this->db->escape($this->code_journal)."'";
$sql .= ",'".$this->db->escape($this->journal_label)."'";
$sql .= ",".$this->db->escape($this->piece_num);
$sql .= ", '".$this->db->escape($this->doc_type)."'";
$sql .= ", '".$this->db->escape($this->doc_ref)."'";
$sql .= ", ".$this->fk_doc;
$sql .= ", ".$this->fk_docdet;
$sql .= ", ".(!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL");
$sql .= ", ".(!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL");
$sql .= ", ".(!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL");
$sql .= ", '".$this->db->escape($this->numero_compte)."'";
$sql .= ", ".(!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL");
$sql .= ", '".$this->db->escape($this->label_operation)."'";
$sql .= ", ".$this->debit;
$sql .= ", ".$this->credit;
$sql .= ", ".$this->montant;
$sql .= ", ".(!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL");
$sql .= ", '".$this->db->escape($this->fk_user_author)."'";
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", '".$this->db->escape($this->code_journal)."'";
$sql .= ", ".(!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL");
$sql .= ", ".$this->db->escape($this->piece_num);
$sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity);
$sql .= ")";

View File

@ -76,6 +76,7 @@ class Lettering extends BookKeeping
$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
$sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) ";
$sql .= ' AND bk.date_validated IS NULL ';
$sql .= $this->db->order('bk.doc_date', 'DESC');
// echo $sql;
@ -253,7 +254,7 @@ class Lettering extends BookKeeping
}
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " rowid IN (" . implode(',', $ids) . ") ";
$sql .= " rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL ";
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
@ -275,7 +276,7 @@ class Lettering extends BookKeeping
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET";
$sql .= " lettering_code='" . $lettre . "'";
$sql .= " , date_lettering = '" . $this->db->idate($now) . "'"; // todo correct date it's false
$sql .= " WHERE rowid IN (" . implode(',', $ids) . ") ";
$sql .= " WHERE rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL ";
$this->db->begin();
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);

View File

@ -17,7 +17,7 @@
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
if (empty($conf) || !is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
@ -29,7 +29,7 @@ $format = $conf->global->ACCOUNTING_EXPORT_FORMAT;
$nodateexport = $conf->global->ACCOUNTING_EXPORT_NO_DATE_IN_FILENAME;
$siren = $conf->global->MAIN_INFO_SIREN;
$date_export = "_" . dol_print_date(dol_now(), '%Y%m%d%H%M%S');
$date_export = "_".dol_print_date(dol_now(), '%Y%m%d%H%M%S');
$endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d');
header('Content-Type: text/csv');
@ -46,22 +46,22 @@ if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$
$search_date_end = dol_now();
}
$datetouseforfilename = $search_date_end;
$tmparray=dol_getdate($datetouseforfilename);
$fiscalmonth=empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START;
$tmparray = dol_getdate($datetouseforfilename);
$fiscalmonth = empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START;
// Define end of month to use
if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon']=$fiscalmonth;
if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon'] = $fiscalmonth;
else {
$tmparray['mon'] = $fiscalmonth;
$tmparray['mon'] = $fiscalmonth;
$tmparray['year']++;
}
$endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard');
$completefilename = $siren . "FEC" . $endaccountingperiod . ".txt";
$completefilename = $siren."FEC".$endaccountingperiod.".txt";
}
else
{
$completefilename = ($code?$code . "_":"") . ($prefix?$prefix . "_":"") . $filename . ($nodateexport?"":$date_export) . "." . $format;
$completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format;
}
header('Content-Disposition: attachment;filename=' . $completefilename);
header('Content-Disposition: attachment;filename='.$completefilename);

View File

@ -202,7 +202,7 @@ if (empty($reshook))
{
// Creation user
$nuser = new User($db);
$result = $nuser->create_from_member($object, GETPOST('login'));
$result = $nuser->create_from_member($object, GETPOST('login', 'alphanohtml'));
if ($result < 0)
{
@ -1747,7 +1747,7 @@ else
{
print '<tr><td>'.$langs->trans("Categories").'</td>';
print '<td colspan="2">';
print $form->showCategories($object->id, 'member', 1);
print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
print '</td></tr>';
}

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,11 @@ class Subscription extends CommonObject
*/
public $table_element='subscription';
/**
* @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table
*/
public $ismultientitymanaged = 'fk_adherent@adherent';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
@ -88,6 +93,21 @@ class Subscription extends CommonObject
*/
public $fk_bank;
public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25),
'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
'datef' =>array('type'=>'date', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1),
'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50),
'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55),
'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60),
'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65),
);
/**
* Constructor

View File

@ -531,7 +531,7 @@ if ($rowid > 0)
{
print '<tr><td>'.$langs->trans("Categories").'</td>';
print '<td colspan="2">';
print $form->showCategories($object->id, 'member', 1);
print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
print '</td></tr>';
}

View File

@ -214,7 +214,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
// Type
print '<tr>';
print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"]) ? $_POST["typeid"] : $object->fk_type));
print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid") : $object->fk_type));
print'</td></tr>';
// Date start subscription

View File

@ -35,8 +35,8 @@ $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search
$filter = GETPOST("filter", "alpha");
$statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1);
$search_ref = GETPOST('search_ref', 'alpha');
$search_type = GETPOST('search_type', 'alpha');
@ -47,6 +47,7 @@ $search_note = GETPOST('search_note', 'alpha');
$search_account = GETPOST('search_account', 'int');
$search_amount = GETPOST('search_amount', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
$sall = '';
$date_select = GETPOST("date_select", 'alpha');
@ -76,21 +77,21 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
$fieldstosearchall = array(
);
$arrayfields = array(
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'd.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
't.libelle'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'd.bank'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled))),
/*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
'c.dateadh'=>array('label'=>$langs->trans("DateSubscription"), 'checked'=>1, 'position'=>100),
'c.datef'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>101),
'd.amount'=>array('label'=>$langs->trans("Amount"), 'checked'=>1, 'position'=>102),
'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
// 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
'd.ref'=>array('label'=>"Ref", 'checked'=>1),
'd.fk_type'=>array('label'=>"Type", 'checked'=>1),
'd.lastname'=>array('label'=>"Lastname", 'checked'=>1),
'd.firstname'=>array('label'=>"Firstname", 'checked'=>1),
'd.login'=>array('label'=>"Login", 'checked'=>1),
't.libelle'=>array('label'=>"Label", 'checked'=>1),
'd.bank'=>array('label'=>"BankAccount", 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled))),
/*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
'c.dateadh'=>array('label'=>"DateSubscription", 'checked'=>1, 'position'=>100),
'c.datef'=>array('label'=>"EndSubscription", 'checked'=>1, 'position'=>101),
'd.amount'=>array('label'=>"Amount", 'checked'=>1, 'position'=>102),
'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
// 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
);
// Security check
@ -256,7 +257,6 @@ if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$opt
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="view" value="'.dol_escape_htmltag($view).'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
@ -388,16 +388,16 @@ print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.fk_type']['checked'])) print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
if (! empty($arrayfields['d.bank']['checked'])) print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['c.dateadh']['checked'])) print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
if (! empty($arrayfields['c.datef']['checked'])) print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
if (! empty($arrayfields['d.amount']['checked'])) print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['d.fk_type']['checked'])) print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
if (!empty($arrayfields['d.bank']['checked'])) print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['c.dateadh']['checked'])) print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
if (!empty($arrayfields['c.datef']['checked'])) print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
if (!empty($arrayfields['d.amount']['checked'])) print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -412,12 +412,10 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'alig
print "</tr>\n";
$total = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($result);
$total += $obj->subscription;
$subscription->ref = $obj->crowid;
$subscription->id = $obj->crowid;

View File

@ -65,7 +65,7 @@ $subscription = GETPOST("subscription", "int");
$duration_value = GETPOST('duration_value', 'int');
$duration_unit = GETPOST('duration_unit', 'alpha');
$vote = GETPOST("vote", "int");
$comment = GETPOST("comment", 'alphanohtml');
$comment = GETPOST("comment", 'none');
$mail_valid = GETPOST("mail_valid", 'none');
// Security check
@ -364,7 +364,9 @@ if ($action == 'create')
print '</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create();
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@ -790,7 +792,7 @@ if ($rowid > 0)
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy);
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy);
print "</td></tr>";
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
@ -807,10 +809,12 @@ if ($rowid > 0)
print '</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create();
print "</td></tr>";
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create();
print "</td></tr>";

View File

@ -235,7 +235,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/action/doc/");
$dir = dol_buildpath($reldir."core/modules/action/doc");
if (is_dir($dir))
{
@ -257,7 +257,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print (empty($module->name) ? $name : $module->name);
print "</td>\n";
print "<td>\n";
require_once $dir.$file;
require_once $dir.'/'.$file;
$module = new $classname($db, $specimenthirdparty);
if (method_exists($module, 'info'))
print $module->info($langs);

View File

@ -178,6 +178,7 @@ $message .= $langs->trans("AgendaUrlOptionsNotAdmin", $user->login, $user->login
$message .= $langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
$message .= $langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
$message .= $langs->trans("AgendaUrlOptionsNotAutoEvent", 'systemauto', 'systemauto').'<br>';
$message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
print info_admin($message);

View File

@ -350,7 +350,8 @@ foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/bom".$valdir);
$realpath = $reldir."core/modules/bom".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -382,7 +383,6 @@ foreach ($dirmodels as $reldir)
if ($modulequalified)
{
$var = !$var;
print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
@ -425,7 +425,9 @@ foreach ($dirmodels as $reldir)
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);

View File

@ -403,7 +403,8 @@ foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/commande".$valdir);
$realpath = $reldir."core/modules/commande".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -471,20 +472,22 @@ foreach ($dirmodels as $reldir)
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
//$htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
//$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
//$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
//$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">';

View File

@ -181,6 +181,13 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
}
}
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FACEBOOK_URL", GETPOST("facebookurl", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TWITTER_URL", GETPOST("twitterurl", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LINKEDIN_URL", GETPOST("linkedinurl", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_INSTAGRAM_URL", GETPOST("instagramurl", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_YOUTUBE_URL", GETPOST("youtubeurl", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GITHUB_URL", GETPOST("githuburl", 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'nohtml'), 'chaine', 0, '', $conf->entity);
@ -407,32 +414,26 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
// Name
print '<tr class="oddeven"><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM: GETPOST("nom", 'nohtml')) . '"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
// Addresse
print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM ? $conf->global->MAIN_INFO_SOCIETE_NOM : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
// Address
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADDRESS?$conf->global->MAIN_INFO_SOCIETE_ADDRESS:GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml')) . '</textarea></td></tr>'."\n";
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'.($conf->global->MAIN_INFO_SOCIETE_ADDRESS ? $conf->global->MAIN_INFO_SOCIETE_ADDRESS : GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml')).'</textarea></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP:GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')) . '"></td></tr>'."\n";
print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP ? $conf->global->MAIN_INFO_SOCIETE_ZIP : GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')).'"></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN:GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')) . '"></td></tr>'."\n";
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN ? $conf->global->MAIN_INFO_SOCIETE_TOWN : GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')).'"></td></tr>'."\n";
// Country
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
//if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization
print $form->select_country($mysoc->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
$state_id = 0;
if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE))
@ -443,22 +444,22 @@ if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE))
$formcompany->select_departement($state_id, $mysoc->country_code, 'state_id');
print '</td></tr>'."\n";
// Currency
print '<tr class="oddeven"><td><label for="currency">'.$langs->trans("CompanyCurrency").'</label></td><td>';
print $form->selectCurrency($conf->currency, "currency");
print '</td></tr>'."\n";
// Phone
print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
print '<input name="tel" id="phone" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL).'"></td></tr>';
print '</td></tr>'."\n";
// Fax
print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
print '<input name="fax" id="fax" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_FAX).'"></td></tr>';
print '</td></tr>'."\n";
// Email
print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
print '<input name="mail" id="email" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL).'"></td></tr>';
print '</td></tr>'."\n";
@ -516,6 +517,45 @@ print '</td></tr>';
print '</table>';
// Social networks
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->trans("SocialNetworksInformation").'</td><td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
// Facebook
print '<tr class="oddeven"><td><label for="facebookurl">'.$langs->trans("SocialNetworksFacebookURL").'</label></td><td>';
print '<input name="facebookurl" id="facebookurl" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_FACEBOOK_URL).'"></td></tr>';
print '</td></tr>'."\n";
// Twitter
print '<tr class="oddeven"><td><label for="twitterurl">'.$langs->trans("SocialNetworksTwitterURL").'</label></td><td>';
print '<input name="twitterurl" id="twitterurl" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TWITTER_URL).'"></td></tr>';
print '</td></tr>'."\n";
// LinkedIn
print '<tr class="oddeven"><td><label for="linkedinurl">'.$langs->trans("SocialNetworksLinkedinURL").'</label></td><td>';
print '<input name="linkedinurl" id="linkedinurl" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_LINKEDIN_URL).'"></td></tr>';
print '</td></tr>'."\n";
// Instagram
print '<tr class="oddeven"><td><label for="instagramurl">'.$langs->trans("SocialNetworksInstagramURL").'</label></td><td>';
print '<input name="instagramurl" id="instagramurl" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_INSTAGRAM_URL).'"></td></tr>';
print '</td></tr>'."\n";
// Youtube
print '<tr class="oddeven"><td><label for="youtubeurl">'.$langs->trans("SocialNetworksYoutubeURL").'</label></td><td>';
print '<input name="youtubeurl" id="youtubeurl" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_YOUTUBE_URL).'"></td></tr>';
print '</td></tr>'."\n";
// Github
print '<tr class="oddeven"><td><label for="githuburl">'.$langs->trans("SocialNetworksGithubURL").'</label></td><td>';
print '<input name="githuburl" id="githuburl" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_GITHUB_URL).'"></td></tr>';
print '</td></tr>'."\n";
print "</table>";
print '<br>';
// IDs of the company (country-specific)
@ -525,24 +565,20 @@ print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("CompanyId
$langs->load("companies");
// Managing Director(s)
print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MANAGERS).'"></td></tr>';
// GDPR contact
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
print '</td><td>';
print '<input name="MAIN_INFO_GDPR" id="director" class="minwidth500" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_GDPR).'"></td></tr>';
// Capital
print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
print '<input name="capital" id="capital" class="minwidth100" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_CAPITAL).'"></td></tr>';
// Juridical Status
print '<tr class="oddeven"><td><label for="forme_juridique_code">'.$langs->trans("JuridicalStatus").'</label></td><td>';
if ($mysoc->country_code) {
print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE, $mysoc->country_code, '', 'forme_juridique_code');
@ -551,7 +587,7 @@ if ($mysoc->country_code) {
}
print '</td></tr>';
// ProfID1
// ProfId1
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
{
print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
@ -641,14 +677,12 @@ if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-')
print '</td></tr>';
}
// TVA Intra
// Intra-community VAT number
print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '').'">';
print '</td></tr>';
// Object of the company
print '<tr class="oddeven"><td><label for="object">'.$langs->trans("CompanyObject").'</label></td><td>';
print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(!empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
print '</td></tr>';

View File

@ -339,7 +339,8 @@ foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/contract".$valdir);
$realpath = $reldir."core/modules/contract".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -407,18 +408,20 @@ foreach ($dirmodels as $reldir)
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">';

View File

@ -107,6 +107,10 @@ $modules = array(
array(
'code' => 'MAIN_DELAY_MEMBERS',
'img' => 'user'
),
array(
'code' => 'MAIN_DELAY_MEMBERS_SHIFT',
'img' => 'user'
)
),
'expensereport' => array(

View File

@ -678,9 +678,9 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$ok = 0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
}
if (isset($_POST["code"]))
if (GETPOSTISSET("code"))
{
if ($_POST["code"] == '0')
if (GETPOST("code") == '0')
{
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
@ -691,7 +691,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/
}
if (isset($_POST["country"]) && ($_POST["country"] == '0') && ($id != 2))
if (GETPOSTISSET("country") && ($_POST["country"] == '0') && ($id != 2))
{
if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries
{

View File

@ -32,13 +32,13 @@ if (!$user->admin)
accessforbidden();
// Load translation files required by the page
$langs->loadLangs(array("users","admin","other"));
$langs->loadLangs(array("users", "admin", "other"));
$action=GETPOST('action', 'aZ09');
$action = GETPOST('action', 'aZ09');
$securityevent=new Events($db);
$eventstolog=$securityevent->eventstolog;
$securityevent = new Events($db);
$eventstolog = $securityevent->eventstolog;
/*
@ -46,15 +46,14 @@ $eventstolog=$securityevent->eventstolog;
*/
if ($action == "save")
{
$i=0;
$i = 0;
$db->begin();
foreach ($eventstolog as $key => $arr)
{
$param='MAIN_LOGEVENTS_'.$arr['id'];
//print "param=".$param." - ".$_POST[$param];
if (! empty($_POST[$param])) dolibarr_set_const($db, $param, $_POST[$param], 'chaine', 0, '', $conf->entity);
$param = 'MAIN_LOGEVENTS_'.$arr['id'];
if (GETPOST($param, 'alphanohtml')) dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity);
else dolibarr_del_const($db, $param, $conf->entity);
}
@ -68,7 +67,7 @@ if ($action == "save")
* View
*/
$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
llxHeader('', $langs->trans("Audit"), $wikihelp);
//$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
@ -82,7 +81,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="save">';
$head=security_prepare_head();
$head = security_prepare_head();
dol_fiche_head($head, 'audit', $langs->trans("Security"), -1);
@ -98,9 +97,9 @@ foreach ($eventstolog as $key => $arr)
print '<tr class="oddeven">';
print '<td>'.$arr['id'].'</td>';
print '<td>';
$key='MAIN_LOGEVENTS_'.$arr['id'];
$value=$conf->global->$key;
print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.($value?' checked':'').'>';
$key = 'MAIN_LOGEVENTS_'.$arr['id'];
$value = $conf->global->$key;
print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.($value ? ' checked' : '').'>';
print '</td></tr>'."\n";
}
}

View File

@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type='invoice';
$type = 'invoice';
/*
@ -53,22 +53,22 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstinvoice=GETPOST('maskconstinvoice', 'alpha');
$maskconstreplacement=GETPOST('maskconstreplacement', 'alpha');
$maskconstcredit=GETPOST('maskconstcredit', 'alpha');
$maskconstdeposit=GETPOST('maskconstdeposit', 'alpha');
$maskinvoice=GETPOST('maskinvoice', 'alpha');
$maskreplacement=GETPOST('maskreplacement', 'alpha');
$maskcredit=GETPOST('maskcredit', 'alpha');
$maskdeposit=GETPOST('maskdeposit', 'alpha');
$maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
$maskconstreplacement = GETPOST('maskconstreplacement', 'alpha');
$maskconstcredit = GETPOST('maskconstcredit', 'alpha');
$maskconstdeposit = GETPOST('maskconstdeposit', 'alpha');
$maskinvoice = GETPOST('maskinvoice', 'alpha');
$maskreplacement = GETPOST('maskreplacement', 'alpha');
$maskcredit = GETPOST('maskcredit', 'alpha');
$maskdeposit = GETPOST('maskdeposit', 'alpha');
if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -79,20 +79,20 @@ if ($action == 'updateMask')
}
elseif ($action == 'specimen')
{
$modele=GETPOST('module', 'alpha');
$modele = GETPOST('module', 'alpha');
$facture = new Facture($db);
$facture->initAsSpecimen();
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound=1;
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
@ -167,9 +167,9 @@ elseif ($action == 'setribchq')
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -184,9 +184,9 @@ elseif ($action == 'set_FACTURE_DRAFT_WATERMARK')
$res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -198,13 +198,13 @@ elseif ($action == 'set_FACTURE_DRAFT_WATERMARK')
elseif ($action == 'set_INVOICE_FREE_TEXT')
{
$freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string
$freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -219,9 +219,9 @@ elseif ($action == 'setforcedate')
$res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -232,19 +232,19 @@ elseif ($action == 'setforcedate')
}
elseif ($action == 'setDefaultPDFModulesByType')
{
$invoicetypemodels = GETPOST('invoicetypemodels');
$invoicetypemodels = GETPOST('invoicetypemodels');
if(!empty($invoicetypemodels) && is_array($invoicetypemodels))
if (!empty($invoicetypemodels) && is_array($invoicetypemodels))
{
$error = 0;
foreach ($invoicetypemodels as $type => $value)
{
$res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
}
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -260,14 +260,14 @@ elseif ($action == 'setDefaultPDFModulesByType')
* View
*/
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader("", $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura');
$form=new Form($db);
$form = new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
$head = invoice_admin_prepare_head();
@ -298,24 +298,24 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{
$filebis = $file;
$classname = preg_replace('/\.php$/', '', $file);
// For compatibility
if (! is_file($dir.$filebis))
if (!is_file($dir.$filebis))
{
$filebis = $file."/".$file.".modules.php";
$classname = "mod_facture_".$file;
}
// Check if there is a filter on country
preg_match('/\-(.*)_(.*)$/', $classname, $reg);
if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
$classname = preg_replace('/\-.*$/', '', $classname);
if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
{
// Charging the numbering class
require_once $dir.$filebis;
@ -323,7 +323,7 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
@ -338,9 +338,9 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '<td class="nowrap">';
$tmp=$module->getExample();
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
@ -356,62 +356,62 @@ foreach ($dirmodels as $reldir)
}
print '</td>';
$facture=new Facture($db);
$facture = new Facture($db);
$facture->initAsSpecimen();
// Example for standard invoice
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc, $facture);
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type = 0;
$nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForInvoices").': ';
$htmltooltip .= $langs->trans("NextValueForInvoices").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
// Example for remplacement
$facture->type=1;
$nextval=$module->getNextValue($mysoc, $facture);
$facture->type = 1;
$nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForReplacements").': ';
$htmltooltip .= $langs->trans("NextValueForReplacements").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
// Example for credit invoice
$facture->type=2;
$nextval=$module->getNextValue($mysoc, $facture);
$facture->type = 2;
$nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForCreditNotes").': ';
$htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
// Example for deposit invoice
$facture->type=3;
$nextval=$module->getNextValue($mysoc, $facture);
$facture->type = 3;
$nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForDeposit").': ';
$htmltooltip .= $langs->trans("NextValueForDeposit").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval;
$htmltooltip .= $nextval;
} else {
$htmltooltip.=$langs->trans($module->error);
$htmltooltip .= $langs->trans($module->error);
}
}
@ -420,7 +420,7 @@ foreach ($dirmodels as $reldir)
if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors
{
if (! empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
}
print '</td>';
@ -445,17 +445,17 @@ print '<br>';
print load_fiche_titre($langs->trans("BillsPDFModules"), '', '');
// Load array def with activated templates
$type='invoice';
$type = 'invoice';
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$type."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -484,42 +484,43 @@ $activatedModels = array();
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/facture".$valdir);
$realpath = $reldir."core/modules/facture".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
$handle=opendir($dir);
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
$filelist[]=$file;
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified)
{
print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name);
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -554,20 +555,22 @@ foreach ($dirmodels as $reldir)
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">';
@ -597,7 +600,7 @@ foreach ($dirmodels as $reldir)
}
print '</table>';
if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
{
/*
* Document templates generators
@ -614,13 +617,13 @@ if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
$listtype=array(
$listtype = array(
Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
);
if (! empty($conf->global->INVOICE_USE_SITUATION))
if (!empty($conf->global->INVOICE_USE_SITUATION))
{
$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
}
@ -628,7 +631,7 @@ if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
foreach ($listtype as $type => $trans)
{
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
$current = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
$current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
print '<tr >';
print '<td>'.$trans.'</td>';
print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
@ -660,14 +663,14 @@ print "</tr>\n";
print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
print "<td>";
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
$sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE clos = 0";
$sql.= " AND courant = 1";
$sql.= " AND entity IN (".getEntity('bank_account').")";
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0";
$sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -681,7 +684,7 @@ if (! empty($conf->banque->enabled))
$row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"';
print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected':'';
print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
print '>'.$row[1].'</option>';
$i++;
@ -705,15 +708,15 @@ print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
print "<td>";
print '<select class="flat" name="chq" id="chq">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER?' selected':'').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name?$mysoc->name:$langs->trans("NotDefined")).')</option>';
print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
$sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE clos = 0";
$sql.= " AND courant = 1";
$sql.= " AND entity IN (".getEntity('bank_account').")";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0";
$sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -723,7 +726,7 @@ if ($resql)
$row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"';
print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected':'';
print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
$i++;
@ -758,18 +761,18 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" /
print "</td></tr>\n";
print '</form>';
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
$htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'" />';
print '<input type="hidden" name="action" value="set_INVOICE_FREE_TEXT" />';
print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename='INVOICE_FREE_TEXT';
$variablename = 'INVOICE_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@ -777,7 +780,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else
{
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create();
}
print '</td><td class="right">';

View File

@ -239,13 +239,6 @@ else
jsdump(CKEDITOR.env, "divforlog");
</script>';
}
/*
print '<!-- Result -->';
print $_POST["formtestfield"];
print '<!-- Result -->';
print $conf->global->FCKEDITOR_TEST;
*/
}
// End of page

View File

@ -409,7 +409,8 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/fichinter/doc/");
$realpath = $reldir."core/modules/fichinter/doc";
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -480,6 +481,8 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);

View File

@ -355,7 +355,8 @@ foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/holiday".$valdir);
$realpath = $reldir."core/modules/holiday".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -429,7 +430,9 @@ foreach ($dirmodels as $reldir)
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);

View File

@ -83,7 +83,7 @@ if ($action == 'update')
{
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"], 'chaine', 0, '', $conf->entity);
@ -241,13 +241,14 @@ print '</tr>';
// Default language
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 2);
print '<input class="button" type="submit" name="submit" value="'.$langs->trans("Save").'">';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Multilingual GUI
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1);
print ajax_constantonoff('MAIN_MULTILANGS');
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';

View File

@ -51,14 +51,14 @@ if ($action == 'setvalue' && $user->admin)
$error = 0;
$db->begin();
if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group"), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
//if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++;
//if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',GETPOST("fieldname", 'alphanohtml'),'chaine',0,'',$conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++;
// This one must be after the others
$valkey = '';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2009-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -32,31 +32,37 @@ $langs->loadLangs(array('companies', 'products', 'admin'));
if (! $user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$currencycode = GETPOST('currencycode', 'alpha');
$mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(! empty($currencycode)?'_'.$currencycode:'');
$mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT'.(! empty($currencycode)?'_'.$currencycode:'');
$mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN'.(! empty($currencycode)?'_'.$currencycode:'');
$mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(! empty($currencycode)?'_'.$currencycode:'');
if ($action == 'update')
{
$error=0;
$MAXDEC=8;
if ($_POST["MAIN_MAX_DECIMALS_UNIT"] > $MAXDEC
|| $_POST["MAIN_MAX_DECIMALS_TOT"] > $MAXDEC
|| $_POST["MAIN_MAX_DECIMALS_SHOWN"] > $MAXDEC)
$error=0;
$MAXDEC=8;
if ($_POST[$mainmaxdecimalsunit] > $MAXDEC
|| $_POST[$mainmaxdecimalstot] > $MAXDEC
|| $_POST[$mainmaxdecimalsshown] > $MAXDEC)
{
$error++;
setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors');
}
if ($_POST["MAIN_MAX_DECIMALS_UNIT"] < 0
|| $_POST["MAIN_MAX_DECIMALS_TOT"] < 0
|| $_POST["MAIN_MAX_DECIMALS_SHOWN"] < 0)
if ($_POST[$mainmaxdecimalsunit].(! empty($currencycode)?'_'.$currencycode:'') < 0
|| $_POST[$mainmaxdecimalstot] < 0
|| $_POST[$mainmaxdecimalsshown] < 0)
{
$langs->load("errors");
$error++;
setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors');
}
if ($_POST["MAIN_ROUNDING_RULE_TOT"])
if ($_POST[$mainroundingruletot])
{
if ($_POST["MAIN_ROUNDING_RULE_TOT"] * pow(10, $_POST["MAIN_MAX_DECIMALS_TOT"]) < 1)
if ($_POST[$mainroundingruletot] * pow(10, $_POST[$mainmaxdecimalstot]) < 1)
{
$langs->load("errors");
$error++;
@ -66,22 +72,21 @@ if ($action == 'update')
if (! $error)
{
dolibarr_set_const($db, "MAIN_MAX_DECIMALS_UNIT", $_POST["MAIN_MAX_DECIMALS_UNIT"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TOT", $_POST["MAIN_MAX_DECIMALS_TOT"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAX_DECIMALS_SHOWN", $_POST["MAIN_MAX_DECIMALS_SHOWN"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalsunit, $_POST[$mainmaxdecimalsunit], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalstot, $_POST[$mainmaxdecimalstot], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalsshown, $_POST[$mainmaxdecimalsshown], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_ROUNDING_RULE_TOT", $_POST["MAIN_ROUNDING_RULE_TOT"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainroundingruletot, $_POST[$mainroundingruletot], 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(! empty($currencycode)?'&currencycode='.$currencycode:''));
exit;
}
}
/*
* View
*/
*/
$form=new Form($db);
@ -89,6 +94,31 @@ llxHeader();
print load_fiche_titre($langs->trans("LimitsSetup"), '', 'title_setup');
$currencycode = (! empty($currencycode)?$currencycode:$conf->currency);
$aCurrencies = array($conf->currency); // Default currency always first position
if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
$sql = 'SELECT rowid, code FROM '.MAIN_DB_PREFIX.'multicurrency';
$sql.= ' WHERE entity = '.$conf->entity;
$sql.= ' AND code != "'.$conf->currency.'"'; // Default currency always first position
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql))
{
$aCurrencies[] = $obj->code;
}
}
if (! empty($aCurrencies) && count($aCurrencies) > 1)
{
$head = multicurrencyLimitPrepareHead($aCurrencies);
dol_fiche_head($head, $currencycode, '', -1, "multicurrency");
}
}
print '<span class="opacitymedium">'.$langs->trans("LimitsDesc")."</span><br>\n";
print "<br>\n";
@ -98,29 +128,29 @@ if ($action == 'edit')
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
print '<input type="hidden" name="currencycode" value="'.$currencycode.'">';
}
clearstatcache();
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly"));
print '</td><td><input class="flat" name="MAIN_MAX_DECIMALS_UNIT" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_UNIT . '"></td></tr>';
print '</td><td><input class="flat" name="'.$mainmaxdecimalsunit.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalsunit)?$conf->global->$mainmaxdecimalsunit:$conf->global->MAIN_MAX_DECIMALS_UNIT).'"></td></tr>';
print '<tr><td>';
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
print '</td><td><input class="flat" name="MAIN_MAX_DECIMALS_TOT" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_TOT . '"></td></tr>';
print '</td><td><input class="flat" name="'.$mainmaxdecimalstot.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalstot)?$conf->global->$mainmaxdecimalstot:$conf->global->MAIN_MAX_DECIMALS_TOT).'"></td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td>';
print '<td><input class="flat" name="'.$mainmaxdecimalsshown.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalsshown)?$conf->global->$mainmaxdecimalsshown:$conf->global->MAIN_MAX_DECIMALS_SHOWN).'"></td></tr>';
print '<tr><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td><td><input class="flat" name="MAIN_MAX_DECIMALS_SHOWN" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_SHOWN . '"></td></tr>';
print '<tr><td>';
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
print '</td><td><input class="flat" name="MAIN_ROUNDING_RULE_TOT" size="3" value="' . $conf->global->MAIN_ROUNDING_RULE_TOT . '"></td></tr>';
print '</td><td><input class="flat" name="'.$mainroundingruletot.'" size="3" value="'.(isset($conf->global->$mainroundingruletot)?$conf->global->$mainroundingruletot:$conf->global->MAIN_ROUNDING_RULE_TOT).'"></td></tr>';
print '</table>';
@ -138,31 +168,35 @@ else
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly"));
print '</td><td class="right">'.$conf->global->MAIN_MAX_DECIMALS_UNIT.'</td></tr>';
print '</td><td align="right">'.(isset($conf->global->$mainmaxdecimalsunit)?$conf->global->$mainmaxdecimalsunit:$conf->global->MAIN_MAX_DECIMALS_UNIT).'</td></tr>';
print '<tr><td>';
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
print '</td><td class="right">'.$conf->global->MAIN_MAX_DECIMALS_TOT.'</td></tr>';
print '</td><td align="right">'.(isset($conf->global->$mainmaxdecimalstot)?$conf->global->$mainmaxdecimalstot:$conf->global->MAIN_MAX_DECIMALS_TOT).'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td>';
print '<td align="right">'.(isset($conf->global->$mainmaxdecimalsshown)?$conf->global->$mainmaxdecimalsshown:$conf->global->MAIN_MAX_DECIMALS_SHOWN).'</td></tr>';
print '<tr><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td><td class="right">'.$conf->global->MAIN_MAX_DECIMALS_SHOWN.'</td></tr>';
print '<tr><td>';
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
print '</td><td class="right">'.$conf->global->MAIN_ROUNDING_RULE_TOT.'</td></tr>';
print '</td><td align="right">'.(isset($conf->global->$mainroundingruletot)?$conf->global->$mainroundingruletot:$conf->global->MAIN_ROUNDING_RULE_TOT).'</td></tr>';
print '</table>';
print '<div class="tabsAction tabsActionNoBottom">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit'.(! empty($currencycode)?'&currencycode='.$currencycode:'').'">'.$langs->trans("Modify").'</a>';
print '</div>';
}
if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
{
if (! empty($aCurrencies) && count($aCurrencies) > 1)
{
dol_fiche_end();
}
}
if (empty($mysoc->country_code))
{
@ -197,7 +231,6 @@ else
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
// Add vat rates examples specific to country
$vat_rates=array();

View File

@ -637,7 +637,7 @@ else
$liste['user'] = $langs->trans('UserEmail');
$liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
$sql.= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')';
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')';
$resql = $db->query($sql);
if ($resql)
{

View File

@ -108,9 +108,9 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1),
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
);
}
}
@ -451,7 +451,7 @@ foreach ($object->fields as $key => $val)
elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
}
elseif (! preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print '</td>';
}
}
@ -555,10 +555,10 @@ while ($i < ($limit ? min($num, $limit) : $num))
// Action column
print '<td class="nowrap center">';
$url = $_SERVER["PHP_SELF"].'?action=list&id='.$obj->rowid;
if ($limit) $url.='&limit='.urlencode($limit);
if ($page) $url.='&page='.urlencode($page);
if ($sortfield) $url.='&sortfield='.urlencode($sortfield);
if ($sortorder) $url.='&page='.urlencode($sortorder);
if ($limit) $url .= '&limit='.urlencode($limit);
if ($page) $url .= '&page='.urlencode($page);
if ($sortfield) $url .= '&sortfield='.urlencode($sortfield);
if ($sortorder) $url .= '&page='.urlencode($sortorder);
//print '<a class="reposition" href="'.$url.'&action=edit">'.img_edit().'</a>';
//print ' &nbsp; ';
print '<a href="'.$url.'&action=delete">'.img_delete().'</a> &nbsp; ';

View File

@ -333,7 +333,7 @@ if (empty($reshook))
if ($i) $sql .= ", ";
$sql .= $field."=";
if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && ! GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work
if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work
elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";

View File

@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
// Load translation files required by the page
$langs->loadLangs(array("other", "admin"));
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
if (!$user->admin) accessforbidden();
$dirstandard = array();
@ -64,12 +66,12 @@ if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler");
if ($action == 'update')
{
if (!$_POST['cancel'])
if (!$cancel)
{
$leftmenu = ''; $mainmenu = '';
if (!empty($_POST['menuIdParent']) && !is_numeric($_POST['menuIdParent']))
if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha')))
{
$tmp = explode('&', $_POST['menuIdParent']);
$tmp = explode('&', GETPOST('menuIdParent', 'alpha'));
foreach ($tmp as $s)
{
if (preg_match('/fk_mainmenu=/', $s))
@ -138,7 +140,7 @@ if ($action == 'update')
if ($action == 'add')
{
if ($_POST['cancel'])
if ($cancel)
{
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
exit;

View File

@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
@ -48,14 +48,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstmrp=GETPOST('maskconstMo', 'alpha');
$maskmrp=GETPOST('maskMo', 'alpha');
$maskconstmrp = GETPOST('maskconstMo', 'alpha');
$maskmrp = GETPOST('maskMo', 'alpha');
if ($maskconstmrp) $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -67,20 +67,20 @@ if ($action == 'updateMask')
elseif ($action == 'specimen')
{
$modele=GETPOST('module', 'alpha');
$modele = GETPOST('module', 'alpha');
$mo = new MO($db);
$mrp->initAsSpecimen();
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound=1;
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
@ -156,9 +156,9 @@ elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK')
$draft = GETPOST("MRP_MO_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "MRP_MO_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -170,13 +170,13 @@ elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK')
elseif ($action == 'set_MRP_MO_FREE_TEXT')
{
$freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string
$freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "MRP_MO_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -191,13 +191,13 @@ elseif ($action == 'set_MRP_MO_FREE_TEXT')
* View
*/
$form=new Form($db);
$form = new Form($db);
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader("", $langs->trans("MrpSetupPage"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup');
$head = mrpAdminPrepareHead();
@ -230,18 +230,18 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file)-3, 3) == 'php')
if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
@ -252,9 +252,9 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp=$module->getExample();
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
@ -271,22 +271,22 @@ foreach ($dirmodels as $reldir)
}
print '</td>';
$mrp=new MO($db);
$mrp = new MO($db);
$mrp->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$mrp->type=0;
$nextval=$module->getNextValue($mysoc, $mrp);
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$mrp->type = 0;
$nextval = $module->getNextValue($mysoc, $mrp);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
@ -314,14 +314,14 @@ print load_fiche_titre($langs->trans("MOsModelModule"), '', '');
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$type."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -349,43 +349,43 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/mrp".$valdir);
$realpath = $reldir."core/modules/mrp".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
$handle=opendir($dir);
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
$filelist[]=$file;
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified)
{
$var = !$var;
print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name);
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -420,15 +420,17 @@ foreach ($dirmodels as $reldir)
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">';
@ -472,18 +474,18 @@ print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
$htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="set_MRP_MO_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename='MRP_MO_FREE_TEXT';
$variablename = 'MRP_MO_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@ -491,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else
{
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create();
}
print '</td><td class="right">';

View File

@ -53,6 +53,7 @@ if ($action == 'setvalue' && $user->admin)
if (!$error && is_array($_POST))
{
//var_dump($_POST);
$reg = array();
foreach ($_POST as $key => $val)
{
if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue;

View File

@ -24,7 +24,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
use OAuth\Common\Storage\DoliStorage;
@ -59,9 +59,18 @@ if ($action == 'setconst' && $user->admin)
{
$error = 0;
$db->begin();
foreach ($_POST['setupdriver'] as $setupconst) {
$setupconstarray = GETPOST('setupdriver', 'array');
foreach ($setupconstarray as $setupconst) {
//print '<pre>'.print_r($setupconst, true).'</pre>';
$result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity);
$constname = dol_escape_htmltag($setupconst['varname']);
$constvalue = dol_escape_htmltag($setupconst['value']);
$consttype = dol_escape_htmltag($setupconst['type']);
$constnote = dol_escape_htmltag($setupconst['note']);
$result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
if (!$result > 0) $error++;
}
@ -119,6 +128,9 @@ $head = oauthadmin_prepare_head();
dol_fiche_head($head, 'tokengeneration', '', -1, 'technic');
if (GETPOST('error')) {
setEventMessages(GETPOST('error'), null, 'errors');
}
if ($mode == 'setup' && $user->admin)
{
@ -135,17 +147,21 @@ if ($mode == 'setup' && $user->admin)
if ($key[0] == 'OAUTH_GITHUB_NAME')
{
$OAUTH_SERVICENAME = 'GitHub';
$state='user,public_repo'; // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service)
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state='.$state.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect.
$shortscope = 'user,public_repo';
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/';
}
elseif ($key[0] == 'OAUTH_GOOGLE_NAME')
{
$OAUTH_SERVICENAME = 'Google';
$state='userinfo_email,userinfo_profile,cloud_print'; // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service)
//$state.=',gmail_full';
$urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state='.$state.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect.
$shortscope = 'userinfo_email,userinfo_profile,cloud_print';
//$scope.=',gmail_full';
$urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions';
}

View File

@ -41,13 +41,13 @@ $extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='commande'; //Must be the $table_element of the class that manage extrafield
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commande'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
@ -64,11 +64,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
$textobject=$langs->transnoentitiesnoconv("Orders");
$textobject = $langs->transnoentitiesnoconv("Orders");
llxHeader('', $langs->trans("OrdersSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
$head = order_admin_prepare_head();
@ -108,7 +108,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
if ($action == 'edit' && !empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -42,13 +42,13 @@ $extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='commandedet'; //Must be the $table_element of the class that manage extrafield
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commandedet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
@ -65,11 +65,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
$textobject=$langs->transnoentitiesnoconv("Orders");
$textobject = $langs->transnoentitiesnoconv("Orders");
llxHeader('', $langs->trans("OrdersSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
$head = order_admin_prepare_head();
@ -109,7 +109,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
if ($action == 'edit' && !empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -58,12 +58,13 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", $_POST["MAIN_PROFID5_IN_ADDRESS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", $_POST["MAIN_PROFID6_IN_ADDRESS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", $_POST["MAIN_TVAINTRA_NOT_IN_ADDRESS"], 'chaine', 0, '', $conf->entity);
@ -79,6 +80,9 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
}
@ -295,6 +299,16 @@ print '<tr class="oddeven"><td>'.$langs->trans("ShowDetailsInPDFPageFoot").'</td
print $form->selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS);
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").'</td><td>';
//if (! empty($conf->global->MAIN_MULTILANGS))
//{
print $formadmin->select_language(GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : $conf->global->PDF_USE_ALSO_LANGUAGE_CODE, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1);
//} else {
// print '<span class="opacitymedium">'.$langs->trans("MultiLangNotEnabled").'</span>';
//}
print '</td></tr>';
print '</table>';
print '</div>';

View File

@ -35,6 +35,8 @@ $action = GETPOST('action', 'aZ09');
if (!$user->admin) accessforbidden();
$entity=$conf->entity;
/*
* Actions
@ -70,14 +72,12 @@ print '<span class="opacitymedium">'.$langs->trans("DefaultRightsDesc")." ".$lan
$db->begin();
// Charge les modules soumis a permissions
// Search all modules with permission and reload permissions def.
$modules = array();
$modulesdir = dolGetModulesDirs();
foreach ($modulesdir as $dir)
{
// Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>";
$handle = @opendir(dol_osencode($dir));
if (is_resource($handle))
{
@ -102,7 +102,7 @@ foreach ($modulesdir as $dir)
// Load all permissions
if ($objMod->rights_class)
{
$ret = $objMod->insert_permissions(0);
$ret = $objMod->insert_permissions(0, $entity);
$modules[$objMod->rights_class] = $objMod;
//print "modules[".$objMod->rights_class."]=$objMod;";
}
@ -122,35 +122,58 @@ dol_fiche_head($head, 'default', $langs->trans("Security"), -1);
// Show warning about external users
print info_admin(showModulesExludedForExternal($modules)).'<br>'."\n";
print "\n";
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
// Show permissions lines
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
print '<td class="center">&nbsp;</td>';
print '<td class="center">'.$langs->trans("Default").'</td>';
print '<td>'.$langs->trans("Permissions").'</td>';
print '</tr>'."\n";
//print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS;
$sql = "SELECT r.id, r.libelle as label, r.module, r.module_position, r.perms, r.subperms, r.bydefault";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND r.entity = ".$entity;
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
$sql .= " ORDER BY r.module, r.id";
$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$oldmod = "";
$oldmod = '';
while ($i < $num)
{
$obj = $db->fetch_object($result);
// Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
if (!$modules[$obj->module])
// If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
if (empty($modules[$obj->module]))
{
$i++;
continue;
}
// Save field module_position in database if value is still zero
if (empty($obj->module_position))
{
if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0))
{
// TODO Define familyposition
$family = $modules[$obj->module]->family_position;
$familyposition = 0;
$sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.",";
$sqlupdate.= " family_position = ".$familyposition;
$sqlupdate.= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'";
$db->query($sqlupdate);
}
}
// Check if permission we found is inside a module definition. If not, we discard it.
$found = false;
foreach ($modules[$obj->module]->rights as $key => $val)
@ -169,49 +192,65 @@ if ($result)
}
// Break found, it's a new module to catch
if ($oldmod <> $obj->module)
if (isset($obj->module) && ($oldmod <> $obj->module))
{
$oldmod = $obj->module;
// Break detected, we get objMod
$objMod = $modules[$obj->module];
$picto = ($objMod->picto ? $objMod->picto : 'generic');
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
print '<td>'.$langs->trans("Permission").'</td>';
print '<td class="center">'.$langs->trans("Default").'</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
// Show break line
print '<tr class="oddeven trforbreak">';
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'"></a>';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>'."\n";
}
$perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label));
print '<tr class="oddeven">';
print '<td>';
print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'">&nbsp;</a>';
// Picto and label of module
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
//print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
//print '<a name="'.$objMod->getName().'">&nbsp;</a>';
print '</td>';
$perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->libelle));
// Tick
if ($obj->bydefault == 1)
{
print '<td>';
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&amp;action=remove">'.img_edit_remove().'</a>';
print '</td>';
print '<td class="center">';
print img_picto($langs->trans("Active"), 'tick');
print '</td>';
}
else
{
print '<td>';
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&amp;action=add">'.img_edit_add().'</a>';
print '</td>';
print '<td class="center">';
print '&nbsp;';
print '</td>';
}
// Permission and tick
print '<td>'.$perm_libelle.'</td>';
print '<td class="center">';
if ($obj->bydefault == 1)
{
print img_picto($langs->trans("Active"), 'tick');
print '</td><td>';
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&amp;action=remove">'.img_edit_remove().'</a>';
}
else
{
print '&nbsp;';
print '</td><td>';
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&amp;action=add">'.img_edit_add().'</a>';
}
print '</tr>'."\n";
print '</td></tr>';
$i++;
}
}
else dol_print_error($db);
print '</table>';
print '</div>';

View File

@ -271,7 +271,7 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/propale/");
$dir = dol_buildpath($reldir."core/modules/propale");
if (is_dir($dir))
{
@ -284,7 +284,7 @@ foreach ($dirmodels as $reldir)
{
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
require_once $dir.'/'.$file.'.php';
$module = new $file;
@ -399,7 +399,8 @@ foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/propale".$valdir);
$realpath = $reldir."core/modules/propale".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -474,7 +475,9 @@ foreach ($dirmodels as $reldir)
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);

View File

@ -221,7 +221,7 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/reception/");
$dir = dol_buildpath($reldir."core/modules/reception");
if (is_dir($dir))
{
@ -234,7 +234,7 @@ foreach ($dirmodels as $reldir)
{
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
require_once $dir.'/'.$file.'.php';
$module = new $file;
@ -353,7 +353,8 @@ foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/reception".$valdir);
$realpath = $reldir."core/modules/reception".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -427,7 +428,9 @@ foreach ($dirmodels as $reldir)
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);

View File

@ -29,12 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
$langs->loadLangs(array("users","admin","other"));
$langs->loadLangs(array("users", "admin", "other"));
if (! $user->admin)
if (!$user->admin)
accessforbidden();
$action=GETPOST('action', 'alpha');
$action = GETPOST('action', 'alpha');
@ -44,8 +44,8 @@ $action=GETPOST('action', 'alpha');
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{
$code=$reg[1];
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
$code = $reg[1];
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
@ -56,7 +56,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
dol_print_error($db);
}
} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
$code=$reg[1];
$code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
@ -70,8 +70,8 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
elseif ($action == 'updateform')
{
$res1=dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", $_POST["MAIN_APPLICATION_TITLE"], 'chaine', 0, '', $conf->entity);
$res2=dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"], 'chaine', 0, '', $conf->entity);
$res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
$res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
if ($res1 && $res2) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
@ -83,7 +83,7 @@ elseif ($action == 'updateform')
$form = new Form($db);
$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
llxHeader('', $langs->trans("Miscellaneous"), $wikihelp);
print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
@ -97,7 +97,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updateform">';
$head=security_prepare_head();
$head = security_prepare_head();
dol_fiche_head($head, 'misc', $langs->trans("Security"), -1);
@ -115,7 +115,7 @@ print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
print '<td class="right">';
if (function_exists("imagecreatefrompng"))
{
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
}
@ -142,7 +142,7 @@ print '</td></tr>';
print '<tr class="oddeven">';
print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
print '<td class="right">';
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
}
@ -173,8 +173,8 @@ print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
$sessiontimeout=ini_get("session.gc_maxlifetime");
if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT=$sessiontimeout;
$sessiontimeout = ini_get("session.gc_maxlifetime");
if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor")));
@ -185,8 +185,8 @@ print '</td>';
print '</tr>';
$sessiontimeout=ini_get("session.gc_maxlifetime");
if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATION_TITLE="";
$sessiontimeout = ini_get("session.gc_maxlifetime");
if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATION_TITLE = "";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
print '</td>';

View File

@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("companies", "admin", "products", "sms", "other", "errors"));
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
if (!$user->admin)
accessforbidden();
@ -46,14 +48,13 @@ $action = GETPOST('action', 'aZ09');
* Actions
*/
if ($action == 'update' && empty($_POST["cancel"]))
if ($action == 'update' && !$cancel)
{
dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", $_POST["MAIN_DISABLE_ALL_SMS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", GETPOST("MAIN_DISABLE_ALL_SMS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SMS_SENDMODE", $_POST["MAIN_SMS_SENDMODE"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SMS_SENDMODE", GETPOST("MAIN_SMS_SENDMODE", 'alphahtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", $_POST["MAIN_MAIL_SMS_FROM"], 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", GETPOST("MAIN_MAIL_SMS_FROM", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@ -68,15 +69,15 @@ if ($action == 'send' && !$_POST['cancel'])
$error = 0;
$smsfrom = '';
if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms");
if (empty($smsfrom)) $smsfrom = GETPOST("fromname");
$sendto = GETPOST("sendto");
$body = GETPOST('message');
$deliveryreceipt = GETPOST("deliveryreceipt");
$deferred = GETPOST('deferred');
$priority = GETPOST('priority');
$class = GETPOST('class');
$errors_to = GETPOST("errorstosms");
if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms", 'alphanohtml');
if (empty($smsfrom)) $smsfrom = GETPOST("fromname", 'alphanohtml');
$sendto = GETPOST("sendto", 'alphanohtml');
$body = GETPOST('message', 'alphanohtml');
$deliveryreceipt = GETPOST("deliveryreceipt", 'alphanohtml');
$deferred = GETPOST('deferred', 'alphanohtml');
$priority = GETPOST('priority', 'alphanohtml');
$class = GETPOST('class', 'alphanohtml');
$errors_to = GETPOST("errorstosms", 'alphanohtml');
// Create form object
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php';

View File

@ -35,10 +35,10 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin", "members", "mailmanspip"));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$type=array('yesno','texte','chaine');
$type = array('yesno', 'texte', 'chaine');
$action = GETPOST('action', 'aZ09');
@ -50,25 +50,27 @@ $action = GETPOST('action', 'aZ09');
// Action mise a jour ou ajout d'une constante
if ($action == 'update' || $action == 'add')
{
$constname=GETPOST("constname");
$constvalue=GETPOST("constvalue");
$constnamearray = GETPOST("constname", 'array');
$constvaluearray = GETPOST("constvalue", 'array');
$consttypearray = GETPOST("consttype", 'array');
$constnotearray = GETPOST("constnote", 'array');
// Action mise a jour ou ajout d'une constante
if ($action == 'update' || $action == 'add')
{
foreach($_POST['constname'] as $key => $val)
foreach ($constnamearray as $key => $val)
{
$constname=$_POST["constname"][$key];
$constvalue=$_POST["constvalue"][$key];
$consttype=$_POST["consttype"][$key];
$constnote=$_POST["constnote"][$key];
$constname = dol_escape_htmltag($constnamearray[$key]);
$constvalue = dol_escape_htmltag($constvaluearray[$key]);
$consttype = dol_escape_htmltag($consttypearray[$key]);
$constnote = dol_escape_htmltag($constnotearray[$key]);
$res=dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
$res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
}
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -82,7 +84,7 @@ if ($action == 'update' || $action == 'add')
// Action activation d'un sous module du module adherent
if ($action == 'set')
{
$result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
$result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
if ($result < 0)
{
dol_print_error($db);
@ -92,7 +94,7 @@ if ($action == 'set')
// Action desactivation d'un sous module du module adherent
if ($action == 'unset')
{
$result=dolibarr_del_const($db, $_GET["name"], $conf->entity);
$result = dolibarr_del_const($db, $_GET["name"], $conf->entity);
if ($result < 0)
{
dol_print_error($db);
@ -105,12 +107,12 @@ if ($action == 'unset')
* View
*/
$help_url='';
$help_url = '';
llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setup');
@ -120,7 +122,7 @@ $head = mailmanspip_admin_prepare_head();
/*
* Spip
*/
if (! empty($conf->global->ADHERENT_USE_SPIP))
if (!empty($conf->global->ADHERENT_USE_SPIP))
{
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -129,12 +131,12 @@ if (! empty($conf->global->ADHERENT_USE_SPIP))
dol_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user');
//$link=img_picto($langs->trans("Active"),'tick').' ';
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_SPIP">';
$link = '<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_SPIP">';
//$link.=$langs->trans("Disable");
$link.=img_picto($langs->trans("Activated"), 'switch_on');
$link.='</a>';
$link .= img_picto($langs->trans("Activated"), 'switch_on');
$link .= '</a>';
// Edition des varibales globales
$constantes=array(
$constantes = array(
'ADHERENT_SPIP_SERVEUR',
'ADHERENT_SPIP_DB',
'ADHERENT_SPIP_USER',
@ -156,10 +158,10 @@ else
{
dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
$link='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_SPIP">';
$link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_SPIP">';
//$link.=$langs->trans("Activate");
$link.=img_picto($langs->trans("Disabled"), 'switch_off');
$link.='</a>';
$link .= img_picto($langs->trans("Disabled"), 'switch_off');
$link .= '</a>';
print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
dol_fiche_end();

View File

@ -461,6 +461,7 @@ print "</tr>\n";
print '</table>';
/*
print '<br>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
@ -471,7 +472,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '</tr>'."\n";
// Example with a yes / no select
/*print '<tr class="oddeven">';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'</td>';
print '<td class="center">';
if ($conf->use_javascript_ajax) {
@ -481,10 +482,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print $form->selectarray("INVENTORY_DISABLE_VIRTUAL", $arrval, $conf->global->INVENTORY_DISABLE_VIRTUAL);
}
print '</td></tr>';
*/
// Example with a yes / no select
/*print '<tr class="oddeven">';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'</td>';
print '<td class="center">';
if ($conf->use_javascript_ajax) {
@ -494,7 +495,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print $form->selectarray("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA", $arrval, $conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA);
}
print '</td></tr>';
*/
// Example with a yes / no select
print '<tr class="oddeven">';
@ -507,8 +508,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print $form->selectarray("INVENTORY_USE_INVENTORY_DATE_FOR_DATE_OF_MVT", $arrval, $conf->global->INVENTORY_USE_INVENTORY_DATE_FOR_DATE_OF_MVT);
}
print '</td></tr>';
print '</table>';
}
*/
/* I keep the option/feature, but hidden to end users for the moment. If feature is used by module, no need to have users see it.
If not used by a module, I still need to understand in which case user may need this now we can set rule on product page.

View File

@ -90,7 +90,7 @@ if ($action == 'specimen') // For invoices
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file = dol_buildpath($reldir."core/modules/supplier_invoice/pdf/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/supplier_invoice/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound = 1;
@ -171,7 +171,7 @@ if ($action == 'setmod')
if ($action == 'addcat')
{
$fourn = new Fournisseur($db);
$fourn->CreateCategory($user, $_POST["cat"]);
$fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml'));
}
if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
@ -230,7 +230,7 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/supplier_invoice/");
$dir = dol_buildpath($reldir."core/modules/supplier_invoice");
if (is_dir($dir))
{
@ -243,7 +243,7 @@ foreach ($dirmodels as $reldir)
{
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
require_once $dir.'/'.$file.'.php';
$module = new $file;
@ -360,7 +360,8 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/supplier_invoice/pdf/");
$realpath = $reldir."core/modules/supplier_invoice/doc";
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -385,7 +386,7 @@ foreach ($dirmodels as $reldir)
print (empty($module->name) ? $name : $module->name);
print "</td>\n";
print "<td>\n";
require_once $dir.$file;
require_once $dir.'/'.$file;
$module = new $classname($db, $specimenthirdparty);
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -434,6 +435,8 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);

View File

@ -88,7 +88,7 @@ elseif ($action == 'specimen') // For orders
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file = dol_buildpath($reldir."core/modules/supplier_order/pdf/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/supplier_order/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound = 1;
@ -165,7 +165,7 @@ elseif ($action == 'setmod')
elseif ($action == 'addcat')
{
$fourn = new Fournisseur($db);
$fourn->CreateCategory($user, $_POST["cat"]);
$fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml'));
}
elseif ($action == 'set_SUPPLIER_ORDER_OTHER')
@ -390,7 +390,8 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
$realpath = $reldir."core/modules/supplier_order/doc";
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -413,7 +414,7 @@ foreach ($dirmodels as $reldir)
print (empty($module->name) ? $name : $module->name);
print "</td>\n";
print "<td>\n";
require_once $dir.$file;
require_once $dir.'/'.$file;
$module = new $classname($db, $specimenthirdparty);
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -458,6 +459,8 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);

View File

@ -332,7 +332,8 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/supplier_payment/doc/");
$realpath = $reldir."core/modules/supplier_payment/doc";
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -356,7 +357,7 @@ foreach ($dirmodels as $reldir)
print (empty($module->name) ? $name : $module->name);
print "</td>\n";
print "<td>\n";
require_once $dir.$file;
require_once $dir.'/'.$file;
$module = new $classname($db, $specimenthirdparty);
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -405,6 +406,8 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
print '<td class="center">';

View File

@ -239,7 +239,7 @@ print '</tr>'."\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/supplier_proposal/");
$dir = dol_buildpath($reldir."core/modules/supplier_proposal");
if (is_dir($dir))
{
@ -252,7 +252,7 @@ foreach ($dirmodels as $reldir)
{
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
require_once $dir.'/'.$file.'.php';
$module = new $file;
@ -366,7 +366,8 @@ foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/supplier_proposal".$valdir);
$realpath = $reldir."core/modules/supplier_proposal".$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
@ -440,7 +441,9 @@ foreach ($dirmodels as $reldir)
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);

View File

@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("admin");
$langs->load("install");
$langs->load("errors");
if (! $user->admin)
accessforbidden();
@ -66,21 +68,123 @@ if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2)
print '<br>';
}
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
print "\n";
$ErrorPicturePath = "../../theme/eldy/img/error.png";
$WarningPicturePath = "../../theme/eldy/img/warning.png";
$OkayPicturePath = "../../theme/eldy/img/tick.png";
// Get PHP version
$phpversion=version_php();
print '<tr class="oddeven"><td width="220px">'.$langs->trans("Version")."</td><td>".$phpversion."</td></tr>\n";
print '<tr><td width="220">'.$langs->trans("Version").'</td><td>';
$arrayphpminversionerror = array(5,5,0);
$arrayphpminversionwarning = array(5,5,0);
if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0)
{
print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
}
elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0)
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.versiontostring(versionphparray());
}
print '</td></tr>';
print '<tr><td>GET and POST support</td><td>';
if (! isset($_GET["testget"]) && ! isset($_POST["testpost"]) && ! isset($_GET["mainmenu"]))
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportPOSTGETOk");
}
print '</td></tr>';
print '<tr><td>Sessions support</td><td>';
if (! function_exists("session_id"))
{
print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions");
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportSessions");
}
print '</td></tr>';
print '<tr><td>GD support</td><td>';
if (! function_exists("imagecreate"))
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupportGD");
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportGD");
}
print '</td></tr>';
print '<tr><td>Curl support</td><td>';
if (! function_exists("curl_init"))
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupportCurl");
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportCurl");
}
print '</td></tr>';
print '<tr><td>UTF-8 support</td><td>';
if (! function_exists("utf8_encode"))
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupportUTF8");
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportUTF8");
}
print '</td></tr>';
print '<tr><td>Intl support</td><td>';
if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost')
{
if (! function_exists("locale_get_primary_language") || ! function_exists("locale_get_region"))
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupportIntl");
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportIntl");
}
}
print '<tr><td>Zip support</td><td>';
if (!class_exists('ZipArchive'))
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupport", "Zip");
}
else
{
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupport", "Zip");
}
print '</td></tr>';
print '</table>';
print '<br>';
// Get php_info array
$phparray=phpinfo_array();
foreach($phparray as $key => $value)

View File

@ -209,7 +209,7 @@ print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/ticket/");
$dir = dol_buildpath($reldir."core/modules/ticket");
if (is_dir($dir)) {
$handle = opendir($dir);
@ -219,7 +219,7 @@ foreach ($dirmodels as $reldir) {
$file = $reg[1];
$classname = substr($file, 4);
include_once $dir.$file.'.php';
include_once $dir.'/'.$file.'.php';
$module = new $file;

View File

@ -29,18 +29,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$langs->load("admin");
$action=GETPOST('action', 'alpha');
$action = GETPOST('action', 'alpha');
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="date";
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "date";
if (empty($page) || $page == -1) { $page = 0; }
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
if (! $user->admin)
if (!$user->admin)
accessforbidden();
@ -52,33 +52,33 @@ if ($action == 'delete')
{
if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha')))
{
$file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha'));
$ret=dol_delete_file($file, 1);
$file = $conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha'));
$ret = dol_delete_file($file, 1);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
}
else
{
$file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha'));
$ret=dol_delete_file($file, 1);
$file = $conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha'));
$ret = dol_delete_file($file, 1);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
}
$action='';
$action = '';
}
/*
* View
*/
$form=new Form($db);
$form = new Form($db);
$formfile = new FormFile($db);
$label=$db::LABEL;
$type=$db->type;
$label = $db::LABEL;
$type = $db->type;
//var_dump($db);
$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
$help_url = 'EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
llxHeader('', '', $help_url);
print '<script type="text/javascript">
@ -141,9 +141,9 @@ print '<br>';
print '<div id="backupdatabaseleft" class="fichehalfleft" >';
print load_fiche_titre($title?$title:$langs->trans("BackupDumpWizard"));
print load_fiche_titre($title ? $title : $langs->trans("BackupDumpWizard"));
print '<table width="100%" class="'.($useinecm?'nobordernopadding':'liste').' nohover">';
print '<table width="100%" class="'.($useinecm ? 'nobordernopadding' : 'liste').' nohover">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b><br>';
@ -186,11 +186,11 @@ if (in_array($type, array('mysql', 'mysqli'))) {
print '<div class="formelementrow">'.$langs->trans("FullPathToMysqldumpCommand");
if (empty($conf->global->SYSTEMTOOLS_MYSQLDUMP))
{
$fullpathofmysqldump=$db->getPathOfDump();
$fullpathofmysqldump = $db->getPathOfDump();
}
else
{
$fullpathofmysqldump=$conf->global->SYSTEMTOOLS_MYSQLDUMP;
$fullpathofmysqldump = $conf->global->SYSTEMTOOLS_MYSQLDUMP;
}
print '<br>';
print '<input type="text" name="mysqldump" style="width: 80%" value="'.$fullpathofmysqldump.'" /></div>';
@ -203,7 +203,7 @@ if (in_array($type, array('mysql', 'mysqli'))) {
print '</div>';
if (! empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
print '<div class="formelementrow">';
print '<input type="checkbox" name="disable_fk" value="yes" id="checkbox_disable_fk" checked />';
print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
@ -242,7 +242,7 @@ if (in_array($type, array('mysql', 'mysqli'))) {
print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
print '</legend>';
print '<input type="checkbox" name="drop"'.(((! isset($_GET["drop"]) && ! isset($_POST["drop"])) || GETPOST('drop'))?' checked':'').' id="checkbox_dump_drop" />';
print '<input type="checkbox" name="drop"'.(((!isset($_GET["drop"]) && !isset($_POST["drop"])) || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
print '<br>';
print '</fieldset>';
@ -293,7 +293,7 @@ if (in_array($type, array('mysql', 'mysqli'))) {
print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
print '</div>';
if (! empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
print '<div class="formelementrow">';
print '<input type="checkbox" name="nobin_disable_fk" value="yes" id="checkbox_disable_fk" checked />';
print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
@ -303,7 +303,7 @@ if (in_array($type, array('mysql', 'mysqli'))) {
print '<br>';
print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
print '<input type="checkbox" name="nobin_drop"'.((! isset($_GET["nobin_drop"]) && ! isset($_POST["nobin_drop"])) || GETPOST('nobin_drop'))?' checked':''.' id="checkbox_dump_drop" />';
print '<input type="checkbox" name="nobin_drop"'.((!isset($_GET["nobin_drop"]) && !isset($_POST["nobin_drop"])) || GETPOST('nobin_drop')) ? ' checked' : ''.' id="checkbox_dump_drop" />';
print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
print '<br>';
print '</fieldset>';
@ -338,11 +338,11 @@ if (in_array($type, array('pgsql'))) {
print '<div class="formelementrow">'.$langs->trans("FullPathToPostgreSQLdumpCommand");
if (empty($conf->global->SYSTEMTOOLS_POSTGRESQLDUMP)) {
$fullpathofpgdump=$db->getPathOfDump();
$fullpathofpgdump = $db->getPathOfDump();
}
else
{
$fullpathofpgdump=$conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
$fullpathofpgdump = $conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
}
print '<br>';
print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" /></div>';
@ -391,27 +391,27 @@ print '<legend>'.$langs->trans("Destination").'</legend> -->';
print '<br>';
print '<label for="filename_template">'.$langs->trans("FileNameToGenerate").'</label>';
print '<br>';
$prefix='dump';
$ext='.sql';
$prefix = 'dump';
$ext = '.sql';
if (in_array($type, array('mysql', 'mysqli'))) {
$prefix='mysqldump';
$ext='sql';
$prefix = 'mysqldump';
$ext = 'sql';
}
//if ($label == 'PostgreSQL') {
// $prefix='pg_dump';
// $ext='dump';
//}
if (in_array($type, array('pgsql'))) {
$prefix='pg_dump';
$ext='sql';
$prefix = 'pg_dump';
$ext = 'sql';
}
$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
print '<input type="text" name="filename_template" style="width: 90%" id="filename_template" value="'.$file.'" />';
print '<br>';
print '<br>';
// Define compressions array
$compression=array();
$compression = array();
if (in_array($type, array('mysql', 'mysqli'))) {
$compression['gz'] = array(
'function' => 'gzopen',
@ -488,7 +488,7 @@ print '<input type="hidden" name="page_y" value="'.GETPOST('page_y', 'int').'">'
print '<br>';
print '<br>';
if (! empty($_SESSION["commandbackuplastdone"]))
if (!empty($_SESSION["commandbackuplastdone"]))
{
print '<br><b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n";
print '<textarea rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuplastdone"].'</textarea><br>'."\n";
@ -500,11 +500,11 @@ if (! empty($_SESSION["commandbackuplastdone"]))
print '<b>'.$langs->trans("BackupResult").':</b> ';
print $_SESSION["commandbackupresult"];
$_SESSION["commandbackuplastdone"]='';
$_SESSION["commandbackuptorun"]='';
$_SESSION["commandbackupresult"]='';
$_SESSION["commandbackuplastdone"] = '';
$_SESSION["commandbackuptorun"] = '';
$_SESSION["commandbackupresult"] = '';
}
if (! empty($_SESSION["commandbackuptorun"]))
if (!empty($_SESSION["commandbackuptorun"]))
{
print '<br><font class="warning">'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser", $dolibarr_main_db_user, $dolibarr_main_db_user).':</font><br>'."\n";
print '<textarea id="commandbackuptoruntext" rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuptorun"].'</textarea><br>'."\n";
@ -513,9 +513,9 @@ if (! empty($_SESSION["commandbackuptorun"]))
//print $paramclear;
$_SESSION["commandbackuplastdone"]='';
$_SESSION["commandbackuptorun"]='';
$_SESSION["commandbackupresult"]='';
$_SESSION["commandbackuplastdone"] = '';
$_SESSION["commandbackuptorun"] = '';
$_SESSION["commandbackupresult"] = '';
}
print "</div> <!-- end div center button -->\n";
@ -529,8 +529,8 @@ print "</div> <!-- end div fichehalfleft -->\n";
print '<div id="backupdatabaseright" class="fichehalfright" style="height:480px; overflow: auto;">';
print '<div class="ficheaddleft">';
$filearray=dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC), 1);
$result=$formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles"));
$filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1);
$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles"));
print '<br>';
print '</div>';

View File

@ -28,11 +28,11 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! $user->admin)
if (!$user->admin)
accessforbidden();
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
// Security check
if ($user->socid > 0)
@ -42,10 +42,10 @@ if ($user->socid > 0)
}
// Load translation files required by the page
$langs->loadLangs(array("companies","admin","users","other"));
$langs->loadLangs(array("companies", "admin", "users", "other"));
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -53,8 +53,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="dateevent";
if (! $sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield = "dateevent";
if (!$sortorder) $sortorder = "DESC";
$search_code = GETPOST("search_code", "alpha");
$search_ip = GETPOST("search_ip", "alpha");
@ -63,24 +63,24 @@ $search_desc = GETPOST("search_desc", "alpha");
$search_ua = GETPOST("search_ua", "none");
$search_prefix_session = GETPOST("search_prefix_session", "none");
if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
else $date_start=-1;
if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) $date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
else $date_end=-1;
if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
else $date_start = -1;
if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
else $date_end = -1;
// checks:if date_start>date_end then date_end=date_start + 24 hours
if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end=$date_start+86400;
if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end = $date_start + 86400;
$now = dol_now();
$nowarray = dol_getdate($now);
if (empty($date_start)) // We define date_start and date_end
{
$date_start=dol_get_first_day($nowarray['year'], $nowarray['mon'], false);
$date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false);
}
if (empty($date_end))
{
$date_end=dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']);
$date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']);
}
// Set $date_startmonth...
$tmp = dol_getdate($date_start);
@ -92,56 +92,56 @@ $date_endday = $tmp['mday'];
$date_endmonth = $tmp['mon'];
$date_endyear = $tmp['year'];
$arrayfields=array();
$arrayfields = array();
/*
* Actions
*/
$now=dol_now();
$now = dol_now();
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$date_start=-1;
$date_end=-1;
$search_code='';
$search_ip='';
$search_user='';
$search_desc='';
$search_ua='';
$search_prefix_session='';
$date_start = -1;
$date_end = -1;
$search_code = '';
$search_ip = '';
$search_user = '';
$search_desc = '';
$search_ua = '';
$search_prefix_session = '';
}
// Purge audit events
if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin)
{
$error=0;
$error = 0;
$db->begin();
$securityevents=new Events($db);
$securityevents = new Events($db);
// Delete events
$sql = "DELETE FROM ".MAIN_DB_PREFIX."events";
$sql.= " WHERE entity = ".$conf->entity;
$sql .= " WHERE entity = ".$conf->entity;
dol_syslog("listevents purge", LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
$error++;
setEventMessages($db->lasterror(), null, 'errors');
}
// Add event purge
$text=$langs->trans("SecurityEventsPurged");
$securityevent=new Events($db);
$securityevent->type='SECURITY_EVENTS_PURGE';
$securityevent->dateevent=$now;
$securityevent->description=$text;
$text = $langs->trans("SecurityEventsPurged");
$securityevent = new Events($db);
$securityevent->type = 'SECURITY_EVENTS_PURGE';
$securityevent->dateevent = $now;
$securityevent->description = $text;
$result=$securityevent->create($user);
$result = $securityevent->create($user);
if ($result > 0)
{
$db->commit();
@ -162,26 +162,26 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin)
llxHeader('', $langs->trans("Audit"));
$form=new Form($db);
$form = new Form($db);
$userstatic=new User($db);
$usefilter=0;
$userstatic = new User($db);
$usefilter = 0;
$sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,";
$sql.= " e.fk_user, e.description, e.prefix_session,";
$sql.= " u.login";
$sql.= " FROM ".MAIN_DB_PREFIX."events as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
$sql.= " WHERE e.entity IN (".getEntity('event').")";
if ($date_start > 0) $sql.= " AND e.dateevent >= '".$db->idate($date_start)."'";
if ($date_end > 0) $sql.= " AND e.dateevent <= '".$db->idate($date_end)."'";
if ($search_code) { $usefilter++; $sql.=natural_search("e.type", $search_code, 0); }
if ($search_ip) { $usefilter++; $sql.=natural_search("e.ip", $search_ip, 0); }
if ($search_user) { $usefilter++; $sql.=natural_search("u.login", $search_user, 0); }
if ($search_desc) { $usefilter++; $sql.=natural_search("e.description", $search_desc, 0); }
if ($search_ua) { $usefilter++; $sql.=natural_search("e.user_agent", $search_ua, 0); }
if ($search_prefix_session) { $usefilter++; $sql.=natural_search("e.prefix_session", $search_prefix_session, 0); }
$sql.= $db->order($sortfield, $sortorder);
$sql .= " e.fk_user, e.description, e.prefix_session,";
$sql .= " u.login";
$sql .= " FROM ".MAIN_DB_PREFIX."events as e";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
$sql .= " WHERE e.entity IN (".getEntity('event').")";
if ($date_start > 0) $sql .= " AND e.dateevent >= '".$db->idate($date_start)."'";
if ($date_end > 0) $sql .= " AND e.dateevent <= '".$db->idate($date_end)."'";
if ($search_code) { $usefilter++; $sql .= natural_search("e.type", $search_code, 0); }
if ($search_ip) { $usefilter++; $sql .= natural_search("e.ip", $search_ip, 0); }
if ($search_user) { $usefilter++; $sql .= natural_search("u.login", $search_user, 0); }
if ($search_desc) { $usefilter++; $sql .= natural_search("e.description", $search_desc, 0); }
if ($search_ua) { $usefilter++; $sql .= natural_search("e.user_agent", $search_ua, 0); }
if ($search_prefix_session) { $usefilter++; $sql .= natural_search("e.prefix_session", $search_prefix_session, 0); }
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
@ -196,7 +196,7 @@ $nbtotalofrecords = '';
}
}*/
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$sql .= $db->plimit($conf->liste_limit + 1, $offset);
//print $sql;
$result = $db->query($sql);
if ($result)
@ -204,27 +204,27 @@ if ($result)
$num = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($search_code) $param.='&search_code='.urlencode($search_code);
if ($search_ip) $param.='&search_ip='.urlencode($search_ip);
if ($search_user) $param.='&search_user='.urlencode($search_user);
if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_ua) $param.='&search_ua='.urlencode($search_ua);
if ($search_prefix_sessiona) $param.='&search_prefix_session='.urlencode($search_prefix_session);
if ($date_startmonth) $param.= "&date_startmonth=".urlencode($date_startmonth);
if ($date_startday) $param.= "&date_startday=".urlencode($date_startday);
if ($date_startyear) $param.= "&date_startyear=".urlencode($date_startyear);
if ($date_endmonth) $param.= "&date_endmonth=".urlencode($date_endmonth);
if ($date_endday) $param.= "&date_endday=".urlencode($date_endday);
if ($date_endyear) $param.= "&date_endyear=".urlencode($date_endyear);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_code) $param .= '&search_code='.urlencode($search_code);
if ($search_ip) $param .= '&search_ip='.urlencode($search_ip);
if ($search_user) $param .= '&search_user='.urlencode($search_user);
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc);
if ($search_ua) $param .= '&search_ua='.urlencode($search_ua);
if ($search_prefix_sessiona) $param .= '&search_prefix_session='.urlencode($search_prefix_session);
if ($date_startmonth) $param .= "&date_startmonth=".urlencode($date_startmonth);
if ($date_startday) $param .= "&date_startday=".urlencode($date_startday);
if ($date_startyear) $param .= "&date_startyear=".urlencode($date_startyear);
if ($date_endmonth) $param .= "&date_endmonth=".urlencode($date_endmonth);
if ($date_endday) $param .= "&date_endday=".urlencode($date_endday);
if ($date_endyear) $param .= "&date_endyear=".urlencode($date_endyear);
$langs->load('withdrawals');
if ($num)
{
$center='<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=purge">'.$langs->trans("Purge").'</a>';
$center = '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=purge">'.$langs->trans("Purge").'</a>';
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -233,7 +233,7 @@ if ($result)
if ($action == 'purge')
{
$formquestion=array();
$formquestion = array();
print $form->formconfirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('PurgeAuditEvents'), $langs->trans('ConfirmPurgeAuditEvents'), 'confirm_purge', $formquestion, 'no', 1);
}
@ -262,14 +262,14 @@ if ($result)
//print '<input class="flat maxwidth100" type="text" size="10" name="search_desc" value="'.$search_desc.'">';
print '</td>';
if (! empty($arrayfields['e.user_agent']['checked']))
if (!empty($arrayfields['e.user_agent']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_ua" value="'.$search_ua.'">';
print '</td>';
}
if (! empty($arrayfields['e.prefix_session']['checked']))
if (!empty($arrayfields['e.prefix_session']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.$search_prefix_session.'">';
@ -277,7 +277,7 @@ if ($result)
}
print '<td class="liste_titre maxwidthsearch">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
@ -290,11 +290,11 @@ if ($result)
print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['e.user_agent']['checked']))
if (!empty($arrayfields['e.user_agent']['checked']))
{
print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder);
}
if (! empty($arrayfields['e.prefix_session']['checked']))
if (!empty($arrayfields['e.prefix_session']['checked']))
{
print_liste_field_titre("PrefixSession", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder);
}
@ -322,8 +322,8 @@ if ($result)
print '<td class="nowrap">';
if ($obj->fk_user)
{
$userstatic->id=$obj->fk_user;
$userstatic->login=$obj->login;
$userstatic->id = $obj->fk_user;
$userstatic->login = $obj->login;
print $userstatic->getLoginUrl(1);
}
else print '&nbsp;';
@ -331,18 +331,18 @@ if ($result)
// Description
print '<td>';
$text=$langs->trans($obj->description);
$text = $langs->trans($obj->description);
$reg = array();
if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg))
{
$val=explode(',', $reg[1]);
$text=$langs->trans($val[0], isset($val[1])?$val[1]:'', isset($val[2])?$val[2]:'', isset($val[3])?$val[3]:'', isset($val[4])?$val[4]:'');
if (! empty($reg[2])) $text.=$reg[2];
$val = explode(',', $reg[1]);
$text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : '');
if (!empty($reg[2])) $text .= $reg[2];
}
print dol_escape_htmltag($text);
print '</td>';
if (! empty($arrayfields['e.user_agent']['checked']))
if (!empty($arrayfields['e.user_agent']['checked']))
{
// User agent
print '<td>';
@ -350,7 +350,7 @@ if ($result)
print '</td>';
}
if (! empty($arrayfields['e.prefix_session']['checked']))
if (!empty($arrayfields['e.prefix_session']['checked']))
{
// User agent
print '<td>';
@ -360,8 +360,8 @@ if ($result)
// More informations
print '<td class="right">';
$htmltext='<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
$htmltext.='<br><b>'.$langs->trans("PrefixSession").'</b>: '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
$htmltext = '<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
$htmltext .= '<br><b>'.$langs->trans("PrefixSession").'</b>: '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
print $form->textwithpicto('', $htmltext);
print '</td>';

View File

@ -34,13 +34,13 @@ require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
// Load translation files required by the page
$langs->loadlangs(array('errors', 'admin', 'companies', 'website'));
$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view';
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view';
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$rowid=GETPOST('rowid', 'alpha');
$rowid = GETPOST('rowid', 'alpha');
$id=1;
$id = 1;
if (!$user->admin) accessforbidden();
@ -52,7 +52,7 @@ $actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$status = 1;
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -65,55 +65,55 @@ $pagenext = $page + 1;
$hookmanager->initHooks(array('website'));
// Name of SQL tables of dictionaries
$tabname=array();
$tabname = array();
$tabname[1] = MAIN_DB_PREFIX."website";
// Dictionary labels
$tablib=array();
$tablib = array();
$tablib[1] = "Websites";
// Requests to extract data
$tabsql=array();
$tabsql = array();
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.status FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
// Criteria to sort dictionaries
$tabsqlsort=array();
$tabsqlsort[1] ="ref ASC";
$tabsqlsort = array();
$tabsqlsort[1] = "ref ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
$tabfield = array();
$tabfield[1] = "ref,description,virtualhost";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
$tabfieldvalue = array();
$tabfieldvalue[1] = "ref,description,virtualhost";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
$tabfieldinsert = array();
$tabfieldinsert[1] = "ref,description,virtualhost,entity";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array();
$tabrowid = array();
$tabrowid[1] = "";
// Condition to show dictionary in setup page
$tabcond=array();
$tabcond[1] = (! empty($conf->website->enabled));
$tabcond = array();
$tabcond[1] = (!empty($conf->website->enabled));
// List of help for fields
$tabhelp=array();
$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'));
$tabhelp = array();
$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
$tabfieldcheck[1] = array();
$tabfieldcheck = array();
$tabfieldcheck[1] = array();
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
$sourceList=array();
$sourceList = array();
/*
@ -123,35 +123,35 @@ $sourceList=array();
// Actions add or modify a website
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{
$listfield=explode(',', $tabfield[$id]);
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
$listfield = explode(',', $tabfield[$id]);
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
$ok = 1;
foreach ($listfield as $f => $value)
{
if ($value == 'ref' && (! isset($_POST[$value]) || $_POST[$value]==''))
if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == ''))
{
$ok=0;
$fieldnamekey=$listfield[$f];
$ok = 0;
$fieldnamekey = $listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
break;
}
elseif ($value == 'ref' && ! preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
elseif ($value == 'ref' && !preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
{
$ok=0;
$fieldnamekey=$listfield[$f];
$ok = 0;
$fieldnamekey = $listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors');
break;
}
}
// Clean parameters
if (! empty($_POST['ref']))
if (!empty($_POST['ref']))
{
$websitekey=strtolower($_POST['ref']);
$websitekey = strtolower($_POST['ref']);
}
// Si verif ok et action add, on ajoute la ligne
@ -160,13 +160,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
$newid = ($obj->newid + 1);
} else {
dol_print_error($db);
}
@ -181,16 +181,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",status)";
$sql.= " VALUES(";
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $tabrowid[$id].",";
$sql .= $tabfieldinsert[$id];
$sql .= ",status)";
$sql .= " VALUES(";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $newid.",";
$i=0;
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $newid.",";
$i = 0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'entity') {
@ -199,19 +199,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($value == 'ref') {
$_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]);
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
$sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
unset($_POST); // Clean $_POST array, we keep only
unset($_POST); // Clean $_POST array, we keep only
}
else
{
@ -227,22 +227,22 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
$db->begin();
$website=new Website($db);
$rowid=GETPOST('rowid', 'int');
$website = new Website($db);
$rowid = GETPOST('rowid', 'int');
$website->fetch($rowid);
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
$sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
@ -250,13 +250,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
$sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
@ -266,8 +266,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09'));
if ($newname != $website->ref)
{
$srcfile=DOL_DATA_ROOT.'/website/'.$website->ref;
$destfile=DOL_DATA_ROOT.'/website/'.$newname;
$srcfile = DOL_DATA_ROOT.'/website/'.$website->ref;
$destfile = DOL_DATA_ROOT.'/website/'.$newname;
if (dol_is_dir($destfile))
{
@ -294,7 +294,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
setEventMessages($db->lasterror(), null, 'errors');
}
if (! $error)
if (!$error)
{
$db->commit();
}
@ -313,8 +313,8 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
$website = new Website($db);
$website->fetch($rowid);
@ -332,7 +332,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
$result = $db->query($sql);
if (! $result)
if (!$result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
@ -358,8 +358,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid ='".$rowid."'";
@ -375,8 +375,8 @@ if ($action == $acts[0])
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid ='".$rowid."'";
@ -396,16 +396,16 @@ if ($action == $acts[1])
*/
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
llxHeader('', $langs->trans("WebsiteSetup"));
$titre=$langs->trans("WebsiteSetup");
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
$titre = $langs->trans("WebsiteSetup");
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($titre, $linkback, 'title_setup');
// Onglets
$head=array();
$head = array();
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/website.php";
@ -428,7 +428,7 @@ print "<br>\n";
// Confirmation de la suppression de la ligne
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1);
}
//var_dump($elementList);
@ -438,12 +438,12 @@ if ($action == 'delete')
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
$sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($limit+1, $offset);
$sql = $tabsql[$id];
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
//print $sql;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -452,10 +452,10 @@ if ($id)
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$var=false;
$alabelisused = 0;
$var = false;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
@ -463,15 +463,15 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$align='';
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
$align = '';
if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($valuetoshow != '')
{
print '<td class="'.$align.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (! empty($tabhelp[$id][$value]))
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (!empty($tabhelp[$id][$value]))
{
if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual');
else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
@ -479,7 +479,7 @@ if ($id)
else print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
}
print '<td colspan="4">';
@ -496,7 +496,7 @@ if ($id)
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val, 'alpha'))
$obj->$val=GETPOST($val);
$obj->$val = GETPOST($val);
}
}
@ -510,7 +510,7 @@ if ($id)
print '</td>';
print "</tr>";
$colspan=count($fieldlist)+2;
$colspan = count($fieldlist) + 2;
}
print '</table>';
@ -518,7 +518,7 @@ if ($id)
// List of websites in database
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -540,10 +540,10 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // Par defaut
$align="left";
$sortable=1;
$valuetoshow='';
$showfield = 1; // Par defaut
$align = "left";
$sortable = 1;
$valuetoshow = '';
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
@ -551,20 +551,20 @@ if ($id)
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); }
if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
// Affiche nom du champ
if ($showfield)
{
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), "", "align=".$align, $sortfield, $sortorder);
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder);
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page?'page='.$page.'&':''), "", 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print '</tr>';
@ -575,34 +575,34 @@ if ($id)
$obj = $db->fetch_object($resql);
//print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit');
print '<td colspan="3" class="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
}
else
{
$tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$align="left";
$fieldname=$fieldlist[$field];
$valuetoshow=$obj->$fieldname;
$showfield = 1;
$align = "left";
$fieldname = $fieldlist[$field];
$valuetoshow = $obj->$fieldname;
// Show value for field
if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
@ -610,14 +610,14 @@ if ($id)
}
// Can an entry be erased or disabled ?
$iserasable=1; $isdisable=1; // true by default
if ($obj->status) $iserasable=0; // We can't delete a website on. Disable it first.
$iserasable = 1; $isdisable = 1; // true by default
if ($obj->status) $iserasable = 0; // We can't delete a website on. Disable it first.
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;';
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&amp;code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&amp;';
// Active
print '<td align="center" class="nowrap">';
print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status?1:0)].'">'.$actl[($obj->status?1:0)].'</a>';
print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'">'.$actl[($obj->status ? 1 : 0)].'</a>';
print "</td>";
// Modify link
@ -660,10 +660,10 @@ $db->close();
*/
function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '')
{
global $conf,$langs,$db;
global $conf, $langs, $db;
global $form;
global $region_id;
global $elementList,$sourceList,$localtax_typeList;
global $elementList, $sourceList, $localtax_typeList;
global $bc;
$formadmin = new FormAdmin($db);
@ -678,18 +678,18 @@ function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '')
print '</td>';
}
elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldname)?$obj->$fieldname:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
print '<td><input type="text" class="flat" value="'.(!empty($obj->$fieldname) ? $obj->$fieldname : '').'" size="10" name="'.$fieldlist[$field].'"></td>';
}
else
{
print '<td>';
$size='';
if ($fieldlist[$field]=='code') $size='size="8" ';
if ($fieldlist[$field]=='position') $size='size="4" ';
if ($fieldlist[$field]=='libelle') $size='size="32" ';
if ($fieldlist[$field]=='tracking') $size='size="92" ';
if ($fieldlist[$field]=='sortorder') $size='size="2" ';
print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname)?$obj->$fieldname:'').'" name="'.$fieldlist[$field].'">';
$size = '';
if ($fieldlist[$field] == 'code') $size = 'size="8" ';
if ($fieldlist[$field] == 'position') $size = 'size="4" ';
if ($fieldlist[$field] == 'libelle') $size = 'size="32" ';
if ($fieldlist[$field] == 'tracking') $size = 'size="92" ';
if ($fieldlist[$field] == 'sortorder') $size = 'size="2" ';
print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname) ? $obj->$fieldname : '').'" name="'.$fieldlist[$field].'">';
print '</td>';
}
}

View File

@ -25,6 +25,8 @@
* \file htdocs/api/admin/explorer.php
*/
use Luracast\Restler\Routes;
require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';

View File

@ -60,10 +60,9 @@ class Documents extends DolibarrApi
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf)
* @return array List of documents
*
* @throws 400
* @throws 401
* @throws 404
* @throws 200
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
*
* @url GET /download
*/
@ -118,12 +117,11 @@ class Documents extends DolibarrApi
* @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language).
* @return array List of documents
*
* @throws 500
* @throws 501
* @throws 400
* @throws 401
* @throws 404
* @throws 200
* @throws RestException 500
* @throws RestException 501
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
*
* @url PUT /builddoc
*/
@ -237,11 +235,10 @@ class Documents extends DolibarrApi
* @param string $sortorder Sort order ('asc' or 'desc')
* @return array Array of documents with path
*
* @throws 200
* @throws 400
* @throws 401
* @throws 404
* @throws 500
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
* @throws RestException 500
*
* @url GET /
*/
@ -275,6 +272,23 @@ class Documents extends DolibarrApi
$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
}
elseif ($modulepart == 'user')
{
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
// Can get doc if has permission to read all user or if it is user itself
if (!DolibarrApiAccess::$user->rights->user->user->lire && DolibarrApiAccess::$user->id != $id) {
throw new RestException(401);
}
$object = new User($this->db);
$result = $object->fetch($id, $ref);
if (!$result) {
throw new RestException(404, 'User not found');
}
$upload_dir = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id;
}
elseif ($modulepart == 'adherent' || $modulepart == 'member')
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
@ -430,11 +444,10 @@ class Documents extends DolibarrApi
* @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return string
*
* @throws 200
* @throws 400
* @throws 401
* @throws 404
* @throws 500
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
* @throws RestException 500
*
* @url POST /upload
*/
@ -610,10 +623,9 @@ class Documents extends DolibarrApi
* @param string $original_file Relative path with filename, relative to modulepart (for example: PRODUCT-REF-999/IMAGE-999.jpg)
* @return array List of documents
*
* @throws 400
* @throws 401
* @throws 404
* @throws 200
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
*
* @url DELETE /
*/

View File

@ -48,9 +48,8 @@ class Login
* @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access)
* @return array Response status and user token
*
* @throws 200
* @throws 403
* @throws 500
* @throws RestException 403
* @throws RestException 500
*
* @url GET /
* @url POST /

View File

@ -59,8 +59,7 @@ class Setup extends DolibarrApi
*
* @return array [List of ordering methods]
*
* @throws 400 RestException
* @throws 200 OK
* @throws RestException 400
*/
public function getOrderingMethods($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -121,8 +120,7 @@ class Setup extends DolibarrApi
*
* @return array [List of payment types]
*
* @throws 400 RestException
* @throws 200 OK
* @throws RestException 400
*/
public function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -339,8 +337,7 @@ class Setup extends DolibarrApi
*
* @return array [List of availability]
*
* @throws 400 RestException
* @throws 200 OK
* @throws RestException 400
*/
public function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -908,8 +905,7 @@ class Setup extends DolibarrApi
*
* @return array List of payment terms
*
* @throws 400 RestException
* @throws 200 OK
* @throws RestException 400
*/
public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -969,8 +965,7 @@ class Setup extends DolibarrApi
*
* @return array List of shipping methods
*
* @throws 400 RestException
* @throws 200 OK
* @throws RestException 400
*/
public function getShippingModes($limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{

View File

@ -82,7 +82,7 @@ class Asset extends CommonObject
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text",),
'amount_ht' => array('type'=>'double(24,8)', 'label'=>'AmountHTShort', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",),
'amount_vat' => array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",),
'fk_asset_type' => array('type'=>'integer:AssetType:asset/class/asset.class.php', 'label'=>'AssetsType', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",),
'fk_asset_type' => array('type'=>'integer:AssetType:asset/class/asset_type.class.php', 'label'=>'AssetsType', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",),
'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>90, 'notnull'=>-1,),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>-1,),

View File

@ -68,7 +68,18 @@ class AssetType extends CommonObject
public $note;
/** @var array Array of asset */
public $asset=array();
public $asset = array();
public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
'label' =>array('type'=>'varchar(50)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25, 'showoncombobox'=>1),
'accountancy_code_asset' =>array('type'=>'varchar(32)', 'label'=>'Accountancy code asset', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
'accountancy_code_depreciation_asset' =>array('type'=>'varchar(32)', 'label'=>'Accountancy code depreciation asset', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
'accountancy_code_depreciation_expense' =>array('type'=>'varchar(32)', 'label'=>'Accountancy code depreciation expense', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
'note' =>array('type'=>'mediumtext', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
);
/**
@ -93,9 +104,9 @@ class AssetType extends CommonObject
{
global $conf;
$error=0;
$error = 0;
$this->label=trim($this->label);
$this->label = trim($this->label);
$this->accountancy_code_asset = trim($this->accountancy_code_asset);
$this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset);
$this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense);
@ -103,20 +114,20 @@ class AssetType extends CommonObject
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type (";
$sql.= "label";
$sql.= ", accountancy_code_asset";
$sql.= ", accountancy_code_depreciation_asset";
$sql.= ", accountancy_code_depreciation_expense";
$sql.= ", note";
$sql.= ", entity";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->label)."'";
$sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'";
$sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'";
$sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'";
$sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
$sql .= "label";
$sql .= ", accountancy_code_asset";
$sql .= ", accountancy_code_depreciation_asset";
$sql .= ", accountancy_code_depreciation_expense";
$sql .= ", note";
$sql .= ", entity";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->escape($this->accountancy_code_asset)."'";
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'";
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'";
$sql .= ", '".$this->db->escape($this->note)."'";
$sql .= ", ".$conf->entity;
$sql .= ")";
dol_syslog("Asset_type::create", LOG_DEBUG);
$result = $this->db->query($sql);
@ -131,15 +142,15 @@ class AssetType extends CommonObject
return -3;
}
if (! $notrigger)
if (!$notrigger)
{
// Call trigger
$result=$this->call_trigger('ASSET_TYPE_CREATE', $user);
$result = $this->call_trigger('ASSET_TYPE_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return $this->id;
@ -153,7 +164,7 @@ class AssetType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
@ -170,45 +181,45 @@ class AssetType extends CommonObject
{
global $conf, $hookmanager;
$error=0;
$error = 0;
$this->label=trim($this->label);
$this->label = trim($this->label);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."asset_type ";
$sql.= "SET ";
$sql.= "label = '".$this->db->escape($this->label) ."',";
$sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',";
$sql.= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',";
$sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',";
$sql.= "note = '".$this->db->escape($this->note) ."'";
$sql.= " WHERE rowid =".$this->id;
$sql .= "SET ";
$sql .= "label = '".$this->db->escape($this->label)."',";
$sql .= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',";
$sql .= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',";
$sql .= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',";
$sql .= "note = '".$this->db->escape($this->note)."'";
$sql .= " WHERE rowid =".$this->id;
$result = $this->db->query($sql);
if ($result)
{
$action='update';
$action = 'update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
if (!$error && !$notrigger)
{
// Call trigger
$result=$this->call_trigger('ASSET_TYPE_MODIFY', $user);
$result = $this->call_trigger('ASSET_TYPE_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return 1;
@ -222,7 +233,7 @@ class AssetType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
@ -240,13 +251,13 @@ class AssetType extends CommonObject
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type";
$sql.= " WHERE rowid = ".$this->id;
$sql .= " WHERE rowid = ".$this->id;
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
// Call trigger
$result=$this->call_trigger('ASSET_TYPE_DELETE', $user);
$result = $this->call_trigger('ASSET_TYPE_DELETE', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
// End call triggers
@ -256,7 +267,7 @@ class AssetType extends CommonObject
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -275,7 +286,7 @@ class AssetType extends CommonObject
dol_syslog("Asset_type::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
@ -295,7 +306,7 @@ class AssetType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -309,15 +320,15 @@ class AssetType extends CommonObject
public function liste_array()
{
// phpcs:enable
global $conf,$langs;
global $conf, $langs;
$assettypes = array();
$sql = "SELECT rowid, label as label";
$sql.= " FROM ".MAIN_DB_PREFIX."asset_type";
$sql.= " WHERE entity IN (".getEntity('asset_type').")";
$sql .= " FROM ".MAIN_DB_PREFIX."asset_type";
$sql .= " WHERE entity IN (".getEntity('asset_type').")";
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
@ -354,13 +365,13 @@ class AssetType extends CommonObject
{
global $conf, $user;
$ret=array();
$ret = array();
$sql = "SELECT a.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."asset as a";
$sql.= " WHERE a.entity IN (".getEntity('asset').")";
$sql.= " AND a.fk_asset_type = ".$this->id;
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')';
$sql .= " FROM ".MAIN_DB_PREFIX."asset as a";
$sql .= " WHERE a.entity IN (".getEntity('asset').")";
$sql .= " AND a.fk_asset_type = ".$this->id;
if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -368,31 +379,31 @@ class AssetType extends CommonObject
{
while ($obj = $this->db->fetch_object($resql))
{
if (! array_key_exists($obj->rowid, $ret))
if (!array_key_exists($obj->rowid, $ret))
{
if ($mode < 2)
{
$assetstatic=new Asset($this->db);
$assetstatic = new Asset($this->db);
if ($mode == 1) {
$assetstatic->fetch($obj->rowid, '', '', '', false, false);
} else {
$assetstatic->fetch($obj->rowid);
}
$ret[$obj->rowid]=$assetstatic;
$ret[$obj->rowid] = $assetstatic;
}
else $ret[$obj->rowid]=$obj->rowid;
else $ret[$obj->rowid] = $obj->rowid;
}
}
$this->db->free($resql);
$this->asset=$ret;
$this->asset = $ret;
return $ret;
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -409,15 +420,15 @@ class AssetType extends CommonObject
{
global $langs;
$result='';
$label=$langs->trans("ShowTypeCard", $this->label);
$result = '';
$label = $langs->trans("ShowTypeCard", $this->label);
$linkstart = '<a href="'.DOL_URL_ROOT.'/asset/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label, $maxlen):$this->label);
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
$result .= $linkend;
return $result;
@ -437,13 +448,13 @@ class AssetType extends CommonObject
// Initialize parameters
$this->id = 0;
$this->ref = 'ATSPEC';
$this->specimen=1;
$this->specimen = 1;
$this->label='ASSET TYPE SPECIMEN';
$this->note='This is a note';
$this->label = 'ASSET TYPE SPECIMEN';
$this->note = 'This is a note';
// Assets of this asset type is just me
$this->asset=array(
$this->asset = array(
$user->id => $user
);
}

View File

@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
// Load translation files required by the page
$langs->loadLangs(array("assets"));
$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
@ -50,7 +50,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -63,6 +63,7 @@ $hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules co
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
//$extrafields->fetch_name_optionals_label($object->table_element_line);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
@ -70,9 +71,9 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
if (!$sortorder) $sortorder = "ASC";
// Protection if external user
// Security check
$socid = 0;
if ($user->socid > 0)
if ($user->socid > 0) // Protection if external user
{
//$socid = $user->socid;
accessforbidden();
@ -84,7 +85,7 @@ $search_all = trim(GETPOST("search_all", 'alpha'));
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
}
// List of fields to search into when doing a "search in all"
@ -99,26 +100,33 @@ $arrayfields = array();
foreach ($object->fields as $key => $val)
{
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
);
}
}
}
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
$permissiontoread = $user->rights->asset->read;
$permissiontoadd = $user->rights->asset->write;
$permissiontodelete = $user->rights->asset->delete;
/*
* Actions
*
* Put here all code to do according to value of "$action" parameter
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
@ -152,8 +160,6 @@ if (empty($reshook))
// Mass actions
$objectclass = 'Asset';
$objectlabel = 'Asset';
$permissiontoread = $user->rights->asset->read;
$permissiontodelete = $user->rights->asset->delete;
$uploaddir = $conf->asset->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -162,8 +168,6 @@ if (empty($reshook))
/*
* View
*
* Put here all code to render page
*/
$form = new Form($db);
@ -183,23 +187,30 @@ foreach ($object->fields as $key => $val)
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label']))
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('assets').")";
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
else $sql .= " WHERE 1 = 1";
foreach ($search as $key => $val)
{
if ($key == 'status' && $search[$key] == -1) continue;
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = '';
$mode_search = 2;
}
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@ -216,10 +227,12 @@ foreach($object->fields as $key => $val)
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql=preg_replace('/,\s*$/','', $sql);
*/
$sql .= $db->order($sortfield, $sortorder);
@ -228,28 +241,35 @@ $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
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0;
$offset = 0;
}
}
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if (!$resql)
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
{
dol_print_error($db);
exit;
$num = $nbtotalofrecords;
}
else
{
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if (!$resql)
{
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
}
$num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
@ -285,7 +305,8 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&co
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
foreach ($search as $key => $val)
{
$param .= '&search_'.$key.'='.urlencode($search[$key]);
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
else $param .= '&search_'.$key.'='.urlencode($search[$key]);
}
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
@ -296,19 +317,11 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->asset->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';
if ($user->rights->asset->write)
{
$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/card.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAsset').'</span>';
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton .= '</a>';
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
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">';
@ -318,6 +331,8 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton = dolGetButtonTitle($langs->trans('NewAsset'), '', 'fa fa-plus-circle', dol_buildpath('/asset/card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accountancy', 0, $newcardbutton, '', $limit);
// Add code for pre mass action (confirmation or email presend form)
@ -363,11 +378,21 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val)
{
$align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap';
if ($key == 'status') $align .= ($align ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
}
elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print '</td>';
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@ -387,118 +412,103 @@ print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
if (is_array($extrafields->attributes[$object->table_element]['computed'])) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (preg_match('/\$object/', $val)) {
// There is at least one compute field that use $object
$needToFetchEachLine++;
}
}
$needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
}
}
// Loop on record
// --------------------------------------------------------------------
$i=0;
$totalarray=array();
while ($i < min($num, $limit))
$i = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) break; // Should not happen
// Store properties in $object
$object->id = $obj->rowid;
foreach($object->fields as $key => $val)
{
if (property_exists($obj, $key)) $object->$key = $obj->$key;
}
$object->setVarsFromFetchObj($obj);
// Show here line of result
print '<tr class="oddeven">';
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
print '<td';
if ($align) print ' class="'.$align.'"';
print '>';
print $object->showOutputField($val, $key, $obj->$key, '');
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') print $object->getLibStatut(5);
else print $object->showOutputField($val, $key, $object->$key, '');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
if (!$i) $totalarray['nbfield']++;
if (!empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
$totalarray['val']['t.'.$key] += $object->$key;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowrap" align="center">';
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
if (in_array($object->id, $arrayofselected)) $selected = 1;
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
print '</tr>';
print '</tr>'."\n";
$i++;
}
// Show total line
if (isset($totalarray['pos']))
{
print '<tr class="liste_total">';
$i = 0;
while ($i < $totalarray['nbfield'])
{
$i++;
if (!empty($totalarray['pos'][$i])) print '<td class="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else
{
if ($i == 1)
{
if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>';
else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
}
else print '<td></td>';
}
}
print '</tr>';
}
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
@ -522,25 +532,21 @@ print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
$filedir = $diroutputmassaction;
$genallowed = $user->rights->asset->read;
$delallowed = $user->rights->asset->create;
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '');
}
else
{
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
}
$filedir = $diroutputmassaction;
$genallowed = $permissiontoread;
$delallowed = $permissiontoadd;
print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '');
}
// End of page

View File

@ -609,37 +609,15 @@ if ($rowid > 0)
print $object->showOptionals($extrafields, 'edit', $parameters);
}
print '</table>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
// Extra field
if (empty($reshook))
{
print '<br><br><table class="border centpercent">';
foreach ($extrafields->attributes[$object->element]['label'] as $key=>$label)
{
if (isset($_POST["options_".$key])) {
if (is_array($_POST["options_".$key])) {
// $_POST["options"] is an array but following code expects a comma separated string
$value = implode(",", $_POST["options_".$key]);
} else {
$value = $_POST["options_".$key];
}
} else {
$value = $adht->array_options["options_".$key];
}
print '<tr><td width="30%">'.$label.'</td><td>';
print $extrafields->showInputField($key, $value);
print "</td></tr>\n";
}
print '</table><br><br>';
}
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>";

View File

@ -28,9 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","other","blockedlog"));
$langs->loadLangs(array("admin", "other", "blockedlog"));
if (! $user->admin || empty($conf->blockedlog->enabled)) accessforbidden();
if (!$user->admin || empty($conf->blockedlog->enabled)) accessforbidden();
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
@ -40,11 +40,12 @@ $backtopage = GETPOST('backtopage', 'alpha');
* Actions
*/
$reg = array();
if (preg_match('/set_(.*)/', $action, $reg))
{
$code=$reg[1];
$code = $reg[1];
$values = GETPOST($code);
if(is_array($values))$values = implode(',', $values);
if (is_array($values)) $values = implode(',', $values);
if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0)
{
@ -59,7 +60,7 @@ if (preg_match('/set_(.*)/', $action, $reg))
if (preg_match('/del_(.*)/', $action, $reg))
{
$code=$reg[1];
$code = $reg[1];
if (dolibarr_del_const($db, $code, 0) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
@ -76,22 +77,22 @@ if (preg_match('/del_(.*)/', $action, $reg))
* View
*/
$form=new Form($db);
$form = new Form($db);
$block_static = new BlockedLog($db);
llxHeader('', $langs->trans("BlockedLogSetup"));
$linkback='';
$linkback = '';
if (GETPOST('withtab', 'alpha'))
{
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
}
print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'), $linkback);
if (GETPOST('withtab', 'alpha'))
{
$head=blockedlogadmin_prepare_head();
$head = blockedlogadmin_prepare_head();
dol_fiche_head($head, 'blockedlog', '', -1);
}
@ -134,16 +135,16 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">';
$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
$sql.= " FROM ".MAIN_DB_PREFIX."c_country";
$sql.= " WHERE active > 0";
$sql .= " FROM ".MAIN_DB_PREFIX."c_country";
$sql .= " WHERE active > 0";
$countryArray=array();
$resql=$db->query($sql);
$countryArray = array();
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql))
{
$countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
}
}
@ -159,8 +160,8 @@ print '</td>';
print '<tr class="oddeven">';
print '<td class="titlefield">';
print $langs->trans("ListOfTrackedEvents").'</td><td>';
$arrayoftrackedevents=$block_static->trackedevents;
foreach($arrayoftrackedevents as $key => $val)
$arrayoftrackedevents = $block_static->trackedevents;
foreach ($arrayoftrackedevents as $key => $val)
{
print $key.' - '.$langs->trans($val).'<br>';
}

View File

@ -747,7 +747,7 @@ class BOM extends CommonObject
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (isset($this->status)) {
$label.= '<br><b>' . $langs->trans("Status").":</b> ".$this->getLibStatut(5);
$label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5);
}
$url = dol_buildpath('/bom/bom_card.php', 1).'?id='.$this->id;

View File

@ -109,7 +109,7 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
}
$coldisplay++;
print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(isset($_POST["qty"]) ?GETPOST("qty", 'alpha', 2) : 1).'">';
print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(GETPOSTISSET("qty") ? GETPOST("qty", 'alpha', 2) : 1).'">';
print '</td>';
if ($conf->global->PRODUCT_USE_UNITS)
@ -141,7 +141,7 @@ print '</td>';
print '</tr>';
if (is_object($objectline)) {
print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1);
print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1);
}
?>

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