Merge branch 'develop' of github.com:OPEN-DSI/dolibarr into new-propal-tooltip-note
This commit is contained in:
commit
48297759fb
10
.github/ISSUE_TEMPLATE/custom.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/custom.md
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Custom issue template
|
||||
about: Describe this issue template's purpose here.
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -254,6 +254,7 @@ before_script:
|
||||
fi
|
||||
- sudo a2enmod rewrite actions fastcgi alias
|
||||
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
- echo "extension = libzip.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
- 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
|
||||
@ -285,7 +286,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 --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --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
|
||||
|
||||
|
||||
53
ChangeLog
53
ChangeLog
@ -21,9 +21,10 @@ Following changes may create regressions for some external modules, but were nec
|
||||
***** ChangeLog for 11.0.0 compared to 10.0.0 *****
|
||||
For Users:
|
||||
|
||||
NEW: Module BOM is now stable (Module MO - Manufacturing Order is still in development).
|
||||
NEW: Module BOM is now stable.
|
||||
NEW: Module MO (Manufacturing Order) is available with experimental status.
|
||||
NEW: Can set the Address/Contact by default on third parties.
|
||||
NEW: Add a dictionary for list of Social networks
|
||||
NEW: Add a dictionary to edit list of Social networks.
|
||||
NEW: A nicer dashboard for open elements on Home page.
|
||||
NEW: Add task widget and add task progress bar
|
||||
NEW: Support of deployment of metapackages
|
||||
@ -152,6 +153,7 @@ NEW: #4301
|
||||
|
||||
For Developers or integrators:
|
||||
|
||||
NEW: Compatible with PHP 7.4
|
||||
NEW: Code for extrafields uses the new array $extrafields->attributes
|
||||
NEW: Can set a filter on object linked in modulebuilder.
|
||||
NEW: Can defined a position of numbering submodules for thirdparties
|
||||
@ -226,6 +228,53 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core.
|
||||
|
||||
|
||||
***** ChangeLog for 10.0.6 compared to 10.0.5 *****
|
||||
FIX Regression of 10.0.5 to create/edit proposals and orders.
|
||||
FIX: #12760 #12763 #12755 #12765 #12751
|
||||
FIX: add product qty in shipment already sent (fix for option STOCK_CALCULATE_ON_SHIPMENT_NEW)
|
||||
FIX: an issue that shows all entities stock
|
||||
FIX: class Facture undefined in displaying margin information
|
||||
FIX: error 500 when getting margin info for objects other than invoices
|
||||
FIX: Loan card - Wrong language key used
|
||||
FIX: Missing language key for MAIN_MAXTABS_IN_CARD
|
||||
FIX: product with empty stock were not visible
|
||||
FIX: remove backward compatibility projectid and uses object id instead
|
||||
FIX: Some issues on salary payment
|
||||
FIX: Some problems on conciliation with others modules
|
||||
FIX: typo on language key
|
||||
FIX: url new for task time spent in project element tab
|
||||
FIX: uses GETPOSTISSET instead of GETPOST for projectfield
|
||||
FIX: var transkey not defined in input hidden
|
||||
FIX: wrong var name and avoid warning
|
||||
|
||||
***** ChangeLog for 10.0.5 compared to 10.0.4 *****
|
||||
FIX: 10.0: add URL param "restore_last_search_values=1" to all backlinks pointing to lists
|
||||
FIX: 10.0: do not display single-letter values (indicating duration unit without value) in product list
|
||||
FIX: #12473
|
||||
FIX: #12481 : fix ticket creation from thirdparty, mission $socid var
|
||||
FIX: #12482
|
||||
FIX: #12644
|
||||
FIX: #12665 Mass invoice validation with stock management
|
||||
FIX: #12688
|
||||
FIX: #12745
|
||||
FIX: add and modify category translate form with posted values on errors
|
||||
FIX: add URL param "restore_last_search_values=1" to all backlinks that point to a list
|
||||
FIX: CommandeFournisseurLigne update function must not be able to return other value than 1 if success
|
||||
FIX: contact card state address selected after filling address
|
||||
FIX: dol_string_nohtmltag when there is html with windows EOL "<br>\r\n"
|
||||
FIX: filter language is an array
|
||||
FIX: first col at wrong position in Export 2007 (new)
|
||||
FIX: getrights() request
|
||||
FIX: Invoice Situation integration into Margin
|
||||
FIX: missing nl2br conversion
|
||||
FIX: not fee in payout list
|
||||
FIX: product_fourn_price_id was assigned too late for logPrice() function
|
||||
FIX: Reduce number of request for list of products
|
||||
FIX: set due date in object in create invoice
|
||||
FIX: units traductions for selectUnits() function
|
||||
FIX: when we need to bill several orders, order lines unit is not on bill lines
|
||||
NEW: 9.0: allow users to use the mysqldump '--quick' option
|
||||
|
||||
***** ChangeLog for 10.0.4 compared to 10.0.3 *****
|
||||
FIX: The pdf templates were using the large logo making PDF too large (and edition of proposal, order, invoice VERY slow)
|
||||
FIX: #12258
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
# DOLIBARR ERP & CRM
|
||||
|
||||

|
||||

|
||||
|
||||
Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans).
|
||||
Il est simple d'utilisation et modulaire, vous permettant de n'activez que les fonctions dont vous avez besoin (contacts, fournisseurs, factures, commandes, stocks, agenda, ...).
|
||||
|
||||

|
||||

|
||||
|
||||
## LICENCE
|
||||
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
# DOLIBARR ERP & CRM
|
||||
|
||||

|
||||
|
||||
|7|8|9|10|develop|
|
||||
|----------|----------|----------|----------|----------|
|
||||
||||||
|
||||

|
||||
|
||||
Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…).
|
||||
|
||||
@ -14,7 +11,7 @@ You can freely use, study, modify or distribute it according to its Free Softwar
|
||||
|
||||
You can use it as a standalone application or as a web application to be able to access it from the Internet or a LAN.
|
||||
|
||||

|
||||

|
||||
|
||||
## LICENSE
|
||||
|
||||
|
||||
@ -231,3 +231,8 @@ $dolibarr_main_prod='0';
|
||||
# Default value: 0 (use database value if exist)
|
||||
# Examples:
|
||||
# $dolibarr_mailing_limit_sendbycli='0';
|
||||
|
||||
# dolibarr_distrib
|
||||
# A key to identify the distribution used for first installation
|
||||
$dolibarr_distrib = 'deb';
|
||||
|
||||
|
||||
@ -1 +1,2 @@
|
||||
htdocs/install/doctemplates/websites/website_template-corporate.zip
|
||||
htdocs/install/doctemplates/websites/website_template-corporate.zip
|
||||
htdocs/install/doctemplates/websites/website_template-stellar.zip
|
||||
@ -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 \
|
||||
|
||||
@ -110,7 +110,7 @@ Source: "C:\Program Files\Wamp\bin\mysql\mysql5.0.45\*.*"; DestDir: "{app}\bin\m
|
||||
; Mysql data files (does not overwrite if exists)
|
||||
Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mysql\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db"
|
||||
; Dolibarr
|
||||
Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,nltechno*\*,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php"
|
||||
Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,nltechno*\*,sabre\sabre\*\tests,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php"
|
||||
Source: "dev\*.*"; DestDir: "{app}\www\dolibarr\dev"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,dbmodel\*,fpdf\*,initdata\*,initdemo\*,iso-normes\*,licence\*,phpcheckstyle\*,phpunit\*,samples\*,test\*,uml\*,vagrant\*,xdebug\*"
|
||||
Source: "doc\*.*"; DestDir: "{app}\www\dolibarr\doc"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,wiki\*,plaquette\*,dev\*,images\dolibarr_screenshot2.png,images\dolibarr_screenshot3.png,images\dolibarr_screenshot4.png,images\dolibarr_screenshot5.png,images\dolibarr_screenshot6.png,images\dolibarr_screenshot7.png,images\dolibarr_screenshot8.png,images\dolibarr_screenshot9.png,images\dolibarr_screenshot10.png,images\dolibarr_screenshot11.png,images\dolibarr_screenshot12.png"
|
||||
Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,product\materiel.net.php,product\import-product.php"
|
||||
|
||||
@ -146,7 +146,7 @@ $iterator1 = new RecursiveIteratorIterator($dir_iterator1);
|
||||
$files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom?'':'custom\/|').'documents\/|conf\/|install\/))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
|
||||
*/
|
||||
$regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
|
||||
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
|
||||
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
|
||||
$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
|
||||
$dir='';
|
||||
$needtoclose=0;
|
||||
|
||||
231
dev/initdata/dbf/import-dbf.php
Normal file
231
dev/initdata/dbf/import-dbf.php
Normal 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";
|
||||
}
|
||||
241
dev/initdata/dbf/importdb-products.php
Normal file
241
dev/initdata/dbf/importdb-products.php
Normal 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);
|
||||
355
dev/initdata/dbf/importdb-thirdparties.php
Normal file
355
dev/initdata/dbf/importdb-thirdparties.php
Normal 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);
|
||||
402
dev/initdata/dbf/includes/dbase.class.php
Normal file
402
dev/initdata/dbf/includes/dbase.class.php
Normal 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();
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -64,6 +64,10 @@ $sqls=array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement_facture where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement where rowid NOT IN (SELECT fk_paiement FROM ".MAIN_DB_PREFIX."paiement_facture)",
|
||||
),
|
||||
'supplier_payment'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn where fk_facturefourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn where rowid NOT IN (SELECT fk_paiementfourn FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn)",
|
||||
),
|
||||
'bank'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
@ -103,6 +107,7 @@ $sqls=array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__'",
|
||||
),
|
||||
'supplier_invoice'=>array(
|
||||
'@supplier_payment',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det WHERE fk_facture_fourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__'",
|
||||
),
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@ -16,7 +16,9 @@ then
|
||||
echo "This pull remote transifex files to local dir."
|
||||
echo "Note: If you pull a language file (not source), file will be skipped if local file is newer."
|
||||
echo " Using -f will overwrite local file (does not work with 'all')."
|
||||
echo "Usage: ./dev/translation/txpull.sh (all|xx_XX) [-r dolibarr.file] [-f] [-s]"
|
||||
echo " Using -s will force fetching of source file (avoid it, use en_US as language instead)."
|
||||
echo " Using en_US as language parameter will update source language from transifex (en_US is excluded from 'all')."
|
||||
echo "Usage: ./dev/translation/txpull.sh (all|en_US|xx_XX) [-r dolibarr.file] [-f] [-s]"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
@ -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
|
||||
@ -41,6 +41,7 @@ $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');
|
||||
@ -64,6 +65,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'),
|
||||
@ -95,7 +97,8 @@ if (empty($reshook))
|
||||
{
|
||||
$search_account = "";
|
||||
$search_label = "";
|
||||
$search_accountparent = "";
|
||||
$search_labelshort = "";
|
||||
$search_accountparent = "";
|
||||
$search_pcgtype = "";
|
||||
$search_pcgsubtype = "";
|
||||
$search_array_options = array();
|
||||
@ -190,7 +193,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;
|
||||
@ -200,6 +203,7 @@ $sql .= " WHERE asy.rowid = ".$pcgver;
|
||||
//print $sql;
|
||||
if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $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))) $sql .= natural_search("aa.account_parent", $search_accountparent);
|
||||
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);
|
||||
@ -232,6 +236,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) $param .= '&search_accountparent='.urlencode($search_accountparent);
|
||||
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
|
||||
if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
|
||||
@ -316,8 +321,9 @@ 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"><input type="text" class="flat" size="10" name="search_accountparent" value="'.$search_accountparent.'"></td>';
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
|
||||
if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="'.$search_pcgsubtype.'"></td>';
|
||||
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
@ -329,8 +335,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 ');
|
||||
@ -368,6 +375,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']))
|
||||
{
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -704,9 +704,9 @@ class AccountancyExport
|
||||
print $end_line;
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
$date_creation = dol_print_date($line->date_creation, '%d%m%Y');
|
||||
$date_doc = dol_print_date($line->doc_date, '%d%m%Y');
|
||||
$date_valid = dol_print_date($line->date_validated, '%d%m%Y');
|
||||
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
|
||||
$date_doc = dol_print_date($line->doc_date, '%Y%m%d');
|
||||
$date_valid = dol_print_date($line->date_validated, '%Y%m%d');
|
||||
|
||||
// FEC:JournalCode
|
||||
print $line->code_journal.$separator;
|
||||
|
||||
@ -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";
|
||||
@ -196,6 +201,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;
|
||||
@ -239,6 +245,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')
|
||||
{
|
||||
@ -261,6 +269,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";
|
||||
@ -273,6 +282,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;
|
||||
@ -344,6 +354,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;
|
||||
@ -461,10 +472,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';
|
||||
|
||||
@ -482,11 +494,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='';
|
||||
@ -513,7 +532,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 .= ' ';
|
||||
|
||||
@ -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 .= ")";
|
||||
|
||||
|
||||
@ -1155,9 +1155,9 @@ if (empty($action) || $action == 'view') {
|
||||
}
|
||||
else print $accounttoshow;
|
||||
print "</td>";
|
||||
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
|
||||
if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) // Type of payment with subledger
|
||||
{
|
||||
$accounttoshowsubledger = length_accounta($k);
|
||||
@ -1171,7 +1171,12 @@ if (empty($action) || $action == 'view') {
|
||||
//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
|
||||
if (! empty($tabcompany[$key]['code_compta']))
|
||||
{
|
||||
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
|
||||
if (in_array($tabtype[$key], array('payment_various'))) {
|
||||
// For such case, if subledger is not defined, we won't use subledger accounts.
|
||||
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>';
|
||||
} else {
|
||||
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -142,14 +142,14 @@ $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
|
||||
if (empty($conf->global->MEMBER_ENABLE_PUBLIC))
|
||||
{
|
||||
// Button off, click to enable
|
||||
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=1'.$param.'">';
|
||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=1'.$param.'">';
|
||||
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
$enabledisablehtml .= '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Button on, click to disable
|
||||
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=0'.$param.'">';
|
||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=0'.$param.'">';
|
||||
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
|
||||
$enabledisablehtml .= '</a>';
|
||||
}
|
||||
@ -174,8 +174,8 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC))
|
||||
$adht = new AdherentType($db);
|
||||
print '<tr class="oddeven drag" id="trforcetype"><td>';
|
||||
print $langs->trans("ForceMemberType");
|
||||
print '</td><td width="60" class="right">';
|
||||
$listofval = array(-1 => $langs->trans("Undefined"));
|
||||
print '</td><td class="right">';
|
||||
$listofval = array();
|
||||
$listofval += $adht->liste_array();
|
||||
$forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1;
|
||||
print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1: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>';
|
||||
}
|
||||
|
||||
|
||||
@ -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>';
|
||||
}
|
||||
|
||||
@ -691,14 +691,14 @@ if ($rowid > 0)
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
@ -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
|
||||
@ -363,7 +363,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';
|
||||
@ -806,10 +808,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>";
|
||||
|
||||
@ -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>';
|
||||
|
||||
@ -193,14 +193,14 @@ $enabledisablehtml .= $langs->trans("EnableDefaultValues").' ';
|
||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
|
||||
{
|
||||
// Button off, click to enable
|
||||
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
|
||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
|
||||
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
$enabledisablehtml .= '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Button on, click to disable
|
||||
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
|
||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
|
||||
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
|
||||
$enabledisablehtml .= '</a>';
|
||||
}
|
||||
|
||||
@ -595,13 +595,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
print '<tr class="drag drop oddeven" id="row-'.$ruleaction['id'].'">';
|
||||
print '<td>';
|
||||
print '<!-- type of action: '.$ruleaction['type'].' -->';
|
||||
print $langs->trans($arrayoftypes[$ruleaction['type']]);
|
||||
if (in_array($ruleaction['type'], array('recordevent')))
|
||||
{
|
||||
print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
|
||||
}
|
||||
elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
|
||||
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<td class="wordbreak">';
|
||||
if ($action == 'editoperation' && $ruleaction['id'] == $operationid)
|
||||
{
|
||||
print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
|
||||
|
||||
@ -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,15 @@ 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"> </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 $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1);
|
||||
print ajax_constantonoff('MAIN_MULTILANGS');
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -180,11 +180,11 @@ if ($action == 'install')
|
||||
$modulename = preg_replace('/module_/', '', $original_file);
|
||||
$modulename = preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename);
|
||||
// Search dir $modulename
|
||||
$modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example .../mymodule
|
||||
//var_dump($modulenamedir);
|
||||
$modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example ./mymodule
|
||||
|
||||
if (!dol_is_dir($modulenamedir))
|
||||
{
|
||||
$modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example .../htdocs/mymodule
|
||||
$modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example ./htdocs/mymodule
|
||||
//var_dump($modulenamedir);
|
||||
if (!dol_is_dir($modulenamedir))
|
||||
{
|
||||
@ -207,6 +207,7 @@ if ($action == 'install')
|
||||
$modulenamearrays = explode("\n", $metafile);
|
||||
}
|
||||
$modulenamearrays[$modulename] = $modulename;
|
||||
//var_dump($modulenamearrays);exit;
|
||||
|
||||
foreach ($modulenamearrays as $modulenameval) {
|
||||
if (strpos($modulenameval, '#') === 0) continue; // Discard comments
|
||||
@ -216,15 +217,14 @@ if ($action == 'install')
|
||||
// Now we install the module
|
||||
if (!$error)
|
||||
{
|
||||
//var_dump($dirins);
|
||||
@dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the zip file
|
||||
dol_syslog("We copy now directory ".$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval." into target dir ".$dirins.'/'.$modulenameval);
|
||||
$result = dolCopyDir($conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval, $dirins.'/'.$modulenameval, '0444', 1);
|
||||
$result = dolCopyDir($modulenamedir, $dirins.'/'.$modulenameval, '0444', 1);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_syslog('Failed to call dolCopyDir result='.$result." with param ".$modulenamedir." and ".$dirins.'/'.$modulenameval, LOG_WARNING);
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFailToCopyDir", $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval, $dirins.'/'.$modulenameval), null, 'errors');
|
||||
setEventMessages($langs->trans("ErrorFailToCopyDir", $modulenamedir, $dirins.'/'.$modulenameval), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -825,10 +825,13 @@ if ($mode == 'common')
|
||||
$warningmessage = '';
|
||||
if (!empty($arrayofwarnings[$modName]))
|
||||
{
|
||||
print '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
|
||||
print '<!-- This module is a core module and it may have a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
|
||||
foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage)
|
||||
{
|
||||
$warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
|
||||
if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry)))
|
||||
{
|
||||
$warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext))
|
||||
|
||||
@ -75,7 +75,7 @@ print '<br>';
|
||||
$file_list = array('missing' => array(), 'updated' => array());
|
||||
|
||||
// Local file to compare to
|
||||
$xmlshortfile = GETPOST('xmlshortfile', 'alpha') ?GETPOST('xmlshortfile', 'alpha') : '/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml';
|
||||
$xmlshortfile = GETPOST('xmlshortfile', 'alpha') ?GETPOST('xmlshortfile', 'alpha') : '/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'.(empty($conf->global->MAIN_FILECHECK_LOCAL_EXT) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_EXT);
|
||||
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
|
||||
// Remote file to compare to
|
||||
$xmlremote = GETPOST('xmlremote');
|
||||
@ -127,6 +127,18 @@ if (GETPOST('target') == 'local')
|
||||
{
|
||||
if (dol_is_file($xmlfile))
|
||||
{
|
||||
// If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before
|
||||
if (preg_match('/\.zip$/i', $xmlfile)) {
|
||||
dol_mkdir($conf->admin->dir_temp);
|
||||
$xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile);
|
||||
$result = dol_uncompress($xmlfile, $conf->admin->dir_temp);
|
||||
if (empty($result['error'])) {
|
||||
$xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew);
|
||||
} else {
|
||||
print $langs->trans('FailedToUncompressFile').': '.$xmlfile;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
$xml = simplexml_load_file($xmlfile);
|
||||
}
|
||||
else
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -81,9 +81,9 @@ $type=$db->type;
|
||||
$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
|
||||
llxHeader('', '', $help_url);
|
||||
|
||||
print '<script type="text/javascript">
|
||||
jQuery(document).ready(function() {';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
function hideoptions () {
|
||||
jQuery("#mysql_options").hide();
|
||||
@ -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>';
|
||||
@ -534,6 +534,8 @@ print '</div>';
|
||||
print '</form>';
|
||||
print '</fieldset>';
|
||||
|
||||
|
||||
|
||||
print "<br>\n";
|
||||
print "<!-- Dump of a server -->\n";
|
||||
|
||||
@ -548,7 +550,7 @@ print $langs->trans("BackupDescX").'<br><br>';
|
||||
|
||||
print '<div id="backupfilesleft" class="fichehalfleft">';
|
||||
|
||||
print load_fiche_titre($title?$title:$langs->trans("BackupDumpWizard"));
|
||||
print load_fiche_titre($title?$title:$langs->trans("BackupZipWizard"));
|
||||
|
||||
print '<label for="zipfilename_template">'.$langs->trans("FileNameToGenerate").'</label><br>';
|
||||
$prefix='documents';
|
||||
|
||||
@ -208,14 +208,14 @@ $enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' ';
|
||||
if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
|
||||
{
|
||||
// Button off, click to enable
|
||||
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=1'.$param.'">';
|
||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=1'.$param.'">';
|
||||
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
$enabledisablehtml .= '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Button on, click to disable
|
||||
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=0'.$param.'">';
|
||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=0'.$param.'">';
|
||||
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
|
||||
$enabledisablehtml .= '</a>';
|
||||
}
|
||||
|
||||
@ -297,10 +297,7 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
$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">';
|
||||
|
||||
@ -34,7 +34,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "members", "users"));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
@ -244,10 +243,7 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
$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">';
|
||||
|
||||
@ -202,6 +202,7 @@ print '<br>';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="mode" value="label">';
|
||||
print '<input type="hidden" name="action" value="initbarcodeproducts">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
@ -1,129 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2019 Maxime Kohlhaas <maxime@atm-consulting.fr>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file bom/admin/setup.php
|
||||
* \ingroup bom
|
||||
* \brief Bom setup page.
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
// Libraries
|
||||
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
|
||||
require_once '../lib/bom.lib.php';
|
||||
//require_once "../class/myclass.class.php";
|
||||
|
||||
// Translations
|
||||
$langs->loadLangs(array("admin", "mrp"));
|
||||
|
||||
// Access control
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
// Parameters
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$arrayofparameters = array(
|
||||
'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
|
||||
'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$page_name = "BomSetup";
|
||||
llxHeader('', $langs->trans($page_name));
|
||||
|
||||
// Subheader
|
||||
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom');
|
||||
|
||||
// Configuration header
|
||||
$head = bomAdminPrepareHead();
|
||||
dol_fiche_head($head, 'settings', '', -1, "bom");
|
||||
|
||||
// Setup page goes here
|
||||
echo $langs->trans("BomSetupPage").'<br><br>';
|
||||
|
||||
|
||||
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">';
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
foreach ($arrayofparameters as $key => $val)
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
|
||||
print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($arrayofparameters))
|
||||
{
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
foreach ($arrayofparameters as $key => $val)
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
|
||||
print '</td><td>'.$conf->global->$key.'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br>'.$langs->trans("NothingToSetup");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Page end
|
||||
dol_fiche_end();
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -97,11 +97,13 @@ if (empty($reshook))
|
||||
$backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
|
||||
|
||||
if (empty($backtopage) || ($cancel && empty($id))) {
|
||||
//var_dump($backurlforlist);exit;
|
||||
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
|
||||
else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.($id > 0 ? $id : '__ID__');
|
||||
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
|
||||
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
|
||||
else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
|
||||
}
|
||||
}
|
||||
$triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
|
||||
$triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
|
||||
// Actions cancel, add, update, delete or clone
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
@ -169,7 +171,9 @@ if (empty($reshook))
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($_POST['qty_frozen']);
|
||||
unset($_POST['idprod']);
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['qty_frozen']);
|
||||
unset($_POST['disable_stock_change']);
|
||||
}
|
||||
}
|
||||
@ -207,7 +211,9 @@ if (empty($reshook))
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($_POST['qty_frozen']);
|
||||
unset($_POST['idprod']);
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['qty_frozen']);
|
||||
unset($_POST['disable_stock_change']);
|
||||
}
|
||||
}
|
||||
@ -506,7 +512,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<table class="border centpercent tableforfield">'."\n";
|
||||
|
||||
// Common attributes
|
||||
$keyforbreak = 'description';
|
||||
$keyforbreak = 'efficiency';
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
||||
|
||||
// Other attributes
|
||||
@ -622,7 +628,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="" title="'.$langs->trans("AddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
|
||||
$langs->load("errors");
|
||||
print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -644,7 +651,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
{
|
||||
if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write))
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopageforcancel='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default sea
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
|
||||
// Security check
|
||||
if (empty($conf->bom->enabled)) accessforbidden('Module not enabled');
|
||||
$socid = 0;
|
||||
if ($user->socid > 0) // Protection if external user
|
||||
{
|
||||
@ -106,8 +107,14 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
|
||||
{
|
||||
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');
|
||||
@ -298,8 +305,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
// 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('/, $/', '', $sql);
|
||||
$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($object->element).")";
|
||||
@ -308,6 +315,10 @@ 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);
|
||||
@ -332,7 +343,7 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
$sql=preg_replace('/, $/','', $sql);
|
||||
$sql=preg_replace('/,\s*$/','', $sql);
|
||||
*/
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
@ -350,13 +361,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
|
||||
{
|
||||
$num = $nbtotalofrecords;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
@ -369,7 +380,7 @@ else
|
||||
}
|
||||
|
||||
// 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;
|
||||
@ -418,7 +429,7 @@ $arrayofmassactions = array(
|
||||
'enable'=>$langs->trans("Enable"),
|
||||
'disable'=>$langs->trans("Disable"),
|
||||
);
|
||||
if ($user->rights->bom->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
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);
|
||||
|
||||
@ -488,7 +499,10 @@ foreach ($object->fields as $key => $val)
|
||||
{
|
||||
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');
|
||||
else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
||||
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>';
|
||||
}
|
||||
}
|
||||
@ -548,17 +562,13 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < min($num, $limit))
|
||||
while ($i < ($limit ? min($num, $limit) : $num))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
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">';
|
||||
@ -577,21 +587,20 @@ while ($i < min($num, $limit))
|
||||
{
|
||||
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
||||
if ($key == 'status') print $object->getLibStatut(5);
|
||||
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
|
||||
else print $object->showOutputField($val, $key, $obj->$key, '');
|
||||
else print $object->showOutputField($val, $key, $object->$key, '');
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!empty($val['isameasure']))
|
||||
{
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
|
||||
$totalarray['val']['t.'.$key] += $obj->$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
|
||||
@ -599,13 +608,13 @@ while ($i < min($num, $limit))
|
||||
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++;
|
||||
}
|
||||
@ -648,8 +657,8 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n
|
||||
$urlsource .= str_replace('&', '&', $param);
|
||||
|
||||
$filedir = $diroutputmassaction;
|
||||
$genallowed = $user->rights->bom->read;
|
||||
$delallowed = $user->rights->bom->create;
|
||||
$genallowed = $permissiontoread;
|
||||
$delallowed = $permissiontoadd;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_bom', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
|
||||
}
|
||||
|
||||
@ -63,10 +63,11 @@ class BOM extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* 'type' if the field format.
|
||||
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'enabled' is a condition when the field must be managed.
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'noteditable' says if field is not editable (1 or 0)
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'default' is a default value for creation (can still be replaced by the global setup of default values)
|
||||
|
||||
@ -48,9 +48,9 @@ $langs->loadLangs(array("main","bills"));
|
||||
|
||||
</script>
|
||||
|
||||
<p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture/card.php?action=builddoc&facid=<?php echo $_GET['facid']; ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p>
|
||||
<p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture/card.php?action=builddoc&facid=<?php echo GETPOST('facid', 'int'); ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p>
|
||||
<br>
|
||||
<p><a class="lien1" href="#" onclick="Javascript: popupTicket(); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p>
|
||||
<p><a class="lien1" href="#" onclick="Javascript: popupTicket(<?php echo GETPOST('facid', 'int'); ?>,'<?php echo $langs->trans('PrintTicket') ?>'); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -48,6 +48,11 @@ class Categories extends DolibarrApi
|
||||
3 => 'member',
|
||||
4 => 'contact',
|
||||
5 => 'account',
|
||||
//6 => 'project',
|
||||
//7 => 'user',
|
||||
//8 => 'bank_line',
|
||||
//9 => 'warehouse',
|
||||
//10 => 'actioncomm',
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@ -54,6 +54,7 @@ class Categorie extends CommonObject
|
||||
const TYPE_ACCOUNT = 'bank_account';
|
||||
const TYPE_BANK_LINE = 'bank_line';
|
||||
const TYPE_WAREHOUSE = 'warehouse';
|
||||
const TYPE_ACTIONCOMM = 'actioncomm';
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
@ -77,6 +78,7 @@ class Categorie extends CommonObject
|
||||
'user' => 7,
|
||||
'bank_line' => 8,
|
||||
'warehouse' => 9,
|
||||
'actioncomm' => 10,
|
||||
);
|
||||
|
||||
/**
|
||||
@ -93,6 +95,7 @@ class Categorie extends CommonObject
|
||||
7 => 'user',
|
||||
8 => 'bank_line',
|
||||
9 => 'warehouse',
|
||||
10 => 'actioncomm',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -111,6 +114,7 @@ class Categorie extends CommonObject
|
||||
'bank_account' => 'account',
|
||||
'project' => 'project',
|
||||
'warehouse'=> 'warehouse',
|
||||
'actioncomm' => 'actioncomm',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -129,6 +133,7 @@ class Categorie extends CommonObject
|
||||
'bank_account'=> 'account',
|
||||
'project' => 'project',
|
||||
'warehouse'=> 'warehouse',
|
||||
'actioncomm' => 'actioncomm',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -147,6 +152,7 @@ class Categorie extends CommonObject
|
||||
'bank_account' => 'Account',
|
||||
'project' => 'Project',
|
||||
'warehouse'=> 'Entrepot',
|
||||
'actioncomm' => 'ActionComm',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -164,6 +170,7 @@ class Categorie extends CommonObject
|
||||
'account' => 'bank_account',
|
||||
'project' => 'projet',
|
||||
'warehouse'=> 'entrepot',
|
||||
'actioncomm' => 'actioncomm',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -214,6 +221,7 @@ class Categorie extends CommonObject
|
||||
* @see Categorie::TYPE_PROJECT
|
||||
* @see Categorie::TYPE_BANK_LINE
|
||||
* @see Categorie::TYPE_WAREHOUSE
|
||||
* @see Categorie::TYPE_ACTIONCOMM
|
||||
*/
|
||||
public $type;
|
||||
|
||||
|
||||
@ -59,7 +59,13 @@ elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCate
|
||||
elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; }
|
||||
elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; }
|
||||
elseif ($type == Categorie::TYPE_WAREHOUSE) { $title=$langs->trans("StocksCategoriesArea"); $typetext='warehouse'; }
|
||||
else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; }
|
||||
elseif ($type == Categorie::TYPE_ACTIONCOMM) {
|
||||
$title = $langs->trans("ActionCommCategoriesArea");
|
||||
$typetext = 'actioncomm';
|
||||
} else {
|
||||
$title = $langs->trans("CategoriesArea");
|
||||
$typetext = 'unknown';
|
||||
}
|
||||
|
||||
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
|
||||
$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
|
||||
|
||||
@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda"));
|
||||
@ -374,6 +375,10 @@ if (empty($reshook) && $action == 'add')
|
||||
{
|
||||
if (!$object->error)
|
||||
{
|
||||
// Category association
|
||||
$categories = GETPOST('categories', 'array');
|
||||
$object->setCategories($categories);
|
||||
|
||||
unset($_SESSION['assignedtouser']);
|
||||
|
||||
$moreparam = '';
|
||||
@ -595,6 +600,10 @@ if (empty($reshook) && $action == 'update')
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
// Category association
|
||||
$categories = GETPOST('categories', 'array');
|
||||
$object->setCategories($categories);
|
||||
|
||||
unset($_SESSION['assignedtouser']);
|
||||
|
||||
$db->commit();
|
||||
@ -1000,6 +1009,14 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($conf->categorie->enabled) {
|
||||
// Categories
|
||||
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1);
|
||||
print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
@ -1411,6 +1428,19 @@ if ($id > 0)
|
||||
print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1, 'doneby', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Tags-Categories
|
||||
if ($conf->categorie->enabled) {
|
||||
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1);
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
|
||||
$arrayselected = array();
|
||||
foreach ($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
}
|
||||
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -1461,6 +1491,7 @@ if ($id > 0)
|
||||
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Priority").'</td><td>';
|
||||
print '<input type="text" name="priority" value="'.($object->priority ? $object->priority : '').'" size="5">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Object linked
|
||||
if (!empty($object->fk_element) && !empty($object->elementtype))
|
||||
{
|
||||
@ -1716,6 +1747,12 @@ if ($id > 0)
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Categories
|
||||
if ($conf->categorie->enabled) {
|
||||
print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||
print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
@ -514,9 +514,10 @@ class ActionComm extends CommonObject
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id");
|
||||
|
||||
// Now insert assignedusers
|
||||
// Now insert assigned users
|
||||
if (!$error)
|
||||
{
|
||||
//dol_syslog(var_export($this->userassigned, true));
|
||||
foreach ($this->userassigned as $key => $val)
|
||||
{
|
||||
if (!is_array($val)) // For backward compatibility when val=id
|
||||
@ -524,16 +525,20 @@ class ActionComm extends CommonObject
|
||||
$val = array('id'=>$val);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
|
||||
$sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")";
|
||||
if ($val['id'] > 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
|
||||
$sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
//var_dump($sql);exit;
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$error++;
|
||||
dol_syslog('Error to process userassigned: '.$this->db->lasterror(), LOG_ERR);
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
//var_dump($sql);exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,7 +546,7 @@ class ActionComm extends CommonObject
|
||||
{
|
||||
if (!empty($this->socpeopleassigned))
|
||||
{
|
||||
foreach ($this->socpeopleassigned as $id => $Tab)
|
||||
foreach ($this->socpeopleassigned as $id => $val)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
|
||||
$sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)";
|
||||
@ -550,6 +555,7 @@ class ActionComm extends CommonObject
|
||||
if (!$resql)
|
||||
{
|
||||
$error++;
|
||||
dol_syslog('Error to process socpeopleassigned: '.$this->db->lasterror(), LOG_ERR);
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
@ -558,8 +564,6 @@ class ActionComm extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$action = 'create';
|
||||
|
||||
// Actions on extra fields
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
@ -1506,6 +1510,50 @@ class ActionComm extends CommonObject
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets object to supplied categories.
|
||||
*
|
||||
* Deletes object from existing categories not supplied.
|
||||
* Adds it to non existing supplied categories.
|
||||
* Existing categories are left untouch.
|
||||
*
|
||||
* @param int[]|int $categories Category or categories IDs
|
||||
* @return void
|
||||
*/
|
||||
public function setCategories($categories)
|
||||
{
|
||||
// Handle single category
|
||||
if (! is_array($categories)) {
|
||||
$categories = array($categories);
|
||||
}
|
||||
|
||||
// Get current categories
|
||||
include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
$c = new Categorie($this->db);
|
||||
$existing = $c->containing($this->id, Categorie::TYPE_ACTIONCOMM, 'id');
|
||||
|
||||
// Diff
|
||||
if (is_array($existing)) {
|
||||
$to_del = array_diff($existing, $categories);
|
||||
$to_add = array_diff($categories, $existing);
|
||||
} else {
|
||||
$to_del = array(); // Nothing to delete
|
||||
$to_add = $categories;
|
||||
}
|
||||
|
||||
// Process
|
||||
foreach($to_del as $del) {
|
||||
if ($c->fetch($del) > 0) {
|
||||
$c->del_type($this, Categorie::TYPE_ACTIONCOMM);
|
||||
}
|
||||
}
|
||||
foreach ($to_add as $add) {
|
||||
if ($c->fetch($add) > 0) {
|
||||
$c->add_type($this, Categorie::TYPE_ACTIONCOMM);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
@ -1721,6 +1769,13 @@ class ActionComm extends CommonObject
|
||||
}
|
||||
$diff++;
|
||||
}
|
||||
|
||||
$parameters=array('filters' => $filters, 'eventarray' => &$eventarray);
|
||||
$reshook=$hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook > 0)
|
||||
{
|
||||
$eventarray = $hookmanager->resArray;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -308,7 +308,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS
|
||||
if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
|
||||
if ($type) $sql .= " AND c.id = ".$type;
|
||||
if ($type) $sql .= " AND c.id = ".(int) $type;
|
||||
if ($status == '0') { $sql .= " AND a.percent = 0"; }
|
||||
if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable
|
||||
if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
|
||||
|
||||
@ -491,7 +491,7 @@ if ($object->id > 0)
|
||||
$langs->load("categories");
|
||||
print '<tr><td>'.$langs->trans("CustomersCategoriesShort").'</td>';
|
||||
print '<td>';
|
||||
print $form->showCategories($object->id, 'customer', 1);
|
||||
print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
@ -1800,7 +1800,7 @@ class Propal extends CommonObject
|
||||
$this->newref = $num;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
||||
$sql .= " SET ref = '".$num."',";
|
||||
$sql .= " SET ref = '".$this->db->escape($num)."',";
|
||||
$sql .= " fk_statut = ".self::STATUS_VALIDATED.", date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
|
||||
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2017-2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2017-2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -75,15 +76,12 @@ $search_zip = GETPOST('search_zip', 'alpha');
|
||||
$search_state = trim(GETPOST("search_state"));
|
||||
$search_country = GETPOST("search_country", 'int');
|
||||
$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
|
||||
$search_day = GETPOST("search_day", "int");
|
||||
$search_month = GETPOST("search_month", "int");
|
||||
$search_year = GETPOST("search_year", "int");
|
||||
$search_dayfin = GETPOST("search_dayfin", "int");
|
||||
$search_month_end = GETPOST("search_month_end", "int");
|
||||
$search_yearfin = GETPOST("search_yearfin", "int");
|
||||
$search_daydelivery = GETPOST("search_daydelivery", "int");
|
||||
$search_monthdelivery = GETPOST("search_monthdelivery", "int");
|
||||
$search_yeardelivery = GETPOST("search_yeardelivery", "int");
|
||||
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
|
||||
$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
|
||||
$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int'));
|
||||
$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int'));
|
||||
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int'));
|
||||
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int'));
|
||||
$search_availability = GETPOST('search_availability', 'int');
|
||||
$search_categ_cus = trim(GETPOST("search_categ_cus", 'int'));
|
||||
$search_btn = GETPOST('button_search', 'alpha');
|
||||
@ -219,15 +217,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
||||
$search_type = '';
|
||||
$search_country = '';
|
||||
$search_type_thirdparty = '';
|
||||
$search_year = '';
|
||||
$search_month = '';
|
||||
$search_day = '';
|
||||
$search_yearfin = '';
|
||||
$search_month_end = '';
|
||||
$search_dayfin = '';
|
||||
$search_yeardelivery = '';
|
||||
$search_monthdelivery = '';
|
||||
$search_daydelivery = '';
|
||||
$search_date_start='';
|
||||
$search_date_end='';
|
||||
$search_dateend_start='';
|
||||
$search_dateend_end='';
|
||||
$search_datedelivery_start='';
|
||||
$search_datedelivery_end='';
|
||||
$search_availability = '';
|
||||
$viewstatut = '';
|
||||
$object_statut = '';
|
||||
@ -273,8 +268,9 @@ $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.
|
||||
$sql .= " typent.code as typent_code,";
|
||||
$sql .= " ava.rowid as availability,";
|
||||
$sql .= " state.code_departement as state_code, state.nom as state_name,";
|
||||
$sql .= ' p.rowid, p.entity, p.note_private, p.note_public, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
|
||||
$sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
|
||||
$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
|
||||
$sql .= ' p.note_public, p.note_private,';
|
||||
$sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
|
||||
$sql .= ' u.login';
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
@ -313,38 +309,42 @@ if (!$user->rights->societe->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($search_town) $sql .= natural_search('s.town', $search_town);
|
||||
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
|
||||
if ($search_state) $sql .= natural_search("state.nom", $search_state);
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
|
||||
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
|
||||
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
|
||||
if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
|
||||
if ($search_project) $sql .= natural_search('pr.title', $search_project);
|
||||
if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')';
|
||||
|
||||
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
|
||||
if ($search_login) $sql .= natural_search("u.login", $search_login);
|
||||
if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
|
||||
if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1);
|
||||
if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1);
|
||||
if ($search_town) $sql .= natural_search('s.town', $search_town);
|
||||
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
|
||||
if ($search_state) $sql .= natural_search("state.nom", $search_state);
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
|
||||
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
|
||||
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
|
||||
if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
|
||||
if ($search_project) $sql .= natural_search('pr.title', $search_project);
|
||||
if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')';
|
||||
|
||||
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
|
||||
if ($search_login) $sql .= natural_search("u.login", $search_login);
|
||||
if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
|
||||
if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1);
|
||||
if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1);
|
||||
if ($sall) {
|
||||
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
}
|
||||
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
|
||||
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
|
||||
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
|
||||
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
|
||||
|
||||
if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category);
|
||||
if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category);
|
||||
if ($socid > 0) $sql .= ' AND s.rowid = '.$socid;
|
||||
if ($viewstatut != '' && $viewstatut != '-1')
|
||||
{
|
||||
$sql .= ' AND p.fk_statut IN ('.$db->escape($viewstatut).')';
|
||||
}
|
||||
$sql .= dolSqlDateFilter("p.datep", $search_day, $search_month, $search_year);
|
||||
$sql .= dolSqlDateFilter("p.fin_validite", $search_dayfin, $search_month_end, $search_yearfin);
|
||||
$sql .= dolSqlDateFilter("p.date_livraison", $search_daydelivery, $search_monthdelivery, $search_yeardelivery);
|
||||
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
|
||||
if ($search_date_start) $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
|
||||
if ($search_date_end) $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
|
||||
if ($search_dateend_start) $sql .= " AND p.fin_validite >= '" . $db->idate($search_dateend_start) . "'";
|
||||
if ($search_dateend_end) $sql .= " AND p.fin_validite <= '" . $db->idate($search_dateend_end) . "'";
|
||||
if ($search_datedelivery_start) $sql .= " AND p.date_livraison >= '" . $db->idate($search_datedelivery_start) . "'";
|
||||
if ($search_datedelivery_end) $sql .= " AND p.date_livraison <= '" . $db->idate($search_datedelivery_end) . "'";
|
||||
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale);
|
||||
if ($search_user > 0)
|
||||
{
|
||||
$sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$db->escape($search_user);
|
||||
@ -414,22 +414,25 @@ if ($resql)
|
||||
$param = '&viewstatut='.urlencode($viewstatut);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($sall) $param .= '&sall='.urlencode($sall);
|
||||
if ($search_day) $param .= '&search_day='.urlencode($search_day);
|
||||
if ($search_month) $param .= '&search_month='.urlencode($search_month);
|
||||
if ($search_year) $param .= '&search_year='.urlencode($search_year);
|
||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer);
|
||||
if ($search_refproject) $param .= '&search_refproject='.urlencode($search_refproject);
|
||||
if ($search_societe) $param .= '&search_societe='.urlencode($search_societe);
|
||||
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
|
||||
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
|
||||
if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht);
|
||||
if ($search_login) $param .= '&search_login='.urlencode($search_login);
|
||||
if ($search_town) $param .= '&search_town='.urlencode($search_town);
|
||||
if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
|
||||
if ($socid > 0) $param .= '&socid='.urlencode($socid);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($sall) $param .= '&sall='.urlencode($sall);
|
||||
if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start);
|
||||
if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end);
|
||||
if ($search_dateend_start) $param .= '&search_dateend_start='.urlencode($search_dateend_start);
|
||||
if ($search_dateend_end) $param .= '&search_dateend_end='.urlencode($search_dateend_end);
|
||||
if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
|
||||
if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
|
||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer);
|
||||
if ($search_refproject) $param .= '&search_refproject='.urlencode($search_refproject);
|
||||
if ($search_societe) $param .= '&search_societe='.urlencode($search_societe);
|
||||
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
|
||||
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
|
||||
if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht);
|
||||
if ($search_login) $param .= '&search_login='.urlencode($search_login);
|
||||
if ($search_town) $param .= '&search_town='.urlencode($search_town);
|
||||
if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
|
||||
if ($socid > 0) $param .= '&socid='.urlencode($socid);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
|
||||
if ($search_product_category != '') $param .= '&search_product_category='.$search_product_category;
|
||||
|
||||
@ -594,34 +597,43 @@ if ($resql)
|
||||
// Date
|
||||
if (!empty($arrayfields['p.date']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
//print $langs->trans('Month').': ';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
|
||||
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
|
||||
//print ' '.$langs->trans('Year').': ';
|
||||
$formother->select_year($search_year, 'search_year', 1, 20, 5);
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Date end
|
||||
if (!empty($arrayfields['p.fin_validite']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
//print $langs->trans('Month').': ';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_dayfin" value="'.dol_escape_htmltag($search_dayfin).'">';
|
||||
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">';
|
||||
//print ' '.$langs->trans('Year').': ';
|
||||
$formother->select_year($search_yearfin, 'search_yearfin', 1, 20, 5);
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_dateend_start?$search_dateend_start:-1, 'search_dateend_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_dateend_end?$search_dateend_end:-1, 'search_dateend_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Date delivery
|
||||
if (!empty($arrayfields['p.date_livraison']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
//print $langs->trans('Month').': ';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" size="1" maxlength="2" name="search_daydelivery" value="'.dol_escape_htmltag($search_daydelivery).'">';
|
||||
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_monthdelivery" value="'.dol_escape_htmltag($search_monthdelivery).'">';
|
||||
//print ' '.$langs->trans('Year').': ';
|
||||
$formother->select_year($search_yeardelivery, 'search_yeardelivery', 1, 20, 5);
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_datedelivery_start?$search_datedelivery_start:-1, 'search_datedelivery_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_datedelivery_end?$search_datedelivery_end:-1, 'search_datedelivery_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Availability
|
||||
@ -719,37 +731,37 @@ if ($resql)
|
||||
|
||||
// Fields title
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
|
||||
// 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); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||
print '</tr>'."\n";
|
||||
|
||||
@ -940,7 +952,7 @@ if ($resql)
|
||||
// Amount HT
|
||||
if (!empty($arrayfields['p.total_ht']['checked']))
|
||||
{
|
||||
print '<td class="right">'.price($obj->total_ht)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($obj->total_ht)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht';
|
||||
$totalarray['val']['p.total_ht'] += $obj->total_ht;
|
||||
@ -948,7 +960,7 @@ if ($resql)
|
||||
// Amount VAT
|
||||
if (!empty($arrayfields['p.total_vat']['checked']))
|
||||
{
|
||||
print '<td class="right">'.price($obj->total_vat)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($obj->total_vat)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_vat';
|
||||
$totalarray['val']['p.total_vat'] += $obj->total_vat;
|
||||
@ -956,7 +968,7 @@ if ($resql)
|
||||
// Amount TTC
|
||||
if (!empty($arrayfields['p.total_ttc']['checked']))
|
||||
{
|
||||
print '<td class="right">'.price($obj->total_ttc)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($obj->total_ttc)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc';
|
||||
$totalarray['val']['p.total_ttc'] += $obj->total_ttc;
|
||||
@ -977,7 +989,7 @@ if ($resql)
|
||||
}
|
||||
}
|
||||
|
||||
print '<td class="right">'.price($totalInvoiced)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($totalInvoiced)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced';
|
||||
$totalarray['val']['p.total_ht_invoiced'] += $obj->total_ht_invoiced;
|
||||
@ -998,7 +1010,7 @@ if ($resql)
|
||||
}
|
||||
}
|
||||
|
||||
print '<td class="right">'.price($totalInvoiced)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($totalInvoiced)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced';
|
||||
$totalarray['val']['p.total_invoiced'] += $obj->total_invoiced;
|
||||
|
||||
@ -222,7 +222,7 @@ if ($socid > 0)
|
||||
$sql .= " u.login, u.rowid as user_id";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE rc.fk_soc = ".$object->id;
|
||||
$sql .= " AND rc.entity = ".$conf->entity;
|
||||
$sql .= " AND rc.entity IN (".getEntity('discount').")";
|
||||
$sql .= " AND u.rowid = rc.fk_user_author";
|
||||
$sql .= " ORDER BY rc.datec DESC";
|
||||
|
||||
@ -281,7 +281,7 @@ if ($socid > 0)
|
||||
$sql .= " u.login, u.rowid as user_id";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE rc.fk_soc = ".$object->id;
|
||||
$sql .= " AND rc.entity = ".$conf->entity;
|
||||
$sql .= " AND rc.entity IN (".getEntity('discount').")";
|
||||
$sql .= " AND u.rowid = rc.fk_user_author";
|
||||
$sql .= " ORDER BY rc.datec DESC";
|
||||
|
||||
|
||||
@ -1447,6 +1447,7 @@ class Commande extends CommonOrder
|
||||
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
||||
|
||||
// Clean vat code
|
||||
$reg = array();
|
||||
$vat_src_code = '';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||
{
|
||||
@ -3558,9 +3559,10 @@ class Commande extends CommonOrder
|
||||
* @param int $short ???
|
||||
* @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 $addlinktonotes Add linkt to notes
|
||||
* @return string String with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1)
|
||||
public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0)
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
|
||||
@ -3627,6 +3629,22 @@ class Commande extends CommonOrder
|
||||
if ($withpicto != 2) $result .= $this->ref;
|
||||
$result .= $linkend;
|
||||
|
||||
if ($addlinktonotes)
|
||||
{
|
||||
$txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private);
|
||||
if ($txttoshow)
|
||||
{
|
||||
$notetoshow = $langs->trans("ViewPrivateNote").':<br>'.dol_string_nohtmltag($txttoshow, 1);
|
||||
$result .= ' <span class="note inline-block">';
|
||||
$result .= '<a href="'.DOL_URL_ROOT.'/commande/note.php?id='.$this->id.'" class="classfortooltip" title="'.dol_escape_htmltag($notetoshow).'">';
|
||||
$result .= img_picto('', 'note');
|
||||
$result .= '</a>';
|
||||
//$result.=img_picto($langs->trans("ViewNote"),'object_generic');
|
||||
//$result.='</a>';
|
||||
$result .= '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -56,12 +56,10 @@ $confirm = GETPOST('confirm', 'alpha');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlist';
|
||||
|
||||
$search_orderyear = GETPOST("search_orderyear", "int");
|
||||
$search_ordermonth = GETPOST("search_ordermonth", "int");
|
||||
$search_orderday = GETPOST("search_orderday", "int");
|
||||
$search_deliveryyear = GETPOST("search_deliveryyear", "int");
|
||||
$search_deliverymonth = GETPOST("search_deliverymonth", "int");
|
||||
$search_deliveryday = GETPOST("search_deliveryday", "int");
|
||||
$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_startmonth', 'int'), GETPOST('search_dateorder_startday', 'int'), GETPOST('search_dateorder_startyear', 'int'));
|
||||
$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_endmonth', 'int'), GETPOST('search_dateorder_endday', 'int'), GETPOST('search_dateorder_endyear', 'int'));
|
||||
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int'));
|
||||
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int'));
|
||||
$search_product_category = GETPOST('search_product_category', 'int');
|
||||
$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
|
||||
$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
|
||||
@ -197,12 +195,10 @@ if (empty($reshook))
|
||||
$search_total_ht = '';
|
||||
$search_total_vat = '';
|
||||
$search_total_ttc = '';
|
||||
$search_orderyear = '';
|
||||
$search_ordermonth = '';
|
||||
$search_orderday = '';
|
||||
$search_deliveryday = '';
|
||||
$search_deliverymonth = '';
|
||||
$search_deliveryyear = '';
|
||||
$search_dateorder_start ='';
|
||||
$search_dateorder_end ='';
|
||||
$search_datedelivery_start ='';
|
||||
$search_datedelivery_end ='';
|
||||
$search_project_ref = '';
|
||||
$search_project = '';
|
||||
$viewstatut = '';
|
||||
@ -311,22 +307,26 @@ if ($viewstatut <> '')
|
||||
$sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed
|
||||
}
|
||||
}
|
||||
$sql .= dolSqlDateFilter("c.date_commande", $search_orderday, $search_ordermonth, $search_orderyear);
|
||||
$sql .= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear);
|
||||
if ($search_town) $sql .= natural_search('s.town', $search_town);
|
||||
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
|
||||
if ($search_state) $sql .= natural_search("state.nom", $search_state);
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
|
||||
if ($search_company) $sql .= natural_search('s.nom', $search_company);
|
||||
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
|
||||
if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
|
||||
if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1);
|
||||
if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1);
|
||||
if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref);
|
||||
if ($search_project != '') $sql .= natural_search("p.title", $search_project);
|
||||
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
|
||||
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
|
||||
|
||||
if ($search_dateorder_start) $sql .= " AND c.date_commande >= '" . $db->idate($search_dateorder_start) . "'";
|
||||
if ($search_dateorder_end) $sql .= " AND c.date_commande <= '" . $db->idate($search_dateorder_end) . "'";
|
||||
if ($search_datedelivery_start) $sql .= " AND c.date_livraison >= '" . $db->idate($search_datedelivery_start) . "'";
|
||||
if ($search_datedelivery_end) $sql .= " AND c.date_livraison <= '" . $db->idate($search_datedelivery_end) . "'";
|
||||
if ($search_town) $sql .= natural_search('s.town', $search_town);
|
||||
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
|
||||
if ($search_state) $sql .= natural_search("state.nom", $search_state);
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
|
||||
if ($search_company) $sql .= natural_search('s.nom', $search_company);
|
||||
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
|
||||
if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
|
||||
if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1);
|
||||
if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1);
|
||||
if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref);
|
||||
if ($search_project != '') $sql .= natural_search("p.title", $search_project);
|
||||
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
|
||||
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
|
||||
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
// Add where from hooks
|
||||
@ -402,34 +402,32 @@ if ($resql)
|
||||
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($sall) $param .= '&sall='.urlencode($sall);
|
||||
if ($socid > 0) $param .= '&socid='.urlencode($socid);
|
||||
if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut);
|
||||
if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday);
|
||||
if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth);
|
||||
if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear);
|
||||
if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday);
|
||||
if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
|
||||
if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
|
||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if ($search_company) $param .= '&search_company='.urlencode($search_company);
|
||||
if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer);
|
||||
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
|
||||
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
|
||||
if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
|
||||
if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat);
|
||||
if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc);
|
||||
if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
|
||||
if ($search_town != '') $param .= '&search_town='.urlencode($search_town);
|
||||
if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip);
|
||||
if ($search_state != '') $param .= '&search_state='.urlencode($search_state);
|
||||
if ($search_country != '') $param .= '&search_country='.urlencode($search_country);
|
||||
if ($sall) $param .= '&sall='.urlencode($sall);
|
||||
if ($socid > 0) $param .= '&socid='.urlencode($socid);
|
||||
if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut);
|
||||
if ($search_dateorder_start) $param .= '&search_dateorder_start='.urlencode($search_dateorder_start);
|
||||
if ($search_dateorder_end) $param .= '&search_dateorder_end='.urlencode($search_dateorder_end);
|
||||
if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
|
||||
if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
|
||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if ($search_company) $param .= '&search_company='.urlencode($search_company);
|
||||
if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer);
|
||||
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
|
||||
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
|
||||
if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
|
||||
if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat);
|
||||
if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc);
|
||||
if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
|
||||
if ($search_town != '') $param .= '&search_town='.urlencode($search_town);
|
||||
if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip);
|
||||
if ($search_state != '') $param .= '&search_state='.urlencode($search_state);
|
||||
if ($search_country != '') $param .= '&search_country='.urlencode($search_country);
|
||||
if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
|
||||
if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category);
|
||||
if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
|
||||
if ($show_files) $param .= '&show_files='.urlencode($show_files);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($billed != '') $param .= '&billed='.urlencode($billed);
|
||||
if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
|
||||
if ($show_files) $param .= '&show_files='.urlencode($show_files);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($billed != '') $param .= '&billed='.urlencode($billed);
|
||||
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
@ -646,18 +644,28 @@ if ($resql)
|
||||
// Date order
|
||||
if (!empty($arrayfields['c.date_commande']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">';
|
||||
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_ordermonth" value="'.$search_ordermonth.'">';
|
||||
$formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5);
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_dateorder_start?$search_dateorder_start:-1, 'search_dateorder_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_dateorder_end?$search_dateorder_end:-1, 'search_dateorder_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['c.date_delivery']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">';
|
||||
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliverymonth" value="'.$search_deliverymonth.'">';
|
||||
$formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5);
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_datedelivery_start?$search_datedelivery_start:-1, 'search_datedelivery_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_datedelivery_end?$search_datedelivery_end:-1, 'search_datedelivery_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['c.total_ht']['checked']))
|
||||
@ -804,6 +812,8 @@ if ($resql)
|
||||
$generic_commande->total_ht = $obj->total_ht;
|
||||
$generic_commande->total_tva = $obj->total_tva;
|
||||
$generic_commande->total_ttc = $obj->total_ttc;
|
||||
$generic_commande->note_public = $obj->note_public;
|
||||
$generic_commande->note_private = $obj->note_private;
|
||||
|
||||
$projectstatic->id = $obj->project_id;
|
||||
$projectstatic->ref = $obj->project_ref;
|
||||
@ -818,7 +828,7 @@ if ($resql)
|
||||
|
||||
$generic_commande->getLinesArray(); // This set ->lines
|
||||
|
||||
print $generic_commande->getNomUrl(1, ($viewstatut != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1);
|
||||
print $generic_commande->getNomUrl(1, ($viewstatut != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
|
||||
|
||||
// Show shippable Icon (create subloop, so may be slow)
|
||||
if ($conf->stock->enabled)
|
||||
@ -926,12 +936,6 @@ if ($resql)
|
||||
if ($generic_commande->hasDelay()) {
|
||||
print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
|
||||
}
|
||||
if (!empty($obj->note_private) || !empty($obj->note_public))
|
||||
{
|
||||
print ' <span class="note">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/commande/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
|
||||
print '</span>';
|
||||
}
|
||||
|
||||
$filename = dol_sanitizeFileName($obj->ref);
|
||||
$filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
|
||||
@ -1054,7 +1058,7 @@ if ($resql)
|
||||
// Amount HT
|
||||
if (!empty($arrayfields['c.total_ht']['checked']))
|
||||
{
|
||||
print '<td class="right">'.price($obj->total_ht)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($obj->total_ht)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht';
|
||||
$totalarray['val']['c.total_ht'] += $obj->total_ht;
|
||||
@ -1062,7 +1066,7 @@ if ($resql)
|
||||
// Amount VAT
|
||||
if (!empty($arrayfields['c.total_vat']['checked']))
|
||||
{
|
||||
print '<td class="right">'.price($obj->total_tva)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($obj->total_tva)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva';
|
||||
$totalarray['val']['c.total_tva'] += $obj->total_tva;
|
||||
@ -1070,7 +1074,7 @@ if ($resql)
|
||||
// Amount TTC
|
||||
if (!empty($arrayfields['c.total_ttc']['checked']))
|
||||
{
|
||||
print '<td class="right">'.price($obj->total_ttc)."</td>\n";
|
||||
print '<td class="nowrap right">'.price($obj->total_ttc)."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc';
|
||||
$totalarray['val']['c.total_ttc'] += $obj->total_ttc;
|
||||
|
||||
@ -690,7 +690,7 @@ else
|
||||
// Categories
|
||||
if ($conf->categorie->enabled) {
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
|
||||
print $form->showCategories($object->id, 'bank_account', 1);
|
||||
print $form->showCategories($object->id, Categorie::TYPE_ACCOUNT, 1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
@ -135,9 +135,9 @@ class PaymentVarious extends CommonObject
|
||||
if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',";
|
||||
$sql.= " datep='".$this->db->idate($this->datep)."',";
|
||||
$sql.= " datev='".$this->db->idate($this->datev)."',";
|
||||
$sql.= " sens=".$this->sens.",";
|
||||
$sql.= " sens=".(int) $this->sens.",";
|
||||
$sql.= " amount=".price2num($this->amount).",";
|
||||
$sql.= " fk_typepayment=".$this->fk_typepayment."',";
|
||||
$sql.= " fk_typepayment=".(int) $this->fk_typepayment.",";
|
||||
$sql.= " num_payment='".$this->db->escape($this->num_payment)."',";
|
||||
$sql.= " label='".$this->db->escape($this->label)."',";
|
||||
$sql.= " note='".$this->db->escape($this->note)."',";
|
||||
@ -145,8 +145,8 @@ class PaymentVarious extends CommonObject
|
||||
$sql.= " subledger_account='".$this->db->escape($this->subledger_account)."',";
|
||||
$sql.= " fk_projet='".$this->db->escape($this->fk_project)."',";
|
||||
$sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").",";
|
||||
$sql.= " fk_user_author=".$this->fk_user_author.",";
|
||||
$sql.= " fk_user_modif=".$this->fk_user_modif;
|
||||
$sql.= " fk_user_author=".(int) $this->fk_user_author.",";
|
||||
$sql.= " fk_user_modif=".(int) $this->fk_user_modif;
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
@ -682,4 +682,40 @@ class PaymentVarious extends CommonObject
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if a various payment linked to a bank line id was dispatched into bookkeeping
|
||||
*
|
||||
* @return int <0 if KO, 0=no, 1=yes
|
||||
*/
|
||||
public function getVentilExportCompta()
|
||||
{
|
||||
$banklineid = $this->fk_bank;
|
||||
|
||||
$alreadydispatched = 0;
|
||||
|
||||
$type = 'bank';
|
||||
|
||||
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$banklineid;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
$alreadydispatched = $obj->nb;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($alreadydispatched)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,12 +38,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
|
||||
//show files
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips"));
|
||||
$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan"));
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$id = GETPOST('account', 'int');
|
||||
@ -202,6 +205,9 @@ $paymentvatstatic = new TVA($db);
|
||||
$bankstatic = new Account($db);
|
||||
$banklinestatic = new AccountLine($db);
|
||||
$remisestatic = new RemiseCheque($db);
|
||||
$paymentdonationstatic=new PaymentDonation($db);
|
||||
$paymentloanstatic=new PaymentLoan($db);
|
||||
$paymentvariousstatic=new PaymentVarious($db);
|
||||
|
||||
// Must be before button action
|
||||
$param = '';
|
||||
@ -512,7 +518,28 @@ else
|
||||
print '</a>';
|
||||
$newline = 0;
|
||||
}
|
||||
elseif ($links[$key]['type'] == 'banktransfert') {
|
||||
elseif ($links[$key]['type']=='payment_donation')
|
||||
{
|
||||
$paymentdonationstatic->id=$links[$key]['url_id'];
|
||||
$paymentdonationstatic->ref=$langs->trans("Payment");
|
||||
print ' '.$paymentdonationstatic->getNomUrl(1);
|
||||
$newline = 0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_loan')
|
||||
{
|
||||
$paymentloanstatic->id=$links[$key]['url_id'];
|
||||
$paymentloanstatic->ref=$langs->trans("Payment");
|
||||
print ' '.$paymentloanstatic->getNomUrl(1);
|
||||
$newline = 0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_various')
|
||||
{
|
||||
$paymentvariousstatic->id=$links[$key]['url_id'];
|
||||
$paymentvariousstatic->ref=$langs->trans("Payment");
|
||||
print ' '.$paymentvariousstatic->getNomUrl(1);
|
||||
$newline = 0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='banktransfert') {
|
||||
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
|
||||
if ($objp->amount > 0)
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
@ -238,6 +238,7 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>';
|
||||
@ -261,6 +262,7 @@ print '<td><input name="amount" class="flat" type="text" size="6" value="'.dol_e
|
||||
print '<td style="display:none" class="multicurrency"><input name="amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>';
|
||||
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
|
||||
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></div>';
|
||||
|
||||
|
||||
@ -64,6 +64,7 @@ $object = new PaymentVarious($db);
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('variouscard','globalcard'));
|
||||
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
@ -216,6 +217,20 @@ if (empty($reshook))
|
||||
setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setsubledger_account') {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$object->subledger_account = (GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : "");
|
||||
|
||||
$res = $object->update($user);
|
||||
if ($res > 0) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -412,6 +427,8 @@ if ($action == 'create')
|
||||
|
||||
if ($id)
|
||||
{
|
||||
$alreadyaccounted = $object->getVentilExportCompta();
|
||||
|
||||
$head=various_payment_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
|
||||
@ -456,7 +473,7 @@ if ($id)
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Label
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||
@ -495,9 +512,9 @@ if ($id)
|
||||
|
||||
// Subledger account
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("SubledgerAccount");
|
||||
print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
|
||||
print '</td><td>';
|
||||
print $object->subledger_account;
|
||||
print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
|
||||
print '</td></tr>';
|
||||
|
||||
if (!empty($conf->banque->enabled))
|
||||
@ -542,7 +559,11 @@ if ($id)
|
||||
{
|
||||
if (!empty($user->rights->banque->modifier))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a></div>';
|
||||
if ($alreadyaccounted) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("Accounted").'">'.$langs->trans("Delete").'</a></div>';
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a></div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -134,7 +134,7 @@ if ($object->id)
|
||||
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
/* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
@ -44,11 +44,15 @@ $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
|
||||
$search_ref = GETPOST('search_ref', 'int');
|
||||
$search_user = GETPOST('search_user', 'alpha');
|
||||
$search_label = GETPOST('search_label', 'alpha');
|
||||
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
|
||||
$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
|
||||
$search_amount_deb = GETPOST('search_amount_deb', 'alpha');
|
||||
$search_amount_cred = GETPOST('search_amount_cred', 'alpha');
|
||||
$search_account = GETPOST('search_account', 'int');
|
||||
$search_date = dol_mktime(0, 0, 0, GETPOST('date_docmonth', 'int'), GETPOST('date_docday', 'int'), GETPOST('date_docyear', 'int'));
|
||||
$search_accountancy_code = GETPOST("search_accountancy_code");
|
||||
$search_accountancy_account = GETPOST("search_accountancy_account");
|
||||
if ($search_accountancy_account == - 1) $search_accountancy_account = '';
|
||||
$search_accountancy_subledger = GETPOST("search_accountancy_subledger");
|
||||
if ($search_accountancy_subledger == - 1) $search_accountancy_subledger = '';
|
||||
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
@ -81,12 +85,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
||||
{
|
||||
$search_ref="";
|
||||
$search_label="";
|
||||
$search_date_start='';
|
||||
$search_date_end='';
|
||||
$search_amount_deb="";
|
||||
$search_amount_cred="";
|
||||
$search_account='';
|
||||
$search_accountancy_account = '';
|
||||
$search_accountancy_subledger = '';
|
||||
$typeid="";
|
||||
$search_date = '';
|
||||
$search_accountancy_code = '';
|
||||
}
|
||||
|
||||
/*
|
||||
@ -100,7 +106,7 @@ $formaccounting = new FormAccounting($db);
|
||||
$variousstatic = new PaymentVarious($db);
|
||||
$accountstatic = new Account($db);
|
||||
|
||||
$sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code,";
|
||||
$sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account,";
|
||||
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
|
||||
$sql.= " pst.code as payment_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
|
||||
@ -110,14 +116,16 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.row
|
||||
$sql.= " WHERE v.entity IN (".getEntity('payment_various').")";
|
||||
|
||||
// Search criteria
|
||||
if ($search_ref) $sql.=" AND v.rowid=".$db->escape($search_ref);
|
||||
if ($search_label) $sql.=natural_search(array('v.label'), $search_label);
|
||||
if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1);
|
||||
if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1);
|
||||
if ($search_account > 0) $sql.=" AND b.fk_account=".$db->escape($search_account);
|
||||
if ($search_date) $sql.=" AND v.datep = '".$db->idate($search_date)."'";
|
||||
if ($search_accountancy_code > 0) $sql.=" AND v.accountancy_code=".$db->escape($search_accountancy_code);
|
||||
if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid;
|
||||
if ($search_ref) $sql.= " AND v.rowid=".$db->escape($search_ref);
|
||||
if ($search_label) $sql.= natural_search(array('v.label'), $search_label);
|
||||
if ($search_date_start) $sql.= " AND v.datep >= '" . $db->idate($search_date_start) . "'";
|
||||
if ($search_date_end) $sql.= " AND v.datep <= '" . $db->idate($search_date_end) . "'";
|
||||
if ($search_amount_deb) $sql.= natural_search("v.amount", $search_amount_deb, 1);
|
||||
if ($search_amount_cred) $sql.= natural_search("v.amount", $search_amount_cred, 1);
|
||||
if ($search_account > 0) $sql.= " AND b.fk_account=".$db->escape($search_account);
|
||||
if ($search_accountancy_account > 0) $sql.= " AND v.accountancy_code=".$db->escape($search_accountancy_account);
|
||||
if ($search_accountancy_subledger > 0) $sql.= " AND v.subledger_account=".$db->escape($search_accountancy_subledger);
|
||||
if ($typeid > 0) $sql.= " AND v.fk_typepayment=".$typeid;
|
||||
if ($filtre) {
|
||||
$filtre=str_replace(":", "=", $filtre);
|
||||
$sql .= " AND ".$filtre;
|
||||
@ -143,14 +151,16 @@ if ($result)
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
|
||||
if ($search_label) $param.='&search_label='.urlencode($search_label);
|
||||
if ($typeid > 0) $param.='&typeid='.urlencode($typeid);
|
||||
if ($search_amount_deb) $param.='&search_amount_deb='.urlencode($search_amount_deb);
|
||||
if ($search_amount_cred) $param.='&search_amount_cred='.urlencode($search_amount_cred);
|
||||
if ($search_account > 0) $param.='&search_amount='.urlencode($search_account);
|
||||
//if ($search_date) $param.='&search_date='.$search_date;
|
||||
if ($search_accountancy_code > 0) $param.='&search_accountancy_code='.urlencode($search_accountancy_code);
|
||||
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
|
||||
if ($search_label) $param.='&search_label='.urlencode($search_label);
|
||||
if ($search_date_start) $param.='&search_date_start='.urlencode($search_date_start);
|
||||
if ($search_date_end) $param.='&search_date_end='.urlencode($search_date_end);
|
||||
if ($typeid > 0) $param.='&typeid='.urlencode($typeid);
|
||||
if ($search_amount_deb) $param.='&search_amount_deb='.urlencode($search_amount_deb);
|
||||
if ($search_amount_cred) $param.='&search_amount_cred='.urlencode($search_amount_cred);
|
||||
if ($search_account > 0) $param.='&search_amount='.urlencode($search_account);
|
||||
if ($search_accountancy_account > 0) $param.='&search_accountancy_account='.urlencode($search_accountancy_account);
|
||||
if ($search_accountancy_subledger > 0) $param.='&search_accountancy_subledger='.urlencode($search_accountancy_subledger);
|
||||
|
||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||
|
||||
@ -188,7 +198,13 @@ if ($result)
|
||||
// Date
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search_date, 'date_doc', 0, 0, 1);
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
|
||||
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
|
||||
@ -208,9 +224,17 @@ if ($result)
|
||||
// Accounting account
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
// Accounting account
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
print $formaccounting->select_account($search_accountancy_code, 'search_accountancy_code', 1, array(), 1, 1, 'maxwidth200');
|
||||
print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array (), 1, 1, 'maxwidth200');
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
|
||||
// Subledger account
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, array (), 1, 1, 'maxwidth200');
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
@ -234,8 +258,9 @@ if ($result)
|
||||
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "v.label", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "v.datep,v.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "v.accountancy_code", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccountingShort", $_SERVER["PHP_SELF"], "v.accountancy_code", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
if (! empty($conf->accounting->enabled)) print_liste_field_titre("SubledgerAccount", $_SERVER["PHP_SELF"], "v.subledger_account", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||
@ -303,6 +328,13 @@ if ($result)
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Accounting subledger account
|
||||
if (! empty($conf->accounting->enabled))
|
||||
{
|
||||
print '<td>' . length_accounta($obj->subledger_account) . '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Debit
|
||||
print '<td class="nowrap right">';
|
||||
if ($obj->sens == 0)
|
||||
@ -312,7 +344,7 @@ if ($result)
|
||||
}
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='total_deb';
|
||||
print "</td>";
|
||||
print '</td>';
|
||||
|
||||
// Credit
|
||||
print '<td class="nowrap right">';
|
||||
|
||||
@ -780,6 +780,23 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
// If some payments were already done, we change the amount to pay using same prorate
|
||||
if (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) {
|
||||
$alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded.
|
||||
if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) {
|
||||
$ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc);
|
||||
foreach($amount_ht as $vatrate => $val) {
|
||||
$amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU');
|
||||
$amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU');
|
||||
$amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU');
|
||||
$multicurrency_amount_ht[$line->tva_tx] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU');
|
||||
$multicurrency_amount_tva[$line->tva_tx] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU');
|
||||
$multicurrency_amount_ttc[$line->tva_tx] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU');
|
||||
}
|
||||
}
|
||||
}
|
||||
//var_dump($amount_ht);var_dump($amount_tva);var_dump($amount_ttc);exit;
|
||||
|
||||
// Insert one discount by VAT rate category
|
||||
$discount = new DiscountAbsolute($db);
|
||||
if ($object->type == Facture::TYPE_CREDIT_NOTE)
|
||||
@ -1520,7 +1537,7 @@ if (empty($reshook))
|
||||
if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')';
|
||||
|
||||
// View third's localtaxes for NOW and do not use value from origin.
|
||||
// TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ?
|
||||
// TODO Is this really what we want ? Yes if source is template invoice but what if proposal or order ?
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
|
||||
|
||||
@ -3189,13 +3206,13 @@ if ($action == 'create')
|
||||
|
||||
$thirdparty = $soc;
|
||||
$discount_type = 0;
|
||||
$backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid'));
|
||||
$backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin', 'alpha').'&originid='.GETPOST('originid', 'int'));
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||
$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
|
||||
// Date invoice
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('DateInvoice').'</td><td colspan="2">';
|
||||
@ -3206,14 +3223,14 @@ if ($action == 'create')
|
||||
if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
|
||||
{
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('DatePointOfTax').'</td><td colspan="2">';
|
||||
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
|
||||
$date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
|
||||
print $form->selectDate($date_pointoftax ? $date_pointoftax : -1, 'date_pointoftax', '', '', '', "add", 1, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Payment term
|
||||
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
|
||||
$form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
|
||||
$form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
if (!empty($conf->global->INVOICE_USE_SITUATION))
|
||||
@ -3730,18 +3747,24 @@ elseif ($id > 0 || !empty($ref))
|
||||
$i++;
|
||||
$close[$i]['code'] = 'badcustomer';
|
||||
$i++;
|
||||
$close[$i]['code'] = 'other';
|
||||
$i++;
|
||||
// Help
|
||||
$i = 0;
|
||||
$close[$i]['label'] = $langs->trans("HelpEscompte").'<br><br>'.$langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
|
||||
$i++;
|
||||
$close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");
|
||||
$i++;
|
||||
$close[$i]['label'] = $langs->trans("Other");
|
||||
$i++;
|
||||
// Texte
|
||||
$i = 0;
|
||||
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1);
|
||||
$i++;
|
||||
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1);
|
||||
$i++;
|
||||
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1);
|
||||
$i++;
|
||||
// arrayreasons[code]=reason
|
||||
foreach ($close as $key => $val) {
|
||||
$arrayreasons[$close [$key]['code']] = $close[$key]['reason'];
|
||||
@ -5014,7 +5037,9 @@ elseif ($id > 0 || !empty($ref))
|
||||
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertExcessReceivedToReduc').'</a>';
|
||||
}
|
||||
// For credit note
|
||||
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) {
|
||||
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate
|
||||
&& (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
|
||||
) {
|
||||
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReduc2")).'">'.$langs->trans('ConvertToReduc').'</a>';
|
||||
}
|
||||
// For deposit invoice
|
||||
|
||||
@ -79,7 +79,7 @@ class FactureStats extends Stats
|
||||
$this->field_line='total_ht';
|
||||
}
|
||||
|
||||
$this->where = " f.fk_statut > 0";
|
||||
$this->where = " f.fk_statut >= 0";
|
||||
$this->where.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons)
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -98,12 +99,10 @@ $search_country = GETPOST("search_country", 'int');
|
||||
$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
|
||||
$search_user = GETPOST('search_user', 'int');
|
||||
$search_sale = GETPOST('search_sale', 'int');
|
||||
$search_day = GETPOST('search_day', 'int');
|
||||
$search_month = GETPOST('search_month', 'int');
|
||||
$search_year = GETPOST('search_year', 'int');
|
||||
$search_day_lim = GETPOST('search_day_lim', 'int');
|
||||
$search_month_lim = GETPOST('search_month_lim', 'int');
|
||||
$search_year_lim = GETPOST('search_year_lim', 'int');
|
||||
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
|
||||
$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
|
||||
$search_datelimit_start = dol_mktime(0, 0, 0, GETPOST('search_datelimit_startmonth', 'int'), GETPOST('search_datelimit_startday', 'int'), GETPOST('search_datelimit_startyear', 'int'));
|
||||
$search_datelimit_end = dol_mktime(23, 59, 59, GETPOST('search_datelimit_endmonth', 'int'), GETPOST('search_datelimit_endday', 'int'), GETPOST('search_datelimit_endyear', 'int'));
|
||||
$search_categ_cus = trim(GETPOST("search_categ_cus", 'int'));
|
||||
$search_btn = GETPOST('button_search', 'alpha');
|
||||
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
|
||||
@ -248,14 +247,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
|
||||
$search_type = '';
|
||||
$search_country = '';
|
||||
$search_type_thirdparty = '';
|
||||
$search_day = '';
|
||||
$search_year = '';
|
||||
$search_month = '';
|
||||
$search_date_start = '';
|
||||
$search_date_end = '';
|
||||
$search_datelimit_start = '';
|
||||
$search_datelimit_end = '';
|
||||
$option = '';
|
||||
$filter = '';
|
||||
$search_day_lim = '';
|
||||
$search_year_lim = '';
|
||||
$search_month_lim = '';
|
||||
$toselect = '';
|
||||
$search_array_options = array();
|
||||
$search_categ_cus = 0;
|
||||
@ -478,12 +475,15 @@ if ($search_status != '-1' && $search_status != '')
|
||||
$sql .= " AND f.fk_statut IN (".$db->escape($search_status).")"; // When search_status is '1,2' for example
|
||||
}
|
||||
}
|
||||
|
||||
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode);
|
||||
if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms);
|
||||
if ($search_module_source) $sql .= natural_search("f.module_source", $search_module_source);
|
||||
if ($search_pos_source) $sql .= natural_search("f.pos_source", $search_pos_source);
|
||||
$sql .= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year);
|
||||
$sql .= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim);
|
||||
if ($search_date_start) $sql .= " AND f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
if ($search_date_end) $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
if ($search_datelimit_start) $sql .= " AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) . "'";
|
||||
if ($search_datelimit_end) $sql .= " AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) . "'";
|
||||
if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'";
|
||||
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".(int) $search_sale;
|
||||
if ($search_user > 0)
|
||||
@ -571,12 +571,10 @@ if ($resql)
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($sall) $param .= '&sall='.urlencode($sall);
|
||||
if ($search_day) $param .= '&search_day='.urlencode($search_day);
|
||||
if ($search_month) $param .= '&search_month='.urlencode($search_month);
|
||||
if ($search_year) $param .= '&search_year='.urlencode($search_year);
|
||||
if ($search_day_lim) $param .= '&search_day_lim='.urlencode($search_day_lim);
|
||||
if ($search_month_lim) $param .= '&search_month_lim='.urlencode($search_month_lim);
|
||||
if ($search_year_lim) $param .= '&search_year_lim='.urlencode($search_year_lim);
|
||||
if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start);
|
||||
if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end);
|
||||
if ($search_datelimit_start) $param .= '&search_datelimit_start='.urlencode($search_datelimit_start);
|
||||
if ($search_datelimit_end) $param .= '&search_datelimit_end='.urlencode($search_datelimit_end);
|
||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer);
|
||||
if ($search_project_ref) $param .= '&search_project_ref='.urlencode($search_project_ref);
|
||||
@ -752,20 +750,29 @@ if ($resql)
|
||||
// Date invoice
|
||||
if (!empty($arrayfields['f.date']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
|
||||
print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
|
||||
$formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Date due
|
||||
if (!empty($arrayfields['f.date_lim_reglement']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_lim" value="'.dol_escape_htmltag($search_day_lim).'">';
|
||||
print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_lim" value="'.dol_escape_htmltag($search_month_lim).'">';
|
||||
$formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
|
||||
print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert");
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $form->selectDate($search_datelimit_start?$search_datelimit_start:-1, 'search_datelimit_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $form->selectDate($search_datelimit_end?$search_datelimit_end:-1, 'search_datelimit_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Project ref
|
||||
@ -778,7 +785,7 @@ if ($resql)
|
||||
{
|
||||
print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.$search_project.'"></td>';
|
||||
}
|
||||
// Thirpdarty
|
||||
// Thirdparty
|
||||
if (!empty($arrayfields['s.nom']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_societe" value="'.$search_societe.'"></td>';
|
||||
|
||||
@ -327,28 +327,6 @@ class Paiement extends CommonObject
|
||||
|
||||
//var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit;
|
||||
|
||||
/* Why this ? We can remove i think.
|
||||
// If there is withdrawals request to do and not done yet on the invoice the payment is on, we wait before closing.
|
||||
$mustwait=0;
|
||||
$sqlrequest ="SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."prelevement_facture_demande";
|
||||
$sqlrequest.="WHERE fk_facture = ".$invoice->id." AND traite = 0";
|
||||
...
|
||||
|
||||
$listofpayments=$invoice->getListOfPayments();
|
||||
foreach($listofpayments as $paym)
|
||||
{
|
||||
// This payment on invoice $invoice might be the one we record or another one
|
||||
if ($paym['type']=='PRE')
|
||||
{
|
||||
if (! empty($conf->prelevement->enabled))
|
||||
{
|
||||
// if not, $mustwait++; // This will disable automatic close on invoice to allow to process
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//Invoice types that are eligible for changing status to paid
|
||||
$affected_types = array(
|
||||
Facture::TYPE_STANDARD,
|
||||
|
||||
@ -49,10 +49,10 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public $table_element = 'prelevement_bons';
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'payment';
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'payment';
|
||||
|
||||
public $date_echeance;
|
||||
public $raison_sociale;
|
||||
@ -116,7 +116,7 @@ class BonPrelevement extends CommonObject
|
||||
$this->fetched = 0;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Add invoice to withdrawal
|
||||
*
|
||||
@ -132,7 +132,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$result = 0;
|
||||
$line_id = 0;
|
||||
|
||||
@ -196,8 +196,8 @@ class BonPrelevement extends CommonObject
|
||||
if ($concat == 1)
|
||||
{
|
||||
/*
|
||||
* We aggregate the lines
|
||||
*/
|
||||
* We aggregate the lines
|
||||
*/
|
||||
$sql = "SELECT rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes";
|
||||
$sql .= " WHERE fk_prelevement_bons = ".$this->id;
|
||||
@ -219,8 +219,8 @@ class BonPrelevement extends CommonObject
|
||||
else
|
||||
{
|
||||
/*
|
||||
* No aggregate
|
||||
*/
|
||||
* No aggregate
|
||||
*/
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_lignes (";
|
||||
$sql .= "fk_prelevement_bons";
|
||||
$sql .= ", fk_soc";
|
||||
@ -335,7 +335,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Set credite and set status of linked invoices. Still used ??
|
||||
*
|
||||
@ -343,7 +343,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function set_credite()
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $user, $conf;
|
||||
|
||||
$error = 0;
|
||||
@ -351,7 +351,7 @@ class BonPrelevement extends CommonObject
|
||||
if ($this->db->begin())
|
||||
{
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
|
||||
$sql .= " SET statut = 1";
|
||||
$sql .= " SET statut = ".self::STATUS_TRANSFERED;
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
@ -392,8 +392,8 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
|
||||
/*
|
||||
* End of procedure
|
||||
*/
|
||||
* End of procedure
|
||||
*/
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
@ -414,7 +414,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Set direct debit order to "credited" status.
|
||||
*
|
||||
@ -424,7 +424,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function set_infocredit($user, $date)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
@ -437,11 +437,11 @@ class BonPrelevement extends CommonObject
|
||||
{
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons ";
|
||||
$sql .= " SET fk_user_credit = ".$user->id;
|
||||
$sql .= ", statut = 2";
|
||||
$sql .= ", statut = ".self::STATUS_CREDITED;
|
||||
$sql .= ", date_credit = '".$this->db->idate($date)."'";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$sql .= " AND statut = 1";
|
||||
$sql .= " AND statut = ".self::STATUS_TRANSFERED;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
@ -483,7 +483,8 @@ class BonPrelevement extends CommonObject
|
||||
$paiement->datepaye = $date;
|
||||
$paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice
|
||||
$paiement->paiementid = 3; //
|
||||
$paiement->num_paiement = $this->ref; // Set ref of direct debit note
|
||||
$paiement->num_payment = $this->ref; // Set ref of direct debit note
|
||||
$paiement->num_paiement = $this->ref; // For bacward compatibility
|
||||
$paiement->id_prelevement = $this->id;
|
||||
|
||||
$paiement_id = $paiement->create($user);
|
||||
@ -525,12 +526,12 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
|
||||
/*
|
||||
* End of procedure
|
||||
*/
|
||||
* End of procedure
|
||||
*/
|
||||
if ($error == 0)
|
||||
{
|
||||
$this->date_credit = $date;
|
||||
$this->statut = 1;
|
||||
$this->statut = self::STATUS_CREDITED;
|
||||
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
@ -560,7 +561,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Set withdrawal to transmited status
|
||||
*
|
||||
@ -571,7 +572,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function set_infotrans($user, $date, $method)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
@ -639,9 +640,9 @@ class BonPrelevement extends CommonObject
|
||||
$arr = array();
|
||||
|
||||
/*
|
||||
* Returns all invoices presented
|
||||
* within a withdrawal receipt
|
||||
*/
|
||||
* Returns all invoices presented
|
||||
* within a withdrawal receipt
|
||||
*/
|
||||
$sql = "SELECT fk_facture";
|
||||
if ($amounts) $sql .= ", SUM(pl.amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
@ -685,7 +686,7 @@ class BonPrelevement extends CommonObject
|
||||
return $arr;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Returns amount of withdrawal
|
||||
*
|
||||
@ -693,7 +694,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function SommeAPrelever()
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT sum(pfd.amount) as nb";
|
||||
@ -724,7 +725,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Get number of invoices to withdrawal
|
||||
* TODO delete params banque and agence when not necesary
|
||||
@ -735,7 +736,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function NbFactureAPrelever($banque = 0, $agence = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT count(f.rowid) as nb";
|
||||
@ -769,7 +770,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Create a withdraw
|
||||
* TODO delete params banque and agence when not necesary
|
||||
@ -784,7 +785,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function Create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $user;
|
||||
|
||||
dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG);
|
||||
@ -797,8 +798,8 @@ class BonPrelevement extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
$datetimeprev = time();
|
||||
//Choice the date of the execution direct debit
|
||||
if (!empty($executiondate)) $datetimeprev = $executiondate;
|
||||
//Choice the date of the execution direct debit
|
||||
if (!empty($executiondate)) $datetimeprev = $executiondate;
|
||||
|
||||
$month = strftime("%m", $datetimeprev);
|
||||
$year = strftime("%Y", $datetimeprev);
|
||||
@ -929,12 +930,12 @@ class BonPrelevement extends CommonObject
|
||||
|
||||
// Return warning
|
||||
/*$i=0;
|
||||
foreach ($this->thirdparty_in_error as $key => $val)
|
||||
{
|
||||
if ($i < 10) setEventMessages($val, null, 'warnings');
|
||||
else setEventMessages('More error were discarded...', null, 'warnings');
|
||||
$i++;
|
||||
}*/
|
||||
foreach ($this->thirdparty_in_error as $key => $val)
|
||||
{
|
||||
if ($i < 10) setEventMessages($val, null, 'warnings');
|
||||
else setEventMessages('More error were discarded...', null, 'warnings');
|
||||
$i++;
|
||||
}*/
|
||||
|
||||
if (count($factures_prev) > 0)
|
||||
{
|
||||
@ -952,16 +953,16 @@ class BonPrelevement extends CommonObject
|
||||
if ($ok)
|
||||
{
|
||||
/*
|
||||
* We are in real mode.
|
||||
* We create withdraw receipt and build withdraw into disk
|
||||
*/
|
||||
* We are in real mode.
|
||||
* We create withdraw receipt and build withdraw into disk
|
||||
*/
|
||||
$this->db->begin();
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
/*
|
||||
* Traitements
|
||||
*/
|
||||
* Traitements
|
||||
*/
|
||||
if (!$error)
|
||||
{
|
||||
$ref = substr($year, -2).$month;
|
||||
@ -1017,8 +1018,8 @@ class BonPrelevement extends CommonObject
|
||||
if (!$error)
|
||||
{
|
||||
/*
|
||||
* Create withdrawal receipt in database
|
||||
*/
|
||||
* Create withdrawal receipt in database
|
||||
*/
|
||||
if (count($factures_prev) > 0)
|
||||
{
|
||||
foreach ($factures_prev as $fac) // Add a link in database for each invoice
|
||||
@ -1027,17 +1028,17 @@ class BonPrelevement extends CommonObject
|
||||
$fact = new Facture($this->db);
|
||||
$fact->fetch($fac[0]);
|
||||
/*
|
||||
* Add standing order
|
||||
*
|
||||
*
|
||||
* $fac[3] : banque
|
||||
* $fac[4] : guichet
|
||||
* $fac[5] : number
|
||||
* $fac[6] : cle rib
|
||||
* $fac[7] : amount
|
||||
* $fac[8] : client nom
|
||||
* $fac[2] : client id
|
||||
*/
|
||||
* Add standing order
|
||||
*
|
||||
*
|
||||
* $fac[3] : banque
|
||||
* $fac[4] : guichet
|
||||
* $fac[5] : number
|
||||
* $fac[6] : cle rib
|
||||
* $fac[7] : amount
|
||||
* $fac[8] : client nom
|
||||
* $fac[2] : client id
|
||||
*/
|
||||
$ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6]);
|
||||
if ($ri <> 0)
|
||||
{
|
||||
@ -1066,8 +1067,8 @@ class BonPrelevement extends CommonObject
|
||||
if (!$error)
|
||||
{
|
||||
/*
|
||||
* Create direct debit order in a XML file
|
||||
*/
|
||||
* Create direct debit order in a XML file
|
||||
*/
|
||||
|
||||
dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG);
|
||||
|
||||
@ -1104,8 +1105,8 @@ class BonPrelevement extends CommonObject
|
||||
//var_dump($factures_prev);exit;
|
||||
|
||||
/*
|
||||
* Update total
|
||||
*/
|
||||
* Update total
|
||||
*/
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
|
||||
$sql .= " SET amount = ".price2num($this->total);
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
@ -1118,13 +1119,13 @@ class BonPrelevement extends CommonObject
|
||||
dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR);
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
@ -1160,10 +1161,10 @@ class BonPrelevement extends CommonObject
|
||||
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
@ -1210,11 +1211,11 @@ class BonPrelevement extends CommonObject
|
||||
/**
|
||||
* Returns clickable name (with picto)
|
||||
*
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to ('nolink', ...)
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $morecss Add more css on link
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to ('nolink', ...)
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $morecss Add more css on link
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string URL of target
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
|
||||
@ -1280,7 +1281,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Delete a notification def by id
|
||||
*
|
||||
@ -1289,7 +1290,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function DeleteNotificationById($rowid)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$result = 0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
|
||||
@ -1305,7 +1306,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Delete a notification
|
||||
*
|
||||
@ -1315,7 +1316,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function DeleteNotification($user, $action)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$result = 0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
|
||||
@ -1331,7 +1332,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Add a notification
|
||||
*
|
||||
@ -1342,7 +1343,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function AddNotification($db, $user, $action)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
$result = 0;
|
||||
|
||||
if ($this->DeleteNotification($user, $action) == 0)
|
||||
@ -1376,7 +1377,7 @@ class BonPrelevement extends CommonObject
|
||||
* File is generated with name this->filename
|
||||
*
|
||||
* @param string $format FRST, RCUR or ALL
|
||||
* @param string $executiondate Date to execute transfer
|
||||
* @param string $executiondate Date to execute transfer
|
||||
* @return int 0 if OK, <0 if KO
|
||||
*/
|
||||
public function generate($format = 'ALL', $executiondate = '')
|
||||
@ -1414,7 +1415,7 @@ class BonPrelevement extends CommonObject
|
||||
$dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S');
|
||||
|
||||
$date_actu = $now;
|
||||
if (!empty($executiondate)) $date_actu = $executiondate;
|
||||
if (!empty($executiondate)) $date_actu = $executiondate;
|
||||
|
||||
$dateTime_YMD = dol_print_date($date_actu, '%Y%m%d');
|
||||
$dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S');
|
||||
@ -1554,12 +1555,12 @@ class BonPrelevement extends CommonObject
|
||||
|
||||
fclose($this->file);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($this->file, octdec($conf->global->MAIN_UMASK));
|
||||
return $result;
|
||||
@chmod($this->file, octdec($conf->global->MAIN_UMASK));
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Write recipient of request (customer)
|
||||
*
|
||||
@ -1576,7 +1577,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
fputs($this->file, "06");
|
||||
fputs($this->file, "08"); // Prelevement ordinaire
|
||||
|
||||
@ -1647,7 +1648,7 @@ class BonPrelevement extends CommonObject
|
||||
return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Write recipient of request (customer)
|
||||
*
|
||||
@ -1667,15 +1668,15 @@ class BonPrelevement extends CommonObject
|
||||
* @param string $row_bic rib.bic AS bic,
|
||||
* @param string $row_datec rib.datec,
|
||||
* @param string $row_drum rib.rowid used to generate rum
|
||||
* @param string $row_rum rib.rum Rum defined on company bank account
|
||||
* @param string $row_rum rib.rum Rum defined on company bank account
|
||||
* @return string Return string with SEPA part DrctDbtTxInf
|
||||
*/
|
||||
public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum, $row_rum)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
$CrLf = "\n";
|
||||
$Rowing = sprintf("%06d", $row_idfac);
|
||||
@ -1690,7 +1691,7 @@ class BonPrelevement extends CommonObject
|
||||
$XML_DEBITOR = '';
|
||||
$XML_DEBITOR .= ' <DrctDbtTxInf>'.$CrLf;
|
||||
$XML_DEBITOR .= ' <PmtId>'.$CrLf;
|
||||
// $XML_DEBITOR .=' <EndToEndId>'.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||
// $XML_DEBITOR .=' <EndToEndId>'.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||
$XML_DEBITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||
$XML_DEBITOR .= ' </PmtId>'.$CrLf;
|
||||
$XML_DEBITOR .= ' <InstdAmt Ccy="EUR">'.round($row_somme, 2).'</InstdAmt>'.$CrLf;
|
||||
@ -1722,8 +1723,8 @@ class BonPrelevement extends CommonObject
|
||||
$XML_DEBITOR .= ' </Id>'.$CrLf;
|
||||
$XML_DEBITOR .= ' </DbtrAcct>'.$CrLf;
|
||||
$XML_DEBITOR .= ' <RmtInf>'.$CrLf;
|
||||
// $XML_DEBITOR .=' <Ustrd>'.($row_ref.'/'.$Rowing.'/'.$Rum).'</Ustrd>'.$CrLf;
|
||||
// $XML_DEBITOR .=' <Ustrd>'.dol_trunc($row_ref, 135).'</Ustrd>'.$CrLf; // 140 max
|
||||
// $XML_DEBITOR .=' <Ustrd>'.($row_ref.'/'.$Rowing.'/'.$Rum).'</Ustrd>'.$CrLf;
|
||||
// $XML_DEBITOR .=' <Ustrd>'.dol_trunc($row_ref, 135).'</Ustrd>'.$CrLf; // 140 max
|
||||
$XML_DEBITOR .= ' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).'</Ustrd>'.$CrLf; // 140 max
|
||||
$XML_DEBITOR .= ' </RmtInf>'.$CrLf;
|
||||
$XML_DEBITOR .= ' </DrctDbtTxInf>'.$CrLf;
|
||||
@ -1731,7 +1732,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Write sender of request (me)
|
||||
*
|
||||
@ -1739,7 +1740,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function EnregEmetteur()
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
fputs($this->file, "03");
|
||||
fputs($this->file, "08"); // Prelevement ordinaire
|
||||
|
||||
@ -1798,7 +1799,7 @@ class BonPrelevement extends CommonObject
|
||||
fputs($this->file, "\n");
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Write sender of request (me).
|
||||
* Note: The tag PmtInf is opened here but closed into caller
|
||||
@ -1813,7 +1814,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST')
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
// SEPA INITIALISATION
|
||||
global $conf;
|
||||
|
||||
@ -1892,13 +1893,13 @@ class BonPrelevement extends CommonObject
|
||||
$XML_SEPA_INFO .= ' </FinInstnId>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' </CdtrAgt>'.$CrLf;
|
||||
/* $XML_SEPA_INFO .= ' <UltmtCdtr>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <Nm>'.$this->raison_sociale.'</Nm>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <Ctry>'.$country[1].'</Ctry>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.'</AdrLine>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/
|
||||
$XML_SEPA_INFO .= ' <Nm>'.$this->raison_sociale.'</Nm>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <Ctry>'.$country[1].'</Ctry>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.'</AdrLine>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/
|
||||
$XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <CdtrSchmeId>'.$CrLf;
|
||||
$XML_SEPA_INFO .= ' <Id>'.$CrLf;
|
||||
@ -1921,7 +1922,7 @@ class BonPrelevement extends CommonObject
|
||||
return $XML_SEPA_INFO;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Write end
|
||||
*
|
||||
@ -1930,7 +1931,7 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function EnregTotal($total)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
fputs($this->file, "08");
|
||||
fputs($this->file, "08"); // Prelevement ordinaire
|
||||
|
||||
@ -1995,7 +1996,7 @@ class BonPrelevement extends CommonObject
|
||||
return $this->LibStatut($this->statut, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return status label for a status
|
||||
*
|
||||
|
||||
@ -108,6 +108,10 @@ class ChargeSociales extends CommonObject
|
||||
public $fk_project;
|
||||
|
||||
|
||||
const STATUS_UNPAID = 0;
|
||||
const STATUS_PAID = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -495,43 +499,23 @@ class ChargeSociales extends CommonObject
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("customers","bills"));
|
||||
|
||||
if ($mode == 0 || $mode == 1)
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if ($status == 0) return $langs->trans("Unpaid");
|
||||
elseif ($status == 1) return $langs->trans("Paid");
|
||||
}
|
||||
elseif ($mode == 2)
|
||||
{
|
||||
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
|
||||
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
|
||||
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
|
||||
}
|
||||
elseif ($mode == 3)
|
||||
{
|
||||
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1');
|
||||
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3');
|
||||
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6');
|
||||
}
|
||||
elseif ($mode == 4)
|
||||
{
|
||||
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
|
||||
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
|
||||
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
|
||||
}
|
||||
elseif ($mode == 5)
|
||||
{
|
||||
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
|
||||
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
|
||||
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
|
||||
}
|
||||
elseif ($mode == 6)
|
||||
{
|
||||
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
|
||||
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
|
||||
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
|
||||
global $langs;
|
||||
//$langs->load("mymodule");
|
||||
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid');
|
||||
$this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid');
|
||||
if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
|
||||
$this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft');
|
||||
$this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled');
|
||||
if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
|
||||
}
|
||||
|
||||
else return "Error, mode/status not found";
|
||||
$statusType = 'status1';
|
||||
if ($status == 0 && $alreadypaid > 0) $statusType = 'status3';
|
||||
if ($status == 1) $statusType = 'status6';
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -170,9 +170,11 @@ elseif ($modecompta == "RECETTES-DEPENSES")
|
||||
}
|
||||
elseif ($modecompta == "BOOKKEEPING")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
elseif ($modecompta == "BOOKKEEPINGCOLLECTED")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start - 1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start + 1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
@ -387,39 +389,53 @@ if (count($amount)) {
|
||||
|
||||
// Amount w/o VAT
|
||||
print '<td class="right">';
|
||||
if ($modecompta != 'CREANCES-DETTES')
|
||||
{
|
||||
if ($modecompta == 'RECETTES-DEPENSES') {
|
||||
if ($key > 0) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
|
||||
//print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
|
||||
} else {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
|
||||
//print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
|
||||
}
|
||||
} else {
|
||||
}
|
||||
elseif ($modecompta == 'CREANCES-DETTES') {
|
||||
if ($key > 0) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
|
||||
} else {
|
||||
print '<a href="#">';
|
||||
//print '<a href="#">';
|
||||
}
|
||||
print price($amount_ht[$key]);
|
||||
if ($key > 0) print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Amount with VAT
|
||||
print '<td class="right">';
|
||||
if ($modecompta != 'CREANCES-DETTES') {
|
||||
if ($modecompta == 'RECETTES-DEPENSES') {
|
||||
if ($key > 0) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
|
||||
//print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
|
||||
} else {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
|
||||
//print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
|
||||
}
|
||||
} else {
|
||||
}
|
||||
elseif ($modecompta == 'CREANCES-DETTES') {
|
||||
if ($key > 0) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
|
||||
} else {
|
||||
print '<a href="#">';
|
||||
//print '<a href="#">';
|
||||
}
|
||||
}
|
||||
print price($amount[$key]);
|
||||
if ($modecompta == 'RECETTES-DEPENSES') {
|
||||
if ($key > 0) {
|
||||
//print '</a>';
|
||||
} else {
|
||||
//print '</a>';
|
||||
}
|
||||
}
|
||||
elseif ($modecompta == 'CREANCES-DETTES') {
|
||||
if ($key > 0) {
|
||||
print '</a>';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Percent
|
||||
|
||||
@ -1364,7 +1364,7 @@ else
|
||||
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showCategories($object->id, 'contact', 1);
|
||||
print $form->showCategories($object->id, Categorie::TYPE_CONTACT, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -181,6 +181,10 @@ class Contact extends CommonObject
|
||||
public $phone_mobile;
|
||||
public $fax;
|
||||
|
||||
/**
|
||||
* Private or public
|
||||
* @var int
|
||||
*/
|
||||
public $priv;
|
||||
|
||||
public $birthday;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2017 Juanjo Menent <jmenent@2byte.es>
|
||||
@ -417,12 +417,12 @@ if (empty($reshook))
|
||||
// Set if we used free entry or predefined product
|
||||
$predef = '';
|
||||
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$price_ht_devise = GETPOST('multicurrency_price_ht');
|
||||
if (GETPOST('prod_entry_mode') == 'free')
|
||||
$price_ht = price2num(GETPOST('price_ht'));
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
|
||||
if (GETPOST('prod_entry_mode', 'alpha') == 'free')
|
||||
{
|
||||
$idprod = 0;
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
$tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -430,7 +430,7 @@ if (empty($reshook))
|
||||
$tva_tx = '';
|
||||
}
|
||||
|
||||
$qty = GETPOST('qty'.$predef);
|
||||
$qty = price2num(GETPOST('qty'.$predef));
|
||||
$remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0);
|
||||
|
||||
if ($qty == '')
|
||||
@ -438,7 +438,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc))
|
||||
if (GETPOST('prod_entry_mode', 'alpha') == 'free' && empty($idprod) && empty($product_desc))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors');
|
||||
$error++;
|
||||
|
||||
@ -1421,9 +1421,18 @@ class Contrat extends CommonObject
|
||||
$pu_ht = price2num($pu_ht);
|
||||
$pu_ttc = price2num($pu_ttc);
|
||||
$pa_ht = price2num($pa_ht);
|
||||
if (!preg_match('/\((.*)\)/', $txtva)) {
|
||||
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
|
||||
|
||||
// Clean vat code
|
||||
$reg = array();
|
||||
$vat_src_code = '';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||
{
|
||||
$vat_src_code = $reg[1];
|
||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||
}
|
||||
|
||||
$txtva = price2num($txtva);
|
||||
|
||||
$txlocaltax1 = price2num($txlocaltax1);
|
||||
$txlocaltax2 = price2num($txlocaltax2);
|
||||
$remise_percent = price2num($remise_percent);
|
||||
@ -1456,15 +1465,7 @@ class Contrat extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
|
||||
|
||||
// Clean vat code
|
||||
$vat_src_code = '';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||
{
|
||||
$vat_src_code = $reg[1];
|
||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||
}
|
||||
$localtaxes_type = getLocalTaxesFromRate($txtva.($vat_src_code ? ' ('.$vat_src_code.')' : ''), 0, $this->societe, $mysoc);
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
|
||||
@ -36,7 +36,12 @@ if ($cancel)
|
||||
{
|
||||
/*var_dump($cancel);
|
||||
var_dump($backtopage);exit;*/
|
||||
if (!empty($backtopage))
|
||||
if (!empty($backtopageforcancel))
|
||||
{
|
||||
header("Location: ".$backtopageforcancel);
|
||||
exit;
|
||||
}
|
||||
elseif (!empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
@ -142,8 +147,8 @@ if ($action == 'update' && !empty($permissiontoadd))
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
} elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) {
|
||||
$value = price2num(GETPOST($key));
|
||||
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
|
||||
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
|
||||
} else {
|
||||
$value = GETPOST($key, 'alpha');
|
||||
}
|
||||
|
||||
@ -107,7 +107,8 @@ abstract class CommonInvoice extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Return amount of payments already done
|
||||
* Return amount of payments already done. This must include ONLY the record into the payment table.
|
||||
* Payments dones using discounts, credit notes, etc are not included.
|
||||
*
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @return int Amount of payment already done, <0 if KO
|
||||
@ -337,6 +338,51 @@ abstract class CommonInvoice extends CommonObject
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
//look for credit notes and discounts and deposits
|
||||
$sql = '';
|
||||
if ($this->element == 'facture' || $this->element == 'invoice')
|
||||
{
|
||||
$sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$this->id;
|
||||
$sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
|
||||
}
|
||||
elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||
{
|
||||
$sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
$sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id;
|
||||
$sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
|
||||
}
|
||||
|
||||
if ($sql) {
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i=0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($multicurrency) {
|
||||
$retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref);
|
||||
}
|
||||
else {
|
||||
$retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
dol_print_error($this->db);
|
||||
return array();
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
|
||||
return $retarray;
|
||||
}
|
||||
else
|
||||
|
||||
@ -3522,6 +3522,7 @@ abstract class CommonObject
|
||||
if ($elementTable == 'user') $fieldstatus = "statut";
|
||||
if ($elementTable == 'expensereport') $fieldstatus = "fk_statut";
|
||||
if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus = "status";
|
||||
if (is_array($this->fields) && array_key_exists('status', $this->fields)) $fieldstatus = 'status';
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
|
||||
$sql .= " SET ".$fieldstatus." = ".$status;
|
||||
@ -3572,7 +3573,7 @@ abstract class CommonObject
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dol_syslog(get_class($this)."::setStatus ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -5562,16 +5563,17 @@ abstract class CommonObject
|
||||
* Return HTML string to put an input field into a page
|
||||
* Code very similar with showInputField of extra fields
|
||||
*
|
||||
* @param array $val Array of properties for field to show
|
||||
* @param array $val Array of properties for field to show (used only if ->fields not defined)
|
||||
* @param string $key Key of attribute
|
||||
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
|
||||
* @param string $moreparam To add more parameters on html input tag
|
||||
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param string|int $morecss Value for css to define style/length of field. May also be a numeric.
|
||||
* @param int $nonewbutton Force to not show the new button on field that are links to object
|
||||
* @return string
|
||||
*/
|
||||
public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0)
|
||||
public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0)
|
||||
{
|
||||
global $conf, $langs, $form;
|
||||
|
||||
@ -5581,7 +5583,9 @@ abstract class CommonObject
|
||||
$form = new Form($this->db);
|
||||
}
|
||||
|
||||
$val = $this->fields[$key];
|
||||
if (! empty($this->fields)) {
|
||||
$val = $this->fields[$key];
|
||||
}
|
||||
|
||||
$out = '';
|
||||
$type = '';
|
||||
@ -6124,7 +6128,7 @@ abstract class CommonObject
|
||||
|
||||
if (!empty($param_list_array[2])) // If we set to add a create button
|
||||
{
|
||||
if (!GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled".
|
||||
if (!GETPOSTISSET('backtopage') && empty($val['disabled']) && empty($nonewbutton)) // To avoid to open several times the 'Create Object' button and to avoid to have button if field is protected by a "disabled".
|
||||
{
|
||||
list($class, $classfile) = explode(':', $param_list[0]);
|
||||
if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1);
|
||||
@ -7383,7 +7387,7 @@ abstract class CommonObject
|
||||
* @param stdClass $obj Contain data of object from database
|
||||
* @return void
|
||||
*/
|
||||
protected function setVarsFromFetchObj(&$obj)
|
||||
public function setVarsFromFetchObj(&$obj)
|
||||
{
|
||||
foreach ($this->fields as $field => $info)
|
||||
{
|
||||
@ -7494,7 +7498,7 @@ abstract class CommonObject
|
||||
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now);
|
||||
if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id;
|
||||
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
|
||||
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data
|
||||
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
|
||||
|
||||
$keys = array();
|
||||
$values = array();
|
||||
@ -7729,6 +7733,7 @@ abstract class CommonObject
|
||||
if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now);
|
||||
if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id;
|
||||
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
|
||||
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
|
||||
|
||||
$keys = array();
|
||||
$values = array();
|
||||
|
||||
@ -546,7 +546,7 @@ class DiscountAbsolute
|
||||
* Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended).
|
||||
*
|
||||
* @param CommonInvoice $invoice Object invoice (customer of supplier)
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @param int $multicurrency 1=Return multicurrency_amount instead of amount
|
||||
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
|
||||
*/
|
||||
public function getSumDepositsUsed($invoice, $multicurrency = 0)
|
||||
@ -578,7 +578,7 @@ class DiscountAbsolute
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($multicurrency) return $obj->multicurrency_amount;
|
||||
if ($multicurrency == 1) return $obj->multicurrency_amount;
|
||||
else return $obj->amount;
|
||||
}
|
||||
else
|
||||
@ -592,7 +592,7 @@ class DiscountAbsolute
|
||||
* Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment
|
||||
*
|
||||
* @param CommonInvoice $invoice Object invoice
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @param int $multicurrency 1=Return multicurrency_amount instead of amount
|
||||
* @return int <0 if KO, Sum of credit notes and excess received amount otherwise
|
||||
*/
|
||||
public function getSumCreditNotesUsed($invoice, $multicurrency = 0)
|
||||
@ -624,7 +624,7 @@ class DiscountAbsolute
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($multicurrency) return $obj->multicurrency_amount;
|
||||
if ($multicurrency == 1) return $obj->multicurrency_amount;
|
||||
else return $obj->amount;
|
||||
}
|
||||
else
|
||||
|
||||
@ -898,87 +898,90 @@ class DolGraph
|
||||
return;
|
||||
}
|
||||
|
||||
$legends=array();
|
||||
$nblot=count($this->data[0])-1; // -1 to remove legend
|
||||
$legends = array();
|
||||
$nblot = 0;
|
||||
if (is_array($this->data) && is_array($this->data[0])) {
|
||||
$nblot = count($this->data[0]) - 1; // -1 to remove legend
|
||||
}
|
||||
if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
|
||||
$firstlot=0;
|
||||
$firstlot = 0;
|
||||
// Works with line but not with bars
|
||||
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
|
||||
|
||||
$i=$firstlot;
|
||||
$serie=array();
|
||||
$i = $firstlot;
|
||||
$serie = array();
|
||||
while ($i < $nblot) // Loop on each serie
|
||||
{
|
||||
$values=array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
|
||||
$serie[$i]="var d".$i." = [];\n";
|
||||
$values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
|
||||
$serie[$i] = "var d".$i." = [];\n";
|
||||
|
||||
// Fill array $values
|
||||
$x=0;
|
||||
foreach($this->data as $valarray) // Loop on each x
|
||||
$x = 0;
|
||||
foreach ($this->data as $valarray) // Loop on each x
|
||||
{
|
||||
$legends[$x] = $valarray[0];
|
||||
$values[$x] = (is_numeric($valarray[$i+1]) ? $valarray[$i+1] : null);
|
||||
$values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] : null);
|
||||
$x++;
|
||||
}
|
||||
|
||||
// TODO Avoid push by adding generated long array...
|
||||
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
|
||||
{
|
||||
foreach($values as $x => $y) {
|
||||
if (isset($y)) $serie[$i].='d'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
|
||||
foreach ($values as $x => $y) {
|
||||
if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($values as $x => $y) {
|
||||
if (isset($y)) $serie[$i].='d'.$i.'.push(['.$x.', '.$y.']);'."\n";
|
||||
foreach ($values as $x => $y) {
|
||||
if (isset($y)) $serie[$i] .= 'd'.$i.'.push(['.$x.', '.$y.']);'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
unset($values);
|
||||
$i++;
|
||||
}
|
||||
$tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-','.'))));
|
||||
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
|
||||
|
||||
$this->stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
|
||||
if (! empty($this->title)) $this->stringtoshow.='<div class="center dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
|
||||
if (! empty($this->shownographyet))
|
||||
$this->stringtoshow = '<!-- Build using '.$this->_library.' -->'."\n";
|
||||
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle'.(empty($this->cssprefix) ? '' : ' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
|
||||
if (!empty($this->shownographyet))
|
||||
{
|
||||
$this->stringtoshow.='<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
|
||||
$this->stringtoshow.='<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
|
||||
$this->stringtoshow .= '<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
|
||||
$this->stringtoshow .= '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
|
||||
return;
|
||||
}
|
||||
$this->stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).' center"></div>'."\n";
|
||||
$this->stringtoshow .= '<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix) ? '' : ' dolgraph'.$this->cssprefix).' center"></div>'."\n";
|
||||
|
||||
$this->stringtoshow.='<script id="'.$tag.'">'."\n";
|
||||
$this->stringtoshow.='$(function () {'."\n";
|
||||
$i=$firstlot;
|
||||
$this->stringtoshow .= '<script id="'.$tag.'">'."\n";
|
||||
$this->stringtoshow .= '$(function () {'."\n";
|
||||
$i = $firstlot;
|
||||
if ($nblot < 0)
|
||||
{
|
||||
$this->stringtoshow.='<!-- No series of data -->';
|
||||
$this->stringtoshow .= '<!-- No series of data -->';
|
||||
}
|
||||
else
|
||||
{
|
||||
while ($i < $nblot)
|
||||
{
|
||||
$this->stringtoshow.=$serie[$i];
|
||||
$this->stringtoshow .= $serie[$i];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$this->stringtoshow.="\n";
|
||||
$this->stringtoshow .= "\n";
|
||||
|
||||
// Special case for Graph of type 'pie'
|
||||
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
|
||||
{
|
||||
$datacolor=array();
|
||||
foreach($this->datacolor as $val) $datacolor[]="#".sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]);
|
||||
$datacolor = array();
|
||||
foreach ($this->datacolor as $val) $datacolor[] = "#".sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]);
|
||||
|
||||
$urltemp=''; // TODO Add support for url link into labels
|
||||
$showlegend=$this->showlegend;
|
||||
$showpointvalue=$this->showpointvalue;
|
||||
$showpercent=$this->showpercent;
|
||||
$urltemp = ''; // TODO Add support for url link into labels
|
||||
$showlegend = $this->showlegend;
|
||||
$showpointvalue = $this->showpointvalue;
|
||||
$showpercent = $this->showpercent;
|
||||
|
||||
$this->stringtoshow.= '
|
||||
$this->stringtoshow .= '
|
||||
function plotWithOptions_'.$tag.'() {
|
||||
$.plot($("#placeholder_'.$tag.'"), d0,
|
||||
{
|
||||
@ -1124,7 +1127,20 @@ class DolGraph
|
||||
$this->stringtoshow .= '</script>'."\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output HTML string to total value
|
||||
*
|
||||
* @return string HTML string to total value
|
||||
*/
|
||||
public function total()
|
||||
{
|
||||
$value = 0;
|
||||
foreach($this->data as $valarray) // Loop on each x
|
||||
{
|
||||
$value += $valarray[1];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML string to show graph
|
||||
|
||||
@ -591,15 +591,14 @@ class Form
|
||||
* Generate select HTML to choose massaction
|
||||
*
|
||||
* @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default.
|
||||
* @param int $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
|
||||
* @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
|
||||
* @param int $alwaysvisible 1=select button always visible
|
||||
* @return string Select list
|
||||
* @return string|void Select list
|
||||
*/
|
||||
public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0)
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
if (count($arrayofaction) == 0) return;
|
||||
|
||||
$disabled = 0;
|
||||
$ret = '<div class="centpercent center">';
|
||||
@ -608,6 +607,8 @@ class Form
|
||||
// Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks.
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters); // Note that $action and $object may have been modified by hook
|
||||
// check if there is a mass action
|
||||
if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) return;
|
||||
if (empty($reshook))
|
||||
{
|
||||
$ret .= '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>-- '.$langs->trans("SelectAction").' --</option>';
|
||||
@ -3007,7 +3008,7 @@ class Form
|
||||
* @param int $productid Id of product
|
||||
* @param string $htmlname Name of HTML field
|
||||
* @param int $selected_supplier Pre-selected supplier if more than 1 result
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '')
|
||||
{
|
||||
@ -4129,6 +4130,7 @@ class Form
|
||||
}
|
||||
|
||||
// Now add questions
|
||||
$moreonecolumn = '';
|
||||
$more .= '<div class="tagtable paddingtopbottomonly centpercent noborderspacing">'."\n";
|
||||
foreach ($formquestion as $key => $input)
|
||||
{
|
||||
@ -4202,13 +4204,14 @@ class Form
|
||||
|
||||
elseif ($input['type'] == 'onecolumn')
|
||||
{
|
||||
$more .= '<div class="tagtr"><div class="tagtd">';
|
||||
$more .= $input['value'];
|
||||
$more .= '</div></div>'."\n";
|
||||
$moreonecolumn .= '<div class="margintoponly">';
|
||||
$moreonecolumn .= $input['value'];
|
||||
$moreonecolumn .= '</div>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$more .= '</div>'."\n";
|
||||
$more .= $moreonecolumn;
|
||||
}
|
||||
|
||||
// JQUI method dialog is broken with jmobile, we use standard HTML.
|
||||
@ -5907,6 +5910,7 @@ class Form
|
||||
//var_dump($objecttmp->filter);
|
||||
$prefixforautocompletemode = $objecttmp->element;
|
||||
if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company';
|
||||
if ($prefixforautocompletemode == 'product') $prefixforautocompletemode='produit';
|
||||
$confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
|
||||
|
||||
dol_syslog(get_class($this)."::selectForForms object->filter=".$objecttmp->filter, LOG_DEBUG);
|
||||
@ -7839,4 +7843,171 @@ class Form
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a combo list with invoices qualified for a third party
|
||||
*
|
||||
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
|
||||
* @param int $selected Id invoice preselected
|
||||
* @param string $htmlname Name of HTML select
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $option_only Return only html options lines without the select tag
|
||||
* @param string $show_empty Add an empty line ('1' or string to show for empty line)
|
||||
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
|
||||
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||
* @param int $disabled Disabled
|
||||
* @param string $morecss More css added to the select component
|
||||
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
|
||||
* @param string $showproject 'all' = Show project info, ''=Hide project info
|
||||
* @param User $usertofilter User object to use for filtering
|
||||
* @return int Nbr of project if OK, <0 if KO
|
||||
*/
|
||||
public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null)
|
||||
{
|
||||
global $user,$conf,$langs;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
if (is_null($usertofilter))
|
||||
{
|
||||
$usertofilter = $user;
|
||||
}
|
||||
|
||||
$out='';
|
||||
|
||||
$hideunselectables = false;
|
||||
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
|
||||
|
||||
if (empty($projectsListId))
|
||||
{
|
||||
if (empty($usertofilter->rights->projet->all->lire))
|
||||
{
|
||||
$projectstatic=new Project($this->db);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Search all projects
|
||||
$sql = 'SELECT f.rowid, f.ref as fref, "nolabel" as flabel, p.rowid as pid, f.ref,
|
||||
p.title, p.fk_soc, p.fk_statut, p.public,';
|
||||
$sql.= ' s.nom as name';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,';
|
||||
$sql.= ' '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project').")";
|
||||
$sql.= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement
|
||||
//if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
||||
//if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
|
||||
//if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
|
||||
$sql.= " GROUP BY f.ref ORDER BY p.ref, f.ref ASC";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
// Use select2 selector
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
|
||||
$out.=$comboenhancement;
|
||||
$morecss='minwidth200imp maxwidth500';
|
||||
}
|
||||
|
||||
if (empty($option_only)) {
|
||||
$out.= '<select class="valignmiddle flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
}
|
||||
if (! empty($show_empty)) {
|
||||
$out.= '<option value="0" class="optiongrey">';
|
||||
if (! is_numeric($show_empty)) $out.=$show_empty;
|
||||
else $out.=' ';
|
||||
$out.= '</option>';
|
||||
}
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
|
||||
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire))
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED)
|
||||
{
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$labeltoshow = '';
|
||||
|
||||
if ($showproject == 'all')
|
||||
{
|
||||
$labeltoshow.=dol_trunc($obj->ref, 18); // Invoice ref
|
||||
if ($obj->name) $labeltoshow.=' - '.$obj->name; // Soc name
|
||||
|
||||
$disabled=0;
|
||||
if ($obj->fk_statut == Project::STATUS_DRAFT)
|
||||
{
|
||||
$disabled=1;
|
||||
$labeltoshow.=' - '.$langs->trans("Draft");
|
||||
}
|
||||
elseif ($obj->fk_statut == Project::STATUS_CLOSED)
|
||||
{
|
||||
if ($discard_closed == 2) $disabled=1;
|
||||
$labeltoshow.=' - '.$langs->trans("Closed");
|
||||
}
|
||||
elseif ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
|
||||
{
|
||||
$disabled=1;
|
||||
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($selected) && $selected == $obj->rowid)
|
||||
{
|
||||
$out.= '<option value="'.$obj->rowid.'" selected';
|
||||
//if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
|
||||
$out.= '>'.$labeltoshow.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($hideunselectables && $disabled && ($selected != $obj->rowid))
|
||||
{
|
||||
$resultat='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$resultat='<option value="'.$obj->rowid.'"';
|
||||
if ($disabled) $resultat.=' disabled';
|
||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
|
||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||
$resultat.='>';
|
||||
$resultat.=$labeltoshow;
|
||||
$resultat.='</option>';
|
||||
}
|
||||
$out.= $resultat;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if (empty($option_only)) {
|
||||
$out.= '</select>';
|
||||
}
|
||||
|
||||
print $out;
|
||||
|
||||
$this->db->free($resql);
|
||||
return $num;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -292,7 +292,7 @@ class FormAccounting extends Form
|
||||
{
|
||||
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT;
|
||||
|
||||
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
|
||||
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.labelshort, aa.rowid, aa.fk_pcg_version";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
|
||||
@ -312,8 +312,17 @@ class FormAccounting extends Form
|
||||
$selected = 0;
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
$label = length_accountg($obj->account_number).' - '.$obj->label;
|
||||
$label = dol_trunc($label, $trunclength);
|
||||
if (empty($obj->labelshort))
|
||||
{
|
||||
$labeltoshow = $obj->label;
|
||||
}
|
||||
else
|
||||
{
|
||||
$labeltoshow = $obj->labelshort;
|
||||
}
|
||||
|
||||
$label = length_accountg($obj->account_number) . ' - ' . $labeltoshow;
|
||||
$label = dol_trunc($label, $trunclength);
|
||||
|
||||
$select_value_in = $obj->rowid;
|
||||
$select_value_out = $obj->rowid;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (c) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (c) 2015-2019 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
|
||||
@ -98,7 +98,7 @@ class FormMargin
|
||||
|
||||
$pv = $line->total_ht;
|
||||
$pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
|
||||
if ($object->type == Facture::TYPE_SITUATION) {
|
||||
if ($object->element == 'facture' && $object->type == $object::TYPE_SITUATION) {
|
||||
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
|
||||
} else {
|
||||
$pa = $line->qty * $pa_ht;
|
||||
|
||||
@ -109,8 +109,10 @@ class Interfaces
|
||||
$handle = opendir($newdir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
$fullpathfiles = array();
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
$reg=array();
|
||||
if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg))
|
||||
{
|
||||
$part1 = $reg[1];
|
||||
@ -274,6 +276,7 @@ class Interfaces
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
$reg = array();
|
||||
if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg))
|
||||
{
|
||||
if (preg_match('/\.back$/', $file)) continue;
|
||||
|
||||
@ -29,17 +29,17 @@
|
||||
*/
|
||||
class Translate
|
||||
{
|
||||
public $dir; // Directories that contains /langs subdirectory
|
||||
public $dir; // Directories that contains /langs subdirectory
|
||||
|
||||
public $defaultlang; // Current language for current user
|
||||
public $charset_output='UTF-8'; // Codage used by "trans" method outputs
|
||||
public $defaultlang; // Current language for current user
|
||||
public $charset_output = 'UTF-8'; // Codage used by "trans" method outputs
|
||||
|
||||
public $tab_translate=array(); // Array of all translations key=>value
|
||||
private $_tab_loaded=array(); // Array to store result after loading each language file
|
||||
public $tab_translate = array(); // Array of all translations key=>value
|
||||
private $_tab_loaded = array(); // Array to store result after loading each language file
|
||||
|
||||
public $cache_labels=array(); // Cache for labels return by getLabelFromKey method
|
||||
public $cache_currencies=array(); // Cache to store currency symbols
|
||||
private $cache_currencies_all_loaded=false;
|
||||
public $cache_labels = array(); // Cache for labels return by getLabelFromKey method
|
||||
public $cache_currencies = array(); // Cache to store currency symbols
|
||||
private $cache_currencies_all_loaded = false;
|
||||
|
||||
|
||||
/**
|
||||
@ -50,9 +50,9 @@ class Translate
|
||||
*/
|
||||
public function __construct($dir, $conf)
|
||||
{
|
||||
if (! empty($conf->file->character_set_client)) $this->charset_output=$conf->file->character_set_client; // If charset output is forced
|
||||
if ($dir) $this->dir=array($dir);
|
||||
else $this->dir=$conf->file->dol_document_root;
|
||||
if (!empty($conf->file->character_set_client)) $this->charset_output = $conf->file->character_set_client; // If charset output is forced
|
||||
if ($dir) $this->dir = array($dir);
|
||||
else $this->dir = $conf->file->dol_document_root;
|
||||
}
|
||||
|
||||
|
||||
@ -69,59 +69,59 @@ class Translate
|
||||
//dol_syslog(get_class($this)."::setDefaultLang srclang=".$srclang,LOG_DEBUG);
|
||||
|
||||
// If a module ask to force a priority on langs directories (to use its own lang files)
|
||||
if (! empty($conf->global->MAIN_FORCELANGDIR))
|
||||
if (!empty($conf->global->MAIN_FORCELANGDIR))
|
||||
{
|
||||
$more=array();
|
||||
$i=0;
|
||||
foreach($conf->file->dol_document_root as $dir)
|
||||
$more = array();
|
||||
$i = 0;
|
||||
foreach ($conf->file->dol_document_root as $dir)
|
||||
{
|
||||
$newdir=$dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
|
||||
if (! in_array($newdir, $this->dir))
|
||||
$newdir = $dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
|
||||
if (!in_array($newdir, $this->dir))
|
||||
{
|
||||
$more['module_'.$i]=$newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
|
||||
$more['module_'.$i] = $newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
|
||||
}
|
||||
}
|
||||
$this->dir=array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir)
|
||||
$this->dir = array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir)
|
||||
}
|
||||
|
||||
$this->origlang=$srclang;
|
||||
$this->origlang = $srclang;
|
||||
|
||||
if (empty($srclang) || $srclang == 'auto')
|
||||
{
|
||||
// $_SERVER['HTTP_ACCEPT_LANGUAGE'] can be 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6' but can contains also malicious content
|
||||
$langpref=empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])?'':$_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
$langpref=preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part
|
||||
$langpref=str_replace("-", "_", $langpref);
|
||||
$langlist=preg_split("/[;,]/", $langpref);
|
||||
$codetouse=preg_replace('/[^_a-zA-Z]/', '', $langlist[0]);
|
||||
$langpref = empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? '' : $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
$langpref = preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part
|
||||
$langpref = str_replace("-", "_", $langpref);
|
||||
$langlist = preg_split("/[;,]/", $langpref);
|
||||
$codetouse = preg_replace('/[^_a-zA-Z]/', '', $langlist[0]);
|
||||
}
|
||||
else $codetouse=$srclang;
|
||||
else $codetouse = $srclang;
|
||||
|
||||
// We redefine $srclang
|
||||
$langpart=explode("_", $codetouse);
|
||||
$langpart = explode("_", $codetouse);
|
||||
//print "Short code before _ : ".$langpart[0].' / Short code after _ : '.$langpart[1].'<br>';
|
||||
if (! empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY
|
||||
if (!empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY
|
||||
{
|
||||
// Array force long code from first part, even if long code is defined
|
||||
$longforshort=array('ar'=>'ar_SA');
|
||||
$longforshortexcep=array('ar_EG');
|
||||
if (isset($longforshort[strtolower($langpart[0])]) && ! in_array($codetouse, $longforshortexcep)) $srclang=$longforshort[strtolower($langpart[0])];
|
||||
elseif (! is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser
|
||||
$srclang=strtolower($langpart[0])."_".strtoupper($langpart[1]);
|
||||
$longforlong=array('no_nb'=>'nb_NO');
|
||||
if (isset($longforlong[strtolower($srclang)])) $srclang=$longforlong[strtolower($srclang)];
|
||||
$longforshort = array('ar'=>'ar_SA');
|
||||
$longforshortexcep = array('ar_EG');
|
||||
if (isset($longforshort[strtolower($langpart[0])]) && !in_array($codetouse, $longforshortexcep)) $srclang = $longforshort[strtolower($langpart[0])];
|
||||
elseif (!is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser
|
||||
$srclang = strtolower($langpart[0])."_".strtoupper($langpart[1]);
|
||||
$longforlong = array('no_nb'=>'nb_NO');
|
||||
if (isset($longforlong[strtolower($srclang)])) $srclang = $longforlong[strtolower($srclang)];
|
||||
}
|
||||
else $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
|
||||
else $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
|
||||
}
|
||||
else { // If it's for a codetouse that is a short code xx
|
||||
// Array to convert short lang code into long code.
|
||||
$longforshort=array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO');
|
||||
if (isset($longforshort[strtolower($langpart[0])])) $srclang=$longforshort[strtolower($langpart[0])];
|
||||
elseif (! empty($langpart[0])) $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
|
||||
else $srclang='en_US';
|
||||
$longforshort = array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO');
|
||||
if (isset($longforshort[strtolower($langpart[0])])) $srclang = $longforshort[strtolower($langpart[0])];
|
||||
elseif (!empty($langpart[0])) $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
|
||||
else $srclang = 'en_US';
|
||||
}
|
||||
|
||||
$this->defaultlang=$srclang;
|
||||
$this->defaultlang = $srclang;
|
||||
//print 'this->defaultlang='.$this->defaultlang;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ class Translate
|
||||
*/
|
||||
public function loadLangs($domains)
|
||||
{
|
||||
foreach($domains as $domain)
|
||||
foreach ($domains as $domain)
|
||||
{
|
||||
$this->load($domain);
|
||||
}
|
||||
@ -176,7 +176,7 @@ class Translate
|
||||
*/
|
||||
public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0)
|
||||
{
|
||||
global $conf,$db;
|
||||
global $conf, $db;
|
||||
|
||||
//dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
|
||||
|
||||
@ -186,18 +186,18 @@ class Translate
|
||||
dol_print_error('', get_class($this)."::Load ErrorWrongParameters");
|
||||
return -1;
|
||||
}
|
||||
if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys
|
||||
if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys
|
||||
|
||||
|
||||
// Load $this->tab_translate[] from database
|
||||
if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database.
|
||||
if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database.
|
||||
|
||||
|
||||
$newdomain = $domain;
|
||||
$modulename = '';
|
||||
|
||||
// Search if a module directory name is provided into lang file name
|
||||
$regs=array();
|
||||
$regs = array();
|
||||
if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs))
|
||||
{
|
||||
$newdomain = $regs[1];
|
||||
@ -205,33 +205,33 @@ class Translate
|
||||
}
|
||||
|
||||
// Check cache
|
||||
if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain
|
||||
if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain
|
||||
{
|
||||
//dol_syslog("Translate::Load already loaded for newdomain=".$newdomain);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$fileread=0;
|
||||
$langofdir=(empty($forcelangdir)?$this->defaultlang:$forcelangdir);
|
||||
$fileread = 0;
|
||||
$langofdir = (empty($forcelangdir) ? $this->defaultlang : $forcelangdir);
|
||||
|
||||
// Redefine alt
|
||||
$langarray=explode('_', $langofdir);
|
||||
if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt=1;
|
||||
if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt=2;
|
||||
$langarray = explode('_', $langofdir);
|
||||
if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt = 1;
|
||||
if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt = 2;
|
||||
|
||||
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
|
||||
{
|
||||
dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
|
||||
dol_syslog("Error: ".get_class($this)."::load was called for domain=".$domain." but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
foreach($this->dir as $searchdir)
|
||||
foreach ($this->dir as $searchdir)
|
||||
{
|
||||
// Directory of translation files
|
||||
$file_lang = $searchdir.($modulename?'/'.$modulename:'')."/langs/".$langofdir."/".$newdomain.".lang";
|
||||
$file_lang_osencoded=dol_osencode($file_lang);
|
||||
$file_lang = $searchdir.($modulename ? '/'.$modulename : '')."/langs/".$langofdir."/".$newdomain.".lang";
|
||||
$file_lang_osencoded = dol_osencode($file_lang);
|
||||
|
||||
$filelangexists=is_file($file_lang_osencoded);
|
||||
$filelangexists = is_file($file_lang_osencoded);
|
||||
|
||||
//dol_syslog(get_class($this).'::Load Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' file_lang='.$file_lang." => filelangexists=".$filelangexists);
|
||||
//print 'Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' this->_tab_loaded[newdomain]='.$this->_tab_loaded[$newdomain].' file_lang='.$file_lang." => filelangexists=".$filelangexists."\n";
|
||||
@ -239,19 +239,19 @@ class Translate
|
||||
if ($filelangexists)
|
||||
{
|
||||
// TODO Move cache read out of loop on dirs or at least filelangexists
|
||||
$found=false;
|
||||
$found = false;
|
||||
|
||||
// Enable caching of lang file in memory (not by default)
|
||||
$usecachekey='';
|
||||
$usecachekey = '';
|
||||
// Using a memcached server
|
||||
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
|
||||
if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER))
|
||||
{
|
||||
$usecachekey=$newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
|
||||
$usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
|
||||
}
|
||||
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
|
||||
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
|
||||
{
|
||||
$usecachekey=$newdomain;
|
||||
$usecachekey = $newdomain;
|
||||
}
|
||||
|
||||
if ($usecachekey)
|
||||
@ -259,23 +259,23 @@ class Translate
|
||||
//dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
|
||||
//global $aaa; $aaa+=1;
|
||||
//print $aaa." ".$usecachekey."\n";
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php';
|
||||
$tmparray=dol_getcache($usecachekey);
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$tmparray = dol_getcache($usecachekey);
|
||||
if (is_array($tmparray) && count($tmparray))
|
||||
{
|
||||
$this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
|
||||
$this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
|
||||
//print $newdomain."\n";
|
||||
//var_dump($this->tab_translate);
|
||||
if ($alt == 2) $fileread=1;
|
||||
$found=true; // Found in dolibarr PHP cache
|
||||
if ($alt == 2) $fileread = 1;
|
||||
$found = true; // Found in dolibarr PHP cache
|
||||
}
|
||||
}
|
||||
|
||||
if (! $found)
|
||||
if (!$found)
|
||||
{
|
||||
if ($fp = @fopen($file_lang, "rt"))
|
||||
{
|
||||
if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache
|
||||
if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache
|
||||
|
||||
/**
|
||||
* Read each lines until a '=' (with any combination of spaces around it)
|
||||
@ -291,7 +291,6 @@ class Translate
|
||||
//if ($key == 'Order') print "Domain=$domain, found a string for key=$key=$tab[0] with value $tab[1]. Currently in cache ".$this->tab_translate[$key]."<br>";
|
||||
if (empty($this->tab_translate[$key]))
|
||||
{ // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries)
|
||||
$value = preg_replace('/\\n/', "\n", $value); // Parse and render carriage returns
|
||||
if ($key == 'DIRECTION') { // This is to declare direction of language
|
||||
if ($alt < 2 || empty($this->tab_translate[$key])) { // We load direction only for primary files or if not yet loaded
|
||||
$this->tab_translate[$key] = $value;
|
||||
@ -307,8 +306,8 @@ class Translate
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$this->tab_translate[$key] = $value;
|
||||
//if ($domain == 'orders') print "$tab[0] value $value<br>";
|
||||
// Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s'
|
||||
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);
|
||||
if ($usecachekey) {
|
||||
$tabtranslatedomain[$key] = $value;
|
||||
} // To save lang content in cache
|
||||
@ -317,21 +316,21 @@ class Translate
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
$fileread=1;
|
||||
$fileread = 1;
|
||||
|
||||
// TODO Move cache write out of loop on dirs
|
||||
// To save lang content for usecachekey into cache
|
||||
if ($usecachekey && count($tabtranslatedomain))
|
||||
{
|
||||
$ressetcache=dol_setcache($usecachekey, $tabtranslatedomain);
|
||||
$ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
|
||||
if ($ressetcache < 0)
|
||||
{
|
||||
$error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
|
||||
$error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
|
||||
dol_syslog($error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
|
||||
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -342,10 +341,10 @@ class Translate
|
||||
{
|
||||
// This function MUST NOT contains call to syslog
|
||||
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
|
||||
$langofdir=strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
|
||||
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
|
||||
if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
|
||||
$this->load($domain, $alt+1, $stopafterdirection, $langofdir);
|
||||
$langofdir = strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
|
||||
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
|
||||
if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
|
||||
$this->load($domain, $alt + 1, $stopafterdirection, $langofdir);
|
||||
}
|
||||
|
||||
// Now we complete with reference file (en_US)
|
||||
@ -353,38 +352,38 @@ class Translate
|
||||
{
|
||||
// This function MUST NOT contains call to syslog
|
||||
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
|
||||
$langofdir='en_US';
|
||||
$this->load($domain, $alt+1, $stopafterdirection, $langofdir);
|
||||
$langofdir = 'en_US';
|
||||
$this->load($domain, $alt + 1, $stopafterdirection, $langofdir);
|
||||
}
|
||||
|
||||
// We are in the pass of the reference file. No more files to scan to complete.
|
||||
if ($alt == 2)
|
||||
{
|
||||
if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as found so loaded
|
||||
if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as found so loaded
|
||||
|
||||
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Set this file as not found
|
||||
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Set this file as not found
|
||||
}
|
||||
|
||||
// This part is deprecated and replaced with table llx_overwrite_trans
|
||||
// Kept for backward compatibility.
|
||||
if (empty($loadfromfileonly))
|
||||
{
|
||||
$overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang;
|
||||
if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2
|
||||
$overwritekey = 'MAIN_OVERWRITE_TRANS_'.$this->defaultlang;
|
||||
if (!empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2
|
||||
{
|
||||
// Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX
|
||||
$tmparray=explode(',', $conf->global->$overwritekey);
|
||||
foreach($tmparray as $tmp)
|
||||
$tmparray = explode(',', $conf->global->$overwritekey);
|
||||
foreach ($tmparray as $tmp)
|
||||
{
|
||||
$tmparray2=explode(':', $tmp);
|
||||
if (! empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]]=$tmparray2[1];
|
||||
$tmparray2 = explode(':', $tmp);
|
||||
if (!empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]] = $tmparray2[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check to be sure that SeparatorDecimal differs from SeparatorThousand
|
||||
if (! empty($this->tab_translate["SeparatorDecimal"]) && ! empty($this->tab_translate["SeparatorThousand"])
|
||||
&& $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"]='';
|
||||
if (!empty($this->tab_translate["SeparatorDecimal"]) && !empty($this->tab_translate["SeparatorThousand"])
|
||||
&& $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"] = '';
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -405,47 +404,47 @@ class Translate
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$domain='database';
|
||||
$domain = 'database';
|
||||
|
||||
// Check parameters
|
||||
if (empty($db)) return 0; // Database handler can't be used
|
||||
if (empty($db)) return 0; // Database handler can't be used
|
||||
|
||||
//dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
|
||||
|
||||
$newdomain = $domain;
|
||||
|
||||
// Check cache
|
||||
if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database'
|
||||
if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database'
|
||||
{
|
||||
//dol_syslog("Translate::Load already loaded for newdomain=".$newdomain);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
|
||||
$this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
|
||||
|
||||
$fileread=0;
|
||||
$langofdir=$this->defaultlang;
|
||||
$fileread = 0;
|
||||
$langofdir = $this->defaultlang;
|
||||
|
||||
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
|
||||
{
|
||||
dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
|
||||
dol_syslog("Error: ".get_class($this)."::loadFromDatabase was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO Move cache read out of loop on dirs or at least filelangexists
|
||||
$found=false;
|
||||
$found = false;
|
||||
|
||||
// Enable caching of lang file in memory (not by default)
|
||||
$usecachekey='';
|
||||
$usecachekey = '';
|
||||
// Using a memcached server
|
||||
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
|
||||
if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER))
|
||||
{
|
||||
$usecachekey=$newdomain.'_'.$langofdir; // Should not contains special chars
|
||||
$usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars
|
||||
}
|
||||
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
|
||||
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
|
||||
{
|
||||
$usecachekey=$newdomain;
|
||||
$usecachekey = $newdomain;
|
||||
}
|
||||
|
||||
if ($usecachekey)
|
||||
@ -453,63 +452,63 @@ class Translate
|
||||
//dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
|
||||
//global $aaa; $aaa+=1;
|
||||
//print $aaa." ".$usecachekey."\n";
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php';
|
||||
$tmparray=dol_getcache($usecachekey);
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$tmparray = dol_getcache($usecachekey);
|
||||
if (is_array($tmparray) && count($tmparray))
|
||||
{
|
||||
$this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
|
||||
$this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
|
||||
//print $newdomain."\n";
|
||||
//var_dump($this->tab_translate);
|
||||
$fileread=1;
|
||||
$found=true; // Found in dolibarr PHP cache
|
||||
$fileread = 1;
|
||||
$found = true; // Found in dolibarr PHP cache
|
||||
}
|
||||
}
|
||||
|
||||
if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
|
||||
if (!$found && !empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
|
||||
{
|
||||
// Overwrite translation with database read
|
||||
$sql ="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL";
|
||||
$sql.=" AND entity IN (0, ".getEntity('overwrite_trans').")";
|
||||
$sql.=$db->order("lang", "DESC");
|
||||
$resql=$db->query($sql);
|
||||
$sql = "SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL";
|
||||
$sql .= " AND entity IN (0, ".getEntity('overwrite_trans').")";
|
||||
$sql .= $db->order("lang", "DESC");
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache
|
||||
if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num) // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$key=$obj->transkey;
|
||||
$value=$obj->transvalue;
|
||||
$key = $obj->transkey;
|
||||
$value = $obj->transvalue;
|
||||
|
||||
//print "Domain=$domain, found a string for $tab[0] with value $tab[1]<br>";
|
||||
if (empty($this->tab_translate[$key])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries)
|
||||
{
|
||||
$value=trim(preg_replace('/\\n/', "\n", $value));
|
||||
// Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s'
|
||||
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);
|
||||
|
||||
$this->tab_translate[$key]=$value;
|
||||
if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache
|
||||
if ($usecachekey) $tabtranslatedomain[$key] = $value; // To save lang content in cache
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$fileread=1;
|
||||
$fileread = 1;
|
||||
|
||||
// TODO Move cache write out of loop on dirs
|
||||
// To save lang content for usecachekey into cache
|
||||
if ($usecachekey && count($tabtranslatedomain))
|
||||
{
|
||||
$ressetcache=dol_setcache($usecachekey, $tabtranslatedomain);
|
||||
$ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
|
||||
if ($ressetcache < 0)
|
||||
{
|
||||
$error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
|
||||
$error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
|
||||
dol_syslog($error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
@ -521,9 +520,9 @@ class Translate
|
||||
}
|
||||
}
|
||||
|
||||
if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as loaded
|
||||
if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded
|
||||
|
||||
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Marque ce cas comme non trouve (no lines found for language)
|
||||
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Marque ce cas comme non trouve (no lines found for language)
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -545,28 +544,28 @@ class Translate
|
||||
{
|
||||
global $conf, $db;
|
||||
|
||||
if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
|
||||
if (!is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
|
||||
|
||||
$newstr=$key;
|
||||
$newstr = $key;
|
||||
if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg))
|
||||
{
|
||||
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label');
|
||||
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label');
|
||||
}
|
||||
elseif (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i', $key, $reg))
|
||||
{
|
||||
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label');
|
||||
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label');
|
||||
}
|
||||
elseif (preg_match('/^SendingMethod([0-9A-Z]+)$/i', $key, $reg))
|
||||
{
|
||||
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle');
|
||||
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle');
|
||||
}
|
||||
elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i', $key, $reg))
|
||||
{
|
||||
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1);
|
||||
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1);
|
||||
}
|
||||
elseif (preg_match('/^OppStatus([0-9A-Z]+)$/i', $key, $reg))
|
||||
{
|
||||
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label');
|
||||
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label');
|
||||
}
|
||||
elseif (preg_match('/^OrderSource([0-9A-Z]+)$/i', $key, $reg))
|
||||
{
|
||||
@ -602,38 +601,37 @@ class Translate
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (! empty($this->tab_translate[$key])) // Translation is available
|
||||
if (!empty($this->tab_translate[$key])) // Translation is available
|
||||
{
|
||||
$str=$this->tab_translate[$key];
|
||||
$str = $this->tab_translate[$key];
|
||||
|
||||
// Make some string replacement after translation
|
||||
$replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
|
||||
if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
|
||||
$replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
|
||||
if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
|
||||
{
|
||||
$tmparray=explode(';', $conf->global->$replacekey);
|
||||
foreach($tmparray as $tmp)
|
||||
$tmparray = explode(';', $conf->global->$replacekey);
|
||||
foreach ($tmparray as $tmp)
|
||||
{
|
||||
$tmparray2=explode(':', $tmp);
|
||||
$str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
|
||||
$tmparray2 = explode(':', $tmp);
|
||||
$str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (! preg_match('/^Format/', $key))
|
||||
if (strpos($key, 'Format') !== 0)
|
||||
{
|
||||
//print $str;
|
||||
$str=sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
|
||||
$str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
|
||||
}
|
||||
|
||||
if ($maxsize) $str=dol_trunc($str, $maxsize);
|
||||
if ($maxsize) $str = dol_trunc($str, $maxsize);
|
||||
|
||||
// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities
|
||||
$str=str_replace(array('<','>','"',), array('__lt__','__gt__','__quot__'), $str);
|
||||
$str = str_replace(array('<', '>', '"',), array('__lt__', '__gt__', '__quot__'), $str);
|
||||
|
||||
// Crypt string into HTML
|
||||
$str=htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content
|
||||
$str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content
|
||||
|
||||
// Restore HTML tags
|
||||
$str=str_replace(array('__lt__','__gt__','__quot__'), array('<','>','"',), $str);
|
||||
$str = str_replace(array('__lt__', '__gt__', '__quot__'), array('<', '>', '"',), $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
@ -684,26 +682,26 @@ class Translate
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (! empty($this->tab_translate[$key])) // Translation is available
|
||||
if (!empty($this->tab_translate[$key])) // Translation is available
|
||||
{
|
||||
$str=$this->tab_translate[$key];
|
||||
$str = $this->tab_translate[$key];
|
||||
|
||||
// Make some string replacement after translation
|
||||
$replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
|
||||
if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
|
||||
$replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
|
||||
if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
|
||||
{
|
||||
$tmparray=explode(';', $conf->global->$replacekey);
|
||||
foreach($tmparray as $tmp)
|
||||
$tmparray = explode(';', $conf->global->$replacekey);
|
||||
foreach ($tmparray as $tmp)
|
||||
{
|
||||
$tmparray2=explode(':', $tmp);
|
||||
$str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
|
||||
$tmparray2 = explode(':', $tmp);
|
||||
$str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (! preg_match('/^Format/', $key))
|
||||
if (!preg_match('/^Format/', $key))
|
||||
{
|
||||
//print $str;
|
||||
$str=sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings.
|
||||
$str = sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings.
|
||||
}
|
||||
|
||||
return $str;
|
||||
@ -753,8 +751,8 @@ class Translate
|
||||
*/
|
||||
public function convToOutputCharset($str, $pagecodefrom = 'UTF-8')
|
||||
{
|
||||
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str);
|
||||
if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str=utf8_decode(str_replace('€', chr(128), $str));
|
||||
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str = utf8_encode($str);
|
||||
if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str = utf8_decode(str_replace('€', chr(128), $str));
|
||||
return $str;
|
||||
}
|
||||
|
||||
@ -774,21 +772,21 @@ class Translate
|
||||
global $conf;
|
||||
|
||||
// We scan directory langs to detect available languages
|
||||
$handle=opendir($langdir."/langs");
|
||||
$langs_available=array();
|
||||
$handle = opendir($langdir."/langs");
|
||||
$langs_available = array();
|
||||
while ($dir = trim(readdir($handle)))
|
||||
{
|
||||
if (preg_match('/^[a-z]+_[A-Z]+/i', $dir))
|
||||
{
|
||||
$this->load("languages");
|
||||
|
||||
if (! empty($conf->global->MAIN_LANGUAGES_ALLOWED) && ! in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED)) ) continue;
|
||||
if (!empty($conf->global->MAIN_LANGUAGES_ALLOWED) && !in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED))) continue;
|
||||
|
||||
if ($usecode == 2)
|
||||
{
|
||||
$langs_available[$dir] = $dir;
|
||||
}
|
||||
if ($usecode == 1 || ! empty($conf->global->MAIN_SHOW_LANGUAGE_CODE))
|
||||
if ($usecode == 1 || !empty($conf->global->MAIN_SHOW_LANGUAGE_CODE))
|
||||
{
|
||||
$langs_available[$dir] = $dir.': '.dol_trunc($this->trans('Language_'.$dir), $maxlength);
|
||||
}
|
||||
@ -814,7 +812,7 @@ class Translate
|
||||
{
|
||||
// phpcs:enable
|
||||
// Test si fichier dans repertoire de la langue
|
||||
foreach($this->dir as $searchdir)
|
||||
foreach ($this->dir as $searchdir)
|
||||
{
|
||||
if (is_readable(dol_osencode($searchdir."/langs/".$this->defaultlang."/".$filename))) return true;
|
||||
|
||||
@ -846,22 +844,22 @@ class Translate
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$newnumber=$number;
|
||||
$newnumber = $number;
|
||||
|
||||
$dirsubstitutions=array_merge(array(), $conf->modules_parts['substitutions']);
|
||||
foreach($dirsubstitutions as $reldir)
|
||||
$dirsubstitutions = array_merge(array(), $conf->modules_parts['substitutions']);
|
||||
foreach ($dirsubstitutions as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir, 0);
|
||||
$newdir=dol_osencode($dir);
|
||||
$dir = dol_buildpath($reldir, 0);
|
||||
$newdir = dol_osencode($dir);
|
||||
|
||||
// Check if directory exists
|
||||
if (! is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded
|
||||
if (!is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded
|
||||
|
||||
$fonc='numberwords';
|
||||
$fonc = 'numberwords';
|
||||
if (file_exists($newdir.'/functions_'.$fonc.'.lib.php'))
|
||||
{
|
||||
include_once $newdir.'/functions_'.$fonc.'.lib.php';
|
||||
$newnumber=numberwords_getLabelFromNumber($this, $number, $isamount);
|
||||
$newnumber = numberwords_getLabelFromNumber($this, $number, $isamount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -893,36 +891,36 @@ class Translate
|
||||
//print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit;
|
||||
|
||||
// Check if a translation is available (this can call getTradFromKey)
|
||||
$tmp=$this->transnoentitiesnoconv($key);
|
||||
$tmp = $this->transnoentitiesnoconv($key);
|
||||
if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString')
|
||||
{
|
||||
return $tmp; // Found in language array
|
||||
return $tmp; // Found in language array
|
||||
}
|
||||
|
||||
// Check in cache
|
||||
if (isset($this->cache_labels[$tablename][$key])) // Can be defined to 0 or ''
|
||||
{
|
||||
return $this->cache_labels[$tablename][$key]; // Found in cache
|
||||
return $this->cache_labels[$tablename][$key]; // Found in cache
|
||||
}
|
||||
|
||||
$sql = "SELECT ".$fieldlabel." as label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
|
||||
$sql.= " WHERE ".$fieldkey." = '".$db->escape($keyforselect?$keyforselect:$key)."'";
|
||||
if ($filteronentity) $sql.= " AND entity IN (" . getEntity($tablename). ')';
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$tablename;
|
||||
$sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'";
|
||||
if ($filteronentity) $sql .= " AND entity IN (".getEntity($tablename).')';
|
||||
dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $this->cache_labels[$tablename][$key]=$obj->label;
|
||||
else $this->cache_labels[$tablename][$key]=$key;
|
||||
if ($obj) $this->cache_labels[$tablename][$key] = $obj->label;
|
||||
else $this->cache_labels[$tablename][$key] = $key;
|
||||
|
||||
$db->free($resql);
|
||||
return $this->cache_labels[$tablename][$key];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$db->lasterror();
|
||||
$this->error = $db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -939,7 +937,7 @@ class Translate
|
||||
*/
|
||||
public function getCurrencyAmount($currency_code, $amount)
|
||||
{
|
||||
$symbol=$this->getCurrencySymbol($currency_code);
|
||||
$symbol = $this->getCurrencySymbol($currency_code);
|
||||
|
||||
if (in_array($currency_code, array('USD'))) return $symbol.$amount;
|
||||
else return $amount.$symbol;
|
||||
@ -955,22 +953,22 @@ class Translate
|
||||
*/
|
||||
public function getCurrencySymbol($currency_code, $forceloadall = 0)
|
||||
{
|
||||
$currency_sign = ''; // By default return iso code
|
||||
$currency_sign = ''; // By default return iso code
|
||||
|
||||
if (function_exists("mb_convert_encoding"))
|
||||
{
|
||||
$this->loadCacheCurrencies($forceloadall?'':$currency_code);
|
||||
$this->loadCacheCurrencies($forceloadall ? '' : $currency_code);
|
||||
|
||||
if (isset($this->cache_currencies[$currency_code]) && ! empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode']))
|
||||
if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode']))
|
||||
{
|
||||
foreach($this->cache_currencies[$currency_code]['unicode'] as $unicode)
|
||||
foreach ($this->cache_currencies[$currency_code]['unicode'] as $unicode)
|
||||
{
|
||||
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ($currency_sign?$currency_sign:$currency_code);
|
||||
return ($currency_sign ? $currency_sign : $currency_code);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -983,13 +981,13 @@ class Translate
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all
|
||||
if (! empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency
|
||||
if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all
|
||||
if (!empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency
|
||||
|
||||
$sql = "SELECT code_iso, label, unicode";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
|
||||
$sql.= " WHERE active = 1";
|
||||
if (! empty($currency_code)) $sql.=" AND code_iso = '".$db->escape($currency_code)."'";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_currencies";
|
||||
$sql .= " WHERE active = 1";
|
||||
if (!empty($currency_code)) $sql .= " AND code_iso = '".$db->escape($currency_code)."'";
|
||||
//$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later
|
||||
|
||||
dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG);
|
||||
@ -997,8 +995,8 @@ class Translate
|
||||
if ($resql)
|
||||
{
|
||||
$this->load("dict");
|
||||
$label=array();
|
||||
if (! empty($currency_code)) foreach($this->cache_currencies as $key => $val) $label[$key]=$val['label']; // Label in already loaded cache
|
||||
$label = array();
|
||||
if (!empty($currency_code)) foreach ($this->cache_currencies as $key => $val) $label[$key] = $val['label']; // Label in already loaded cache
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
@ -1007,12 +1005,12 @@ class Translate
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$this->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
|
||||
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
|
||||
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
|
||||
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
|
||||
$i++;
|
||||
}
|
||||
if (empty($currency_code)) $this->cache_currencies_all_loaded=true;
|
||||
if (empty($currency_code)) $this->cache_currencies_all_loaded = true;
|
||||
//print count($label).' '.count($this->cache_currencies);
|
||||
|
||||
// Resort cache
|
||||
@ -1039,7 +1037,7 @@ class Translate
|
||||
// phpcs:enable
|
||||
$substitutionarray = array();
|
||||
|
||||
foreach($this->tab_translate as $code => $label) {
|
||||
foreach ($this->tab_translate as $code => $label) {
|
||||
$substitutionarray['lang_'.$code] = $label;
|
||||
$substitutionarray['__('.$code.')__'] = $label;
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ class Utils
|
||||
|
||||
$outputdir = $conf->admin->dir_output.'/backup';
|
||||
$result = dol_mkdir($outputdir);
|
||||
|
||||
$errormsg = '';
|
||||
|
||||
// MYSQL
|
||||
if ($type == 'mysql' || $type == 'mysqli')
|
||||
@ -296,7 +296,6 @@ class Utils
|
||||
$paramclear .= ' -p"'.str_replace(array('"', '`'), array('\"', '\`'), $dolibarr_main_db_pass).'"';
|
||||
}
|
||||
|
||||
$errormsg = '';
|
||||
$handle = '';
|
||||
|
||||
// Start call method to execute dump
|
||||
@ -383,6 +382,8 @@ class Utils
|
||||
{
|
||||
// Get 2048 first chars of error message.
|
||||
$errormsg = fgets($handle, 2048);
|
||||
//$ok=0;$errormsg=''; To force error
|
||||
|
||||
// Close file
|
||||
if ($compression == 'none') fclose($handle);
|
||||
if ($compression == 'gz') gzclose($handle);
|
||||
@ -492,7 +493,7 @@ class Utils
|
||||
}
|
||||
|
||||
// Clean old files
|
||||
if ($keeplastnfiles > 0)
|
||||
if (! $errormsg && $keeplastnfiles > 0)
|
||||
{
|
||||
$tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC);
|
||||
$i = 0;
|
||||
@ -504,7 +505,7 @@ class Utils
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ($errormsg ? -1 : 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1328,13 +1328,17 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
$sql .= " a.fk_contact,";
|
||||
$sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,";
|
||||
$sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname";
|
||||
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= ", sp.lastname, sp.firstname";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ }
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ }
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", o.ref";
|
||||
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
|
||||
@ -1346,23 +1350,26 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
$sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id;
|
||||
}
|
||||
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
|
||||
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er";
|
||||
$sql .= " ON er.resource_type = 'dolresource'";
|
||||
$sql .= " AND er.element_id = a.id";
|
||||
$sql .= " AND er.resource_id = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ }
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o";
|
||||
elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o";
|
||||
|
||||
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
|
||||
if ($force_filter_contact === false) {
|
||||
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id;
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ }
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id;
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent')
|
||||
{
|
||||
@ -1394,6 +1401,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element)
|
||||
{
|
||||
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element)."'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Condition on actioncode
|
||||
@ -1612,7 +1624,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
$caction = new CActionComm($db);
|
||||
$arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
|
||||
|
||||
foreach ($histo as $key=>$value)
|
||||
foreach ($histo as $key => $value)
|
||||
{
|
||||
$actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
|
||||
|
||||
@ -1693,13 +1705,13 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
|
||||
// Date
|
||||
$out .= '<td class="center nowrap">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayhour');
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel');
|
||||
if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart'])
|
||||
{
|
||||
$tmpa = dol_getdate($histo[$key]['datestart'], true);
|
||||
$tmpb = dol_getdate($histo[$key]['dateend'], true);
|
||||
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour');
|
||||
else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour');
|
||||
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel');
|
||||
else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel');
|
||||
}
|
||||
$late = 0;
|
||||
if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1;
|
||||
@ -1712,7 +1724,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
// Title of event
|
||||
//$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
|
||||
|
||||
// Objet lie
|
||||
// Linked object
|
||||
$out .= '<td>';
|
||||
if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element']))
|
||||
{
|
||||
@ -1721,7 +1733,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
else $out .= ' ';
|
||||
$out .= '</td>';
|
||||
|
||||
// Contact pour cette action
|
||||
// Contact(s) for action
|
||||
if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0)
|
||||
{
|
||||
$contactstatic->lastname = $histo[$key]['lastname'];
|
||||
@ -1730,15 +1742,15 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
$out .= '<td width="120">'.$contactstatic->getNomUrl(1, '', 10).'</td>';
|
||||
} elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) {
|
||||
$out .= '<td>';
|
||||
foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) {
|
||||
$contact = new Contact($db);
|
||||
$contact = new Contact($db);
|
||||
foreach ($histo[$key]['socpeopleassigned'] as $cid => $value) {
|
||||
$result = $contact->fetch($cid);
|
||||
|
||||
if ($result < 0)
|
||||
dol_print_error($db, $contact->error);
|
||||
|
||||
if ($result > 0) {
|
||||
$out .= $contact->getNomUrl(1);
|
||||
$out .= $contact->getNomUrl(1, '', 16);
|
||||
if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
|
||||
if (!empty($contact->phone_pro))
|
||||
$out .= '('.dol_print_phone($contact->phone_pro).')';
|
||||
|
||||
@ -2082,9 +2082,10 @@ function dol_uncompress($inputfile, $outputdir)
|
||||
* @param string $outputfile Target file name (output directory must exists and be writable)
|
||||
* @param string $mode 'zip'
|
||||
* @param string $excludefiles A regex pattern. For example: '/\.log$|\/temp\//'
|
||||
* @param string $rootdirinzip Add a root dir level in zip file
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '')
|
||||
function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '', $rootdirinzip = '')
|
||||
{
|
||||
$foundhandler=0;
|
||||
|
||||
@ -2145,7 +2146,8 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles =
|
||||
{
|
||||
// Get real and relative path for current file
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen($inputdir) + 1);
|
||||
$relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen($inputdir) + 1);
|
||||
|
||||
if (empty($excludefiles) || ! preg_match($excludefiles, $filePath))
|
||||
{
|
||||
// Add current file to archive
|
||||
|
||||
@ -838,7 +838,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
|
||||
function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
|
||||
{
|
||||
$filesystem_forbidden_chars = array('<', '>', '?', '*', '|', '"', '°');
|
||||
return dol_string_nospecial($unaccent ?dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
|
||||
return dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1561,13 +1561,13 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
||||
}
|
||||
|
||||
// Add if object was dispatched "into accountancy"
|
||||
if (!empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'facture', 'invoice', 'invoice_supplier', 'expensereport')))
|
||||
if (!empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'facture', 'invoice', 'invoice_supplier', 'expensereport', 'payment_various')))
|
||||
{
|
||||
if (method_exists($object, 'getVentilExportCompta'))
|
||||
{
|
||||
$accounted = $object->getVentilExportCompta();
|
||||
$langs->load("accountancy");
|
||||
$morehtmlstatus .= '</div><div class="statusref statusrefbis">'.($accounted > 0 ? $langs->trans("Accounted") : '<span class="opacitymedium">'.$langs->trans("NotYetAccounted").'</span>');
|
||||
$morehtmlstatus .= '</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted")).'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1639,13 +1639,14 @@ function dol_bc($var, $moreclass = '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formated address (part address/zip/town/state) according to country rules
|
||||
* Return a formated address (part address/zip/town/state) according to country rules.
|
||||
* See https://en.wikipedia.org/wiki/Address
|
||||
*
|
||||
* @param Object $object A company or contact object
|
||||
* @param int $withcountry 1=Add country into address string
|
||||
* @param string $sep Separator to use to build string
|
||||
* @param Translate $outputlangs Object lang that contains language for text translation.
|
||||
* @param int $mode 0=Standard output, 1=Remove address
|
||||
* @param int $withcountry 1=Add country into address string
|
||||
* @param string $sep Separator to use to build string
|
||||
* @param Translate $outputlangs Object lang that contains language for text translation.
|
||||
* @param int $mode 0=Standard output, 1=Remove address
|
||||
* @return string Formated string
|
||||
* @see dol_print_address()
|
||||
*/
|
||||
@ -1656,6 +1657,8 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
|
||||
$ret = '';
|
||||
$countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
|
||||
|
||||
// See format of addresses on https://en.wikipedia.org/wiki/Address
|
||||
|
||||
// Address
|
||||
if (empty($mode)) {
|
||||
$ret .= $object->address;
|
||||
@ -1692,7 +1695,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
|
||||
{
|
||||
$ret .= ($ret ? $sep : '').$object->zip;
|
||||
$ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : '');
|
||||
$ret .= ($object->state_id ? (' ('.($object->state_id).')') : '');
|
||||
$ret .= ($object->state_code ? (' '.($object->state_code)) : '');
|
||||
}
|
||||
else // Other: title firstname name \n address lines \n zip town \n country
|
||||
{
|
||||
@ -3099,7 +3102,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
$fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext];
|
||||
}
|
||||
elseif ($pictowithouttext == 'switch_on') {
|
||||
$morecss = 'font-status4';
|
||||
$morecss .= ($morecss ? ' ' : '').'font-status4';
|
||||
$fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext];
|
||||
}
|
||||
elseif ($pictowithouttext == 'off') {
|
||||
@ -4677,6 +4680,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_sell
|
||||
dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '')."/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj);
|
||||
|
||||
$vatratecleaned = $vatrate;
|
||||
$reg = array();
|
||||
if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)"
|
||||
{
|
||||
$vatratecleaned = trim($reg[1]);
|
||||
@ -4921,13 +4925,14 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local);
|
||||
|
||||
// Search local taxes
|
||||
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
|
||||
$sql = "SELECT t.taux as rate, t.code, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
|
||||
if ($firstparamisid) $sql .= " WHERE t.rowid = ".(int) $vatrate;
|
||||
else
|
||||
{
|
||||
$vatratecleaned = $vatrate;
|
||||
$vatratecode = '';
|
||||
$reg = array();
|
||||
if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "x.x (yy)"
|
||||
{
|
||||
$vatratecleaned = $reg[1];
|
||||
@ -4945,17 +4950,20 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$vateratestring = $obj->rate.($obj->code ? ' ('.$obj->code.')' : '');
|
||||
|
||||
if ($local == 1)
|
||||
{
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
elseif ($local == 2)
|
||||
{
|
||||
return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
return array($obj->localtax2_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, get_localtax($vateratestring, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vateratestring, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6031,6 +6039,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
||||
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
|
||||
$substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
|
||||
$substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : '');
|
||||
$substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset($object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : '');
|
||||
|
||||
$birthday = dol_print_date($object->birth, 'day');
|
||||
|
||||
@ -7656,6 +7665,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
|
||||
$operator = '=';
|
||||
$newcrit = preg_replace('/([<>=]+)/', '', trim($crit));
|
||||
|
||||
$reg = array();
|
||||
preg_match('/([<>=]+)/', trim($crit), $reg);
|
||||
if ($reg[1])
|
||||
{
|
||||
|
||||
@ -573,7 +573,7 @@ function isValidVATID($company)
|
||||
elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers
|
||||
else $vatprefix = preg_quote($vatprefix, '/');*/
|
||||
$vatprefix = '[a-zA-Z][a-zA-Z]';
|
||||
if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra)))
|
||||
if (!preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -732,17 +732,17 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '
|
||||
*/
|
||||
function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null)
|
||||
{
|
||||
global $conf,$user;
|
||||
global $conf, $user;
|
||||
|
||||
if (! is_object($objsoc)) $valueforccc=$objsoc;
|
||||
elseif ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=dol_string_unaccent($objsoc->code_fournisseur);
|
||||
else $valueforccc=dol_string_unaccent($objsoc->code_client);
|
||||
if (!is_object($objsoc)) $valueforccc = $objsoc;
|
||||
elseif ($table == "commande_fournisseur" || $table == "facture_fourn") $valueforccc = dol_string_unaccent($objsoc->code_fournisseur);
|
||||
else $valueforccc = dol_string_unaccent($objsoc->code_client);
|
||||
|
||||
$sharetable = $table;
|
||||
if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function
|
||||
|
||||
// Clean parameters
|
||||
if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers
|
||||
if ($date == '') $date = dol_now(); // We use local year and month of PHP server to search numbers
|
||||
// but we should use local year and month of user
|
||||
|
||||
// For debugging
|
||||
@ -811,73 +811,73 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
$lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
|
||||
if (is_object($objuser)) $lastname = $objuser->lastname;
|
||||
|
||||
$maskuser=$regType[1];
|
||||
$maskuser_value=substr($lastname, 0, dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask)
|
||||
$maskuser_value=str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask
|
||||
$maskuser = $regType[1];
|
||||
$maskuser_value = substr($lastname, 0, dol_strlen($regType[1])); // get n first characters of user firstname (where n is length in mask)
|
||||
$maskuser_value = str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask
|
||||
}
|
||||
else
|
||||
{
|
||||
$maskuser='';
|
||||
$maskuser_value='';
|
||||
$maskuser = '';
|
||||
$maskuser_value = '';
|
||||
}
|
||||
|
||||
// Personalized field {XXX-1} à {XXX-9}
|
||||
$maskperso=array();
|
||||
$maskpersonew=array();
|
||||
$tmpmask=$mask;
|
||||
$maskperso = array();
|
||||
$maskpersonew = array();
|
||||
$tmpmask = $mask;
|
||||
while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey))
|
||||
{
|
||||
$maskperso[$regKey[1]]='{'.$regKey[1].'-'.$regKey[2].'}';
|
||||
$maskpersonew[$regKey[1]]=str_pad('', $regKey[2], '_', STR_PAD_RIGHT);
|
||||
$tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask);
|
||||
$maskperso[$regKey[1]] = '{'.$regKey[1].'-'.$regKey[2].'}';
|
||||
$maskpersonew[$regKey[1]] = str_pad('', $regKey[2], '_', STR_PAD_RIGHT);
|
||||
$tmpmask = preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask);
|
||||
}
|
||||
|
||||
if (strstr($mask, 'user_extra_'))
|
||||
{
|
||||
$start = "{user_extra_";
|
||||
$end = "\}";
|
||||
$extra= get_string_between($mask, "user_extra_", "}");
|
||||
$extra = get_string_between($mask, "user_extra_", "}");
|
||||
if (!empty($user->array_options['options_'.$extra])) {
|
||||
$mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask);
|
||||
$mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask);
|
||||
}
|
||||
}
|
||||
$maskwithonlyymcode=$mask;
|
||||
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode);
|
||||
foreach($maskperso as $key => $val)
|
||||
$maskwithonlyymcode = $mask;
|
||||
$maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode);
|
||||
$maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode = preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode = preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode);
|
||||
foreach ($maskperso as $key => $val)
|
||||
{
|
||||
$maskwithonlyymcode=preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode);
|
||||
$maskwithonlyymcode = preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode);
|
||||
}
|
||||
$maskwithnocode=$maskwithonlyymcode;
|
||||
$maskwithnocode=preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{yy\}/i', 'yy', $maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{y\}/i', 'y', $maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{mm\}/i', 'mm', $maskwithnocode);
|
||||
$maskwithnocode = $maskwithonlyymcode;
|
||||
$maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode);
|
||||
$maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode);
|
||||
$maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode);
|
||||
$maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode);
|
||||
// Now maskwithnocode = 0000ddmmyyyyccc for example
|
||||
// and maskcounter = 0000 for example
|
||||
//print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>";
|
||||
//var_dump($reg);
|
||||
|
||||
// If an offset is asked
|
||||
if (! empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset=preg_replace('/^\+/', '', $reg[2]);
|
||||
if (! empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset=preg_replace('/^\+/', '', $reg[3]);
|
||||
if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]);
|
||||
if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]);
|
||||
|
||||
// Define $sqlwhere
|
||||
$sqlwhere='';
|
||||
$yearoffset=0; // Use year of current $date by default
|
||||
$yearoffsettype=false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x
|
||||
$sqlwhere = '';
|
||||
$yearoffset = 0; // Use year of current $date by default
|
||||
$yearoffsettype = false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x
|
||||
|
||||
// If a restore to zero after a month is asked we check if there is already a value for this year.
|
||||
if (! empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]);
|
||||
if (! empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]);
|
||||
if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]);
|
||||
if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]);
|
||||
|
||||
//print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype;
|
||||
if (is_numeric($yearoffsettype) && $yearoffsettype >= 1)
|
||||
$maskraz=$yearoffsettype; // For backward compatibility
|
||||
elseif ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
|
||||
$maskraz = $yearoffsettype; // For backward compatibility
|
||||
elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
|
||||
$maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
|
||||
//print "maskraz=".$maskraz; // -1=no reset
|
||||
|
||||
@ -1161,24 +1161,24 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
if ($maskrefclient)
|
||||
{
|
||||
//print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n<br>";exit;
|
||||
$maskrefclient_maskbefore='{'.$maskrefclient.'}';
|
||||
$maskrefclient_maskafter=$maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT);
|
||||
$maskrefclient_maskbefore = '{'.$maskrefclient.'}';
|
||||
$maskrefclient_maskafter = $maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT);
|
||||
$numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal);
|
||||
}
|
||||
|
||||
// Now we replace the type
|
||||
if ($masktype)
|
||||
{
|
||||
$masktype_maskbefore='{'.$masktype.'}';
|
||||
$masktype_maskafter=$masktype_value;
|
||||
$masktype_maskbefore = '{'.$masktype.'}';
|
||||
$masktype_maskafter = $masktype_value;
|
||||
$numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal);
|
||||
}
|
||||
|
||||
// Now we replace the user
|
||||
if ($maskuser)
|
||||
{
|
||||
$maskuser_maskbefore='{'.$maskuser.'}';
|
||||
$maskuser_maskafter=$maskuser_value;
|
||||
$maskuser_maskbefore = '{'.$maskuser.'}';
|
||||
$maskuser_maskafter = $maskuser_value;
|
||||
$numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal);
|
||||
}
|
||||
}
|
||||
@ -1214,69 +1214,69 @@ function get_string_between($string, $start, $end)
|
||||
*/
|
||||
function check_value($mask, $value)
|
||||
{
|
||||
$result=0;
|
||||
$result = 0;
|
||||
|
||||
$hasglobalcounter=false;
|
||||
$hasglobalcounter = false;
|
||||
// Extract value for mask counter, mask raz and mask offset
|
||||
if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg))
|
||||
{
|
||||
$masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:'');
|
||||
$maskcounter=$reg[1];
|
||||
$hasglobalcounter=true;
|
||||
$masktri = $reg[1].(isset($reg[2]) ? $reg[2] : '').(isset($reg[3]) ? $reg[3] : '');
|
||||
$maskcounter = $reg[1];
|
||||
$hasglobalcounter = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// setting some defaults so the rest of the code won't fail if there is a third party counter
|
||||
$masktri='00000';
|
||||
$maskcounter='00000';
|
||||
$masktri = '00000';
|
||||
$maskcounter = '00000';
|
||||
}
|
||||
|
||||
$maskraz=-1;
|
||||
$maskoffset=0;
|
||||
$maskraz = -1;
|
||||
$maskoffset = 0;
|
||||
if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
|
||||
|
||||
// Extract value for third party mask counter
|
||||
if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef))
|
||||
{
|
||||
$maskrefclient=$regClientRef[1].$regClientRef[2];
|
||||
$maskrefclient_maskclientcode=$regClientRef[1];
|
||||
$maskrefclient_maskcounter=$regClientRef[2];
|
||||
$maskrefclient_maskoffset=0; //default value of maskrefclient_counter offset
|
||||
$maskrefclient_clientcode=substr('', 0, dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode
|
||||
$maskrefclient_clientcode=str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode
|
||||
$maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like
|
||||
$maskrefclient = $regClientRef[1].$regClientRef[2];
|
||||
$maskrefclient_maskclientcode = $regClientRef[1];
|
||||
$maskrefclient_maskcounter = $regClientRef[2];
|
||||
$maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset
|
||||
$maskrefclient_clientcode = substr('', 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code to form maskrefclient_clientcode
|
||||
$maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode
|
||||
$maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like
|
||||
if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
|
||||
}
|
||||
else $maskrefclient='';
|
||||
else $maskrefclient = '';
|
||||
|
||||
// fail if there is neither a global nor a third party counter
|
||||
if (! $hasglobalcounter && ($maskrefclient_maskcounter == ''))
|
||||
if (!$hasglobalcounter && ($maskrefclient_maskcounter == ''))
|
||||
{
|
||||
return 'ErrorBadMask';
|
||||
}
|
||||
|
||||
$maskwithonlyymcode=$mask;
|
||||
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode);
|
||||
$maskwithnocode=$maskwithonlyymcode;
|
||||
$maskwithnocode=preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{yy\}/i', 'yy', $maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{y\}/i', 'y', $maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{mm\}/i', 'mm', $maskwithnocode);
|
||||
$maskwithonlyymcode = $mask;
|
||||
$maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode);
|
||||
$maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode);
|
||||
$maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode);
|
||||
$maskwithnocode = $maskwithonlyymcode;
|
||||
$maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode);
|
||||
$maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode);
|
||||
$maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode);
|
||||
$maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode);
|
||||
// Now maskwithnocode = 0000ddmmyyyyccc for example
|
||||
// and maskcounter = 0000 for example
|
||||
//print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>";
|
||||
|
||||
// If an offset is asked
|
||||
if (! empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset=preg_replace('/^\+/', '', $reg[2]);
|
||||
if (! empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset=preg_replace('/^\+/', '', $reg[3]);
|
||||
if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]);
|
||||
if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]);
|
||||
|
||||
// Define $sqlwhere
|
||||
|
||||
// If a restore to zero after a month is asked we check if there is already a value for this year.
|
||||
if (! empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz=preg_replace('/^@/', '', $reg[2]);
|
||||
if (! empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz=preg_replace('/^@/', '', $reg[3]);
|
||||
if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz = preg_replace('/^@/', '', $reg[2]);
|
||||
if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz = preg_replace('/^@/', '', $reg[3]);
|
||||
if ($maskraz >= 0)
|
||||
{
|
||||
if ($maskraz == 99) {
|
||||
@ -1286,8 +1286,8 @@ function check_value($mask, $value)
|
||||
if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth';
|
||||
|
||||
// Define reg
|
||||
if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
|
||||
if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask';
|
||||
if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
|
||||
if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask';
|
||||
//print "x".$maskwithonlyymcode." ".$maskraz;
|
||||
}
|
||||
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
|
||||
@ -1616,16 +1616,16 @@ function version_webserver()
|
||||
*/
|
||||
function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$liste=array();
|
||||
$found=0;
|
||||
$dirtoscan='';
|
||||
global $conf, $langs;
|
||||
$liste = array();
|
||||
$found = 0;
|
||||
$dirtoscan = '';
|
||||
|
||||
$sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity IN (0,".$conf->entity.")";
|
||||
$sql.= " ORDER BY description DESC";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity IN (0,".$conf->entity.")";
|
||||
$sql .= " ORDER BY description DESC";
|
||||
|
||||
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
@ -1635,48 +1635,48 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$found=1;
|
||||
$found = 1;
|
||||
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
// If this generation module needs to scan a directory, then description field is filled
|
||||
// with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
|
||||
if (! empty($obj->description)) // A list of directories to scan is defined
|
||||
if (!empty($obj->description)) // A list of directories to scan is defined
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$const=$obj->description;
|
||||
$const = $obj->description;
|
||||
//irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const));
|
||||
$dirtoscan= preg_replace('/[\r\n]+/', ',', trim($conf->global->$const));
|
||||
$dirtoscan = preg_replace('/[\r\n]+/', ',', trim($conf->global->$const));
|
||||
|
||||
$listoffiles=array();
|
||||
$listoffiles = array();
|
||||
|
||||
// Now we add models found in directories scanned
|
||||
$listofdir=explode(',', $dirtoscan);
|
||||
foreach($listofdir as $key=>$tmpdir)
|
||||
$listofdir = explode(',', $dirtoscan);
|
||||
foreach ($listofdir as $key=>$tmpdir)
|
||||
{
|
||||
$tmpdir=trim($tmpdir);
|
||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (! $tmpdir) { unset($listofdir[$key]); continue; }
|
||||
$tmpdir = trim($tmpdir);
|
||||
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (!$tmpdir) { unset($listofdir[$key]); continue; }
|
||||
if (is_dir($tmpdir))
|
||||
{
|
||||
// all type of template is allowed
|
||||
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0);
|
||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
|
||||
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0);
|
||||
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($listoffiles))
|
||||
{
|
||||
foreach($listoffiles as $record)
|
||||
foreach ($listoffiles as $record)
|
||||
{
|
||||
$max=($maxfilenamelength?$maxfilenamelength:28);
|
||||
$liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'], $max, 'middle');
|
||||
$max = ($maxfilenamelength ? $maxfilenamelength : 28);
|
||||
$liste[$obj->id.':'.$record['fullname']] = dol_trunc($record['name'], $max, 'middle');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$liste[0]=$obj->label.': '.$langs->trans("None");
|
||||
$liste[0] = $obj->label.': '.$langs->trans("None");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1685,14 +1685,14 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
{
|
||||
global $_Avery_Labels;
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
|
||||
foreach($_Avery_Labels as $key => $val)
|
||||
foreach ($_Avery_Labels as $key => $val)
|
||||
{
|
||||
$liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->doc_template_name).' '.$val['name'];
|
||||
$liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name'];
|
||||
}
|
||||
}
|
||||
else // Common usage
|
||||
{
|
||||
$liste[$obj->id]=$obj->label?$obj->label:$obj->doc_template_name;
|
||||
$liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
@ -1762,7 +1762,7 @@ function getSoapParams()
|
||||
$proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT);
|
||||
$proxyuser = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_USER);
|
||||
$proxypass = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PASS);
|
||||
$timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout
|
||||
$timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout
|
||||
$response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout
|
||||
//print extension_loaded('soap');
|
||||
if ($proxyuse)
|
||||
@ -1797,7 +1797,7 @@ function getSoapParams()
|
||||
* Return link url to an object
|
||||
*
|
||||
* @param int $objectid Id of record
|
||||
* @param string $objecttype Type of object ('invoice', 'order', 'expedition_bon', ...)
|
||||
* @param string $objecttype Type of object ('invoice', 'order', 'expedition_bon', 'myobject@mymodule', ...)
|
||||
* @param int $withpicto Picto to show
|
||||
* @param string $option More options
|
||||
* @return string URL of link to object id/type
|
||||
@ -1807,83 +1807,95 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
||||
global $db, $conf, $langs;
|
||||
|
||||
$ret = '';
|
||||
$regs = array();
|
||||
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$module = $element = $subelement = $objecttype;
|
||||
// If we ask an resource form external module (instead of default path)
|
||||
if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) {
|
||||
$myobject = $regs[1];
|
||||
$module = $regs[2];
|
||||
}
|
||||
|
||||
// Parse $objecttype (ex: project_task)
|
||||
$module = $myobject = $objecttype;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
|
||||
{
|
||||
$module = $element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
$module = $regs[1];
|
||||
$myobject = $regs[2];
|
||||
}
|
||||
|
||||
// Generic case for $classpath
|
||||
$classpath = $element.'/class';
|
||||
$classpath = $module.'/class';
|
||||
|
||||
// Special cases, to work with non standard path
|
||||
if ($objecttype == 'facture' || $objecttype == 'invoice') {
|
||||
$classpath = 'compta/facture/class';
|
||||
$module='facture';
|
||||
$subelement='facture';
|
||||
$module = 'facture';
|
||||
$myobject = 'facture';
|
||||
}
|
||||
elseif ($objecttype == 'commande' || $objecttype == 'order') {
|
||||
$classpath = 'commande/class';
|
||||
$module='commande';
|
||||
$subelement='commande';
|
||||
$module = 'commande';
|
||||
$myobject = 'commande';
|
||||
}
|
||||
elseif ($objecttype == 'propal') {
|
||||
elseif ($objecttype == 'propal') {
|
||||
$classpath = 'comm/propal/class';
|
||||
}
|
||||
elseif ($objecttype == 'supplier_proposal') {
|
||||
elseif ($objecttype == 'supplier_proposal') {
|
||||
$classpath = 'supplier_proposal/class';
|
||||
}
|
||||
elseif ($objecttype == 'shipping') {
|
||||
$classpath = 'expedition/class';
|
||||
$subelement = 'expedition';
|
||||
$myobject = 'expedition';
|
||||
$module = 'expedition_bon';
|
||||
}
|
||||
elseif ($objecttype == 'delivery') {
|
||||
$classpath = 'livraison/class';
|
||||
$subelement = 'livraison';
|
||||
$myobject = 'livraison';
|
||||
$module = 'livraison_bon';
|
||||
}
|
||||
elseif ($objecttype == 'contract') {
|
||||
$classpath = 'contrat/class';
|
||||
$module='contrat';
|
||||
$subelement='contrat';
|
||||
$module = 'contrat';
|
||||
$myobject = 'contrat';
|
||||
}
|
||||
elseif ($objecttype == 'member') {
|
||||
$classpath = 'adherents/class';
|
||||
$module='adherent';
|
||||
$subelement='adherent';
|
||||
$module = 'adherent';
|
||||
$myobject = 'adherent';
|
||||
}
|
||||
elseif ($objecttype == 'cabinetmed_cons') {
|
||||
$classpath = 'cabinetmed/class';
|
||||
$module='cabinetmed';
|
||||
$subelement='cabinetmedcons';
|
||||
$module = 'cabinetmed';
|
||||
$myobject = 'cabinetmedcons';
|
||||
}
|
||||
elseif ($objecttype == 'fichinter') {
|
||||
$classpath = 'fichinter/class';
|
||||
$module='ficheinter';
|
||||
$subelement='fichinter';
|
||||
$module = 'ficheinter';
|
||||
$myobject = 'fichinter';
|
||||
}
|
||||
elseif ($objecttype == 'task') {
|
||||
$classpath = 'projet/class';
|
||||
$module='projet';
|
||||
$subelement='task';
|
||||
$module = 'projet';
|
||||
$myobject = 'task';
|
||||
}
|
||||
elseif ($objecttype == 'stock') {
|
||||
$classpath = 'product/stock/class';
|
||||
$module='stock';
|
||||
$subelement='stock';
|
||||
$module = 'stock';
|
||||
$myobject = 'stock';
|
||||
}
|
||||
elseif ($objecttype == 'inventory') {
|
||||
$classpath = 'product/inventory/class';
|
||||
$module='stock';
|
||||
$subelement='inventory';
|
||||
$module = 'stock';
|
||||
$myobject = 'inventory';
|
||||
}
|
||||
elseif ($objecttype == 'mo') {
|
||||
$classpath = 'mrp/class';
|
||||
$module = 'mrp';
|
||||
$myobject = 'mo';
|
||||
}
|
||||
|
||||
// Generic case for $classfile and $classname
|
||||
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
||||
$classfile = strtolower($myobject); $classname = ucfirst($myobject);
|
||||
//print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname;
|
||||
|
||||
if ($objecttype == 'invoice_supplier') {
|
||||
@ -1903,6 +1915,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
||||
$classfile = 'entrepot';
|
||||
$classname = 'Entrepot';
|
||||
}
|
||||
|
||||
if (!empty($conf->$module->enabled))
|
||||
{
|
||||
$res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
||||
@ -2048,12 +2061,14 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent)
|
||||
/**
|
||||
* Get an array with properties of an element
|
||||
*
|
||||
* @param string $element_type Element type: 'action', 'facture', 'project_task' or 'object@modulext'...
|
||||
* @param string $element_type Element type: 'action', 'facture', 'project_task' or 'object@mymodule'...
|
||||
* @return array (module, classpath, element, subelement, classfile, classname)
|
||||
*/
|
||||
function getElementProperties($element_type)
|
||||
{
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$regs = array();
|
||||
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$module = $element_type;
|
||||
$element = $element_type;
|
||||
$subelement = $element_type;
|
||||
@ -2242,9 +2257,9 @@ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88))
|
||||
*/
|
||||
function colorValidateHex($color, $allow_white = true)
|
||||
{
|
||||
if(!$allow_white && ($color === '#fff' || $color === '#ffffff') ) return false;
|
||||
if (!$allow_white && ($color === '#fff' || $color === '#ffffff')) return false;
|
||||
|
||||
if(preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid
|
||||
if (preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -2262,7 +2277,7 @@ function colorValidateHex($color, $allow_white = true)
|
||||
*/
|
||||
function colorAgressiveness($hex, $ratio = -50, $brightness = 0)
|
||||
{
|
||||
if (empty($ratio)) $ratio = 0; // To avoid null
|
||||
if (empty($ratio)) $ratio = 0; // To avoid null
|
||||
|
||||
// Steps should be between -255 and 255. Negative = darker, positive = lighter
|
||||
$ratio = max(-100, min(100, $ratio));
|
||||
@ -2278,7 +2293,7 @@ function colorAgressiveness($hex, $ratio = -50, $brightness = 0)
|
||||
$return = '#';
|
||||
|
||||
foreach ($color_parts as $color) {
|
||||
$color = hexdec($color); // Convert to decimal
|
||||
$color = hexdec($color); // Convert to decimal
|
||||
if ($ratio > 0) // We increase aggressivity
|
||||
{
|
||||
if ($color > 127) $color += ((255 - $color) * ($ratio / 100));
|
||||
@ -2592,9 +2607,9 @@ function convertBackOfficeMediasLinksToPublicLinks($notetoshow)
|
||||
{
|
||||
global $dolibarr_main_url_root;
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
$notetoshow=preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow);
|
||||
$notetoshow = preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow);
|
||||
return $notetoshow;
|
||||
}
|
||||
|
||||
@ -1072,7 +1072,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
|
||||
if ($projectstatic->title)
|
||||
{
|
||||
print ' - ';
|
||||
print $projectstatic->title;
|
||||
print '<span class="secondary">'.$projectstatic->title.'</span>';
|
||||
}
|
||||
/*
|
||||
$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
|
||||
@ -1451,7 +1451,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
||||
if ($projectstatic->title)
|
||||
{
|
||||
print ' - ';
|
||||
print $projectstatic->title;
|
||||
print '<span class="secondary">'.$projectstatic->title.'</span>';
|
||||
}
|
||||
|
||||
/*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
|
||||
|
||||
@ -222,7 +222,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
|
||||
public $export_permission;
|
||||
public $export_fields_array;
|
||||
public $export_TypeFields_array;
|
||||
public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid'
|
||||
public $export_entities_array;
|
||||
public $export_special_array; // special or computed field
|
||||
public $export_dependencies_array;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user