Merge branch 'dev_EventOrganisation' into dev_EventOrganisation_draft
This commit is contained in:
commit
9162574262
34
DCO
Normal file
34
DCO
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
Developer Certificate of Origin
|
||||||
|
Version 1.1
|
||||||
|
|
||||||
|
Copyright (C) 2002 - Today, The Dolibarr team and its contributors.
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this
|
||||||
|
license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
Developer's Certificate of Origin 1.1
|
||||||
|
|
||||||
|
By making a contribution to this project, I certify that:
|
||||||
|
|
||||||
|
(a) The contribution was created in whole or in part by me and I
|
||||||
|
have the right to submit it under the open source license
|
||||||
|
indicated in the file; or
|
||||||
|
|
||||||
|
(b) The contribution is based upon previous work that, to the best
|
||||||
|
of my knowledge, is covered under an appropriate open source
|
||||||
|
license and I have the right under that license to submit that
|
||||||
|
work with modifications, whether created in whole or in part
|
||||||
|
by me, under the same open source license (unless I am
|
||||||
|
permitted to submit under a different license), as indicated
|
||||||
|
in the file; or
|
||||||
|
|
||||||
|
(c) The contribution was provided directly to me by some other
|
||||||
|
person who certified (a), (b) or (c) and I have not modified
|
||||||
|
it.
|
||||||
|
|
||||||
|
(d) I understand and agree that this project and the contribution
|
||||||
|
are public and that a record of the contribution (including all
|
||||||
|
personal information I submit with it, including my sign-off) is
|
||||||
|
maintained indefinitely and may be redistributed consistent with
|
||||||
|
this project or the open source license(s) involved.
|
||||||
@ -22,7 +22,9 @@
|
|||||||
* \brief This script create a xml checksum file
|
* \brief This script create a xml checksum file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
|
if (! defined('NOREQUIREDB')) {
|
||||||
|
define('NOREQUIREDB', '1'); // Do not create database handler $db
|
||||||
|
}
|
||||||
|
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
@ -30,8 +32,8 @@ $path=dirname(__FILE__).'/';
|
|||||||
|
|
||||||
// Test if batch mode
|
// Test if batch mode
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once $path."../htdocs/master.inc.php";
|
require_once $path."../htdocs/master.inc.php";
|
||||||
@ -46,30 +48,33 @@ $includecustom=0;
|
|||||||
$includeconstants=array();
|
$includeconstants=array();
|
||||||
|
|
||||||
if (empty($argv[1])) {
|
if (empty($argv[1])) {
|
||||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||||
print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n";
|
print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n";
|
||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_str($argv[1]);
|
parse_str($argv[1]);
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($i < $argc) {
|
while ($i < $argc) {
|
||||||
if (! empty($argv[$i])) parse_str($argv[$i]);
|
if (! empty($argv[$i])) {
|
||||||
if (preg_match('/includeconstant=/', $argv[$i])) {
|
parse_str($argv[$i]);
|
||||||
$tmp=explode(':', $includeconstant, 3);
|
}
|
||||||
if (count($tmp) != 3) {
|
if (preg_match('/includeconstant=/', $argv[$i])) {
|
||||||
print "Error: Bad parameter includeconstant ".$includeconstant."\n";
|
$tmp=explode(':', $includeconstant, 3); // $includeconstant has been set with previous parse_str()
|
||||||
exit -1;
|
if (count($tmp) != 3) {
|
||||||
}
|
print "Error: Bad parameter includeconstant=".$includeconstant."\n";
|
||||||
$includeconstants[$tmp[0]][$tmp[1]] = $tmp[2];
|
exit -1;
|
||||||
}
|
}
|
||||||
$i++;
|
$includeconstants[$tmp[0]][$tmp[1]] = $tmp[2];
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($release)) {
|
if (empty($release)) {
|
||||||
print "Error: Missing release paramater\n";
|
print "Error: Missing release paramater\n";
|
||||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$savrelease = $release;
|
$savrelease = $release;
|
||||||
@ -77,32 +82,34 @@ $savrelease = $release;
|
|||||||
// If release is auto, we take current version
|
// If release is auto, we take current version
|
||||||
$tmpver=explode('-', $release, 2);
|
$tmpver=explode('-', $release, 2);
|
||||||
if ($tmpver[0] == 'auto' || $tmpver[0] == 'autostable') {
|
if ($tmpver[0] == 'auto' || $tmpver[0] == 'autostable') {
|
||||||
$release=DOL_VERSION;
|
$release=DOL_VERSION;
|
||||||
if ($tmpver[1] && $tmpver[0] == 'auto') $release.='-'.$tmpver[1];
|
if ($tmpver[1] && $tmpver[0] == 'auto') {
|
||||||
|
$release.='-'.$tmpver[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($includecustom)) {
|
if (empty($includecustom)) {
|
||||||
$tmpverbis=explode('-', $release, 2);
|
$tmpverbis=explode('-', $release, 2);
|
||||||
if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable') {
|
if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable') {
|
||||||
if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') {
|
if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') {
|
||||||
print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
||||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$tmpverter=explode('-', DOL_VERSION, 2);
|
$tmpverter=explode('-', DOL_VERSION, 2);
|
||||||
if ($tmpverter[0] != $tmpverbis[0]) {
|
if ($tmpverter[0] != $tmpverbis[0]) {
|
||||||
print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
||||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (! preg_match('/'.preg_quote(DOL_VERSION, '/').'-/', $release)) {
|
if (! preg_match('/'.preg_quote(DOL_VERSION, '/').'-/', $release)) {
|
||||||
print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n";
|
print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n";
|
||||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "Working on files into : ".DOL_DOCUMENT_ROOT."\n";
|
print "Working on files into : ".DOL_DOCUMENT_ROOT."\n";
|
||||||
@ -110,9 +117,9 @@ print "Release : ".$release."\n";
|
|||||||
print "Include custom in signature : ".$includecustom."\n";
|
print "Include custom in signature : ".$includecustom."\n";
|
||||||
print "Include constants in signature : ";
|
print "Include constants in signature : ";
|
||||||
foreach ($includeconstants as $countrycode => $tmp) {
|
foreach ($includeconstants as $countrycode => $tmp) {
|
||||||
foreach ($tmp as $constname => $constvalue) {
|
foreach ($tmp as $constname => $constvalue) {
|
||||||
print $constname.'='.$constvalue." ";
|
print $constname.'='.$constvalue." ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
@ -134,13 +141,13 @@ fputs($fp, '<?xml version="1.0" encoding="UTF-8" ?>'."\n");
|
|||||||
fputs($fp, '<checksum_list version="'.$release.'" date="'.dol_print_date(dol_now(), 'dayhourrfc').'" generator="'.$script_file.'">'."\n");
|
fputs($fp, '<checksum_list version="'.$release.'" date="'.dol_print_date(dol_now(), 'dayhourrfc').'" generator="'.$script_file.'">'."\n");
|
||||||
|
|
||||||
foreach ($includeconstants as $countrycode => $tmp) {
|
foreach ($includeconstants as $countrycode => $tmp) {
|
||||||
fputs($fp, '<dolibarr_constants country="'.$countrycode.'">'."\n");
|
fputs($fp, '<dolibarr_constants country="'.$countrycode.'">'."\n");
|
||||||
foreach ($tmp as $constname => $constvalue) {
|
foreach ($tmp as $constname => $constvalue) {
|
||||||
$valueforchecksum=(empty($constvalue)?'0':$constvalue);
|
$valueforchecksum=(empty($constvalue)?'0':$constvalue);
|
||||||
$checksumconcat[]=$valueforchecksum;
|
$checksumconcat[]=$valueforchecksum;
|
||||||
fputs($fp, ' <constant name="'.$constname.'">'.$valueforchecksum.'</constant>'."\n");
|
fputs($fp, ' <constant name="'.$constname.'">'.$valueforchecksum.'</constant>'."\n");
|
||||||
}
|
}
|
||||||
fputs($fp, '</dolibarr_constants>'."\n");
|
fputs($fp, '</dolibarr_constants>'."\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs($fp, '<dolibarr_htdocs_dir includecustom="'.$includecustom.'">'."\n");
|
fputs($fp, '<dolibarr_htdocs_dir includecustom="'.$includecustom.'">'."\n");
|
||||||
@ -151,28 +158,28 @@ $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');
|
$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)$';
|
$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|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
|
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|dejavu-fonts-ttf-.*|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');
|
$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
|
||||||
|
|
||||||
$dir='';
|
$dir='';
|
||||||
$needtoclose=0;
|
$needtoclose=0;
|
||||||
foreach ($files as $filetmp) {
|
foreach ($files as $filetmp) {
|
||||||
$file = $filetmp['fullname'];
|
$file = $filetmp['fullname'];
|
||||||
//$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
|
//$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
|
||||||
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
||||||
if ($newdir!=$dir) {
|
if ($newdir!=$dir) {
|
||||||
if ($needtoclose) {
|
if ($needtoclose) {
|
||||||
fputs($fp, ' </dir>'."\n");
|
fputs($fp, ' </dir>'."\n");
|
||||||
}
|
}
|
||||||
fputs($fp, ' <dir name="'.$newdir.'">'."\n");
|
fputs($fp, ' <dir name="'.$newdir.'">'."\n");
|
||||||
$dir = $newdir;
|
$dir = $newdir;
|
||||||
$needtoclose=1;
|
$needtoclose=1;
|
||||||
}
|
}
|
||||||
if (filetype($file)=="file") {
|
if (filetype($file)=="file") {
|
||||||
$md5=md5_file($file);
|
$md5=md5_file($file);
|
||||||
$checksumconcat[]=$md5;
|
$checksumconcat[]=$md5;
|
||||||
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fputs($fp, ' </dir>'."\n");
|
fputs($fp, ' </dir>'."\n");
|
||||||
fputs($fp, '</dolibarr_htdocs_dir>'."\n");
|
fputs($fp, '</dolibarr_htdocs_dir>'."\n");
|
||||||
@ -200,22 +207,23 @@ $files = dol_dir_list(dirname(__FILE__).'/../scripts/', 'files', 1, $regextoincl
|
|||||||
$dir='';
|
$dir='';
|
||||||
$needtoclose=0;
|
$needtoclose=0;
|
||||||
foreach ($files as $filetmp) {
|
foreach ($files as $filetmp) {
|
||||||
$file = $filetmp['fullname'];
|
$file = $filetmp['fullname'];
|
||||||
//$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
//$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
||||||
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
||||||
$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
||||||
if ($newdir!=$dir) {
|
if ($newdir!=$dir) {
|
||||||
if ($needtoclose)
|
if ($needtoclose) {
|
||||||
fputs($fp, ' </dir>'."\n");
|
fputs($fp, ' </dir>'."\n");
|
||||||
fputs($fp, ' <dir name="'.$newdir.'" >'."\n");
|
}
|
||||||
$dir = $newdir;
|
fputs($fp, ' <dir name="'.$newdir.'" >'."\n");
|
||||||
$needtoclose=1;
|
$dir = $newdir;
|
||||||
}
|
$needtoclose=1;
|
||||||
if (filetype($file)=="file") {
|
}
|
||||||
$md5=md5_file($file);
|
if (filetype($file)=="file") {
|
||||||
$checksumconcat[]=$md5;
|
$md5=md5_file($file);
|
||||||
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
$checksumconcat[]=$md5;
|
||||||
}
|
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fputs($fp, ' </dir>'."\n");
|
fputs($fp, ' </dir>'."\n");
|
||||||
fputs($fp, '</dolibarr_script_dir>'."\n");
|
fputs($fp, '</dolibarr_script_dir>'."\n");
|
||||||
|
|||||||
@ -390,6 +390,9 @@ if ($nboftargetok) {
|
|||||||
$olddir=getcwd();
|
$olddir=getcwd();
|
||||||
chdir("$SOURCE");
|
chdir("$SOURCE");
|
||||||
|
|
||||||
|
print "Clean $SOURCE/htdocs\n";
|
||||||
|
$ret=`rm -f $SOURCE/htdocs/includes/autoload.php`;
|
||||||
|
|
||||||
$ret=`git ls-files . --exclude-standard --others`;
|
$ret=`git ls-files . --exclude-standard --others`;
|
||||||
if ($ret)
|
if ($ret)
|
||||||
{
|
{
|
||||||
@ -613,7 +616,6 @@ if ($nboftargetok) {
|
|||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/test`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/test`;
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`;
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/parsedown/LICENSE.txt`;
|
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`;
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`;
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/tests`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/tests`;
|
||||||
@ -623,7 +625,6 @@ if ($nboftargetok) {
|
|||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
|
||||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
|
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
|
||||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`;
|
|
||||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
|
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
|
||||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`;
|
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`;
|
||||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/webmozart`;
|
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/webmozart`;
|
||||||
|
|||||||
@ -30,8 +30,8 @@ $script_file = basename(__FILE__);
|
|||||||
|
|
||||||
$path = dirname(__FILE__) . '/';
|
$path = dirname(__FILE__) . '/';
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -62,40 +62,40 @@ $startlinenb = empty($argv[3]) ? 1 : (int) $argv[3];
|
|||||||
$endlinenb = empty($argv[4]) ? 0 : (int) $argv[4];
|
$endlinenb = empty($argv[4]) ? 0 : (int) $argv[4];
|
||||||
|
|
||||||
if (empty($filepath)) {
|
if (empty($filepath)) {
|
||||||
print "Usage: php $script_file myfilepath.dbf [removeChatColumnName] [startlinenb] [endlinenb]\n";
|
print "Usage: php $script_file myfilepath.dbf [removeChatColumnName] [startlinenb] [endlinenb]\n";
|
||||||
print "Example: php $script_file myfilepath.dbf 0 2 1002\n";
|
print "Example: php $script_file myfilepath.dbf 0 2 1002\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (!file_exists($filepath)) {
|
if (!file_exists($filepath)) {
|
||||||
print "Error: File " . $filepath . " not found.\n";
|
print "Error: File " . $filepath . " not found.\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = $user->fetch('', 'admin');
|
$ret = $user->fetch('', 'admin');
|
||||||
if (!$ret > 0) {
|
if (!$ret > 0) {
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
// Ask confirmation
|
// Ask confirmation
|
||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||||
$input = trim(fgets(STDIN));
|
$input = trim(fgets(STDIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open input and output files
|
// Open input and output files
|
||||||
$fhandle = dbase_open($filepath, 0);
|
$fhandle = dbase_open($filepath, 0);
|
||||||
if (!$fhandle) {
|
if (!$fhandle) {
|
||||||
print 'Error: Failed to open file ' . $filepath . "\n";
|
print 'Error: Failed to open file ' . $filepath . "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
$fhandleerr = fopen($filepatherr, 'w');
|
$fhandleerr = fopen($filepatherr, 'w');
|
||||||
if (!$fhandleerr) {
|
if (!$fhandleerr) {
|
||||||
print 'Error: Failed to open file ' . $filepatherr . "\n";
|
print 'Error: Failed to open file ' . $filepatherr . "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$langs->setDefaultLang($defaultlang);
|
$langs->setDefaultLang($defaultlang);
|
||||||
@ -105,23 +105,23 @@ $table_name = substr(basename($filepath), 0, strpos(basename($filepath), '.'));
|
|||||||
print 'Info: ' . $record_numbers . " lines in file \n";
|
print 'Info: ' . $record_numbers . " lines in file \n";
|
||||||
$header = dbase_get_header_info($fhandle);
|
$header = dbase_get_header_info($fhandle);
|
||||||
if ($deleteTable) {
|
if ($deleteTable) {
|
||||||
$db->query("DROP TABLE IF EXISTS `$table_name`");
|
$db->query("DROP TABLE IF EXISTS `$table_name`");
|
||||||
}
|
}
|
||||||
$sqlCreate = "CREATE TABLE IF NOT EXISTS `$table_name` ( `id` INT(11) NOT NULL AUTO_INCREMENT ";
|
$sqlCreate = "CREATE TABLE IF NOT EXISTS `$table_name` ( `id` INT(11) NOT NULL AUTO_INCREMENT ";
|
||||||
$fieldArray = array("`id`");
|
$fieldArray = array("`id`");
|
||||||
foreach ($header as $value) {
|
foreach ($header as $value) {
|
||||||
$fieldName = substr(str_replace('_', '', $value['name']), $startchar);
|
$fieldName = substr(str_replace('_', '', $value['name']), $startchar);
|
||||||
$fieldArray[] = "`$fieldName`";
|
$fieldArray[] = "`$fieldName`";
|
||||||
$sqlCreate .= ", `" . $fieldName . "` VARCHAR({$value['length']}) NULL DEFAULT NULL ";
|
$sqlCreate .= ", `" . $fieldName . "` VARCHAR({$value['length']}) NULL DEFAULT NULL ";
|
||||||
}
|
}
|
||||||
$sqlCreate .= ", PRIMARY KEY (`id`)) ENGINE = InnoDB";
|
$sqlCreate .= ", PRIMARY KEY (`id`)) ENGINE = InnoDB";
|
||||||
$resql = $db->query($sqlCreate);
|
$resql = $db->query($sqlCreate);
|
||||||
if ($resql !== false) {
|
if ($resql !== false) {
|
||||||
print "Table $table_name created\n";
|
print "Table $table_name created\n";
|
||||||
} else {
|
} else {
|
||||||
var_dump($db->errno());
|
var_dump($db->errno());
|
||||||
print "Impossible : " . $sqlCreate . "\n";
|
print "Impossible : " . $sqlCreate . "\n";
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -131,30 +131,33 @@ $fields = implode(',', $fieldArray);
|
|||||||
//var_dump($fieldArray);die();
|
//var_dump($fieldArray);die();
|
||||||
$maxLength = 0;
|
$maxLength = 0;
|
||||||
for ($i = 1; $i <= $record_numbers; $i++) {
|
for ($i = 1; $i <= $record_numbers; $i++) {
|
||||||
if ($startlinenb && $i < $startlinenb)
|
if ($startlinenb && $i < $startlinenb) {
|
||||||
continue;
|
continue;
|
||||||
if ($endlinenb && $i > $endlinenb)
|
}
|
||||||
continue;
|
if ($endlinenb && $i > $endlinenb) {
|
||||||
$row = dbase_get_record_with_names($fhandle, $i);
|
continue;
|
||||||
if ($row === false || (isset($row["deleted"]) && $row["deleted"] == '1'))
|
}
|
||||||
continue;
|
$row = dbase_get_record_with_names($fhandle, $i);
|
||||||
$sqlInsert = "INSERT INTO `$table_name`($fields) VALUES (null,";
|
if ($row === false || (isset($row["deleted"]) && $row["deleted"] == '1')) {
|
||||||
array_shift($row); // remove delete column
|
continue;
|
||||||
foreach ($row as $value) {
|
}
|
||||||
$sqlInsert .= "'" . $db->escape(utf8_encode($value)) . "', ";
|
$sqlInsert = "INSERT INTO `$table_name`($fields) VALUES (null,";
|
||||||
}
|
array_shift($row); // remove delete column
|
||||||
replaceable_echo(implode("\t", $row));
|
foreach ($row as $value) {
|
||||||
$sqlInsert = rtrim($sqlInsert, ', ');
|
$sqlInsert .= "'" . $db->escape(utf8_encode($value)) . "', ";
|
||||||
$sqlInsert .= ")";
|
}
|
||||||
$resql = $db->query($sqlInsert);
|
replaceable_echo(implode("\t", $row));
|
||||||
if ($resql === false) {
|
$sqlInsert = rtrim($sqlInsert, ', ');
|
||||||
print "Impossible : " . $sqlInsert . "\n";
|
$sqlInsert .= ")";
|
||||||
var_dump($row, $db->errno());
|
$resql = $db->query($sqlInsert);
|
||||||
die();
|
if ($resql === false) {
|
||||||
}
|
print "Impossible : " . $sqlInsert . "\n";
|
||||||
|
var_dump($row, $db->errno());
|
||||||
|
die();
|
||||||
|
}
|
||||||
// $fields = (object) $row;
|
// $fields = (object) $row;
|
||||||
// var_dump($fields);
|
// var_dump($fields);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
die();
|
die();
|
||||||
|
|
||||||
@ -166,11 +169,11 @@ die();
|
|||||||
print "Nb of lines qualified: " . $nboflines . "\n";
|
print "Nb of lines qualified: " . $nboflines . "\n";
|
||||||
print "Nb of errors: " . $error . "\n";
|
print "Nb of errors: " . $error . "\n";
|
||||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||||
print "Rollback any changes.\n";
|
print "Rollback any changes.\n";
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
} else {
|
} else {
|
||||||
print "Commit all changes.\n";
|
print "Commit all changes.\n";
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
@ -189,43 +192,43 @@ exit($error);
|
|||||||
*/
|
*/
|
||||||
function replaceable_echo($message, $force_clear_lines = null)
|
function replaceable_echo($message, $force_clear_lines = null)
|
||||||
{
|
{
|
||||||
static $last_lines = 0;
|
static $last_lines = 0;
|
||||||
|
|
||||||
if (!is_null($force_clear_lines)) {
|
if (!is_null($force_clear_lines)) {
|
||||||
$last_lines = $force_clear_lines;
|
$last_lines = $force_clear_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
$toss = array();
|
$toss = array();
|
||||||
$status = 0;
|
$status = 0;
|
||||||
$term_width = exec('tput cols', $toss, $status);
|
$term_width = exec('tput cols', $toss, $status);
|
||||||
if ($status) {
|
if ($status) {
|
||||||
$term_width = 64; // Arbitrary fall-back term width.
|
$term_width = 64; // Arbitrary fall-back term width.
|
||||||
}
|
}
|
||||||
|
|
||||||
$line_count = 0;
|
$line_count = 0;
|
||||||
foreach (explode("\n", $message) as $line) {
|
foreach (explode("\n", $message) as $line) {
|
||||||
$line_count += count(str_split($line, $term_width));
|
$line_count += count(str_split($line, $term_width));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erasure MAGIC: Clear as many lines as the last output had.
|
// Erasure MAGIC: Clear as many lines as the last output had.
|
||||||
for ($i = 0; $i < $last_lines; $i++) {
|
for ($i = 0; $i < $last_lines; $i++) {
|
||||||
// Return to the beginning of the line
|
// Return to the beginning of the line
|
||||||
echo "\r";
|
echo "\r";
|
||||||
// Erase to the end of the line
|
// Erase to the end of the line
|
||||||
echo "\033[K";
|
echo "\033[K";
|
||||||
// Move cursor Up a line
|
// Move cursor Up a line
|
||||||
echo "\033[1A";
|
echo "\033[1A";
|
||||||
// Return to the beginning of the line
|
// Return to the beginning of the line
|
||||||
echo "\r";
|
echo "\r";
|
||||||
// Erase to the end of the line
|
// Erase to the end of the line
|
||||||
echo "\033[K";
|
echo "\033[K";
|
||||||
// Return to the beginning of the line
|
// Return to the beginning of the line
|
||||||
echo "\r";
|
echo "\r";
|
||||||
// Can be consolodated into
|
// Can be consolodated into
|
||||||
// echo "\r\033[K\033[1A\r\033[K\r";
|
// echo "\r\033[K\033[1A\r\033[K\r";
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_lines = $line_count;
|
$last_lines = $line_count;
|
||||||
|
|
||||||
echo $message . "\n";
|
echo $message . "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,8 @@ $sapi_type = php_sapi_name();
|
|||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
$path = dirname(__FILE__) . '/';
|
$path = dirname(__FILE__) . '/';
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -50,18 +50,18 @@ $confirmed = 1;
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$tvas = [
|
$tvas = [
|
||||||
'1' => "20.00",
|
'1' => "20.00",
|
||||||
'2' => "5.50",
|
'2' => "5.50",
|
||||||
'3' => "0.00",
|
'3' => "0.00",
|
||||||
'4' => "20.60",
|
'4' => "20.60",
|
||||||
'5' => "19.60",
|
'5' => "19.60",
|
||||||
];
|
];
|
||||||
$tvasD = [
|
$tvasD = [
|
||||||
'1' => "20",
|
'1' => "20",
|
||||||
'2' => "5.5",
|
'2' => "5.5",
|
||||||
'3' => "0",
|
'3' => "0",
|
||||||
'4' => "20",
|
'4' => "20",
|
||||||
'5' => "20",
|
'5' => "20",
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -75,159 +75,167 @@ dol_syslog($script_file . " launched with arg " . implode(',', $argv));
|
|||||||
$table = $argv[1];
|
$table = $argv[1];
|
||||||
|
|
||||||
if (empty($argv[1])) {
|
if (empty($argv[1])) {
|
||||||
print "Error: Which table ?\n";
|
print "Error: Which table ?\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = $user->fetch('', 'admin');
|
$ret = $user->fetch('', 'admin');
|
||||||
if (!$ret > 0) {
|
if (!$ret > 0) {
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM `$table` WHERE 1";
|
$sql = "SELECT * FROM `$table` WHERE 1";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
while ($fields = $db->fetch_array($resql)) {
|
while ($fields = $db->fetch_array($resql)) {
|
||||||
$errorrecord = 0;
|
$errorrecord = 0;
|
||||||
if ($fields === false)
|
if ($fields === false) {
|
||||||
continue;
|
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) {
|
$nboflines++;
|
||||||
print " - Error in updatePrice result " . $produit->errorsToString();
|
|
||||||
|
$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++;
|
$errorrecord++;
|
||||||
} else {
|
} else {
|
||||||
print " - updatePrice OK";
|
print " - Creation OK with ref " . $produit->ref . " - id = " . $ret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
dol_syslog("Add prices");
|
||||||
|
|
||||||
// dol_syslog("Add multilangs");
|
// If we use price level, insert price for each level
|
||||||
// Add alternative languages
|
if (!$errorrecord && 1) {
|
||||||
// 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());
|
||||||
// $produit->multilangs['fr_FR'] = array('label' => $produit->label, 'description' => $produit->description, 'note' => $produit->note_private);
|
$ret1 = false;
|
||||||
// $produit->multilangs['en_US'] = array('label' => $fields[3], 'description' => $produit->description, 'note' => $produit->note_private);
|
for ($i = 0; $i < 10; $i++) {
|
||||||
//
|
if ($fields['TARIF' . ($i)] == 0) {
|
||||||
// $ret = $produit->setMultiLangs($user);
|
continue;
|
||||||
// if ($ret < 0) {
|
}
|
||||||
// print " - Error in setMultiLangs result code = " . $ret . " - " . $produit->errorsToString();
|
$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;
|
||||||
// $errorrecord++;
|
}
|
||||||
// } else {
|
if ($ret1) {
|
||||||
// print " - setMultiLangs OK";
|
print " - Error in updatePrice result " . $produit->errorsToString();
|
||||||
// }
|
$errorrecord++;
|
||||||
// }
|
} else {
|
||||||
|
print " - updatePrice 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) {
|
// dol_syslog("Add multilangs");
|
||||||
$date = substr($fields['DATCREA'], 0, 4) . '-' . substr($fields['DATCREA'], 4, 2) . '-' . substr($fields['DATCREA'], 6, 2);
|
// Add alternative languages
|
||||||
$retd = $db->query("UPDATE `llx_product` SET `datec` = '$date 00:00:00' WHERE `llx_product`.`rowid` = $produit->id");
|
// if (!$errorrecord && 1) {
|
||||||
if ($retd < 1) {
|
// $produit->multilangs['fr_FR'] = array('label' => $produit->label, 'description' => $produit->description, 'note' => $produit->note_private);
|
||||||
print " - Error in update date créa result " . $produit->errorsToString();
|
// $produit->multilangs['en_US'] = array('label' => $fields[3], 'description' => $produit->description, 'note' => $produit->note_private);
|
||||||
$errorrecord++;
|
//
|
||||||
} else {
|
// $ret = $produit->setMultiLangs($user);
|
||||||
print " - update date créa OK";
|
// 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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
print "\n";
|
|
||||||
|
|
||||||
if ($errorrecord) {
|
//update date créa
|
||||||
print( 'Error on record nb ' . $i . " - " . $produit->errorsToString() . "\n");
|
if (!$errorrecord) {
|
||||||
var_dump($db);
|
$date = substr($fields['DATCREA'], 0, 4) . '-' . substr($fields['DATCREA'], 4, 2) . '-' . substr($fields['DATCREA'], 6, 2);
|
||||||
die();
|
$retd = $db->query("UPDATE `llx_product` SET `datec` = '$date 00:00:00' WHERE `llx_product`.`rowid` = $produit->id");
|
||||||
$error++; // $errorrecord will be reset
|
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++;
|
||||||
}
|
}
|
||||||
$j++;
|
} else {
|
||||||
} else die("error : $sql");
|
die("error : $sql");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -29,8 +29,8 @@ $sapi_type = php_sapi_name();
|
|||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
$path = dirname(__FILE__) . '/';
|
$path = dirname(__FILE__) . '/';
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -50,73 +50,73 @@ $confirmed = 1;
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$civilPrivate = array("MLLE",
|
$civilPrivate = array("MLLE",
|
||||||
"MM",
|
"MM",
|
||||||
"MM/MADAME",
|
"MM/MADAME",
|
||||||
"MME",
|
"MME",
|
||||||
"MME.",
|
"MME.",
|
||||||
"MME²",
|
"MME²",
|
||||||
"MMONSIEUR",
|
"MMONSIEUR",
|
||||||
"MMR",
|
"MMR",
|
||||||
"MOBNSIEUR",
|
"MOBNSIEUR",
|
||||||
"MOMSIEUR",
|
"MOMSIEUR",
|
||||||
"MON SIEUR",
|
"MON SIEUR",
|
||||||
"MONDIAL",
|
"MONDIAL",
|
||||||
"MONIEUR",
|
"MONIEUR",
|
||||||
"MONJSIEUR",
|
"MONJSIEUR",
|
||||||
"MONNSIEUR",
|
"MONNSIEUR",
|
||||||
"MONRIEUR",
|
"MONRIEUR",
|
||||||
"MONS",
|
"MONS",
|
||||||
"MONSIEÕR",
|
"MONSIEÕR",
|
||||||
"MONSIER",
|
"MONSIER",
|
||||||
"MONSIERU",
|
"MONSIERU",
|
||||||
"MONSIEU",
|
"MONSIEU",
|
||||||
"monsieue",
|
"monsieue",
|
||||||
"MONSIEUR",
|
"MONSIEUR",
|
||||||
"Monsieur \"",
|
"Monsieur \"",
|
||||||
"MONSIEUR \"",
|
"MONSIEUR \"",
|
||||||
"MONSIEUR E",
|
"MONSIEUR E",
|
||||||
"MONSIEUR DENIS",
|
"MONSIEUR DENIS",
|
||||||
"MONSIEUR ET MME",
|
"MONSIEUR ET MME",
|
||||||
"MONSIEUR!",
|
"MONSIEUR!",
|
||||||
"MONSIEUR.",
|
"MONSIEUR.",
|
||||||
"MONSIEUR.MADAME",
|
"MONSIEUR.MADAME",
|
||||||
"MONSIEUR3",
|
"MONSIEUR3",
|
||||||
"MONSIEURN",
|
"MONSIEURN",
|
||||||
"MONSIEURT",
|
"MONSIEURT",
|
||||||
"MONSIEUR£",
|
"MONSIEUR£",
|
||||||
"MONSIEYR",
|
"MONSIEYR",
|
||||||
"Monsigur",
|
"Monsigur",
|
||||||
"MONSIIEUR",
|
"MONSIIEUR",
|
||||||
"MONSIUER",
|
"MONSIUER",
|
||||||
"MONSIZEUR",
|
"MONSIZEUR",
|
||||||
"MOPNSIEUR",
|
"MOPNSIEUR",
|
||||||
"MOSIEUR",
|
"MOSIEUR",
|
||||||
"MR",
|
"MR",
|
||||||
"Mr Mme",
|
"Mr Mme",
|
||||||
"Mr - MME",
|
"Mr - MME",
|
||||||
"MR BLANC",
|
"MR BLANC",
|
||||||
"MR ET MME",
|
"MR ET MME",
|
||||||
"mr mm",
|
"mr mm",
|
||||||
"MR OU MME",
|
"MR OU MME",
|
||||||
"Mr.",
|
"Mr.",
|
||||||
"MR/MME",
|
"MR/MME",
|
||||||
"MRME",
|
"MRME",
|
||||||
"MRR",
|
"MRR",
|
||||||
"Mrs",
|
"Mrs",
|
||||||
"Mademoiselle",
|
"Mademoiselle",
|
||||||
"MADAOME",
|
"MADAOME",
|
||||||
"madamme",
|
"madamme",
|
||||||
"MADAME",
|
"MADAME",
|
||||||
"M0NSIEUR",
|
"M0NSIEUR",
|
||||||
"M.et Madame",
|
"M.et Madame",
|
||||||
"M. ET MR",
|
"M. ET MR",
|
||||||
"M.",
|
"M.",
|
||||||
"M%",
|
"M%",
|
||||||
"M MME",
|
"M MME",
|
||||||
"M ET MME",
|
"M ET MME",
|
||||||
"M",
|
"M",
|
||||||
"M CROCE",
|
"M CROCE",
|
||||||
"M DIEVART",
|
"M DIEVART",
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -130,128 +130,134 @@ dol_syslog($script_file . " launched with arg " . implode(',', $argv));
|
|||||||
$table = $argv[1];
|
$table = $argv[1];
|
||||||
|
|
||||||
if (empty($argv[1])) {
|
if (empty($argv[1])) {
|
||||||
print "Error: Quelle table ?\n";
|
print "Error: Quelle table ?\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = $user->fetch('', 'admin');
|
$ret = $user->fetch('', 'admin');
|
||||||
if (!$ret > 0) {
|
if (!$ret > 0) {
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM `$table` WHERE 1 "; //ORDER BY REMISE DESC,`LCIVIL` DESC";
|
$sql = "SELECT * FROM `$table` WHERE 1 "; //ORDER BY REMISE DESC,`LCIVIL` DESC";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
//$db->begin();
|
//$db->begin();
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
while ($fields = $db->fetch_array($resql)) {
|
while ($fields = $db->fetch_array($resql)) {
|
||||||
$i++;
|
$i++;
|
||||||
$errorrecord = 0;
|
$errorrecord = 0;
|
||||||
|
|
||||||
if ($startlinenb && $i < $startlinenb)
|
if ($startlinenb && $i < $startlinenb) {
|
||||||
continue;
|
continue;
|
||||||
if ($endlinenb && $i > $endlinenb)
|
}
|
||||||
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) {
|
$nboflines++;
|
||||||
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");
|
$object = new Societe($db);
|
||||||
// Insert an invoice contact if there is an invoice email != standard email
|
$object->import_key = $fields['CODE'];
|
||||||
if (!$errorrecord && ($fields['LCIVIL'] || $fields['LNOM'])) {
|
$object->state = 1;
|
||||||
$madame = array("MADAME",
|
$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",
|
"MADEMOISELLE",
|
||||||
"MELLE",
|
"MELLE",
|
||||||
"MLLE",
|
"MLLE",
|
||||||
"MM",
|
"MM",
|
||||||
"Mme",
|
"Mme",
|
||||||
"MNE",
|
"MNE",
|
||||||
);
|
);
|
||||||
$monsieur = array("M",
|
$monsieur = array("M",
|
||||||
"M ET MME",
|
"M ET MME",
|
||||||
"M MME",
|
"M MME",
|
||||||
"M.",
|
"M.",
|
||||||
@ -268,77 +274,84 @@ while ($fields = $db->fetch_array($resql)) {
|
|||||||
"MONSIUER",
|
"MONSIUER",
|
||||||
"MONSKIEUR",
|
"MONSKIEUR",
|
||||||
"MR",
|
"MR",
|
||||||
);
|
);
|
||||||
$ret1 = $ret2 = 0;
|
$ret1 = $ret2 = 0;
|
||||||
|
|
||||||
$contact = new Contact($db);
|
$contact = new Contact($db);
|
||||||
if (in_array($fields['LCIVIL'], $madame)) {
|
if (in_array($fields['LCIVIL'], $madame)) {
|
||||||
// une dame
|
// une dame
|
||||||
$contact->civility_id = 'MME';
|
$contact->civility_id = 'MME';
|
||||||
$contact->lastname = $fields['LNOM'];
|
$contact->lastname = $fields['LNOM'];
|
||||||
} elseif (in_array($fields['LCIVIL'], $monsieur)) {
|
} elseif (in_array($fields['LCIVIL'], $monsieur)) {
|
||||||
// un monsieur
|
// un monsieur
|
||||||
$contact->civility_id = 'MR';
|
$contact->civility_id = 'MR';
|
||||||
$contact->lastname = $fields['LNOM'];
|
$contact->lastname = $fields['LNOM'];
|
||||||
} elseif (in_array($fields['LCIVIL'], ['DOCTEUR'])) {
|
} elseif (in_array($fields['LCIVIL'], ['DOCTEUR'])) {
|
||||||
// un monsieur
|
// un monsieur
|
||||||
$contact->civility_id = 'DR';
|
$contact->civility_id = 'DR';
|
||||||
$contact->lastname = $fields['LNOM'];
|
$contact->lastname = $fields['LNOM'];
|
||||||
} else {
|
} else {
|
||||||
// un a rattraper
|
// un a rattraper
|
||||||
$contact->lastname = $fields['LCIVIL'] . " " . $fields['LNOM'];
|
$contact->lastname = $fields['LCIVIL'] . " " . $fields['LNOM'];
|
||||||
}
|
}
|
||||||
$contact->address = trim($fields['LADR1']);
|
$contact->address = trim($fields['LADR1']);
|
||||||
if ($fields['LADR2'])
|
if ($fields['LADR2']) {
|
||||||
$contact->address .= "\n" . trim($fields['LADR2']);
|
$contact->address .= "\n" . trim($fields['LADR2']);
|
||||||
if ($fields['LADR3'])
|
}
|
||||||
$contact->address .= "\n" . trim($fields['LADR3']);
|
if ($fields['LADR3']) {
|
||||||
|
$contact->address .= "\n" . trim($fields['LADR3']);
|
||||||
|
}
|
||||||
|
|
||||||
$contact->zip = trim($fields['LPOSTE']);
|
$contact->zip = trim($fields['LPOSTE']);
|
||||||
$contact->town = trim($fields['LVILLE']);
|
$contact->town = trim($fields['LVILLE']);
|
||||||
if ($fields['FPAYS'])
|
if ($fields['FPAYS']) {
|
||||||
$contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid');
|
$contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid');
|
||||||
else $contact->country_id = 1;
|
} else {
|
||||||
$contact->email = $fields['LMAIL'];
|
$contact->country_id = 1;
|
||||||
$contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']);
|
}
|
||||||
$contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']);
|
$contact->email = $fields['LMAIL'];
|
||||||
$contact->socid = $object->id;
|
$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);
|
$ret1 = $contact->create($user);
|
||||||
if ($ret1 > 0) {
|
if ($ret1 > 0) {
|
||||||
//$ret2=$contact->add_contact($object->id, 'BILLING');
|
//$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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($ret1 < 0 || $ret2 < 0) {
|
|
||||||
print " - Error in create contact result code = " . $ret1 . " " . $ret2 . " - " . $contact->errorsToString();
|
|
||||||
$errorrecord++;
|
//update date créa
|
||||||
} else {
|
if (!$errorrecord) {
|
||||||
print " - create contact OK";
|
$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");
|
||||||
//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();
|
$db->commit();
|
||||||
|
|
||||||
|
|||||||
@ -18,382 +18,582 @@ define('DBASE_TYPE_FOXPRO', 1);
|
|||||||
*/
|
*/
|
||||||
class DBase
|
class DBase
|
||||||
{
|
{
|
||||||
private $fd;
|
private $fd;
|
||||||
private $headerLength = 0;
|
private $headerLength = 0;
|
||||||
private $fields = array();
|
private $fields = array();
|
||||||
private $fieldCount = 0;
|
private $fieldCount = 0;
|
||||||
private $recordLength = 0;
|
private $recordLength = 0;
|
||||||
private $recordCount = 0;
|
private $recordCount = 0;
|
||||||
|
|
||||||
//resource dbase_open ( string $filename , int $mode )
|
/**
|
||||||
public static function open($filename, $mode)
|
* resource dbase_open
|
||||||
|
* @param string $filename filename
|
||||||
|
* @param int $mode mode
|
||||||
|
* @return DBase
|
||||||
|
*/
|
||||||
|
public static function open($filename, $mode)
|
||||||
{
|
{
|
||||||
if (!file_exists($filename))
|
if (!file_exists($filename)) {
|
||||||
return false;
|
return false;
|
||||||
$modes = array('r', 'w', 'r+');
|
}
|
||||||
$mode = $modes[$mode];
|
$modes = array('r', 'w', 'r+');
|
||||||
$fd = fopen($filename, $mode);
|
$mode = $modes[$mode];
|
||||||
if (!$fd)
|
$fd = fopen($filename, $mode);
|
||||||
return false;
|
if (!$fd) {
|
||||||
return new DBase($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)
|
* resource dbase_create
|
||||||
|
* @param string $filename filename
|
||||||
|
* @param array $fields fields
|
||||||
|
* @param int $type DBASE_TYPE_DBASE
|
||||||
|
* @return DBase
|
||||||
|
*/
|
||||||
|
public static function create($filename, $fields, $type = DBASE_TYPE_DBASE)
|
||||||
{
|
{
|
||||||
if (file_exists($filename))
|
if (file_exists($filename)) {
|
||||||
return false;
|
return false;
|
||||||
$fd = fopen($filename, 'c+');
|
}
|
||||||
if (!$fd)
|
$fd = fopen($filename, 'c+');
|
||||||
return false;
|
if (!$fd) {
|
||||||
// Byte 0 (1 byte): Valid dBASE for DOS file; bits 0-2 indicate version number, bit 3
|
return false;
|
||||||
// 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
|
// Byte 0 (1 byte): Valid dBASE for DOS file; bits 0-2 indicate version number, bit 3
|
||||||
// (either dBASE m PLUS or dBASE for DOS)
|
// indicates the presence of a dBASE for DOS memo file, bits 4-6 indicate the
|
||||||
self::putChar8($fd, 5);
|
// presence of a SQL table, bit 7 indicates the presence of any memo file
|
||||||
// Byte 1-3 (3 bytes): Date of last update; formatted as YYMMDD
|
// (either dBASE m PLUS or dBASE for DOS)
|
||||||
self::putChar8($fd, date('Y') - 1900);
|
self::putChar8($fd, 5);
|
||||||
self::putChar8($fd, date('m'));
|
// Byte 1-3 (3 bytes): Date of last update; formatted as YYMMDD
|
||||||
self::putChar8($fd, date('d'));
|
self::putChar8($fd, date('Y') - 1900);
|
||||||
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
self::putChar8($fd, date('m'));
|
||||||
self::putInt32($fd, 0);
|
self::putChar8($fd, date('d'));
|
||||||
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
||||||
self::putInt16($fd, 32 + (32 * count($fields)) + 1);
|
self::putInt32($fd, 0);
|
||||||
// Byte 10-11 (16-bit number): Number of bytes in record.
|
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
||||||
// Make sure the include the byte for deleted flag
|
self::putInt16($fd, 32 + (32 * count($fields)) + 1);
|
||||||
$len = 1;
|
// Byte 10-11 (16-bit number): Number of bytes in record.
|
||||||
foreach ($fields as &$field)
|
// Make sure the include the byte for deleted flag
|
||||||
$len += self::length($field);
|
$len = 1;
|
||||||
self::putInt16($fd, $len);
|
foreach ($fields as &$field) {
|
||||||
// Byte 12-13 (2 bytes): Reserved, 0 filled.
|
$len += self::length($field);
|
||||||
self::putInt16($fd, 0);
|
}
|
||||||
// Byte 14 (1 byte): Flag indicating incomplete transaction
|
self::putInt16($fd, $len);
|
||||||
// The ISMARKEDO function checks this flag. BEGIN TRANSACTION sets it to 1, END TRANSACTION and ROLLBACK reset it to 0.
|
// Byte 12-13 (2 bytes): Reserved, 0 filled.
|
||||||
self::putChar8($fd, 0);
|
self::putInt16($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.
|
// Byte 14 (1 byte): Flag indicating incomplete transaction
|
||||||
self::putChar8($fd, 0);
|
// The ISMARKEDO function checks this flag. BEGIN TRANSACTION sets it to 1, END TRANSACTION and ROLLBACK reset it to 0.
|
||||||
// Byte 16-27 (12 bytes): Reserved for dBASE for DOS in a multi-user environment
|
self::putChar8($fd, 0);
|
||||||
self::putInt32($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::putInt32($fd, 0);
|
self::putChar8($fd, 0);
|
||||||
self::putInt32($fd, 0);
|
// Byte 16-27 (12 bytes): Reserved for dBASE for DOS in a multi-user environment
|
||||||
// Byte 28 (1 byte): Production .mdx file flag; 0x01 if there is a production .mdx file, 0x00 if not
|
self::putInt32($fd, 0);
|
||||||
self::putChar8($fd, 0);
|
self::putInt32($fd, 0);
|
||||||
// Byte 29 (1 byte): Language driver ID
|
self::putInt32($fd, 0);
|
||||||
// (no clue what this is)
|
// Byte 28 (1 byte): Production .mdx file flag; 0x01 if there is a production .mdx file, 0x00 if not
|
||||||
self::putChar8($fd, 0);
|
self::putChar8($fd, 0);
|
||||||
// Byte 30-31 (2 bytes): Reserved, 0 filled.
|
// Byte 29 (1 byte): Language driver ID
|
||||||
self::putInt16($fd, 0);
|
// (no clue what this is)
|
||||||
// Byte 32 - n (32 bytes each): Field descriptor array
|
self::putChar8($fd, 0);
|
||||||
foreach ($fields as &$field) {
|
// Byte 30-31 (2 bytes): Reserved, 0 filled.
|
||||||
self::putString($fd, $field[0], 11); // Byte 0 - 10 (11 bytes): Field name in ASCII (zero-filled)
|
self::putInt16($fd, 0);
|
||||||
self::putString($fd, $field[1], 1); // Byte 11 (1 byte): Field type in ASCII (C, D, F, L, M, or N)
|
// Byte 32 - n (32 bytes each): Field descriptor array
|
||||||
self::putInt32($fd, 0); // Byte 12 - 15 (4 bytes): Reserved
|
foreach ($fields as &$field) {
|
||||||
self::putChar8($fd, self::length($field)); // Byte 16 (1 byte): Field length in binary. The maximum length of a field is 254 (0xFE).
|
self::putString($fd, $field[0], 11); // Byte 0 - 10 (11 bytes): Field name in ASCII (zero-filled)
|
||||||
self::putChar8($fd, $field[3]); // Byte 17 (1 byte): Field decimal count in binary
|
self::putString($fd, $field[1], 1); // Byte 11 (1 byte): Field type in ASCII (C, D, F, L, M, or N)
|
||||||
self::putInt16($fd, 0); // Byte 18 - 19 (2 bytes): Work area ID
|
self::putInt32($fd, 0); // Byte 12 - 15 (4 bytes): Reserved
|
||||||
self::putChar8($fd, 0); // Byte 20 (1 byte): Example (??)
|
self::putChar8($fd, self::length($field)); // Byte 16 (1 byte): Field length in binary. The maximum length of a field is 254 (0xFE).
|
||||||
self::putInt32($fd, 0); // Byte 21 - 30 (10 bytes): Reserved
|
self::putChar8($fd, $field[3]); // Byte 17 (1 byte): Field decimal count in binary
|
||||||
self::putInt32($fd, 0);
|
self::putInt16($fd, 0); // Byte 18 - 19 (2 bytes): Work area ID
|
||||||
self::putInt16($fd, 0);
|
self::putChar8($fd, 0); // Byte 20 (1 byte): Example (??)
|
||||||
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
|
self::putInt32($fd, 0); // Byte 21 - 30 (10 bytes): Reserved
|
||||||
}
|
self::putInt32($fd, 0);
|
||||||
// Byte n + 1 (1 byte): 0x0D as the field descriptor array terminator
|
self::putInt16($fd, 0);
|
||||||
self::putChar8($fd, 0x0D);
|
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
|
||||||
return new DBase($fd);
|
}
|
||||||
}
|
// 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)
|
* Create DBase instance
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function __construct($fd)
|
||||||
{
|
{
|
||||||
$this->fd = $fd;
|
$this->fd = $fd;
|
||||||
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
||||||
fseek($this->fd, 4, SEEK_SET);
|
fseek($this->fd, 4, SEEK_SET);
|
||||||
$this->recordCount = self::getInt32($fd);
|
$this->recordCount = self::getInt32($fd);
|
||||||
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
||||||
fseek($this->fd, 8, SEEK_SET);
|
fseek($this->fd, 8, SEEK_SET);
|
||||||
$this->headerLength = self::getInt16($fd);
|
$this->headerLength = self::getInt16($fd);
|
||||||
// Number of fields is (headerLength - 33) / 32)
|
// Number of fields is (headerLength - 33) / 32)
|
||||||
$this->fieldCount = ($this->headerLength - 33) / 32;
|
$this->fieldCount = ($this->headerLength - 33) / 32;
|
||||||
// Byte 10-11 (16-bit number): Number of bytes in record.
|
// Byte 10-11 (16-bit number): Number of bytes in record.
|
||||||
fseek($this->fd, 10, SEEK_SET);
|
fseek($this->fd, 10, SEEK_SET);
|
||||||
$this->recordLength = self::getInt16($fd);
|
$this->recordLength = self::getInt16($fd);
|
||||||
// Byte 32 - n (32 bytes each): Field descriptor array
|
// Byte 32 - n (32 bytes each): Field descriptor array
|
||||||
fseek($fd, 32, SEEK_SET);
|
fseek($fd, 32, SEEK_SET);
|
||||||
for ($i = 0; $i < $this->fieldCount; $i++) {
|
for ($i = 0; $i < $this->fieldCount; $i++) {
|
||||||
$data = fread($this->fd, 32);
|
$data = fread($this->fd, 32);
|
||||||
$field = array_map('trim', unpack('a11name/a1type/c4/c1length/c1precision/s1workid/c1example/c10/c1production', $data));
|
$field = array_map('trim', unpack('a11name/a1type/c4/c1length/c1precision/s1workid/c1example/c10/c1production', $data));
|
||||||
$this->fields[] = $field;
|
$this->fields[] = $field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool dbase_close ( resource $dbase_identifier )
|
/**
|
||||||
public function close()
|
* dbase_close
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function close()
|
||||||
{
|
{
|
||||||
fclose($this->fd);
|
fclose($this->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
//array dbase_get_header_info ( resource $dbase_identifier )
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
public function get_header_info()
|
/**
|
||||||
|
* dbase_get_header_info
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_header_info()
|
||||||
{
|
{
|
||||||
return $this->fields;
|
// phpcs:disable
|
||||||
}
|
return $this->fields;
|
||||||
|
}
|
||||||
|
|
||||||
//int dbase_numfields ( resource $dbase_identifier )
|
/**
|
||||||
public function numfields()
|
* dbase_numfields
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function numfields()
|
||||||
{
|
{
|
||||||
return $this->fieldCount;
|
return $this->fieldCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//int dbase_numrecords ( resource $dbase_identifier )
|
/**
|
||||||
public function numrecords()
|
* dbase_numrecords
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function numrecords()
|
||||||
{
|
{
|
||||||
return $this->recordCount;
|
return $this->recordCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool dbase_add_record ( resource $dbase_identifier , array $record )
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
public function add_record($record)
|
/**
|
||||||
|
* dbase_add_record
|
||||||
|
* @param array $record record
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function add_record($record)
|
||||||
{
|
{
|
||||||
if (count($record) != $this->fieldCount)
|
// phpcs:enable
|
||||||
return false;
|
if (count($record) != $this->fieldCount) {
|
||||||
// Seek to end of file, minus the end of file marker
|
return false;
|
||||||
fseek($this->fd, 0, SEEK_END);
|
}
|
||||||
// Put the deleted flag
|
// Seek to end of file, minus the end of file marker
|
||||||
self::putChar8($this->fd, 0x20);
|
fseek($this->fd, 0, SEEK_END);
|
||||||
// Put the record
|
// Put the deleted flag
|
||||||
if (!$this->putRecord($record))
|
self::putChar8($this->fd, 0x20);
|
||||||
return false;
|
// Put the record
|
||||||
// Update the record count
|
if (!$this->putRecord($record)) {
|
||||||
fseek($this->fd, 4);
|
return false;
|
||||||
self::putInt32($this->fd, ++$this->recordCount);
|
}
|
||||||
return true;
|
// 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 )
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
public function replace_record($record, $record_number)
|
/**
|
||||||
|
* dbase_replace_record
|
||||||
|
* @param array $record record
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function replace_record($record, $record_number)
|
||||||
{
|
{
|
||||||
if (count($record) != $this->fieldCount)
|
// phpcs:enable
|
||||||
return false;
|
if (count($record) != $this->fieldCount) {
|
||||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
return false;
|
||||||
return false;
|
}
|
||||||
// Skip to the record location, plus the 1 byte for the deleted flag
|
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)) + 1);
|
return false;
|
||||||
return $this->putRecord($record);
|
}
|
||||||
}
|
// 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 )
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
public function delete_record($record_number)
|
/**
|
||||||
|
* dbase_delete_record
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function delete_record($record_number)
|
||||||
{
|
{
|
||||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
// phpcs:enable
|
||||||
return false;
|
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
|
return false;
|
||||||
self::putChar8($this->fd, 0x2A);
|
}
|
||||||
return true;
|
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 )
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
public function get_record($record_number)
|
/**
|
||||||
|
* dbase_get_record
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_record($record_number)
|
||||||
{
|
{
|
||||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
// phpcs:enable
|
||||||
return false;
|
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
|
return false;
|
||||||
$record = array(
|
}
|
||||||
'deleted' => self::getChar8($this->fd) == 0x2A ? 1 : 0
|
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
|
||||||
);
|
$record = array(
|
||||||
foreach ($this->fields as $i => &$field) {
|
'deleted' => self::getChar8($this->fd) == 0x2A ? 1 : 0
|
||||||
$value = trim(fread($this->fd, $field['length']));
|
);
|
||||||
if ($field['type'] == 'L') {
|
foreach ($this->fields as $i => &$field) {
|
||||||
$value = strtolower($value);
|
$value = trim(fread($this->fd, $field['length']));
|
||||||
if ($value == 't' || $value == 'y')
|
if ($field['type'] == 'L') {
|
||||||
$value = true;
|
$value = strtolower($value);
|
||||||
elseif ($value == 'f' || $value == 'n')
|
if ($value == 't' || $value == 'y') {
|
||||||
$value = false;
|
$value = true;
|
||||||
else $value = null;
|
} elseif ($value == 'f' || $value == 'n') {
|
||||||
}
|
$value = false;
|
||||||
$record[$i] = $value;
|
} else {
|
||||||
}
|
$value = null;
|
||||||
return $record;
|
}
|
||||||
}
|
}
|
||||||
|
$record[$i] = $value;
|
||||||
|
}
|
||||||
|
return $record;
|
||||||
|
}
|
||||||
|
|
||||||
//array dbase_get_record_with_names ( resource $dbase_identifier , int $record_number )
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
public function get_record_with_names($record_number)
|
/**
|
||||||
|
* dbase_get_record_with_names
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_record_with_names($record_number)
|
||||||
{
|
{
|
||||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
// phpcs:enable
|
||||||
return false;
|
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||||
$record = $this->get_record($record_number);
|
return false;
|
||||||
foreach ($this->fields as $i => &$field) {
|
}
|
||||||
$record[$field['name']] = $record[$i];
|
$record = $this->get_record($record_number);
|
||||||
unset($record[$i]);
|
foreach ($this->fields as $i => &$field) {
|
||||||
}
|
$record[$field['name']] = $record[$i];
|
||||||
return $record;
|
unset($record[$i]);
|
||||||
}
|
}
|
||||||
|
return $record;
|
||||||
|
}
|
||||||
|
|
||||||
//bool dbase_pack ( resource $dbase_identifier )
|
/**
|
||||||
public function pack()
|
* dbase_pack
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function pack()
|
||||||
{
|
{
|
||||||
$in_offset = $out_offset = $this->headerLength;
|
$in_offset = $out_offset = $this->headerLength;
|
||||||
$new_count = 0;
|
$new_count = 0;
|
||||||
$rec_count = $this->recordCount;
|
$rec_count = $this->recordCount;
|
||||||
while ($rec_count > 0) {
|
while ($rec_count > 0) {
|
||||||
fseek($this->fd, $in_offset, SEEK_SET);
|
fseek($this->fd, $in_offset, SEEK_SET);
|
||||||
$record = fread($this->fd, $this->recordLength);
|
$record = fread($this->fd, $this->recordLength);
|
||||||
$deleted = substr($record, 0, 1);
|
$deleted = substr($record, 0, 1);
|
||||||
if ($deleted != '*') {
|
if ($deleted != '*') {
|
||||||
fseek($this->fd, $out_offset, SEEK_SET);
|
fseek($this->fd, $out_offset, SEEK_SET);
|
||||||
fwrite($this->fd, $record);
|
fwrite($this->fd, $record);
|
||||||
$out_offset += $this->recordLength;
|
$out_offset += $this->recordLength;
|
||||||
$new_count++;
|
$new_count++;
|
||||||
}
|
}
|
||||||
$in_offset += $this->recordLength;
|
$in_offset += $this->recordLength;
|
||||||
$rec_count--;
|
$rec_count--;
|
||||||
}
|
}
|
||||||
ftruncate($this->fd, $out_offset);
|
ftruncate($this->fd, $out_offset);
|
||||||
// Update the record count
|
// Update the record count
|
||||||
fseek($this->fd, 4);
|
fseek($this->fd, 4);
|
||||||
self::putInt32($this->fd, $new_count);
|
self::putInt32($this->fd, $new_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A few utilitiy functions
|
* A few utilitiy functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static function length($field)
|
/**
|
||||||
|
* @param string $field field
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function length($field)
|
||||||
{
|
{
|
||||||
switch ($field[1]) {
|
switch ($field[1]) {
|
||||||
case 'D': // Date: Numbers and a character to separate month, day, and year (stored internally as 8 digits in YYYYMMDD format)
|
case 'D': // Date: Numbers and a character to separate month, day, and year (stored internally as 8 digits in YYYYMMDD format)
|
||||||
return 8;
|
return 8;
|
||||||
case 'T': // DateTime (YYYYMMDDhhmmss.uuu) (FoxPro)
|
case 'T': // DateTime (YYYYMMDDhhmmss.uuu) (FoxPro)
|
||||||
return 18;
|
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 '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 'N': // Number: -.0123456789 (right justified, padded with whitespaces)
|
||||||
case 'F': // Float: -.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)
|
case 'C': // String: All ASCII characters (padded with whitespaces up to the field's length)
|
||||||
return $field[2];
|
return $field[2];
|
||||||
case 'L': // Boolean: YyNnTtFf? (? when not initialized)
|
case 'L': // Boolean: YyNnTtFf? (? when not initialized)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions for reading and writing bytes
|
* Functions for reading and writing bytes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static function getChar8($fd)
|
/**
|
||||||
|
* getChar8
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function getChar8($fd)
|
||||||
{
|
{
|
||||||
return ord(fread($fd, 1));
|
return ord(fread($fd, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function putChar8($fd, $value)
|
/**
|
||||||
|
* putChar8
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @param mixed $value value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function putChar8($fd, $value)
|
||||||
{
|
{
|
||||||
return fwrite($fd, chr($value));
|
return fwrite($fd, chr($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getInt16($fd, $n = 1)
|
/**
|
||||||
|
* getInt16
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @param int $n n
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function getInt16($fd, $n = 1)
|
||||||
{
|
{
|
||||||
$data = fread($fd, 2 * $n);
|
$data = fread($fd, 2 * $n);
|
||||||
$i = unpack("S$n", $data);
|
$i = unpack("S$n", $data);
|
||||||
if ($n == 1)
|
if ($n == 1) {
|
||||||
return (int) $i[1];
|
return (int) $i[1];
|
||||||
else return array_merge($i);
|
} else {
|
||||||
}
|
return array_merge($i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static function putInt16($fd, $value)
|
/**
|
||||||
|
* putInt16
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @param mixed $value value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function putInt16($fd, $value)
|
||||||
{
|
{
|
||||||
return fwrite($fd, pack('S', $value));
|
return fwrite($fd, pack('S', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getInt32($fd, $n = 1)
|
/**
|
||||||
|
* getInt32
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @param int $n n
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function getInt32($fd, $n = 1)
|
||||||
{
|
{
|
||||||
$data = fread($fd, 4 * $n);
|
$data = fread($fd, 4 * $n);
|
||||||
$i = unpack("L$n", $data);
|
$i = unpack("L$n", $data);
|
||||||
if ($n == 1)
|
if ($n == 1) {
|
||||||
return (int) $i[1];
|
return (int) $i[1];
|
||||||
else return array_merge($i);
|
} else {
|
||||||
}
|
return array_merge($i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static function putInt32($fd, $value)
|
/**
|
||||||
|
* putint32
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @param mixed $value value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function putInt32($fd, $value)
|
||||||
{
|
{
|
||||||
return fwrite($fd, pack('L', $value));
|
return fwrite($fd, pack('L', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function putString($fd, $value, $length = 254)
|
/**
|
||||||
|
* putString
|
||||||
|
* @param mixed $fd file descriptor
|
||||||
|
* @param mixed $value value
|
||||||
|
* @param int $length length
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function putString($fd, $value, $length = 254)
|
||||||
{
|
{
|
||||||
$ret = fwrite($fd, pack('A' . $length, $value));
|
$ret = fwrite($fd, pack('A' . $length, $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function putRecord($record)
|
/**
|
||||||
|
* putRecord
|
||||||
|
* @param mixed $record record
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function putRecord($record)
|
||||||
{
|
{
|
||||||
foreach ($this->fields as $i => &$field) {
|
foreach ($this->fields as $i => &$field) {
|
||||||
$value = $record[$i];
|
$value = $record[$i];
|
||||||
// Number types are right aligned with spaces
|
// Number types are right aligned with spaces
|
||||||
if ($field['type'] == 'N' || $field['type'] == 'F' && strlen($value) < $field['length']) {
|
if ($field['type'] == 'N' || $field['type'] == 'F' && strlen($value) < $field['length']) {
|
||||||
$value = str_repeat(' ', $field['length'] - strlen($value)) . $value;
|
$value = str_repeat(' ', $field['length'] - strlen($value)) . $value;
|
||||||
}
|
}
|
||||||
self::putString($this->fd, $value, $field['length']);
|
self::putString($this->fd, $value, $field['length']);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('dbase_open')) {
|
if (!function_exists('dbase_open')) {
|
||||||
|
/**
|
||||||
function dbase_open($filename, $mode)
|
* dbase_open
|
||||||
|
* @param string $filename filename
|
||||||
|
* @param int $mode mode
|
||||||
|
* @return DBase
|
||||||
|
*/
|
||||||
|
function dbase_open($filename, $mode)
|
||||||
{
|
{
|
||||||
return DBase::open($filename, $mode);
|
return DBase::open($filename, $mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_create($filename, $fields, $type = DBASE_TYPE_DBASE)
|
/**
|
||||||
|
* dbase_create
|
||||||
|
* @param string $filename filename
|
||||||
|
* @param array $fields fields
|
||||||
|
* @param int $type type
|
||||||
|
* @return DBase
|
||||||
|
*/
|
||||||
|
function dbase_create($filename, $fields, $type = DBASE_TYPE_DBASE)
|
||||||
{
|
{
|
||||||
return DBase::create($filename, $fields, $type);
|
return DBase::create($filename, $fields, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_close($dbase_identifier)
|
/**
|
||||||
|
* dbase_close
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function dbase_close($dbase_identifier)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->close();
|
return $dbase_identifier->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_get_header_info($dbase_identifier)
|
/**
|
||||||
|
* dbase_get_header_info
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function dbase_get_header_info($dbase_identifier)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->get_header_info();
|
return $dbase_identifier->get_header_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_numfields($dbase_identifier)
|
/**
|
||||||
|
* dbase_numfields
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function dbase_numfields($dbase_identifier)
|
||||||
{
|
{
|
||||||
$dbase_identifier->numfields();
|
$dbase_identifier->numfields();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_numrecords($dbase_identifier)
|
/**
|
||||||
|
* dbase_numrecords
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function dbase_numrecords($dbase_identifier)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->numrecords();
|
return $dbase_identifier->numrecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_add_record($dbase_identifier, $record)
|
/**
|
||||||
|
* dbase_add_record
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @param array $record record
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function dbase_add_record($dbase_identifier, $record)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->add_record($record);
|
return $dbase_identifier->add_record($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_delete_record($dbase_identifier, $record_number)
|
/**
|
||||||
|
* dbase_delete_record
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function dbase_delete_record($dbase_identifier, $record_number)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->delete_record($record_number);
|
return $dbase_identifier->delete_record($record_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_replace_record($dbase_identifier, $record, $record_number)
|
/**
|
||||||
|
* dbase_replace_record
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @param array $record record
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function dbase_replace_record($dbase_identifier, $record, $record_number)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->replace_record($record, $record_number);
|
return $dbase_identifier->replace_record($record, $record_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_get_record($dbase_identifier, $record_number)
|
/**
|
||||||
|
* dbase_get_record
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function dbase_get_record($dbase_identifier, $record_number)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->get_record($record_number);
|
return $dbase_identifier->get_record($record_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_get_record_with_names($dbase_identifier, $record_number)
|
/**
|
||||||
|
* dbase_get_record_with_names
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @param int $record_number record number
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function dbase_get_record_with_names($dbase_identifier, $record_number)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->get_record_with_names($record_number);
|
return $dbase_identifier->get_record_with_names($record_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbase_pack($dbase_identifier)
|
/**
|
||||||
|
* dbase_pack
|
||||||
|
* @param Resource $dbase_identifier dbase identifier
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function dbase_pack($dbase_identifier)
|
||||||
{
|
{
|
||||||
return $dbase_identifier->pack();
|
return $dbase_identifier->pack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,60 +48,59 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
|
|||||||
define(GEN_NUMBER_FACTURE, 1);
|
define(GEN_NUMBER_FACTURE, 1);
|
||||||
$year = 2016;
|
$year = 2016;
|
||||||
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
||||||
mktime(12, 0, 0, 1, 9, $year),
|
mktime(12, 0, 0, 1, 9, $year),
|
||||||
mktime(12, 0, 0, 2, 13, $year),
|
mktime(12, 0, 0, 2, 13, $year),
|
||||||
mktime(12, 0, 0, 2, 23, $year),
|
mktime(12, 0, 0, 2, 23, $year),
|
||||||
mktime(12, 0, 0, 3, 30, $year),
|
mktime(12, 0, 0, 3, 30, $year),
|
||||||
mktime(12, 0, 0, 4, 3, $year),
|
mktime(12, 0, 0, 4, 3, $year),
|
||||||
mktime(12, 0, 0, 4, 3, $year),
|
mktime(12, 0, 0, 4, 3, $year),
|
||||||
mktime(12, 0, 0, 5, 9, $year),
|
mktime(12, 0, 0, 5, 9, $year),
|
||||||
mktime(12, 0, 0, 5, 1, $year),
|
mktime(12, 0, 0, 5, 1, $year),
|
||||||
mktime(12, 0, 0, 5, 13, $year),
|
mktime(12, 0, 0, 5, 13, $year),
|
||||||
mktime(12, 0, 0, 5, 19, $year),
|
mktime(12, 0, 0, 5, 19, $year),
|
||||||
mktime(12, 0, 0, 5, 23, $year),
|
mktime(12, 0, 0, 5, 23, $year),
|
||||||
mktime(12, 0, 0, 6, 3, $year),
|
mktime(12, 0, 0, 6, 3, $year),
|
||||||
mktime(12, 0, 0, 6, 19, $year),
|
mktime(12, 0, 0, 6, 19, $year),
|
||||||
mktime(12, 0, 0, 6, 24, $year),
|
mktime(12, 0, 0, 6, 24, $year),
|
||||||
mktime(12, 0, 0, 7, 3, $year),
|
mktime(12, 0, 0, 7, 3, $year),
|
||||||
mktime(12, 0, 0, 7, 9, $year),
|
mktime(12, 0, 0, 7, 9, $year),
|
||||||
mktime(12, 0, 0, 7, 23, $year),
|
mktime(12, 0, 0, 7, 23, $year),
|
||||||
mktime(12, 0, 0, 7, 30, $year),
|
mktime(12, 0, 0, 7, 30, $year),
|
||||||
mktime(12, 0, 0, 8, 9, $year),
|
mktime(12, 0, 0, 8, 9, $year),
|
||||||
mktime(12, 0, 0, 9, 23, $year),
|
mktime(12, 0, 0, 9, 23, $year),
|
||||||
mktime(12, 0, 0, 10, 3, $year),
|
mktime(12, 0, 0, 10, 3, $year),
|
||||||
mktime(12, 0, 0, 11, 12, $year),
|
mktime(12, 0, 0, 11, 12, $year),
|
||||||
mktime(12, 0, 0, 11, 13, $year),
|
mktime(12, 0, 0, 11, 13, $year),
|
||||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 11, 12, $year),
|
mktime(12, 0, 0, 11, 12, $year),
|
||||||
mktime(12, 0, 0, 11, 13, $year),
|
mktime(12, 0, 0, 11, 13, $year),
|
||||||
mktime(12, 0, 0, 12, 12, $year),
|
mktime(12, 0, 0, 12, 12, $year),
|
||||||
mktime(12, 0, 0, 12, 13, $year),
|
mktime(12, 0, 0, 12, 13, $year),
|
||||||
);
|
);
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -111,12 +110,10 @@ $user->getrights();
|
|||||||
$socids = array();
|
$socids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1, 3)";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1, 3)";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num_thirdparties = $db->num_rows($resql);
|
$num_thirdparties = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_thirdparties)
|
while ($i < $num_thirdparties) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$socids[$i] = $row[0];
|
$socids[$i] = $row[0];
|
||||||
@ -126,12 +123,10 @@ if ($resql)
|
|||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num_prods = $db->num_rows($resql);
|
$num_prods = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_prods)
|
while ($i < $num_prods) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$prodids[$i] = $row[0];
|
$prodids[$i] = $row[0];
|
||||||
@ -140,8 +135,7 @@ if ($resql)
|
|||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$result=0;
|
$result=0;
|
||||||
while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
while ($i < GEN_NUMBER_FACTURE && $result >= 0) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
$socid = mt_rand(1, $num_thirdparties);
|
$socid = mt_rand(1, $num_thirdparties);
|
||||||
|
|
||||||
@ -153,31 +147,27 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
|||||||
$object->cond_reglement_id = 3;
|
$object->cond_reglement_id = 3;
|
||||||
$object->mode_reglement_id = 3;
|
$object->mode_reglement_id = 3;
|
||||||
|
|
||||||
$fuser = new User($db);
|
$fuser = new User($db);
|
||||||
$fuser->fetch(mt_rand(1, 2));
|
$fuser->fetch(mt_rand(1, 2));
|
||||||
$fuser->getRights();
|
$fuser->getRights();
|
||||||
|
|
||||||
$result=$object->create($fuser);
|
$result=$object->create($fuser);
|
||||||
if ($result >= 0)
|
if ($result >= 0) {
|
||||||
{
|
|
||||||
$nbp = mt_rand(2, 5);
|
$nbp = mt_rand(2, 5);
|
||||||
$xnbp = 0;
|
$xnbp = 0;
|
||||||
while ($xnbp < $nbp)
|
while ($xnbp < $nbp) {
|
||||||
{
|
|
||||||
$prodid = mt_rand(1, $num_prods);
|
$prodid = mt_rand(1, $num_prods);
|
||||||
$product=new Product($db);
|
$product=new Product($db);
|
||||||
$result=$product->fetch($prodids[$prodid]);
|
$result=$product->fetch($prodids[$prodid]);
|
||||||
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
dol_print_error($db, $propal->error);
|
||||||
dol_print_error($db, $propal->error);
|
}
|
||||||
}
|
$xnbp++;
|
||||||
$xnbp++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$object->validate($fuser);
|
$result=$object->validate($fuser);
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
print " OK with ref ".$object->ref."\n";;
|
print " OK with ref ".$object->ref."\n";;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db, $object->error);
|
dol_print_error($db, $object->error);
|
||||||
|
|||||||
@ -31,8 +31,8 @@ $path=dirname(__FILE__).'/';
|
|||||||
// Test si mode batch
|
// Test si mode batch
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -54,62 +54,61 @@ require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
|
|||||||
define(GEN_NUMBER_COMMANDE, 10);
|
define(GEN_NUMBER_COMMANDE, 10);
|
||||||
$year = 2016;
|
$year = 2016;
|
||||||
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
||||||
mktime(12, 0, 0, 1, 9, $year),
|
mktime(12, 0, 0, 1, 9, $year),
|
||||||
mktime(12, 0, 0, 2, 13, $year),
|
mktime(12, 0, 0, 2, 13, $year),
|
||||||
mktime(12, 0, 0, 2, 23, $year),
|
mktime(12, 0, 0, 2, 23, $year),
|
||||||
mktime(12, 0, 0, 3, 30, $year),
|
mktime(12, 0, 0, 3, 30, $year),
|
||||||
mktime(12, 0, 0, 4, 3, $year),
|
mktime(12, 0, 0, 4, 3, $year),
|
||||||
mktime(12, 0, 0, 4, 3, $year),
|
mktime(12, 0, 0, 4, 3, $year),
|
||||||
mktime(12, 0, 0, 5, 9, $year),
|
mktime(12, 0, 0, 5, 9, $year),
|
||||||
mktime(12, 0, 0, 5, 1, $year),
|
mktime(12, 0, 0, 5, 1, $year),
|
||||||
mktime(12, 0, 0, 5, 13, $year),
|
mktime(12, 0, 0, 5, 13, $year),
|
||||||
mktime(12, 0, 0, 5, 19, $year),
|
mktime(12, 0, 0, 5, 19, $year),
|
||||||
mktime(12, 0, 0, 5, 23, $year),
|
mktime(12, 0, 0, 5, 23, $year),
|
||||||
mktime(12, 0, 0, 6, 3, $year),
|
mktime(12, 0, 0, 6, 3, $year),
|
||||||
mktime(12, 0, 0, 6, 19, $year),
|
mktime(12, 0, 0, 6, 19, $year),
|
||||||
mktime(12, 0, 0, 6, 24, $year),
|
mktime(12, 0, 0, 6, 24, $year),
|
||||||
mktime(12, 0, 0, 7, 3, $year),
|
mktime(12, 0, 0, 7, 3, $year),
|
||||||
mktime(12, 0, 0, 7, 9, $year),
|
mktime(12, 0, 0, 7, 9, $year),
|
||||||
mktime(12, 0, 0, 7, 23, $year),
|
mktime(12, 0, 0, 7, 23, $year),
|
||||||
mktime(12, 0, 0, 7, 30, $year),
|
mktime(12, 0, 0, 7, 30, $year),
|
||||||
mktime(12, 0, 0, 8, 9, $year),
|
mktime(12, 0, 0, 8, 9, $year),
|
||||||
mktime(12, 0, 0, 9, 23, $year),
|
mktime(12, 0, 0, 9, 23, $year),
|
||||||
mktime(12, 0, 0, 10, 3, $year),
|
mktime(12, 0, 0, 10, 3, $year),
|
||||||
mktime(12, 0, 0, 11, 12, $year),
|
mktime(12, 0, 0, 11, 12, $year),
|
||||||
mktime(12, 0, 0, 11, 13, $year),
|
mktime(12, 0, 0, 11, 13, $year),
|
||||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 11, 12, $year),
|
mktime(12, 0, 0, 11, 12, $year),
|
||||||
mktime(12, 0, 0, 11, 13, $year),
|
mktime(12, 0, 0, 11, 13, $year),
|
||||||
mktime(12, 0, 0, 12, 12, $year),
|
mktime(12, 0, 0, 12, 12, $year),
|
||||||
mktime(12, 0, 0, 12, 13, $year),
|
mktime(12, 0, 0, 12, 13, $year),
|
||||||
);
|
);
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if ($ret <= 0)
|
if ($ret <= 0) {
|
||||||
{
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
exit;
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
@ -117,101 +116,100 @@ $societesid = array();
|
|||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)";
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num_thirdparties = $db->num_rows($resql);
|
$num_thirdparties = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_thirdparties) {
|
while ($i < $num_thirdparties) {
|
||||||
$i++;
|
$i++;
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$societesid[$i] = $row[0];
|
$societesid[$i] = $row[0];
|
||||||
}
|
}
|
||||||
} else { print "err"; }
|
} else {
|
||||||
|
print "err";
|
||||||
|
}
|
||||||
|
|
||||||
$commandesid = array();
|
$commandesid = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$i++;
|
$i++;
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$commandesid[$i] = $row[0];
|
$commandesid[$i] = $row[0];
|
||||||
}
|
}
|
||||||
} else { print "err"; }
|
} else {
|
||||||
|
print "err";
|
||||||
|
}
|
||||||
|
|
||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num_prods = $db->num_rows($resql);
|
$num_prods = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_prods) {
|
while ($i < $num_prods) {
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$prodids[$i] = $row[0];
|
$prodids[$i] = $row[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print "Build ".GEN_NUMBER_COMMANDE." orders\n";
|
print "Build ".GEN_NUMBER_COMMANDE." orders\n";
|
||||||
for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
|
for ($s = 0; $s < GEN_NUMBER_COMMANDE; $s++) {
|
||||||
{
|
print "Process order ".$s."\n";
|
||||||
print "Process order ".$s."\n";
|
|
||||||
|
|
||||||
$object = new Commande($db);
|
$object = new Commande($db);
|
||||||
|
|
||||||
$object->socid = $societesid[mt_rand(1, $num_thirdparties)];
|
$object->socid = $societesid[mt_rand(1, $num_thirdparties)];
|
||||||
$object->date_commande = $dates[mt_rand(1, count($dates)-1)];
|
$object->date_commande = $dates[mt_rand(1, count($dates)-1)];
|
||||||
$object->note = 'My small comment about this order. Hum. Nothing.';
|
$object->note = 'My small comment about this order. Hum. Nothing.';
|
||||||
$object->source = 1;
|
$object->source = 1;
|
||||||
$object->fk_project = 0;
|
$object->fk_project = 0;
|
||||||
$object->remise_percent = 0;
|
$object->remise_percent = 0;
|
||||||
$object->shipping_method_id = mt_rand(1, 2);
|
$object->shipping_method_id = mt_rand(1, 2);
|
||||||
$object->cond_reglement_id = mt_rand(0, 2);
|
$object->cond_reglement_id = mt_rand(0, 2);
|
||||||
$object->more_reglement_id = mt_rand(0, 7);
|
$object->more_reglement_id = mt_rand(0, 7);
|
||||||
$object->availability_id = mt_rand(0, 1);
|
$object->availability_id = mt_rand(0, 1);
|
||||||
|
|
||||||
$listofuserid=array(12,13,16);
|
$listofuserid=array(12,13,16);
|
||||||
|
|
||||||
$fuser = new User($db);
|
$fuser = new User($db);
|
||||||
$fuser->fetch($listofuserid[mt_rand(0, 2)]);
|
$fuser->fetch($listofuserid[mt_rand(0, 2)]);
|
||||||
$fuser->getRights();
|
$fuser->getRights();
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$result=$object->create($fuser);
|
$result=$object->create($fuser);
|
||||||
if ($result >= 0)
|
if ($result >= 0) {
|
||||||
{
|
$nbp = mt_rand(2, 5);
|
||||||
$nbp = mt_rand(2, 5);
|
$xnbp = 0;
|
||||||
$xnbp = 0;
|
while ($xnbp < $nbp) {
|
||||||
while ($xnbp < $nbp)
|
$prodid = mt_rand(1, $num_prods);
|
||||||
{
|
$product=new Product($db);
|
||||||
$prodid = mt_rand(1, $num_prods);
|
$result=$product->fetch($prodids[$prodid]);
|
||||||
$product=new Product($db);
|
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
|
||||||
$result=$product->fetch($prodids[$prodid]);
|
if ($result <= 0) {
|
||||||
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
|
dol_print_error($db, $object->error);
|
||||||
if ($result <= 0)
|
}
|
||||||
{
|
$xnbp++;
|
||||||
dol_print_error($db, $object->error);
|
}
|
||||||
}
|
|
||||||
$xnbp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result=$object->valid($fuser);
|
$result=$object->valid($fuser);
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
$db->commit();
|
||||||
$db->commit();
|
print " OK with ref ".$object->ref."\n";
|
||||||
print " OK with ref ".$object->ref."\n";
|
} else {
|
||||||
} else {
|
print " KO\n";
|
||||||
print " KO\n";
|
$db->rollback();
|
||||||
$db->rollback();
|
dol_print_error($db, $object->error);
|
||||||
dol_print_error($db, $object->error);
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
print " KO\n";
|
||||||
print " KO\n";
|
$db->rollback();
|
||||||
$db->rollback();
|
dol_print_error($db, $object->error);
|
||||||
dol_print_error($db, $object->error);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,8 @@ $path=dirname(__FILE__).'/';
|
|||||||
// Test si mode batch
|
// Test si mode batch
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -54,8 +54,7 @@ define(GEN_NUMBER_PRODUIT, 100000);
|
|||||||
|
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -65,38 +64,50 @@ $user->getrights();
|
|||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql); $i = 0;
|
$num = $db->num_rows($resql); $i = 0;
|
||||||
while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; }
|
while ($i < $num) {
|
||||||
|
$row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql); $i = 0;
|
$num = $db->num_rows($resql); $i = 0;
|
||||||
while ($i < $num) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++; }
|
while ($i < $num) {
|
||||||
} else { print "err"; }
|
$row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "err";
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql); $i = 0;
|
$num = $db->num_rows($resql); $i = 0;
|
||||||
while ($i < $num) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++; }
|
while ($i < $num) {
|
||||||
} else { print "err"; }
|
$row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "err";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print "Generates ".GEN_NUMBER_PRODUIT." products\n";
|
print "Generates ".GEN_NUMBER_PRODUIT." products\n";
|
||||||
for ($s = 0 ; $s < GEN_NUMBER_PRODUIT ; $s++)
|
for ($s = 0; $s < GEN_NUMBER_PRODUIT; $s++) {
|
||||||
{
|
print "Product ".$s;
|
||||||
print "Product ".$s;
|
$produit = new Product($db);
|
||||||
$produit = new Product($db);
|
$produit->type = mt_rand(0, 1);
|
||||||
$produit->type = mt_rand(0, 1);
|
$produit->status = 1;
|
||||||
$produit->status = 1;
|
$produit->ref = ($produit->type?'S':'P').time().$s;
|
||||||
$produit->ref = ($produit->type?'S':'P').time().$s;
|
$produit->label = 'Label '.time().$s;
|
||||||
$produit->label = 'Label '.time().$s;
|
$produit->description = 'Description '.time().$s;
|
||||||
$produit->description = 'Description '.time().$s;
|
$produit->price = mt_rand(1, 1000);
|
||||||
$produit->price = mt_rand(1, 1000);
|
$produit->tva_tx = "19.6";
|
||||||
$produit->tva_tx = "19.6";
|
$ret=$produit->create($user);
|
||||||
$ret=$produit->create($user);
|
if ($ret < 0) {
|
||||||
if ($ret < 0) print "Error $ret - ".$produit->error."\n";
|
print "Error $ret - ".$produit->error."\n";
|
||||||
else print " OK with ref ".$produit->ref."\n";
|
} else {
|
||||||
|
print " OK with ref ".$produit->ref."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,60 +50,59 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
|
|||||||
define(GEN_NUMBER_PROPAL, 10);
|
define(GEN_NUMBER_PROPAL, 10);
|
||||||
$year = 2016;
|
$year = 2016;
|
||||||
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
||||||
mktime(12, 0, 0, 1, 9, $year),
|
mktime(12, 0, 0, 1, 9, $year),
|
||||||
mktime(12, 0, 0, 2, 13, $year),
|
mktime(12, 0, 0, 2, 13, $year),
|
||||||
mktime(12, 0, 0, 2, 23, $year),
|
mktime(12, 0, 0, 2, 23, $year),
|
||||||
mktime(12, 0, 0, 3, 30, $year),
|
mktime(12, 0, 0, 3, 30, $year),
|
||||||
mktime(12, 0, 0, 4, 3, $year),
|
mktime(12, 0, 0, 4, 3, $year),
|
||||||
mktime(12, 0, 0, 4, 3, $year),
|
mktime(12, 0, 0, 4, 3, $year),
|
||||||
mktime(12, 0, 0, 5, 9, $year),
|
mktime(12, 0, 0, 5, 9, $year),
|
||||||
mktime(12, 0, 0, 5, 1, $year),
|
mktime(12, 0, 0, 5, 1, $year),
|
||||||
mktime(12, 0, 0, 5, 13, $year),
|
mktime(12, 0, 0, 5, 13, $year),
|
||||||
mktime(12, 0, 0, 5, 19, $year),
|
mktime(12, 0, 0, 5, 19, $year),
|
||||||
mktime(12, 0, 0, 5, 23, $year),
|
mktime(12, 0, 0, 5, 23, $year),
|
||||||
mktime(12, 0, 0, 6, 3, $year),
|
mktime(12, 0, 0, 6, 3, $year),
|
||||||
mktime(12, 0, 0, 6, 19, $year),
|
mktime(12, 0, 0, 6, 19, $year),
|
||||||
mktime(12, 0, 0, 6, 24, $year),
|
mktime(12, 0, 0, 6, 24, $year),
|
||||||
mktime(12, 0, 0, 7, 3, $year),
|
mktime(12, 0, 0, 7, 3, $year),
|
||||||
mktime(12, 0, 0, 7, 9, $year),
|
mktime(12, 0, 0, 7, 9, $year),
|
||||||
mktime(12, 0, 0, 7, 23, $year),
|
mktime(12, 0, 0, 7, 23, $year),
|
||||||
mktime(12, 0, 0, 7, 30, $year),
|
mktime(12, 0, 0, 7, 30, $year),
|
||||||
mktime(12, 0, 0, 8, 9, $year),
|
mktime(12, 0, 0, 8, 9, $year),
|
||||||
mktime(12, 0, 0, 9, 23, $year),
|
mktime(12, 0, 0, 9, 23, $year),
|
||||||
mktime(12, 0, 0, 10, 3, $year),
|
mktime(12, 0, 0, 10, 3, $year),
|
||||||
mktime(12, 0, 0, 11, 12, $year),
|
mktime(12, 0, 0, 11, 12, $year),
|
||||||
mktime(12, 0, 0, 11, 13, $year),
|
mktime(12, 0, 0, 11, 13, $year),
|
||||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||||
mktime(12, 0, 0, 11, 12, $year),
|
mktime(12, 0, 0, 11, 12, $year),
|
||||||
mktime(12, 0, 0, 11, 13, $year),
|
mktime(12, 0, 0, 11, 13, $year),
|
||||||
mktime(12, 0, 0, 12, 12, $year),
|
mktime(12, 0, 0, 12, 12, $year),
|
||||||
mktime(12, 0, 0, 12, 13, $year),
|
mktime(12, 0, 0, 12, 13, $year),
|
||||||
);
|
);
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -113,12 +112,10 @@ $user->getrights();
|
|||||||
$socids = array();
|
$socids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1,3)";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1,3)";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num_thirdparties = $db->num_rows($resql);
|
$num_thirdparties = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_thirdparties)
|
while ($i < $num_thirdparties) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$socids[$i] = $row[0];
|
$socids[$i] = $row[0];
|
||||||
@ -128,12 +125,10 @@ if ($resql)
|
|||||||
$contids = array();
|
$contids = array();
|
||||||
$sql = "SELECT rowid, fk_soc FROM ".MAIN_DB_PREFIX."socpeople";
|
$sql = "SELECT rowid, fk_soc FROM ".MAIN_DB_PREFIX."socpeople";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num_conts = $db->num_rows($resql);
|
$num_conts = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_conts)
|
while ($i < $num_conts) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$contids[$row[1]][0] = $row[0]; // A ameliorer
|
$contids[$row[1]][0] = $row[0]; // A ameliorer
|
||||||
@ -143,12 +138,10 @@ if ($resql)
|
|||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num_prods = $db->num_rows($resql);
|
$num_prods = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_prods)
|
while ($i < $num_prods) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$prodids[$i] = $row[0];
|
$prodids[$i] = $row[0];
|
||||||
@ -159,15 +152,13 @@ $user->rights->propal->creer=1;
|
|||||||
$user->rights->propal->propal_advance->validate=1;
|
$user->rights->propal->propal_advance->validate=1;
|
||||||
|
|
||||||
|
|
||||||
if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
|
if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) {
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php";
|
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php";
|
||||||
}
|
}
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$result=0;
|
$result=0;
|
||||||
while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
while ($i < GEN_NUMBER_PROPAL && $result >= 0) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
$socid = mt_rand(1, $num_thirdparties);
|
$socid = mt_rand(1, $num_thirdparties);
|
||||||
print "Proposal ".$i." for socid ".$socid;
|
print "Proposal ".$i." for socid ".$socid;
|
||||||
@ -177,9 +168,9 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
|||||||
|
|
||||||
$object = new Propal($db);
|
$object = new Propal($db);
|
||||||
|
|
||||||
$fuser = new User($db);
|
$fuser = new User($db);
|
||||||
$fuser->fetch(mt_rand(1, 2));
|
$fuser->fetch(mt_rand(1, 2));
|
||||||
$fuser->getRights();
|
$fuser->getRights();
|
||||||
|
|
||||||
$object->contactid = $contids[$socids[$socid]][0];
|
$object->contactid = $contids[$socids[$socid]][0];
|
||||||
$object->socid = $socids[$socid];
|
$object->socid = $socids[$socid];
|
||||||
@ -188,32 +179,28 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
|||||||
$object->mode_reglement_id = 3;
|
$object->mode_reglement_id = 3;
|
||||||
|
|
||||||
$result=$object->create($fuser);
|
$result=$object->create($fuser);
|
||||||
if ($result >= 0)
|
if ($result >= 0) {
|
||||||
{
|
|
||||||
$nbp = mt_rand(2, 5);
|
$nbp = mt_rand(2, 5);
|
||||||
$xnbp = 0;
|
$xnbp = 0;
|
||||||
while ($xnbp < $nbp)
|
while ($xnbp < $nbp) {
|
||||||
{
|
|
||||||
$prodid = mt_rand(1, $num_prods);
|
$prodid = mt_rand(1, $num_prods);
|
||||||
$product=new Product($db);
|
$product=new Product($db);
|
||||||
$result=$product->fetch($prodids[$prodid]);
|
$result=$product->fetch($prodids[$prodid]);
|
||||||
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0);
|
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
dol_print_error($db, $object->error);
|
dol_print_error($db, $object->error);
|
||||||
}
|
}
|
||||||
$xnbp++;
|
$xnbp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$object->valid($fuser);
|
$result=$object->valid($fuser);
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
$db->commit();
|
||||||
$db->commit();
|
print " OK with ref ".$object->ref."\n";
|
||||||
print " OK with ref ".$object->ref."\n";
|
|
||||||
} else {
|
} else {
|
||||||
print " KO\n";
|
print " KO\n";
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
dol_print_error($db, $object->error);
|
dol_print_error($db, $object->error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db, $object->error);
|
dol_print_error($db, $object->error);
|
||||||
|
|||||||
@ -31,8 +31,8 @@ $path=dirname(__FILE__).'/';
|
|||||||
// Test si mode batch
|
// Test si mode batch
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -57,8 +57,7 @@ define(GEN_NUMBER_SOCIETE, 10);
|
|||||||
|
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -68,8 +67,8 @@ $user->getrights();
|
|||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql); $i = 0;
|
$num = $db->num_rows($resql); $i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$productsid[$i] = $row[0];
|
$productsid[$i] = $row[0];
|
||||||
$i++;
|
$i++;
|
||||||
@ -80,63 +79,65 @@ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
|||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql); $i = 0;
|
$num = $db->num_rows($resql); $i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$societesid[$i] = $row[0];
|
$societesid[$i] = $row[0];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
} else { print "err"; }
|
} else {
|
||||||
|
print "err";
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql); $i = 0;
|
$num = $db->num_rows($resql); $i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$commandesid[$i] = $row[0];
|
$commandesid[$i] = $row[0];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
} else { print "err"; }
|
} else {
|
||||||
|
print "err";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print "Generates ".GEN_NUMBER_SOCIETE." companies\n";
|
print "Generates ".GEN_NUMBER_SOCIETE." companies\n";
|
||||||
for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++)
|
for ($s = 0; $s < GEN_NUMBER_SOCIETE; $s++) {
|
||||||
{
|
print "Company $s\n";
|
||||||
print "Company $s\n";
|
$soc = new Societe($db);
|
||||||
$soc = new Societe($db);
|
$soc->name = "Company num ".time()."$s";
|
||||||
$soc->name = "Company num ".time()."$s";
|
$soc->town = $listoftown[mt_rand(0, count($listoftown)-1)];
|
||||||
$soc->town = $listoftown[mt_rand(0, count($listoftown)-1)];
|
$soc->client = mt_rand(1, 2); // Une societe sur 2 est prospect, l'autre client
|
||||||
$soc->client = mt_rand(1, 2); // Une societe sur 2 est prospect, l'autre client
|
$soc->fournisseur = mt_rand(0, 1); // Une societe sur 2 est fournisseur
|
||||||
$soc->fournisseur = mt_rand(0, 1); // Une societe sur 2 est fournisseur
|
$soc->code_client='CU'.time()."$s";
|
||||||
$soc->code_client='CU'.time()."$s";
|
$soc->code_fournisseur='SU'.time()."$s";
|
||||||
$soc->code_fournisseur='SU'.time()."$s";
|
$soc->tva_assuj=1;
|
||||||
$soc->tva_assuj=1;
|
$soc->country_id=1;
|
||||||
$soc->country_id=1;
|
$soc->country_code='FR';
|
||||||
$soc->country_code='FR';
|
|
||||||
// Un client sur 3 a une remise de 5%
|
// Un client sur 3 a une remise de 5%
|
||||||
$user_remise=mt_rand(1, 3); if ($user_remise==3) $soc->remise_percent=5;
|
$user_remise=mt_rand(1, 3); if ($user_remise==3) {
|
||||||
|
$soc->remise_percent=5;
|
||||||
|
}
|
||||||
print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n";
|
print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n";
|
||||||
$soc->note_private = 'Company created by the script generate-societe.php';
|
$soc->note_private = 'Company created by the script generate-societe.php';
|
||||||
$socid = $soc->create();
|
$socid = $soc->create();
|
||||||
|
|
||||||
if ($socid >= 0)
|
if ($socid >= 0) {
|
||||||
{
|
$rand = mt_rand(1, 4);
|
||||||
$rand = mt_rand(1, 4);
|
print "> Generates $rand contact(s)\n";
|
||||||
print "> Generates $rand contact(s)\n";
|
for ($c = 0; $c < $rand; $c++) {
|
||||||
for ($c = 0 ; $c < $rand ; $c++)
|
$contact = new Contact($db);
|
||||||
{
|
$contact->socid = $soc->id;
|
||||||
$contact = new Contact($db);
|
$contact->lastname = "Lastname".$c;
|
||||||
$contact->socid = $soc->id;
|
$contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)];
|
||||||
$contact->lastname = "Lastname".$c;
|
if ($contact->create($user)) {
|
||||||
$contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)];
|
}
|
||||||
if ( $contact->create($user) )
|
}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print "Company ".$s." created nom=".$soc->name."\n";
|
print "Company ".$s." created nom=".$soc->name."\n";
|
||||||
} else {
|
} else {
|
||||||
print "Error: ".$soc->error."\n";
|
print "Error: ".$soc->error."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,8 +30,8 @@ $sapi_type = php_sapi_name();
|
|||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
$path=dirname(__FILE__).'/';
|
$path=dirname(__FILE__).'/';
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -67,44 +67,40 @@ $startlinenb = empty($argv[4])?1:$argv[4];
|
|||||||
$endlinenb = empty($argv[5])?0:$argv[5];
|
$endlinenb = empty($argv[5])?0:$argv[5];
|
||||||
|
|
||||||
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
||||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n";
|
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n";
|
||||||
print "Usage: $script_file test myfilepath.csv fr_FR 2 1002\n";
|
print "Usage: $script_file test myfilepath.csv fr_FR 2 1002\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (! file_exists($filepath)) {
|
if (! file_exists($filepath)) {
|
||||||
print "Error: File ".$filepath." not found.\n";
|
print "Error: File ".$filepath." not found.\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
// Ask confirmation
|
// Ask confirmation
|
||||||
if (! $confirmed)
|
if (! $confirmed) {
|
||||||
{
|
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
$input = trim(fgets(STDIN));
|
||||||
$input = trim(fgets(STDIN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open input and output files
|
// Open input and output files
|
||||||
$fhandle = fopen($filepath, 'r');
|
$fhandle = fopen($filepath, 'r');
|
||||||
if (! $fhandle)
|
if (! $fhandle) {
|
||||||
{
|
print 'Error: Failed to open file '.$filepath."\n";
|
||||||
print 'Error: Failed to open file '.$filepath."\n";
|
exit(1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
$fhandleerr = fopen($filepatherr, 'w');
|
$fhandleerr = fopen($filepatherr, 'w');
|
||||||
if (! $fhandleerr)
|
if (! $fhandleerr) {
|
||||||
{
|
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
exit(1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$langs->setDefaultLang($defaultlang);
|
$langs->setDefaultLang($defaultlang);
|
||||||
@ -114,99 +110,96 @@ $db->begin();
|
|||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$nboflines++;
|
$nboflines++;
|
||||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
|
||||||
{
|
$i++;
|
||||||
$i++;
|
$errorrecord=0;
|
||||||
$errorrecord=0;
|
|
||||||
|
|
||||||
if ($startlinenb && $i < $startlinenb) continue;
|
if ($startlinenb && $i < $startlinenb) {
|
||||||
if ($endlinenb && $i > $endlinenb) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($endlinenb && $i > $endlinenb) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$nboflines++;
|
$nboflines++;
|
||||||
|
|
||||||
$produit = new Product($db);
|
$produit = new Product($db);
|
||||||
$produit->type = 0;
|
$produit->type = 0;
|
||||||
$produit->status = 1;
|
$produit->status = 1;
|
||||||
$produit->ref = trim($fields[0]);
|
$produit->ref = trim($fields[0]);
|
||||||
|
|
||||||
print "Process line nb ".$i.", ref ".$produit->ref;
|
print "Process line nb ".$i.", ref ".$produit->ref;
|
||||||
$produit->label = trim($fields[2]);
|
$produit->label = trim($fields[2]);
|
||||||
$produit->description = trim($fields[4]."\n".($fields[5] ? $fields[5].' x '.$fields[6].' x '.$fields[7] : ''));
|
$produit->description = trim($fields[4]."\n".($fields[5] ? $fields[5].' x '.$fields[6].' x '.$fields[7] : ''));
|
||||||
$produit->volume = price2num($fields[8]);
|
$produit->volume = price2num($fields[8]);
|
||||||
$produit->volume_unit = 0;
|
$produit->volume_unit = 0;
|
||||||
$produit->weight = price2num($fields[9]);
|
$produit->weight = price2num($fields[9]);
|
||||||
$produit->weight_units = 0; // -3 = g
|
$produit->weight_units = 0; // -3 = g
|
||||||
|
|
||||||
$produit->customcode = $fields[10];
|
$produit->customcode = $fields[10];
|
||||||
$produit->barcode = $fields[1];
|
$produit->barcode = $fields[1];
|
||||||
|
|
||||||
$produit->status = 1;
|
$produit->status = 1;
|
||||||
$produit->status_buy = 1;
|
$produit->status_buy = 1;
|
||||||
|
|
||||||
$produit->finished = 1;
|
$produit->finished = 1;
|
||||||
|
|
||||||
$produit->price_min = null;
|
$produit->price_min = null;
|
||||||
$produit->price_min_ttc = null;
|
$produit->price_min_ttc = null;
|
||||||
$produit->price = price2num($fields[11]);
|
$produit->price = price2num($fields[11]);
|
||||||
$produit->price_ttc = price2num($fields[12]);
|
$produit->price_ttc = price2num($fields[12]);
|
||||||
$produit->price_base_type = 'TTC';
|
$produit->price_base_type = 'TTC';
|
||||||
$produit->tva_tx = price2num($fields[13]);
|
$produit->tva_tx = price2num($fields[13]);
|
||||||
$produit->tva_npr = 0;
|
$produit->tva_npr = 0;
|
||||||
|
|
||||||
$produit->cost_price = price2num($fields[16]);
|
$produit->cost_price = price2num($fields[16]);
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$produit->array_options['options_ecotaxdeee']=price2num($fields[17]);
|
$produit->array_options['options_ecotaxdeee']=price2num($fields[17]);
|
||||||
|
|
||||||
$ret=$produit->create($user);
|
$ret=$produit->create($user);
|
||||||
if ($ret < 0)
|
if ($ret < 0) {
|
||||||
{
|
print " - Error in create result code = ".$ret." - ".$produit->errorsToString();
|
||||||
print " - Error in create result code = ".$ret." - ".$produit->errorsToString();
|
$errorrecord++;
|
||||||
$errorrecord++;
|
} else {
|
||||||
} else {
|
print " - Creation OK with ref ".$produit->ref." - id = ".$ret;
|
||||||
print " - Creation OK with ref ".$produit->ref." - id = ".$ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("Add prices");
|
dol_syslog("Add prices");
|
||||||
|
|
||||||
// If we use price level, insert price for each level
|
// If we use price level, insert price for each level
|
||||||
if (! $errorrecord && 1)
|
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=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
|
$ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
|
||||||
$ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
|
if ($ret1 < 0 || $ret2 < 0) {
|
||||||
if ($ret1 < 0 || $ret2 < 0)
|
print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
|
||||||
{
|
$errorrecord++;
|
||||||
print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
|
} else {
|
||||||
$errorrecord++;
|
print " - updatePrice OK";
|
||||||
} else {
|
}
|
||||||
print " - updatePrice OK";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("Add multilangs");
|
dol_syslog("Add multilangs");
|
||||||
|
|
||||||
// Add alternative languages
|
// Add alternative languages
|
||||||
if (! $errorrecord && 1)
|
if (! $errorrecord && 1) {
|
||||||
{
|
$produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private);
|
||||||
$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);
|
||||||
$produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private);
|
|
||||||
|
|
||||||
$ret=$produit->setMultiLangs($user);
|
$ret=$produit->setMultiLangs($user);
|
||||||
if ($ret < 0)
|
if ($ret < 0) {
|
||||||
{
|
print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
|
||||||
print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
|
$errorrecord++;
|
||||||
$errorrecord++;
|
} else {
|
||||||
} else {
|
print " - setMultiLangs OK";
|
||||||
print " - setMultiLangs OK";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
if ($errorrecord)
|
if ($errorrecord) {
|
||||||
{
|
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n");
|
||||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n");
|
$error++; // $errorrecord will be reset
|
||||||
$error++; // $errorrecord will be reset
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,13 +210,12 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
|||||||
// commit or rollback
|
// commit or rollback
|
||||||
print "Nb of lines qualified: ".$nboflines."\n";
|
print "Nb of lines qualified: ".$nboflines."\n";
|
||||||
print "Nb of errors: ".$error."\n";
|
print "Nb of errors: ".$error."\n";
|
||||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
|
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||||
{
|
print "Rollback any changes.\n";
|
||||||
print "Rollback any changes.\n";
|
$db->rollback();
|
||||||
$db->rollback();
|
|
||||||
} else {
|
} else {
|
||||||
print "Commit all changes.\n";
|
print "Commit all changes.\n";
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -30,8 +30,8 @@ $sapi_type = php_sapi_name();
|
|||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
$path=dirname(__FILE__).'/';
|
$path=dirname(__FILE__).'/';
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -67,44 +67,40 @@ $startlinenb = empty($argv[3])?1:$argv[3];
|
|||||||
$endlinenb = empty($argv[4])?0:$argv[4];
|
$endlinenb = empty($argv[4])?0:$argv[4];
|
||||||
|
|
||||||
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
||||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (! file_exists($filepath)) {
|
if (! file_exists($filepath)) {
|
||||||
print "Error: File ".$filepath." not found.\n";
|
print "Error: File ".$filepath." not found.\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
// Ask confirmation
|
// Ask confirmation
|
||||||
if (! $confirmed)
|
if (! $confirmed) {
|
||||||
{
|
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
$input = trim(fgets(STDIN));
|
||||||
$input = trim(fgets(STDIN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open input and output files
|
// Open input and output files
|
||||||
$fhandle = fopen($filepath, 'r');
|
$fhandle = fopen($filepath, 'r');
|
||||||
if (! $fhandle)
|
if (! $fhandle) {
|
||||||
{
|
print 'Error: Failed to open file '.$filepath."\n";
|
||||||
print 'Error: Failed to open file '.$filepath."\n";
|
exit(1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
$fhandleerr = fopen($filepatherr, 'w');
|
$fhandleerr = fopen($filepatherr, 'w');
|
||||||
if (! $fhandleerr)
|
if (! $fhandleerr) {
|
||||||
{
|
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
exit(1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//$langs->setDefaultLang($defaultlang);
|
//$langs->setDefaultLang($defaultlang);
|
||||||
@ -114,175 +110,173 @@ $db->begin();
|
|||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$nboflines=0;
|
$nboflines=0;
|
||||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
|
||||||
{
|
$i++;
|
||||||
$i++;
|
$errorrecord=0;
|
||||||
$errorrecord=0;
|
|
||||||
|
|
||||||
if ($startlinenb && $i < $startlinenb) continue;
|
if ($startlinenb && $i < $startlinenb) {
|
||||||
if ($endlinenb && $i > $endlinenb) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($endlinenb && $i > $endlinenb) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$nboflines++;
|
$nboflines++;
|
||||||
|
|
||||||
$object = new Societe($db);
|
$object = new Societe($db);
|
||||||
$object->state = $fields[6];
|
$object->state = $fields[6];
|
||||||
$object->client = $fields[7];
|
$object->client = $fields[7];
|
||||||
$object->fournisseur = $fields[8];
|
$object->fournisseur = $fields[8];
|
||||||
|
|
||||||
$object->name = $fields[13]?trim($fields[13]):$fields[0];
|
$object->name = $fields[13]?trim($fields[13]):$fields[0];
|
||||||
$object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
|
$object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
|
||||||
|
|
||||||
$object->address = trim($fields[14]);
|
$object->address = trim($fields[14]);
|
||||||
$object->zip = trim($fields[15]);
|
$object->zip = trim($fields[15]);
|
||||||
$object->town = trim($fields[16]);
|
$object->town = trim($fields[16]);
|
||||||
$object->country_id = dol_getIdFromCode($db, trim($fields[21]), 'c_country', 'code', 'rowid');
|
$object->country_id = dol_getIdFromCode($db, trim($fields[21]), 'c_country', 'code', 'rowid');
|
||||||
$object->phone = trim($fields[22]);
|
$object->phone = trim($fields[22]);
|
||||||
$object->fax = trim($fields[23]);
|
$object->fax = trim($fields[23]);
|
||||||
$object->email = trim($fields[26]);
|
$object->email = trim($fields[26]);
|
||||||
$object->idprof2 = trim($fields[29]);
|
$object->idprof2 = trim($fields[29]);
|
||||||
$object->tva_intra = trim($fields[34]);
|
$object->tva_intra = trim($fields[34]);
|
||||||
$object->default_lang = trim($fields[43]);
|
$object->default_lang = trim($fields[43]);
|
||||||
|
|
||||||
//$condpayment = dol_string_unaccent(trim($fields[36]));
|
//$condpayment = dol_string_unaccent(trim($fields[36]));
|
||||||
if ($fields[36])
|
if ($fields[36]) {
|
||||||
{
|
$condpayment = trim($fields[36]);
|
||||||
$condpayment = trim($fields[36]);
|
if ($condpayment == 'A la commande') {
|
||||||
if ($condpayment == 'A la commande') $condpayment = 'A réception de commande';
|
$condpayment = 'A réception de commande';
|
||||||
if ($condpayment == 'A reception facture') $condpayment = 'Réception de facture';
|
}
|
||||||
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', 1);
|
if ($condpayment == 'A reception facture') {
|
||||||
if (empty($object->cond_reglement_id))
|
$condpayment = 'Réception de facture';
|
||||||
{
|
}
|
||||||
print " - Error cant find payment mode for ".$condpayment."\n";
|
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', 1);
|
||||||
$errorrecord++;
|
if (empty($object->cond_reglement_id)) {
|
||||||
}
|
print " - Error cant find payment mode for ".$condpayment."\n";
|
||||||
}
|
$errorrecord++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$object->code_client = $fields[9];
|
$object->code_client = $fields[9];
|
||||||
$object->code_fournisseur = $fields[10];
|
$object->code_fournisseur = $fields[10];
|
||||||
|
|
||||||
$labeltype = trim($fields[1]);
|
$labeltype = trim($fields[1]);
|
||||||
$object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'libelle');
|
$object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'libelle');
|
||||||
|
|
||||||
// Set price level
|
// Set price level
|
||||||
$object->price_level = 1;
|
$object->price_level = 1;
|
||||||
if ($labeltype == 'Revendeur') $object->price_level = 2;
|
if ($labeltype == 'Revendeur') {
|
||||||
|
$object->price_level = 2;
|
||||||
|
}
|
||||||
|
|
||||||
print "Process line nb ".$i.", name ".$object->name;
|
print "Process line nb ".$i.", name ".$object->name;
|
||||||
|
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$object->array_options['options_anastate']=price2num($fields[20]);
|
$object->array_options['options_anastate']=price2num($fields[20]);
|
||||||
$object->array_options['options_anaregion']=price2num($fields[17]);
|
$object->array_options['options_anaregion']=price2num($fields[17]);
|
||||||
|
|
||||||
if (! $errorrecord)
|
if (! $errorrecord) {
|
||||||
{
|
$ret=$object->create($user);
|
||||||
$ret=$object->create($user);
|
if ($ret < 0) {
|
||||||
if ($ret < 0)
|
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
||||||
{
|
$errorrecord++;
|
||||||
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
} else {
|
||||||
$errorrecord++;
|
print " - Creation OK with name ".$object->name." - id = ".$ret;
|
||||||
} else {
|
}
|
||||||
print " - Creation OK with name ".$object->name." - id = ".$ret;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $errorrecord)
|
if (! $errorrecord) {
|
||||||
{
|
dol_syslog("Set price level");
|
||||||
dol_syslog("Set price level");
|
$object->set_price_level($object->price_level, $user);
|
||||||
$object->set_price_level($object->price_level, $user);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Assign sales representative
|
// Assign sales representative
|
||||||
if (! $errorrecord && $fields[3])
|
if (! $errorrecord && $fields[3]) {
|
||||||
{
|
$salesrep=new User($db);
|
||||||
$salesrep=new User($db);
|
|
||||||
|
|
||||||
$tmp=explode(' ', $fields[3], 2);
|
$tmp=explode(' ', $fields[3], 2);
|
||||||
$salesrep->firstname = trim($tmp[0]);
|
$salesrep->firstname = trim($tmp[0]);
|
||||||
$salesrep->lastname = trim($tmp[1]);
|
$salesrep->lastname = trim($tmp[1]);
|
||||||
if ($salesrep->lastname) $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0));
|
if ($salesrep->lastname) {
|
||||||
else $salesrep->login=strtolower($salesrep->firstname);
|
$salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0));
|
||||||
$salesrep->login=preg_replace('/ /', '', $salesrep->login);
|
} else {
|
||||||
$salesrep->fetch(0, $salesrep->login);
|
$salesrep->login=strtolower($salesrep->firstname);
|
||||||
|
}
|
||||||
|
$salesrep->login=preg_replace('/ /', '', $salesrep->login);
|
||||||
|
$salesrep->fetch(0, $salesrep->login);
|
||||||
|
|
||||||
$result = $object->add_commercial($user, $salesrep->id);
|
$result = $object->add_commercial($user, $salesrep->id);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString();
|
||||||
print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString();
|
$errorrecord++;
|
||||||
$errorrecord++;
|
} else {
|
||||||
} else {
|
print " - create link sale representative OK";
|
||||||
print " - create link sale representative OK";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("Add invoice contacts");
|
dol_syslog("Add invoice contacts");
|
||||||
// Insert an invoice contact if there is an invoice email != standard email
|
// Insert an invoice contact if there is an invoice email != standard email
|
||||||
if (! $errorrecord && $fields[27] && $fields[26] != $fields[27])
|
if (! $errorrecord && $fields[27] && $fields[26] != $fields[27]) {
|
||||||
{
|
$ret1=$ret2=0;
|
||||||
$ret1=$ret2=0;
|
|
||||||
|
|
||||||
$contact = new Contact($db);
|
$contact = new Contact($db);
|
||||||
$contact->lastname = $object->name;
|
$contact->lastname = $object->name;
|
||||||
$contact->address=$object->address;
|
$contact->address=$object->address;
|
||||||
$contact->zip=$object->zip;
|
$contact->zip=$object->zip;
|
||||||
$contact->town=$object->town;
|
$contact->town=$object->town;
|
||||||
$contact->country_id=$object->country_id;
|
$contact->country_id=$object->country_id;
|
||||||
$contact->email=$fields[27];
|
$contact->email=$fields[27];
|
||||||
$contact->socid=$object->id;
|
$contact->socid=$object->id;
|
||||||
|
|
||||||
$ret1=$contact->create($user);
|
$ret1=$contact->create($user);
|
||||||
if ($ret1 > 0)
|
if ($ret1 > 0) {
|
||||||
{
|
//$ret2=$contact->add_contact($object->id, 'BILLING');
|
||||||
//$ret2=$contact->add_contact($object->id, 'BILLING');
|
}
|
||||||
}
|
if ($ret1 < 0 || $ret2 < 0) {
|
||||||
if ($ret1 < 0 || $ret2 < 0)
|
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||||
{
|
$errorrecord++;
|
||||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
} else {
|
||||||
$errorrecord++;
|
print " - create contact OK";
|
||||||
} else {
|
}
|
||||||
print " - create contact OK";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("Add delivery contacts");
|
dol_syslog("Add delivery contacts");
|
||||||
// Insert a delivery contact
|
// Insert a delivery contact
|
||||||
if (! $errorrecord && $fields[47])
|
if (! $errorrecord && $fields[47]) {
|
||||||
{
|
$ret1=$ret2=0;
|
||||||
$ret1=$ret2=0;
|
|
||||||
|
|
||||||
$contact2 = new Contact($db);
|
$contact2 = new Contact($db);
|
||||||
$contact2->lastname = 'Service livraison - '.$fields[47];
|
$contact2->lastname = 'Service livraison - '.$fields[47];
|
||||||
$contact2->address = $fields[48];
|
$contact2->address = $fields[48];
|
||||||
$contact2->zip = $fields[50];
|
$contact2->zip = $fields[50];
|
||||||
$contact2->town = $fields[51];
|
$contact2->town = $fields[51];
|
||||||
$contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
|
$contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
|
||||||
$contact2->note_public=$fields[54];
|
$contact2->note_public=$fields[54];
|
||||||
$contact2->socid=$object->id;
|
$contact2->socid=$object->id;
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$contact2->array_options['options_anazoneliv']=price2num($fields[53]);
|
$contact2->array_options['options_anazoneliv']=price2num($fields[53]);
|
||||||
|
|
||||||
$ret1=$contact2->create($user);
|
$ret1=$contact2->create($user);
|
||||||
if ($ret1 > 0)
|
if ($ret1 > 0) {
|
||||||
{
|
//$ret2=$contact2->add_contact($object->id, 'SHIPPING');
|
||||||
//$ret2=$contact2->add_contact($object->id, 'SHIPPING');
|
}
|
||||||
}
|
if ($ret1 < 0 || $ret2 < 0) {
|
||||||
if ($ret1 < 0 || $ret2 < 0)
|
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||||
{
|
$errorrecord++;
|
||||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
} else {
|
||||||
$errorrecord++;
|
print " - create contact OK";
|
||||||
} else {
|
}
|
||||||
print " - create contact OK";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
if ($errorrecord)
|
if ($errorrecord) {
|
||||||
{
|
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
||||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
$error++; // $errorrecord will be reset
|
||||||
$error++; // $errorrecord will be reset
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,13 +287,12 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
|||||||
// commit or rollback
|
// commit or rollback
|
||||||
print "Nb of lines qualified: ".$nboflines."\n";
|
print "Nb of lines qualified: ".$nboflines."\n";
|
||||||
print "Nb of errors: ".$error."\n";
|
print "Nb of errors: ".$error."\n";
|
||||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
|
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||||
{
|
print "Rollback any changes.\n";
|
||||||
print "Rollback any changes.\n";
|
$db->rollback();
|
||||||
$db->rollback();
|
|
||||||
} else {
|
} else {
|
||||||
print "Commit all changes.\n";
|
print "Commit all changes.\n";
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -30,8 +30,8 @@ $sapi_type = php_sapi_name();
|
|||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
$path=dirname(__FILE__).'/';
|
$path=dirname(__FILE__).'/';
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -67,44 +67,40 @@ $startlinenb = empty($argv[3])?1:$argv[3];
|
|||||||
$endlinenb = empty($argv[4])?0:$argv[4];
|
$endlinenb = empty($argv[4])?0:$argv[4];
|
||||||
|
|
||||||
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
||||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (! file_exists($filepath)) {
|
if (! file_exists($filepath)) {
|
||||||
print "Error: File ".$filepath." not found.\n";
|
print "Error: File ".$filepath." not found.\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
// Ask confirmation
|
// Ask confirmation
|
||||||
if (! $confirmed)
|
if (! $confirmed) {
|
||||||
{
|
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
$input = trim(fgets(STDIN));
|
||||||
$input = trim(fgets(STDIN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open input and output files
|
// Open input and output files
|
||||||
$fhandle = fopen($filepath, 'r');
|
$fhandle = fopen($filepath, 'r');
|
||||||
if (! $fhandle)
|
if (! $fhandle) {
|
||||||
{
|
print 'Error: Failed to open file '.$filepath."\n";
|
||||||
print 'Error: Failed to open file '.$filepath."\n";
|
exit(1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
$fhandleerr = fopen($filepatherr, 'w');
|
$fhandleerr = fopen($filepatherr, 'w');
|
||||||
if (! $fhandleerr)
|
if (! $fhandleerr) {
|
||||||
{
|
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
exit(1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//$langs->setDefaultLang($defaultlang);
|
//$langs->setDefaultLang($defaultlang);
|
||||||
@ -114,44 +110,48 @@ $db->begin();
|
|||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$nboflines=0;
|
$nboflines=0;
|
||||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
|
||||||
{
|
$i++;
|
||||||
$i++;
|
$errorrecord=0;
|
||||||
$errorrecord=0;
|
|
||||||
|
|
||||||
if ($startlinenb && $i < $startlinenb) continue;
|
if ($startlinenb && $i < $startlinenb) {
|
||||||
if ($endlinenb && $i > $endlinenb) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($endlinenb && $i > $endlinenb) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$nboflines++;
|
$nboflines++;
|
||||||
|
|
||||||
$object = new User($db);
|
$object = new User($db);
|
||||||
$object->statut = 1;
|
$object->statut = 1;
|
||||||
|
|
||||||
$tmp=explode(' ', $fields[3], 2);
|
$tmp=explode(' ', $fields[3], 2);
|
||||||
$object->firstname = trim($tmp[0]);
|
$object->firstname = trim($tmp[0]);
|
||||||
$object->lastname = trim($tmp[1]);
|
$object->lastname = trim($tmp[1]);
|
||||||
if ($object->lastname) $object->login = strtolower(substr($object->firstname, 0, 1)) . strtolower(substr($object->lastname, 0));
|
if ($object->lastname) {
|
||||||
else $object->login=strtolower($object->firstname);
|
$object->login = strtolower(substr($object->firstname, 0, 1)) . strtolower(substr($object->lastname, 0));
|
||||||
$object->login=preg_replace('/ /', '', $object->login);
|
} else {
|
||||||
$object->password = 'init';
|
$object->login=strtolower($object->firstname);
|
||||||
|
}
|
||||||
|
$object->login=preg_replace('/ /', '', $object->login);
|
||||||
|
$object->password = 'init';
|
||||||
|
|
||||||
print "Process line nb ".$i.", login ".$object->login;
|
print "Process line nb ".$i.", login ".$object->login;
|
||||||
|
|
||||||
$ret=$object->create($user);
|
$ret=$object->create($user);
|
||||||
if ($ret < 0)
|
if ($ret < 0) {
|
||||||
{
|
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
||||||
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
$errorrecord++;
|
||||||
$errorrecord++;
|
} else {
|
||||||
} else {
|
print " - Creation OK with login ".$object->login." - id = ".$ret;
|
||||||
print " - Creation OK with login ".$object->login." - id = ".$ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
if ($errorrecord)
|
if ($errorrecord) {
|
||||||
{
|
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
||||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
$error++; // $errorrecord will be reset
|
||||||
$error++; // $errorrecord will be reset
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,13 +162,12 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
|||||||
// commit or rollback
|
// commit or rollback
|
||||||
print "Nb of lines qualified: ".$nboflines."\n";
|
print "Nb of lines qualified: ".$nboflines."\n";
|
||||||
print "Nb of errors: ".$error."\n";
|
print "Nb of errors: ".$error."\n";
|
||||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
|
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||||
{
|
print "Rollback any changes.\n";
|
||||||
print "Rollback any changes.\n";
|
$db->rollback();
|
||||||
$db->rollback();
|
|
||||||
} else {
|
} else {
|
||||||
print "Commit all changes.\n";
|
print "Commit all changes.\n";
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -30,8 +30,8 @@ $path=__DIR__.'/';
|
|||||||
|
|
||||||
// Test si mode batch
|
// Test si mode batch
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere root dolibarr
|
// Recupere root dolibarr
|
||||||
@ -52,121 +52,121 @@ $error=0;
|
|||||||
|
|
||||||
// List of sql to execute
|
// List of sql to execute
|
||||||
$sqls=array(
|
$sqls=array(
|
||||||
'user'=>array(
|
'user'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user IN (SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin') AND fk_user IN (select rowid FROM ".MAIN_DB_PREFIX."user where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user IN (SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin') AND fk_user IN (select rowid FROM ".MAIN_DB_PREFIX."user where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin' AND datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin' AND datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'event'=>array(
|
'event'=>array(
|
||||||
//"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
//"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'payment'=>array(
|
'payment'=>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_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)",
|
"DELETE FROM ".MAIN_DB_PREFIX."paiement where rowid NOT IN (SELECT fk_paiement FROM ".MAIN_DB_PREFIX."paiement_facture)",
|
||||||
),
|
),
|
||||||
'supplier_payment'=>array(
|
'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_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)",
|
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn where rowid NOT IN (SELECT fk_paiementfourn FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn)",
|
||||||
),
|
),
|
||||||
'bank'=>array(
|
'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_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__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'bankaccount'=>array(
|
'bankaccount'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_account WHERE datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."bank_account WHERE datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'invoice'=>array(
|
'invoice'=>array(
|
||||||
'@payment',
|
'@payment',
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_source IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_source IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_line IN (select rowid FROM ".MAIN_DB_PREFIX."facturedet as fd WHERE fd.fk_facture IN (select rowid from ".MAIN_DB_PREFIX."facture where datec < '__DATE__'))",
|
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_line IN (select rowid FROM ".MAIN_DB_PREFIX."facturedet as fd WHERE fd.fk_facture IN (select rowid from ".MAIN_DB_PREFIX."facture where datec < '__DATE__'))",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_rec where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."facture_rec where datec < '__DATE__'",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||||
"UPDATE ".MAIN_DB_PREFIX."facture SET fk_facture_source = NULL WHERE fk_facture_source IN (select f2.rowid FROM (select * from ".MAIN_DB_PREFIX."facture) as f2 where f2.datec < '__DATE__')",
|
"UPDATE ".MAIN_DB_PREFIX."facture SET fk_facture_source = NULL WHERE fk_facture_source IN (select f2.rowid FROM (select * from ".MAIN_DB_PREFIX."facture) as f2 where f2.datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'accounting'=>array(
|
'accounting'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."accounting_bookkeeping where doc_date < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."accounting_bookkeeping where doc_date < '__DATE__'",
|
||||||
),
|
),
|
||||||
'proposal'=>array(
|
'proposal'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."propal WHERE datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."propal WHERE datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
"supplier_proposal"=>array(
|
"supplier_proposal"=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE fk_supplier_proposal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE fk_supplier_proposal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposal where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposal where datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'order'=>array(
|
'order'=>array(
|
||||||
'@shipment',
|
'@shipment',
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__'",
|
||||||
),
|
),
|
||||||
'supplier_order'=>array(
|
'supplier_order'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__'",
|
||||||
),
|
),
|
||||||
'supplier_invoice'=>array(
|
'supplier_invoice'=>array(
|
||||||
'@supplier_payment',
|
'@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_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__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'shipment'=>array(
|
'shipment'=>array(
|
||||||
'@delivery',
|
'@delivery',
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch WHERE fk_expeditiondet IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch WHERE fk_expeditiondet IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."expedition_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."expedition_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'",
|
||||||
),
|
),
|
||||||
'delivery'=>array(
|
'delivery'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."deliverydet WHERE fk_delivery IN (select rowid FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."deliverydet WHERE fk_delivery IN (select rowid FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__'",
|
||||||
),
|
),
|
||||||
'contract'=>array(
|
'contract'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."contratdet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__'))",
|
"DELETE FROM ".MAIN_DB_PREFIX."contratdet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__'))",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."contrat_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."contrat_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."contrat WHERE datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."contrat WHERE datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'intervention'=>array(
|
'intervention'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE fk_fichinter IN (select rowid FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE fk_fichinter IN (select rowid FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'stock'=>array(
|
'stock'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement WHERE datem < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement WHERE datem < '__DATE__'",
|
||||||
),
|
),
|
||||||
'product'=>array(
|
'product'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product_lang WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."product_lang WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty WHERE fk_product_price IN (select rowid FROM ".MAIN_DB_PREFIX."product_price where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
"DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty WHERE fk_product_price IN (select rowid FROM ".MAIN_DB_PREFIX."product_price where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."product_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE fk_product_stock IN (select rowid FROM ".MAIN_DB_PREFIX."product_stock where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
"DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE fk_product_stock IN (select rowid FROM ".MAIN_DB_PREFIX."product_stock where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product_lot WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."product_lot WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'project'=>array(
|
'project'=>array(
|
||||||
// TODO set fk_project to null on object that refer to project
|
// TODO set fk_project to null on object that refer to project
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_task IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
|
"DELETE FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_task IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'contact'=>array(
|
'contact'=>array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople IN (select rowid FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople IN (select rowid FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__'",
|
||||||
),
|
),
|
||||||
'thirdparty'=>array(
|
'thirdparty'=>array(
|
||||||
'@contact',
|
'@contact',
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."cabinetmed_cons WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."cabinetmed_cons WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||||
"UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = NULL WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
"UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = NULL WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_fournisseur WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."categorie_fournisseur WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
"DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__'",
|
"DELETE FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__'",
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -183,44 +183,42 @@ $option = $argv[2];
|
|||||||
$date = $argv[3];
|
$date = $argv[3];
|
||||||
|
|
||||||
if (empty($mode) || ! in_array($mode, array('test','confirm'))) {
|
if (empty($mode) || ! in_array($mode, array('test','confirm'))) {
|
||||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "option can be ".implode(',', array_keys($sqls))."\n";
|
print "option can be ".implode(',', array_keys($sqls))."\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (empty($option))
|
if (empty($option)) {
|
||||||
{
|
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
print "\n";
|
||||||
print "\n";
|
print "option must be defined with a value in list ".implode(',', array_keys($sqls))."\n";
|
||||||
print "option must be defined with a value in list ".implode(',', array_keys($sqls))."\n";
|
exit(-1);
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
if ($option != 'all')
|
if ($option != 'all') {
|
||||||
{
|
$listofoptions=explode(',', $option);
|
||||||
$listofoptions=explode(',', $option);
|
foreach ($listofoptions as $cursoroption) {
|
||||||
foreach ($listofoptions as $cursoroption)
|
if (! in_array($cursoroption, array_keys($sqls))) {
|
||||||
{
|
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||||
if (! in_array($cursoroption, array_keys($sqls))) {
|
print "\n";
|
||||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
print "option '".$cursoroption."' must be in list ".implode(',', array_keys($sqls))."\n";
|
||||||
print "\n";
|
exit(-1);
|
||||||
print "option '".$cursoroption."' must be in list ".implode(',', array_keys($sqls))."\n";
|
}
|
||||||
exit(-1);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($date) || (! preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date != 'all')) {
|
if (empty($date) || (! preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date != 'all')) {
|
||||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "date can be 'all' or 'YYYY-MM-DD' to delete record before YYYY-MM-DD\n";
|
print "date can be 'all' or 'YYYY-MM-DD' to delete record before YYYY-MM-DD\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($date == 'all') $date = '2199-01-01';
|
if ($date == 'all') {
|
||||||
|
$date = '2199-01-01';
|
||||||
|
}
|
||||||
|
|
||||||
// Replace database handler
|
// Replace database handler
|
||||||
if (! empty($argv[4]))
|
if (! empty($argv[4])) {
|
||||||
{
|
|
||||||
$db->close();
|
$db->close();
|
||||||
unset($db);
|
unset($db);
|
||||||
$db=getDoliDBInstance($argv[4], $argv[5], $argv[6], $argv[7], $argv[8], $argv[9]);
|
$db=getDoliDBInstance($argv[4], $argv[5], $argv[6], $argv[7], $argv[8], $argv[9]);
|
||||||
@ -229,8 +227,7 @@ if (! empty($argv[4]))
|
|||||||
|
|
||||||
//var_dump($user->db->database_name);
|
//var_dump($user->db->database_name);
|
||||||
$ret=$user->fetch('', 'admin');
|
$ret=$user->fetch('', 'admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0) {
|
||||||
{
|
|
||||||
print 'An admin user with login "admin" must exists to use this script.'."\n";
|
print 'An admin user with login "admin" must exists to use this script.'."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -245,10 +242,9 @@ print "Database port = ".$db->database_port."\n";
|
|||||||
print "User = ".$db->database_user."\n";
|
print "User = ".$db->database_user."\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
if (! $confirmed)
|
if (! $confirmed) {
|
||||||
{
|
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
$input = trim(fgets(STDIN));
|
||||||
$input = trim(fgets(STDIN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -261,73 +257,71 @@ if (! $confirmed)
|
|||||||
*/
|
*/
|
||||||
function processfamily($family, $date)
|
function processfamily($family, $date)
|
||||||
{
|
{
|
||||||
global $db, $sqls;
|
global $db, $sqls;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
foreach ($sqls[$family] as $sql)
|
foreach ($sqls[$family] as $sql) {
|
||||||
{
|
if (preg_match('/^@/', $sql)) {
|
||||||
if (preg_match('/^@/', $sql))
|
$newfamily=preg_replace('/@/', '', $sql);
|
||||||
{
|
processfamily($newfamily, $date);
|
||||||
$newfamily=preg_replace('/@/', '', $sql);
|
continue;
|
||||||
processfamily($newfamily, $date);
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = preg_replace('/__DATE__/', $date, $sql);
|
$sql = preg_replace('/__DATE__/', $date, $sql);
|
||||||
|
|
||||||
print "Run sql: ".$sql."\n";
|
print "Run sql: ".$sql."\n";
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql) {
|
||||||
{
|
if ($db->errno() != 'DB_ERROR_NOSUCHTABLE') {
|
||||||
if ($db->errno() != 'DB_ERROR_NOSUCHTABLE')
|
$error++;
|
||||||
{
|
}
|
||||||
$error++;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($error)
|
if ($error) {
|
||||||
{
|
print $db->lasterror();
|
||||||
print $db->lasterror();
|
$error++;
|
||||||
$error++;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($error) return -1;
|
if ($error) {
|
||||||
else return 1;
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$listofoptions=explode(',', $option);
|
$listofoptions=explode(',', $option);
|
||||||
foreach ($listofoptions as $cursoroption)
|
foreach ($listofoptions as $cursoroption) {
|
||||||
{
|
$oldfamily='';
|
||||||
$oldfamily='';
|
foreach ($sqls as $family => $familysql) {
|
||||||
foreach ($sqls as $family => $familysql)
|
if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) {
|
||||||
{
|
continue;
|
||||||
if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) continue;
|
}
|
||||||
|
|
||||||
if ($family != $oldfamily) print "Process action for family ".$family."\n";
|
if ($family != $oldfamily) {
|
||||||
$oldfamily = $family;
|
print "Process action for family ".$family."\n";
|
||||||
|
}
|
||||||
|
$oldfamily = $family;
|
||||||
|
|
||||||
$result=processfamily($family, $date);
|
$result=processfamily($family, $date);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
$error++;
|
||||||
$error++;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error || $mode != 'confirm')
|
if ($error || $mode != 'confirm') {
|
||||||
{
|
print "\nRollback any changes.\n";
|
||||||
print "\nRollback any changes.\n";
|
$db->rollback();
|
||||||
$db->rollback();
|
|
||||||
} else {
|
} else {
|
||||||
print "Commit all changes.\n";
|
print "Commit all changes.\n";
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -41,14 +41,30 @@ $passwordbase=isset($argv[6])?$argv[6]:'';
|
|||||||
|
|
||||||
// Include Dolibarr environment
|
// Include Dolibarr environment
|
||||||
$res=0;
|
$res=0;
|
||||||
if (! $res && file_exists($path."../../master.inc.php")) $res=@include $path."../../master.inc.php";
|
if (! $res && file_exists($path."../../master.inc.php")) {
|
||||||
if (! $res && file_exists($path."../../htdocs/master.inc.php")) $res=@include $path."../../htdocs/master.inc.php";
|
$res=@include $path."../../master.inc.php";
|
||||||
if (! $res && file_exists("../master.inc.php")) $res=@include "../master.inc.php";
|
}
|
||||||
if (! $res && file_exists("../../master.inc.php")) $res=@include "../../master.inc.php";
|
if (! $res && file_exists($path."../../htdocs/master.inc.php")) {
|
||||||
if (! $res && file_exists("../../../master.inc.php")) $res=@include "../../../master.inc.php";
|
$res=@include $path."../../htdocs/master.inc.php";
|
||||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
}
|
||||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
if (! $res && file_exists("../master.inc.php")) {
|
||||||
if (! $res) die("Failed to include master.inc.php file\n");
|
$res=@include "../master.inc.php";
|
||||||
|
}
|
||||||
|
if (! $res && file_exists("../../master.inc.php")) {
|
||||||
|
$res=@include "../../master.inc.php";
|
||||||
|
}
|
||||||
|
if (! $res && file_exists("../../../master.inc.php")) {
|
||||||
|
$res=@include "../../../master.inc.php";
|
||||||
|
}
|
||||||
|
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||||
|
$res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||||
|
}
|
||||||
|
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||||
|
$res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||||
|
}
|
||||||
|
if (! $res) {
|
||||||
|
die("Failed to include master.inc.php file\n");
|
||||||
|
}
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
|
|
||||||
@ -58,15 +74,13 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|||||||
|
|
||||||
$login='';
|
$login='';
|
||||||
$server='';
|
$server='';
|
||||||
if (preg_match('/^(.*)@(.*):(.*)$/', $sourceserver, $reg))
|
if (preg_match('/^(.*)@(.*):(.*)$/', $sourceserver, $reg)) {
|
||||||
{
|
|
||||||
$login=$reg[1];
|
$login=$reg[1];
|
||||||
$server=$reg[2];
|
$server=$reg[2];
|
||||||
$sourcefile=$reg[3];
|
$sourcefile=$reg[3];
|
||||||
$targetfile=basename($sourcefile);
|
$targetfile=basename($sourcefile);
|
||||||
}
|
}
|
||||||
if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase))
|
if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase)) {
|
||||||
{
|
|
||||||
print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n";
|
print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n";
|
||||||
print "Return code: 0 if success, <>0 if error\n";
|
print "Return code: 0 if success, <>0 if error\n";
|
||||||
print "Warning, this script may take a long time.\n";
|
print "Warning, this script may take a long time.\n";
|
||||||
@ -88,14 +102,11 @@ if (! function_exists("ssh2_connect")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$connection = ssh2_connect($server, 22);
|
$connection = ssh2_connect($server, 22);
|
||||||
if ($connection)
|
if ($connection) {
|
||||||
{
|
if (! @ssh2_auth_password($connection, $login, $password)) {
|
||||||
if (! @ssh2_auth_password($connection, $login, $password))
|
|
||||||
{
|
|
||||||
dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR);
|
dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR);
|
||||||
exit(-5);
|
exit(-5);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//$stream = ssh2_exec($connection, '/usr/bin/php -i');
|
//$stream = ssh2_exec($connection, '/usr/bin/php -i');
|
||||||
/*
|
/*
|
||||||
print "Generate dump ".$filesys1.'.bz2'."\n";
|
print "Generate dump ".$filesys1.'.bz2'."\n";
|
||||||
@ -111,12 +122,10 @@ if ($connection)
|
|||||||
ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile);
|
ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile);
|
||||||
|
|
||||||
$fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
$fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||||
if (preg_match('/\.bz2$/', $targetfile))
|
if (preg_match('/\.bz2$/', $targetfile)) {
|
||||||
{
|
|
||||||
$fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
$fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||||
}
|
}
|
||||||
if (preg_match('/\.gz$/', $targetfile))
|
if (preg_match('/\.gz$/', $targetfile)) {
|
||||||
{
|
|
||||||
$fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
$fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||||
}
|
}
|
||||||
print "Load dump with ".$fullcommand."\n";
|
print "Load dump with ".$fullcommand."\n";
|
||||||
@ -124,13 +133,14 @@ if ($connection)
|
|||||||
$return_var=0;
|
$return_var=0;
|
||||||
print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n";
|
print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n";
|
||||||
exec($fullcommand, $output, $return_var);
|
exec($fullcommand, $output, $return_var);
|
||||||
foreach ($output as $line) print $line."\n";
|
foreach ($output as $line) {
|
||||||
|
print $line."\n";
|
||||||
|
}
|
||||||
|
|
||||||
//ssh2_sftp_unlink($sftp, $fileinstalllock);
|
//ssh2_sftp_unlink($sftp, $fileinstalllock);
|
||||||
//print $output;
|
//print $output;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
print 'Failed to connect to ssh2 to '.$server;
|
print 'Failed to connect to ssh2 to '.$server;
|
||||||
exit(-6);
|
exit(-6);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,14 +36,30 @@ $confirm=isset($argv[1])?$argv[1]:'';
|
|||||||
|
|
||||||
// Include Dolibarr environment
|
// Include Dolibarr environment
|
||||||
$res=0;
|
$res=0;
|
||||||
if (! $res && file_exists($path."../../master.inc.php")) $res=@include $path."../../master.inc.php";
|
if (! $res && file_exists($path."../../master.inc.php")) {
|
||||||
if (! $res && file_exists($path."../../htdocs/master.inc.php")) $res=@include $path."../../htdocs/master.inc.php";
|
$res=@include $path."../../master.inc.php";
|
||||||
if (! $res && file_exists("../master.inc.php")) $res=@include "../master.inc.php";
|
}
|
||||||
if (! $res && file_exists("../../master.inc.php")) $res=@include "../../master.inc.php";
|
if (! $res && file_exists($path."../../htdocs/master.inc.php")) {
|
||||||
if (! $res && file_exists("../../../master.inc.php")) $res=@include "../../../master.inc.php";
|
$res=@include $path."../../htdocs/master.inc.php";
|
||||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
}
|
||||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
if (! $res && file_exists("../master.inc.php")) {
|
||||||
if (! $res) die("Failed to include master.inc.php file\n");
|
$res=@include "../master.inc.php";
|
||||||
|
}
|
||||||
|
if (! $res && file_exists("../../master.inc.php")) {
|
||||||
|
$res=@include "../../master.inc.php";
|
||||||
|
}
|
||||||
|
if (! $res && file_exists("../../../master.inc.php")) {
|
||||||
|
$res=@include "../../../master.inc.php";
|
||||||
|
}
|
||||||
|
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||||
|
$res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||||
|
}
|
||||||
|
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||||
|
$res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||||
|
}
|
||||||
|
if (! $res) {
|
||||||
|
die("Failed to include master.inc.php file\n");
|
||||||
|
}
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
|
|
||||||
@ -53,8 +69,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|||||||
|
|
||||||
print "***** ".$script_file." *****\n";
|
print "***** ".$script_file." *****\n";
|
||||||
print "Update dates to current year for database name = ".$db->database_name."\n";
|
print "Update dates to current year for database name = ".$db->database_name."\n";
|
||||||
if (empty($confirm))
|
if (empty($confirm)) {
|
||||||
{
|
|
||||||
print "Usage: $script_file confirm\n";
|
print "Usage: $script_file confirm\n";
|
||||||
print "Return code: 0 if success, <>0 if error\n";
|
print "Return code: 0 if success, <>0 if error\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -65,66 +80,65 @@ $tmp=dol_getdate(dol_now());
|
|||||||
|
|
||||||
|
|
||||||
$tables=array(
|
$tables=array(
|
||||||
'propal'=>array(0=>'datep', 1=>'fin_validite', 2=>'date_valid', 3=>'date_cloture'),
|
'propal'=>array(0=>'datep', 1=>'fin_validite', 2=>'date_valid', 3=>'date_cloture'),
|
||||||
'commande'=>array(0=>'date_commande', 1=>'date_valid', 2=>'date_cloture'),
|
'commande'=>array(0=>'date_commande', 1=>'date_valid', 2=>'date_cloture'),
|
||||||
'facture'=>array(0=>'datec', 0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'),
|
'facture'=>array(0=>'datec', 0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'),
|
||||||
'paiement'=>array(0=>'datep'),
|
'paiement'=>array(0=>'datep'),
|
||||||
'bank'=>array(0=>'datev', 1=>'dateo'),
|
'bank'=>array(0=>'datev', 1=>'dateo'),
|
||||||
'commande_fournisseur'=>array(0=>'date_commande', 1=>'date_valid', 3=>'date_creation', 4=>'date_approve', 5=>'date_approve2', 6=>'date_livraison'),
|
'commande_fournisseur'=>array(0=>'date_commande', 1=>'date_valid', 3=>'date_creation', 4=>'date_approve', 5=>'date_approve2', 6=>'date_livraison'),
|
||||||
'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture'),
|
'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture'),
|
||||||
'expensereport'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 4=>'date_approve', 5=>'date_refuse', 6=>'date_cancel'),
|
'expensereport'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 4=>'date_approve', 5=>'date_refuse', 6=>'date_cancel'),
|
||||||
'holiday'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 5=>'date_refuse', 6=>'date_cancel')
|
'holiday'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 5=>'date_refuse', 6=>'date_cancel'),
|
||||||
|
'ticket'=>array(0=>'datec', 1=>'date_read', 2=>'date_close')
|
||||||
);
|
);
|
||||||
|
|
||||||
$year=2010;
|
$year=2010;
|
||||||
$currentyear=$tmp['year'];
|
$currentyear=$tmp['year'];
|
||||||
while ($year <= $currentyear)
|
while ($year <= $currentyear) {
|
||||||
{
|
//$year=2021;
|
||||||
//$year=2021;
|
$delta1=($currentyear - $year);
|
||||||
$delta1=($currentyear - $year);
|
$delta2=($currentyear - $year - 1);
|
||||||
$delta2=($currentyear - $year - 1);
|
//$delta=-1;
|
||||||
//$delta=-1;
|
|
||||||
|
|
||||||
if ($delta1)
|
if ($delta1) {
|
||||||
{
|
foreach ($tables as $tablekey => $tableval) {
|
||||||
foreach ($tables as $tablekey => $tableval)
|
print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." ";
|
||||||
{
|
$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)";
|
||||||
print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." ";
|
//$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." > NOW()";
|
||||||
$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)";
|
$resql = $db->query($sql);
|
||||||
//$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." > NOW()";
|
if ($resql) {
|
||||||
$resql = $db->query($sql);
|
$num = $db->num_rows($resql);
|
||||||
if ($resql)
|
$i=0;
|
||||||
{
|
while ($i < $num) {
|
||||||
$num = $db->num_rows($resql);
|
$obj=$db->fetch_object($resql);
|
||||||
$i=0;
|
if ($obj) {
|
||||||
while ($i < $num)
|
print ".";
|
||||||
{
|
$sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set ";
|
||||||
$obj=$db->fetch_object($resql);
|
$j=0;
|
||||||
if ($obj)
|
foreach ($tableval as $field) {
|
||||||
{
|
if ($j) {
|
||||||
print ".";
|
$sql2.=", ";
|
||||||
$sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set ";
|
}
|
||||||
$j=0;
|
$sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)");
|
||||||
foreach ($tableval as $field)
|
$j++;
|
||||||
{
|
}
|
||||||
if ($j) $sql2.=", ";
|
$sql2.=" WHERE rowid = ".$obj->rowid;
|
||||||
$sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)");
|
//print $sql2."\n";
|
||||||
$j++;
|
$resql2 = $db->query($sql2);
|
||||||
}
|
if (! $resql2) {
|
||||||
$sql2.=" WHERE rowid = ".$obj->rowid;
|
dol_print_error($db);
|
||||||
//print $sql2."\n";
|
}
|
||||||
$resql2 = $db->query($sql2);
|
}
|
||||||
if (! $resql2) dol_print_error($db);
|
$i++;
|
||||||
}
|
}
|
||||||
$i++;
|
} else {
|
||||||
}
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
else dol_print_error($db);
|
print "\n";
|
||||||
print "\n";
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$year++;
|
$year++;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<exclude-pattern type="relative">build/html</exclude-pattern>
|
<exclude-pattern type="relative">build/html</exclude-pattern>
|
||||||
<exclude-pattern type="relative">build/aps</exclude-pattern>
|
<exclude-pattern type="relative">build/aps</exclude-pattern>
|
||||||
<exclude-pattern type="relative">dev/tools/test/namespacemig</exclude-pattern>
|
<exclude-pattern type="relative">dev/tools/test/namespacemig</exclude-pattern>
|
||||||
<exclude-pattern type="relative">dev/initdata/dbf/includes</exclude-pattern>
|
<!-- <exclude-pattern type="relative">dev/initdata/dbf/includes</exclude-pattern> -->
|
||||||
<exclude-pattern type="relative">documents</exclude-pattern>
|
<exclude-pattern type="relative">documents</exclude-pattern>
|
||||||
<exclude-pattern type="relative">htdocs/core/class/lessc.class.php</exclude-pattern>
|
<exclude-pattern type="relative">htdocs/core/class/lessc.class.php</exclude-pattern>
|
||||||
<exclude-pattern type="relative">htdocs/custom</exclude-pattern>
|
<exclude-pattern type="relative">htdocs/custom</exclude-pattern>
|
||||||
@ -104,9 +104,9 @@
|
|||||||
</rule>
|
</rule>
|
||||||
-->
|
-->
|
||||||
<!-- We want to allow 'if () { ...small code... }' on same line for better code compacity and readability -->
|
<!-- We want to allow 'if () { ...small code... }' on same line for better code compacity and readability -->
|
||||||
<rule ref="Generic.Formatting.DisallowMultipleStatements">
|
<!-- <rule ref="Generic.Formatting.DisallowMultipleStatements">
|
||||||
<severity>0</severity>
|
<severity>0</severity>
|
||||||
</rule>
|
</rule> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Check assignement have the = align on each line. Have 20 chars padding maximum and always show as errors -->
|
<!-- Check assignement have the = align on each line. Have 20 chars padding maximum and always show as errors -->
|
||||||
@ -174,8 +174,8 @@
|
|||||||
<rule ref="Generic.Strings.UnnecessaryStringConcat.Found">
|
<rule ref="Generic.Strings.UnnecessaryStringConcat.Found">
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Disallow usage of tab -->
|
<!-- Disallow usage of space -->
|
||||||
<!-- <rule ref="Generic.WhiteSpace.DisallowTabIndent" /> -->
|
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
|
||||||
|
|
||||||
<!-- Check indent are done with spaces and with correct number -->
|
<!-- Check indent are done with spaces and with correct number -->
|
||||||
<!-- Disabled as this does not support tab -->
|
<!-- Disabled as this does not support tab -->
|
||||||
@ -214,8 +214,8 @@
|
|||||||
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
|
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
|
||||||
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
|
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
|
||||||
|
|
||||||
<!-- <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis" /> -->
|
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis" />
|
||||||
<!-- <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" /> -->
|
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" />
|
||||||
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword" />
|
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword" />
|
||||||
|
|
||||||
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen" />
|
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen" />
|
||||||
|
|||||||
@ -48,8 +48,9 @@ if (! ($argv[1] && $argv[2])) {
|
|||||||
echo "Usage: php pg2mysql_cli.php <inputfilename> <outputfilename> [engine]\n";
|
echo "Usage: php pg2mysql_cli.php <inputfilename> <outputfilename> [engine]\n";
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
if (isset($argv[3]))
|
if (isset($argv[3])) {
|
||||||
$config['engine'] = $argv[3];
|
$config['engine'] = $argv[3];
|
||||||
|
}
|
||||||
pg2mysql_large($argv[1], $argv[2]);
|
pg2mysql_large($argv[1], $argv[2]);
|
||||||
|
|
||||||
echo <<<XHTML
|
echo <<<XHTML
|
||||||
@ -74,14 +75,18 @@ function getfieldname($l)
|
|||||||
// first check if its in nice quotes for us
|
// first check if its in nice quotes for us
|
||||||
$regs = array();
|
$regs = array();
|
||||||
if (preg_match("/`(.*)`/", $l, $regs)) {
|
if (preg_match("/`(.*)`/", $l, $regs)) {
|
||||||
if ($regs[1])
|
if ($regs[1]) {
|
||||||
return $regs[1];
|
return $regs[1];
|
||||||
else return null;
|
} else {
|
||||||
} // if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space.
|
return null;
|
||||||
elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) {
|
}
|
||||||
if ($regs[1])
|
} elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) {
|
||||||
|
// if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space.
|
||||||
|
if ($regs[1]) {
|
||||||
return $regs[1];
|
return $regs[1];
|
||||||
else return null;
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,13 +99,15 @@ function getfieldname($l)
|
|||||||
*/
|
*/
|
||||||
function formatsize($s)
|
function formatsize($s)
|
||||||
{
|
{
|
||||||
if ($s < pow(2, 14))
|
if ($s < pow(2, 14)) {
|
||||||
return "{$s}B";
|
return "{$s}B";
|
||||||
elseif ($s < pow(2, 20))
|
} elseif ($s < pow(2, 20)) {
|
||||||
return sprintf("%.1f", round($s / 1024, 1)) . "K";
|
return sprintf("%.1f", round($s / 1024, 1)) . "K";
|
||||||
elseif ($s < pow(2, 30))
|
} elseif ($s < pow(2, 30)) {
|
||||||
return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M";
|
return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M";
|
||||||
else return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G";
|
} else {
|
||||||
|
return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,9 +148,11 @@ function pg2mysql_large($infilename, $outfilename)
|
|||||||
$c = substr_count($instr, "'");
|
$c = substr_count($instr, "'");
|
||||||
// we have an odd number of ' marks
|
// we have an odd number of ' marks
|
||||||
if ($c % 2 != 0) {
|
if ($c % 2 != 0) {
|
||||||
if ($inquotes)
|
if ($inquotes) {
|
||||||
$inquotes = false;
|
$inquotes = false;
|
||||||
else $inquotes = true;
|
} else {
|
||||||
|
$inquotes = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($linenum % 10000 == 0) {
|
if ($linenum % 10000 == 0) {
|
||||||
@ -323,9 +332,11 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
|||||||
$line = str_replace(" bool DEFAULT false", " bool DEFAULT 0", $line);
|
$line = str_replace(" bool DEFAULT false", " bool DEFAULT 0", $line);
|
||||||
if (preg_match("/ character varying\(([0-9]*)\)/", $line, $regs)) {
|
if (preg_match("/ character varying\(([0-9]*)\)/", $line, $regs)) {
|
||||||
$num = $regs[1];
|
$num = $regs[1];
|
||||||
if ($num <= 255)
|
if ($num <= 255) {
|
||||||
$line = preg_replace("/ character varying\([0-9]*\)/", " varchar($num)", $line);
|
$line = preg_replace("/ character varying\([0-9]*\)/", " varchar($num)", $line);
|
||||||
else $line = preg_replace("/ character varying\([0-9]*\)/", " text", $line);
|
} else {
|
||||||
|
$line = preg_replace("/ character varying\([0-9]*\)/", " text", $line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// character varying with no size, we will default to varchar(255)
|
// character varying with no size, we will default to varchar(255)
|
||||||
if (preg_match("/ character varying/", $line)) {
|
if (preg_match("/ character varying/", $line)) {
|
||||||
@ -345,9 +356,11 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
|||||||
$line = preg_replace("/::.*$/", "\n", $line);
|
$line = preg_replace("/::.*$/", "\n", $line);
|
||||||
if (preg_match("/character\(([0-9]*)\)/", $line, $regs)) {
|
if (preg_match("/character\(([0-9]*)\)/", $line, $regs)) {
|
||||||
$num = $regs[1];
|
$num = $regs[1];
|
||||||
if ($num <= 255)
|
if ($num <= 255) {
|
||||||
$line = preg_replace("/ character\([0-9]*\)/", " varchar($num)", $line);
|
$line = preg_replace("/ character\([0-9]*\)/", " varchar($num)", $line);
|
||||||
else $line = preg_replace("/ character\([0-9]*\)/", " text", $line);
|
} else {
|
||||||
|
$line = preg_replace("/ character\([0-9]*\)/", " text", $line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// timestamps
|
// timestamps
|
||||||
$line = str_replace(" timestamp with time zone", " datetime", $line);
|
$line = str_replace(" timestamp with time zone", " datetime", $line);
|
||||||
@ -457,9 +470,11 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
|||||||
$c = substr_count($line, "'");
|
$c = substr_count($line, "'");
|
||||||
// we have an odd number of ' marks
|
// we have an odd number of ' marks
|
||||||
if ($c % 2 != 0) {
|
if ($c % 2 != 0) {
|
||||||
if ($inquotes)
|
if ($inquotes) {
|
||||||
$inquotes = false;
|
$inquotes = false;
|
||||||
else $inquotes = true;
|
} else {
|
||||||
|
$inquotes = true;
|
||||||
|
}
|
||||||
// echo "inquotes=$inquotes\n";
|
// echo "inquotes=$inquotes\n";
|
||||||
}
|
}
|
||||||
} while (substr($lines[$linenumber], - 3, - 1) != ");" || $inquotes);
|
} while (substr($lines[$linenumber], - 3, - 1) != ");" || $inquotes);
|
||||||
@ -524,8 +539,9 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($line, 0, 13) == 'DROP DATABASE')
|
if (substr($line, 0, 13) == 'DROP DATABASE') {
|
||||||
$output .= $line;
|
$output .= $line;
|
||||||
|
}
|
||||||
|
|
||||||
if (substr($line, 0, 15) == 'CREATE DATABASE') {
|
if (substr($line, 0, 15) == 'CREATE DATABASE') {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use Dolibarr\Aaa as Aaa;
|
use Dolibarr\Aaa as Aaa;
|
||||||
use function Dolibarr\faaa as faaa; // Need php 5.6+
|
use function Dolibarr\faaa as faaa; // Need php 5.6+
|
||||||
|
|
||||||
//use const Dolibarr\AAA;
|
//use const Dolibarr\AAA;
|
||||||
|
|
||||||
//use Bbb as Bbb;
|
//use Bbb as Bbb;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*spl_autoload_register(function ($class_name) {
|
/*spl_autoload_register(function ($class_name) {
|
||||||
var_dump('class='.$class_name);
|
var_dump('class='.$class_name);
|
||||||
require $class_name;
|
require $class_name;
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -3,10 +3,11 @@
|
|||||||
$a = microtime(true);
|
$a = microtime(true);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < 1000000)
|
while ($i < 1000000) {
|
||||||
{
|
|
||||||
$key = '1234567890111213141516171819'.$i;
|
$key = '1234567890111213141516171819'.$i;
|
||||||
if ($i == 1000) $key = 'MAIN_MODULE_AAAAAiiiiiiiiiiiiiiiiiiiiiiiiiiiii';
|
if ($i == 1000) {
|
||||||
|
$key = 'MAIN_MODULE_AAAAAiiiiiiiiiiiiiiiiiiiiiiiiiiiii';
|
||||||
|
}
|
||||||
|
|
||||||
//if (preg_match('/^MAIN_MODULE_/', $key)) {
|
//if (preg_match('/^MAIN_MODULE_/', $key)) {
|
||||||
//if (substr($key, 0, 12) == 'MAIN_MODULE_') {
|
//if (substr($key, 0, 12) == 'MAIN_MODULE_') {
|
||||||
|
|||||||
@ -38,25 +38,25 @@ $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8',
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
The permission array is composed of values taken from the following ones (specify the ones you want to block):
|
The permission array is composed of values taken from the following ones (specify the ones you want to block):
|
||||||
- print : Print the document;
|
- print : Print the document;
|
||||||
- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
|
- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
|
||||||
- copy : Copy or otherwise extract text and graphics from the document;
|
- copy : Copy or otherwise extract text and graphics from the document;
|
||||||
- annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
|
- annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
|
||||||
- fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
|
- fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
|
||||||
- extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
|
- extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
|
||||||
- assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
|
- assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
|
||||||
- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
|
- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
|
||||||
- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
|
- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
|
||||||
|
|
||||||
If you don't set any password, the document will open as usual.
|
If you don't set any password, the document will open as usual.
|
||||||
If you set a user password, the PDF viewer will ask for it before displaying the document.
|
If you set a user password, the PDF viewer will ask for it before displaying the document.
|
||||||
The master (owner) password, if different from the user one, can be used to get full document access.
|
The master (owner) password, if different from the user one, can be used to get full document access.
|
||||||
|
|
||||||
Possible encryption modes are:
|
Possible encryption modes are:
|
||||||
0 = RSA 40 bit
|
0 = RSA 40 bit
|
||||||
1 = RSA 128 bit
|
1 = RSA 128 bit
|
||||||
2 = AES 128 bit
|
2 = AES 128 bit
|
||||||
3 = AES 256 bit
|
3 = AES 256 bit
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
- To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt
|
- To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt
|
||||||
@ -89,8 +89,8 @@ $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
|
|||||||
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 016', PDF_HEADER_STRING);
|
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 016', PDF_HEADER_STRING);
|
||||||
|
|
||||||
// set header and footer fonts
|
// set header and footer fonts
|
||||||
$pdf->setHeaderFont(Array('helvetica', '', PDF_FONT_SIZE_MAIN));
|
$pdf->setHeaderFont(array('helvetica', '', PDF_FONT_SIZE_MAIN));
|
||||||
$pdf->setFooterFont(Array('helvetica', '', PDF_FONT_SIZE_DATA));
|
$pdf->setFooterFont(array('helvetica', '', PDF_FONT_SIZE_DATA));
|
||||||
|
|
||||||
// set default monospaced font
|
// set default monospaced font
|
||||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||||
|
|||||||
@ -64,8 +64,8 @@ $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
|
|||||||
$pdf->SetHeaderData('', PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 038', PDF_HEADER_STRING);
|
$pdf->SetHeaderData('', PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 038', PDF_HEADER_STRING);
|
||||||
|
|
||||||
// set header and footer fonts
|
// set header and footer fonts
|
||||||
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||||||
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||||||
|
|
||||||
// set default monospaced font
|
// set default monospaced font
|
||||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||||
|
|||||||
@ -40,18 +40,18 @@ class autoTranslator
|
|||||||
const DIR_SEPARATOR = '/';
|
const DIR_SEPARATOR = '/';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $_destlang Destination lang
|
* @param string $_destlang Destination lang
|
||||||
* @param string $_refLang Ref lang
|
* @param string $_refLang Ref lang
|
||||||
* @param string $_langDir Dir lang
|
* @param string $_langDir Dir lang
|
||||||
* @param string $_limittofile Limit to file
|
* @param string $_limittofile Limit to file
|
||||||
* @param string $_apikey Api key
|
* @param string $_apikey Api key
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey)
|
public function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Set enviorment variables
|
// Set enviorment variables
|
||||||
$this->_destlang = $_destlang;
|
$this->_destlang = $_destlang;
|
||||||
@ -59,7 +59,7 @@ class autoTranslator
|
|||||||
$this->_langDir = $_langDir.self::DIR_SEPARATOR;
|
$this->_langDir = $_langDir.self::DIR_SEPARATOR;
|
||||||
$this->_time = date('Y-m-d H:i:s');
|
$this->_time = date('Y-m-d H:i:s');
|
||||||
$this->_limittofile = $_limittofile;
|
$this->_limittofile = $_limittofile;
|
||||||
$this->_apikey = $_apikey;
|
$this->_apikey = $_apikey;
|
||||||
|
|
||||||
// Translate
|
// Translate
|
||||||
//ini_set('default_charset','UTF-8');
|
//ini_set('default_charset','UTF-8');
|
||||||
@ -77,9 +77,10 @@ class autoTranslator
|
|||||||
|
|
||||||
$files = $this->getTranslationFilesArray($this->_refLang);
|
$files = $this->getTranslationFilesArray($this->_refLang);
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
foreach ($files as $file)
|
foreach ($files as $file) {
|
||||||
{
|
if ($this->_limittofile && $this->_limittofile != $file) {
|
||||||
if ($this->_limittofile && $this->_limittofile != $file) continue;
|
continue;
|
||||||
|
}
|
||||||
$counter++;
|
$counter++;
|
||||||
$fileContent = null;
|
$fileContent = null;
|
||||||
$refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file;
|
$refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file;
|
||||||
@ -88,54 +89,66 @@ class autoTranslator
|
|||||||
|
|
||||||
// Define target dirs
|
// Define target dirs
|
||||||
$targetlangs=array($this->_destlang);
|
$targetlangs=array($this->_destlang);
|
||||||
if ($this->_destlang == 'all')
|
if ($this->_destlang == 'all') {
|
||||||
{
|
|
||||||
$targetlangs=array();
|
$targetlangs=array();
|
||||||
|
|
||||||
// If we must process all languages
|
// If we must process all languages
|
||||||
$arraytmp=dol_dir_list($this->_langDir, 'directories', 0);
|
$arraytmp=dol_dir_list($this->_langDir, 'directories', 0);
|
||||||
foreach ($arraytmp as $dirtmp)
|
foreach ($arraytmp as $dirtmp) {
|
||||||
{
|
if ($dirtmp['name'] === $this->_refLang) {
|
||||||
if ($dirtmp['name'] === $this->_refLang) continue; // We discard source language
|
continue; // We discard source language
|
||||||
|
}
|
||||||
$tmppart=explode('_', $dirtmp['name']);
|
$tmppart=explode('_', $dirtmp['name']);
|
||||||
if (preg_match('/^en/i', $dirtmp['name'])) continue; // We discard en_* languages
|
if (preg_match('/^en/i', $dirtmp['name'])) {
|
||||||
if (preg_match('/^fr/i', $dirtmp['name'])) continue; // We discard fr_* languages
|
continue; // We discard en_* languages
|
||||||
if (preg_match('/^es/i', $dirtmp['name'])) continue; // We discard es_* languages
|
}
|
||||||
if (preg_match('/ca_ES/i', $dirtmp['name'])) continue; // We discard es_CA language
|
if (preg_match('/^fr/i', $dirtmp['name'])) {
|
||||||
if (preg_match('/pt_BR/i', $dirtmp['name'])) continue; // We discard pt_BR language
|
continue; // We discard fr_* languages
|
||||||
if (preg_match('/nl_BE/i', $dirtmp['name'])) continue; // We discard nl_BE language
|
}
|
||||||
if (preg_match('/^\./i', $dirtmp['name'])) continue; // We discard files .*
|
if (preg_match('/^es/i', $dirtmp['name'])) {
|
||||||
if (preg_match('/^CVS/i', $dirtmp['name'])) continue; // We discard CVS
|
continue; // We discard es_* languages
|
||||||
|
}
|
||||||
|
if (preg_match('/ca_ES/i', $dirtmp['name'])) {
|
||||||
|
continue; // We discard es_CA language
|
||||||
|
}
|
||||||
|
if (preg_match('/pt_BR/i', $dirtmp['name'])) {
|
||||||
|
continue; // We discard pt_BR language
|
||||||
|
}
|
||||||
|
if (preg_match('/nl_BE/i', $dirtmp['name'])) {
|
||||||
|
continue; // We discard nl_BE language
|
||||||
|
}
|
||||||
|
if (preg_match('/^\./i', $dirtmp['name'])) {
|
||||||
|
continue; // We discard files .*
|
||||||
|
}
|
||||||
|
if (preg_match('/^CVS/i', $dirtmp['name'])) {
|
||||||
|
continue; // We discard CVS
|
||||||
|
}
|
||||||
$targetlangs[]=$dirtmp['name'];
|
$targetlangs[]=$dirtmp['name'];
|
||||||
}
|
}
|
||||||
//var_dump($targetlangs);
|
//var_dump($targetlangs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process translation of source file for each target languages
|
// Process translation of source file for each target languages
|
||||||
foreach ($targetlangs as $my_destlang)
|
foreach ($targetlangs as $my_destlang) {
|
||||||
{
|
|
||||||
$this->_translatedFiles = array();
|
$this->_translatedFiles = array();
|
||||||
|
|
||||||
$destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file;
|
$destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file;
|
||||||
// Check destination file presence
|
// Check destination file presence
|
||||||
if (! file_exists($destPath))
|
if (! file_exists($destPath)) {
|
||||||
{
|
|
||||||
// No file present, we generate file
|
// No file present, we generate file
|
||||||
echo "File not found: " . $destPath . ". We generate it.<br>\n";
|
echo "File not found: " . $destPath . ". We generate it.<br>\n";
|
||||||
$this->createTranslationFile($destPath, $my_destlang);
|
$this->createTranslationFile($destPath, $my_destlang);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
echo "Updating file: " . $destPath . "<br>\n";
|
echo "Updating file: " . $destPath . "<br>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate lines
|
// Translate lines
|
||||||
$fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
$fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||||
$newlines=0;
|
$newlines=0;
|
||||||
foreach ($fileContent as $line){
|
foreach ($fileContent as $line) {
|
||||||
$key = $this->getLineKey($line);
|
$key = $this->getLineKey($line);
|
||||||
$value = $this->getLineValue($line);
|
$value = $this->getLineValue($line);
|
||||||
if ($key && $value)
|
if ($key && $value) {
|
||||||
{
|
|
||||||
$newlines+=$this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang);
|
$newlines+=$this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,8 +172,7 @@ class autoTranslator
|
|||||||
{
|
{
|
||||||
$this->_time_end = date('Y-m-d H:i:s');
|
$this->_time_end = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file])>0)
|
if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file])>0) {
|
||||||
{
|
|
||||||
$fp = fopen($destPath, 'a');
|
$fp = fopen($destPath, 'a');
|
||||||
fwrite($fp, "\n");
|
fwrite($fp, "\n");
|
||||||
fwrite($fp, "\n");
|
fwrite($fp, "\n");
|
||||||
@ -213,27 +225,31 @@ class autoTranslator
|
|||||||
$destValue = $this->getLineValue($line);
|
$destValue = $this->getLineValue($line);
|
||||||
// If translated return
|
// If translated return
|
||||||
//print "destKey=".$destKey."\n";
|
//print "destKey=".$destKey."\n";
|
||||||
if ( trim($destKey) == trim($key) )
|
if (trim($destKey) == trim($key)) { // Found already existing translation (key already exits in dest file)
|
||||||
{ // Found already existing translation (key already exits in dest file)
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key == 'CHARSET') {
|
if ($key == 'CHARSET') {
|
||||||
$val=$this->_outputpagecode;
|
$val=$this->_outputpagecode;
|
||||||
} elseif (preg_match('/^Format/', $key)) {
|
} elseif (preg_match('/^Format/', $key)) {
|
||||||
$val=$value;
|
$val=$value;
|
||||||
} elseif ($value=='-') {
|
} elseif ($value=='-') {
|
||||||
$val=$value;
|
$val=$value;
|
||||||
} else {
|
} else {
|
||||||
// If not translated then translate
|
// If not translated then translate
|
||||||
if ($this->_outputpagecode == 'UTF-8') $val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2));
|
if ($this->_outputpagecode == 'UTF-8') {
|
||||||
else $val=utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)));
|
$val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2));
|
||||||
|
} else {
|
||||||
|
$val=utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$val=trim($val);
|
$val=trim($val);
|
||||||
|
|
||||||
if (empty($val)) return 0;
|
if (empty($val)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_translatedFiles[$file][] = $key . '=' . $val ;
|
$this->_translatedFiles[$file][] = $key . '=' . $val ;
|
||||||
return 1;
|
return 1;
|
||||||
@ -293,9 +309,13 @@ class autoTranslator
|
|||||||
{
|
{
|
||||||
// We want to be sure that src_lang and dest_lang are using 2 chars only
|
// We want to be sure that src_lang and dest_lang are using 2 chars only
|
||||||
$tmp=explode('_', $src_lang);
|
$tmp=explode('_', $src_lang);
|
||||||
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) $src_lang=$tmp[0];
|
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) {
|
||||||
|
$src_lang=$tmp[0];
|
||||||
|
}
|
||||||
$tmp=explode('_', $dest_lang);
|
$tmp=explode('_', $dest_lang);
|
||||||
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) $dest_lang=$tmp[0];
|
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) {
|
||||||
|
$dest_lang=$tmp[0];
|
||||||
|
}
|
||||||
|
|
||||||
//setting language pair
|
//setting language pair
|
||||||
$lang_pair = $src_lang.'|'.$dest_lang;
|
$lang_pair = $src_lang.'|'.$dest_lang;
|
||||||
@ -306,17 +326,16 @@ class autoTranslator
|
|||||||
// Define GET URL v1
|
// Define GET URL v1
|
||||||
//$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
|
//$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
|
||||||
// Example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Setup%20area&langpair=en_US|fr_FR
|
// Example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Setup%20area&langpair=en_US|fr_FR
|
||||||
// Define GET URL v2
|
// Define GET URL v2
|
||||||
$url = "https://www.googleapis.com/language/translate/v2?key=".$this->_apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang);
|
$url = "https://www.googleapis.com/language/translate/v2?key=".$this->_apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang);
|
||||||
// Example: https://www.googleapis.com/language/translate/v2?key=_apikey&q=Setup%20area&source=en_US&target=fr_FR
|
// Example: https://www.googleapis.com/language/translate/v2?key=_apikey&q=Setup%20area&source=en_US&target=fr_FR
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
//print "Url to translate: ".$url."\n";
|
//print "Url to translate: ".$url."\n";
|
||||||
|
|
||||||
if (! function_exists("curl_init"))
|
if (! function_exists("curl_init")) {
|
||||||
{
|
print "Error, your PHP does not support curl functions.\n";
|
||||||
print "Error, your PHP does not support curl functions.\n";
|
die();
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
@ -331,9 +350,8 @@ class autoTranslator
|
|||||||
$json = json_decode($body, true);
|
$json = json_decode($body, true);
|
||||||
|
|
||||||
if ((! empty($json['responseStatus']) && $json['responseStatus'] != 200)
|
if ((! empty($json['responseStatus']) && $json['responseStatus'] != 200)
|
||||||
|| count($json['data']['translations']) == 0)
|
|| count($json['data']['translations']) == 0) {
|
||||||
{
|
print "Error: ".$json['responseStatus']." ".$url."\n";
|
||||||
print "Error: ".$json['responseStatus']." ".$url."\n";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,5 +363,5 @@ class autoTranslator
|
|||||||
//print "OK ".join('',$src_texts).' => '.$rep."\n";
|
//print "OK ".join('',$src_texts).' => '.$rep."\n";
|
||||||
|
|
||||||
return $rep;
|
return $rep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,8 @@ $path=dirname(__FILE__).'/';
|
|||||||
|
|
||||||
// Test if batch mode
|
// Test if batch mode
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
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";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include Dolibarr environment
|
// Include Dolibarr environment
|
||||||
@ -56,10 +56,10 @@ $dir=DOL_DOCUMENT_ROOT."/langs";
|
|||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (! isset($argv[3])) {
|
if (! isset($argv[3])) {
|
||||||
print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
|
print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
|
||||||
print "Example: ".$script_file." en_US pt_PT 123456\n";
|
print "Example: ".$script_file." en_US pt_PT 123456\n";
|
||||||
print "Rem: lang_code to use can be found on https://translate.google.com\n";
|
print "Rem: lang_code to use can be found on https://translate.google.com\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show parameters
|
// Show parameters
|
||||||
@ -67,21 +67,17 @@ print 'Argument 1='.$argv[1]."\n";
|
|||||||
print 'Argument 2='.$argv[2]."\n";
|
print 'Argument 2='.$argv[2]."\n";
|
||||||
print 'Argument 3='.$argv[3]."\n";
|
print 'Argument 3='.$argv[3]."\n";
|
||||||
$file='';
|
$file='';
|
||||||
if (isset($argv[4]))
|
if (isset($argv[4])) {
|
||||||
{
|
|
||||||
$file=$argv[4];
|
$file=$argv[4];
|
||||||
print 'Argument 4='.$argv[4]."\n";
|
print 'Argument 4='.$argv[4]."\n";
|
||||||
}
|
}
|
||||||
print 'Files will be generated/updated in directory '.$dir."\n";
|
print 'Files will be generated/updated in directory '.$dir."\n";
|
||||||
|
|
||||||
if ($argv[2] != 'all')
|
if ($argv[2] != 'all') {
|
||||||
{
|
if (! is_dir($dir.'/'.$argv[2])) {
|
||||||
if (! is_dir($dir.'/'.$argv[2]))
|
|
||||||
{
|
|
||||||
print 'Create directory '.$dir.'/'.$argv[2]."\n";
|
print 'Create directory '.$dir.'/'.$argv[2]."\n";
|
||||||
$result=mkdir($dir.'/'.$argv[2]);
|
$result=mkdir($dir.'/'.$argv[2]);
|
||||||
if (! $result)
|
if (! $result) {
|
||||||
{
|
|
||||||
$db->close();
|
$db->close();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,18 +25,16 @@ $path=dirname(__FILE__).'/';
|
|||||||
$web=0;
|
$web=0;
|
||||||
|
|
||||||
// Test if batch mode
|
// Test if batch mode
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi')
|
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||||
{
|
$web=1;
|
||||||
$web=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($web)
|
if ($web) {
|
||||||
{
|
echo "<html>";
|
||||||
echo "<html>";
|
echo "<head>";
|
||||||
echo "<head>";
|
|
||||||
|
|
||||||
echo "<STYLE type=\"text/css\">
|
echo "<STYLE type=\"text/css\">
|
||||||
|
|
||||||
table {
|
table {
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
@ -83,13 +81,17 @@ if ($web)
|
|||||||
|
|
||||||
</STYLE>";
|
</STYLE>";
|
||||||
|
|
||||||
echo "<body>";
|
echo "<body>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "If you call this with argument \"unused=true\" it searches for the translation strings that exist in en_US but are never used.\n";
|
echo "If you call this with argument \"unused=true\" it searches for the translation strings that exist in en_US but are never used.\n";
|
||||||
if ($web) print "<br>";
|
if ($web) {
|
||||||
|
print "<br>";
|
||||||
|
}
|
||||||
echo "IMPORTANT: that can take quite a lot of time (up to 10 minutes), you need to tune the max_execution_time on your php.ini accordingly.\n";
|
echo "IMPORTANT: that can take quite a lot of time (up to 10 minutes), you need to tune the max_execution_time on your php.ini accordingly.\n";
|
||||||
if ($web) print "<br>";
|
if ($web) {
|
||||||
|
print "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -105,8 +107,7 @@ $workdir = $htdocs."langs/en_US/";
|
|||||||
|
|
||||||
|
|
||||||
$files = scandir($workdir);
|
$files = scandir($workdir);
|
||||||
if (empty($files))
|
if (empty($files)) {
|
||||||
{
|
|
||||||
echo "Can't scan workdir = ".$workdir;
|
echo "Can't scan workdir = ".$workdir;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -115,18 +116,17 @@ $dups=array();
|
|||||||
$exludefiles = array('.','..','README');
|
$exludefiles = array('.','..','README');
|
||||||
$files = array_diff($files, $exludefiles);
|
$files = array_diff($files, $exludefiles);
|
||||||
// To force a file: $files=array('myfile.lang');
|
// To force a file: $files=array('myfile.lang');
|
||||||
if (isset($argv[2]))
|
if (isset($argv[2])) {
|
||||||
{
|
$files = array($argv[2]);
|
||||||
$files = array($argv[2]);
|
|
||||||
}
|
}
|
||||||
$langstrings_3d = array();
|
$langstrings_3d = array();
|
||||||
$langstrings_full = array();
|
$langstrings_full = array();
|
||||||
foreach ($files AS $file) {
|
foreach ($files as $file) {
|
||||||
$path_file = pathinfo($file);
|
$path_file = pathinfo($file);
|
||||||
// we're only interested in .lang files
|
// we're only interested in .lang files
|
||||||
if ($path_file['extension']=='lang') {
|
if ($path_file['extension']=='lang') {
|
||||||
$content = file($workdir.$file);
|
$content = file($workdir.$file);
|
||||||
foreach ($content AS $line => $row) {
|
foreach ($content as $line => $row) {
|
||||||
// don't want comment lines
|
// don't want comment lines
|
||||||
if (substr($row, 0, 1) !== '#') {
|
if (substr($row, 0, 1) !== '#') {
|
||||||
// don't want lines without the separator (why should those even be here, anyway...)
|
// don't want lines without the separator (why should those even be here, anyway...)
|
||||||
@ -142,29 +142,29 @@ foreach ($files AS $file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($langstrings_3d AS $filename => $file)
|
foreach ($langstrings_3d as $filename => $file) {
|
||||||
{
|
foreach ($file as $linenum => $value) {
|
||||||
foreach ($file AS $linenum => $value)
|
|
||||||
{
|
|
||||||
$keys = array_keys($langstrings_full, $value);
|
$keys = array_keys($langstrings_full, $value);
|
||||||
if (count($keys)>1)
|
if (count($keys)>1) {
|
||||||
{
|
foreach ($keys as $key) {
|
||||||
foreach ($keys AS $key) {
|
|
||||||
$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
|
$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($web) print "<h2>";
|
if ($web) {
|
||||||
|
print "<h2>";
|
||||||
|
}
|
||||||
print "Duplicate strings in lang files in $workdir - ".count($dups)." found\n";
|
print "Duplicate strings in lang files in $workdir - ".count($dups)." found\n";
|
||||||
if ($web) print "</h2>";
|
if ($web) {
|
||||||
|
print "</h2>";
|
||||||
|
}
|
||||||
|
|
||||||
if ($web)
|
if ($web) {
|
||||||
{
|
echo '<table border_bottom="1">'."\n";
|
||||||
echo '<table border_bottom="1">'."\n";
|
echo "<thead><tr><th align=\"center\">#</th><th>String</th><th>File and lines</th></thead>\n";
|
||||||
echo "<thead><tr><th align=\"center\">#</th><th>String</th><th>File and lines</th></thead>\n";
|
echo "<tbody>\n";
|
||||||
echo "<tbody>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sduplicateinsamefile='';
|
$sduplicateinsamefile='';
|
||||||
@ -173,216 +173,419 @@ $sininstallandadmin='';
|
|||||||
$sother='';
|
$sother='';
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($dups as $string => $pages)
|
foreach ($dups as $string => $pages) {
|
||||||
{
|
|
||||||
$count++;
|
$count++;
|
||||||
$s='';
|
$s='';
|
||||||
|
|
||||||
// Keyword $string
|
// Keyword $string
|
||||||
if ($web) $s.="<tr>";
|
if ($web) {
|
||||||
if ($web) $s.="<td align=\"center\">";
|
$s.="<tr>";
|
||||||
if ($web) $s.=$count;
|
}
|
||||||
if ($web) $s.="</td>";
|
if ($web) {
|
||||||
if ($web) $s.="<td>";
|
$s.="<td align=\"center\">";
|
||||||
|
}
|
||||||
|
if ($web) {
|
||||||
|
$s.=$count;
|
||||||
|
}
|
||||||
|
if ($web) {
|
||||||
|
$s.="</td>";
|
||||||
|
}
|
||||||
|
if ($web) {
|
||||||
|
$s.="<td>";
|
||||||
|
}
|
||||||
$s.=$string;
|
$s.=$string;
|
||||||
if ($web) $s.="</td>";
|
if ($web) {
|
||||||
if ($web) $s.="<td>";
|
$s.="</td>";
|
||||||
if (! $web) $s.= ' : ';
|
}
|
||||||
|
if ($web) {
|
||||||
|
$s.="<td>";
|
||||||
|
}
|
||||||
|
if (! $web) {
|
||||||
|
$s.= ' : ';
|
||||||
|
}
|
||||||
|
|
||||||
// Loop on each files keyword was found
|
// Loop on each files keyword was found
|
||||||
$duplicateinsamefile=0;
|
$duplicateinsamefile=0;
|
||||||
$inmain=0;
|
$inmain=0;
|
||||||
$inadmin=0;
|
$inadmin=0;
|
||||||
foreach ($pages AS $file => $lines)
|
foreach ($pages as $file => $lines) {
|
||||||
{
|
if ($file == 'main.lang') {
|
||||||
if ($file == 'main.lang') { $inmain=1; $inadmin=0; }
|
$inmain=1; $inadmin=0;
|
||||||
if ($file == 'admin.lang' && ! $inmain) { $inadmin=1; }
|
}
|
||||||
|
if ($file == 'admin.lang' && ! $inmain) {
|
||||||
|
$inadmin=1;
|
||||||
|
}
|
||||||
|
|
||||||
$s.=$file." ";
|
$s.=$file." ";
|
||||||
|
|
||||||
// Loop on each line keword was found into file.
|
// Loop on each line keword was found into file.
|
||||||
$listoffilesforthisentry=array();
|
$listoffilesforthisentry=array();
|
||||||
foreach ($lines as $line => $translatedvalue)
|
foreach ($lines as $line => $translatedvalue) {
|
||||||
{
|
if (! empty($listoffilesforthisentry[$file])) {
|
||||||
if (! empty($listoffilesforthisentry[$file])) $duplicateinsamefile=1;
|
$duplicateinsamefile=1;
|
||||||
$listoffilesforthisentry[$file]=1;
|
}
|
||||||
|
$listoffilesforthisentry[$file]=1;
|
||||||
|
|
||||||
$s.= "(".$line." - ".htmlentities($translatedvalue).") ";
|
$s.= "(".$line." - ".htmlentities($translatedvalue).") ";
|
||||||
}
|
}
|
||||||
if ($web) $s.="<br>";
|
if ($web) {
|
||||||
|
$s.="<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($web) {
|
||||||
|
$s.="</td></tr>";
|
||||||
}
|
}
|
||||||
if ($web) $s.="</td></tr>";
|
|
||||||
$s.="\n";
|
$s.="\n";
|
||||||
|
|
||||||
if ($duplicateinsamefile) $sduplicateinsamefile .= $s;
|
if ($duplicateinsamefile) {
|
||||||
elseif ($inmain) $sinmainandother .= $s;
|
$sduplicateinsamefile .= $s;
|
||||||
elseif ($inadmin) $sininstallandadmin .= $s;
|
} elseif ($inmain) {
|
||||||
else $sother .= $s;
|
$sinmainandother .= $s;
|
||||||
|
} elseif ($inadmin) {
|
||||||
|
$sininstallandadmin .= $s;
|
||||||
|
} else {
|
||||||
|
$sother .= $s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $web) print "\n***** Entries duplicated in same file\n";
|
if (! $web) {
|
||||||
|
print "\n***** Entries duplicated in same file\n";
|
||||||
|
}
|
||||||
print $sduplicateinsamefile;
|
print $sduplicateinsamefile;
|
||||||
if (! $web && empty($sduplicateinsamefile)) print "None\n";
|
if (! $web && empty($sduplicateinsamefile)) {
|
||||||
if (! $web) print "\n";
|
print "None\n";
|
||||||
|
}
|
||||||
|
if (! $web) {
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (! $web) print "***** Entries in main and another (keep only entry in main)\n";
|
if (! $web) {
|
||||||
|
print "***** Entries in main and another (keep only entry in main)\n";
|
||||||
|
}
|
||||||
print $sinmainandother;
|
print $sinmainandother;
|
||||||
if (! $web && empty($sinmainandother)) print "None\n";
|
if (! $web && empty($sinmainandother)) {
|
||||||
if (! $web) print "\n";
|
print "None\n";
|
||||||
|
}
|
||||||
|
if (! $web) {
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (! $web) print "***** Entries in admin and another\n";
|
if (! $web) {
|
||||||
|
print "***** Entries in admin and another\n";
|
||||||
|
}
|
||||||
print $sininstallandadmin;
|
print $sininstallandadmin;
|
||||||
if (! $web && empty($sininstallandadmin)) print "None\n";
|
if (! $web && empty($sininstallandadmin)) {
|
||||||
if (! $web) print "\n";
|
print "None\n";
|
||||||
|
}
|
||||||
|
if (! $web) {
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (! $web) print "***** Other\n";
|
if (! $web) {
|
||||||
|
print "***** Other\n";
|
||||||
|
}
|
||||||
print $sother;
|
print $sother;
|
||||||
if (! $web && empty($sother)) print "None\n";
|
if (! $web && empty($sother)) {
|
||||||
if (! $web) print "\n";
|
print "None\n";
|
||||||
|
}
|
||||||
|
if (! $web) {
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ($web)
|
if ($web) {
|
||||||
{
|
echo "</tbody>\n";
|
||||||
echo "</tbody>\n";
|
echo "</table>\n";
|
||||||
echo "</table>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// STEP 2 - Search key not used
|
// STEP 2 - Search key not used
|
||||||
|
|
||||||
if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true'))
|
if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true')) {
|
||||||
{
|
print "***** Strings in en_US that are never used:\n";
|
||||||
print "***** Strings in en_US that are never used:\n";
|
|
||||||
|
|
||||||
$unused=array();
|
$unused=array();
|
||||||
foreach ($langstrings_dist AS $value => $line)
|
foreach ($langstrings_dist as $value => $line) {
|
||||||
{
|
$qualifiedforclean=1;
|
||||||
$qualifiedforclean=1;
|
// Check if we must keep this key to be into file for removal
|
||||||
// Check if we must keep this key to be into file for removal
|
if (preg_match('/^Module\d+/', $value)) {
|
||||||
if (preg_match('/^Module\d+/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Permission\d+/', $value)) {
|
||||||
if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^Delays_/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^PermissionAdvanced\d+/', $value)) {
|
||||||
if (preg_match('/^Extrafield/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^LocalTax/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^Country/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^ProfId\d+/', $value)) {
|
||||||
if (preg_match('/^Civility/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^Currency/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Delays_/', $value)) {
|
||||||
if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^AmountLT/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^BarcodeDesc/', $value)) {
|
||||||
if (preg_match('/^TotalLT/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^Month/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^MonthShort/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Extrafield/', $value)) {
|
||||||
if (preg_match('/^Day\d/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^Short/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^ExportDataset_/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^LocalTax/', $value)) {
|
||||||
if (preg_match('/^ImportDataset_/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^ActionAC_/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^TypeLocaltax/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Country/', $value)) {
|
||||||
if (preg_match('/^StatusProspect/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^PL_/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^TE_/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Civility/', $value)) {
|
||||||
if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^newLT/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Currency/', $value)) {
|
||||||
if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^DemandReasonTypeSRC/', $value)) {
|
||||||
if (preg_match('/^Language_/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^PaperFormat/', $value)) {
|
||||||
if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0;
|
}
|
||||||
// admin.lang
|
if (preg_match('/^Duration/', $value)) {
|
||||||
if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0;
|
}
|
||||||
// boxes.lang
|
if (preg_match('/^AmountLT/', $value)) {
|
||||||
if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0;
|
}
|
||||||
// install.lang
|
if (preg_match('/^TotalLT/', $value)) {
|
||||||
if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^Month/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^MonthShort/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^Day\d/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^Short/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^ExportDataset_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^ImportDataset_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^ActionAC_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^TypeLocaltax/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^StatusProspect/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^PL_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^TE_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^JuridicalStatus/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^CalcMode/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^newLT/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^LT[0-9]/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^TypeContact_contrat_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^ErrorPriceExpression/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^Language_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^DescADHERENT_/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^SubmitTranslation/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^ModuleCompanyCode/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/InDolibarr$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
// admin.lang
|
||||||
|
if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
// boxes.lang
|
||||||
|
if (preg_match('/^BoxTitleLast/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^BoxTitleLatest/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
// install.lang
|
||||||
|
if (preg_match('/^KeepDefaultValues/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
// mail.lang
|
// mail.lang
|
||||||
if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean=0;
|
if (preg_match('/MailingModuleDesc/i', $value)) {
|
||||||
// main.lang
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^FormatDate/', $value)) $qualifiedforclean=0;
|
// main.lang
|
||||||
if (preg_match('/^DateFormat/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Duration/', $value)) {
|
||||||
if (preg_match('/^.b$/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^FormatDate/', $value)) {
|
||||||
if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^DateFormat/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^.b$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^.*Bytes$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
// modulebuilder
|
// modulebuilder
|
||||||
if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^ModuleBuilderDesc/', $value)) {
|
||||||
// orders
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0;
|
// orders
|
||||||
// other.lang
|
if (preg_match('/^OrderSource/', $value)) {
|
||||||
if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^TypeContact_/', $value)) {
|
||||||
if (preg_match('/^WeightUnit/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^LengthUnit/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/^SurfaceUnit/', $value)) $qualifiedforclean=0;
|
// other.lang
|
||||||
if (preg_match('/^VolumeUnit/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^Notify_/', $value)) {
|
||||||
if (preg_match('/^SizeUnit/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/^EMailText/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/ById$/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^PredefinedMail/', $value)) {
|
||||||
if (preg_match('/ByLogin$/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
// printing
|
}
|
||||||
if (preg_match('/PrintingDriverDesc$/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^DemoCompany/', $value)) {
|
||||||
if (preg_match('/PrintTestDesc$/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
// products
|
}
|
||||||
if (preg_match('/GlobalVariableUpdaterType$/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^WeightUnit/', $value)) {
|
||||||
if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0;
|
if (preg_match('/^LengthUnit/', $value)) {
|
||||||
if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^SurfaceUnit/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^VolumeUnit/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^SizeUnit/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/^EMailText/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/ById$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/ByLogin$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
// printing
|
||||||
|
if (preg_match('/PrintingDriverDesc$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/PrintTestDesc$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
// products
|
||||||
|
if (preg_match('/GlobalVariableUpdaterType$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/OppStatus/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/AvailabilityType/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/CardProduct/', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match('/sms/i', $value)) $qualifiedforclean=0;
|
if (preg_match('/sms/i', $value)) {
|
||||||
if (preg_match('/TF_/i', $value)) $qualifiedforclean=0;
|
$qualifiedforclean=0;
|
||||||
if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0;
|
}
|
||||||
if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0;
|
if (preg_match('/TF_/i', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/WithBankUsing/i', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
if (preg_match('/descWORKFLOW_/i', $value)) {
|
||||||
|
$qualifiedforclean=0;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $qualifiedforclean)
|
if (! $qualifiedforclean) {
|
||||||
{
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//$search = '\'trans("'.$value.'")\'';
|
//$search = '\'trans("'.$value.'")\'';
|
||||||
$search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
|
$search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
|
||||||
$string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
|
$string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
|
||||||
//print $string."<br>\n";
|
//print $string."<br>\n";
|
||||||
exec($string, $output);
|
exec($string, $output);
|
||||||
if (empty($output)) {
|
if (empty($output)) {
|
||||||
$unused[$value] = $line;
|
$unused[$value] = $line;
|
||||||
echo $line; // $trad contains the \n
|
echo $line; // $trad contains the \n
|
||||||
}
|
} else {
|
||||||
else {
|
unset($output);
|
||||||
unset($output);
|
//print 'X'.$output.'Y';
|
||||||
//print 'X'.$output.'Y';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($unused)) print "No string not used found.\n";
|
if (empty($unused)) {
|
||||||
else {
|
print "No string not used found.\n";
|
||||||
$filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
|
} else {
|
||||||
print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
|
$filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
|
||||||
file_put_contents($filetosave, implode("", $unused));
|
print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
|
||||||
print "To remove from original file, run command :\n";
|
file_put_contents($filetosave, implode("", $unused));
|
||||||
if (($argv[2]?$argv[2]:"")) print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
|
print "To remove from original file, run command :\n";
|
||||||
print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2]?$argv[2]:"");
|
if (($argv[2]?$argv[2]:"")) {
|
||||||
if (($argv[2]?$argv[2]:"")) print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
|
print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
|
||||||
|
}
|
||||||
|
print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2]?$argv[2]:"");
|
||||||
|
if (($argv[2]?$argv[2]:"")) {
|
||||||
|
print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
if ($web)
|
if ($web) {
|
||||||
{
|
echo "</body>\n";
|
||||||
echo "</body>\n";
|
echo "</html>\n";
|
||||||
echo "</html>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@ -63,8 +63,7 @@ $lSecondary = isset($argv[2])?$argv[2]:'';
|
|||||||
$lEnglish = 'en_US';
|
$lEnglish = 'en_US';
|
||||||
$filesToProcess = isset($argv[3])?$argv[3]:'';
|
$filesToProcess = isset($argv[3])?$argv[3]:'';
|
||||||
|
|
||||||
if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess))
|
if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess)) {
|
||||||
{
|
|
||||||
$rc = 1;
|
$rc = 1;
|
||||||
$msg = '***** Script to clean language files *****'."\n";
|
$msg = '***** Script to clean language files *****'."\n";
|
||||||
$msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
|
$msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
|
||||||
@ -77,8 +76,7 @@ $aSecondary = array();
|
|||||||
$aEnglish = array();
|
$aEnglish = array();
|
||||||
|
|
||||||
// Define array $filesToProcess
|
// Define array $filesToProcess
|
||||||
if ($filesToProcess == 'all')
|
if ($filesToProcess == 'all') {
|
||||||
{
|
|
||||||
$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
|
$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
|
||||||
while ($dir->valid()) {
|
while ($dir->valid()) {
|
||||||
if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) {
|
if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) {
|
||||||
@ -87,15 +85,15 @@ if ($filesToProcess == 'all')
|
|||||||
$dir->next();
|
$dir->next();
|
||||||
}
|
}
|
||||||
$filesToProcess=$files;
|
$filesToProcess=$files;
|
||||||
|
} else {
|
||||||
|
$filesToProcess=explode(',', $filesToProcess);
|
||||||
}
|
}
|
||||||
else $filesToProcess=explode(',', $filesToProcess);
|
|
||||||
|
|
||||||
// Arguments should be OK here.
|
// Arguments should be OK here.
|
||||||
|
|
||||||
|
|
||||||
// Loop on each file
|
// Loop on each file
|
||||||
foreach ($filesToProcess as $fileToProcess)
|
foreach ($filesToProcess as $fileToProcess) {
|
||||||
{
|
|
||||||
$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
|
$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
|
||||||
$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
|
$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
|
||||||
$lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess;
|
$lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess;
|
||||||
@ -103,21 +101,21 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
|
|
||||||
print "---- Process language file ".$lSecondaryFile."\n";
|
print "---- Process language file ".$lSecondaryFile."\n";
|
||||||
|
|
||||||
if ( ! is_readable($lPrimaryFile) ) {
|
if (! is_readable($lPrimaryFile)) {
|
||||||
$rc = 2;
|
$rc = 2;
|
||||||
$msg = "Cannot read primary language file $lPrimaryFile.";
|
$msg = "Cannot read primary language file $lPrimaryFile.";
|
||||||
print $msg . " (rc=$rc).\n";
|
print $msg . " (rc=$rc).\n";
|
||||||
exit($rc);
|
exit($rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_readable($lSecondaryFile) ) {
|
if (! is_readable($lSecondaryFile)) {
|
||||||
$rc = 3;
|
$rc = 3;
|
||||||
$msg = "Cannot read secondary language file $lSecondaryFile. We discard this file.";
|
$msg = "Cannot read secondary language file $lSecondaryFile. We discard this file.";
|
||||||
print $msg . "\n";
|
print $msg . "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_readable($lEnglishFile) ) {
|
if (! is_readable($lEnglishFile)) {
|
||||||
$rc = 3;
|
$rc = 3;
|
||||||
$msg = "Cannot read english language file $lEnglishFile. We discard this file.";
|
$msg = "Cannot read english language file $lEnglishFile. We discard this file.";
|
||||||
print $msg . "\n";
|
print $msg . "\n";
|
||||||
@ -126,25 +124,23 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
|
|
||||||
// Start reading and parsing Secondary
|
// Start reading and parsing Secondary
|
||||||
|
|
||||||
if ( $handle = fopen($lSecondaryFile, 'r') )
|
if ($handle = fopen($lSecondaryFile, 'r')) {
|
||||||
{
|
|
||||||
print "Read Secondary File $lSecondaryFile:\n";
|
print "Read Secondary File $lSecondaryFile:\n";
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
while (($line = fgets($handle)) !== false)
|
while (($line = fgets($handle)) !== false) {
|
||||||
{
|
|
||||||
$cnt++;
|
$cnt++;
|
||||||
|
|
||||||
// strip comments
|
// strip comments
|
||||||
if ( preg_match("/^\w*#/", $line) ) {
|
if (preg_match("/^\w*#/", $line)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// strip empty lines
|
// strip empty lines
|
||||||
if ( preg_match("/^\w*$/", $line) ) {
|
if (preg_match("/^\w*$/", $line)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = mb_split('=', trim($line), 2);
|
$a = mb_split('=', trim($line), 2);
|
||||||
if ( count($a) != 2 ) {
|
if (count($a) != 2) {
|
||||||
print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n";
|
print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -152,29 +148,27 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
list($key, $value) = $a;
|
list($key, $value) = $a;
|
||||||
|
|
||||||
// key is redundant
|
// key is redundant
|
||||||
if ( array_key_exists($key, $aSecondary) ) {
|
if (array_key_exists($key, $aSecondary)) {
|
||||||
print "Key $key is redundant in file $lSecondaryFile (line: $cnt).\n";
|
print "Key $key is redundant in file $lSecondaryFile (line: $cnt).\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// String has no value
|
// String has no value
|
||||||
if ( $value == '' ) {
|
if ($value == '') {
|
||||||
print "Key $key has no value in file $lSecondaryFile (line: $cnt).\n";
|
print "Key $key has no value in file $lSecondaryFile (line: $cnt).\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aSecondary[$key] = trim($value);
|
$aSecondary[$key] = trim($value);
|
||||||
}
|
}
|
||||||
if ( ! feof($handle) )
|
if (! feof($handle)) {
|
||||||
{
|
|
||||||
$rc = 5;
|
$rc = 5;
|
||||||
$msg = "Unexpected fgets() fail";
|
$msg = "Unexpected fgets() fail";
|
||||||
print $msg . " (rc=$rc).\n";
|
print $msg . " (rc=$rc).\n";
|
||||||
exit($rc);
|
exit($rc);
|
||||||
}
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$rc = 6;
|
$rc = 6;
|
||||||
$msg = "Cannot open file $lSecondaryFile";
|
$msg = "Cannot open file $lSecondaryFile";
|
||||||
print $msg . " (rc=$rc).\n";
|
print $msg . " (rc=$rc).\n";
|
||||||
@ -184,25 +178,23 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
|
|
||||||
// Start reading and parsing English
|
// Start reading and parsing English
|
||||||
|
|
||||||
if ( $handle = fopen($lEnglishFile, 'r') )
|
if ($handle = fopen($lEnglishFile, 'r')) {
|
||||||
{
|
|
||||||
print "Read English File $lEnglishFile:\n";
|
print "Read English File $lEnglishFile:\n";
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
while (($line = fgets($handle)) !== false)
|
while (($line = fgets($handle)) !== false) {
|
||||||
{
|
|
||||||
$cnt++;
|
$cnt++;
|
||||||
|
|
||||||
// strip comments
|
// strip comments
|
||||||
if ( preg_match("/^\w*#/", $line) ) {
|
if (preg_match("/^\w*#/", $line)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// strip empty lines
|
// strip empty lines
|
||||||
if ( preg_match("/^\w*$/", $line) ) {
|
if (preg_match("/^\w*$/", $line)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = mb_split('=', trim($line), 2);
|
$a = mb_split('=', trim($line), 2);
|
||||||
if ( count($a) != 2 ) {
|
if (count($a) != 2) {
|
||||||
print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n";
|
print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -210,29 +202,27 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
list($key, $value) = $a;
|
list($key, $value) = $a;
|
||||||
|
|
||||||
// key is redundant
|
// key is redundant
|
||||||
if ( array_key_exists($key, $aEnglish) ) {
|
if (array_key_exists($key, $aEnglish)) {
|
||||||
print "Key $key is redundant in file $lEnglishFile (line: $cnt).\n";
|
print "Key $key is redundant in file $lEnglishFile (line: $cnt).\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// String has no value
|
// String has no value
|
||||||
if ( $value == '' ) {
|
if ($value == '') {
|
||||||
print "Key $key has no value in file $lEnglishFile (line: $cnt).\n";
|
print "Key $key has no value in file $lEnglishFile (line: $cnt).\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aEnglish[$key] = trim($value);
|
$aEnglish[$key] = trim($value);
|
||||||
}
|
}
|
||||||
if ( ! feof($handle) )
|
if (! feof($handle)) {
|
||||||
{
|
|
||||||
$rc = 5;
|
$rc = 5;
|
||||||
$msg = "Unexpected fgets() fail";
|
$msg = "Unexpected fgets() fail";
|
||||||
print $msg . " (rc=$rc).\n";
|
print $msg . " (rc=$rc).\n";
|
||||||
exit($rc);
|
exit($rc);
|
||||||
}
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$rc = 6;
|
$rc = 6;
|
||||||
$msg = "Cannot open file $lEnglishFile";
|
$msg = "Cannot open file $lEnglishFile";
|
||||||
print $msg . " (rc=$rc).\n";
|
print $msg . " (rc=$rc).\n";
|
||||||
@ -246,10 +236,8 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
$arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand');
|
$arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand');
|
||||||
|
|
||||||
|
|
||||||
if ( $handle = fopen($lPrimaryFile, 'r') )
|
if ($handle = fopen($lPrimaryFile, 'r')) {
|
||||||
{
|
if (! $oh = fopen($output, 'w')) {
|
||||||
if ( ! $oh = fopen($output, 'w') )
|
|
||||||
{
|
|
||||||
print "ERROR in writing to file ".$output."\n";
|
print "ERROR in writing to file ".$output."\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -259,21 +247,20 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/', '', $fileToProcess))."\n");
|
fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/', '', $fileToProcess))."\n");
|
||||||
|
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
while (($line = fgets($handle)) !== false)
|
while (($line = fgets($handle)) !== false) {
|
||||||
{
|
|
||||||
$cnt++;
|
$cnt++;
|
||||||
|
|
||||||
// strip comments
|
// strip comments
|
||||||
if ( preg_match("/^\w*#/", $line) ) {
|
if (preg_match("/^\w*#/", $line)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// strip empty lines
|
// strip empty lines
|
||||||
if ( preg_match("/^\w*$/", $line) ) {
|
if (preg_match("/^\w*$/", $line)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = mb_split('=', trim($line), 2);
|
$a = mb_split('=', trim($line), 2);
|
||||||
if ( count($a) != 2 ) {
|
if (count($a) != 2) {
|
||||||
print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n";
|
print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -281,17 +268,16 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
list($key, $value) = $a;
|
list($key, $value) = $a;
|
||||||
|
|
||||||
// key is redundant
|
// key is redundant
|
||||||
if ( array_key_exists($key, $aPrimary) ) {
|
if (array_key_exists($key, $aPrimary)) {
|
||||||
print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
|
print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$fileFirstFound[$key] = $fileToProcess;
|
$fileFirstFound[$key] = $fileToProcess;
|
||||||
$lineFirstFound[$key] = $cnt;
|
$lineFirstFound[$key] = $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// String has no value
|
// String has no value
|
||||||
if ( $value == '' ) {
|
if ($value == '') {
|
||||||
print "Key $key has no value in file $lPrimaryFile (line: $cnt).\n";
|
print "Key $key has no value in file $lPrimaryFile (line: $cnt).\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -305,28 +291,23 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
//print "Found primary key = ".$key."\n";
|
//print "Found primary key = ".$key."\n";
|
||||||
|
|
||||||
// Key not in other file
|
// Key not in other file
|
||||||
if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key))
|
if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)) {
|
||||||
{
|
|
||||||
//print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
|
//print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
|
||||||
}
|
} elseif (! array_key_exists($key, $aSecondary)) {
|
||||||
elseif ( ! array_key_exists($key, $aSecondary))
|
|
||||||
{
|
|
||||||
//print "Key $key does NOT exist in secondary language (line: $cnt).\n";
|
//print "Key $key does NOT exist in secondary language (line: $cnt).\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// String exists in both files and value into alternative language differs from main language but also from english files
|
// String exists in both files and value into alternative language differs from main language but also from english files
|
||||||
if (
|
if ((! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
|
||||||
(! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
|
&& ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
|
||||||
&& ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
|
|
||||||
|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)
|
|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
//print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
|
//print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
|
||||||
fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
|
fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! feof($handle) ) {
|
if (! feof($handle)) {
|
||||||
$rc = 7;
|
$rc = 7;
|
||||||
$msg = "Unexpected fgets() fail";
|
$msg = "Unexpected fgets() fail";
|
||||||
print $msg . " (rc=$rc).\n";
|
print $msg . " (rc=$rc).\n";
|
||||||
@ -334,8 +315,7 @@ foreach ($filesToProcess as $fileToProcess)
|
|||||||
}
|
}
|
||||||
fclose($oh);
|
fclose($oh);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$rc = 8;
|
$rc = 8;
|
||||||
$msg = "Cannot open file $lPrimaryFile";
|
$msg = "Cannot open file $lPrimaryFile";
|
||||||
print $msg . " (rc=$rc).\n";
|
print $msg . " (rc=$rc).\n";
|
||||||
|
|||||||
@ -542,17 +542,17 @@ class AccountancyExport
|
|||||||
|
|
||||||
// Credit invoice - invert sens
|
// Credit invoice - invert sens
|
||||||
/*
|
/*
|
||||||
if ($data->montant < 0) {
|
if ($data->montant < 0) {
|
||||||
if ($data->sens == 'C') {
|
if ($data->sens == 'C') {
|
||||||
$Tab['sens'] = 'D';
|
$Tab['sens'] = 'D';
|
||||||
} else {
|
} else {
|
||||||
$Tab['sens'] = 'C';
|
$Tab['sens'] = 'C';
|
||||||
}
|
}
|
||||||
$Tab['signe_montant'] = '-';
|
$Tab['signe_montant'] = '-';
|
||||||
} else {
|
} else {
|
||||||
$Tab['sens'] = $data->sens; // C or D
|
$Tab['sens'] = $data->sens; // C or D
|
||||||
$Tab['signe_montant'] = '+';
|
$Tab['signe_montant'] = '+';
|
||||||
}*/
|
}*/
|
||||||
$Tab['sens'] = $data->sens; // C or D
|
$Tab['sens'] = $data->sens; // C or D
|
||||||
$Tab['signe_montant'] = '+';
|
$Tab['signe_montant'] = '+';
|
||||||
|
|
||||||
@ -856,8 +856,8 @@ class AccountancyExport
|
|||||||
|
|
||||||
foreach ($objectLines as $line) {
|
foreach ($objectLines as $line) {
|
||||||
if ($line->debit == 0 && $line->credit == 0) {
|
if ($line->debit == 0 && $line->credit == 0) {
|
||||||
//unset($array[$line]);
|
//unset($array[$line]);
|
||||||
} else {
|
} else {
|
||||||
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
|
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
|
||||||
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
|
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
|
||||||
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
|
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
|
||||||
|
|||||||
@ -63,7 +63,9 @@ if (GETPOST('addbox')) {
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
llxHeader('', $langs->trans("AccountancyArea"));
|
$help_url = '';
|
||||||
|
|
||||||
|
llxHeader('', $langs->trans("AccountancyArea"), $help_url);
|
||||||
|
|
||||||
if ($conf->accounting->enabled) {
|
if ($conf->accounting->enabled) {
|
||||||
$step = 0;
|
$step = 0;
|
||||||
@ -91,7 +93,7 @@ if ($conf->accounting->enabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial);
|
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
|
||||||
|
|
||||||
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
|
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|||||||
@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "members"));
|
$langs->loadLangs(array("admin", "members"));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$choices = array('yesno', 'texte', 'chaine');
|
$choices = array('yesno', 'texte', 'chaine');
|
||||||
@ -126,17 +128,24 @@ if ($action == 'update' || $action == 'add') {
|
|||||||
$constname = GETPOST('constname', 'alpha');
|
$constname = GETPOST('constname', 'alpha');
|
||||||
$constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
|
$constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
|
||||||
|
|
||||||
if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue = '';
|
if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) {
|
||||||
|
$constvalue = '';
|
||||||
|
}
|
||||||
if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') { // Invert choice
|
if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') { // Invert choice
|
||||||
if ($constvalue) $constvalue = 0;
|
if ($constvalue) {
|
||||||
else $constvalue = 1;
|
$constvalue = 0;
|
||||||
|
} else {
|
||||||
|
$constvalue = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$consttype = GETPOST('consttype', 'alpha');
|
$consttype = GETPOST('consttype', 'alpha');
|
||||||
$constnote = GETPOST('constnote');
|
$constnote = GETPOST('constnote');
|
||||||
$res = dolibarr_set_const($db, $constname, $constvalue, $choices[$consttype], 0, $constnote, $conf->entity);
|
$res = dolibarr_set_const($db, $constname, $constvalue, $choices[$consttype], 0, $constnote, $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
@ -211,9 +220,15 @@ print "</td></tr>\n";
|
|||||||
// Insert subscription into bank account
|
// Insert subscription into bank account
|
||||||
print '<tr class="oddeven"><td>'.$langs->trans("MoreActionsOnSubscription").'</td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("MoreActionsOnSubscription").'</td>';
|
||||||
$arraychoices = array('0'=>$langs->trans("None"));
|
$arraychoices = array('0'=>$langs->trans("None"));
|
||||||
if (!empty($conf->banque->enabled)) $arraychoices['bankdirect'] = $langs->trans("MoreActionBankDirect");
|
if (!empty($conf->banque->enabled)) {
|
||||||
if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['invoiceonly'] = $langs->trans("MoreActionInvoiceOnly");
|
$arraychoices['bankdirect'] = $langs->trans("MoreActionBankDirect");
|
||||||
if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice");
|
}
|
||||||
|
if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
|
||||||
|
$arraychoices['invoiceonly'] = $langs->trans("MoreActionInvoiceOnly");
|
||||||
|
}
|
||||||
|
if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
|
||||||
|
$arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice");
|
||||||
|
}
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0);
|
print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0);
|
||||||
if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') {
|
if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') {
|
||||||
@ -349,7 +364,9 @@ foreach ($dirmodels as $reldir) {
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
$modulequalified = 1;
|
$modulequalified = 1;
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
$modulequalified = 0;
|
$modulequalified = 0;
|
||||||
}
|
}
|
||||||
@ -404,8 +421,7 @@ foreach ($dirmodels as $reldir) {
|
|||||||
|
|
||||||
// Preview
|
// Preview
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||||
|
|||||||
@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "members"));
|
$langs->loadLangs(array("admin", "members"));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones
|
$oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones
|
||||||
@ -92,7 +94,9 @@ if ($action == 'update' || $action == 'add') {
|
|||||||
|
|
||||||
$res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
|
$res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
|
|||||||
@ -37,13 +37,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'adherent'; //Must be the $table_element of the class that manage extrafield
|
$elementtype = 'adherent'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -40,13 +40,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield
|
$elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -35,7 +35,9 @@ $langs->loadLangs(array("admin", "members"));
|
|||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,8 +45,11 @@ if (!$user->admin) accessforbidden();
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'setMEMBER_ENABLE_PUBLIC') {
|
if ($action == 'setMEMBER_ENABLE_PUBLIC') {
|
||||||
if (GETPOST('value')) dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
|
if (GETPOST('value')) {
|
||||||
else dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
|
||||||
|
} else {
|
||||||
|
dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'update') {
|
if ($action == 'update') {
|
||||||
@ -58,14 +63,17 @@ if ($action == 'update') {
|
|||||||
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
|
||||||
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
|
||||||
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
|
||||||
if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
|
if ($forcetype < 0) {
|
||||||
else {
|
$res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
|
||||||
|
} else {
|
||||||
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -195,9 +203,15 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
|
|||||||
$listofval = array();
|
$listofval = array();
|
||||||
$listofval['-1'] = $langs->trans('No');
|
$listofval['-1'] = $langs->trans('No');
|
||||||
$listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
|
$listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
|
||||||
if (!empty($conf->paybox->enabled)) $listofval['paybox'] = 'Paybox';
|
if (!empty($conf->paybox->enabled)) {
|
||||||
if (!empty($conf->paypal->enabled)) $listofval['paypal'] = 'PayPal';
|
$listofval['paybox'] = 'Paybox';
|
||||||
if (!empty($conf->stripe->enabled)) $listofval['stripe'] = 'Stripe';
|
}
|
||||||
|
if (!empty($conf->paypal->enabled)) {
|
||||||
|
$listofval['paypal'] = 'PayPal';
|
||||||
|
}
|
||||||
|
if (!empty($conf->stripe->enabled)) {
|
||||||
|
$listofval['stripe'] = 'Stripe';
|
||||||
|
}
|
||||||
print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
|
print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
|
|||||||
@ -42,16 +42,24 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortfield) $sortfield = 'a.datep,a.id';
|
if (!$sortfield) {
|
||||||
if (!$sortorder) $sortorder = 'DESC';
|
$sortfield = 'a.datep,a.id';
|
||||||
|
}
|
||||||
|
if (!$sortorder) {
|
||||||
|
$sortorder = 'DESC';
|
||||||
|
}
|
||||||
|
|
||||||
if (GETPOST('actioncode', 'array')) {
|
if (GETPOST('actioncode', 'array')) {
|
||||||
$actioncode = GETPOST('actioncode', 'array', 3);
|
$actioncode = GETPOST('actioncode', 'array', 3);
|
||||||
if (!count($actioncode)) $actioncode = '0';
|
if (!count($actioncode)) {
|
||||||
|
$actioncode = '0';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||||
}
|
}
|
||||||
@ -76,7 +84,9 @@ if ($result > 0) {
|
|||||||
|
|
||||||
$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
|
$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
// Cancel
|
// Cancel
|
||||||
@ -115,7 +125,9 @@ if ($object->id > 0) {
|
|||||||
$helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros";
|
$helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros";
|
||||||
llxHeader("", $title, $helpurl);
|
llxHeader("", $title, $helpurl);
|
||||||
|
|
||||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
if (!empty($conf->notification->enabled)) {
|
||||||
|
$langs->load("mails");
|
||||||
|
}
|
||||||
$head = member_prepare_head($object);
|
$head = member_prepare_head($object);
|
||||||
|
|
||||||
print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
|
print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
|
||||||
@ -149,8 +161,12 @@ if ($object->id > 0) {
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
$param = '&id='.$id;
|
$param = '&id='.$id;
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
$param .= '&contextpage='.$contextpage;
|
||||||
|
}
|
||||||
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
|
$param .= '&limit='.$limit;
|
||||||
|
}
|
||||||
|
|
||||||
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
|
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
|
||||||
|
|
||||||
|
|||||||
@ -64,13 +64,15 @@ abstract class ActionsAdherentCardCommon
|
|||||||
//$ret = $this->getInstanceDao();
|
//$ret = $this->getInstanceDao();
|
||||||
|
|
||||||
/*if (is_object($this->object) && method_exists($this->object,'fetch'))
|
/*if (is_object($this->object) && method_exists($this->object,'fetch'))
|
||||||
{
|
{
|
||||||
if (! empty($id)) $this->object->fetch($id);
|
if (! empty($id)) $this->object->fetch($id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{*/
|
{*/
|
||||||
$object = new Adherent($this->db);
|
$object = new Adherent($this->db);
|
||||||
if (!empty($id)) $object->fetch($id);
|
if (!empty($id)) {
|
||||||
|
$object->fetch($id);
|
||||||
|
}
|
||||||
$this->object = $object;
|
$this->object = $object;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@ -89,7 +91,9 @@ abstract class ActionsAdherentCardCommon
|
|||||||
global $conf, $langs, $user, $canvas;
|
global $conf, $langs, $user, $canvas;
|
||||||
global $form, $formcompany, $objsoc;
|
global $form, $formcompany, $objsoc;
|
||||||
|
|
||||||
if ($action == 'add' || $action == 'update') $this->assign_post();
|
if ($action == 'add' || $action == 'update') {
|
||||||
|
$this->assign_post();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->object as $key => $value) {
|
foreach ($this->object as $key => $value) {
|
||||||
$this->tpl[$key] = $value;
|
$this->tpl[$key] = $value;
|
||||||
@ -123,12 +127,24 @@ abstract class ActionsAdherentCardCommon
|
|||||||
|
|
||||||
// Predefined with third party
|
// Predefined with third party
|
||||||
if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) {
|
if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) {
|
||||||
if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address;
|
if (dol_strlen(trim($this->object->address)) == 0) {
|
||||||
if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip;
|
$this->tpl['address'] = $objsoc->address;
|
||||||
if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town;
|
}
|
||||||
if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone;
|
if (dol_strlen(trim($this->object->zip)) == 0) {
|
||||||
if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile;
|
$this->object->zip = $objsoc->zip;
|
||||||
if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email;
|
}
|
||||||
|
if (dol_strlen(trim($this->object->town)) == 0) {
|
||||||
|
$this->object->town = $objsoc->town;
|
||||||
|
}
|
||||||
|
if (dol_strlen(trim($this->object->phone_perso)) == 0) {
|
||||||
|
$this->object->phone_perso = $objsoc->phone;
|
||||||
|
}
|
||||||
|
if (dol_strlen(trim($this->object->phone_mobile)) == 0) {
|
||||||
|
$this->object->phone_mobile = $objsoc->phone_mobile;
|
||||||
|
}
|
||||||
|
if (dol_strlen(trim($this->object->email)) == 0) {
|
||||||
|
$this->object->email = $objsoc->email;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zip
|
// Zip
|
||||||
@ -137,17 +153,24 @@ abstract class ActionsAdherentCardCommon
|
|||||||
// Town
|
// Town
|
||||||
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
|
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
|
||||||
|
|
||||||
if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id;
|
if (dol_strlen(trim($this->object->country_id)) == 0) {
|
||||||
|
$this->object->country_id = $objsoc->country_id;
|
||||||
|
}
|
||||||
|
|
||||||
// Country
|
// Country
|
||||||
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
|
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
|
||||||
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||||
|
|
||||||
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
if ($user->admin) {
|
||||||
|
$this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
|
}
|
||||||
|
|
||||||
// State
|
// State
|
||||||
if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
|
if ($this->object->country_id) {
|
||||||
else $this->tpl['select_state'] = $countrynotdefined;
|
$this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
|
||||||
|
} else {
|
||||||
|
$this->tpl['select_state'] = $countrynotdefined;
|
||||||
|
}
|
||||||
|
|
||||||
// Physical or Moral
|
// Physical or Moral
|
||||||
$selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral"));
|
$selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral"));
|
||||||
@ -166,7 +189,9 @@ abstract class ActionsAdherentCardCommon
|
|||||||
$dolibarr_user = new User($this->db);
|
$dolibarr_user = new User($this->db);
|
||||||
$result = $dolibarr_user->fetch($this->object->user_id);
|
$result = $dolibarr_user->fetch($this->object->user_id);
|
||||||
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
|
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
|
||||||
} else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
|
} else {
|
||||||
|
$this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'view' || $action == 'delete') {
|
if ($action == 'view' || $action == 'delete') {
|
||||||
@ -205,7 +230,7 @@ abstract class ActionsAdherentCardCommon
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||||
$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
|
$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
|
||||||
|
|
||||||
$generated_password = getRandomPassword(false);
|
$generated_password = getRandomPassword(false);
|
||||||
$password = $generated_password;
|
$password = $generated_password;
|
||||||
|
|
||||||
// Create a form array
|
// Create a form array
|
||||||
|
|||||||
@ -60,9 +60,15 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
|
|||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
|
|
||||||
if ($action == 'view') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress"));
|
if ($action == 'view') {
|
||||||
if ($action == 'edit') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress"));
|
$out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress"));
|
||||||
if ($action == 'create') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress"));
|
}
|
||||||
|
if ($action == 'edit') {
|
||||||
|
$out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress"));
|
||||||
|
}
|
||||||
|
if ($action == 'create') {
|
||||||
|
$out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress"));
|
||||||
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,12 @@ echo "<!-- BEGIN PHP TEMPLATE ADHERENTCARD_VIEW.TPL.PHP DEFAULT -->\n";
|
|||||||
echo $this->control->tpl['showhead'];
|
echo $this->control->tpl['showhead'];
|
||||||
|
|
||||||
dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']);
|
dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']);
|
||||||
if (!empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user'];
|
if (!empty($this->control->tpl['action_create_user'])) {
|
||||||
if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?>
|
echo $this->control->tpl['action_create_user'];
|
||||||
|
}
|
||||||
|
if (!empty($this->control->tpl['action_delete'])) {
|
||||||
|
echo $this->control->tpl['action_delete'];
|
||||||
|
} ?>
|
||||||
|
|
||||||
<table class="border allwidth">
|
<table class="border allwidth">
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,9 @@ if ($id) {
|
|||||||
|
|
||||||
$parameters = array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm);
|
$parameters = array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm);
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
if ($cancel) {
|
if ($cancel) {
|
||||||
@ -141,7 +143,9 @@ if (empty($reshook)) {
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
if ($userid != $object->user_id) { // If link differs from currently in database
|
if ($userid != $object->user_id) { // If link differs from currently in database
|
||||||
$result = $object->setUserId($userid);
|
$result = $object->setUserId($userid);
|
||||||
if ($result < 0) dol_print_error($object->db, $object->error);
|
if ($result < 0) {
|
||||||
|
dol_print_error($object->db, $object->error);
|
||||||
|
}
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +173,9 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$result = $object->setThirdPartyId($socid);
|
$result = $object->setThirdPartyId($socid);
|
||||||
if ($result < 0) dol_print_error($object->db, $object->error);
|
if ($result < 0) {
|
||||||
|
dol_print_error($object->db, $object->error);
|
||||||
|
}
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,8 +227,7 @@ if (empty($reshook)) {
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
$birthdate = '';
|
$birthdate = '';
|
||||||
if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int'))
|
if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) {
|
||||||
{
|
|
||||||
$birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
|
$birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
|
||||||
}
|
}
|
||||||
$lastname = GETPOST("lastname", 'alphanohtml');
|
$lastname = GETPOST("lastname", 'alphanohtml');
|
||||||
@ -294,8 +299,11 @@ if (empty($reshook)) {
|
|||||||
//$object->note = trim(GETPOST("comment","alpha"));
|
//$object->note = trim(GETPOST("comment","alpha"));
|
||||||
$object->morphy = GETPOST("morphy", 'alpha');
|
$object->morphy = GETPOST("morphy", 'alpha');
|
||||||
|
|
||||||
if (GETPOST('deletephoto', 'alpha')) $object->photo = '';
|
if (GETPOST('deletephoto', 'alpha')) {
|
||||||
elseif (!empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
$object->photo = '';
|
||||||
|
} elseif (!empty($_FILES['photo']['name'])) {
|
||||||
|
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||||
|
}
|
||||||
|
|
||||||
// Get status and public property
|
// Get status and public property
|
||||||
$object->statut = GETPOST("statut", 'alpha');
|
$object->statut = GETPOST("statut", 'alpha');
|
||||||
@ -303,18 +311,24 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we need to also synchronize user information
|
// Check if we need to also synchronize user information
|
||||||
$nosyncuser = 0;
|
$nosyncuser = 0;
|
||||||
if ($object->user_id) { // If linked to a user
|
if ($object->user_id) { // If linked to a user
|
||||||
if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser = 1; // Disable synchronizing
|
if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) {
|
||||||
|
$nosyncuser = 1; // Disable synchronizing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we need to also synchronize password information
|
// Check if we need to also synchronize password information
|
||||||
$nosyncuserpass = 0;
|
$nosyncuserpass = 0;
|
||||||
if ($object->user_id) { // If linked to a user
|
if ($object->user_id) { // If linked to a user
|
||||||
if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass = 1; // Disable synchronizing
|
if ($user->id != $object->user_id && empty($user->rights->user->user->password)) {
|
||||||
|
$nosyncuserpass = 1; // Disable synchronizing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->update($user, 0, $nosyncuser, $nosyncuserpass);
|
$result = $object->update($user, 0, $nosyncuser, $nosyncuserpass);
|
||||||
@ -380,7 +394,9 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'add' && $user->rights->adherent->creer) {
|
if ($action == 'add' && $user->rights->adherent->creer) {
|
||||||
if ($canvas) $object->canvas = $canvas;
|
if ($canvas) {
|
||||||
|
$object->canvas = $canvas;
|
||||||
|
}
|
||||||
$birthdate = '';
|
$birthdate = '';
|
||||||
if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) {
|
if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) {
|
||||||
$birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
|
$birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
|
||||||
@ -461,7 +477,9 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($morphy) || $morphy == "-1") {
|
if (empty($morphy) || $morphy == "-1") {
|
||||||
@ -515,7 +533,9 @@ if (empty($reshook)) {
|
|||||||
setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
|
setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
|
||||||
}
|
}
|
||||||
$public = 0;
|
$public = 0;
|
||||||
if (isset($public)) $public = 1;
|
if (isset($public)) {
|
||||||
|
$public = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
@ -590,7 +610,9 @@ if (empty($reshook)) {
|
|||||||
$arraydefaultmessage = null;
|
$arraydefaultmessage = null;
|
||||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
|
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
|
||||||
|
|
||||||
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
if (!empty($labeltouse)) {
|
||||||
|
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||||
$subject = $arraydefaultmessage->topic;
|
$subject = $arraydefaultmessage->topic;
|
||||||
@ -659,7 +681,9 @@ if (empty($reshook)) {
|
|||||||
$arraydefaultmessage = null;
|
$arraydefaultmessage = null;
|
||||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
|
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
|
||||||
|
|
||||||
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
if (!empty($labeltouse)) {
|
||||||
|
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||||
$subject = $arraydefaultmessage->topic;
|
$subject = $arraydefaultmessage->topic;
|
||||||
@ -757,9 +781,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
if (empty($object->error) && $id) {
|
if (empty($object->error) && $id) {
|
||||||
$object = new Adherent($db);
|
$object = new Adherent($db);
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error('', $object->error);
|
if ($result <= 0) {
|
||||||
|
dol_print_error('', $object->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
||||||
$objcanvas->display_canvas($action); // Show template
|
$objcanvas->display_canvas($action); // Show template
|
||||||
} else {
|
} else {
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
@ -785,7 +811,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
|
|
||||||
if (!empty($socid)) {
|
if (!empty($socid)) {
|
||||||
$object = new Societe($db);
|
$object = new Societe($db);
|
||||||
if ($socid > 0) $object->fetch($socid);
|
if ($socid > 0) {
|
||||||
|
$object->fetch($socid);
|
||||||
|
}
|
||||||
|
|
||||||
if (!($object->id > 0)) {
|
if (!($object->id > 0)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
@ -832,7 +860,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
print '<input type="hidden" name="socid" value="'.$socid.'">';
|
print '<input type="hidden" name="socid" value="'.$socid.'">';
|
||||||
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
|
if ($backtopage) {
|
||||||
|
print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
|
||||||
|
}
|
||||||
|
|
||||||
print dol_get_fiche_head('');
|
print dol_get_fiche_head('');
|
||||||
|
|
||||||
@ -913,7 +943,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
$object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
|
$object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
|
||||||
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
|
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
|
||||||
print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'alpha') : $object->country_id, 'country_id');
|
print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'alpha') : $object->country_id, 'country_id');
|
||||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
if ($user->admin) {
|
||||||
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// State
|
// State
|
||||||
@ -941,7 +973,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
|
|
||||||
if (!empty($conf->socialnetworks->enabled)) {
|
if (!empty($conf->socialnetworks->enabled)) {
|
||||||
foreach ($socialnetworks as $key => $value) {
|
foreach ($socialnetworks as $key => $value) {
|
||||||
if (!$value['active']) break;
|
if (!$value['active']) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>';
|
print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1057,7 +1091,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print '<input type="hidden" name="action" value="update" />';
|
print '<input type="hidden" name="action" value="update" />';
|
||||||
print '<input type="hidden" name="rowid" value="'.$id.'" />';
|
print '<input type="hidden" name="rowid" value="'.$id.'" />';
|
||||||
print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
|
print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
|
||||||
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
|
if ($backtopage) {
|
||||||
|
print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
|
||||||
|
}
|
||||||
|
|
||||||
print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
|
print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
|
||||||
|
|
||||||
@ -1121,9 +1157,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print '<td class="hideonsmartphone" valign="middle">';
|
print '<td class="hideonsmartphone" valign="middle">';
|
||||||
print $form->showphoto('memberphoto', $object)."\n";
|
print $form->showphoto('memberphoto', $object)."\n";
|
||||||
if ($caneditfieldmember) {
|
if ($caneditfieldmember) {
|
||||||
if ($object->photo) print "<br>\n";
|
if ($object->photo) {
|
||||||
|
print "<br>\n";
|
||||||
|
}
|
||||||
print '<table class="nobordernopadding">';
|
print '<table class="nobordernopadding">';
|
||||||
if ($object->photo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
if ($object->photo) {
|
||||||
|
print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||||
|
}
|
||||||
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -1150,7 +1190,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
//$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined
|
//$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined
|
||||||
print '<tr><td>'.$langs->trans('Country').'</td><td>';
|
print '<tr><td>'.$langs->trans('Country').'</td><td>';
|
||||||
print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id');
|
print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id');
|
||||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
if ($user->admin) {
|
||||||
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// State
|
// State
|
||||||
@ -1174,7 +1216,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
|
|
||||||
if (!empty($conf->socialnetworks->enabled)) {
|
if (!empty($conf->socialnetworks->enabled)) {
|
||||||
foreach ($socialnetworks as $key => $value) {
|
foreach ($socialnetworks as $key => $value) {
|
||||||
if (!$value['active']) break;
|
if (!$value['active']) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'"></td></tr>';
|
print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'"></td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1223,7 +1267,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
|
print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
|
||||||
if ($object->user_id) {
|
if ($object->user_id) {
|
||||||
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none');
|
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none');
|
||||||
} else print $langs->trans("NoDolibarrAccess");
|
} else {
|
||||||
|
print $langs->trans("NoDolibarrAccess");
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Other attributes. Fields from hook formObjectOptions and Extrafields.
|
// Other attributes. Fields from hook formObjectOptions and Extrafields.
|
||||||
@ -1279,7 +1325,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
$login = dol_buildlogin($object->lastname, $object->firstname);
|
$login = dol_buildlogin($object->lastname, $object->firstname);
|
||||||
}
|
}
|
||||||
if (empty($login)) $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
|
if (empty($login)) {
|
||||||
|
$login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
|
||||||
|
}
|
||||||
|
|
||||||
// Create a form array
|
// Create a form array
|
||||||
$formquestion = array(
|
$formquestion = array(
|
||||||
@ -1304,10 +1352,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
|
|
||||||
if ($object->morphy == 'mor') {
|
if ($object->morphy == 'mor') {
|
||||||
$companyname = $object->company;
|
$companyname = $object->company;
|
||||||
if (!empty($fullname)) $companyalias = $fullname;
|
if (!empty($fullname)) {
|
||||||
|
$companyalias = $fullname;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$companyname = $fullname;
|
$companyname = $fullname;
|
||||||
if (!empty($object->company)) $companyalias = $object->company;
|
if (!empty($object->company)) {
|
||||||
|
$companyalias = $object->company;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a form array
|
// Create a form array
|
||||||
@ -1341,7 +1393,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
$arraydefaultmessage = null;
|
$arraydefaultmessage = null;
|
||||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
|
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
|
||||||
|
|
||||||
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
if (!empty($labeltouse)) {
|
||||||
|
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||||
$subject = $arraydefaultmessage->topic;
|
$subject = $arraydefaultmessage->topic;
|
||||||
@ -1368,7 +1422,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
|
|
||||||
// Create form popup
|
// Create form popup
|
||||||
$formquestion = array();
|
$formquestion = array();
|
||||||
if ($object->email) $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL ?true:false));
|
if ($object->email) {
|
||||||
|
$formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL ?true:false));
|
||||||
|
}
|
||||||
if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_MAILMAN)) {
|
if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_MAILMAN)) {
|
||||||
$formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value'=>'');
|
$formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value'=>'');
|
||||||
}
|
}
|
||||||
@ -1400,7 +1456,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
$arraydefaultmessage = null;
|
$arraydefaultmessage = null;
|
||||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
|
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
|
||||||
|
|
||||||
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
if (!empty($labeltouse)) {
|
||||||
|
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||||
$subject = $arraydefaultmessage->topic;
|
$subject = $arraydefaultmessage->topic;
|
||||||
@ -1427,15 +1485,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
|
|
||||||
// Create an array
|
// Create an array
|
||||||
$formquestion = array();
|
$formquestion = array();
|
||||||
if ($object->email) $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? 'true' : 'false'));
|
if ($object->email) {
|
||||||
if ($backtopage) $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
$formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? 'true' : 'false'));
|
||||||
|
}
|
||||||
|
if ($backtopage) {
|
||||||
|
$formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
||||||
|
}
|
||||||
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resign", $formquestion, 'no', 1, 240);
|
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resign", $formquestion, 'no', 1, 240);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm remove member
|
// Confirm remove member
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
$formquestion = array();
|
$formquestion = array();
|
||||||
if ($backtopage) $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
if ($backtopage) {
|
||||||
|
$formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
||||||
|
}
|
||||||
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1);
|
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1449,8 +1513,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rowspan = 17;
|
$rowspan = 17;
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||||
if (!empty($conf->societe->enabled)) $rowspan++;
|
$rowspan++;
|
||||||
|
}
|
||||||
|
if (!empty($conf->societe->enabled)) {
|
||||||
|
$rowspan++;
|
||||||
|
}
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
@ -1477,7 +1545,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
// Gender
|
// Gender
|
||||||
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if ($object->gender) print $langs->trans("Gender".$object->gender);
|
if ($object->gender) {
|
||||||
|
print $langs->trans("Gender".$object->gender);
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
@ -1490,10 +1560,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
// Password
|
// Password
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||||
print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
|
print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
|
||||||
if ($object->pass) print preg_replace('/./i', '*', $object->pass);
|
if ($object->pass) {
|
||||||
else {
|
print preg_replace('/./i', '*', $object->pass);
|
||||||
if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
|
} else {
|
||||||
else print $langs->trans("Hidden");
|
if ($user->admin) {
|
||||||
|
print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
|
||||||
|
} else {
|
||||||
|
print $langs->trans("Hidden");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
|
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
@ -1515,14 +1589,44 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print $langs->trans("SubscriptionNotNeeded");
|
print $langs->trans("SubscriptionNotNeeded");
|
||||||
} elseif (!$adht->subscription) {
|
} elseif (!$adht->subscription) {
|
||||||
print $langs->trans("SubscriptionNotRecorded");
|
print $langs->trans("SubscriptionNotRecorded");
|
||||||
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
|
if ($object->statut > 0) {
|
||||||
|
print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print $langs->trans("SubscriptionNotReceived");
|
print $langs->trans("SubscriptionNotReceived");
|
||||||
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
|
if ($object->statut > 0) {
|
||||||
|
print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
|
||||||
|
print '<table class="border tableforfield tableforfield" width="100%">';
|
||||||
|
|
||||||
|
// Birth Date
|
||||||
|
print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
|
||||||
|
|
||||||
|
// Public
|
||||||
|
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
|
||||||
|
print '<tr><td>'.$langs->trans("Categories").'</td>';
|
||||||
|
print '<td colspan="2">';
|
||||||
|
print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other attributes
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
||||||
|
|
||||||
// Third party Dolibarr
|
// Third party Dolibarr
|
||||||
if (!empty($conf->societe->enabled)) {
|
if (!empty($conf->societe->enabled)) {
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
@ -1566,34 +1670,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
$linkeduser->fetch($object->user_id);
|
$linkeduser->fetch($object->user_id);
|
||||||
print $linkeduser->getNomUrl(-1);
|
print $linkeduser->getNomUrl(-1);
|
||||||
} else {
|
} else {
|
||||||
print $langs->trans("NoDolibarrAccess");
|
print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print '<div class="fichehalfright"><div class="ficheaddleft">';
|
|
||||||
print '<div class="underbanner clearboth"></div>';
|
|
||||||
|
|
||||||
print '<table class="border tableforfield tableforfield" width="100%">';
|
|
||||||
|
|
||||||
// Birth Date
|
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
|
|
||||||
|
|
||||||
// Public
|
|
||||||
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
|
|
||||||
|
|
||||||
// Categories
|
|
||||||
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
|
|
||||||
print '<tr><td>'.$langs->trans("Categories").'</td>';
|
|
||||||
print '<td colspan="2">';
|
|
||||||
print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
//VCard
|
//VCard
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $langs->trans("VCard").'</td><td colspan="3">';
|
print $langs->trans("VCard").'</td><td colspan="3">';
|
||||||
@ -1603,9 +1684,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print '</a>';
|
print '</a>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Other attributes
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
print "</div></div></div>\n";
|
print "</div></div></div>\n";
|
||||||
@ -1687,8 +1765,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
// Create third party
|
// Create third party
|
||||||
if (!empty($conf->societe->enabled) && !$object->socid) {
|
if (!empty($conf->societe->enabled) && !$object->socid) {
|
||||||
if ($user->rights->societe->creer) {
|
if ($user->rights->societe->creer) {
|
||||||
if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
|
if ($object->statut != -1) {
|
||||||
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
|
||||||
|
} else {
|
||||||
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty")."</font></div>";
|
print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty")."</font></div>";
|
||||||
}
|
}
|
||||||
@ -1697,8 +1778,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
// Create user
|
// Create user
|
||||||
if (!$user->socid && !$object->user_id) {
|
if (!$user->socid && !$object->user_id) {
|
||||||
if ($user->rights->user->user->creer) {
|
if ($user->rights->user->user->creer) {
|
||||||
if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
|
if ($object->statut != -1) {
|
||||||
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
|
||||||
|
} else {
|
||||||
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</font></div>";
|
print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</font></div>";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,8 +80,12 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
|||||||
}
|
}
|
||||||
$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
|
$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
|
||||||
$sql .= " AND d.entity IN (".getEntity('adherent').")";
|
$sql .= " AND d.entity IN (".getEntity('adherent').")";
|
||||||
if (is_numeric($foruserid)) $sql .= " AND d.rowid=".(int) $foruserid;
|
if (is_numeric($foruserid)) {
|
||||||
if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'";
|
$sql .= " AND d.rowid=".(int) $foruserid;
|
||||||
|
}
|
||||||
|
if ($foruserlogin) {
|
||||||
|
$sql .= " AND d.login='".$db->escape($foruserlogin)."'";
|
||||||
|
}
|
||||||
$sql .= " ORDER BY d.rowid ASC";
|
$sql .= " ORDER BY d.rowid ASC";
|
||||||
|
|
||||||
dol_syslog("Search members", LOG_DEBUG);
|
dol_syslog("Search members", LOG_DEBUG);
|
||||||
@ -92,7 +96,9 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
|||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
if ($objp->country == '-') $objp->country = '';
|
if ($objp->country == '-') {
|
||||||
|
$objp->country = '';
|
||||||
|
}
|
||||||
|
|
||||||
$adherentstatic->id = $objp->rowid;
|
$adherentstatic->id = $objp->rowid;
|
||||||
$adherentstatic->ref = $objp->ref;
|
$adherentstatic->ref = $objp->ref;
|
||||||
@ -147,7 +153,9 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
|||||||
|
|
||||||
if (is_numeric($foruserid) || $foruserlogin) {
|
if (is_numeric($foruserid) || $foruserlogin) {
|
||||||
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
|
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
|
||||||
if ($nb <= 0) $nb = 1; // Protection to avoid empty page
|
if ($nb <= 0) {
|
||||||
|
$nb = 1; // Protection to avoid empty page
|
||||||
|
}
|
||||||
|
|
||||||
for ($j = 0; $j < $nb; $j++) {
|
for ($j = 0; $j < $nb; $j++) {
|
||||||
$arrayofmembers[] = array(
|
$arrayofmembers[] = array(
|
||||||
@ -175,7 +183,9 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
|||||||
|
|
||||||
// For labels
|
// For labels
|
||||||
if ($mode == 'label') {
|
if ($mode == 'label') {
|
||||||
if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
|
if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) {
|
||||||
|
$conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
|
||||||
|
}
|
||||||
$textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
|
$textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
|
||||||
$textheader = '';
|
$textheader = '';
|
||||||
$textfooter = '';
|
$textfooter = '';
|
||||||
@ -203,7 +213,9 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
|||||||
if (empty($model) || $model == '-1') {
|
if (empty($model) || $model == '-1') {
|
||||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
|
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
|
||||||
}
|
}
|
||||||
if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
|
if (!$mesg) {
|
||||||
|
$result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
|
||||||
|
}
|
||||||
} elseif ($mode == 'label') {
|
} elseif ($mode == 'label') {
|
||||||
if (!count($arrayofmembers)) {
|
if (!count($arrayofmembers)) {
|
||||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||||
@ -211,7 +223,9 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
|||||||
if (empty($modellabel) || $modellabel == '-1') {
|
if (empty($modellabel) || $modellabel == '-1') {
|
||||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
|
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
|
||||||
}
|
}
|
||||||
if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs);
|
if (!$mesg) {
|
||||||
|
$result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0) {
|
if ($result <= 0) {
|
||||||
|
|||||||
@ -373,18 +373,24 @@ class Adherent extends CommonObject
|
|||||||
// Detect if message is HTML
|
// Detect if message is HTML
|
||||||
if ($msgishtml == -1) {
|
if ($msgishtml == -1) {
|
||||||
$msgishtml = 0;
|
$msgishtml = 0;
|
||||||
if (dol_textishtml($text, 0)) $msgishtml = 1;
|
if (dol_textishtml($text, 0)) {
|
||||||
|
$msgishtml = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog('send_an_email msgishtml='.$msgishtml);
|
dol_syslog('send_an_email msgishtml='.$msgishtml);
|
||||||
|
|
||||||
$texttosend = $this->makeSubstitution($text);
|
$texttosend = $this->makeSubstitution($text);
|
||||||
$subjecttosend = $this->makeSubstitution($subject);
|
$subjecttosend = $this->makeSubstitution($subject);
|
||||||
if ($msgishtml) $texttosend = dol_htmlentitiesbr($texttosend);
|
if ($msgishtml) {
|
||||||
|
$texttosend = dol_htmlentitiesbr($texttosend);
|
||||||
|
}
|
||||||
|
|
||||||
// Envoi mail confirmation
|
// Envoi mail confirmation
|
||||||
$from = $conf->email_from;
|
$from = $conf->email_from;
|
||||||
if (!empty($conf->global->ADHERENT_MAIL_FROM)) $from = $conf->global->ADHERENT_MAIL_FROM;
|
if (!empty($conf->global->ADHERENT_MAIL_FROM)) {
|
||||||
|
$from = $conf->global->ADHERENT_MAIL_FROM;
|
||||||
|
}
|
||||||
|
|
||||||
$trackid = 'mem'.$this->id;
|
$trackid = 'mem'.$this->id;
|
||||||
|
|
||||||
@ -413,10 +419,14 @@ class Adherent extends CommonObject
|
|||||||
$birthday = dol_print_date($this->birth, 'day');
|
$birthday = dol_print_date($this->birth, 'day');
|
||||||
|
|
||||||
$msgishtml = 0;
|
$msgishtml = 0;
|
||||||
if (dol_textishtml($text, 1)) $msgishtml = 1;
|
if (dol_textishtml($text, 1)) {
|
||||||
|
$msgishtml = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$infos = '';
|
$infos = '';
|
||||||
if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n";
|
if ($this->civility_id) {
|
||||||
|
$infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n";
|
||||||
|
}
|
||||||
$infos .= $langs->transnoentities("id").": ".$this->id."\n";
|
$infos .= $langs->transnoentities("id").": ".$this->id."\n";
|
||||||
$infos .= $langs->transnoentities("ref").": ".$this->ref."\n";
|
$infos .= $langs->transnoentities("ref").": ".$this->ref."\n";
|
||||||
$infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
|
$infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
|
||||||
@ -514,7 +524,9 @@ class Adherent extends CommonObject
|
|||||||
$this->error = $langs->trans("ErrorBadEMail", $this->email);
|
$this->error = $langs->trans("ErrorBadEMail", $this->email);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!$this->datec) $this->datec = $now;
|
if (!$this->datec) {
|
||||||
|
$this->datec = $now;
|
||||||
|
}
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||||
if (empty($this->login)) {
|
if (empty($this->login)) {
|
||||||
$this->error = $langs->trans("ErrorWrongValueForParameterX", "Login");
|
$this->error = $langs->trans("ErrorWrongValueForParameterX", "Login");
|
||||||
@ -669,9 +681,15 @@ class Adherent extends CommonObject
|
|||||||
$sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid);
|
$sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid);
|
||||||
$sql .= ", morphy = '".$this->db->escape($this->morphy)."'";
|
$sql .= ", morphy = '".$this->db->escape($this->morphy)."'";
|
||||||
$sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null");
|
$sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null");
|
||||||
if ($this->socid) $sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party
|
if ($this->socid) {
|
||||||
if ($this->datefin) $sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
|
$sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party
|
||||||
if ($this->datevalid) $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member
|
}
|
||||||
|
if ($this->datefin) {
|
||||||
|
$sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
|
||||||
|
}
|
||||||
|
if ($this->datevalid) {
|
||||||
|
$sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member
|
||||||
|
}
|
||||||
$sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest
|
$sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
@ -716,7 +734,9 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
// If password to set differs from the one found into database
|
// If password to set differs from the one found into database
|
||||||
$result = $this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
|
$result = $this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
|
||||||
if (!$nbrowsaffected) $nbrowsaffected++;
|
if (!$nbrowsaffected) {
|
||||||
|
$nbrowsaffected++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,7 +779,9 @@ class Adherent extends CommonObject
|
|||||||
//var_dump($this->login);exit;
|
//var_dump($this->login);exit;
|
||||||
|
|
||||||
// If option ADHERENT_LOGIN_NOT_REQUIRED is on, there is no login of member, so we do not overwrite user login to keep existing one.
|
// If option ADHERENT_LOGIN_NOT_REQUIRED is on, there is no login of member, so we do not overwrite user login to keep existing one.
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login = $this->login;
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||||
|
$luser->login = $this->login;
|
||||||
|
}
|
||||||
|
|
||||||
$luser->ref = $this->ref;
|
$luser->ref = $this->ref;
|
||||||
$luser->civility_id = $this->civility_id;
|
$luser->civility_id = $this->civility_id;
|
||||||
@ -925,14 +947,18 @@ class Adherent extends CommonObject
|
|||||||
$errorflag = 0;
|
$errorflag = 0;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($rowid)) $rowid = $this->id;
|
if (empty($rowid)) {
|
||||||
|
$rowid = $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$error && !$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('MEMBER_DELETE', $user);
|
$result = $this->call_trigger('MEMBER_DELETE', $user);
|
||||||
if ($result < 0) $error++;
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1474,7 +1500,9 @@ class Adherent extends CommonObject
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (!$amount) $amount = 0;
|
if (!$amount) {
|
||||||
|
$amount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -1605,10 +1633,14 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
if ($this->morphy == 'mor') {
|
if ($this->morphy == 'mor') {
|
||||||
$companyname = $this->company;
|
$companyname = $this->company;
|
||||||
if (!empty($fullname)) $companyalias = $fullname;
|
if (!empty($fullname)) {
|
||||||
|
$companyalias = $fullname;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$companyname = $fullname;
|
$companyname = $fullname;
|
||||||
if (!empty($this->company)) $companyalias = $this->company;
|
if (!empty($this->company)) {
|
||||||
|
$companyalias = $this->company;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $customer->create_from_member($this, $companyname, $companyalias);
|
$result = $customer->create_from_member($this, $companyname, $companyalias);
|
||||||
@ -1671,7 +1703,9 @@ class Adherent extends CommonObject
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
// Add line to draft invoice
|
// Add line to draft invoice
|
||||||
$idprodsubscription = 0;
|
$idprodsubscription = 0;
|
||||||
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
|
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
|
||||||
|
$idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
|
||||||
|
}
|
||||||
|
|
||||||
$vattouse = 0;
|
$vattouse = 0;
|
||||||
if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') {
|
if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') {
|
||||||
@ -1758,8 +1792,12 @@ class Adherent extends CommonObject
|
|||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang = '';
|
$newlang = '';
|
||||||
$lang_id = GETPOST('lang_id');
|
$lang_id = GETPOST('lang_id');
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($lang_id)) $newlang = $lang_id;
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($lang_id)) {
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $customer->default_lang;
|
$newlang = $lang_id;
|
||||||
|
}
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
|
||||||
|
$newlang = $customer->default_lang;
|
||||||
|
}
|
||||||
if (!empty($newlang)) {
|
if (!empty($newlang)) {
|
||||||
$outputlangs = new Translate("", $conf);
|
$outputlangs = new Translate("", $conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
@ -1901,7 +1939,9 @@ class Adherent extends CommonObject
|
|||||||
$result = $mailmanspip->add_to_mailman($this);
|
$result = $mailmanspip->add_to_mailman($this);
|
||||||
|
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error;
|
if (!empty($mailmanspip->error)) {
|
||||||
|
$this->errors[] = $mailmanspip->error;
|
||||||
|
}
|
||||||
$err += 1;
|
$err += 1;
|
||||||
}
|
}
|
||||||
foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
|
foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
|
||||||
@ -1950,7 +1990,9 @@ class Adherent extends CommonObject
|
|||||||
if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
|
if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
|
||||||
$result = $mailmanspip->del_to_mailman($this);
|
$result = $mailmanspip->del_to_mailman($this);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error;
|
if (!empty($mailmanspip->error)) {
|
||||||
|
$this->errors[] = $mailmanspip->error;
|
||||||
|
}
|
||||||
$err += 1;
|
$err += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1991,7 +2033,9 @@ class Adherent extends CommonObject
|
|||||||
$langs->load("dict");
|
$langs->load("dict");
|
||||||
|
|
||||||
$code = (empty($this->civility_id) ? '' : $this->civility_id);
|
$code = (empty($this->civility_id) ? '' : $this->civility_id);
|
||||||
if (empty($code)) return '';
|
if (empty($code)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
|
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2012,7 +2056,9 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0;
|
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) {
|
||||||
|
$withpictoimg = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$result = '';
|
$result = '';
|
||||||
$label = '';
|
$label = '';
|
||||||
@ -2028,9 +2074,15 @@ class Adherent extends CommonObject
|
|||||||
$label .= '<div class="centpercent">';
|
$label .= '<div class="centpercent">';
|
||||||
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Member").'</u>';
|
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Member").'</u>';
|
||||||
$label .= ' '.$this->getLibStatut(4);
|
$label .= ' '.$this->getLibStatut(4);
|
||||||
if (!empty($this->ref)) $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
if (!empty($this->ref)) {
|
||||||
if (!empty($this->firstname) || !empty($this->lastname)) $label .= '<br><b>'.$langs->trans('Name').':</b> '.$this->getFullName($langs);
|
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||||
if (!empty($this->company)) $label .= '<br><b>'.$langs->trans('Company').':</b> '.$this->company;
|
}
|
||||||
|
if (!empty($this->firstname) || !empty($this->lastname)) {
|
||||||
|
$label .= '<br><b>'.$langs->trans('Name').':</b> '.$this->getFullName($langs);
|
||||||
|
}
|
||||||
|
if (!empty($this->company)) {
|
||||||
|
$label .= '<br><b>'.$langs->trans('Company').':</b> '.$this->company;
|
||||||
|
}
|
||||||
$label .= '</div>';
|
$label .= '</div>';
|
||||||
|
|
||||||
$url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id;
|
$url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id;
|
||||||
@ -2041,8 +2093,12 @@ class Adherent extends CommonObject
|
|||||||
if ($option != 'nolink') {
|
if ($option != 'nolink') {
|
||||||
// Add param to save lastsearch_values or not
|
// Add param to save lastsearch_values or not
|
||||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
$add_save_lastsearch_values = 1;
|
||||||
|
}
|
||||||
|
if ($add_save_lastsearch_values) {
|
||||||
|
$url .= '&save_lastsearch_values=1';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$linkstart .= '<a href="'.$url.'"';
|
$linkstart .= '<a href="'.$url.'"';
|
||||||
@ -2061,16 +2117,20 @@ class Adherent extends CommonObject
|
|||||||
$linkend = '</a>';
|
$linkend = '</a>';
|
||||||
|
|
||||||
$result .= $linkstart;
|
$result .= $linkstart;
|
||||||
if ($withpictoimg) $result .= '<div class="inline-block nopadding valignmiddle">';
|
if ($withpictoimg) {
|
||||||
|
$result .= '<div class="inline-block nopadding valignmiddle">';
|
||||||
|
}
|
||||||
if ($withpictoimg) {
|
if ($withpictoimg) {
|
||||||
$paddafterimage = '';
|
$paddafterimage = '';
|
||||||
if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-right: 3px;"';
|
if (abs($withpictoimg) == 1) {
|
||||||
|
$paddafterimage = 'style="margin-right: 3px;"';
|
||||||
|
}
|
||||||
// Only picto
|
// Only picto
|
||||||
if ($withpictoimg > 0)
|
if ($withpictoimg > 0) {
|
||||||
$picto = '<span class="nopadding'.($morecss ? ' userimg'.$morecss : '').'">'.
|
$picto = '<span class="nopadding'.($morecss ? ' userimg'.$morecss : '').'">'.
|
||||||
img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).'</span>';
|
img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).'</span>';
|
||||||
// Picto must be a photo
|
} else {
|
||||||
else {
|
// Picto must be a photo
|
||||||
$picto = '<span class="nopadding'.($morecss ? ' userimg'.$morecss : '').'"'.($paddafterimage ? ' '.$paddafterimage : '').'>';
|
$picto = '<span class="nopadding'.($morecss ? ' userimg'.$morecss : '').'"'.($paddafterimage ? ' '.$paddafterimage : '').'>';
|
||||||
$picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1);
|
$picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1);
|
||||||
$picto .= '</span>';
|
$picto .= '</span>';
|
||||||
@ -2078,8 +2138,10 @@ class Adherent extends CommonObject
|
|||||||
$result .= $picto;
|
$result .= $picto;
|
||||||
}
|
}
|
||||||
if ($withpictoimg > -2 && $withpictoimg != 2) {
|
if ($withpictoimg > -2 && $withpictoimg != 2) {
|
||||||
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= '<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ? '' : ' strikefordisabled').
|
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||||
|
$result .= '<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ? '' : ' strikefordisabled').
|
||||||
($morecss ? ' usertext'.$morecss : '').'">';
|
($morecss ? ' usertext'.$morecss : '').'">';
|
||||||
|
}
|
||||||
if ($mode == 'login') {
|
if ($mode == 'login') {
|
||||||
$result .= dol_trunc($this->login, $maxlen);
|
$result .= dol_trunc($this->login, $maxlen);
|
||||||
} elseif ($mode == 'ref') {
|
} elseif ($mode == 'ref') {
|
||||||
@ -2087,9 +2149,13 @@ class Adherent extends CommonObject
|
|||||||
} else {
|
} else {
|
||||||
$result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen);
|
$result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen);
|
||||||
}
|
}
|
||||||
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= '</span>';
|
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||||
|
$result .= '</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($withpictoimg) {
|
||||||
|
$result .= '</div>';
|
||||||
}
|
}
|
||||||
if ($withpictoimg) $result .= '</div>';
|
|
||||||
$result .= $linkend;
|
$result .= $linkend;
|
||||||
|
|
||||||
if ($addlinktonotes) {
|
if ($addlinktonotes) {
|
||||||
@ -2214,7 +2280,9 @@ class Adherent extends CommonObject
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe
|
if ($user->socid) {
|
||||||
|
return -1; // protection pour eviter appel par utilisateur externe
|
||||||
|
}
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
@ -2398,9 +2466,15 @@ class Adherent extends CommonObject
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
$dn = '';
|
$dn = '';
|
||||||
if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN;
|
if ($mode == 0) {
|
||||||
if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_DN;
|
$dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN;
|
||||||
if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS];
|
}
|
||||||
|
if ($mode == 1) {
|
||||||
|
$dn = $conf->global->LDAP_MEMBER_DN;
|
||||||
|
}
|
||||||
|
if ($mode == 2) {
|
||||||
|
$dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS];
|
||||||
|
}
|
||||||
return $dn;
|
return $dn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2448,31 +2522,65 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
// Check if it is the LDAP key and if its value has been changed
|
// Check if it is the LDAP key and if its value has been changed
|
||||||
if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) {
|
if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) {
|
||||||
if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified = true; // For check if LDAP key has been modified
|
if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
|
||||||
|
$keymodified = true; // For check if LDAP key has been modified
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
|
if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) {
|
||||||
if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
|
$info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
|
||||||
if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company;
|
}
|
||||||
if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
|
if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) {
|
||||||
if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
|
$info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
|
||||||
if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
|
}
|
||||||
if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
|
if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company;
|
||||||
|
}
|
||||||
|
if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
|
||||||
|
}
|
||||||
|
if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
|
||||||
|
}
|
||||||
|
if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
|
||||||
|
}
|
||||||
|
if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
|
||||||
|
}
|
||||||
foreach ($socialnetworks as $key => $value) {
|
foreach ($socialnetworks as $key => $value) {
|
||||||
if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])})) {
|
if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])})) {
|
||||||
$info[$conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']];
|
$info[$conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
|
if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) {
|
||||||
if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
|
$info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
|
||||||
if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
|
}
|
||||||
if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
|
if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) {
|
||||||
if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
|
$info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
|
||||||
if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2);
|
}
|
||||||
if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth, 'dayhourldap');
|
if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) {
|
||||||
if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
|
$info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
|
||||||
if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin, 'dayhourldap');
|
}
|
||||||
|
if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
|
||||||
|
}
|
||||||
|
if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
|
||||||
|
}
|
||||||
|
if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2);
|
||||||
|
}
|
||||||
|
if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth, 'dayhourldap');
|
||||||
|
}
|
||||||
|
if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
|
||||||
|
$info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
|
||||||
|
}
|
||||||
|
if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) {
|
||||||
|
$info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin, 'dayhourldap');
|
||||||
|
}
|
||||||
|
|
||||||
// When password is modified
|
// When password is modified
|
||||||
if (!empty($this->pass)) {
|
if (!empty($this->pass)) {
|
||||||
@ -2482,8 +2590,9 @@ class Adherent extends CommonObject
|
|||||||
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
|
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
|
||||||
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption)
|
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption)
|
||||||
}
|
}
|
||||||
} // Set LDAP password if possible
|
} elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') {
|
||||||
elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password
|
// Set LDAP password if possible
|
||||||
|
// If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password
|
||||||
if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
|
if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
|
||||||
// Just for the default MD5 !
|
// Just for the default MD5 !
|
||||||
if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
|
if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
|
||||||
@ -2493,18 +2602,30 @@ class Adherent extends CommonObject
|
|||||||
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted));
|
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // Use $this->pass_indatabase value if exists
|
} elseif (!empty($this->pass_indatabase)) {
|
||||||
elseif (!empty($this->pass_indatabase)) {
|
// Use $this->pass_indatabase value if exists
|
||||||
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte
|
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
|
||||||
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption
|
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte
|
||||||
|
}
|
||||||
|
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date, 'dayhourldap');
|
if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) {
|
||||||
if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
|
$info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date, 'dayhourldap');
|
||||||
if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date, 'dayhourldap');
|
}
|
||||||
if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
|
if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) {
|
||||||
|
$info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
|
||||||
|
}
|
||||||
|
if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) {
|
||||||
|
$info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date, 'dayhourldap');
|
||||||
|
}
|
||||||
|
if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) {
|
||||||
|
$info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
|
||||||
|
}
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
@ -2626,8 +2747,12 @@ class Adherent extends CommonObject
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
//Only valid members
|
//Only valid members
|
||||||
if ($this->statut <= 0) return false;
|
if ($this->statut <= 0) {
|
||||||
if (!$this->datefin) return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (!$this->datefin) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
@ -2720,7 +2845,9 @@ class Adherent extends CommonObject
|
|||||||
$arraydefaultmessage = null;
|
$arraydefaultmessage = null;
|
||||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION;
|
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION;
|
||||||
|
|
||||||
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
if (!empty($labeltouse)) {
|
||||||
|
$arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $adherent);
|
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $adherent);
|
||||||
@ -2763,7 +2890,9 @@ class Adherent extends CommonObject
|
|||||||
if ($message) {
|
if ($message) {
|
||||||
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
|
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
|
||||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
|
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
|
||||||
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
|
if ($sendtocc) {
|
||||||
|
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
|
||||||
|
}
|
||||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
|
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
|
||||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
|
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
|
||||||
$actionmsg = dol_concatdesc($actionmsg, $message);
|
$actionmsg = dol_concatdesc($actionmsg, $message);
|
||||||
@ -2843,7 +2972,9 @@ class Adherent extends CommonObject
|
|||||||
$listofids .= $idmember;
|
$listofids .= $idmember;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if ($listofids) $listofids .= ']';
|
if ($listofids) {
|
||||||
|
$listofids .= ']';
|
||||||
|
}
|
||||||
$this->output .= $listofids;
|
$this->output .= $listofids;
|
||||||
}
|
}
|
||||||
if ($nbko) {
|
if ($nbko) {
|
||||||
@ -2864,7 +2995,9 @@ class Adherent extends CommonObject
|
|||||||
$listofids .= $idmember;
|
$listofids .= $idmember;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if ($listofids) $listofids .= ']';
|
if ($listofids) {
|
||||||
|
$listofids .= ']';
|
||||||
|
}
|
||||||
$this->output .= $listofids;
|
$this->output .= $listofids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,8 +74,8 @@ class AdherentType extends CommonObject
|
|||||||
public $duration;
|
public $duration;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* type expiration
|
* type expiration
|
||||||
*/
|
*/
|
||||||
public $duration_value;
|
public $duration_value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,12 +241,12 @@ class AdherentType extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a language for this member type
|
* Delete a language for this member type
|
||||||
*
|
*
|
||||||
* @param string $langtodelete Language code to delete
|
* @param string $langtodelete Language code to delete
|
||||||
* @param User $user Object user making delete
|
* @param User $user Object user making delete
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function delMultiLangs($langtodelete, $user)
|
public function delMultiLangs($langtodelete, $user)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
||||||
@ -313,7 +313,9 @@ class AdherentType extends CommonObject
|
|||||||
if (!$notrigger) {
|
if (!$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
|
$result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +388,9 @@ class AdherentType extends CommonObject
|
|||||||
if (!$error && !$notrigger) {
|
if (!$error && !$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
|
$result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +427,9 @@ class AdherentType extends CommonObject
|
|||||||
if ($resql) {
|
if ($resql) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('MEMBER_TYPE_DELETE', $user);
|
$result = $this->call_trigger('MEMBER_TYPE_DELETE', $user);
|
||||||
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
|
if ($result < 0) {
|
||||||
|
$error++; $this->db->rollback(); return -2;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@ -499,7 +505,9 @@ class AdherentType extends CommonObject
|
|||||||
$sql = "SELECT rowid, libelle as label";
|
$sql = "SELECT rowid, libelle as label";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
|
||||||
$sql .= " WHERE entity IN (".getEntity('member_type').")";
|
$sql .= " WHERE entity IN (".getEntity('member_type').")";
|
||||||
if ($status >= 0) $sql .= " AND statut = ".((int) $status);
|
if ($status >= 0) {
|
||||||
|
$sql .= " AND statut = ".((int) $status);
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
@ -539,7 +547,9 @@ class AdherentType extends CommonObject
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
||||||
$sql .= " WHERE a.entity IN (".getEntity('member').")";
|
$sql .= " WHERE a.entity IN (".getEntity('member').")";
|
||||||
$sql .= " AND a.fk_adherent_type = ".$this->id;
|
$sql .= " AND a.fk_adherent_type = ".$this->id;
|
||||||
if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
|
if (!empty($excludefilter)) {
|
||||||
|
$sql .= ' AND ('.$excludefilter.')';
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
|
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -554,7 +564,9 @@ class AdherentType extends CommonObject
|
|||||||
$memberstatic->fetch($obj->rowid);
|
$memberstatic->fetch($obj->rowid);
|
||||||
}
|
}
|
||||||
$ret[$obj->rowid] = $memberstatic;
|
$ret[$obj->rowid] = $memberstatic;
|
||||||
} else $ret[$obj->rowid] = $obj->rowid;
|
} else {
|
||||||
|
$ret[$obj->rowid] = $obj->rowid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +590,13 @@ class AdherentType extends CommonObject
|
|||||||
public function getmorphylib($morphy = '')
|
public function getmorphylib($morphy = '')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
if ($morphy == 'phy') { return $langs->trans("Physical"); } elseif ($morphy == 'mor') { return $langs->trans("Moral"); } else return $langs->trans("MorAndPhy");
|
if ($morphy == 'phy') {
|
||||||
|
return $langs->trans("Physical");
|
||||||
|
} elseif ($morphy == 'mor') {
|
||||||
|
return $langs->trans("Moral");
|
||||||
|
} else {
|
||||||
|
return $langs->trans("MorAndPhy");
|
||||||
|
}
|
||||||
//return $morphy;
|
//return $morphy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,8 +627,12 @@ class AdherentType extends CommonObject
|
|||||||
$linkend = '</a>';
|
$linkend = '</a>';
|
||||||
|
|
||||||
$result .= $linkstart;
|
$result .= $linkstart;
|
||||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
if ($withpicto) {
|
||||||
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
|
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||||
|
}
|
||||||
|
if ($withpicto != 2) {
|
||||||
|
$result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
|
||||||
|
}
|
||||||
$result .= $linkend;
|
$result .= $linkend;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -642,7 +664,9 @@ class AdherentType extends CommonObject
|
|||||||
$langs->load('companies');
|
$langs->load('companies');
|
||||||
|
|
||||||
$statusType = 'status4';
|
$statusType = 'status4';
|
||||||
if ($status == 0) $statusType = 'status5';
|
if ($status == 0) {
|
||||||
|
$statusType = 'status5';
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||||
$this->labelStatus[0] = $langs->trans("ActivityCeased");
|
$this->labelStatus[0] = $langs->trans("ActivityCeased");
|
||||||
@ -670,9 +694,15 @@ class AdherentType extends CommonObject
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
$dn = '';
|
$dn = '';
|
||||||
if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
|
if ($mode == 0) {
|
||||||
if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
|
$dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
|
||||||
if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
|
}
|
||||||
|
if ($mode == 1) {
|
||||||
|
$dn = $conf->global->LDAP_MEMBER_TYPE_DN;
|
||||||
|
}
|
||||||
|
if ($mode == 2) {
|
||||||
|
$dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
|
||||||
|
}
|
||||||
return $dn;
|
return $dn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,11 +725,15 @@ class AdherentType extends CommonObject
|
|||||||
$info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
|
$info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
|
||||||
|
|
||||||
// Champs
|
// Champs
|
||||||
if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
|
if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) {
|
||||||
if ($this->note && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
|
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
|
||||||
|
}
|
||||||
|
if ($this->note && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) {
|
||||||
|
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
|
||||||
|
}
|
||||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) {
|
if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) {
|
||||||
$valueofldapfield = array();
|
$valueofldapfield = array();
|
||||||
foreach ($this->members as $key=>$val) { // This is array of users for group into dolibarr database.
|
foreach ($this->members as $key => $val) { // This is array of users for group into dolibarr database.
|
||||||
$member = new Adherent($this->db);
|
$member = new Adherent($this->db);
|
||||||
$member->fetch($val->id, '', '', '', false, false);
|
$member->fetch($val->id, '', '', '', false, false);
|
||||||
$info2 = $member->_load_ldap_info();
|
$info2 = $member->_load_ldap_info();
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class Members extends DolibarrApi
|
|||||||
/**
|
/**
|
||||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
*/
|
*/
|
||||||
static $FIELDS = array(
|
public static $FIELDS = array(
|
||||||
'morphy',
|
'morphy',
|
||||||
'typeid'
|
'typeid'
|
||||||
);
|
);
|
||||||
@ -325,7 +325,9 @@ class Members extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request_data as $field => $value) {
|
foreach ($request_data as $field => $value) {
|
||||||
if ($field == 'id') continue;
|
if ($field == 'id') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Process the status separately because it must be updated using
|
// Process the status separately because it must be updated using
|
||||||
// the validate() and resiliate() methods of the class Adherent.
|
// the validate() and resiliate() methods of the class Adherent.
|
||||||
if ($field == 'statut') {
|
if ($field == 'statut') {
|
||||||
@ -399,8 +401,9 @@ class Members extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$member = array();
|
$member = array();
|
||||||
foreach (Members::$FIELDS as $field) {
|
foreach (Members::$FIELDS as $field) {
|
||||||
if (!isset($data[$field]))
|
if (!isset($data[$field])) {
|
||||||
throw new RestException(400, "$field field missing");
|
throw new RestException(400, "$field field missing");
|
||||||
|
}
|
||||||
$member[$field] = $data[$field];
|
$member[$field] = $data[$field];
|
||||||
}
|
}
|
||||||
return $member;
|
return $member;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class MembersTypes extends DolibarrApi
|
|||||||
/**
|
/**
|
||||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
*/
|
*/
|
||||||
static $FIELDS = array(
|
public static $FIELDS = array(
|
||||||
'label',
|
'label',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -190,7 +190,9 @@ class MembersTypes extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request_data as $field => $value) {
|
foreach ($request_data as $field => $value) {
|
||||||
if ($field == 'id') continue;
|
if ($field == 'id') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Process the status separately because it must be updated using
|
// Process the status separately because it must be updated using
|
||||||
// the validate() and resiliate() methods of the class AdherentType.
|
// the validate() and resiliate() methods of the class AdherentType.
|
||||||
$membertype->$field = $value;
|
$membertype->$field = $value;
|
||||||
@ -250,8 +252,9 @@ class MembersTypes extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$membertype = array();
|
$membertype = array();
|
||||||
foreach (MembersTypes::$FIELDS as $field) {
|
foreach (MembersTypes::$FIELDS as $field) {
|
||||||
if (!isset($data[$field]))
|
if (!isset($data[$field])) {
|
||||||
throw new RestException(400, "$field field missing");
|
throw new RestException(400, "$field field missing");
|
||||||
|
}
|
||||||
$membertype[$field] = $data[$field];
|
$membertype[$field] = $data[$field];
|
||||||
}
|
}
|
||||||
return $membertype;
|
return $membertype;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class Subscriptions extends DolibarrApi
|
|||||||
/**
|
/**
|
||||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
*/
|
*/
|
||||||
static $FIELDS = array(
|
public static $FIELDS = array(
|
||||||
'fk_adherent',
|
'fk_adherent',
|
||||||
'dateh',
|
'dateh',
|
||||||
'datef',
|
'datef',
|
||||||
|
|||||||
@ -50,12 +50,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortorder) $sortorder = "ASC";
|
if (!$sortorder) {
|
||||||
if (!$sortfield) $sortfield = "name";
|
$sortorder = "ASC";
|
||||||
|
}
|
||||||
|
if (!$sortfield) {
|
||||||
|
$sortfield = "name";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
@ -96,8 +102,9 @@ if ($id > 0) {
|
|||||||
$totalsize += $file['size'];
|
$totalsize += $file['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->notification->enabled))
|
if (!empty($conf->notification->enabled)) {
|
||||||
$langs->load("mails");
|
$langs->load("mails");
|
||||||
|
}
|
||||||
|
|
||||||
$head = member_prepare_head($object);
|
$head = member_prepare_head($object);
|
||||||
|
|
||||||
@ -125,8 +132,8 @@ if ($id > 0) {
|
|||||||
// Morphy
|
// Morphy
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
|
print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
|
||||||
/*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
|
/*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
|
||||||
print $form->showphoto('memberphoto',$object);
|
print $form->showphoto('memberphoto',$object);
|
||||||
print '</td>';*/
|
print '</td>';*/
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
|
|||||||
@ -27,7 +27,9 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (!$user->rights->adherent->export) accessforbidden();
|
if (!$user->rights->adherent->export) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -38,8 +40,12 @@ llxHeader();
|
|||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
if (empty($sortorder)) { $sortorder = "ASC"; }
|
if (empty($sortorder)) {
|
||||||
if (empty($sortfield)) { $sortfield = "d.login"; }
|
$sortorder = "ASC";
|
||||||
|
}
|
||||||
|
if (empty($sortfield)) {
|
||||||
|
$sortfield = "d.login";
|
||||||
|
}
|
||||||
if (!isset($statut)) {
|
if (!isset($statut)) {
|
||||||
$statut = 1;
|
$statut = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -257,7 +257,7 @@ print "</tr>\n";
|
|||||||
|
|
||||||
krsort($Total);
|
krsort($Total);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($Total as $key=>$value) {
|
foreach ($Total as $key => $value) {
|
||||||
if ($i >= 8) {
|
if ($i >= 8) {
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print "<td>...</td>";
|
print "<td>...</td>";
|
||||||
|
|||||||
@ -142,7 +142,9 @@ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTI
|
|||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
|
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') print "<br>\n";
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') {
|
||||||
|
print "<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -69,24 +69,36 @@ $catid = GETPOST("catid", 'int');
|
|||||||
$optioncss = GETPOST('optioncss', 'alpha');
|
$optioncss = GETPOST('optioncss', 'alpha');
|
||||||
|
|
||||||
$filter = GETPOST("filter", 'alpha');
|
$filter = GETPOST("filter", 'alpha');
|
||||||
if ($filter) $search_filter = $filter; // For backward compatibility
|
if ($filter) {
|
||||||
|
$search_filter = $filter; // For backward compatibility
|
||||||
|
}
|
||||||
$statut = GETPOST("statut", 'alpha');
|
$statut = GETPOST("statut", 'alpha');
|
||||||
if ($statut != '') $search_status = $statut; // For backward compatibility
|
if ($statut != '') {
|
||||||
|
$search_status = $statut; // For backward compatibility
|
||||||
|
}
|
||||||
|
|
||||||
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||||
|
|
||||||
if ($search_status < -1) $search_status = '';
|
if ($search_status < -1) {
|
||||||
|
$search_status = '';
|
||||||
|
}
|
||||||
|
|
||||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortorder) { $sortorder = ($filter == 'outofdate' ? "DESC" : "ASC"); }
|
if (!$sortorder) {
|
||||||
if (!$sortfield) { $sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname"); }
|
$sortorder = ($filter == 'outofdate' ? "DESC" : "ASC");
|
||||||
|
}
|
||||||
|
if (!$sortfield) {
|
||||||
|
$sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname");
|
||||||
|
}
|
||||||
|
|
||||||
$object = new Adherent($db);
|
$object = new Adherent($db);
|
||||||
|
|
||||||
@ -117,7 +129,9 @@ $fieldstosearchall = array(
|
|||||||
'd.note_public'=>'NotePublic',
|
'd.note_public'=>'NotePublic',
|
||||||
'd.note_private'=>'NotePrivate',
|
'd.note_private'=>'NotePrivate',
|
||||||
);
|
);
|
||||||
if ($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
|
if ($db->type == 'pgsql') {
|
||||||
|
unset($fieldstosearchall['d.rowid']);
|
||||||
|
}
|
||||||
$arrayfields = array(
|
$arrayfields = array(
|
||||||
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
||||||
'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
|
'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
|
||||||
@ -153,12 +167,18 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
if (GETPOST('cancel', 'alpha')) {
|
||||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }
|
$action = 'list'; $massaction = '';
|
||||||
|
}
|
||||||
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
|
||||||
|
$massaction = '';
|
||||||
|
}
|
||||||
|
|
||||||
$parameters = array('socid'=>$socid);
|
$parameters = array('socid'=>$socid);
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
// Selection of new fields
|
// Selection of new fields
|
||||||
@ -212,7 +232,9 @@ if (empty($reshook)) {
|
|||||||
if ($result < 0 && !count($tmpmember->errors)) {
|
if ($result < 0 && !count($tmpmember->errors)) {
|
||||||
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
|
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
|
||||||
} else {
|
} else {
|
||||||
if ($result > 0) $nbclose++;
|
if ($result > 0) {
|
||||||
|
$nbclose++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,8 +278,11 @@ $sql .= " s.nom,";
|
|||||||
$sql .= " t.libelle as type, t.subscription,";
|
$sql .= " t.libelle as type, t.subscription,";
|
||||||
$sql .= " state.code_departement as state_code, state.nom as state_name,";
|
$sql .= " state.code_departement as state_code, state.nom as state_name,";
|
||||||
// Add fields from extrafields
|
// Add fields from extrafields
|
||||||
if (!empty($extrafields->attributes[$object->table_element]['label']))
|
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||||
|
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
// Add fields from hooks
|
// Add fields from hooks
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
@ -276,16 +301,34 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid =
|
|||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
|
$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
|
||||||
$sql .= " WHERE d.fk_adherent_type = t.rowid ";
|
$sql .= " WHERE d.fk_adherent_type = t.rowid ";
|
||||||
if ($catid > 0) $sql .= " AND cm.fk_categorie = ".$db->escape($catid);
|
if ($catid > 0) {
|
||||||
if ($catid == -2) $sql .= " AND cm.fk_categorie IS NULL";
|
$sql .= " AND cm.fk_categorie = ".$db->escape($catid);
|
||||||
if ($search_categ > 0) $sql .= " AND cm.fk_categorie = ".$db->escape($search_categ);
|
}
|
||||||
if ($search_categ == -2) $sql .= " AND cm.fk_categorie IS NULL";
|
if ($catid == -2) {
|
||||||
|
$sql .= " AND cm.fk_categorie IS NULL";
|
||||||
|
}
|
||||||
|
if ($search_categ > 0) {
|
||||||
|
$sql .= " AND cm.fk_categorie = ".$db->escape($search_categ);
|
||||||
|
}
|
||||||
|
if ($search_categ == -2) {
|
||||||
|
$sql .= " AND cm.fk_categorie IS NULL";
|
||||||
|
}
|
||||||
$sql .= " AND d.entity IN (".getEntity('adherent').")";
|
$sql .= " AND d.entity IN (".getEntity('adherent').")";
|
||||||
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
if ($sall) {
|
||||||
if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type);
|
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||||
if ($search_filter == 'withoutsubscription') $sql .= " AND (datefin IS NULL OR t.subscription = 0)";
|
}
|
||||||
if ($search_filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
|
if ($search_type > 0) {
|
||||||
if ($search_filter == 'outofdate') $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
|
$sql .= " AND t.rowid=".$db->escape($search_type);
|
||||||
|
}
|
||||||
|
if ($search_filter == 'withoutsubscription') {
|
||||||
|
$sql .= " AND (datefin IS NULL OR t.subscription = 0)";
|
||||||
|
}
|
||||||
|
if ($search_filter == 'uptodate') {
|
||||||
|
$sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
|
||||||
|
}
|
||||||
|
if ($search_filter == 'outofdate') {
|
||||||
|
$sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
|
||||||
|
}
|
||||||
if ($search_status != '') {
|
if ($search_status != '') {
|
||||||
// Peut valoir un nombre ou liste de nombre separes par virgules
|
// Peut valoir un nombre ou liste de nombre separes par virgules
|
||||||
$sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
|
$sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
|
||||||
@ -293,21 +336,51 @@ if ($search_status != '') {
|
|||||||
if ($search_ref) {
|
if ($search_ref) {
|
||||||
$sql .= natural_search("d.ref", $search_ref);
|
$sql .= natural_search("d.ref", $search_ref);
|
||||||
}
|
}
|
||||||
if ($search_civility) $sql .= natural_search("d.civility", $search_civility);
|
if ($search_civility) {
|
||||||
if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname);
|
$sql .= natural_search("d.civility", $search_civility);
|
||||||
if ($search_lastname) $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
|
}
|
||||||
if ($search_gender != '' && $search_gender != '-1') $sql .= natural_search("d.gender", $search_gender);
|
if ($search_firstname) {
|
||||||
if ($search_login) $sql .= natural_search("d.login", $search_login);
|
$sql .= natural_search("d.firstname", $search_firstname);
|
||||||
if ($search_company) $sql .= natural_search("s.nom", $search_company);
|
}
|
||||||
if ($search_email) $sql .= natural_search("d.email", $search_email);
|
if ($search_lastname) {
|
||||||
if ($search_address) $sql .= natural_search("d.address", $search_address);
|
$sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
|
||||||
if ($search_town) $sql .= natural_search("d.town", $search_town);
|
}
|
||||||
if ($search_zip) $sql .= natural_search("d.zip", $search_zip);
|
if ($search_gender != '' && $search_gender != '-1') {
|
||||||
if ($search_state) $sql .= natural_search("state.nom", $search_state);
|
$sql .= natural_search("d.gender", $search_gender);
|
||||||
if ($search_phone) $sql .= natural_search("d.phone", $search_phone);
|
}
|
||||||
if ($search_phone_perso) $sql .= natural_search("d.phone_perso", $search_phone_perso);
|
if ($search_login) {
|
||||||
if ($search_phone_mobile) $sql .= natural_search("d.phone_mobile", $search_phone_mobile);
|
$sql .= natural_search("d.login", $search_login);
|
||||||
if ($search_country) $sql .= " AND d.country IN (".$search_country.')';
|
}
|
||||||
|
if ($search_company) {
|
||||||
|
$sql .= natural_search("s.nom", $search_company);
|
||||||
|
}
|
||||||
|
if ($search_email) {
|
||||||
|
$sql .= natural_search("d.email", $search_email);
|
||||||
|
}
|
||||||
|
if ($search_address) {
|
||||||
|
$sql .= natural_search("d.address", $search_address);
|
||||||
|
}
|
||||||
|
if ($search_town) {
|
||||||
|
$sql .= natural_search("d.town", $search_town);
|
||||||
|
}
|
||||||
|
if ($search_zip) {
|
||||||
|
$sql .= natural_search("d.zip", $search_zip);
|
||||||
|
}
|
||||||
|
if ($search_state) {
|
||||||
|
$sql .= natural_search("state.nom", $search_state);
|
||||||
|
}
|
||||||
|
if ($search_phone) {
|
||||||
|
$sql .= natural_search("d.phone", $search_phone);
|
||||||
|
}
|
||||||
|
if ($search_phone_perso) {
|
||||||
|
$sql .= natural_search("d.phone_perso", $search_phone_perso);
|
||||||
|
}
|
||||||
|
if ($search_phone_mobile) {
|
||||||
|
$sql .= natural_search("d.phone_mobile", $search_phone_mobile);
|
||||||
|
}
|
||||||
|
if ($search_country) {
|
||||||
|
$sql .= " AND d.country IN (".$search_country.')';
|
||||||
|
}
|
||||||
|
|
||||||
// Add where from extra fields
|
// Add where from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||||
@ -323,8 +396,11 @@ $sql .= $db->order($sortfield, $sortorder);
|
|||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) $nbtotalofrecords = $db->num_rows($resql);
|
if ($resql) {
|
||||||
else dol_print_error($db);
|
$nbtotalofrecords = $db->num_rows($resql);
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
@ -355,13 +431,27 @@ llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adh&eacu
|
|||||||
|
|
||||||
$titre = $langs->trans("MembersList");
|
$titre = $langs->trans("MembersList");
|
||||||
if (GETPOSTISSET("search_status")) {
|
if (GETPOSTISSET("search_status")) {
|
||||||
if ($search_status == '-1,1') { $titre = $langs->trans("MembersListQualified"); }
|
if ($search_status == '-1,1') {
|
||||||
if ($search_status == '-1') { $titre = $langs->trans("MembersListToValid"); }
|
$titre = $langs->trans("MembersListQualified");
|
||||||
if ($search_status == '1' && $filter == '') { $titre = $langs->trans("MembersValidated"); }
|
}
|
||||||
if ($search_status == '1' && $filter == 'withoutsubscription') { $titre = $langs->trans("MembersWithSubscriptionToReceive"); }
|
if ($search_status == '-1') {
|
||||||
if ($search_status == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); }
|
$titre = $langs->trans("MembersListToValid");
|
||||||
if ($search_status == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); }
|
}
|
||||||
if ($search_status == '0') { $titre = $langs->trans("MembersListResiliated"); }
|
if ($search_status == '1' && $filter == '') {
|
||||||
|
$titre = $langs->trans("MembersValidated");
|
||||||
|
}
|
||||||
|
if ($search_status == '1' && $filter == 'withoutsubscription') {
|
||||||
|
$titre = $langs->trans("MembersWithSubscriptionToReceive");
|
||||||
|
}
|
||||||
|
if ($search_status == '1' && $filter == 'uptodate') {
|
||||||
|
$titre = $langs->trans("MembersListUpToDate");
|
||||||
|
}
|
||||||
|
if ($search_status == '1' && $filter == 'outofdate') {
|
||||||
|
$titre = $langs->trans("MembersListNotUpToDate");
|
||||||
|
}
|
||||||
|
if ($search_status == '0') {
|
||||||
|
$titre = $langs->trans("MembersListResiliated");
|
||||||
|
}
|
||||||
} elseif ($action == 'search') {
|
} elseif ($action == 'search') {
|
||||||
$titre = $langs->trans("MembersListQualified");
|
$titre = $langs->trans("MembersListQualified");
|
||||||
}
|
}
|
||||||
@ -373,30 +463,78 @@ if ($search_type > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$param = '';
|
$param = '';
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
$param .= '&contextpage='.urlencode($contextpage);
|
||||||
if ($sall != "") $param .= "&sall=".urlencode($sall);
|
}
|
||||||
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
if ($search_civility) $param .= "&search_civility=".urlencode($search_civility);
|
$param .= '&limit='.urlencode($limit);
|
||||||
if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname);
|
}
|
||||||
if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname);
|
if ($sall != "") {
|
||||||
if ($search_gender) $param .= "&search_gender=".urlencode($search_gender);
|
$param .= "&sall=".urlencode($sall);
|
||||||
if ($search_login) $param .= "&search_login=".urlencode($search_login);
|
}
|
||||||
if ($search_email) $param .= "&search_email=".urlencode($search_email);
|
if ($search_ref) {
|
||||||
if ($search_categ) $param .= "&search_categ=".urlencode($search_categ);
|
$param .= "&search_ref=".urlencode($search_ref);
|
||||||
if ($search_company) $param .= "&search_company=".urlencode($search_company);
|
}
|
||||||
if ($search_address != '') $param .= "&search_address=".urlencode($search_address);
|
if ($search_civility) {
|
||||||
if ($search_town != '') $param .= "&search_town=".urlencode($search_town);
|
$param .= "&search_civility=".urlencode($search_civility);
|
||||||
if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip);
|
}
|
||||||
if ($search_state != '') $param .= "&search_state=".urlencode($search_state);
|
if ($search_firstname) {
|
||||||
if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
|
$param .= "&search_firstname=".urlencode($search_firstname);
|
||||||
if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone);
|
}
|
||||||
if ($search_phone_perso != '') $param .= "&search_phone_perso=".urlencode($search_phone_perso);
|
if ($search_lastname) {
|
||||||
if ($search_phone_mobile != '') $param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
|
$param .= "&search_lastname=".urlencode($search_lastname);
|
||||||
if ($search_filter && $search_filter != '-1') $param .= "&search_filter=".urlencode($search_filter);
|
}
|
||||||
if ($search_status != "" && $search_status != '-1') $param .= "&search_status=".urlencode($search_status);
|
if ($search_gender) {
|
||||||
if ($search_type > 0) $param .= "&search_type=".urlencode($search_type);
|
$param .= "&search_gender=".urlencode($search_gender);
|
||||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
}
|
||||||
|
if ($search_login) {
|
||||||
|
$param .= "&search_login=".urlencode($search_login);
|
||||||
|
}
|
||||||
|
if ($search_email) {
|
||||||
|
$param .= "&search_email=".urlencode($search_email);
|
||||||
|
}
|
||||||
|
if ($search_categ) {
|
||||||
|
$param .= "&search_categ=".urlencode($search_categ);
|
||||||
|
}
|
||||||
|
if ($search_company) {
|
||||||
|
$param .= "&search_company=".urlencode($search_company);
|
||||||
|
}
|
||||||
|
if ($search_address != '') {
|
||||||
|
$param .= "&search_address=".urlencode($search_address);
|
||||||
|
}
|
||||||
|
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_phone != '') {
|
||||||
|
$param .= "&search_phone=".urlencode($search_phone);
|
||||||
|
}
|
||||||
|
if ($search_phone_perso != '') {
|
||||||
|
$param .= "&search_phone_perso=".urlencode($search_phone_perso);
|
||||||
|
}
|
||||||
|
if ($search_phone_mobile != '') {
|
||||||
|
$param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
|
||||||
|
}
|
||||||
|
if ($search_filter && $search_filter != '-1') {
|
||||||
|
$param .= "&search_filter=".urlencode($search_filter);
|
||||||
|
}
|
||||||
|
if ($search_status != "" && $search_status != '-1') {
|
||||||
|
$param .= "&search_status=".urlencode($search_status);
|
||||||
|
}
|
||||||
|
if ($search_type > 0) {
|
||||||
|
$param .= "&search_type=".urlencode($search_type);
|
||||||
|
}
|
||||||
|
if ($optioncss != '') {
|
||||||
|
$param .= '&optioncss='.urlencode($optioncss);
|
||||||
|
}
|
||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
|
||||||
@ -405,10 +543,18 @@ $arrayofmassactions = array(
|
|||||||
//'presend'=>$langs->trans("SendByMail"),
|
//'presend'=>$langs->trans("SendByMail"),
|
||||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||||
);
|
);
|
||||||
if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate");
|
if ($user->rights->adherent->creer) {
|
||||||
if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
$arrayofmassactions['close'] = $langs->trans("Resiliate");
|
||||||
if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
|
}
|
||||||
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
|
if ($user->rights->adherent->supprimer) {
|
||||||
|
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||||
|
}
|
||||||
|
if ($user->rights->societe->creer) {
|
||||||
|
$arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
|
||||||
|
}
|
||||||
|
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
|
||||||
|
$arrayofmassactions = array();
|
||||||
|
}
|
||||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
$newcardbutton = '';
|
$newcardbutton = '';
|
||||||
@ -417,7 +563,9 @@ if ($user->rights->adherent->creer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') {
|
||||||
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
}
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
print '<input type="hidden" name="action" value="list">';
|
print '<input type="hidden" name="action" value="list">';
|
||||||
@ -434,7 +582,9 @@ $trackid = 'mem'.$object->id;
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||||
|
|
||||||
if ($sall) {
|
if ($sall) {
|
||||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
foreach ($fieldstosearchall as $key => $val) {
|
||||||
|
$fieldstosearchall[$key] = $langs->trans($val);
|
||||||
|
}
|
||||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,8 +598,11 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
|
|||||||
}
|
}
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
if (empty($reshook)) {
|
||||||
else $moreforfilter = $hookmanager->resPrint;
|
$moreforfilter .= $hookmanager->resPrint;
|
||||||
|
} else {
|
||||||
|
$moreforfilter = $hookmanager->resPrint;
|
||||||
|
}
|
||||||
if (!empty($moreforfilter)) {
|
if (!empty($moreforfilter)) {
|
||||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||||
print $moreforfilter;
|
print $moreforfilter;
|
||||||
@ -458,7 +611,9 @@ if (!empty($moreforfilter)) {
|
|||||||
|
|
||||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
if ($massactionbutton) {
|
||||||
|
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
||||||
|
}
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||||
@ -609,26 +764,66 @@ print '</td>';
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
|
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
|
||||||
if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.ref']['checked'])) {
|
||||||
if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['d.gender']['checked'])) print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.civility']['checked'])) {
|
||||||
if (!empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.firstname']['checked'])) {
|
||||||
if (!empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.lastname']['checked'])) {
|
||||||
if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $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['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.gender']['checked'])) {
|
||||||
if (!empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.company']['checked'])) {
|
||||||
if (!empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.login']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.morphy']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['t.libelle']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.address']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.zip']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.town']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $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['d.phone']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.phone_perso']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.phone_mobile']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.email']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.datefin']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
// Extra fields
|
// Extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||||
|
|
||||||
@ -636,10 +831,18 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
|||||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
$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
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
if (!empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.datec']['checked'])) {
|
||||||
if (!empty($arrayfields['d.birth']['checked'])) print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder);
|
if (!empty($arrayfields['d.birth']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.tms']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.statut']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@ -676,7 +879,9 @@ while ($i < min($num, $limit)) {
|
|||||||
|
|
||||||
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
|
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
|
||||||
print '<td class="center">'.$obj->rowid.'</td>';
|
print '<td class="center">'.$obj->rowid.'</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
@ -684,35 +889,47 @@ while ($i < min($num, $limit)) {
|
|||||||
print "<td>";
|
print "<td>";
|
||||||
print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
|
print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Civility
|
// Civility
|
||||||
if (!empty($arrayfields['d.civility']['checked'])) {
|
if (!empty($arrayfields['d.civility']['checked'])) {
|
||||||
print "<td>";
|
print "<td>";
|
||||||
print $obj->civility;
|
print $obj->civility;
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Firstname
|
// Firstname
|
||||||
if (!empty($arrayfields['d.firstname']['checked'])) {
|
if (!empty($arrayfields['d.firstname']['checked'])) {
|
||||||
print "<td>";
|
print "<td>";
|
||||||
print $obj->firstname;
|
print $obj->firstname;
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Lastname
|
// Lastname
|
||||||
if (!empty($arrayfields['d.lastname']['checked'])) {
|
if (!empty($arrayfields['d.lastname']['checked'])) {
|
||||||
print "<td>";
|
print "<td>";
|
||||||
print $obj->lastname;
|
print $obj->lastname;
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Gender
|
// Gender
|
||||||
if (!empty($arrayfields['d.gender']['checked'])) {
|
if (!empty($arrayfields['d.gender']['checked'])) {
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if ($obj->gender) print $langs->trans("Gender".$obj->gender);
|
if ($obj->gender) {
|
||||||
|
print $langs->trans("Gender".$obj->gender);
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Company
|
// Company
|
||||||
if (!empty($arrayfields['d.company']['checked'])) {
|
if (!empty($arrayfields['d.company']['checked'])) {
|
||||||
@ -723,7 +940,9 @@ while ($i < min($num, $limit)) {
|
|||||||
// Login
|
// Login
|
||||||
if (!empty($arrayfields['d.login']['checked'])) {
|
if (!empty($arrayfields['d.login']['checked'])) {
|
||||||
print "<td>".$obj->login."</td>\n";
|
print "<td>".$obj->login."</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Nature (Moral/Physical)
|
// Nature (Moral/Physical)
|
||||||
if (!empty($arrayfields['d.morphy']['checked'])) {
|
if (!empty($arrayfields['d.morphy']['checked'])) {
|
||||||
@ -737,7 +956,9 @@ while ($i < min($num, $limit)) {
|
|||||||
}
|
}
|
||||||
print $s;
|
print $s;
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Type label
|
// Type label
|
||||||
if (!empty($arrayfields['t.libelle']['checked'])) {
|
if (!empty($arrayfields['t.libelle']['checked'])) {
|
||||||
@ -746,33 +967,43 @@ while ($i < min($num, $limit)) {
|
|||||||
print '<td class="nowrap">';
|
print '<td class="nowrap">';
|
||||||
print $membertypestatic->getNomUrl(1, 32);
|
print $membertypestatic->getNomUrl(1, 32);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Address
|
// Address
|
||||||
if (!empty($arrayfields['d.address']['checked'])) {
|
if (!empty($arrayfields['d.address']['checked'])) {
|
||||||
print '<td class="nocellnopadd">';
|
print '<td class="nocellnopadd">';
|
||||||
print $obj->address;
|
print $obj->address;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Zip
|
// Zip
|
||||||
if (!empty($arrayfields['d.zip']['checked'])) {
|
if (!empty($arrayfields['d.zip']['checked'])) {
|
||||||
print '<td class="nocellnopadd">';
|
print '<td class="nocellnopadd">';
|
||||||
print $obj->zip;
|
print $obj->zip;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Town
|
// Town
|
||||||
if (!empty($arrayfields['d.town']['checked'])) {
|
if (!empty($arrayfields['d.town']['checked'])) {
|
||||||
print '<td class="nocellnopadd">';
|
print '<td class="nocellnopadd">';
|
||||||
print $obj->town;
|
print $obj->town;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// State
|
// State
|
||||||
if (!empty($arrayfields['state.nom']['checked'])) {
|
if (!empty($arrayfields['state.nom']['checked'])) {
|
||||||
print "<td>".$obj->state_name."</td>\n";
|
print "<td>".$obj->state_name."</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Country
|
// Country
|
||||||
if (!empty($arrayfields['country.code_iso']['checked'])) {
|
if (!empty($arrayfields['country.code_iso']['checked'])) {
|
||||||
@ -780,28 +1011,36 @@ while ($i < min($num, $limit)) {
|
|||||||
$tmparray = getCountry($obj->country, 'all');
|
$tmparray = getCountry($obj->country, 'all');
|
||||||
print $tmparray['label'];
|
print $tmparray['label'];
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Phone pro
|
// Phone pro
|
||||||
if (!empty($arrayfields['d.phone']['checked'])) {
|
if (!empty($arrayfields['d.phone']['checked'])) {
|
||||||
print '<td class="nocellnopadd">';
|
print '<td class="nocellnopadd">';
|
||||||
print $obj->phone;
|
print $obj->phone;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Phone perso
|
// Phone perso
|
||||||
if (!empty($arrayfields['d.phone_perso']['checked'])) {
|
if (!empty($arrayfields['d.phone_perso']['checked'])) {
|
||||||
print '<td class="nocellnopadd">';
|
print '<td class="nocellnopadd">';
|
||||||
print $obj->phone_perso;
|
print $obj->phone_perso;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Phone mobile
|
// Phone mobile
|
||||||
if (!empty($arrayfields['d.phone_mobile']['checked'])) {
|
if (!empty($arrayfields['d.phone_mobile']['checked'])) {
|
||||||
print '<td class="nocellnopadd">';
|
print '<td class="nocellnopadd">';
|
||||||
print $obj->phone_mobile;
|
print $obj->phone_mobile;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// EMail
|
// EMail
|
||||||
if (!empty($arrayfields['d.email']['checked'])) {
|
if (!empty($arrayfields['d.email']['checked'])) {
|
||||||
@ -822,7 +1061,9 @@ while ($i < min($num, $limit)) {
|
|||||||
print '<td class="nowrap left">';
|
print '<td class="nowrap left">';
|
||||||
if ($obj->subscription == 'yes') {
|
if ($obj->subscription == 'yes') {
|
||||||
print $langs->trans("SubscriptionNotReceived");
|
print $langs->trans("SubscriptionNotReceived");
|
||||||
if ($obj->statut > 0) print " ".img_warning();
|
if ($obj->statut > 0) {
|
||||||
|
print " ".img_warning();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print ' ';
|
print ' ';
|
||||||
}
|
}
|
||||||
@ -840,38 +1081,50 @@ while ($i < min($num, $limit)) {
|
|||||||
print '<td class="nowrap center">';
|
print '<td class="nowrap center">';
|
||||||
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
|
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Birth
|
// Birth
|
||||||
if (!empty($arrayfields['d.birth']['checked'])) {
|
if (!empty($arrayfields['d.birth']['checked'])) {
|
||||||
print '<td class="nowrap center">';
|
print '<td class="nowrap center">';
|
||||||
print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
|
print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Date modification
|
// Date modification
|
||||||
if (!empty($arrayfields['d.tms']['checked'])) {
|
if (!empty($arrayfields['d.tms']['checked'])) {
|
||||||
print '<td class="nowrap center">';
|
print '<td class="nowrap center">';
|
||||||
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
|
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Status
|
// Status
|
||||||
if (!empty($arrayfields['d.statut']['checked'])) {
|
if (!empty($arrayfields['d.statut']['checked'])) {
|
||||||
print '<td class="nowrap right">';
|
print '<td class="nowrap right">';
|
||||||
print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
|
print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
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;
|
$selected = 0;
|
||||||
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
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"' : '').'>';
|
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -884,7 +1137,11 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
|||||||
// If no record found
|
// If no record found
|
||||||
if ($num == 0) {
|
if ($num == 0) {
|
||||||
$colspan = 1;
|
$colspan = 1;
|
||||||
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
foreach ($arrayfields as $key => $val) {
|
||||||
|
if (!empty($val['checked'])) {
|
||||||
|
$colspan++;
|
||||||
|
}
|
||||||
|
}
|
||||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,8 +91,8 @@ if ($id) {
|
|||||||
// Morphy
|
// Morphy
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
|
print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
|
||||||
/*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
|
/*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
|
||||||
print $form->showphoto('memberphoto',$member);
|
print $form->showphoto('memberphoto',$member);
|
||||||
print '</td>';*/
|
print '</td>';*/
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
|
|||||||
@ -82,8 +82,12 @@ if ($resql) {
|
|||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
if ($obj->code == 'phy') $foundphy++;
|
if ($obj->code == 'phy') {
|
||||||
if ($obj->code == 'mor') $foundmor++;
|
$foundphy++;
|
||||||
|
}
|
||||||
|
if ($obj->code == 'mor') {
|
||||||
|
$foundmor++;
|
||||||
|
}
|
||||||
|
|
||||||
$data[$obj->code] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'nbsubscriptions'=>$obj->nbsubscriptions, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
|
$data[$obj->code] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'nbsubscriptions'=>$obj->nbsubscriptions, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
|
||||||
|
|
||||||
@ -113,8 +117,12 @@ if ($resql) {
|
|||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
if ($obj->code == 'phy') $foundphy++;
|
if ($obj->code == 'phy') {
|
||||||
if ($obj->code == 'mor') $foundmor++;
|
$foundphy++;
|
||||||
|
}
|
||||||
|
if ($obj->code == 'mor') {
|
||||||
|
$foundmor++;
|
||||||
|
}
|
||||||
|
|
||||||
$data[$obj->code]['nbactive'] = $obj->nb;
|
$data[$obj->code]['nbactive'] = $obj->nb;
|
||||||
|
|
||||||
@ -152,8 +160,12 @@ print '<td class="right">'.$langs->trans("NbOfSubscriptions").'</td>';
|
|||||||
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
if (!$foundphy) {
|
||||||
if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
$data[] = array('label'=>'phy', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
||||||
|
}
|
||||||
|
if (!$foundmor) {
|
||||||
|
$data[] = array('label'=>'mor', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($data as $val) {
|
foreach ($data as $val) {
|
||||||
$nb = $val['nb'];
|
$nb = $val['nb'];
|
||||||
|
|||||||
@ -56,13 +56,23 @@ $langs->loadLangs(array("companies", "members", "banks"));
|
|||||||
$memberstatic = new Adherent($db);
|
$memberstatic = new Adherent($db);
|
||||||
|
|
||||||
$arrayjs = array('https://www.google.com/jsapi');
|
$arrayjs = array('https://www.google.com/jsapi');
|
||||||
if (!empty($conf->dol_use_jmobile)) $arrayjs = array();
|
if (!empty($conf->dol_use_jmobile)) {
|
||||||
|
$arrayjs = array();
|
||||||
|
}
|
||||||
|
|
||||||
$title = $langs->trans("Statistics");
|
$title = $langs->trans("Statistics");
|
||||||
if ($mode == 'memberbycountry') $title = $langs->trans("MembersStatisticsByCountries");
|
if ($mode == 'memberbycountry') {
|
||||||
if ($mode == 'memberbystate') $title = $langs->trans("MembersStatisticsByState");
|
$title = $langs->trans("MembersStatisticsByCountries");
|
||||||
if ($mode == 'memberbytown') $title = $langs->trans("MembersStatisticsByTown");
|
}
|
||||||
if ($mode == 'memberbyregion') $title = $langs->trans("MembersStatisticsByRegion");
|
if ($mode == 'memberbystate') {
|
||||||
|
$title = $langs->trans("MembersStatisticsByState");
|
||||||
|
}
|
||||||
|
if ($mode == 'memberbytown') {
|
||||||
|
$title = $langs->trans("MembersStatisticsByTown");
|
||||||
|
}
|
||||||
|
if ($mode == 'memberbyregion') {
|
||||||
|
$title = $langs->trans("MembersStatisticsByRegion");
|
||||||
|
}
|
||||||
|
|
||||||
llxHeader('', $title, '', '', 0, 0, $arrayjs);
|
llxHeader('', $title, '', '', 0, 0, $arrayjs);
|
||||||
|
|
||||||
@ -207,11 +217,15 @@ if ($mode && !count($data)) {
|
|||||||
print $langs->trans("NoValidatedMemberYet").'<br>';
|
print $langs->trans("NoValidatedMemberYet").'<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
} else {
|
} else {
|
||||||
if ($mode == 'memberbycountry') print '<span class="opacitymedium">'.$langs->trans("MembersByCountryDesc").'</span><br>';
|
if ($mode == 'memberbycountry') {
|
||||||
elseif ($mode == 'memberbystate') print '<span class="opacitymedium">'.$langs->trans("MembersByStateDesc").'</span><br>';
|
print '<span class="opacitymedium">'.$langs->trans("MembersByCountryDesc").'</span><br>';
|
||||||
elseif ($mode == 'memberbytown') print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>';
|
} elseif ($mode == 'memberbystate') {
|
||||||
elseif ($mode == 'memberbyregion') print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>'; //+
|
print '<span class="opacitymedium">'.$langs->trans("MembersByStateDesc").'</span><br>';
|
||||||
else {
|
} elseif ($mode == 'memberbytown') {
|
||||||
|
print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>';
|
||||||
|
} elseif ($mode == 'memberbyregion') {
|
||||||
|
print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>'; //+
|
||||||
|
} else {
|
||||||
print '<span class="opacitymedium">'.$langs->trans("MembersStatisticsDesc").'</span><br>';
|
print '<span class="opacitymedium">'.$langs->trans("MembersStatisticsDesc").'</span><br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
|
||||||
@ -229,7 +243,9 @@ if ($mode && !count($data)) {
|
|||||||
// Show graphics
|
// Show graphics
|
||||||
if (count($arrayjs) && $mode == 'memberbycountry') {
|
if (count($arrayjs) && $mode == 'memberbycountry') {
|
||||||
$color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
$color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
||||||
if (is_readable($color_file)) include_once $color_file;
|
if (is_readable($color_file)) {
|
||||||
|
include_once $color_file;
|
||||||
|
}
|
||||||
|
|
||||||
// Assume we've already included the proper headers so just call our script inline
|
// Assume we've already included the proper headers so just call our script inline
|
||||||
// More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR
|
// More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR
|
||||||
@ -248,11 +264,15 @@ if (count($arrayjs) && $mode == 'memberbycountry') {
|
|||||||
foreach ($data as $val) {
|
foreach ($data as $val) {
|
||||||
$valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster)
|
$valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster)
|
||||||
//$valcountry=ucfirst($val['label_en']);
|
//$valcountry=ucfirst($val['label_en']);
|
||||||
if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; } // fix case of uk (when we use labels)
|
if ($valcountry == 'Great Britain') {
|
||||||
|
$valcountry = 'United Kingdom';
|
||||||
|
} // fix case of uk (when we use labels)
|
||||||
print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
|
print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
|
||||||
print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
|
print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
|
||||||
// Google's Geomap only supports up to 400 entries
|
// Google's Geomap only supports up to 400 entries
|
||||||
if ($i >= 400) { break; }
|
if ($i >= 400) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +299,9 @@ if ($mode) {
|
|||||||
print '<table class="liste centpercent">';
|
print '<table class="liste centpercent">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$label.'</td>';
|
print '<td>'.$label.'</td>';
|
||||||
if ($label2) print '<td class="center">'.$label2.'</td>';
|
if ($label2) {
|
||||||
|
print '<td class="center">'.$label2.'</td>';
|
||||||
|
}
|
||||||
print '<td class="right">'.$langs->trans("NbOfMembers").' <span class="opacitymedium">('.$langs->trans("AllTime").')</span></td>';
|
print '<td class="right">'.$langs->trans("NbOfMembers").' <span class="opacitymedium">('.$langs->trans("AllTime").')</span></td>';
|
||||||
print '<td class="center">'.$langs->trans("LastMemberDate").'</td>';
|
print '<td class="center">'.$langs->trans("LastMemberDate").'</td>';
|
||||||
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
||||||
@ -289,7 +311,9 @@ if ($mode) {
|
|||||||
$year = $val['year'];
|
$year = $val['year'];
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$val['label'].'</td>';
|
print '<td>'.$val['label'].'</td>';
|
||||||
if ($label2) print '<td class="center">'.$val['label2'].'</td>';
|
if ($label2) {
|
||||||
|
print '<td class="center">'.$val['label2'].'</td>';
|
||||||
|
}
|
||||||
print '<td class="right">'.$val['nb'].'</td>';
|
print '<td class="right">'.$val['nb'].'</td>';
|
||||||
print '<td class="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>';
|
print '<td class="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>';
|
||||||
print '<td class="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>';
|
print '<td class="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>';
|
||||||
|
|||||||
@ -32,8 +32,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
|
|||||||
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
|
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
|
||||||
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
||||||
|
|
||||||
$userid = GETPOST('userid', 'int'); if ($userid < 0) $userid = 0;
|
$userid = GETPOST('userid', 'int'); if ($userid < 0) {
|
||||||
$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0;
|
$userid = 0;
|
||||||
|
}
|
||||||
|
$socid = GETPOST('socid', 'int'); if ($socid < 0) {
|
||||||
|
$socid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->socid > 0) {
|
if ($user->socid > 0) {
|
||||||
@ -209,7 +213,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
|||||||
|
|
||||||
// Show graphs
|
// Show graphs
|
||||||
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
|
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
|
||||||
if ($mesg) { print $mesg; } else {
|
if ($mesg) {
|
||||||
|
print $mesg;
|
||||||
|
} else {
|
||||||
print $px1->show();
|
print $px1->show();
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
print $px2->show();
|
print $px2->show();
|
||||||
|
|||||||
@ -50,14 +50,20 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
// Default sort order (if not yet defined by previous GETPOST)
|
// Default sort order (if not yet defined by previous GETPOST)
|
||||||
if (!$sortfield) $sortfield = "c.rowid";
|
if (!$sortfield) {
|
||||||
if (!$sortorder) $sortorder = "DESC";
|
$sortfield = "c.rowid";
|
||||||
|
}
|
||||||
|
if (!$sortorder) {
|
||||||
|
$sortorder = "DESC";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
@ -150,7 +156,9 @@ if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->cre
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
if ($_POST["userid"] != $object->user_id) { // If link differs from currently in database
|
if ($_POST["userid"] != $object->user_id) { // If link differs from currently in database
|
||||||
$result = $object->setUserId($_POST["userid"]);
|
$result = $object->setUserId($_POST["userid"]);
|
||||||
if ($result < 0) dol_print_error('', $object->error);
|
if ($result < 0) {
|
||||||
|
dol_print_error('', $object->error);
|
||||||
|
}
|
||||||
$_POST['action'] = '';
|
$_POST['action'] = '';
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
@ -178,7 +186,9 @@ if (empty($reshook) && $action == 'setsocid') {
|
|||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$result = $object->setThirdPartyId(GETPOST('socid', 'int'));
|
$result = $object->setThirdPartyId(GETPOST('socid', 'int'));
|
||||||
if ($result < 0) dol_print_error('', $object->error);
|
if ($result < 0) {
|
||||||
|
dol_print_error('', $object->error);
|
||||||
|
}
|
||||||
$_POST['action'] = '';
|
$_POST['action'] = '';
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
@ -423,25 +433,37 @@ llxHeader("", $title, $helpurl);
|
|||||||
|
|
||||||
|
|
||||||
$param = '';
|
$param = '';
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
$param .= '&contextpage='.urlencode($contextpage);
|
||||||
|
}
|
||||||
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
|
$param .= '&limit='.urlencode($limit);
|
||||||
|
}
|
||||||
$param .= '&id='.$rowid;
|
$param .= '&id='.$rowid;
|
||||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
if ($optioncss != '') {
|
||||||
|
$param .= '&optioncss='.urlencode($optioncss);
|
||||||
|
}
|
||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
|
||||||
|
|
||||||
if ($rowid > 0) {
|
if ($rowid > 0) {
|
||||||
$res = $object->fetch($rowid);
|
$res = $object->fetch($rowid);
|
||||||
if ($res < 0) { dol_print_error($db, $object->error); exit; }
|
if ($res < 0) {
|
||||||
|
dol_print_error($db, $object->error); exit;
|
||||||
|
}
|
||||||
|
|
||||||
$adht->fetch($object->typeid);
|
$adht->fetch($object->typeid);
|
||||||
|
|
||||||
$head = member_prepare_head($object);
|
$head = member_prepare_head($object);
|
||||||
|
|
||||||
$rowspan = 10;
|
$rowspan = 10;
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||||
if (!empty($conf->societe->enabled)) $rowspan++;
|
$rowspan++;
|
||||||
|
}
|
||||||
|
if (!empty($conf->societe->enabled)) {
|
||||||
|
$rowspan++;
|
||||||
|
}
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
@ -471,6 +493,12 @@ if ($rowid > 0) {
|
|||||||
print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
|
print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Gender
|
||||||
|
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
if ($object->gender) print $langs->trans("Gender".$object->gender);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
|
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
|
||||||
|
|
||||||
@ -481,6 +509,15 @@ if ($rowid > 0) {
|
|||||||
// Password
|
// Password
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||||
print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
|
print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
|
||||||
|
if ($object->pass) {
|
||||||
|
print preg_replace('/./i', '*', $object->pass);
|
||||||
|
} else {
|
||||||
|
if ($user->admin) {
|
||||||
|
print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
|
||||||
|
} else {
|
||||||
|
print $langs->trans("Hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
|
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
|
$htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
|
||||||
@ -489,6 +526,28 @@ if ($rowid > 0) {
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Date end subscription
|
||||||
|
print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
|
||||||
|
if ($object->datefin) {
|
||||||
|
print dol_print_date($object->datefin, 'day');
|
||||||
|
if ($object->hasDelay()) {
|
||||||
|
print " ".img_warning($langs->trans("Late"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!$adht->subscription) {
|
||||||
|
print $langs->trans("SubscriptionNotRecorded");
|
||||||
|
if ($object->statut > 0) {
|
||||||
|
print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print $langs->trans("SubscriptionNotReceived");
|
||||||
|
if ($object->statut > 0) {
|
||||||
|
print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -498,7 +557,7 @@ if ($rowid > 0) {
|
|||||||
print '<table class="border tableforfield" width="100%">';
|
print '<table class="border tableforfield" width="100%">';
|
||||||
|
|
||||||
// Birthday
|
// Birthday
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
|
print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
|
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
|
||||||
@ -515,31 +574,15 @@ if ($rowid > 0) {
|
|||||||
$cols = 2;
|
$cols = 2;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
||||||
|
|
||||||
// Date end subscription
|
|
||||||
print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
|
|
||||||
if ($object->datefin) {
|
|
||||||
print dol_print_date($object->datefin, 'day');
|
|
||||||
if ($object->hasDelay()) {
|
|
||||||
print " ".img_warning($langs->trans("Late"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!$adht->subscription) {
|
|
||||||
print $langs->trans("SubscriptionNotRecorded");
|
|
||||||
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
|
||||||
} else {
|
|
||||||
print $langs->trans("SubscriptionNotReceived");
|
|
||||||
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Third party Dolibarr
|
// Third party Dolibarr
|
||||||
if (!empty($conf->societe->enabled)) {
|
if (!empty($conf->societe->enabled)) {
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||||
print $langs->trans("LinkedToDolibarrThirdParty");
|
print $langs->trans("LinkedToDolibarrThirdParty");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if ($action != 'editthirdparty' && $user->rights->adherent->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'</a></td>';
|
if ($action != 'editthirdparty' && $user->rights->adherent->creer) {
|
||||||
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'</a></td>';
|
||||||
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
print '</td><td colspan="2" class="valeur">';
|
print '</td><td colspan="2" class="valeur">';
|
||||||
if ($action == 'editthirdparty') {
|
if ($action == 'editthirdparty') {
|
||||||
@ -585,7 +628,9 @@ if ($rowid > 0) {
|
|||||||
} else {
|
} else {
|
||||||
if ($object->user_id) {
|
if ($object->user_id) {
|
||||||
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none');
|
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none');
|
||||||
} else print $langs->trans("NoDolibarrAccess");
|
} else {
|
||||||
|
print $langs->trans("NoDolibarrAccess");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@ -608,8 +653,11 @@ if ($rowid > 0) {
|
|||||||
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
|
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($object->statut > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>";
|
if ($object->statut > 0) {
|
||||||
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>";
|
||||||
|
} else {
|
||||||
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
|
||||||
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
@ -712,7 +760,9 @@ if ($rowid > 0) {
|
|||||||
|
|
||||||
if (empty($num)) {
|
if (empty($num)) {
|
||||||
$colspan = 6;
|
$colspan = 6;
|
||||||
if (!empty($conf->banque->enabled)) $colspan++;
|
if (!empty($conf->banque->enabled)) {
|
||||||
|
$colspan++;
|
||||||
|
}
|
||||||
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
|
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,13 +799,23 @@ if ($rowid > 0) {
|
|||||||
$invoiceonly = 0; // 1 means option by default is invoice only
|
$invoiceonly = 0; // 1 means option by default is invoice only
|
||||||
$bankviainvoice = 0; // 1 means option by default is write to bank via invoice
|
$bankviainvoice = 0; // 1 means option by default is write to bank via invoice
|
||||||
if (GETPOST('paymentsave')) {
|
if (GETPOST('paymentsave')) {
|
||||||
if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1;
|
if (GETPOST('paymentsave') == 'bankdirect') {
|
||||||
if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1;
|
$bankdirect = 1;
|
||||||
if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice = 1;
|
}
|
||||||
|
if (GETPOST('paymentsave') == 'invoiceonly') {
|
||||||
|
$invoiceonly = 1;
|
||||||
|
}
|
||||||
|
if (GETPOST('paymentsave') == 'bankviainvoice') {
|
||||||
|
$bankviainvoice = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $bankviainvoice = 1;
|
if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
|
||||||
elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) $bankdirect = 1;
|
$bankviainvoice = 1;
|
||||||
elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $invoiceonly = 1;
|
} elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) {
|
||||||
|
$bankdirect = 1;
|
||||||
|
} elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
|
||||||
|
$invoiceonly = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n\n<!-- Form add subscription -->\n";
|
print "\n\n<!-- Form add subscription -->\n";
|
||||||
@ -789,7 +849,9 @@ if ($rowid > 0) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
';
|
';
|
||||||
if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);';
|
if (GETPOST('paymentsave')) {
|
||||||
|
print '$("#'.GETPOST('paymentsave').'").prop("checked",true);';
|
||||||
|
}
|
||||||
print '});';
|
print '});';
|
||||||
print '</script>'."\n";
|
print '</script>'."\n";
|
||||||
}
|
}
|
||||||
@ -802,10 +864,14 @@ if ($rowid > 0) {
|
|||||||
|
|
||||||
if ($object->morphy == 'mor') {
|
if ($object->morphy == 'mor') {
|
||||||
$companyname = $object->company;
|
$companyname = $object->company;
|
||||||
if (!empty($fullname)) $companyalias = $fullname;
|
if (!empty($fullname)) {
|
||||||
|
$companyalias = $fullname;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$companyname = $fullname;
|
$companyname = $fullname;
|
||||||
if (!empty($object->company)) $companyalias = $object->company;
|
if (!empty($object->company)) {
|
||||||
|
$companyalias = $object->company;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a form array
|
// Create a form array
|
||||||
@ -886,7 +952,9 @@ if ($rowid > 0) {
|
|||||||
// Label
|
// Label
|
||||||
print '<tr><td>'.$langs->trans("Label").'</td>';
|
print '<tr><td>'.$langs->trans("Label").'</td>';
|
||||||
print '<td><input name="label" type="text" size="32" value="';
|
print '<td><input name="label" type="text" size="32" value="';
|
||||||
if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans("Subscription").' '.dol_print_date(($datefrom ? $datefrom : time()), "%Y");
|
if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) {
|
||||||
|
print $langs->trans("Subscription").' '.dol_print_date(($datefrom ? $datefrom : time()), "%Y");
|
||||||
|
}
|
||||||
print '"></td></tr>';
|
print '"></td></tr>';
|
||||||
|
|
||||||
// Complementary action
|
// Complementary action
|
||||||
@ -914,16 +982,21 @@ if ($rowid > 0) {
|
|||||||
print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ? ' checked' : '');
|
print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ? ' checked' : '');
|
||||||
//if (empty($object->fk_soc)) print ' disabled';
|
//if (empty($object->fk_soc)) print ' disabled';
|
||||||
print '> '.$langs->trans("MoreActionInvoiceOnly");
|
print '> '.$langs->trans("MoreActionInvoiceOnly");
|
||||||
if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
|
if ($object->fk_soc) {
|
||||||
else {
|
print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
|
||||||
|
} else {
|
||||||
print ' (';
|
print ' (';
|
||||||
if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
|
if (empty($object->fk_soc)) {
|
||||||
|
print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
|
||||||
|
}
|
||||||
print $langs->trans("NoThirdPartyAssociatedToMember");
|
print $langs->trans("NoThirdPartyAssociatedToMember");
|
||||||
print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">';
|
print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">';
|
||||||
print $langs->trans("CreateDolibarrThirdParty");
|
print $langs->trans("CreateDolibarrThirdParty");
|
||||||
print '</a>)';
|
print '</a>)';
|
||||||
}
|
}
|
||||||
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
|
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') {
|
||||||
|
print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
|
||||||
|
}
|
||||||
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
|
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
|
||||||
$prodtmp = new Product($db);
|
$prodtmp = new Product($db);
|
||||||
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
|
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
|
||||||
@ -943,13 +1016,17 @@ if ($rowid > 0) {
|
|||||||
print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
|
print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
|
||||||
} else {
|
} else {
|
||||||
print ' (';
|
print ' (';
|
||||||
if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
|
if (empty($object->fk_soc)) {
|
||||||
|
print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
|
||||||
|
}
|
||||||
print $langs->trans("NoThirdPartyAssociatedToMember");
|
print $langs->trans("NoThirdPartyAssociatedToMember");
|
||||||
print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">';
|
print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">';
|
||||||
print $langs->trans("CreateDolibarrThirdParty");
|
print $langs->trans("CreateDolibarrThirdParty");
|
||||||
print '</a>)';
|
print '</a>)';
|
||||||
}
|
}
|
||||||
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
|
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') {
|
||||||
|
print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
|
||||||
|
}
|
||||||
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
|
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
|
||||||
$prodtmp = new Product($db);
|
$prodtmp = new Product($db);
|
||||||
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
|
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
|
||||||
|
|||||||
@ -48,8 +48,9 @@ $note = GETPOST('note', 'alpha');
|
|||||||
$typeid = (int) GETPOST('typeid', 'int');
|
$typeid = (int) GETPOST('typeid', 'int');
|
||||||
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
|
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
|
||||||
|
|
||||||
if (!$user->rights->adherent->cotisation->lire)
|
if (!$user->rights->adherent->cotisation->lire) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php
|
$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php
|
||||||
$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
|
$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
|
||||||
@ -65,7 +66,9 @@ $result = restrictedArea($user, 'subscription', 0); // TODO Check on object id
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($cancel) $action = '';
|
if ($cancel) {
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
|
||||||
//include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
//include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
@ -122,7 +125,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
|
|||||||
$errmsg = $object->error;
|
$errmsg = $object->error;
|
||||||
} else {
|
} else {
|
||||||
foreach ($object->errors as $error) {
|
foreach ($object->errors as $error) {
|
||||||
if ($errmsg) $errmsg .= '<br>';
|
if ($errmsg) {
|
||||||
|
$errmsg .= '<br>';
|
||||||
|
}
|
||||||
$errmsg .= $error;
|
$errmsg .= $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,7 +274,9 @@ if ($rowid && $action != 'edit') {
|
|||||||
//$formquestion=array();
|
//$formquestion=array();
|
||||||
//$formquestion['text']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>';
|
//$formquestion['text']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>';
|
||||||
$text = $langs->trans("ConfirmDeleteSubscription");
|
$text = $langs->trans("ConfirmDeleteSubscription");
|
||||||
if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
|
if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) {
|
||||||
|
$text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
|
||||||
|
}
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1);
|
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,9 +349,9 @@ if ($rowid && $action != 'edit') {
|
|||||||
print dol_get_fiche_end();
|
print dol_get_fiche_end();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Barre d'actions
|
* Barre d'actions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($user->rights->adherent->cotisation->creer) {
|
if ($user->rights->adherent->cotisation->creer) {
|
||||||
@ -368,15 +375,15 @@ if ($rowid && $action != 'edit') {
|
|||||||
|
|
||||||
// Documents generes
|
// Documents generes
|
||||||
/*
|
/*
|
||||||
$filename = dol_sanitizeFileName($object->ref);
|
$filename = dol_sanitizeFileName($object->ref);
|
||||||
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
||||||
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
|
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
|
||||||
$genallowed = $user->rights->facture->lire;
|
$genallowed = $user->rights->facture->lire;
|
||||||
$delallowed = $user->rights->facture->creer;
|
$delallowed = $user->rights->facture->creer;
|
||||||
|
|
||||||
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||||
$somethingshown = $formfile->numoffiles;
|
$somethingshown = $formfile->numoffiles;
|
||||||
*/
|
*/
|
||||||
// Show links to link elements
|
// Show links to link elements
|
||||||
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
|
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
|
||||||
$somethingshown = $form->showLinkedObjectBlock($object, '');
|
$somethingshown = $form->showLinkedObjectBlock($object, '');
|
||||||
@ -384,16 +391,16 @@ if ($rowid && $action != 'edit') {
|
|||||||
// Show links to link elements
|
// Show links to link elements
|
||||||
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
|
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
|
||||||
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
|
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
// List of actions on element
|
// List of actions on element
|
||||||
/*
|
/*
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||||
$formactions = new FormActions($db);
|
$formactions = new FormActions($db);
|
||||||
$somethingshown = $formactions->showactions($object, 'invoice', $socid, 1);
|
$somethingshown = $formactions->showactions($object, 'invoice', $socid, 1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '</div></div></div>';
|
print '</div></div></div>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("companies", "members", "bills", "users"));
|
$langs->loadLangs(array("companies", "members", "bills", "users"));
|
||||||
|
|
||||||
if (!$user->rights->adherent->lire)
|
if (!$user->rights->adherent->lire) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$rowid = GETPOST("rowid", 'int');
|
$rowid = GETPOST("rowid", 'int');
|
||||||
|
|
||||||
|
|||||||
@ -55,12 +55,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortorder) { $sortorder = "DESC"; }
|
if (!$sortorder) {
|
||||||
if (!$sortfield) { $sortfield = "c.dateadh"; }
|
$sortorder = "DESC";
|
||||||
|
}
|
||||||
|
if (!$sortfield) {
|
||||||
|
$sortfield = "c.dateadh";
|
||||||
|
}
|
||||||
|
|
||||||
$object = new Subscription($db);
|
$object = new Subscription($db);
|
||||||
|
|
||||||
@ -102,12 +108,18 @@ $result = restrictedArea($user, 'adherent', '', '', 'cotisation');
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
if (GETPOST('cancel', 'alpha')) {
|
||||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }
|
$action = 'list'; $massaction = '';
|
||||||
|
}
|
||||||
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
|
||||||
|
$massaction = '';
|
||||||
|
}
|
||||||
|
|
||||||
$parameters = array('socid'=>$socid);
|
$parameters = array('socid'=>$socid);
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
// Selection of new fields
|
// Selection of new fields
|
||||||
@ -157,16 +169,33 @@ if (isset($date_select) && $date_select != '') {
|
|||||||
$sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
|
$sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
|
||||||
}
|
}
|
||||||
if ($search_ref) {
|
if ($search_ref) {
|
||||||
if (is_numeric($search_ref)) $sql .= " AND (c.rowid = ".$db->escape($search_ref).")";
|
if (is_numeric($search_ref)) {
|
||||||
else $sql .= " AND 1 = 2"; // Always wrong
|
$sql .= " AND (c.rowid = ".$db->escape($search_ref).")";
|
||||||
|
} else {
|
||||||
|
$sql .= " AND 1 = 2"; // Always wrong
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($search_type) {
|
||||||
|
$sql .= natural_search(array('c.fk_type'), $search_type);
|
||||||
|
}
|
||||||
|
if ($search_lastname) {
|
||||||
|
$sql .= natural_search(array('d.lastname', 'd.societe'), $search_lastname);
|
||||||
|
}
|
||||||
|
if ($search_firstname) {
|
||||||
|
$sql .= natural_search(array('d.firstname'), $search_firstname);
|
||||||
|
}
|
||||||
|
if ($search_login) {
|
||||||
|
$sql .= natural_search('d.login', $search_login);
|
||||||
|
}
|
||||||
|
if ($search_note) {
|
||||||
|
$sql .= natural_search('c.note', $search_note);
|
||||||
|
}
|
||||||
|
if ($search_account > 0) {
|
||||||
|
$sql .= " AND b.fk_account = ".urldecode($search_account);
|
||||||
|
}
|
||||||
|
if ($search_amount) {
|
||||||
|
$sql .= natural_search('c.subscription', $search_amount, 1);
|
||||||
}
|
}
|
||||||
if ($search_type) $sql .= natural_search(array('c.fk_type'), $search_type);
|
|
||||||
if ($search_lastname) $sql .= natural_search(array('d.lastname', 'd.societe'), $search_lastname);
|
|
||||||
if ($search_firstname) $sql .= natural_search(array('d.firstname'), $search_firstname);
|
|
||||||
if ($search_login) $sql .= natural_search('d.login', $search_login);
|
|
||||||
if ($search_note) $sql .= natural_search('c.note', $search_note);
|
|
||||||
if ($search_account > 0) $sql .= " AND b.fk_account = ".urldecode($search_account);
|
|
||||||
if ($search_amount) $sql .= natural_search('c.subscription', $search_amount, 1);
|
|
||||||
|
|
||||||
// Add where from extra fields
|
// Add where from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||||
@ -182,8 +211,11 @@ $sql .= $db->order($sortfield, $sortorder);
|
|||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) $nbtotalofrecords = $db->num_rows($resql);
|
if ($resql) {
|
||||||
else dol_print_error($db);
|
$nbtotalofrecords = $db->num_rows($resql);
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
@ -215,19 +247,41 @@ llxHeader('', $langs->trans("ListOfSubscriptions"), $help_url);
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$title = $langs->trans("ListOfSubscriptions");
|
$title = $langs->trans("ListOfSubscriptions");
|
||||||
if (!empty($date_select)) $title .= ' ('.$langs->trans("Year").' '.$date_select.')';
|
if (!empty($date_select)) {
|
||||||
|
$title .= ' ('.$langs->trans("Year").' '.$date_select.')';
|
||||||
|
}
|
||||||
|
|
||||||
$param = '';
|
$param = '';
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
$param .= '&contextpage='.urlencode($contextpage);
|
||||||
if ($statut != '') $param .= "&statut=".urlencode($statut);
|
}
|
||||||
if ($search_type) $param .= "&search_type=".urlencode($search_type);
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
if ($date_select) $param .= "&date_select=".urlencode($date_select);
|
$param .= '&limit='.urlencode($limit);
|
||||||
if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname);
|
}
|
||||||
if ($search_login) $param .= "&search_login=".urlencode($search_login);
|
if ($statut != '') {
|
||||||
if ($search_account) $param .= "&search_account=".urlencode($search_account);
|
$param .= "&statut=".urlencode($statut);
|
||||||
if ($search_amount) $param .= "&search_amount=".urlencode($search_amount);
|
}
|
||||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
if ($search_type) {
|
||||||
|
$param .= "&search_type=".urlencode($search_type);
|
||||||
|
}
|
||||||
|
if ($date_select) {
|
||||||
|
$param .= "&date_select=".urlencode($date_select);
|
||||||
|
}
|
||||||
|
if ($search_lastname) {
|
||||||
|
$param .= "&search_lastname=".urlencode($search_lastname);
|
||||||
|
}
|
||||||
|
if ($search_login) {
|
||||||
|
$param .= "&search_login=".urlencode($search_login);
|
||||||
|
}
|
||||||
|
if ($search_account) {
|
||||||
|
$param .= "&search_account=".urlencode($search_account);
|
||||||
|
}
|
||||||
|
if ($search_amount) {
|
||||||
|
$param .= "&search_amount=".urlencode($search_amount);
|
||||||
|
}
|
||||||
|
if ($optioncss != '') {
|
||||||
|
$param .= '&optioncss='.urlencode($optioncss);
|
||||||
|
}
|
||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
|
||||||
@ -237,7 +291,9 @@ $arrayofmassactions = array(
|
|||||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||||
);
|
);
|
||||||
//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||||
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
if (in_array($massaction, array('presend', 'predelete'))) {
|
||||||
|
$arrayofmassactions = array();
|
||||||
|
}
|
||||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
$newcardbutton = '';
|
$newcardbutton = '';
|
||||||
@ -246,7 +302,9 @@ if ($user->rights->adherent->cotisation->creer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') {
|
||||||
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
}
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
print '<input type="hidden" name="action" value="list">';
|
print '<input type="hidden" name="action" value="list">';
|
||||||
@ -263,7 +321,9 @@ $trackid = 'sub'.$object->id;
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||||
|
|
||||||
if ($sall) {
|
if ($sall) {
|
||||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
foreach ($fieldstosearchall as $key => $val) {
|
||||||
|
$fieldstosearchall[$key] = $langs->trans($val);
|
||||||
|
}
|
||||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +331,9 @@ $moreforfilter = '';
|
|||||||
|
|
||||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
if ($massactionbutton) {
|
||||||
|
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
||||||
|
}
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||||
@ -366,16 +428,36 @@ print "</tr>\n";
|
|||||||
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
|
if (!empty($arrayfields['d.ref']['checked'])) {
|
||||||
if (!empty($arrayfields['d.fk_type']['checked'])) print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
|
if (!empty($arrayfields['d.fk_type']['checked'])) {
|
||||||
if (!empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
|
}
|
||||||
if (!empty($arrayfields['d.bank']['checked'])) print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
|
if (!empty($arrayfields['d.lastname']['checked'])) {
|
||||||
if (!empty($arrayfields['c.dateadh']['checked'])) print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
|
print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
|
||||||
if (!empty($arrayfields['c.datef']['checked'])) print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
|
}
|
||||||
if (!empty($arrayfields['d.amount']['checked'])) print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
|
if (!empty($arrayfields['d.firstname']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.login']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['t.libelle']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.bank']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['c.dateadh']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['c.datef']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['d.amount']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
|
||||||
|
}
|
||||||
|
|
||||||
// Extra fields
|
// Extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||||
@ -384,8 +466,12 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
|||||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
$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
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
if (!empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
if (!empty($arrayfields['c.datec']['checked'])) {
|
||||||
if (!empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['c.tms']['checked'])) {
|
||||||
|
print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@ -420,7 +506,9 @@ while ($i < min($num, $limit)) {
|
|||||||
// Ref
|
// Ref
|
||||||
if (!empty($arrayfields['d.ref']['checked'])) {
|
if (!empty($arrayfields['d.ref']['checked'])) {
|
||||||
print '<td>'.$subscription->getNomUrl(1).'</td>';
|
print '<td>'.$subscription->getNomUrl(1).'</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Type
|
// Type
|
||||||
if (!empty($arrayfields['d.fk_type']['checked'])) {
|
if (!empty($arrayfields['d.fk_type']['checked'])) {
|
||||||
@ -429,24 +517,32 @@ while ($i < min($num, $limit)) {
|
|||||||
print $adht->getNomUrl(1);
|
print $adht->getNomUrl(1);
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lastname
|
// Lastname
|
||||||
if (!empty($arrayfields['d.lastname']['checked'])) {
|
if (!empty($arrayfields['d.lastname']['checked'])) {
|
||||||
print '<td>'.$adherent->getNomUrl(-1, 0, 'card', 'lastname').'</td>';
|
print '<td>'.$adherent->getNomUrl(-1, 0, 'card', 'lastname').'</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Firstname
|
// Firstname
|
||||||
if (!empty($arrayfields['d.firstname']['checked'])) {
|
if (!empty($arrayfields['d.firstname']['checked'])) {
|
||||||
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->firstname).'">'.$adherent->firstname.'</td>';
|
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->firstname).'">'.$adherent->firstname.'</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
if (!empty($arrayfields['d.login']['checked'])) {
|
if (!empty($arrayfields['d.login']['checked'])) {
|
||||||
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->login).'">'.$adherent->login.'</td>';
|
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->login).'">'.$adherent->login.'</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
@ -454,7 +550,9 @@ while ($i < min($num, $limit)) {
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
print dol_trunc($obj->note, 128);
|
print dol_trunc($obj->note, 128);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Banque
|
// Banque
|
||||||
@ -467,24 +565,34 @@ while ($i < min($num, $limit)) {
|
|||||||
print $accountstatic->getNomUrl(1);
|
print $accountstatic->getNomUrl(1);
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Date start
|
// Date start
|
||||||
if (!empty($arrayfields['c.dateadh']['checked'])) {
|
if (!empty($arrayfields['c.dateadh']['checked'])) {
|
||||||
print '<td class="center">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
|
print '<td class="center">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Date end
|
// Date end
|
||||||
if (!empty($arrayfields['c.datef']['checked'])) {
|
if (!empty($arrayfields['c.datef']['checked'])) {
|
||||||
print '<td class="center">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
|
print '<td class="center">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Price
|
// Price
|
||||||
if (!empty($arrayfields['d.amount']['checked'])) {
|
if (!empty($arrayfields['d.amount']['checked'])) {
|
||||||
print '<td class="right">'.price($obj->subscription).'</td>';
|
print '<td class="right">'.price($obj->subscription).'</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.amount';
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
if (!$i) {
|
||||||
|
$totalarray['pos'][$totalarray['nbfield']] = 'd.amount';
|
||||||
|
}
|
||||||
$totalarray['val']['d.amount'] += $obj->subscription;
|
$totalarray['val']['d.amount'] += $obj->subscription;
|
||||||
}
|
}
|
||||||
// Extra fields
|
// Extra fields
|
||||||
@ -498,24 +606,32 @@ while ($i < min($num, $limit)) {
|
|||||||
print '<td class="nowrap center">';
|
print '<td class="nowrap center">';
|
||||||
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
|
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Date modification
|
// Date modification
|
||||||
if (!empty($arrayfields['c.tms']['checked'])) {
|
if (!empty($arrayfields['c.tms']['checked'])) {
|
||||||
print '<td class="nowrap center">';
|
print '<td class="nowrap center">';
|
||||||
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
|
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
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;
|
$selected = 0;
|
||||||
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
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"' : '').'>';
|
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -528,7 +644,11 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
|||||||
// If no record found
|
// If no record found
|
||||||
if ($num == 0) {
|
if ($num == 0) {
|
||||||
$colspan = 1;
|
$colspan = 1;
|
||||||
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
foreach ($arrayfields as $key => $val) {
|
||||||
|
if (!empty($val['checked'])) {
|
||||||
|
$colspan++;
|
||||||
|
}
|
||||||
|
}
|
||||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,12 +52,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortorder) { $sortorder = "DESC"; }
|
if (!$sortorder) {
|
||||||
if (!$sortfield) { $sortfield = "d.lastname"; }
|
$sortorder = "DESC";
|
||||||
|
}
|
||||||
|
if (!$sortfield) {
|
||||||
|
$sortfield = "d.lastname";
|
||||||
|
}
|
||||||
|
|
||||||
$label = GETPOST("label", "alpha");
|
$label = GETPOST("label", "alpha");
|
||||||
$morphy = GETPOST("morphy", "alpha");
|
$morphy = GETPOST("morphy", "alpha");
|
||||||
@ -118,7 +124,9 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
|
|||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($object->label)) {
|
if (empty($object->label)) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -167,7 +175,9 @@ if ($action == 'update' && $user->rights->adherent->configurer) {
|
|||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
$ret = $object->update($user);
|
$ret = $object->update($user);
|
||||||
|
|
||||||
@ -222,8 +232,12 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$param = '';
|
$param = '';
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
$param .= '&contextpage='.$contextpage;
|
||||||
|
}
|
||||||
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
|
$param .= '&limit='.$limit;
|
||||||
|
}
|
||||||
|
|
||||||
$newcardbutton = '';
|
$newcardbutton = '';
|
||||||
if ($user->rights->adherent->configurer) {
|
if ($user->rights->adherent->configurer) {
|
||||||
@ -231,7 +245,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') {
|
||||||
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
}
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
print '<input type="hidden" name="action" value="list">';
|
print '<input type="hidden" name="action" value="list">';
|
||||||
@ -273,14 +289,20 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>'.dol_escape_htmltag($objp->label).'</td>';
|
print '<td>'.dol_escape_htmltag($objp->label).'</td>';
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorAndPhy");
|
if ($objp->morphy == 'phy') {
|
||||||
|
print $langs->trans("Physical");
|
||||||
|
} elseif ($objp->morphy == 'mor') {
|
||||||
|
print $langs->trans("Moral");
|
||||||
|
} else {
|
||||||
|
print $langs->trans("MorAndPhy");
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="center">'.yn($objp->subscription).'</td>';
|
print '<td class="center">'.yn($objp->subscription).'</td>';
|
||||||
print '<td class="center">'.yn($objp->vote).'</td>';
|
print '<td class="center">'.yn($objp->vote).'</td>';
|
||||||
print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
|
print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
|
||||||
if ($user->rights->adherent->configurer)
|
if ($user->rights->adherent->configurer) {
|
||||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
|
||||||
else {
|
} else {
|
||||||
print '<td class="right"> </td>';
|
print '<td class="right"> </td>';
|
||||||
}
|
}
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
@ -318,19 +340,19 @@ if ($action == 'create') {
|
|||||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
|
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||||
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
|
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Morphy
|
// Morphy
|
||||||
$morphys = array();
|
$morphys = array();
|
||||||
$morphys[""] = $langs->trans("MorAndPhy");
|
$morphys[""] = $langs->trans("MorAndPhy");
|
||||||
$morphys["phy"] = $langs->trans("Physical");
|
$morphys["phy"] = $langs->trans("Physical");
|
||||||
$morphys["mor"] = $langs->trans("Moral");
|
$morphys["mor"] = $langs->trans("Moral");
|
||||||
print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
|
print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
|
||||||
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
|
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
|
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
|
||||||
print $form->selectyesno("subscription", 1, 1);
|
print $form->selectyesno("subscription", 1, 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@ -485,8 +507,8 @@ if ($rowid > 0) {
|
|||||||
}
|
}
|
||||||
if ($action == 'search') {
|
if ($action == 'search') {
|
||||||
if (GETPOST('search', 'alpha')) {
|
if (GETPOST('search', 'alpha')) {
|
||||||
$sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha'));
|
$sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($search_lastname)) {
|
if (!empty($search_lastname)) {
|
||||||
$sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname);
|
$sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname);
|
||||||
@ -510,8 +532,11 @@ if ($rowid > 0) {
|
|||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) $nbtotalofrecords = $db->num_rows($result);
|
if ($resql) {
|
||||||
else dol_print_error($db);
|
$nbtotalofrecords = $db->num_rows($result);
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
@ -551,12 +576,24 @@ if ($rowid > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$param = "&rowid=".$object->id;
|
$param = "&rowid=".$object->id;
|
||||||
if (!empty($status)) $param .= "&status=".$status;
|
if (!empty($status)) {
|
||||||
if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname;
|
$param .= "&status=".$status;
|
||||||
if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname;
|
}
|
||||||
if (!empty($search_login)) $param .= "&search_login=".$search_login;
|
if (!empty($search_lastname)) {
|
||||||
if (!empty($search_email)) $param .= "&search_email=".$search_email;
|
$param .= "&search_lastname=".$search_lastname;
|
||||||
if (!empty($filter)) $param .= "&filter=".$filter;
|
}
|
||||||
|
if (!empty($search_firstname)) {
|
||||||
|
$param .= "&search_firstname=".$search_firstname;
|
||||||
|
}
|
||||||
|
if (!empty($search_login)) {
|
||||||
|
$param .= "&search_login=".$search_login;
|
||||||
|
}
|
||||||
|
if (!empty($search_email)) {
|
||||||
|
$param .= "&search_email=".$search_email;
|
||||||
|
}
|
||||||
|
if (!empty($filter)) {
|
||||||
|
$param .= "&filter=".$filter;
|
||||||
|
}
|
||||||
|
|
||||||
if ($sall) {
|
if ($sall) {
|
||||||
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
|
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
|
||||||
@ -633,10 +670,10 @@ if ($rowid > 0) {
|
|||||||
|
|
||||||
// Type
|
// Type
|
||||||
/*print '<td class="nowrap">';
|
/*print '<td class="nowrap">';
|
||||||
$membertypestatic->id=$objp->type_id;
|
$membertypestatic->id=$objp->type_id;
|
||||||
$membertypestatic->label=$objp->type;
|
$membertypestatic->label=$objp->type;
|
||||||
print $membertypestatic->getNomUrl(1,12);
|
print $membertypestatic->getNomUrl(1,12);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Moral/Physique
|
// Moral/Physique
|
||||||
@ -663,7 +700,9 @@ if ($rowid > 0) {
|
|||||||
print '<td class="nowrap left">';
|
print '<td class="nowrap left">';
|
||||||
if ($objp->subscription == 'yes') {
|
if ($objp->subscription == 'yes') {
|
||||||
print $langs->trans("SubscriptionNotReceived");
|
print $langs->trans("SubscriptionNotReceived");
|
||||||
if ($objp->status > 0) print " ".img_warning();
|
if ($objp->status > 0) {
|
||||||
|
print " ".img_warning();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print ' ';
|
print ' ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,9 @@ $hookmanager->initHooks(array('membertypeldapcard', 'globalcard'));
|
|||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
if ($action == 'dolibarr2ldap') {
|
if ($action == 'dolibarr2ldap') {
|
||||||
@ -128,7 +130,9 @@ if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) {
|
|||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
|
|
||||||
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) print "<br>\n";
|
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) {
|
||||||
|
print "<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,9 @@ $ref = GETPOST('ref', 'alphanohtml');
|
|||||||
// Security check
|
// Security check
|
||||||
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
|
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
|
||||||
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
|
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
|
||||||
if ($user->socid) $socid = $user->socid;
|
if ($user->socid) {
|
||||||
|
$socid = $user->socid;
|
||||||
|
}
|
||||||
// Security check
|
// Security check
|
||||||
$result = restrictedArea($user, 'adherent', $id, 'adherent_type');
|
$result = restrictedArea($user, 'adherent', $id, 'adherent_type');
|
||||||
|
|
||||||
@ -184,7 +186,9 @@ print "\n<div class=\"tabsAction\">\n";
|
|||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
if ($user->rights->produit->creer || $user->rights->service->creer) {
|
if ($user->rights->produit->creer || $user->rights->service->creer) {
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=add&rowid='.$object->id.'">'.$langs->trans("Add").'</a>';
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=add&rowid='.$object->id.'">'.$langs->trans("Add").'</a>';
|
||||||
if ($cnt_trans > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=edit&rowid='.$object->id.'">'.$langs->trans("Update").'</a>';
|
if ($cnt_trans > 0) {
|
||||||
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=edit&rowid='.$object->id.'">'.$langs->trans("Update").'</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +246,9 @@ if ($action == 'edit') {
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$cnt_trans && $action != 'add') print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
|
if (!$cnt_trans && $action != 'add') {
|
||||||
|
print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'companies'));
|
$langs->loadLangs(array('admin', 'companies'));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
@ -45,11 +47,12 @@ $error = 0;
|
|||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
||||||
|| ($action == 'updateedit'))
|
|| ($action == 'updateedit')) {
|
||||||
{
|
|
||||||
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
||||||
@ -64,8 +67,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if ($action != 'updateedit' && !$error)
|
if ($action != 'updateedit' && !$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
@ -131,7 +133,9 @@ print '<input name="town" class="minwidth100" id="town" value="'.(GETPOSTISSET('
|
|||||||
print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
|
print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
|
||||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
||||||
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'country_id');
|
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'country_id');
|
||||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
if ($user->admin) {
|
||||||
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
|
}
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
|
|
||||||
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
|
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
|
||||||
|
|||||||
@ -28,8 +28,9 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'other', 'agenda'));
|
$langs->loadLangs(array('admin', 'other', 'agenda'));
|
||||||
@ -45,12 +46,10 @@ $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position";
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
|
||||||
$sql .= " ORDER BY a.rang ASC";
|
$sql .= " ORDER BY a.rang ASC";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$triggers[$i]['rowid'] = $obj->rowid;
|
$triggers[$i]['rowid'] = $obj->rowid;
|
||||||
$triggers[$i]['code'] = $obj->code;
|
$triggers[$i]['code'] = $obj->code;
|
||||||
@ -73,36 +72,32 @@ if ($resql)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Purge search criteria
|
// Purge search criteria
|
||||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||||
{
|
|
||||||
$search_event = '';
|
$search_event = '';
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search
|
if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { // To avoid the save when we click on search
|
||||||
{
|
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "save" && empty($cancel))
|
if ($action == "save" && empty($cancel)) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
foreach ($triggers as $trigger)
|
foreach ($triggers as $trigger) {
|
||||||
{
|
|
||||||
$keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
|
$keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
|
||||||
//print "param=".$param." - ".$_POST[$param];
|
//print "param=".$param." - ".$_POST[$param];
|
||||||
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam))
|
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) {
|
||||||
{
|
|
||||||
$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
$db->commit();
|
$db->commit();
|
||||||
} else {
|
} else {
|
||||||
@ -155,17 +150,27 @@ print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</t
|
|||||||
print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>';
|
print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>';
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
// Show each trigger (list is in c_action_trigger)
|
// Show each trigger (list is in c_action_trigger)
|
||||||
if (!empty($triggers))
|
if (!empty($triggers)) {
|
||||||
{
|
foreach ($triggers as $trigger) {
|
||||||
foreach ($triggers as $trigger)
|
|
||||||
{
|
|
||||||
$module = $trigger['element'];
|
$module = $trigger['element'];
|
||||||
if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur';
|
if ($module == 'order_supplier' || $module == 'invoice_supplier') {
|
||||||
if ($module == 'shipping') $module = 'expedition_bon';
|
$module = 'fournisseur';
|
||||||
if ($module == 'member') $module = 'adherent';
|
}
|
||||||
if ($module == 'project') $module = 'projet';
|
if ($module == 'shipping') {
|
||||||
if ($module == 'proposal_supplier') $module = 'supplier_proposal';
|
$module = 'expedition_bon';
|
||||||
if ($module == 'contact') $module = 'societe';
|
}
|
||||||
|
if ($module == 'member') {
|
||||||
|
$module = 'adherent';
|
||||||
|
}
|
||||||
|
if ($module == 'project') {
|
||||||
|
$module = 'projet';
|
||||||
|
}
|
||||||
|
if ($module == 'proposal_supplier') {
|
||||||
|
$module = 'supplier_proposal';
|
||||||
|
}
|
||||||
|
if ($module == 'contact') {
|
||||||
|
$module = 'societe';
|
||||||
|
}
|
||||||
|
|
||||||
// If 'element' value is myobject@mymodule instead of mymodule
|
// If 'element' value is myobject@mymodule instead of mymodule
|
||||||
$tmparray = explode('@', $module);
|
$tmparray = explode('@', $module);
|
||||||
@ -174,14 +179,16 @@ if (!empty($triggers))
|
|||||||
}
|
}
|
||||||
|
|
||||||
//print 'module='.$module.' code='.$trigger['code'].'<br>';
|
//print 'module='.$module.' code='.$trigger['code'].'<br>';
|
||||||
if (!empty($conf->$module->enabled))
|
if (!empty($conf->$module->enabled)) {
|
||||||
{
|
|
||||||
// Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
|
// Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
|
||||||
if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
|
if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
|
||||||
if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code']))
|
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code'])) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$trigger['code'].'</td>';
|
print '<td>'.$trigger['code'].'</td>';
|
||||||
print '<td>'.$trigger['label'].'</td>';
|
print '<td>'.$trigger['label'].'</td>';
|
||||||
|
|||||||
@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'other', 'agenda'));
|
$langs->loadLangs(array('admin', 'other', 'agenda'));
|
||||||
@ -43,13 +44,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield
|
$elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -82,8 +87,7 @@ print dol_get_fiche_end();
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if ($action != 'create' && $action != 'edit')
|
if ($action != 'create' && $action != 'edit') {
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -96,8 +100,7 @@ if ($action != 'create' && $action != 'edit')
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print '<br><div id="newattrib"></div>';
|
print '<br><div id="newattrib"></div>';
|
||||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
@ -109,8 +112,7 @@ if ($action == 'create')
|
|||||||
/* Edition of an optional field */
|
/* Edition of an optional field */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
if ($action == 'edit' && !empty($attrname))
|
if ($action == 'edit' && !empty($attrname)) {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('agenda', 'admin', 'other'));
|
$langs->loadLangs(array('agenda', 'admin', 'other'));
|
||||||
@ -41,7 +43,9 @@ $def = array();
|
|||||||
$actiontest = GETPOST('test', 'alpha');
|
$actiontest = GETPOST('test', 'alpha');
|
||||||
$actionsave = GETPOST('save', 'alpha');
|
$actionsave = GETPOST('save', 'alpha');
|
||||||
|
|
||||||
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
|
if (empty($conf->global->AGENDA_EXT_NB)) {
|
||||||
|
$conf->global->AGENDA_EXT_NB = 5;
|
||||||
|
}
|
||||||
$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
|
$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
|
||||||
|
|
||||||
// List of available colors
|
// List of available colors
|
||||||
@ -52,8 +56,7 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', '
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($actionsave)
|
if ($actionsave) {
|
||||||
{
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
|
$disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
|
||||||
@ -63,17 +66,17 @@ if ($actionsave)
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Save agendas
|
// Save agendas
|
||||||
while ($i <= $MAXAGENDA)
|
while ($i <= $MAXAGENDA) {
|
||||||
{
|
|
||||||
$name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha'));
|
$name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha'));
|
||||||
$src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha'));
|
$src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha'));
|
||||||
$offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha'));
|
$offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha'));
|
||||||
$color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha'));
|
$color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha'));
|
||||||
if ($color == '-1') $color = '';
|
if ($color == '-1') {
|
||||||
|
$color = '';
|
||||||
|
}
|
||||||
$enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha'));
|
$enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha'));
|
||||||
|
|
||||||
if (!empty($src) && !dol_is_url($src))
|
if (!empty($src) && !dol_is_url($src)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
|
setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
$errorsaved++;
|
$errorsaved++;
|
||||||
@ -82,34 +85,48 @@ if ($actionsave)
|
|||||||
|
|
||||||
//print '-name='.$name.'-color='.$color;
|
//print '-name='.$name.'-color='.$color;
|
||||||
$res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
$res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
$res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
$res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
$res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save nb of agenda
|
// Save nb of agenda
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
|
$error++;
|
||||||
|
}
|
||||||
|
if (empty($conf->global->AGENDA_EXT_NB)) {
|
||||||
|
$conf->global->AGENDA_EXT_NB = 5;
|
||||||
|
}
|
||||||
$MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB;
|
$MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
|
if (empty($errorsaved)) {
|
||||||
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +160,11 @@ print "<br>\n";
|
|||||||
|
|
||||||
|
|
||||||
$selectedvalue = $conf->global->AGENDA_DISABLE_EXT;
|
$selectedvalue = $conf->global->AGENDA_DISABLE_EXT;
|
||||||
if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1;
|
if ($selectedvalue == 1) {
|
||||||
|
$selectedvalue = 0;
|
||||||
|
} else {
|
||||||
|
$selectedvalue = 1;
|
||||||
|
}
|
||||||
|
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
|
|
||||||
@ -157,12 +178,10 @@ print "</tr>";
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print "<td>".$langs->trans("ExtSitesEnableThisTool")."</td>";
|
print "<td>".$langs->trans("ExtSitesEnableThisTool")."</td>";
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax) {
|
||||||
{
|
|
||||||
print ajax_constantonoff('AGENDA_DISABLE_EXT', array('enabled'=>array(0=>'.hideifnotset')), null, 1);
|
print ajax_constantonoff('AGENDA_DISABLE_EXT', array('enabled'=>array(0=>'.hideifnotset')), null, 1);
|
||||||
} else {
|
} else {
|
||||||
if (empty($conf->global->AGENDA_DISABLE_EXT))
|
if (empty($conf->global->AGENDA_DISABLE_EXT)) {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
@ -194,8 +213,7 @@ print '<td class="right">'.$langs->trans("Color").'</td>';
|
|||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($i <= $MAXAGENDA)
|
while ($i <= $MAXAGENDA) {
|
||||||
{
|
|
||||||
$key = $i;
|
$key = $i;
|
||||||
$name = 'AGENDA_EXT_NAME'.$key;
|
$name = 'AGENDA_EXT_NAME'.$key;
|
||||||
$src = 'AGENDA_EXT_SRC'.$key;
|
$src = 'AGENDA_EXT_SRC'.$key;
|
||||||
|
|||||||
@ -30,9 +30,11 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php';
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'other', 'agenda', 'users'));
|
$langs->loadLangs(array('admin', 'other', 'agenda', 'users'));
|
||||||
@ -52,12 +54,10 @@ $type = 'action';
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||||
|
|
||||||
$reg = array();
|
$reg = array();
|
||||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
|
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
|
||||||
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -65,27 +65,47 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
|
||||||
{
|
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($action == 'set')
|
if ($action == 'set') {
|
||||||
{
|
|
||||||
$getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
|
$getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
|
||||||
$defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter;
|
$defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter;
|
||||||
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
||||||
} elseif ($action == 'specimen') // For orders
|
|
||||||
{
|
$defaultValues = new DefaultValues($db);
|
||||||
|
$result = $defaultValues->fetchAll('', '', 0, 0, array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity));
|
||||||
|
if (!is_array($result) && $result<0) {
|
||||||
|
setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
|
||||||
|
} elseif (count($result)>0) {
|
||||||
|
foreach ($result as $defval) {
|
||||||
|
$defaultValues->id=$defval->id;
|
||||||
|
$resultDel = $defaultValues->delete($user);
|
||||||
|
if ($resultDel<0) {
|
||||||
|
setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$defaultValues->type='createform';
|
||||||
|
$defaultValues->entity=$conf->entity;
|
||||||
|
$defaultValues->user_id=0;
|
||||||
|
$defaultValues->page='comm/action/card.php';
|
||||||
|
$defaultValues->param='complete';
|
||||||
|
$defaultValues->value=GETPOST('AGENDA_EVENT_DEFAULT_STATUS');
|
||||||
|
$resultCreat=$defaultValues->create($user);
|
||||||
|
if ($resultCreat<0) {
|
||||||
|
setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
|
||||||
|
}
|
||||||
|
} elseif ($action == 'specimen') { // For orders
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
|
|
||||||
$commande = new CommandeFournisseur($db);
|
$commande = new CommandeFournisseur($db);
|
||||||
@ -95,25 +115,21 @@ if ($action == 'set')
|
|||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0;
|
$file = ''; $classname = ''; $filefound = 0;
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file)) {
|
||||||
{
|
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound) {
|
||||||
{
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$module = new $classname($db, $commande);
|
$module = new $classname($db, $commande);
|
||||||
|
|
||||||
if ($module->write_file($commande, $langs) > 0)
|
if ($module->write_file($commande, $langs) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -124,27 +140,20 @@ if ($action == 'set')
|
|||||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setmodel') {
|
||||||
|
// Activate a model
|
||||||
// Activate a model
|
|
||||||
elseif ($action == 'setmodel')
|
|
||||||
{
|
|
||||||
//print "sssd".$value;
|
//print "sssd".$value;
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
} elseif ($action == 'del')
|
} elseif ($action == 'del') {
|
||||||
{
|
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
|
||||||
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
|
dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setdoc') {
|
||||||
|
// Set default model
|
||||||
// Set default model
|
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
elseif ($action == 'setdoc')
|
|
||||||
{
|
|
||||||
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
|
|
||||||
{
|
|
||||||
// La constante qui a ete lue en avant du nouveau set
|
// La constante qui a ete lue en avant du nouveau set
|
||||||
// on passe donc par une variable pour avoir un affichage coherent
|
// on passe donc par une variable pour avoir un affichage coherent
|
||||||
$conf->global->ACTION_EVENT_ADDON_PDF = $value;
|
$conf->global->ACTION_EVENT_ADDON_PDF = $value;
|
||||||
@ -152,8 +161,7 @@ elseif ($action == 'setdoc')
|
|||||||
|
|
||||||
// On active le modele
|
// On active le modele
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,12 +201,10 @@ $sql .= " WHERE type = 'action'";
|
|||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num_rows = $db->num_rows($resql);
|
$num_rows = $db->num_rows($resql);
|
||||||
while ($i < $num_rows)
|
while ($i < $num_rows) {
|
||||||
{
|
|
||||||
$array = $db->fetch_array($resql);
|
$array = $db->fetch_array($resql);
|
||||||
array_push($def, $array[0]);
|
array_push($def, $array[0]);
|
||||||
$i++;
|
$i++;
|
||||||
@ -207,8 +213,7 @@ if ($resql)
|
|||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||||
{
|
|
||||||
print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
|
print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
|
||||||
|
|
||||||
print '<table class="noborder centpercent">'."\n";
|
print '<table class="noborder centpercent">'."\n";
|
||||||
@ -223,19 +228,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir."core/modules/action/doc");
|
$dir = dol_buildpath($reldir."core/modules/action/doc");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||||
{
|
|
||||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
|
||||||
{
|
|
||||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
@ -249,17 +249,17 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
|||||||
print "<td>\n";
|
print "<td>\n";
|
||||||
require_once $dir.'/'.$file;
|
require_once $dir.'/'.$file;
|
||||||
$module = new $classname($db, $specimenthirdparty);
|
$module = new $classname($db, $specimenthirdparty);
|
||||||
if (method_exists($module, 'info'))
|
if (method_exists($module, 'info')) {
|
||||||
print $module->info($langs);
|
print $module->info($langs);
|
||||||
else print $module->description;
|
} else {
|
||||||
|
print $module->description;
|
||||||
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
if (in_array($name, $def))
|
if (in_array($name, $def)) {
|
||||||
{
|
|
||||||
print '<td class="center">'."\n";
|
print '<td class="center">'."\n";
|
||||||
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
|
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">';
|
||||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
@ -275,8 +275,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
|||||||
|
|
||||||
// Default
|
// Default
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
|
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Default"), 'on');
|
print img_picto($langs->trans("Default"), 'on');
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
@ -324,8 +323,7 @@ print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE").'</td>'."\n";
|
|||||||
print '<td class="center"> </td>'."\n";
|
print '<td class="center"> </td>'."\n";
|
||||||
print '<td class="right">'."\n";
|
print '<td class="right">'."\n";
|
||||||
//print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
|
//print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
|
||||||
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
|
||||||
@ -342,8 +340,7 @@ $tmplist = array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_mon
|
|||||||
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
|
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
|
|
||||||
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
|
||||||
{
|
|
||||||
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
|
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
|
||||||
print '<tr class="oddeven">'."\n";
|
print '<tr class="oddeven">'."\n";
|
||||||
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
|
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
|
||||||
@ -353,6 +350,22 @@ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
|||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AGENDA_EVENT_DEFAULT_STATUS
|
||||||
|
print '<tr class="oddeven">'."\n";
|
||||||
|
print '<td>'.$langs->trans("AGENDA_EVENT_DEFAULT_STATUS").'</td>'."\n";
|
||||||
|
print '<td class="center"> </td>'."\n";
|
||||||
|
print '<td class="right nowrap">'."\n";
|
||||||
|
$defval='na';
|
||||||
|
$defaultValues = new DefaultValues($db);
|
||||||
|
$result = $defaultValues->fetchAll('', '', 0, 0, array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity));
|
||||||
|
if (!is_array($result) && $result<0) {
|
||||||
|
setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
|
||||||
|
} elseif (count($result)>0) {
|
||||||
|
$defval=reset($result)->value;
|
||||||
|
}
|
||||||
|
$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200');
|
||||||
|
print '</td></tr>'."\n";
|
||||||
|
|
||||||
// AGENDA_DEFAULT_FILTER_TYPE
|
// AGENDA_DEFAULT_FILTER_TYPE
|
||||||
print '<tr class="oddeven">'."\n";
|
print '<tr class="oddeven">'."\n";
|
||||||
print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").'</td>'."\n";
|
print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").'</td>'."\n";
|
||||||
|
|||||||
@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "other", "agenda"));
|
$langs->loadLangs(array("admin", "other", "agenda"));
|
||||||
@ -47,12 +48,10 @@ $type = 'action';
|
|||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||||
|
|
||||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
|
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
|
||||||
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -60,25 +59,21 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
|
||||||
{
|
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($action == 'set')
|
if ($action == 'set') {
|
||||||
{
|
|
||||||
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
||||||
} elseif ($action == 'specimen') // For orders
|
} elseif ($action == 'specimen') { // For orders
|
||||||
{
|
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
|
|
||||||
$commande = new CommandeFournisseur($db);
|
$commande = new CommandeFournisseur($db);
|
||||||
@ -88,25 +83,21 @@ if ($action == 'set')
|
|||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0;
|
$file = ''; $classname = ''; $filefound = 0;
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file)) {
|
||||||
{
|
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound) {
|
||||||
{
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$module = new $classname($db, $commande);
|
$module = new $classname($db, $commande);
|
||||||
|
|
||||||
if ($module->write_file($commande, $langs) > 0)
|
if ($module->write_file($commande, $langs) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -117,27 +108,20 @@ if ($action == 'set')
|
|||||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setmodel') {
|
||||||
|
// Activate a model
|
||||||
// Activate a model
|
|
||||||
elseif ($action == 'setmodel')
|
|
||||||
{
|
|
||||||
//print "sssd".$value;
|
//print "sssd".$value;
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
} elseif ($action == 'del')
|
} elseif ($action == 'del') {
|
||||||
{
|
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
|
||||||
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
|
dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setdoc') {
|
||||||
|
// Set default model
|
||||||
// Set default model
|
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
elseif ($action == 'setdoc')
|
|
||||||
{
|
|
||||||
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
|
|
||||||
{
|
|
||||||
// The constant that has been read in front of the new set
|
// The constant that has been read in front of the new set
|
||||||
// is therefore passed through a variable to have a coherent display
|
// is therefore passed through a variable to have a coherent display
|
||||||
$conf->global->ACTION_EVENT_ADDON_PDF = $value;
|
$conf->global->ACTION_EVENT_ADDON_PDF = $value;
|
||||||
@ -145,8 +129,7 @@ elseif ($action == 'setdoc')
|
|||||||
|
|
||||||
// On active le modele
|
// On active le modele
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "other", "agenda"));
|
$langs->loadLangs(array("admin", "other", "agenda"));
|
||||||
@ -39,8 +40,7 @@ $def = array();
|
|||||||
$actionsave = GETPOST('save', 'alpha');
|
$actionsave = GETPOST('save', 'alpha');
|
||||||
|
|
||||||
// Sauvegardes parametres
|
// Sauvegardes parametres
|
||||||
if ($actionsave)
|
if ($actionsave) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
@ -50,8 +50,7 @@ if ($actionsave)
|
|||||||
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
|
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
|
||||||
$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
|
$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if ($i >= 4)
|
if ($i >= 4) {
|
||||||
{
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
@ -66,7 +65,9 @@ if ($actionsave)
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
|
if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) {
|
||||||
|
$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
|
||||||
|
}
|
||||||
|
|
||||||
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||||
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
|
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
|
||||||
@ -97,8 +98,9 @@ print "</tr>";
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
|
print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
|
||||||
print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
|
print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
|
||||||
if (!empty($conf->use_javascript_ajax))
|
if (!empty($conf->use_javascript_ajax)) {
|
||||||
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
|
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "<td> </td>";
|
print "<td> </td>";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
@ -183,8 +185,7 @@ $message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
|
|||||||
|
|
||||||
print info_admin($message);
|
print info_admin($message);
|
||||||
|
|
||||||
if (!empty($conf->use_javascript_ajax))
|
if (!empty($conf->use_javascript_ajax)) {
|
||||||
{
|
|
||||||
print "\n".'<script type="text/javascript">';
|
print "\n".'<script type="text/javascript">';
|
||||||
print '$(document).ready(function () {
|
print '$(document).ready(function () {
|
||||||
$("#generate_token").click(function() {
|
$("#generate_token").click(function() {
|
||||||
|
|||||||
@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
|
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$actionsave = GETPOST('save', 'alpha');
|
$actionsave = GETPOST('save', 'alpha');
|
||||||
@ -51,8 +52,7 @@ $type = 'bankaccount';
|
|||||||
|
|
||||||
// Order display of bank account
|
// Order display of bank account
|
||||||
if ($action == 'setbankorder') {
|
if ($action == 'setbankorder') {
|
||||||
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -62,16 +62,14 @@ if ($action == 'setbankorder') {
|
|||||||
|
|
||||||
// Auto report last num releve on conciliate
|
// Auto report last num releve on conciliate
|
||||||
if ($action == 'setreportlastnumreleve') {
|
if ($action == 'setreportlastnumreleve') {
|
||||||
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'unsetreportlastnumreleve') {
|
} elseif ($action == 'unsetreportlastnumreleve') {
|
||||||
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -81,16 +79,14 @@ if ($action == 'setreportlastnumreleve') {
|
|||||||
|
|
||||||
// Colorize movements
|
// Colorize movements
|
||||||
if ($action == 'setbankcolorizemovement') {
|
if ($action == 'setbankcolorizemovement') {
|
||||||
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'unsetbankcolorizemovement') {
|
} elseif ($action == 'unsetbankcolorizemovement') {
|
||||||
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -98,31 +94,34 @@ if ($action == 'setbankcolorizemovement') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($actionsave)
|
if ($actionsave) {
|
||||||
{
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$i = 1; $errorsaved = 0;
|
$i = 1; $errorsaved = 0;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Save colors
|
// Save colors
|
||||||
while ($i <= 2)
|
while ($i <= 2) {
|
||||||
{
|
|
||||||
$color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha');
|
$color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha');
|
||||||
if ($color == '-1') $color = '';
|
if ($color == '-1') {
|
||||||
|
$color = '';
|
||||||
|
}
|
||||||
|
|
||||||
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
|
if (empty($errorsaved)) {
|
||||||
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,12 +174,12 @@ if ($action == 'set') {
|
|||||||
} elseif ($action == 'del') {
|
} elseif ($action == 'del') {
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0) {
|
if ($ret > 0) {
|
||||||
if ($conf->global->BANKADDON_PDF == "$value")
|
if ($conf->global->BANKADDON_PDF == "$value") {
|
||||||
dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity);
|
dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setdoc') {
|
||||||
// Set default model
|
// Set default model
|
||||||
elseif ($action == 'setdoc') {
|
|
||||||
if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
// The constant that was read before the new set
|
// The constant that was read before the new set
|
||||||
// We therefore requires a variable to have a coherent view
|
// We therefore requires a variable to have a coherent view
|
||||||
@ -247,8 +246,9 @@ while ($i < $nbofbank) {
|
|||||||
print '<td class="nowrap">';
|
print '<td class="nowrap">';
|
||||||
$tmparray = explode(' ', $bankorder[$i][2]);
|
$tmparray = explode(' ', $bankorder[$i][2]);
|
||||||
foreach ($tmparray as $key => $val) {
|
foreach ($tmparray as $key => $val) {
|
||||||
if ($key > 0)
|
if ($key > 0) {
|
||||||
print ', ';
|
print ', ';
|
||||||
|
}
|
||||||
print $langs->trans($val);
|
print $langs->trans($val);
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
@ -333,18 +333,22 @@ foreach ($dirmodels as $reldir) {
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
$modulequalified = 1;
|
$modulequalified = 1;
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
$modulequalified = 0;
|
$modulequalified = 0;
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
$modulequalified = 0;
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($modulequalified) {
|
if ($modulequalified) {
|
||||||
print '<tr class="oddeven"><td width="100">';
|
print '<tr class="oddeven"><td width="100">';
|
||||||
print(empty($module->name) ? $name : $module->name);
|
print(empty($module->name) ? $name : $module->name);
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
if (method_exists($module, 'info'))
|
if (method_exists($module, 'info')) {
|
||||||
print $module->info($langs);
|
print $module->info($langs);
|
||||||
else print $module->description;
|
} else {
|
||||||
|
print $module->description;
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
@ -436,11 +440,9 @@ if ($conf->global->BANK_COLORIZE_MOVEMENT) {
|
|||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if (!empty($conf->global->BANK_COLORIZE_MOVEMENT))
|
if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
|
||||||
{
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($i <= 2)
|
while ($i <= 2) {
|
||||||
{
|
|
||||||
$key = $i;
|
$key = $i;
|
||||||
$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
|
$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
|
||||||
|
|
||||||
|
|||||||
@ -39,13 +39,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'bank_account'; //Must be the $element of the class that manage extrafield
|
$elementtype = 'bank_account'; //Must be the $element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -79,8 +83,7 @@ print dol_get_fiche_end();
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if ($action != 'create' && $action != 'edit')
|
if ($action != 'create' && $action != 'edit') {
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -90,8 +93,7 @@ if ($action != 'create' && $action != 'edit')
|
|||||||
/*
|
/*
|
||||||
* Creation of an optional field
|
* Creation of an optional field
|
||||||
*/
|
*/
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print '<br><div id="newattrib"></div>';
|
print '<br><div id="newattrib"></div>';
|
||||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
@ -101,8 +103,7 @@ if ($action == 'create')
|
|||||||
/*
|
/*
|
||||||
* Edition of an optional field
|
* Edition of an optional field
|
||||||
*/
|
*/
|
||||||
if ($action == 'edit' && !empty($attrname))
|
if ($action == 'edit' && !empty($attrname)) {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
|
||||||
@ -42,21 +44,17 @@ $action = GETPOST('action', 'aZ09');
|
|||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||||
|
|
||||||
if ($action == 'setbarcodeproducton')
|
if ($action == 'setbarcodeproducton') {
|
||||||
{
|
|
||||||
$barcodenumberingmodule = GETPOST('value', 'alpha');
|
$barcodenumberingmodule = GETPOST('value', 'alpha');
|
||||||
$res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
|
||||||
if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
|
if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) {
|
||||||
{
|
|
||||||
$res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'setbarcodeproductoff')
|
} elseif ($action == 'setbarcodeproductoff') {
|
||||||
{
|
|
||||||
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
|
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setcoder')
|
if ($action == 'setcoder') {
|
||||||
{
|
|
||||||
$coder = GETPOST('coder', 'alpha');
|
$coder = GETPOST('coder', 'alpha');
|
||||||
$code_id = GETPOST('code_id', 'int');
|
$code_id = GETPOST('code_id', 'int');
|
||||||
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
|
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
|
||||||
@ -65,9 +63,10 @@ if ($action == 'setcoder')
|
|||||||
$sqlp .= " AND entity = ".$conf->entity;
|
$sqlp .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql = $db->query($sqlp);
|
$resql = $db->query($sqlp);
|
||||||
if (!$resql) dol_print_error($db);
|
if (!$resql) {
|
||||||
} elseif ($action == 'update')
|
dol_print_error($db);
|
||||||
{
|
}
|
||||||
|
} elseif ($action == 'update') {
|
||||||
$location = GETPOST('GENBARCODE_LOCATION', 'alpha');
|
$location = GETPOST('GENBARCODE_LOCATION', 'alpha');
|
||||||
$res = dolibarr_set_const($db, "GENBARCODE_LOCATION", $location, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "GENBARCODE_LOCATION", $location, 'chaine', 0, '', $conf->entity);
|
||||||
$coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE', 'alpha');
|
$coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE', 'alpha');
|
||||||
@ -75,31 +74,26 @@ if ($action == 'setcoder')
|
|||||||
$coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY', 'alpha');
|
$coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY', 'alpha');
|
||||||
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if ($res > 0)
|
if ($res > 0) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'updateengine')
|
} elseif ($action == 'updateengine') {
|
||||||
{
|
|
||||||
$sql = "SELECT rowid, coder";
|
$sql = "SELECT rowid, coder";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
|
||||||
$sql .= " WHERE entity = ".$conf->entity;
|
$sql .= " WHERE entity = ".$conf->entity;
|
||||||
$sql .= " ORDER BY code";
|
$sql .= " ORDER BY code";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
if (GETPOST('coder'.$obj->rowid, 'alpha'))
|
if (GETPOST('coder'.$obj->rowid, 'alpha')) {
|
||||||
{
|
|
||||||
$coder = GETPOST('coder'.$obj->rowid, 'alpha');
|
$coder = GETPOST('coder'.$obj->rowid, 'alpha');
|
||||||
$code_id = $obj->rowid;
|
$code_id = $obj->rowid;
|
||||||
|
|
||||||
@ -109,7 +103,9 @@ if ($action == 'setcoder')
|
|||||||
$sqlp .= " AND entity = ".$conf->entity;
|
$sqlp .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$upsql = $db->query($sqlp);
|
$upsql = $db->query($sqlp);
|
||||||
if (!$upsql) dol_print_error($db);
|
if (!$upsql) {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -140,25 +136,21 @@ clearstatcache();
|
|||||||
// Scan list of all barcode included provided by external modules
|
// Scan list of all barcode included provided by external modules
|
||||||
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
|
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
|
||||||
|
|
||||||
foreach ($dirbarcode as $reldir)
|
foreach ($dirbarcode as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir);
|
$dir = dol_buildpath($reldir);
|
||||||
$newdir = dol_osencode($dir);
|
$newdir = dol_osencode($dir);
|
||||||
|
|
||||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||||
if (!is_dir($newdir)) continue;
|
if (!is_dir($newdir)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$handle = @opendir($newdir);
|
$handle = @opendir($newdir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
|
||||||
{
|
if (is_readable($newdir.$file)) {
|
||||||
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
if (preg_match('/(.*)\.modules\.php$/i', $file, $reg)) {
|
||||||
{
|
|
||||||
if (is_readable($newdir.$file))
|
|
||||||
{
|
|
||||||
if (preg_match('/(.*)\.modules\.php$/i', $file, $reg))
|
|
||||||
{
|
|
||||||
$filebis = $reg[1];
|
$filebis = $reg[1];
|
||||||
|
|
||||||
// Loading encoding class
|
// Loading encoding class
|
||||||
@ -167,11 +159,14 @@ foreach ($dirbarcode as $reldir)
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
// Show modules according to features level
|
// Show modules according to features level
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled()) {
|
||||||
{
|
|
||||||
$barcodelist[$filebis] = $module->info();
|
$barcodelist[$filebis] = $module->info();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,8 +183,7 @@ foreach ($dirbarcode as $reldir)
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', '');
|
print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', '');
|
||||||
|
|
||||||
if (empty($conf->use_javascript_ajax))
|
if (empty($conf->use_javascript_ajax)) {
|
||||||
{
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="updateengine">';
|
print '<input type="hidden" name="action" value="updateengine">';
|
||||||
@ -210,13 +204,11 @@ $sql .= " ORDER BY code";
|
|||||||
|
|
||||||
dol_syslog("admin/barcode.php", LOG_DEBUG);
|
dol_syslog("admin/barcode.php", LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
print '<tr class="oddeven"><td width="100">';
|
print '<tr class="oddeven"><td width="100">';
|
||||||
@ -230,29 +222,28 @@ if ($resql)
|
|||||||
|
|
||||||
// Show example
|
// Show example
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($obj->coder && $obj->coder != -1)
|
if ($obj->coder && $obj->coder != -1) {
|
||||||
{
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
|
||||||
foreach ($dirbarcode as $reldir)
|
foreach ($dirbarcode as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir, 0);
|
$dir = dol_buildpath($reldir, 0);
|
||||||
$newdir = dol_osencode($dir);
|
$newdir = dol_osencode($dir);
|
||||||
|
|
||||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||||
if (!is_dir($newdir)) continue;
|
if (!is_dir($newdir)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$result = @include_once $newdir.$obj->coder.'.modules.php';
|
$result = @include_once $newdir.$obj->coder.'.modules.php';
|
||||||
if ($result) break;
|
if ($result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
$classname = "mod".ucfirst($obj->coder);
|
$classname = "mod".ucfirst($obj->coder);
|
||||||
if (class_exists($classname))
|
if (class_exists($classname)) {
|
||||||
{
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
if ($module->encodingIsSupported($obj->encoding))
|
if ($module->encodingIsSupported($obj->encoding)) {
|
||||||
{
|
|
||||||
// Build barcode on disk (not used, this is done to make debug easier)
|
// Build barcode on disk (not used, this is done to make debug easier)
|
||||||
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
|
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
|
||||||
// Generate on the fly and output barcode with generator
|
// Generate on the fly and output barcode with generator
|
||||||
@ -280,8 +271,7 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
if (empty($conf->use_javascript_ajax))
|
if (empty($conf->use_javascript_ajax)) {
|
||||||
{
|
|
||||||
print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'"></div>';
|
print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'"></div>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
@ -306,14 +296,12 @@ print '<td> </td>';
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Chemin du binaire genbarcode sous linux
|
// Chemin du binaire genbarcode sous linux
|
||||||
if (!isset($_SERVER['WINDIR']))
|
if (!isset($_SERVER['WINDIR'])) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
|
print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
|
||||||
print '<td width="60" class="center">';
|
print '<td width="60" class="center">';
|
||||||
print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">';
|
print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">';
|
||||||
if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION))
|
if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) {
|
||||||
{
|
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>';
|
print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>';
|
||||||
}
|
}
|
||||||
@ -321,8 +309,7 @@ if (!isset($_SERVER['WINDIR']))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Module products
|
// Module products
|
||||||
if (!empty($conf->product->enabled))
|
if (!empty($conf->product->enabled)) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
|
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
|
||||||
print '<td width="60" class="right">';
|
print '<td width="60" class="right">';
|
||||||
@ -331,8 +318,7 @@ if (!empty($conf->product->enabled))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Module thirdparty
|
// Module thirdparty
|
||||||
if (!empty($conf->societe->enabled))
|
if (!empty($conf->societe->enabled)) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
|
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
|
||||||
print '<td width="60" class="right">';
|
print '<td width="60" class="right">';
|
||||||
@ -351,8 +337,7 @@ print '<br>';
|
|||||||
|
|
||||||
|
|
||||||
// Select barcode numbering module
|
// Select barcode numbering module
|
||||||
if ($conf->product->enabled)
|
if ($conf->product->enabled) {
|
||||||
{
|
|
||||||
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
|
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
@ -366,23 +351,18 @@ if ($conf->product->enabled)
|
|||||||
|
|
||||||
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
|
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
|
||||||
|
|
||||||
foreach ($dirbarcodenum as $dirroot)
|
foreach ($dirbarcodenum as $dirroot) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($dirroot, 0);
|
$dir = dol_buildpath($dirroot, 0);
|
||||||
|
|
||||||
$handle = @opendir($dir);
|
$handle = @opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (preg_match('/^mod_barcode_product_.*php$/', $file)) {
|
||||||
{
|
|
||||||
if (preg_match('/^mod_barcode_product_.*php$/', $file))
|
|
||||||
{
|
|
||||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dol_include_once($dirroot.$file.'.php');
|
dol_include_once($dirroot.$file.'.php');
|
||||||
} catch (Exception $e)
|
} catch (Exception $e) {
|
||||||
{
|
|
||||||
dol_syslog($e->getMessage(), LOG_ERR);
|
dol_syslog($e->getMessage(), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,8 +374,7 @@ if ($conf->product->enabled)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
|
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
|
||||||
|
|
||||||
if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file")
|
if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") {
|
||||||
{
|
|
||||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&token='.newToken().'&value='.urlencode($file).'">';
|
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&token='.newToken().'&value='.urlencode($file).'">';
|
||||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
|
|||||||
@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
|
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$value = GETPOST('value', 'alpha');
|
$value = GETPOST('value', 'alpha');
|
||||||
@ -45,23 +47,24 @@ $type = 'bom';
|
|||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||||
|
|
||||||
if ($action == 'updateMask')
|
if ($action == 'updateMask') {
|
||||||
{
|
|
||||||
$maskconstbom = GETPOST('maskconstBom', 'alpha');
|
$maskconstbom = GETPOST('maskconstBom', 'alpha');
|
||||||
$maskbom = GETPOST('maskBom', 'alpha');
|
$maskbom = GETPOST('maskBom', 'alpha');
|
||||||
|
|
||||||
if ($maskconstbom) $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity);
|
if ($maskconstbom) {
|
||||||
|
$res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'specimen')
|
} elseif ($action == 'specimen') {
|
||||||
{
|
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
|
|
||||||
$bom = new BOM($db);
|
$bom = new BOM($db);
|
||||||
@ -70,25 +73,21 @@ if ($action == 'updateMask')
|
|||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0;
|
$file = ''; $classname = ''; $filefound = 0;
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
|
$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file)) {
|
||||||
{
|
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound) {
|
||||||
{
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($bom, $langs) > 0)
|
if ($module->write_file($bom, $langs) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -99,26 +98,19 @@ if ($action == 'updateMask')
|
|||||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'set') {
|
||||||
|
// Activate a model
|
||||||
// Activate a model
|
|
||||||
elseif ($action == 'set')
|
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
} elseif ($action == 'del')
|
} elseif ($action == 'del') {
|
||||||
{
|
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
if ($conf->global->BOM_ADDON_PDF == "$value") {
|
||||||
if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
|
dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setdoc') {
|
||||||
|
// Set default model
|
||||||
// Set default model
|
if (dolibarr_set_const($db, "BOM_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
elseif ($action == 'setdoc')
|
|
||||||
{
|
|
||||||
if (dolibarr_set_const($db, "BOM_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
|
|
||||||
{
|
|
||||||
// The constant that was read before the new set
|
// The constant that was read before the new set
|
||||||
// We therefore requires a variable to have a coherent view
|
// We therefore requires a variable to have a coherent view
|
||||||
$conf->global->BOM_ADDON_PDF = $value;
|
$conf->global->BOM_ADDON_PDF = $value;
|
||||||
@ -126,39 +118,37 @@ elseif ($action == 'setdoc')
|
|||||||
|
|
||||||
// On active le modele
|
// On active le modele
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'setmod')
|
} elseif ($action == 'setmod') {
|
||||||
{
|
|
||||||
// TODO Check if numbering module chosen can be activated
|
// TODO Check if numbering module chosen can be activated
|
||||||
// by calling method canBeActivated
|
// by calling method canBeActivated
|
||||||
|
|
||||||
dolibarr_set_const($db, "BOM_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "BOM_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
||||||
} elseif ($action == 'set_BOM_DRAFT_WATERMARK')
|
} elseif ($action == 'set_BOM_DRAFT_WATERMARK') {
|
||||||
{
|
|
||||||
$draft = GETPOST("BOM_DRAFT_WATERMARK");
|
$draft = GETPOST("BOM_DRAFT_WATERMARK");
|
||||||
$res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'set_BOM_FREE_TEXT')
|
} elseif ($action == 'set_BOM_FREE_TEXT') {
|
||||||
{
|
|
||||||
$freetext = GETPOST("BOM_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
|
$freetext = GETPOST("BOM_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
|
||||||
|
|
||||||
$res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -200,19 +190,14 @@ print '</tr>'."\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir."core/modules/bom/");
|
$dir = dol_buildpath($reldir."core/modules/bom/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
|
||||||
{
|
|
||||||
if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
|
||||||
{
|
|
||||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||||
|
|
||||||
require_once $dir.$file.'.php';
|
require_once $dir.$file.'.php';
|
||||||
@ -220,11 +205,14 @@ foreach ($dirmodels as $reldir)
|
|||||||
$module = new $file($db);
|
$module = new $file($db);
|
||||||
|
|
||||||
// Show modules according to features level
|
// Show modules according to features level
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled()) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
||||||
print $module->info();
|
print $module->info();
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -235,13 +223,15 @@ foreach ($dirmodels as $reldir)
|
|||||||
if (preg_match('/^Error/', $tmp)) {
|
if (preg_match('/^Error/', $tmp)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||||
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
} elseif ($tmp == 'NotConfigured') {
|
||||||
else print $tmp;
|
print $langs->trans($tmp);
|
||||||
|
} else {
|
||||||
|
print $tmp;
|
||||||
|
}
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
|
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->BOM_ADDON == $file)
|
if ($conf->global->BOM_ADDON == $file) {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
|
||||||
@ -261,8 +251,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||||
if ($nextval) {
|
if ($nextval) {
|
||||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
|
||||||
$nextval = $langs->trans($nextval);
|
$nextval = $langs->trans($nextval);
|
||||||
|
}
|
||||||
$htmltooltip .= $nextval.'<br>';
|
$htmltooltip .= $nextval.'<br>';
|
||||||
} else {
|
} else {
|
||||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||||
@ -297,12 +288,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
|||||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num_rows = $db->num_rows($resql);
|
$num_rows = $db->num_rows($resql);
|
||||||
while ($i < $num_rows)
|
while ($i < $num_rows) {
|
||||||
{
|
|
||||||
$array = $db->fetch_array($resql);
|
$array = $db->fetch_array($resql);
|
||||||
array_push($def, $array[0]);
|
array_push($def, $array[0]);
|
||||||
$i++;
|
$i++;
|
||||||
@ -324,31 +313,23 @@ print "</tr>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
foreach (array('', '/doc') as $valdir) {
|
||||||
foreach (array('', '/doc') as $valdir)
|
|
||||||
{
|
|
||||||
$realpath = $reldir."core/modules/bom".$valdir;
|
$realpath = $reldir."core/modules/bom".$valdir;
|
||||||
$dir = dol_buildpath($realpath);
|
$dir = dol_buildpath($realpath);
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
|
||||||
{
|
|
||||||
$filelist[] = $file;
|
$filelist[] = $file;
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
arsort($filelist);
|
arsort($filelist);
|
||||||
|
|
||||||
foreach ($filelist as $file)
|
foreach ($filelist as $file) {
|
||||||
{
|
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
if (file_exists($dir.'/'.$file)) {
|
||||||
{
|
|
||||||
if (file_exists($dir.'/'.$file))
|
|
||||||
{
|
|
||||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
@ -356,21 +337,26 @@ foreach ($dirmodels as $reldir)
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
$modulequalified = 1;
|
$modulequalified = 1;
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($modulequalified)
|
if ($modulequalified) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td width="100">';
|
print '<tr class="oddeven"><td width="100">';
|
||||||
print (empty($module->name) ? $name : $module->name);
|
print (empty($module->name) ? $name : $module->name);
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
if (method_exists($module, 'info')) print $module->info($langs);
|
if (method_exists($module, 'info')) {
|
||||||
else print $module->description;
|
print $module->info($langs);
|
||||||
|
} else {
|
||||||
|
print $module->description;
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
if (in_array($name, $def))
|
if (in_array($name, $def)) {
|
||||||
{
|
|
||||||
print '<td class="center">'."\n";
|
print '<td class="center">'."\n";
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'">';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'">';
|
||||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||||
@ -384,8 +370,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Default
|
// Default
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->BOM_ADDON_PDF == $name)
|
if ($conf->global->BOM_ADDON_PDF == $name) {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Default"), 'on');
|
print img_picto($langs->trans("Default"), 'on');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
@ -395,8 +380,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
// Info
|
// Info
|
||||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||||
}
|
}
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
||||||
@ -412,8 +396,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Preview
|
// Preview
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||||
@ -448,7 +431,9 @@ print "</tr>\n";
|
|||||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
foreach ($substitutionarray as $key => $val) {
|
||||||
|
$htmltext .= $key.'<br>';
|
||||||
|
}
|
||||||
$htmltext .= '</i>';
|
$htmltext .= '</i>';
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
@ -457,8 +442,7 @@ print '<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
|
|||||||
print '<tr class="oddeven"><td colspan="2">';
|
print '<tr class="oddeven"><td colspan="2">';
|
||||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||||
$variablename = 'BOM_FREE_TEXT';
|
$variablename = 'BOM_FREE_TEXT';
|
||||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
|
||||||
{
|
|
||||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||||
} else {
|
} else {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
|
|||||||
@ -39,13 +39,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'bom_bom';
|
$elementtype = 'bom_bom';
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -78,8 +82,7 @@ print dol_get_fiche_end();
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if ($action != 'create' && $action != 'edit')
|
if ($action != 'create' && $action != 'edit') {
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -89,8 +92,7 @@ if ($action != 'create' && $action != 'edit')
|
|||||||
/*
|
/*
|
||||||
* Creation of an optional field
|
* Creation of an optional field
|
||||||
*/
|
*/
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print '<br><div id="newattrib"></div>';
|
print '<br><div id="newattrib"></div>';
|
||||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
@ -100,8 +102,7 @@ if ($action == 'create')
|
|||||||
/*
|
/*
|
||||||
* Edition of an optional field
|
* Edition of an optional field
|
||||||
*/
|
*/
|
||||||
if ($action == 'edit' && !empty($attrname))
|
if ($action == 'edit' && !empty($attrname)) {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
|||||||
@ -34,14 +34,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
|
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$value = GETPOST('value', 'alpha');
|
$value = GETPOST('value', 'alpha');
|
||||||
|
|
||||||
|
|
||||||
if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipts_mint.php';
|
if (empty($conf->global->CHEQUERECEIPTS_ADDON)) {
|
||||||
|
$conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipts_mint.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -49,37 +52,38 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_AD
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'updateMask')
|
if ($action == 'updateMask') {
|
||||||
{
|
|
||||||
$maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha');
|
$maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha');
|
||||||
$maskchequereceipts = GETPOST('maskchequereceipts', 'alpha');
|
$maskchequereceipts = GETPOST('maskchequereceipts', 'alpha');
|
||||||
if ($maskconstchequereceipts) $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity);
|
if ($maskconstchequereceipts) {
|
||||||
|
$res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setmod')
|
if ($action == 'setmod') {
|
||||||
{
|
|
||||||
dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
|
if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') {
|
||||||
{
|
|
||||||
$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
|
$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
|
||||||
|
|
||||||
$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -118,45 +122,43 @@ print '</tr>'."\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir."core/modules/cheque/");
|
$dir = dol_buildpath($reldir."core/modules/cheque/");
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
|
||||||
{
|
|
||||||
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
|
|
||||||
{
|
|
||||||
$filebis = $file;
|
$filebis = $file;
|
||||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||||
$classname = preg_replace('/\.php$/', '', $file);
|
$classname = preg_replace('/\.php$/', '', $file);
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if (!is_file($dir.$filebis))
|
if (!is_file($dir.$filebis)) {
|
||||||
{
|
|
||||||
$filebis = $file."/".$file.".modules.php";
|
$filebis = $file."/".$file.".modules.php";
|
||||||
$classname = "mod_chequereceipt_".$file;
|
$classname = "mod_chequereceipt_".$file;
|
||||||
}
|
}
|
||||||
// Check if there is a filter on country
|
// Check if there is a filter on country
|
||||||
preg_match('/\-(.*)_(.*)$/', $classname, $reg);
|
preg_match('/\-(.*)_(.*)$/', $classname, $reg);
|
||||||
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
|
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$classname = preg_replace('/\-.*$/', '', $classname);
|
$classname = preg_replace('/\-.*$/', '', $classname);
|
||||||
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
|
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
|
||||||
{
|
|
||||||
// Charging the numbering class
|
// Charging the numbering class
|
||||||
require_once $dir.$filebis;
|
require_once $dir.$filebis;
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
// Show modules according to features level
|
// Show modules according to features level
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled()) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td width="100">';
|
print '<tr class="oddeven"><td width="100">';
|
||||||
print (empty($module->name) ? $name : $module->name);
|
print (empty($module->name) ? $name : $module->name);
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
@ -171,13 +173,15 @@ foreach ($dirmodels as $reldir)
|
|||||||
if (preg_match('/^Error/', $tmp)) {
|
if (preg_match('/^Error/', $tmp)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||||
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
} elseif ($tmp == 'NotConfigured') {
|
||||||
else print $tmp;
|
print $langs->trans($tmp);
|
||||||
|
} else {
|
||||||
|
print $tmp;
|
||||||
|
}
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
|
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->CHEQUERECEIPTS_ADDON == $file || $conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file)
|
if ($conf->global->CHEQUERECEIPTS_ADDON == $file || $conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
||||||
@ -194,8 +198,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||||
$htmltooltip .= $langs->trans("NextValue").': ';
|
$htmltooltip .= $langs->trans("NextValue").': ';
|
||||||
if ($nextval) {
|
if ($nextval) {
|
||||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
|
||||||
$nextval = $langs->trans($nextval);
|
$nextval = $langs->trans($nextval);
|
||||||
|
}
|
||||||
$htmltooltip .= $nextval.'<br>';
|
$htmltooltip .= $nextval.'<br>';
|
||||||
} else {
|
} else {
|
||||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||||
@ -205,9 +210,10 @@ foreach ($dirmodels as $reldir)
|
|||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||||
|
|
||||||
if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) // If module is the one used, we show existing errors
|
if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) { // If module is the one used, we show existing errors
|
||||||
{
|
if (!empty($module->error)) {
|
||||||
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
|
dol_htmloutput_mesg($module->error, '', 'error', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -246,14 +252,15 @@ print "</tr>\n";
|
|||||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
foreach ($substitutionarray as $key => $val) {
|
||||||
|
$htmltext .= $key.'<br>';
|
||||||
|
}
|
||||||
$htmltext .= '</i>';
|
$htmltext .= '</i>';
|
||||||
|
|
||||||
print '<tr class="oddeven"><td colspan="2">';
|
print '<tr class="oddeven"><td colspan="2">';
|
||||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||||
$variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT';
|
$variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT';
|
||||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
|
||||||
{
|
|
||||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||||
} else {
|
} else {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
|
|||||||
@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
|
||||||
@ -42,13 +44,11 @@ if (!in_array('clicktodial', $conf->modules)) {
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'setvalue' && $user->admin)
|
if ($action == 'setvalue' && $user->admin) {
|
||||||
{
|
|
||||||
$result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
|
$result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
|
||||||
$result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
|
$result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if ($result1 >= 0 && $result2 >= 0)
|
if ($result1 >= 0 && $result2 >= 0) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -117,12 +117,13 @@ print '<div class="center"><br><input type="submit" class="button" value="'.$lan
|
|||||||
print '</form><br><br>';
|
print '</form><br><br>';
|
||||||
|
|
||||||
|
|
||||||
if (!empty($conf->global->CLICKTODIAL_URL))
|
if (!empty($conf->global->CLICKTODIAL_URL)) {
|
||||||
{
|
|
||||||
$user->fetch_clicktodial();
|
$user->fetch_clicktodial();
|
||||||
|
|
||||||
$phonefortest = $mysoc->phone;
|
$phonefortest = $mysoc->phone;
|
||||||
if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest');
|
if (GETPOST('phonefortest')) {
|
||||||
|
$phonefortest = GETPOST('phonefortest');
|
||||||
|
}
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
@ -132,12 +133,17 @@ if (!empty($conf->global->CLICKTODIAL_URL))
|
|||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
$setupcomplete = 1;
|
$setupcomplete = 1;
|
||||||
if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete = 0;
|
if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) {
|
||||||
if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete = 0;
|
$setupcomplete = 0;
|
||||||
if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete = 0;
|
}
|
||||||
|
if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) {
|
||||||
|
$setupcomplete = 0;
|
||||||
|
}
|
||||||
|
if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) {
|
||||||
|
$setupcomplete = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($setupcomplete)
|
if ($setupcomplete) {
|
||||||
{
|
|
||||||
print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
|
print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
|
||||||
} else {
|
} else {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
|
|||||||
@ -39,7 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
|
$langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$value = GETPOST('value', 'alpha');
|
$value = GETPOST('value', 'alpha');
|
||||||
@ -54,23 +56,24 @@ $type = 'order';
|
|||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||||
|
|
||||||
if ($action == 'updateMask')
|
if ($action == 'updateMask') {
|
||||||
{
|
|
||||||
$maskconstorder = GETPOST('maskconstorder', 'alpha');
|
$maskconstorder = GETPOST('maskconstorder', 'alpha');
|
||||||
$maskorder = GETPOST('maskorder', 'alpha');
|
$maskorder = GETPOST('maskorder', 'alpha');
|
||||||
|
|
||||||
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
|
if ($maskconstorder) {
|
||||||
|
$res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'specimen')
|
} elseif ($action == 'specimen') {
|
||||||
{
|
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
|
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
@ -79,25 +82,21 @@ if ($action == 'updateMask')
|
|||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0;
|
$file = ''; $classname = ''; $filefound = 0;
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
|
$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file)) {
|
||||||
{
|
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound) {
|
||||||
{
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($commande, $langs) > 0)
|
if ($module->write_file($commande, $langs) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -108,23 +107,19 @@ if ($action == 'updateMask')
|
|||||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'set') {
|
||||||
|
// Activate a model
|
||||||
// Activate a model
|
|
||||||
elseif ($action == 'set') {
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
} elseif ($action == 'del') {
|
} elseif ($action == 'del') {
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
if ($conf->global->COMMANDE_ADDON_PDF == "$value") {
|
||||||
if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
|
dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setdoc') {
|
||||||
|
// Set default model
|
||||||
// Set default model
|
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
elseif ($action == 'setdoc') {
|
|
||||||
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
|
|
||||||
{
|
|
||||||
// The constant that was read before the new set
|
// The constant that was read before the new set
|
||||||
// We therefore requires a variable to have a coherent view
|
// We therefore requires a variable to have a coherent view
|
||||||
$conf->global->COMMANDE_ADDON_PDF = $value;
|
$conf->global->COMMANDE_ADDON_PDF = $value;
|
||||||
@ -132,8 +127,7 @@ elseif ($action == 'setdoc') {
|
|||||||
|
|
||||||
// On active le modele
|
// On active le modele
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'setmod') {
|
} elseif ($action == 'setmod') {
|
||||||
@ -141,29 +135,29 @@ elseif ($action == 'setdoc') {
|
|||||||
// by calling method canBeActivated
|
// by calling method canBeActivated
|
||||||
|
|
||||||
dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
||||||
} elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK')
|
} elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') {
|
||||||
{
|
|
||||||
$draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
|
$draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
|
||||||
$res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'set_ORDER_FREE_TEXT')
|
} elseif ($action == 'set_ORDER_FREE_TEXT') {
|
||||||
{
|
|
||||||
$freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
|
$freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
|
||||||
|
|
||||||
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -172,54 +166,52 @@ elseif ($action == 'setdoc') {
|
|||||||
// Activate Set Shippable Icon In List
|
// Activate Set Shippable Icon In List
|
||||||
$setshippableiconinlist = GETPOST('value', 'int');
|
$setshippableiconinlist = GETPOST('value', 'int');
|
||||||
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'setribchq')
|
} elseif ($action == 'setribchq') {
|
||||||
{
|
|
||||||
$rib = GETPOST('rib', 'alpha');
|
$rib = GETPOST('rib', 'alpha');
|
||||||
$chq = GETPOST('chq', 'alpha');
|
$chq = GETPOST('chq', 'alpha');
|
||||||
|
|
||||||
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
|
||||||
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') {
|
||||||
|
// Activate ask for payment bank
|
||||||
// Activate ask for payment bank
|
|
||||||
elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
|
|
||||||
{
|
|
||||||
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') {
|
||||||
|
// Activate ask for warehouse
|
||||||
// Activate ask for warehouse
|
|
||||||
elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
|
|
||||||
{
|
|
||||||
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -262,19 +254,14 @@ print '</tr>'."\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir."core/modules/commande/");
|
$dir = dol_buildpath($reldir."core/modules/commande/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
|
||||||
{
|
|
||||||
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
|
||||||
{
|
|
||||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||||
|
|
||||||
require_once $dir.$file.'.php';
|
require_once $dir.$file.'.php';
|
||||||
@ -282,11 +269,14 @@ foreach ($dirmodels as $reldir)
|
|||||||
$module = new $file($db);
|
$module = new $file($db);
|
||||||
|
|
||||||
// Show modules according to features level
|
// Show modules according to features level
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled()) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
||||||
print $module->info();
|
print $module->info();
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -297,13 +287,15 @@ foreach ($dirmodels as $reldir)
|
|||||||
if (preg_match('/^Error/', $tmp)) {
|
if (preg_match('/^Error/', $tmp)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||||
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
} elseif ($tmp == 'NotConfigured') {
|
||||||
else print $tmp;
|
print $langs->trans($tmp);
|
||||||
|
} else {
|
||||||
|
print $tmp;
|
||||||
|
}
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
|
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->COMMANDE_ADDON == $file)
|
if ($conf->global->COMMANDE_ADDON == $file) {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
|
||||||
@ -323,8 +315,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||||
if ($nextval) {
|
if ($nextval) {
|
||||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
|
||||||
$nextval = $langs->trans($nextval);
|
$nextval = $langs->trans($nextval);
|
||||||
|
}
|
||||||
$htmltooltip .= $nextval.'<br>';
|
$htmltooltip .= $nextval.'<br>';
|
||||||
} else {
|
} else {
|
||||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||||
@ -359,12 +352,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
|||||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num_rows = $db->num_rows($resql);
|
$num_rows = $db->num_rows($resql);
|
||||||
while ($i < $num_rows)
|
while ($i < $num_rows) {
|
||||||
{
|
|
||||||
$array = $db->fetch_array($resql);
|
$array = $db->fetch_array($resql);
|
||||||
array_push($def, $array[0]);
|
array_push($def, $array[0]);
|
||||||
$i++;
|
$i++;
|
||||||
@ -387,31 +378,23 @@ print "</tr>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
foreach (array('', '/doc') as $valdir) {
|
||||||
foreach (array('', '/doc') as $valdir)
|
|
||||||
{
|
|
||||||
$realpath = $reldir."core/modules/commande".$valdir;
|
$realpath = $reldir."core/modules/commande".$valdir;
|
||||||
$dir = dol_buildpath($realpath);
|
$dir = dol_buildpath($realpath);
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
|
||||||
{
|
|
||||||
$filelist[] = $file;
|
$filelist[] = $file;
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
arsort($filelist);
|
arsort($filelist);
|
||||||
|
|
||||||
foreach ($filelist as $file)
|
foreach ($filelist as $file) {
|
||||||
{
|
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
if (file_exists($dir.'/'.$file)) {
|
||||||
{
|
|
||||||
if (file_exists($dir.'/'.$file))
|
|
||||||
{
|
|
||||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
@ -419,21 +402,26 @@ foreach ($dirmodels as $reldir)
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
$modulequalified = 1;
|
$modulequalified = 1;
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($modulequalified)
|
if ($modulequalified) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td width="100">';
|
print '<tr class="oddeven"><td width="100">';
|
||||||
print (empty($module->name) ? $name : $module->name);
|
print (empty($module->name) ? $name : $module->name);
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
if (method_exists($module, 'info')) print $module->info($langs);
|
if (method_exists($module, 'info')) {
|
||||||
else print $module->description;
|
print $module->info($langs);
|
||||||
|
} else {
|
||||||
|
print $module->description;
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
if (in_array($name, $def))
|
if (in_array($name, $def)) {
|
||||||
{
|
|
||||||
print '<td class="center">'."\n";
|
print '<td class="center">'."\n";
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
|
||||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||||
@ -447,8 +435,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Default
|
// Default
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->COMMANDE_ADDON_PDF == $name)
|
if ($conf->global->COMMANDE_ADDON_PDF == $name) {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Default"), 'on');
|
print img_picto($langs->trans("Default"), 'on');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
@ -458,8 +445,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
// Info
|
// Info
|
||||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||||
}
|
}
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
||||||
@ -480,8 +466,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Preview
|
// Preview
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||||
@ -528,26 +513,21 @@ print "</tr>\n";
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
|
print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
|
||||||
print "<td>";
|
print "<td>";
|
||||||
if (empty($conf->facture->enabled))
|
if (empty($conf->facture->enabled)) {
|
||||||
{
|
if (!empty($conf->banque->enabled)) {
|
||||||
if (!empty($conf->banque->enabled))
|
|
||||||
{
|
|
||||||
$sql = "SELECT rowid, label";
|
$sql = "SELECT rowid, label";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||||
$sql .= " WHERE clos = 0";
|
$sql .= " WHERE clos = 0";
|
||||||
$sql .= " AND courant = 1";
|
$sql .= " AND courant = 1";
|
||||||
$sql .= " AND entity IN (".getEntity('bank_account').")";
|
$sql .= " AND entity IN (".getEntity('bank_account').")";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num > 0)
|
if ($num > 0) {
|
||||||
{
|
|
||||||
print '<select name="rib" class="flat" id="rib">';
|
print '<select name="rib" class="flat" id="rib">';
|
||||||
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
|
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
|
|
||||||
print '<option value="'.$row[0].'"';
|
print '<option value="'.$row[0].'"';
|
||||||
@ -572,8 +552,7 @@ print "</td></tr>";
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
|
print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
|
||||||
print "<td>";
|
print "<td>";
|
||||||
if (empty($conf->facture->enabled))
|
if (empty($conf->facture->enabled)) {
|
||||||
{
|
|
||||||
print '<select class="flat" name="chq" id="chq">';
|
print '<select class="flat" name="chq" id="chq">';
|
||||||
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
|
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
|
||||||
print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
|
print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
|
||||||
@ -585,12 +564,10 @@ if (empty($conf->facture->enabled))
|
|||||||
$sql .= " AND entity IN (".getEntity('bank_account').")";
|
$sql .= " AND entity IN (".getEntity('bank_account').")";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
|
|
||||||
print '<option value="'.$row[0].'"';
|
print '<option value="'.$row[0].'"';
|
||||||
@ -626,7 +603,9 @@ print "</tr>\n";
|
|||||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
foreach ($substitutionarray as $key => $val) {
|
||||||
|
$htmltext .= $key.'<br>';
|
||||||
|
}
|
||||||
$htmltext .= '</i>';
|
$htmltext .= '</i>';
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
@ -635,8 +614,7 @@ print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
|
|||||||
print '<tr class="oddeven"><td colspan="2">';
|
print '<tr class="oddeven"><td colspan="2">';
|
||||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||||
$variablename = 'ORDER_FREE_TEXT';
|
$variablename = 'ORDER_FREE_TEXT';
|
||||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
|
||||||
{
|
|
||||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||||
} else {
|
} else {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
@ -671,11 +649,11 @@ print '<td>'.$langs->trans("ShippableOrderIconInList").'</td>';
|
|||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if (!empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
|
if (!empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&token='.newToken().'&value=0">';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&token='.newToken().'&value=0">';
|
||||||
print img_picto($langs->trans("Activated"),'switch_on');
|
print img_picto($langs->trans("Activated"),'switch_on');
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&token='.newToken().'&value=1">';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&token='.newToken().'&value=1">';
|
||||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||||
}
|
}
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -686,60 +664,60 @@ print '</tr>';
|
|||||||
if ($conf->banque->enabled)
|
if ($conf->banque->enabled)
|
||||||
{
|
{
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td> </td><td class="center">';
|
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td> </td><td class="center">';
|
||||||
if (! empty($conf->use_javascript_ajax))
|
if (! empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ORDER');
|
print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ORDER');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER))
|
if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER))
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&token='.newToken().'&value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&token='.newToken().'&value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&token='.newToken().'&value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&token='.newToken().'&value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td> </td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
|
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td> </td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask for warehouse during order
|
// Ask for warehouse during order
|
||||||
if ($conf->stock->enabled)
|
if ($conf->stock->enabled)
|
||||||
{
|
{
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td> </td><td class="center">';
|
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td> </td><td class="center">';
|
||||||
if (! empty($conf->use_javascript_ajax))
|
if (! empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
|
print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER))
|
if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER))
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&token='.newToken().'&value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&token='.newToken().'&value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&token='.newToken().'&value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&token='.newToken().'&value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td> </td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
|
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td> </td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
@ -48,13 +49,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->trans($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->trans($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield
|
$elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -87,8 +92,7 @@ print dol_get_fiche_end();
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if ($action != 'create' && $action != 'edit')
|
if ($action != 'create' && $action != 'edit') {
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
|
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -101,8 +105,7 @@ if ($action != 'create' && $action != 'edit')
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
@ -114,8 +117,7 @@ if ($action == 'create')
|
|||||||
/* Edition of an optional field */
|
/* Edition of an optional field */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
if ($action == 'edit' && !empty($attrname))
|
if ($action == 'edit' && !empty($attrname)) {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'companies', 'bills'));
|
$langs->loadLangs(array('admin', 'companies', 'bills'));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
@ -57,14 +59,14 @@ $hookmanager->initHooks(array('admincompany', 'globaladmin'));
|
|||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
||||||
|| ($action == 'updateedit'))
|
|| ($action == 'updateedit')) {
|
||||||
{
|
|
||||||
$tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
|
$tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
|
||||||
if (!empty($tmparray['id']))
|
if (!empty($tmparray['id'])) {
|
||||||
{
|
|
||||||
$mysoc->country_id = $tmparray['id'];
|
$mysoc->country_id = $tmparray['id'];
|
||||||
$mysoc->country_code = $tmparray['code'];
|
$mysoc->country_code = $tmparray['code'];
|
||||||
$mysoc->country_label = $tmparray['label'];
|
$mysoc->country_label = $tmparray['label'];
|
||||||
@ -76,8 +78,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
|
$tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
|
||||||
if (!empty($tmparray['id']))
|
if (!empty($tmparray['id'])) {
|
||||||
{
|
|
||||||
$mysoc->state_id = $tmparray['id'];
|
$mysoc->state_id = $tmparray['id'];
|
||||||
$mysoc->state_code = $tmparray['code'];
|
$mysoc->state_code = $tmparray['code'];
|
||||||
$mysoc->state_label = $tmparray['label'];
|
$mysoc->state_label = $tmparray['label'];
|
||||||
@ -107,59 +108,58 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
|
|
||||||
$arrayofimages = array('logo', 'logo_squarred');
|
$arrayofimages = array('logo', 'logo_squarred');
|
||||||
|
|
||||||
foreach ($arrayofimages as $varforimage)
|
foreach ($arrayofimages as $varforimage) {
|
||||||
{
|
|
||||||
if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported.
|
if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported.
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
|
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_FILES[$varforimage]["tmp_name"])
|
if ($_FILES[$varforimage]["tmp_name"]) {
|
||||||
{
|
|
||||||
$reg = array();
|
$reg = array();
|
||||||
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg))
|
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
|
||||||
{
|
|
||||||
$original_file = $reg[1];
|
$original_file = $reg[1];
|
||||||
|
|
||||||
$isimage = image_format_supported($original_file);
|
$isimage = image_format_supported($original_file);
|
||||||
if ($isimage >= 0)
|
if ($isimage >= 0) {
|
||||||
{
|
|
||||||
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
|
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
|
||||||
if (!is_dir($dirforimage))
|
if (!is_dir($dirforimage)) {
|
||||||
{
|
|
||||||
dol_mkdir($dirforimage);
|
dol_mkdir($dirforimage);
|
||||||
}
|
}
|
||||||
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
|
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$constant = "MAIN_INFO_SOCIETE_LOGO";
|
$constant = "MAIN_INFO_SOCIETE_LOGO";
|
||||||
if ($varforimage == 'logo_squarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
|
if ($varforimage == 'logo_squarred') {
|
||||||
|
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
|
||||||
|
}
|
||||||
|
|
||||||
dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
// Create thumbs of logo (Note that PDF use original file and not thumbs)
|
// Create thumbs of logo (Note that PDF use original file and not thumbs)
|
||||||
if ($isimage > 0)
|
if ($isimage > 0) {
|
||||||
{
|
|
||||||
// Create thumbs
|
// Create thumbs
|
||||||
//$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
|
//$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
|
||||||
|
|
||||||
// Create small thumb, Used on logon for example
|
// Create small thumb, Used on logon for example
|
||||||
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
||||||
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg))
|
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
|
||||||
{
|
|
||||||
$imgThumbSmall = $reg[1]; // Save only basename
|
$imgThumbSmall = $reg[1]; // Save only basename
|
||||||
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
|
||||||
} else dol_syslog($imgThumbSmall);
|
} else {
|
||||||
|
dol_syslog($imgThumbSmall);
|
||||||
|
}
|
||||||
|
|
||||||
// Create mini thumb, Used on menu or for setup page for example
|
// Create mini thumb, Used on menu or for setup page for example
|
||||||
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||||
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg))
|
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
|
||||||
{
|
|
||||||
$imgThumbMini = $reg[1]; // Save only basename
|
$imgThumbMini = $reg[1]; // Save only basename
|
||||||
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
|
||||||
} else dol_syslog($imgThumbMini);
|
} else {
|
||||||
} else dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
|
dol_syslog($imgThumbMini);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
|
||||||
|
}
|
||||||
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
|
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
|
||||||
$error++;
|
$error++;
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
@ -198,13 +198,11 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
$usevat = GETPOST("optiontva", 'aZ09');
|
$usevat = GETPOST("optiontva", 'aZ09');
|
||||||
$uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
|
$uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
|
||||||
$uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
|
$uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
|
||||||
if ($uselocaltax1 == 'localtax1on' && !$usevat)
|
if ($uselocaltax1 == 'localtax1on' && !$usevat) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
|
setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if ($uselocaltax2 == 'localtax2on' && !$usevat)
|
if ($uselocaltax2 == 'localtax2on' && !$usevat) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
|
setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -213,8 +211,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if ($_POST["optionlocaltax1"] == "localtax1on")
|
if ($_POST["optionlocaltax1"] == "localtax1on") {
|
||||||
{
|
|
||||||
if (!GETPOSTISSET('lt1')) {
|
if (!GETPOSTISSET('lt1')) {
|
||||||
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
|
||||||
} else {
|
} else {
|
||||||
@ -222,8 +219,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
}
|
}
|
||||||
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
||||||
}
|
}
|
||||||
if ($_POST["optionlocaltax2"] == "localtax2on")
|
if ($_POST["optionlocaltax2"] == "localtax2on") {
|
||||||
{
|
|
||||||
if (!GETPOSTISSET('lt2')) {
|
if (!GETPOSTISSET('lt2')) {
|
||||||
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
|
||||||
} else {
|
} else {
|
||||||
@ -232,8 +228,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
|
if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
}
|
}
|
||||||
@ -242,24 +237,22 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action != 'updateedit' && !$error)
|
if ($action != 'updateedit' && !$error) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumbs
|
if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
|
||||||
{
|
if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) {
|
||||||
if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
|
|
||||||
{
|
|
||||||
$isimage = image_format_supported($_GET["file"]);
|
$isimage = image_format_supported($_GET["file"]);
|
||||||
|
|
||||||
// Create thumbs of logo
|
// Create thumbs of logo
|
||||||
if ($isimage > 0)
|
if ($isimage > 0) {
|
||||||
{
|
|
||||||
$constant = "MAIN_INFO_SOCIETE_LOGO";
|
$constant = "MAIN_INFO_SOCIETE_LOGO";
|
||||||
if ($action == 'addthumbsquarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
|
if ($action == 'addthumbsquarred') {
|
||||||
|
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
|
||||||
|
}
|
||||||
|
|
||||||
$reg = array();
|
$reg = array();
|
||||||
|
|
||||||
@ -268,19 +261,21 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
|
|||||||
|
|
||||||
// Create small thumb. Used on logon for example
|
// Create small thumb. Used on logon for example
|
||||||
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
||||||
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg))
|
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
|
||||||
{
|
|
||||||
$imgThumbSmall = $reg[1]; // Save only basename
|
$imgThumbSmall = $reg[1]; // Save only basename
|
||||||
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
|
||||||
} else dol_syslog($imgThumbSmall);
|
} else {
|
||||||
|
dol_syslog($imgThumbSmall);
|
||||||
|
}
|
||||||
|
|
||||||
// Create mini thumbs. Used on menu or for setup page for example
|
// Create mini thumbs. Used on menu or for setup page for example
|
||||||
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
|
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||||
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg))
|
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
|
||||||
{
|
|
||||||
$imgThumbMini = $reg[1]; // Save only basename
|
$imgThumbMini = $reg[1]; // Save only basename
|
||||||
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
|
||||||
} else dol_syslog($imgThumbMini);
|
} else {
|
||||||
|
dol_syslog($imgThumbMini);
|
||||||
|
}
|
||||||
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
@ -299,54 +294,67 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($action == 'removelogo' || $action == 'removelogosquarred')
|
if ($action == 'removelogo' || $action == 'removelogosquarred') {
|
||||||
{
|
|
||||||
$constant = "MAIN_INFO_SOCIETE_LOGO";
|
$constant = "MAIN_INFO_SOCIETE_LOGO";
|
||||||
if ($action == 'removelogosquarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
|
if ($action == 'removelogosquarred') {
|
||||||
|
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
|
||||||
|
}
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
$logofilename = $mysoc->logo;
|
$logofilename = $mysoc->logo;
|
||||||
$logofilenamebis = $mysoc->logo_squarred;
|
$logofilenamebis = $mysoc->logo_squarred;
|
||||||
if ($action == 'removelogosquarred')
|
if ($action == 'removelogosquarred') {
|
||||||
{
|
|
||||||
$logofilename = $mysoc->logo_squarred;
|
$logofilename = $mysoc->logo_squarred;
|
||||||
$logofilenamebis = $mysoc->logo;
|
$logofilenamebis = $mysoc->logo;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
|
$logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
|
||||||
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logofile);
|
if ($logofilename != '' && $logofilename != $logofilenamebis) {
|
||||||
|
dol_delete_file($logofile);
|
||||||
|
}
|
||||||
dolibarr_del_const($db, $constant, $conf->entity);
|
dolibarr_del_const($db, $constant, $conf->entity);
|
||||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred = '';
|
if ($action == 'removelogosquarred') {
|
||||||
else $mysoc->logo = '';
|
$mysoc->logo_squarred = '';
|
||||||
|
} else {
|
||||||
|
$mysoc->logo = '';
|
||||||
|
}
|
||||||
|
|
||||||
$logofilename = $mysoc->logo_small;
|
$logofilename = $mysoc->logo_small;
|
||||||
$logofilenamebis = $mysoc->logo_squarred_small;
|
$logofilenamebis = $mysoc->logo_squarred_small;
|
||||||
if ($action == 'removelogosquarred')
|
if ($action == 'removelogosquarred') {
|
||||||
{
|
|
||||||
$logofilename = $mysoc->logo_squarred_small;
|
$logofilename = $mysoc->logo_squarred_small;
|
||||||
$logofilenamebis = $mysoc->logo_small;
|
$logofilenamebis = $mysoc->logo_small;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
$logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
||||||
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logosmallfile);
|
if ($logofilename != '' && $logofilename != $logofilenamebis) {
|
||||||
|
dol_delete_file($logosmallfile);
|
||||||
|
}
|
||||||
dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
|
dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
|
||||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred_small = '';
|
if ($action == 'removelogosquarred') {
|
||||||
else $mysoc->logo_small = '';
|
$mysoc->logo_squarred_small = '';
|
||||||
|
} else {
|
||||||
|
$mysoc->logo_small = '';
|
||||||
|
}
|
||||||
|
|
||||||
$logofilename = $mysoc->logo_mini;
|
$logofilename = $mysoc->logo_mini;
|
||||||
$logofilenamebis = $mysoc->logo_squarred_mini;
|
$logofilenamebis = $mysoc->logo_squarred_mini;
|
||||||
if ($action == 'removelogosquarred')
|
if ($action == 'removelogosquarred') {
|
||||||
{
|
|
||||||
$logofilename = $mysoc->logo_squarred_mini;
|
$logofilename = $mysoc->logo_squarred_mini;
|
||||||
$logofilenamebis = $mysoc->logo_mini;
|
$logofilenamebis = $mysoc->logo_mini;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
$logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
||||||
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logominifile);
|
if ($logofilename != '' && $logofilename != $logofilenamebis) {
|
||||||
|
dol_delete_file($logominifile);
|
||||||
|
}
|
||||||
dolibarr_del_const($db, $constant."_MINI", $conf->entity);
|
dolibarr_del_const($db, $constant."_MINI", $conf->entity);
|
||||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini = '';
|
if ($action == 'removelogosquarred') {
|
||||||
else $mysoc->logo_mini = '';
|
$mysoc->logo_squarred_mini = '';
|
||||||
|
} else {
|
||||||
|
$mysoc->logo_mini = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,13 +419,14 @@ print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth200" id="MAIN_INFO_SO
|
|||||||
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
|
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
|
||||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
||||||
print $form->select_country($mysoc->country_id, 'country_id');
|
print $form->select_country($mysoc->country_id, 'country_id');
|
||||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
if ($user->admin) {
|
||||||
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
|
}
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
|
|
||||||
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
|
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
|
||||||
$state_id = 0;
|
$state_id = 0;
|
||||||
if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE))
|
if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) {
|
||||||
{
|
|
||||||
$tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
|
$tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
|
||||||
$state_id = $tmp[0];
|
$state_id = $tmp[0];
|
||||||
}
|
}
|
||||||
@ -473,13 +482,13 @@ if (!empty($mysoc->logo_small)) {
|
|||||||
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
|
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
} elseif (!empty($mysoc->logo)) {
|
} elseif (!empty($mysoc->logo)) {
|
||||||
if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
|
if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
|
||||||
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||||
}
|
}
|
||||||
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_small', $quality);
|
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_small', $quality);
|
||||||
print '<div class="inline-block valignmiddle">';
|
print '<div class="inline-block valignmiddle">';
|
||||||
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
|
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
|
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
|
||||||
} elseif (!empty($mysoc->logo)) {
|
} elseif (!empty($mysoc->logo)) {
|
||||||
@ -508,13 +517,13 @@ if (!empty($mysoc->logo_squarred_small)) {
|
|||||||
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_small).'">';
|
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_small).'">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
} elseif (!empty($mysoc->logo_squarred)) {
|
} elseif (!empty($mysoc->logo_squarred)) {
|
||||||
if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
|
if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
|
||||||
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||||
}
|
}
|
||||||
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_small', $quality);
|
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_small', $quality);
|
||||||
print '<div class="inline-block valignmiddle">';
|
print '<div class="inline-block valignmiddle">';
|
||||||
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
|
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
|
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
|
||||||
} elseif (!empty($mysoc->logo_squarred)) {
|
} elseif (!empty($mysoc->logo_squarred)) {
|
||||||
@ -523,8 +532,7 @@ if (!empty($mysoc->logo_squarred_small)) {
|
|||||||
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo_squarred).'">';
|
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo_squarred).'">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
|
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
print '<div class="inline-block valignmiddle">';
|
print '<div class="inline-block valignmiddle">';
|
||||||
print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
|
print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -572,11 +580,9 @@ if ($mysoc->country_code) {
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// ProfId1
|
// ProfId1
|
||||||
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
|
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
|
||||||
if (!empty($mysoc->country_code))
|
if (!empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">';
|
print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">';
|
||||||
} else {
|
} else {
|
||||||
print $countrynotdefined;
|
print $countrynotdefined;
|
||||||
@ -585,11 +591,9 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProfId2
|
// ProfId2
|
||||||
if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
|
if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
|
||||||
if (!empty($mysoc->country_code))
|
if (!empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">';
|
print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">';
|
||||||
} else {
|
} else {
|
||||||
print $countrynotdefined;
|
print $countrynotdefined;
|
||||||
@ -598,11 +602,9 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProfId3
|
// ProfId3
|
||||||
if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
|
if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
|
||||||
if (!empty($mysoc->country_code))
|
if (!empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">';
|
print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">';
|
||||||
} else {
|
} else {
|
||||||
print $countrynotdefined;
|
print $countrynotdefined;
|
||||||
@ -611,11 +613,9 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProfId4
|
// ProfId4
|
||||||
if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
|
if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
|
||||||
if (!empty($mysoc->country_code))
|
if (!empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">';
|
print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">';
|
||||||
} else {
|
} else {
|
||||||
print $countrynotdefined;
|
print $countrynotdefined;
|
||||||
@ -624,11 +624,9 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProfId5
|
// ProfId5
|
||||||
if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
|
if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
|
||||||
if (!empty($mysoc->country_code))
|
if (!empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">';
|
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">';
|
||||||
} else {
|
} else {
|
||||||
print $countrynotdefined;
|
print $countrynotdefined;
|
||||||
@ -637,11 +635,9 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProfId6
|
// ProfId6
|
||||||
if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-')
|
if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
|
||||||
if (!empty($mysoc->country_code))
|
if (!empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">';
|
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">';
|
||||||
} else {
|
} else {
|
||||||
print $countrynotdefined;
|
print $countrynotdefined;
|
||||||
@ -689,7 +685,9 @@ print "</tr>\n";
|
|||||||
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
|
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
$tooltiphelp = '';
|
$tooltiphelp = '';
|
||||||
if ($mysoc->country_code == 'FR') $tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
|
if ($mysoc->country_code == 'FR') {
|
||||||
|
$tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
|
||||||
|
}
|
||||||
print "<label for=\"use_vat\">".$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>";
|
print "<label for=\"use_vat\">".$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>";
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
@ -697,7 +695,9 @@ print "</td></tr>\n";
|
|||||||
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="no_vat" value="0"'.(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
|
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="no_vat" value="0"'.(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
$tooltiphelp = '';
|
$tooltiphelp = '';
|
||||||
if ($mysoc->country_code == 'FR') $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
|
if ($mysoc->country_code == 'FR') {
|
||||||
|
$tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
|
||||||
|
}
|
||||||
print "<label for=\"no_vat\">".$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
|
print "<label for=\"no_vat\">".$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
@ -711,8 +711,7 @@ print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax1Man
|
|||||||
print '<td class="right"> </td>';
|
print '<td class="right"> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if ($mysoc->useLocalTax(1))
|
if ($mysoc->useLocalTax(1)) {
|
||||||
{
|
|
||||||
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
||||||
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="lt1" value="localtax1on"'.(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
|
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="lt1" value="localtax1on"'.(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
@ -720,8 +719,7 @@ if ($mysoc->useLocalTax(1))
|
|||||||
$tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
|
$tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
|
||||||
$tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
|
$tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
|
||||||
print '<label for="lt1">'.$form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
|
print '<label for="lt1">'.$form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
|
||||||
if (!isOnlyOneLocalTax(1))
|
if (!isOnlyOneLocalTax(1)) {
|
||||||
{
|
|
||||||
print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
|
print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
|
||||||
$formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
|
$formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
|
||||||
}
|
}
|
||||||
@ -740,8 +738,7 @@ if ($mysoc->useLocalTax(1))
|
|||||||
print "<label for=\"nolt1\">".$form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
|
print "<label for=\"nolt1\">".$form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
} else {
|
} else {
|
||||||
if (empty($mysoc->country_code))
|
if (empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
|
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
|
||||||
} else {
|
} else {
|
||||||
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</td></tr>';
|
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</td></tr>';
|
||||||
@ -758,8 +755,7 @@ print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax2Man
|
|||||||
print '<td class="right"> </td>';
|
print '<td class="right"> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if ($mysoc->useLocalTax(2))
|
if ($mysoc->useLocalTax(2)) {
|
||||||
{
|
|
||||||
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
||||||
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="lt2" value="localtax2on"'.(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
|
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="lt2" value="localtax2on"'.(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
@ -767,8 +763,7 @@ if ($mysoc->useLocalTax(2))
|
|||||||
print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
|
print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
|
||||||
$tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
|
$tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
|
||||||
$tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
|
$tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
|
||||||
if (!isOnlyOneLocalTax(2))
|
if (!isOnlyOneLocalTax(2)) {
|
||||||
{
|
|
||||||
print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
|
print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
|
||||||
$formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
|
$formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
|
||||||
}
|
}
|
||||||
@ -786,8 +781,7 @@ if ($mysoc->useLocalTax(2))
|
|||||||
print "</div>";
|
print "</div>";
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
} else {
|
} else {
|
||||||
if (empty($mysoc->country_code))
|
if (empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
|
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
|
||||||
} else {
|
} else {
|
||||||
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</td></tr>';
|
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</td></tr>';
|
||||||
@ -804,8 +798,7 @@ print '<tr class="liste_titre">';
|
|||||||
print '<td width="25%">'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>';
|
print '<td width="25%">'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>';
|
||||||
print '<td class="right"> </td>';
|
print '<td class="right"> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
if ($mysoc->useRevenueStamp())
|
if ($mysoc->useRevenueStamp()) {
|
||||||
{
|
|
||||||
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $langs->trans("UseRevenueStamp");
|
print $langs->trans("UseRevenueStamp");
|
||||||
@ -814,8 +807,7 @@ if ($mysoc->useRevenueStamp())
|
|||||||
print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
|
print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
} else {
|
} else {
|
||||||
if (empty($mysoc->country_code))
|
if (empty($mysoc->country_code)) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
|
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
|
||||||
} else {
|
} else {
|
||||||
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</td></tr>';
|
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</td></tr>';
|
||||||
|
|||||||
@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'compta', 'accountancy'));
|
$langs->loadLangs(array('admin', 'compta', 'accountancy'));
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
|
||||||
@ -56,8 +57,7 @@ $list = array(
|
|||||||
|
|
||||||
$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
|
$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
|
||||||
|
|
||||||
if ($action == 'update')
|
if ($action == 'update') {
|
||||||
{
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$accounting_modes = array(
|
$accounting_modes = array(
|
||||||
@ -85,21 +85,34 @@ if ($action == 'update')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
|
$report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
|
||||||
if (!empty($report_include_varpay))
|
if (!empty($report_include_varpay)) {
|
||||||
if ($report_include_varpay == 'yes')
|
if ($report_include_varpay == 'yes') {
|
||||||
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++;
|
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
|
||||||
if ($report_include_varpay == 'no')
|
$error++;
|
||||||
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($report_include_varpay == 'no') {
|
||||||
|
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
|
$report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
|
||||||
if (!empty($report_include_loan))
|
if (!empty($report_include_loan)) {
|
||||||
if ($report_include_loan == 'yes')
|
if ($report_include_loan == 'yes') {
|
||||||
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++;
|
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
|
||||||
if ($report_include_loan == 'no')
|
$error++;
|
||||||
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($report_include_loan == 'no') {
|
||||||
|
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -157,8 +170,7 @@ print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|
||||||
foreach ($list as $key)
|
foreach ($list as $key) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven value">';
|
print '<tr class="oddeven value">';
|
||||||
|
|
||||||
// Param
|
// Param
|
||||||
|
|||||||
@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'sendings', 'deliveries'));
|
$langs->loadLangs(array('admin', 'sendings', 'deliveries'));
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
|
||||||
@ -43,35 +44,32 @@ $action = GETPOST('action', 'aZ09');
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Shipment note
|
// Shipment note
|
||||||
if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
|
if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) {
|
||||||
{
|
|
||||||
// This option should always be set to on when module is on.
|
// This option should always be set to on when module is on.
|
||||||
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if ($action == 'activate_sending')
|
if ($action == 'activate_sending')
|
||||||
{
|
{
|
||||||
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity);
|
||||||
header("Location: confexped.php");
|
header("Location: confexped.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if ($action == 'disable_sending')
|
if ($action == 'disable_sending')
|
||||||
{
|
{
|
||||||
dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity);
|
dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity);
|
||||||
header("Location: confexped.php");
|
header("Location: confexped.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Delivery note
|
// Delivery note
|
||||||
if ($action == 'activate_delivery')
|
if ($action == 'activate_delivery') {
|
||||||
{
|
|
||||||
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this
|
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this
|
||||||
dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity);
|
||||||
header("Location: confexped.php");
|
header("Location: confexped.php");
|
||||||
exit;
|
exit;
|
||||||
} elseif ($action == 'disable_delivery')
|
} elseif ($action == 'disable_delivery') {
|
||||||
{
|
|
||||||
dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity);
|
dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity);
|
||||||
header("Location: confexped.php");
|
header("Location: confexped.php");
|
||||||
exit;
|
exit;
|
||||||
@ -131,8 +129,7 @@ print '<td>';
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_SUBMODULE_DELIVERY))
|
if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) {
|
||||||
{
|
|
||||||
print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
|
print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
|
||||||
|
|||||||
@ -30,8 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$rowid = GETPOST('rowid', 'int');
|
$rowid = GETPOST('rowid', 'int');
|
||||||
$entity = GETPOST('entity', 'int');
|
$entity = GETPOST('entity', 'int');
|
||||||
@ -49,37 +50,38 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (empty($sortfield)) $sortfield = 'entity,name';
|
if (empty($sortfield)) {
|
||||||
if (empty($sortorder)) $sortorder = 'ASC';
|
$sortfield = 'entity,name';
|
||||||
|
}
|
||||||
|
if (empty($sortorder)) {
|
||||||
|
$sortorder = 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'add' || (GETPOST('add') && $action != 'update'))
|
if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
|
||||||
{
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if (empty($constname))
|
if (empty($constname)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if ($constvalue == '')
|
if ($constvalue == '') {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Value")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Value")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0) {
|
||||||
if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||||
$action = "";
|
$action = "";
|
||||||
$constname = "";
|
$constname = "";
|
||||||
@ -92,50 +94,44 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mass update
|
// Mass update
|
||||||
if (!empty($consts) && $action == 'update')
|
if (!empty($consts) && $action == 'update') {
|
||||||
{
|
|
||||||
$nbmodified = 0;
|
$nbmodified = 0;
|
||||||
foreach ($consts as $const)
|
foreach ($consts as $const) {
|
||||||
{
|
if (!empty($const["check"])) {
|
||||||
if (!empty($const["check"]))
|
if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0) {
|
||||||
{
|
|
||||||
if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0)
|
|
||||||
{
|
|
||||||
$nbmodified++;
|
$nbmodified++;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($nbmodified > 0) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
if ($nbmodified > 0) {
|
||||||
|
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||||
|
}
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mass delete
|
// Mass delete
|
||||||
if (!empty($consts) && $action == 'delete')
|
if (!empty($consts) && $action == 'delete') {
|
||||||
{
|
|
||||||
$nbdeleted = 0;
|
$nbdeleted = 0;
|
||||||
foreach ($consts as $const)
|
foreach ($consts as $const) {
|
||||||
{
|
if (!empty($const["check"])) { // Is checkbox checked
|
||||||
if (!empty($const["check"])) // Is checkbox checked
|
if (dolibarr_del_const($db, $const["rowid"], -1) >= 0) {
|
||||||
{
|
|
||||||
if (dolibarr_del_const($db, $const["rowid"], -1) >= 0)
|
|
||||||
{
|
|
||||||
$nbdeleted++;
|
$nbdeleted++;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($nbdeleted > 0) setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
if ($nbdeleted > 0) {
|
||||||
|
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||||
|
}
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete line from delete picto
|
// Delete line from delete picto
|
||||||
if ($action == 'delete')
|
if ($action == 'delete') {
|
||||||
{
|
if (dolibarr_del_const($db, $rowid, $entity) >= 0) {
|
||||||
if (dolibarr_del_const($db, $rowid, $entity) >= 0)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
@ -153,8 +149,7 @@ $wikihelp = 'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
|
|||||||
llxHeader('', $langs->trans("Setup"), $wikihelp);
|
llxHeader('', $langs->trans("Setup"), $wikihelp);
|
||||||
|
|
||||||
// Add logic to show/hide buttons
|
// Add logic to show/hide buttons
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
@ -173,7 +168,7 @@ jQuery(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("OtherSetup"), '', 'title_setup');
|
print load_fiche_titre($langs->trans("OtherSetup"), '', 'title_setup');
|
||||||
@ -196,8 +191,7 @@ print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '
|
|||||||
print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||||
print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||||
print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
|
print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
|
||||||
if (!empty($conf->multicompany->enabled) && !$user->entity)
|
if (!empty($conf->multicompany->enabled) && !$user->entity) {
|
||||||
{
|
|
||||||
print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
|
print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
|
||||||
}
|
}
|
||||||
print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
|
print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||||
@ -219,8 +213,7 @@ print '</td>';
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// Limit to superadmin
|
// Limit to superadmin
|
||||||
if (!empty($conf->multicompany->enabled) && !$user->entity)
|
if (!empty($conf->multicompany->enabled) && !$user->entity) {
|
||||||
{
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
|
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -245,20 +238,23 @@ $sql .= ", tms";
|
|||||||
$sql .= ", entity";
|
$sql .= ", entity";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."const";
|
$sql .= " FROM ".MAIN_DB_PREFIX."const";
|
||||||
$sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
|
$sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
|
||||||
if ((empty($user->entity) || $user->admin) && $debug) {} // to force for superadmin to debug
|
if ((empty($user->entity) || $user->admin) && $debug) {
|
||||||
elseif (!GETPOST('visible') || GETPOST('visible') != 'all') $sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits
|
} elseif (!GETPOST('visible') || GETPOST('visible') != 'all') {
|
||||||
if (GETPOST('name')) $sql .= natural_search("name", GETPOST('name'));
|
// to force for superadmin to debug
|
||||||
|
$sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits
|
||||||
|
}
|
||||||
|
if (GETPOST('name')) {
|
||||||
|
$sql .= natural_search("name", GETPOST('name'));
|
||||||
|
}
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
dol_syslog("Const::listConstant", LOG_DEBUG);
|
dol_syslog("Const::listConstant", LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
@ -284,8 +280,7 @@ if ($result)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Entity limit to superadmin
|
// Entity limit to superadmin
|
||||||
if (!empty($conf->multicompany->enabled) && !$user->entity)
|
if (!empty($conf->multicompany->enabled) && !$user->entity) {
|
||||||
{
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
|
print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -295,8 +290,7 @@ if ($result)
|
|||||||
print '<input type="hidden" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
|
print '<input type="hidden" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax) {
|
||||||
{
|
|
||||||
print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
|
print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
|
||||||
@ -313,8 +307,7 @@ if ($result)
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax) {
|
||||||
{
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<div id="updateconst" class="right">';
|
print '<div id="updateconst" class="right">';
|
||||||
print '<input type="submit" name="update" class="button marginbottomonly" value="'.$langs->trans("Modify").'">';
|
print '<input type="submit" name="update" class="button marginbottomonly" value="'.$langs->trans("Modify").'">';
|
||||||
|
|||||||
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "errors", "contracts"));
|
$langs->loadLangs(array("admin", "errors", "contracts"));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$value = GETPOST('value', 'alpha');
|
$value = GETPOST('value', 'alpha');
|
||||||
@ -39,8 +41,7 @@ $label = GETPOST('label', 'alpha');
|
|||||||
$scandir = GETPOST('scan_dir', 'alpha');
|
$scandir = GETPOST('scan_dir', 'alpha');
|
||||||
$type = 'contract';
|
$type = 'contract';
|
||||||
|
|
||||||
if (empty($conf->global->CONTRACT_ADDON))
|
if (empty($conf->global->CONTRACT_ADDON)) {
|
||||||
{
|
|
||||||
$conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
|
$conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,22 +52,23 @@ if (empty($conf->global->CONTRACT_ADDON))
|
|||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||||
|
|
||||||
if ($action == 'updateMask')
|
if ($action == 'updateMask') {
|
||||||
{
|
|
||||||
$maskconst = GETPOST('maskconstcontract', 'alpha');
|
$maskconst = GETPOST('maskconstcontract', 'alpha');
|
||||||
$maskvalue = GETPOST('maskcontract', 'alpha');
|
$maskvalue = GETPOST('maskcontract', 'alpha');
|
||||||
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
|
if ($maskconst) {
|
||||||
|
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'specimen') // For contract
|
} elseif ($action == 'specimen') { // For contract
|
||||||
{
|
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
|
|
||||||
$contract = new Contrat($db);
|
$contract = new Contrat($db);
|
||||||
@ -75,25 +77,21 @@ if ($action == 'updateMask')
|
|||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0;
|
$file = ''; $classname = ''; $filefound = 0;
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
|
$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file)) {
|
||||||
{
|
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound) {
|
||||||
{
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($contract, $langs) > 0)
|
if ($module->write_file($contract, $langs) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -104,26 +102,19 @@ if ($action == 'updateMask')
|
|||||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'set') {
|
||||||
|
// Activate a model
|
||||||
// Activate a model
|
|
||||||
elseif ($action == 'set')
|
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
} elseif ($action == 'del')
|
} elseif ($action == 'del') {
|
||||||
{
|
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
if ($conf->global->CONTRACT_ADDON_PDF == "$value") {
|
||||||
if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
|
dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setdoc') {
|
||||||
|
// Set default model
|
||||||
// Set default model
|
if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
elseif ($action == 'setdoc')
|
|
||||||
{
|
|
||||||
if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
|
|
||||||
{
|
|
||||||
// La constante qui a ete lue en avant du nouveau set
|
// La constante qui a ete lue en avant du nouveau set
|
||||||
// on passe donc par une variable pour avoir un affichage coherent
|
// on passe donc par une variable pour avoir un affichage coherent
|
||||||
$conf->global->CONTRACT_ADDON_PDF = $value;
|
$conf->global->CONTRACT_ADDON_PDF = $value;
|
||||||
@ -131,18 +122,15 @@ elseif ($action == 'setdoc')
|
|||||||
|
|
||||||
// On active le modele
|
// On active le modele
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'setmod')
|
} elseif ($action == 'setmod') {
|
||||||
{
|
|
||||||
// TODO Verifier si module numerotation choisi peut etre active
|
// TODO Verifier si module numerotation choisi peut etre active
|
||||||
// par appel methode canBeActivated
|
// par appel methode canBeActivated
|
||||||
|
|
||||||
dolibarr_set_const($db, "CONTRACT_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "CONTRACT_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
||||||
} elseif ($action == 'set_other')
|
} elseif ($action == 'set_other') {
|
||||||
{
|
|
||||||
$freetext = GETPOST('CONTRACT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
|
$freetext = GETPOST('CONTRACT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
|
||||||
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
@ -152,10 +140,11 @@ elseif ($action == 'setdoc')
|
|||||||
$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
|
$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
|
||||||
$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
|
$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++;
|
if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -197,19 +186,14 @@ print "</tr>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir."core/modules/contract/");
|
$dir = dol_buildpath($reldir."core/modules/contract/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
|
||||||
{
|
|
||||||
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
|
||||||
{
|
|
||||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||||
|
|
||||||
require_once $dir.$file.'.php';
|
require_once $dir.$file.'.php';
|
||||||
@ -217,11 +201,14 @@ foreach ($dirmodels as $reldir)
|
|||||||
$module = new $file($db);
|
$module = new $file($db);
|
||||||
|
|
||||||
// Show modules according to features level
|
// Show modules according to features level
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled()) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
|
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
|
||||||
print $module->info();
|
print $module->info();
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -232,14 +219,15 @@ foreach ($dirmodels as $reldir)
|
|||||||
if (preg_match('/^Error/', $tmp)) {
|
if (preg_match('/^Error/', $tmp)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||||
|
} elseif ($tmp == 'NotConfigured') {
|
||||||
|
print $langs->trans($tmp);
|
||||||
|
} else {
|
||||||
|
print $tmp;
|
||||||
}
|
}
|
||||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
|
||||||
else print $tmp;
|
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
|
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->CONTRACT_ADDON == "$file")
|
if ($conf->global->CONTRACT_ADDON == "$file") {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
|
||||||
@ -258,8 +246,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||||
if ($nextval) {
|
if ($nextval) {
|
||||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
|
||||||
$nextval = $langs->trans($nextval);
|
$nextval = $langs->trans($nextval);
|
||||||
|
}
|
||||||
$htmltooltip .= $nextval.'<br>';
|
$htmltooltip .= $nextval.'<br>';
|
||||||
} else {
|
} else {
|
||||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||||
@ -294,12 +283,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
|||||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num_rows = $db->num_rows($resql);
|
$num_rows = $db->num_rows($resql);
|
||||||
while ($i < $num_rows)
|
while ($i < $num_rows) {
|
||||||
{
|
|
||||||
$array = $db->fetch_array($resql);
|
$array = $db->fetch_array($resql);
|
||||||
array_push($def, $array[0]);
|
array_push($def, $array[0]);
|
||||||
$i++;
|
$i++;
|
||||||
@ -321,31 +308,23 @@ print "</tr>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
foreach (array('', '/doc') as $valdir) {
|
||||||
foreach (array('', '/doc') as $valdir)
|
|
||||||
{
|
|
||||||
$realpath = $reldir."core/modules/contract".$valdir;
|
$realpath = $reldir."core/modules/contract".$valdir;
|
||||||
$dir = dol_buildpath($realpath);
|
$dir = dol_buildpath($realpath);
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
|
||||||
{
|
|
||||||
$filelist[] = $file;
|
$filelist[] = $file;
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
arsort($filelist);
|
arsort($filelist);
|
||||||
|
|
||||||
foreach ($filelist as $file)
|
foreach ($filelist as $file) {
|
||||||
{
|
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
if (file_exists($dir.'/'.$file)) {
|
||||||
{
|
|
||||||
if (file_exists($dir.'/'.$file))
|
|
||||||
{
|
|
||||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
@ -353,21 +332,26 @@ foreach ($dirmodels as $reldir)
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
$modulequalified = 1;
|
$modulequalified = 1;
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($modulequalified)
|
if ($modulequalified) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td width="100">';
|
print '<tr class="oddeven"><td width="100">';
|
||||||
print (empty($module->name) ? $name : $module->name);
|
print (empty($module->name) ? $name : $module->name);
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
if (method_exists($module, 'info')) print $module->info($langs);
|
if (method_exists($module, 'info')) {
|
||||||
else print $module->description;
|
print $module->info($langs);
|
||||||
|
} else {
|
||||||
|
print $module->description;
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
if (in_array($name, $def))
|
if (in_array($name, $def)) {
|
||||||
{
|
|
||||||
print '<td class="center">'."\n";
|
print '<td class="center">'."\n";
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
|
||||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||||
@ -381,8 +365,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Defaut
|
// Defaut
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->CONTRACT_ADDON_PDF == $name)
|
if ($conf->global->CONTRACT_ADDON_PDF == $name) {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Default"), 'on');
|
print img_picto($langs->trans("Default"), 'on');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
@ -392,8 +375,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
// Info
|
// Info
|
||||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||||
}
|
}
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
||||||
@ -412,8 +394,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Preview
|
// Preview
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||||
@ -452,15 +433,16 @@ print "</tr>\n";
|
|||||||
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
|
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
|
||||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
foreach ($substitutionarray as $key => $val) {
|
||||||
|
$htmltext .= $key.'<br>';
|
||||||
|
}
|
||||||
$htmltext .= '</i>';
|
$htmltext .= '</i>';
|
||||||
|
|
||||||
print '<tr class="oddeven"><td colspan="2">';
|
print '<tr class="oddeven"><td colspan="2">';
|
||||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
|
print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
|
||||||
print '<br>';
|
print '<br>';
|
||||||
$variablename = 'CONTRACT_FREE_TEXT';
|
$variablename = 'CONTRACT_FREE_TEXT';
|
||||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
|
||||||
{
|
|
||||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||||
} else {
|
} else {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
|
|||||||
@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "other", "agenda"));
|
$langs->loadLangs(array("admin", "other", "agenda"));
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
@ -71,8 +72,7 @@ $head = dav_admin_prepare_head();
|
|||||||
|
|
||||||
print dol_get_fiche_head($head, 'webdav', '', -1, 'action');
|
print dol_get_fiche_head($head, 'webdav', '', -1, 'action');
|
||||||
|
|
||||||
if ($action == 'edit')
|
if ($action == 'edit') {
|
||||||
{
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
@ -80,9 +80,10 @@ if ($action == 'edit')
|
|||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||||
|
|
||||||
foreach ($arrayofparameters as $key => $val)
|
foreach ($arrayofparameters as $key => $val) {
|
||||||
{
|
if (isset($val['enabled']) && empty($val['enabled'])) {
|
||||||
if (isset($val['enabled']) && empty($val['enabled'])) continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
|
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
|
||||||
@ -93,11 +94,9 @@ if ($action == 'edit')
|
|||||||
}
|
}
|
||||||
print $form->textwithpicto($label, $tooltiphelp);
|
print $form->textwithpicto($label, $tooltiphelp);
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
if ($key == 'DAV_ALLOW_PRIVATE_DIR')
|
if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
|
||||||
{
|
|
||||||
print $langs->trans("AlwaysActive");
|
print $langs->trans("AlwaysActive");
|
||||||
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR')
|
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
|
||||||
{
|
|
||||||
print $form->selectyesno($key, $conf->global->$key, 1);
|
print $form->selectyesno($key, $conf->global->$key, 1);
|
||||||
} else {
|
} else {
|
||||||
print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">';
|
print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">';
|
||||||
@ -117,8 +116,7 @@ if ($action == 'edit')
|
|||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||||
|
|
||||||
foreach ($arrayofparameters as $key => $val)
|
foreach ($arrayofparameters as $key => $val) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
|
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
|
||||||
$label = $langs->trans($key);
|
$label = $langs->trans($key);
|
||||||
@ -128,11 +126,9 @@ if ($action == 'edit')
|
|||||||
}
|
}
|
||||||
print $form->textwithpicto($label, $tooltiphelp);
|
print $form->textwithpicto($label, $tooltiphelp);
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
if ($key == 'DAV_ALLOW_PRIVATE_DIR')
|
if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
|
||||||
{
|
|
||||||
print $langs->trans("AlwaysActive");
|
print $langs->trans("AlwaysActive");
|
||||||
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR')
|
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
|
||||||
{
|
|
||||||
print yn($conf->global->$key);
|
print yn($conf->global->$key);
|
||||||
} else {
|
} else {
|
||||||
print $conf->global->$key;
|
print $conf->global->$key;
|
||||||
@ -174,8 +170,7 @@ $message = '';
|
|||||||
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
|
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
|
||||||
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}'));
|
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}'));
|
||||||
$message .= '<br>';
|
$message .= '<br>';
|
||||||
if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
|
if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) {
|
||||||
{
|
|
||||||
$urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
|
$urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
|
||||||
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
|
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
|
||||||
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}'));
|
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}'));
|
||||||
|
|||||||
@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
|
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "other"));
|
$langs->loadLangs(array("admin", "other"));
|
||||||
@ -43,19 +45,16 @@ $action = GETPOST('action', 'aZ09');
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Set modes
|
// Set modes
|
||||||
if ($action == 'set')
|
if ($action == 'set') {
|
||||||
{
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0);
|
$result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0);
|
||||||
$result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0);
|
$result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0);
|
||||||
if ($result1 < 0 || $result2 < 0)
|
if ($result1 < 0 || $result2 < 0) {
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
@ -76,8 +75,7 @@ $form = new Form($db);
|
|||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup');
|
print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup');
|
||||||
|
|
||||||
if (!function_exists('mb_check_encoding'))
|
if (!function_exists('mb_check_encoding')) {
|
||||||
{
|
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error');
|
print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,28 +30,37 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php';
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors'));
|
$langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors'));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$id = GETPOST('rowid', 'int');
|
$id = GETPOST('rowid', 'int');
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$optioncss = GETPOST('optionscss', 'alphanohtml');
|
$optioncss = GETPOST('optionscss', 'alphanohtml');
|
||||||
|
|
||||||
$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus'
|
$mode = GETPOST('mode', 'aZ09') ? GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus'
|
||||||
|
|
||||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortfield) $sortfield = 'page,param';
|
if (!$sortfield) {
|
||||||
if (!$sortorder) $sortorder = 'ASC';
|
$sortfield = 'page,param';
|
||||||
|
}
|
||||||
|
if (!$sortorder) {
|
||||||
|
$sortorder = 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
$defaulturl = GETPOST('defaulturl', 'alphanohtml');
|
$defaulturl = GETPOST('defaulturl', 'alphanohtml');
|
||||||
$defaultkey = GETPOST('defaultkey', 'alphanohtml');
|
$defaultkey = GETPOST('defaultkey', 'alphanohtml');
|
||||||
@ -67,22 +76,28 @@ $value = GETPOST('value', 'restricthtml');
|
|||||||
$hookmanager->initHooks(array('admindefaultvalues', 'globaladmin'));
|
$hookmanager->initHooks(array('admindefaultvalues', 'globaladmin'));
|
||||||
|
|
||||||
|
|
||||||
|
$object = new DefaultValues($db);
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
if (GETPOST('cancel', 'alpha')) {
|
||||||
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
$action = 'list'; $massaction = '';
|
||||||
|
}
|
||||||
|
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||||
|
$massaction = '';
|
||||||
|
}
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||||
|
|
||||||
// Purge search criteria
|
// Purge search criteria
|
||||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||||
{
|
|
||||||
$defaulturl = '';
|
$defaulturl = '';
|
||||||
$defaultkey = '';
|
$defaultkey = '';
|
||||||
$defaultvalue = '';
|
$defaultvalue = '';
|
||||||
@ -90,85 +105,87 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
|||||||
$search_array_options = array();
|
$search_array_options = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
|
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') {
|
||||||
{
|
if (GETPOST('value')) {
|
||||||
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
|
||||||
else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
|
} else {
|
||||||
|
dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify'))
|
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) {
|
||||||
{
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if (($action == 'add' || (GETPOST('add') && $action != 'update')))
|
if (($action == 'add' || (GETPOST('add') && $action != 'update'))) {
|
||||||
{
|
if (empty($defaulturl)) {
|
||||||
if (empty($defaulturl))
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if (empty($defaultkey))
|
if (empty($defaultkey)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GETPOST('actionmodify'))
|
if (GETPOST('actionmodify')) {
|
||||||
{
|
if (empty($urlpage)) {
|
||||||
if (empty($urlpage))
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if (empty($key))
|
if (empty($key)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
|
||||||
$db->begin();
|
$object->type=$mode;
|
||||||
|
$object->user_id=0;
|
||||||
if ($action == 'add' || (GETPOST('add') && $action != 'update'))
|
$object->page=$defaulturl;
|
||||||
{
|
$object->param=$defaultkey;
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
|
$object->value=$defaultvalue;
|
||||||
|
$object->entity=$conf->entity;
|
||||||
|
$result=$object->create($user);
|
||||||
|
if ($result<0) {
|
||||||
|
$action = '';
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||||
|
$action = "";
|
||||||
|
$defaulturl = '';
|
||||||
|
$defaultkey = '';
|
||||||
|
$defaultvalue = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (GETPOST('actionmodify'))
|
if (GETPOST('actionmodify')) {
|
||||||
{
|
$object->id=$id;
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
|
$object->type=$mode;
|
||||||
$sql .= " WHERE rowid = ".$id;
|
$object->page=$urlpage;
|
||||||
}
|
$object->param=$key;
|
||||||
|
$object->value=$value;
|
||||||
$result = $db->query($sql);
|
$object->entity=$conf->entity;
|
||||||
if ($result > 0)
|
$result=$object->update($user);
|
||||||
{
|
if ($result<0) {
|
||||||
$db->commit();
|
$action = '';
|
||||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$action = "";
|
} else {
|
||||||
$defaulturl = '';
|
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||||
$defaultkey = '';
|
$action = "";
|
||||||
$defaultvalue = '';
|
$defaulturl = '';
|
||||||
} else {
|
$defaultkey = '';
|
||||||
$db->rollback();
|
$defaultvalue = '';
|
||||||
setEventMessages($db->lasterror(), null, 'errors');
|
}
|
||||||
$action = '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete line from delete picto
|
// Delete line from delete picto
|
||||||
if ($action == 'delete')
|
if ($action == 'delete') {
|
||||||
{
|
$object->id=$id;
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id);
|
$result=$object->delete($user);
|
||||||
// Delete const
|
if ($result<0) {
|
||||||
$result = $db->query($sql);
|
$action = '';
|
||||||
if ($result >= 0)
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,8 +204,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp);
|
|||||||
$param = '&mode='.$mode;
|
$param = '&mode='.$mode;
|
||||||
|
|
||||||
$enabledisablehtml = $langs->trans("EnableDefaultValues").' ';
|
$enabledisablehtml = $langs->trans("EnableDefaultValues").' ';
|
||||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
|
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
|
||||||
{
|
|
||||||
// Button off, click to enable
|
// Button off, click to enable
|
||||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.newToken().'&value=1'.$param.'">';
|
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.newToken().'&value=1'.$param.'">';
|
||||||
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
|
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
|
||||||
@ -205,16 +221,30 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl
|
|||||||
print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n";
|
print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n";
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
$param .= '&contextpage='.urlencode($contextpage);
|
||||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
}
|
||||||
if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl);
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey);
|
$param .= '&limit='.urlencode($limit);
|
||||||
if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue);
|
}
|
||||||
|
if ($optioncss != '') {
|
||||||
|
$param .= '&optioncss='.urlencode($optioncss);
|
||||||
|
}
|
||||||
|
if ($defaulturl) {
|
||||||
|
$param .= '&defaulturl='.urlencode($defaulturl);
|
||||||
|
}
|
||||||
|
if ($defaultkey) {
|
||||||
|
$param .= '&defaultkey='.urlencode($defaultkey);
|
||||||
|
}
|
||||||
|
if ($defaultvalue) {
|
||||||
|
$param .= '&defaultvalue='.urlencode($defaultvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">';
|
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') {
|
||||||
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
}
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
print '<input type="hidden" name="action" value="list">';
|
print '<input type="hidden" name="action" value="list">';
|
||||||
@ -226,12 +256,10 @@ $head = defaultvalues_prepare_head();
|
|||||||
|
|
||||||
print dol_get_fiche_head($head, $mode, '', -1, '');
|
print dol_get_fiche_head($head, $mode, '', -1, '');
|
||||||
|
|
||||||
if ($mode == 'sortorder')
|
if ($mode == 'sortorder') {
|
||||||
{
|
|
||||||
print info_admin($langs->trans("WarningSettingSortOrder")).'<br>';
|
print info_admin($langs->trans("WarningSettingSortOrder")).'<br>';
|
||||||
}
|
}
|
||||||
if ($mode == 'mandatory')
|
if ($mode == 'mandatory') {
|
||||||
{
|
|
||||||
print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'<br>';
|
print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,15 +272,17 @@ print '<table class="noborder centpercent">';
|
|||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
// Page
|
// Page
|
||||||
$texthelp = $langs->trans("PageUrlForDefaultValues");
|
$texthelp = $langs->trans("PageUrlForDefaultValues");
|
||||||
if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
|
if ($mode == 'createform') {
|
||||||
else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
|
$texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
|
||||||
|
} else {
|
||||||
|
$texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
|
||||||
|
}
|
||||||
$texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
|
$texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
|
||||||
$texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp);
|
$texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp);
|
||||||
print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
|
||||||
// Field
|
// Field
|
||||||
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
|
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
|
||||||
if ($mode != 'sortorder')
|
if ($mode != 'sortorder') {
|
||||||
{
|
|
||||||
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
|
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
|
||||||
} else {
|
} else {
|
||||||
$texthelp = 'field or alias.field';
|
$texthelp = 'field or alias.field';
|
||||||
@ -260,15 +290,12 @@ if ($mode != 'sortorder')
|
|||||||
}
|
}
|
||||||
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
|
||||||
// Value
|
// Value
|
||||||
if ($mode != 'focus' && $mode != 'mandatory')
|
if ($mode != 'focus' && $mode != 'mandatory') {
|
||||||
{
|
if ($mode != 'sortorder') {
|
||||||
if ($mode != 'sortorder')
|
|
||||||
{
|
|
||||||
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
|
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
|
||||||
unset($substitutionarray['__USER_SIGNATURE__']);
|
unset($substitutionarray['__USER_SIGNATURE__']);
|
||||||
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||||
foreach ($substitutionarray as $key => $val)
|
foreach ($substitutionarray as $key => $val) {
|
||||||
{
|
|
||||||
$texthelp .= $key.' -> '.$val.'<br>';
|
$texthelp .= $key.' -> '.$val.'<br>';
|
||||||
}
|
}
|
||||||
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
|
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
|
||||||
@ -279,8 +306,11 @@ if ($mode != 'focus' && $mode != 'mandatory')
|
|||||||
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
// Entity
|
// Entity
|
||||||
if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
|
if (!empty($conf->multicompany->enabled) && !$user->entity) {
|
||||||
else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
|
||||||
|
} else {
|
||||||
|
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||||
|
}
|
||||||
// Actions
|
// Actions
|
||||||
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
@ -299,15 +329,13 @@ print '<td>';
|
|||||||
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(GETPOST('defaultkey', 'alphanohtml')).'">';
|
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(GETPOST('defaultkey', 'alphanohtml')).'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// Value
|
// Value
|
||||||
if ($mode != 'focus' && $mode != 'mandatory')
|
if ($mode != 'focus' && $mode != 'mandatory') {
|
||||||
{
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
|
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
// Limit to superadmin
|
// Limit to superadmin
|
||||||
if (!empty($conf->multicompany->enabled) && !$user->entity)
|
if (!empty($conf->multicompany->enabled) && !$user->entity) {
|
||||||
{
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
|
print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -318,57 +346,45 @@ if (!empty($conf->multicompany->enabled) && !$user->entity)
|
|||||||
}
|
}
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
$disabled = '';
|
$disabled = '';
|
||||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"';
|
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
|
||||||
|
$disabled = ' disabled="disabled"';
|
||||||
|
}
|
||||||
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
|
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
$result=$object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity)));
|
||||||
|
|
||||||
// Show constants
|
if (!is_array($result) && $result<0) {
|
||||||
$sql = "SELECT rowid, entity, type, page, param, value";
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."default_values";
|
} elseif (count($result)>0) {
|
||||||
$sql .= " WHERE type = '".$db->escape($mode)."'";
|
foreach ($result as $key=>$defaultvalue) {
|
||||||
$sql .= " AND entity IN (".$user->entity.",".$conf->entity.")";
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
|
||||||
|
|
||||||
dol_syslog("translation::select from table", LOG_DEBUG);
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows($result);
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($result);
|
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
// Page
|
// Page
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page;
|
if ($action != 'edit' || GETPOST('rowid', 'int') != $defaultvalue->id) print $defaultvalue->page;
|
||||||
else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">';
|
else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($defaultvalue->page).'">';
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
|
|
||||||
// Field
|
// Field
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param;
|
if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print $defaultvalue->param;
|
||||||
else print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).'">';
|
else print '<input type="text" name="key" value="'.dol_escape_htmltag($defaultvalue->param).'">';
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
|
|
||||||
// Value
|
// Value
|
||||||
if ($mode != 'focus' && $mode != 'mandatory')
|
if ($mode != 'focus' && $mode != 'mandatory') {
|
||||||
{
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
|
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
|
||||||
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
|
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
|
||||||
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
|
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
|
||||||
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
|
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
|
||||||
*/
|
*/
|
||||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value);
|
if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print dol_escape_htmltag($defaultvalue->value);
|
||||||
else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
|
else print '<input type="text" name="value" value="'.dol_escape_htmltag($defaultvalue->value).'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,14 +392,13 @@ if ($result)
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
|
if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) {
|
||||||
{
|
print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$defaultvalue->id.'&entity='.$defaultvalue->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
|
||||||
print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
|
print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$defaultvalue->id.'&entity='.$defaultvalue->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
|
||||||
print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
|
|
||||||
} else {
|
} else {
|
||||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||||
print '<input type="hidden" name="rowid" value="'.$id.'">';
|
print '<input type="hidden" name="rowid" value="'.$id.'">';
|
||||||
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : 'none').'"></div>';
|
print '<div name="'.(!empty($defaultvalue->id) ? $defaultvalue->id : 'none').'"></div>';
|
||||||
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
||||||
print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
|
print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
|
||||||
}
|
}
|
||||||
@ -393,8 +408,6 @@ if ($result)
|
|||||||
print "\n";
|
print "\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
@ -30,134 +30,138 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
if (empty($action)) $action = 'edit';
|
if (empty($action)) {
|
||||||
|
$action = 'edit';
|
||||||
|
}
|
||||||
|
|
||||||
// Define list of managed delays
|
// Define list of managed delays
|
||||||
$modules = array(
|
$modules = array(
|
||||||
'agenda' => array(
|
'agenda' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_ACTIONS_TODO',
|
'code' => 'MAIN_DELAY_ACTIONS_TODO',
|
||||||
'img' => 'action'
|
'img' => 'action'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'projet' => array(
|
'projet' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
|
'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
|
||||||
'img' => 'project'
|
'img' => 'project'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_TASKS_TODO',
|
'code' => 'MAIN_DELAY_TASKS_TODO',
|
||||||
'img' => 'projecttask'
|
'img' => 'projecttask'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'propal' => array(
|
'propal' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
|
'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
|
||||||
'img' => 'propal'
|
'img' => 'propal'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
|
'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
|
||||||
'img' => 'propal'
|
'img' => 'propal'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'commande' => array(
|
'commande' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
|
'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
|
||||||
'img' => 'order'
|
'img' => 'order'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'facture' => array(
|
'facture' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
|
'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
|
||||||
'img' => 'bill'
|
'img' => 'bill'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'fournisseur' => array(
|
'fournisseur' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
|
'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
|
||||||
'img' => 'order'
|
'img' => 'order'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
|
'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
|
||||||
'img' => 'bill'
|
'img' => 'bill'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'service' => array(
|
'service' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
|
'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
|
||||||
'img' => 'service'
|
'img' => 'service'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_RUNNING_SERVICES',
|
'code' => 'MAIN_DELAY_RUNNING_SERVICES',
|
||||||
'img' => 'service'
|
'img' => 'service'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'banque' => array(
|
'banque' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
|
'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
|
||||||
'img' => 'account'
|
'img' => 'account'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
|
'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
|
||||||
'img' => 'account'
|
'img' => 'account'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'adherent' => array(
|
'adherent' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_MEMBERS',
|
'code' => 'MAIN_DELAY_MEMBERS',
|
||||||
'img' => 'user'
|
'img' => 'user'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'expensereport' => array(
|
'expensereport' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_EXPENSEREPORTS',
|
'code' => 'MAIN_DELAY_EXPENSEREPORTS',
|
||||||
'img' => 'trip'
|
'img' => 'trip'
|
||||||
),
|
),
|
||||||
/* TODO Enable this
|
/* TODO Enable this
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
|
'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
|
||||||
'img' => 'trip'
|
'img' => 'trip'
|
||||||
)*/
|
)*/
|
||||||
),
|
),
|
||||||
'holiday' => array(
|
'holiday' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'MAIN_DELAY_HOLIDAYS',
|
'code' => 'MAIN_DELAY_HOLIDAYS',
|
||||||
'img' => 'holiday'
|
'img' => 'holiday'
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
|
$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
|
||||||
|
|
||||||
if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
|
if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
|
||||||
$conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
|
$conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
|
if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
|
||||||
$conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
|
$conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
|
if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
|
||||||
$conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
|
$conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
|
if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
|
||||||
$conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
|
$conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
||||||
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
|
if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
|
||||||
$conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
|
$conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
||||||
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
||||||
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
||||||
}
|
}
|
||||||
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
||||||
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -166,32 +170,31 @@ if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'update')
|
if ($action == 'update') {
|
||||||
{
|
foreach ($modules as $module => $delays) {
|
||||||
foreach ($modules as $module => $delays)
|
if (!empty($conf->$module->enabled)) {
|
||||||
{
|
foreach ($delays as $delay) {
|
||||||
if (!empty($conf->$module->enabled))
|
if (GETPOST($delay['code']) != '') {
|
||||||
{
|
dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
|
||||||
foreach ($delays as $delay)
|
}
|
||||||
{
|
}
|
||||||
if (GETPOST($delay['code']) != '')
|
}
|
||||||
{
|
}
|
||||||
dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
// For update value with percentage
|
// For update value with percentage
|
||||||
$plus = '';
|
$plus = '';
|
||||||
if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
|
if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
|
||||||
// Update values
|
$plus = '_PERCENTAGE';
|
||||||
for ($i = 0; $i < 4; $i++) {
|
}
|
||||||
if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
|
// Update values
|
||||||
}
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
|
||||||
|
dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
|
|
||||||
@ -213,158 +216,165 @@ print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceD
|
|||||||
print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
|
print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
if ($action == 'edit')
|
if ($action == 'edit') {
|
||||||
{
|
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
|
||||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
||||||
|
|
||||||
foreach ($modules as $module => $delays)
|
foreach ($modules as $module => $delays) {
|
||||||
{
|
if (!empty($conf->$module->enabled)) {
|
||||||
if (!empty($conf->$module->enabled))
|
foreach ($delays as $delay) {
|
||||||
{
|
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
|
||||||
foreach ($delays as $delay)
|
print '<tr class="oddeven">';
|
||||||
{
|
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
|
||||||
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
|
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td class="nowraponall">';
|
||||||
print '<tr class="oddeven">';
|
print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
|
||||||
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
|
}
|
||||||
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td class="nowraponall">';
|
}
|
||||||
print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// Show if meteo is enabled
|
// Show if meteo is enabled
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
|
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
|
||||||
print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
|
print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Show parameters
|
* Show parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
||||||
|
|
||||||
foreach ($modules as $module => $delays)
|
foreach ($modules as $module => $delays) {
|
||||||
{
|
if (!empty($conf->$module->enabled)) {
|
||||||
if (!empty($conf->$module->enabled))
|
foreach ($delays as $delay) {
|
||||||
{
|
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
|
||||||
foreach ($delays as $delay)
|
print '<tr class="oddeven">';
|
||||||
{
|
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
|
||||||
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
|
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
|
||||||
print '<tr class="oddeven">';
|
print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>';
|
||||||
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
|
}
|
||||||
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
|
}
|
||||||
print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>';
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// Show if meteo is enabled
|
// Show if meteo is enabled
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
|
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
|
||||||
print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
|
print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
if ($conf->global->MAIN_DISABLE_METEO != 1) {
|
if ($conf->global->MAIN_DISABLE_METEO != 1) {
|
||||||
// Show logo for weather
|
// Show logo for weather
|
||||||
print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
|
print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
|
||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
|
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
|
||||||
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
|
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
|
||||||
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
|
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
|
||||||
else $str_mode_enabled = $str_mode_percentage;
|
$str_mode_enabled = $str_mode_std;
|
||||||
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
|
} else {
|
||||||
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
|
$str_mode_enabled = $str_mode_percentage;
|
||||||
|
}
|
||||||
|
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
|
||||||
|
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
|
||||||
|
|
||||||
print '<br><br>';
|
print '<br><br>';
|
||||||
} else {
|
} else {
|
||||||
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
|
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
|
||||||
else print $langs->trans('MeteoPercentageModEnabled');
|
print $langs->trans('MeteoStdModEnabled');
|
||||||
print '<br><br>';
|
} else {
|
||||||
}
|
print $langs->trans('MeteoPercentageModEnabled');
|
||||||
|
}
|
||||||
|
print '<br><br>';
|
||||||
|
}
|
||||||
|
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$cursor = 10; // By default
|
$cursor = 10; // By default
|
||||||
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
|
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
|
||||||
//if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
|
//if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
|
||||||
$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0;
|
$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) {
|
||||||
$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1;
|
$level0 = $conf->global->MAIN_METEO_LEVEL0;
|
||||||
$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2;
|
}
|
||||||
$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3;
|
$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) {
|
||||||
$text = ''; $options = 'class="valignmiddle" height="60px"';
|
$level1 = $conf->global->MAIN_METEO_LEVEL1;
|
||||||
|
}
|
||||||
|
$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) {
|
||||||
|
$level2 = $conf->global->MAIN_METEO_LEVEL2;
|
||||||
|
}
|
||||||
|
$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) {
|
||||||
|
$level3 = $conf->global->MAIN_METEO_LEVEL3;
|
||||||
|
}
|
||||||
|
$text = ''; $options = 'class="valignmiddle" height="60px"';
|
||||||
|
|
||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
|
print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
|
||||||
|
|
||||||
print '<div>';
|
print '<div>';
|
||||||
print '<div class="inline-block" style="padding-right: 20px">';
|
print '<div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 0, $options);
|
print img_weather($text, 0, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
|
||||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 1, $options);
|
print img_weather($text, 1, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
|
||||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 2, $options);
|
print img_weather($text, 2, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
|
||||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 3, $options);
|
print img_weather($text, 3, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
|
print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
|
||||||
|
|
||||||
print '<div>';
|
print '<div>';
|
||||||
print '<div class="inline-block" style="padding-right: 20px">';
|
print '<div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 0, $options);
|
print img_weather($text, 0, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/> %</td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/> %</td>';
|
||||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 1, $options);
|
print img_weather($text, 1, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/> %</td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/> %</td>';
|
||||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 2, $options);
|
print img_weather($text, 2, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/> %</td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/> %</td>';
|
||||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||||
print img_weather($text, 3, $options);
|
print img_weather($text, 3, $options);
|
||||||
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/> %</td>';
|
print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/> %</td>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "sendings", "deliveries", "other"));
|
$langs->loadLangs(array("admin", "sendings", "deliveries", "other"));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'alpha');
|
$action = GETPOST('action', 'alpha');
|
||||||
$value = GETPOST('value', 'alpha');
|
$value = GETPOST('value', 'alpha');
|
||||||
@ -52,39 +54,40 @@ $type = 'delivery';
|
|||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||||
|
|
||||||
if ($action == 'updateMask')
|
if ($action == 'updateMask') {
|
||||||
{
|
|
||||||
$maskconstdelivery = GETPOST('maskconstdelivery', 'alpha');
|
$maskconstdelivery = GETPOST('maskconstdelivery', 'alpha');
|
||||||
$maskdelivery = GETPOST('maskdelivery', 'alpha');
|
$maskdelivery = GETPOST('maskdelivery', 'alpha');
|
||||||
if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity);
|
if ($maskconstdelivery) {
|
||||||
|
$res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set_DELIVERY_FREE_TEXT')
|
if ($action == 'set_DELIVERY_FREE_TEXT') {
|
||||||
{
|
|
||||||
$free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
|
$free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
|
||||||
$res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'specimen')
|
if ($action == 'specimen') {
|
||||||
{
|
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
|
|
||||||
$sending = new Delivery($db);
|
$sending = new Delivery($db);
|
||||||
@ -93,25 +96,21 @@ if ($action == 'specimen')
|
|||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0;
|
$file = ''; $classname = ''; $filefound = 0;
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0);
|
$file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file)) {
|
||||||
{
|
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound) {
|
||||||
{
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($sending, $langs) > 0)
|
if ($module->write_file($sending, $langs) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -124,24 +123,21 @@ if ($action == 'specimen')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set')
|
if ($action == 'set') {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'del')
|
if ($action == 'del') {
|
||||||
{
|
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
if ($conf->global->DELIVERY_ADDON_PDF == "$value") {
|
||||||
if ($conf->global->DELIVERY_ADDON_PDF == "$value") dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity);
|
dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setdoc')
|
if ($action == 'setdoc') {
|
||||||
{
|
if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
|
|
||||||
{
|
|
||||||
// La constante qui a ete lue en avant du nouveau set
|
// La constante qui a ete lue en avant du nouveau set
|
||||||
// on passe donc par une variable pour avoir un affichage coherent
|
// on passe donc par une variable pour avoir un affichage coherent
|
||||||
$conf->global->DELIVERY_ADDON_PDF = $value;
|
$conf->global->DELIVERY_ADDON_PDF = $value;
|
||||||
@ -149,14 +145,12 @@ if ($action == 'setdoc')
|
|||||||
|
|
||||||
// On active le modele
|
// On active le modele
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setmod')
|
if ($action == 'setmod') {
|
||||||
{
|
|
||||||
// TODO Verifier si module numerotation choisi peut etre active
|
// TODO Verifier si module numerotation choisi peut etre active
|
||||||
// par appel methode canBeActivated
|
// par appel methode canBeActivated
|
||||||
|
|
||||||
@ -197,17 +191,13 @@ print '</tr>'."\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir."core/modules/delivery/");
|
$dir = dol_buildpath($reldir."core/modules/delivery/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
|
||||||
{
|
|
||||||
if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
|
if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
|
||||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||||
|
|
||||||
@ -215,11 +205,14 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
$module = new $file;
|
$module = new $file;
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled()) {
|
||||||
{
|
|
||||||
// Show modules according to features level
|
// Show modules according to features level
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
||||||
print $module->info();
|
print $module->info();
|
||||||
@ -231,13 +224,15 @@ foreach ($dirmodels as $reldir)
|
|||||||
if (preg_match('/^Error/', $tmp)) {
|
if (preg_match('/^Error/', $tmp)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||||
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
} elseif ($tmp == 'NotConfigured') {
|
||||||
else print $tmp;
|
print $langs->trans($tmp);
|
||||||
|
} else {
|
||||||
|
print $tmp;
|
||||||
|
}
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
|
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($conf->global->DELIVERY_ADDON_NUMBER == "$file")
|
if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
||||||
@ -254,8 +249,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||||
if ($nextval) {
|
if ($nextval) {
|
||||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
|
||||||
$nextval = $langs->trans($nextval);
|
$nextval = $langs->trans($nextval);
|
||||||
|
}
|
||||||
$htmltooltip .= $nextval.'<br>';
|
$htmltooltip .= $nextval.'<br>';
|
||||||
} else {
|
} else {
|
||||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||||
@ -294,12 +290,10 @@ $sql .= " WHERE type = '".$db->escape($type)."'";
|
|||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num_rows = $db->num_rows($resql);
|
$num_rows = $db->num_rows($resql);
|
||||||
while ($i < $num_rows)
|
while ($i < $num_rows) {
|
||||||
{
|
|
||||||
$array = $db->fetch_array($resql);
|
$array = $db->fetch_array($resql);
|
||||||
array_push($def, $array[0]);
|
array_push($def, $array[0]);
|
||||||
$i++;
|
$i++;
|
||||||
@ -320,28 +314,21 @@ print "</tr>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
|
||||||
$dir = dol_buildpath($reldir."core/modules/delivery/doc/");
|
$dir = dol_buildpath($reldir."core/modules/delivery/doc/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir)) {
|
||||||
{
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
|
||||||
{
|
|
||||||
$filelist[] = $file;
|
$filelist[] = $file;
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
arsort($filelist);
|
arsort($filelist);
|
||||||
|
|
||||||
foreach ($filelist as $file)
|
foreach ($filelist as $file) {
|
||||||
{
|
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
if (file_exists($dir.'/'.$file)) {
|
||||||
{
|
|
||||||
if (file_exists($dir.'/'.$file))
|
|
||||||
{
|
|
||||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
@ -349,21 +336,26 @@ foreach ($dirmodels as $reldir)
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
$modulequalified = 1;
|
$modulequalified = 1;
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
$modulequalified = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($modulequalified)
|
if ($modulequalified) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td width="100">';
|
print '<tr class="oddeven"><td width="100">';
|
||||||
print (empty($module->name) ? $name : $module->name);
|
print (empty($module->name) ? $name : $module->name);
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
if (method_exists($module, 'info')) print $module->info($langs);
|
if (method_exists($module, 'info')) {
|
||||||
else print $module->description;
|
print $module->info($langs);
|
||||||
|
} else {
|
||||||
|
print $module->description;
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
if (in_array($name, $def))
|
if (in_array($name, $def)) {
|
||||||
{
|
|
||||||
print "<td align=\"center\">\n";
|
print "<td align=\"center\">\n";
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
|
||||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||||
@ -377,8 +369,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Default
|
// Default
|
||||||
print "<td align=\"center\">";
|
print "<td align=\"center\">";
|
||||||
if ($conf->global->DELIVERY_ADDON_PDF == "$name")
|
if ($conf->global->DELIVERY_ADDON_PDF == "$name") {
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Default"), 'on');
|
print img_picto($langs->trans("Default"), 'on');
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
@ -396,8 +387,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
// Preview
|
// Preview
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||||
@ -430,7 +420,9 @@ print "</tr>\n";
|
|||||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
foreach ($substitutionarray as $key => $val) {
|
||||||
|
$htmltext .= $key.'<br>';
|
||||||
|
}
|
||||||
$htmltext .= '</i>';
|
$htmltext .= '</i>';
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
@ -439,8 +431,7 @@ print '<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
|
|||||||
print '<tr class="oddeven"><td colspan="2">';
|
print '<tr class="oddeven"><td colspan="2">';
|
||||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||||
$variablename = 'DELIVERY_FREE_TEXT';
|
$variablename = 'DELIVERY_FREE_TEXT';
|
||||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
|
||||||
{
|
|
||||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||||
} else {
|
} else {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
|
|||||||
@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries'));
|
$langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries'));
|
||||||
@ -45,13 +46,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'delivery'; //Must be the $table_element of the class that manage extrafield
|
$elementtype = 'delivery'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -84,8 +89,7 @@ print dol_get_fiche_end();
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if ($action != 'create' && $action != 'edit')
|
if ($action != 'create' && $action != 'edit') {
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -98,8 +102,7 @@ if ($action != 'create' && $action != 'edit')
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print '<br><div id="newattrib"></div>';
|
print '<br><div id="newattrib"></div>';
|
||||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
@ -111,8 +114,7 @@ if ($action == 'create')
|
|||||||
/* Edition of an optional field */
|
/* Edition of an optional field */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
if ($action == 'edit' && !empty($attrname))
|
if ($action == 'edit' && !empty($attrname)) {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'other', 'sendings'));
|
$langs->loadLangs(array('admin', 'other', 'sendings'));
|
||||||
@ -46,13 +47,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'deliverydet'; //Must be the $table_element of the class that manage extrafield
|
$elementtype = 'deliverydet'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -85,8 +90,7 @@ print dol_get_fiche_end();
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if ($action != 'create' && $action != 'edit')
|
if ($action != 'create' && $action != 'edit') {
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -99,8 +103,7 @@ if ($action != 'create' && $action != 'edit')
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print '<br><div id="newattrib"></div>';
|
print '<br><div id="newattrib"></div>';
|
||||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
@ -112,8 +115,7 @@ if ($action == 'create')
|
|||||||
/* Edition of an optional field */
|
/* Edition of an optional field */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
if ($action == 'edit' && !empty($attrname))
|
if ($action == 'edit' && !empty($attrname)) {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,9 @@
|
|||||||
* or see https://www.gnu.org/
|
* or see https://www.gnu.org/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
|
if (!defined('REQUIRE_JQUERY_BLOCKUI')) {
|
||||||
|
define('REQUIRE_JQUERY_BLOCKUI', 1);
|
||||||
|
}
|
||||||
if (!defined('NOTOKENRENEWAL')) {
|
if (!defined('NOTOKENRENEWAL')) {
|
||||||
define('NOTOKENRENEWAL', 1);
|
define('NOTOKENRENEWAL', 1);
|
||||||
}
|
}
|
||||||
@ -47,7 +49,8 @@ try {
|
|||||||
$url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
|
$url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
|
||||||
$api = new PrestaShopWebservice(
|
$api = new PrestaShopWebservice(
|
||||||
$conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
|
$conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
|
||||||
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api
|
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY,
|
||||||
|
$dolistore->debug_api
|
||||||
);
|
);
|
||||||
//echo $url;
|
//echo $url;
|
||||||
$request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
|
$request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
|
||||||
@ -56,7 +59,11 @@ try {
|
|||||||
} catch (PrestaShopWebserviceException $e) {
|
} catch (PrestaShopWebserviceException $e) {
|
||||||
// Here we are dealing with errors
|
// Here we are dealing with errors
|
||||||
$trace = $e->getTrace();
|
$trace = $e->getTrace();
|
||||||
if ($trace[0]['args'][0] == 404) die('Bad ID');
|
if ($trace[0]['args'][0] == 404) {
|
||||||
elseif ($trace[0]['args'][0] == 401) die('Bad auth key');
|
die('Bad ID');
|
||||||
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
|
} elseif ($trace[0]['args'][0] == 401) {
|
||||||
|
die('Bad auth key');
|
||||||
|
} else {
|
||||||
|
die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,8 +71,9 @@ class PrestaShopWebservice
|
|||||||
*/
|
*/
|
||||||
public function __construct($url, $key, $debug = true)
|
public function __construct($url, $key, $debug = true)
|
||||||
{
|
{
|
||||||
if (!extension_loaded('curl'))
|
if (!extension_loaded('curl')) {
|
||||||
throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library');
|
throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library');
|
||||||
|
}
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
$this->debug = $debug;
|
$this->debug = $debug;
|
||||||
@ -88,8 +89,7 @@ class PrestaShopWebservice
|
|||||||
protected function checkStatusCode($status_code)
|
protected function checkStatusCode($status_code)
|
||||||
{
|
{
|
||||||
$error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.';
|
$error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.';
|
||||||
switch ($status_code)
|
switch ($status_code) {
|
||||||
{
|
|
||||||
case 200:
|
case 200:
|
||||||
case 201:
|
case 201:
|
||||||
break;
|
break;
|
||||||
@ -132,25 +132,27 @@ class PrestaShopWebservice
|
|||||||
$session = curl_init($url);
|
$session = curl_init($url);
|
||||||
|
|
||||||
$curl_options = array();
|
$curl_options = array();
|
||||||
foreach ($defaultParams as $defkey => $defval)
|
foreach ($defaultParams as $defkey => $defval) {
|
||||||
{
|
if (isset($curl_params[$defkey])) {
|
||||||
if (isset($curl_params[$defkey]))
|
|
||||||
$curl_options[$defkey] = $curl_params[$defkey];
|
$curl_options[$defkey] = $curl_params[$defkey];
|
||||||
else {
|
} else {
|
||||||
$curl_options[$defkey] = $defaultParams[$defkey];
|
$curl_options[$defkey] = $defaultParams[$defkey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($curl_params as $defkey => $defval)
|
foreach ($curl_params as $defkey => $defval) {
|
||||||
if (!isset($curl_options[$defkey]))
|
if (!isset($curl_options[$defkey])) {
|
||||||
$curl_options[$defkey] = $curl_params[$defkey];
|
$curl_options[$defkey] = $curl_params[$defkey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog("curl curl_options = ".var_export($curl_options, true));
|
dol_syslog("curl curl_options = ".var_export($curl_options, true));
|
||||||
curl_setopt_array($session, $curl_options);
|
curl_setopt_array($session, $curl_options);
|
||||||
$response = curl_exec($session);
|
$response = curl_exec($session);
|
||||||
|
|
||||||
$index = strpos($response, "\r\n\r\n");
|
$index = strpos($response, "\r\n\r\n");
|
||||||
if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD')
|
if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
|
||||||
throw new PrestaShopWebserviceException('Bad HTTP response');
|
throw new PrestaShopWebserviceException('Bad HTTP response');
|
||||||
|
}
|
||||||
|
|
||||||
$header = substr($response, 0, $index);
|
$header = substr($response, 0, $index);
|
||||||
$body = substr($response, $index + 4);
|
$body = substr($response, $index + 4);
|
||||||
@ -158,39 +160,39 @@ class PrestaShopWebservice
|
|||||||
$headerArrayTmp = explode("\n", $header);
|
$headerArrayTmp = explode("\n", $header);
|
||||||
|
|
||||||
$headerArray = array();
|
$headerArray = array();
|
||||||
foreach ($headerArrayTmp as &$headerItem)
|
foreach ($headerArrayTmp as &$headerItem) {
|
||||||
{
|
|
||||||
$tmp = explode(':', $headerItem);
|
$tmp = explode(':', $headerItem);
|
||||||
$tmp = array_map('trim', $tmp);
|
$tmp = array_map('trim', $tmp);
|
||||||
if (count($tmp) == 2)
|
if (count($tmp) == 2) {
|
||||||
$headerArray[$tmp[0]] = $tmp[1];
|
$headerArray[$tmp[0]] = $tmp[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('PSWS-Version', $headerArray))
|
if (array_key_exists('PSWS-Version', $headerArray)) {
|
||||||
{
|
|
||||||
$this->version = $headerArray['PSWS-Version'];
|
$this->version = $headerArray['PSWS-Version'];
|
||||||
if (
|
if (version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 ||
|
||||||
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 ||
|
|
||||||
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1
|
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1
|
||||||
)
|
) {
|
||||||
throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library');
|
throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
{
|
|
||||||
$this->printDebug('HTTP REQUEST HEADER', curl_getinfo($session, CURLINFO_HEADER_OUT));
|
$this->printDebug('HTTP REQUEST HEADER', curl_getinfo($session, CURLINFO_HEADER_OUT));
|
||||||
$this->printDebug('HTTP RESPONSE HEADER', $header);
|
$this->printDebug('HTTP RESPONSE HEADER', $header);
|
||||||
}
|
}
|
||||||
$status_code = curl_getinfo($session, CURLINFO_HTTP_CODE);
|
$status_code = curl_getinfo($session, CURLINFO_HTTP_CODE);
|
||||||
if ($status_code === 0)
|
if ($status_code === 0) {
|
||||||
throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session));
|
throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session));
|
||||||
|
}
|
||||||
curl_close($session);
|
curl_close($session);
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
{
|
if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST') {
|
||||||
if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST')
|
|
||||||
$this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS]));
|
$this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS]));
|
||||||
if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD')
|
}
|
||||||
|
if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
|
||||||
$this->printDebug('RETURN HTTP BODY', $body);
|
$this->printDebug('RETURN HTTP BODY', $body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return array('status_code' => $status_code, 'response' => $body, 'header' => $header);
|
return array('status_code' => $status_code, 'response' => $body, 'header' => $header);
|
||||||
}
|
}
|
||||||
@ -227,13 +229,11 @@ class PrestaShopWebservice
|
|||||||
*/
|
*/
|
||||||
protected function parseXML($response)
|
protected function parseXML($response)
|
||||||
{
|
{
|
||||||
if ($response != '')
|
if ($response != '') {
|
||||||
{
|
|
||||||
libxml_clear_errors();
|
libxml_clear_errors();
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
|
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||||
if (libxml_get_errors())
|
if (libxml_get_errors()) {
|
||||||
{
|
|
||||||
$msg = var_export(libxml_get_errors(), true);
|
$msg = var_export(libxml_get_errors(), true);
|
||||||
libxml_clear_errors();
|
libxml_clear_errors();
|
||||||
throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg);
|
throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg);
|
||||||
@ -261,14 +261,15 @@ class PrestaShopWebservice
|
|||||||
$xml = '';
|
$xml = '';
|
||||||
$url = '';
|
$url = '';
|
||||||
|
|
||||||
if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml']))
|
if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) {
|
||||||
{
|
|
||||||
$url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']);
|
$url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']);
|
||||||
$xml = $options['postXml'];
|
$xml = $options['postXml'];
|
||||||
if (isset($options['id_shop']))
|
if (isset($options['id_shop'])) {
|
||||||
$url .= '&id_shop='.$options['id_shop'];
|
$url .= '&id_shop='.$options['id_shop'];
|
||||||
if (isset($options['id_group_shop']))
|
}
|
||||||
|
if (isset($options['id_group_shop'])) {
|
||||||
$url .= '&id_group_shop='.$options['id_group_shop'];
|
$url .= '&id_group_shop='.$options['id_group_shop'];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PrestaShopWebserviceException('Bad parameters given');
|
throw new PrestaShopWebserviceException('Bad parameters given');
|
||||||
}
|
}
|
||||||
@ -310,24 +311,28 @@ class PrestaShopWebservice
|
|||||||
*/
|
*/
|
||||||
public function get($options)
|
public function get($options)
|
||||||
{
|
{
|
||||||
if (isset($options['url']))
|
if (isset($options['url'])) {
|
||||||
$url = $options['url'];
|
$url = $options['url'];
|
||||||
elseif (isset($options['resource']))
|
} elseif (isset($options['resource'])) {
|
||||||
{
|
|
||||||
$url = $this->url.'/api/'.$options['resource'];
|
$url = $this->url.'/api/'.$options['resource'];
|
||||||
$url_params = array();
|
$url_params = array();
|
||||||
if (isset($options['id']))
|
if (isset($options['id'])) {
|
||||||
$url .= '/'.$options['id'];
|
$url .= '/'.$options['id'];
|
||||||
|
}
|
||||||
|
|
||||||
// @CHANGE LDR
|
// @CHANGE LDR
|
||||||
//$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop');
|
//$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop');
|
||||||
$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date');
|
$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date');
|
||||||
foreach ($params as $p)
|
foreach ($params as $p) {
|
||||||
foreach ($options as $k => $o)
|
foreach ($options as $k => $o) {
|
||||||
if (strpos($k, $p) !== false)
|
if (strpos($k, $p) !== false) {
|
||||||
$url_params[$k] = $options[$k];
|
$url_params[$k] = $options[$k];
|
||||||
if (count($url_params) > 0)
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($url_params) > 0) {
|
||||||
$url .= '?'.http_build_query($url_params);
|
$url .= '?'.http_build_query($url_params);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PrestaShopWebserviceException('Bad parameters given ');
|
throw new PrestaShopWebserviceException('Bad parameters given ');
|
||||||
}
|
}
|
||||||
@ -347,22 +352,26 @@ class PrestaShopWebservice
|
|||||||
*/
|
*/
|
||||||
public function head($options)
|
public function head($options)
|
||||||
{
|
{
|
||||||
if (isset($options['url']))
|
if (isset($options['url'])) {
|
||||||
$url = $options['url'];
|
$url = $options['url'];
|
||||||
elseif (isset($options['resource']))
|
} elseif (isset($options['resource'])) {
|
||||||
{
|
|
||||||
$url = $this->url.'/api/'.$options['resource'];
|
$url = $this->url.'/api/'.$options['resource'];
|
||||||
$url_params = array();
|
$url_params = array();
|
||||||
if (isset($options['id']))
|
if (isset($options['id'])) {
|
||||||
$url .= '/'.$options['id'];
|
$url .= '/'.$options['id'];
|
||||||
|
}
|
||||||
|
|
||||||
$params = array('filter', 'display', 'sort', 'limit');
|
$params = array('filter', 'display', 'sort', 'limit');
|
||||||
foreach ($params as $p)
|
foreach ($params as $p) {
|
||||||
foreach ($options as $k => $o)
|
foreach ($options as $k => $o) {
|
||||||
if (strpos($k, $p) !== false)
|
if (strpos($k, $p) !== false) {
|
||||||
$url_params[$k] = $options[$k];
|
$url_params[$k] = $options[$k];
|
||||||
if (count($url_params) > 0)
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($url_params) > 0) {
|
||||||
$url .= '?'.http_build_query($url_params);
|
$url .= '?'.http_build_query($url_params);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PrestaShopWebserviceException('Bad parameters given');
|
throw new PrestaShopWebserviceException('Bad parameters given');
|
||||||
}
|
}
|
||||||
@ -386,16 +395,17 @@ class PrestaShopWebservice
|
|||||||
public function edit($options)
|
public function edit($options)
|
||||||
{
|
{
|
||||||
$xml = '';
|
$xml = '';
|
||||||
if (isset($options['url']))
|
if (isset($options['url'])) {
|
||||||
$url = $options['url'];
|
$url = $options['url'];
|
||||||
elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml'])
|
} elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) {
|
||||||
{
|
|
||||||
$url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']);
|
$url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']);
|
||||||
$xml = $options['putXml'];
|
$xml = $options['putXml'];
|
||||||
if (isset($options['id_shop']))
|
if (isset($options['id_shop'])) {
|
||||||
$url .= '&id_shop='.$options['id_shop'];
|
$url .= '&id_shop='.$options['id_shop'];
|
||||||
if (isset($options['id_group_shop']))
|
}
|
||||||
|
if (isset($options['id_group_shop'])) {
|
||||||
$url .= '&id_group_shop='.$options['id_group_shop'];
|
$url .= '&id_group_shop='.$options['id_group_shop'];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PrestaShopWebserviceException('Bad parameters given');
|
throw new PrestaShopWebserviceException('Bad parameters given');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
if (!class_exists('PrestaShopWebservice')) // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors.
|
if (!class_exists('PrestaShopWebservice')) { // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors.
|
||||||
{
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +66,9 @@ class Dolistore
|
|||||||
$langtmp = explode('_', $langs->defaultlang);
|
$langtmp = explode('_', $langs->defaultlang);
|
||||||
$lang = $langtmp[0];
|
$lang = $langtmp[0];
|
||||||
$lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1
|
$lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1
|
||||||
if (!in_array($lang, array_keys($lang_array))) $lang = 'en';
|
if (!in_array($lang, array_keys($lang_array))) {
|
||||||
|
$lang = 'en';
|
||||||
|
}
|
||||||
$this->lang = $lang_array[$lang];
|
$this->lang = $lang_array[$lang];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +100,11 @@ class Dolistore
|
|||||||
} catch (PrestaShopWebserviceException $e) {
|
} catch (PrestaShopWebserviceException $e) {
|
||||||
// Here we are dealing with errors
|
// Here we are dealing with errors
|
||||||
$trace = $e->getTrace();
|
$trace = $e->getTrace();
|
||||||
if ($trace[0]['args'][0] == 404) die('Bad ID');
|
if ($trace[0]['args'][0] == 404) {
|
||||||
elseif ($trace[0]['args'][0] == 401) die('Bad auth key');
|
die('Bad ID');
|
||||||
else {
|
} elseif ($trace[0]['args'][0] == 401) {
|
||||||
|
die('Bad auth key');
|
||||||
|
} else {
|
||||||
print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>';
|
print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>';
|
||||||
print $e->getMessage();
|
print $e->getMessage();
|
||||||
}
|
}
|
||||||
@ -180,9 +183,11 @@ class Dolistore
|
|||||||
} catch (PrestaShopWebserviceException $e) {
|
} catch (PrestaShopWebserviceException $e) {
|
||||||
// Here we are dealing with errors
|
// Here we are dealing with errors
|
||||||
$trace = $e->getTrace();
|
$trace = $e->getTrace();
|
||||||
if ($trace[0]['args'][0] == 404) die('Bad ID');
|
if ($trace[0]['args'][0] == 404) {
|
||||||
elseif ($trace[0]['args'][0] == 401) die('Bad auth key');
|
die('Bad ID');
|
||||||
else {
|
} elseif ($trace[0]['args'][0] == 401) {
|
||||||
|
die('Bad auth key');
|
||||||
|
} else {
|
||||||
print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>';
|
print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'<br>';
|
||||||
print $e->getMessage();
|
print $e->getMessage();
|
||||||
}
|
}
|
||||||
@ -199,7 +204,9 @@ class Dolistore
|
|||||||
public function get_categories($parent = 0)
|
public function get_categories($parent = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
if (!isset($this->categories)) die('not possible');
|
if (!isset($this->categories)) {
|
||||||
|
die('not possible');
|
||||||
|
}
|
||||||
if ($parent != 0) {
|
if ($parent != 0) {
|
||||||
$html = '<ul>';
|
$html = '<ul>';
|
||||||
} else {
|
} else {
|
||||||
@ -207,8 +214,7 @@ class Dolistore
|
|||||||
}
|
}
|
||||||
|
|
||||||
$nbofcateg = count($this->categories);
|
$nbofcateg = count($this->categories);
|
||||||
for ($i = 0; $i < $nbofcateg; $i++)
|
for ($i = 0; $i < $nbofcateg; $i++) {
|
||||||
{
|
|
||||||
$cat = $this->categories[$i];
|
$cat = $this->categories[$i];
|
||||||
if ($cat->is_root_category == 1 && $parent == 0) {
|
if ($cat->is_root_category == 1 && $parent == 0) {
|
||||||
$html .= '<li class="root"><h3 class="nomargesupinf"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.$cat->id.'" ';
|
$html .= '<li class="root"><h3 class="nomargesupinf"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.$cat->id.'" ';
|
||||||
@ -282,19 +288,31 @@ class Dolistore
|
|||||||
if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) {
|
if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) {
|
||||||
if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) {
|
if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) {
|
||||||
//compatible
|
//compatible
|
||||||
$version = '<span class="compatible">'.$langs->trans('CompatibleUpTo', $product->dolibarr_max,
|
$version = '<span class="compatible">'.$langs->trans(
|
||||||
$product->dolibarr_min, $product->dolibarr_max).'</span>';
|
'CompatibleUpTo',
|
||||||
|
$product->dolibarr_max,
|
||||||
|
$product->dolibarr_min,
|
||||||
|
$product->dolibarr_max
|
||||||
|
).'</span>';
|
||||||
$compatible = '';
|
$compatible = '';
|
||||||
} else {
|
} else {
|
||||||
//never compatible, module expired
|
//never compatible, module expired
|
||||||
$version = '<span class="notcompatible">'.$langs->trans('NotCompatible', DOL_VERSION,
|
$version = '<span class="notcompatible">'.$langs->trans(
|
||||||
$product->dolibarr_min, $product->dolibarr_max).'</span>';
|
'NotCompatible',
|
||||||
|
DOL_VERSION,
|
||||||
|
$product->dolibarr_min,
|
||||||
|
$product->dolibarr_max
|
||||||
|
).'</span>';
|
||||||
$compatible = 'NotCompatible';
|
$compatible = 'NotCompatible';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//need update
|
//need update
|
||||||
$version = '<span class="compatibleafterupdate">'.$langs->trans('CompatibleAfterUpdate', DOL_VERSION,
|
$version = '<span class="compatibleafterupdate">'.$langs->trans(
|
||||||
$product->dolibarr_min, $product->dolibarr_max).'</span>';
|
'CompatibleAfterUpdate',
|
||||||
|
DOL_VERSION,
|
||||||
|
$product->dolibarr_min,
|
||||||
|
$product->dolibarr_max
|
||||||
|
).'</span>';
|
||||||
$compatible = 'NotCompatible';
|
$compatible = 'NotCompatible';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,17 +29,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action
|
* Action
|
||||||
*/
|
*/
|
||||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -47,11 +47,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -91,15 +89,12 @@ print '<td>'.$langs->trans("ECMAutoTree").'</td>';
|
|||||||
print '<td class="center" width="20"> </td>';
|
print '<td class="center" width="20"> </td>';
|
||||||
|
|
||||||
print '<td class="center" width="100">';
|
print '<td class="center" width="100">';
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax) {
|
||||||
{
|
|
||||||
print ajax_constantonoff('ECM_AUTO_TREE_ENABLED');
|
print ajax_constantonoff('ECM_AUTO_TREE_ENABLED');
|
||||||
} else {
|
} else {
|
||||||
if (empty($conf->global->ECM_AUTO_TREE_ENABLED))
|
if (empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ECM_AUTO_TREE_ENABLED&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ECM_AUTO_TREE_ENABLED&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
} elseif (!empty($conf->global->USER_MAIL_REQUIRED))
|
} elseif (!empty($conf->global->USER_MAIL_REQUIRED)) {
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ECM_AUTO_TREE_ENABLED&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ECM_AUTO_TREE_ENABLED&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'other', 'ecm'));
|
$langs->loadLangs(array('admin', 'other', 'ecm'));
|
||||||
|
|||||||
@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'other', 'ecm'));
|
$langs->loadLangs(array('admin', 'other', 'ecm'));
|
||||||
|
|||||||
@ -33,8 +33,12 @@ include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectorfilter.class
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
if (empty($conf->emailcollector->enabled)) accessforbidden();
|
accessforbidden();
|
||||||
|
}
|
||||||
|
if (empty($conf->emailcollector->enabled)) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
// Load traductions files required by page
|
// Load traductions files required by page
|
||||||
$langs->loadLangs(array("admin", "mails", "other"));
|
$langs->loadLangs(array("admin", "mails", "other"));
|
||||||
@ -65,11 +69,17 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
|
|||||||
$search_all = GETPOST("search_all", 'alpha');
|
$search_all = GETPOST("search_all", 'alpha');
|
||||||
$search = array();
|
$search = array();
|
||||||
foreach ($object->fields as $key => $val) {
|
foreach ($object->fields as $key => $val) {
|
||||||
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
|
if (GETPOST('search_'.$key, 'alpha')) {
|
||||||
|
$search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST('saveoperation2')) $action = 'updateoperation';
|
if (GETPOST('saveoperation2')) {
|
||||||
if (empty($action) && empty($id) && empty($ref)) $action = 'view';
|
$action = 'updateoperation';
|
||||||
|
}
|
||||||
|
if (empty($action) && empty($id) && empty($ref)) {
|
||||||
|
$action = 'view';
|
||||||
|
}
|
||||||
|
|
||||||
// Load object
|
// Load object
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
||||||
@ -93,15 +103,18 @@ $debuginfo = '';
|
|||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook)) {
|
||||||
{
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$permissiontoadd = 1;
|
$permissiontoadd = 1;
|
||||||
$permissiontodelete = 1;
|
$permissiontodelete = 1;
|
||||||
if (empty($backtopage)) $backtopage = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.($id > 0 ? $id : '__ID__');
|
if (empty($backtopage)) {
|
||||||
|
$backtopage = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.($id > 0 ? $id : '__ID__');
|
||||||
|
}
|
||||||
$backurlforlist = DOL_URL_ROOT.'/admin/emailcollector_list.php';
|
$backurlforlist = DOL_URL_ROOT.'/admin/emailcollector_list.php';
|
||||||
|
|
||||||
// Actions cancel, add, update, delete or clone
|
// Actions cancel, add, update, delete or clone
|
||||||
@ -114,8 +127,7 @@ if (empty($reshook))
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST('addfilter', 'alpha'))
|
if (GETPOST('addfilter', 'alpha')) {
|
||||||
{
|
|
||||||
$emailcollectorfilter = new EmailCollectorFilter($db);
|
$emailcollectorfilter = new EmailCollectorFilter($db);
|
||||||
$emailcollectorfilter->type = GETPOST('filtertype', 'aZ09');
|
$emailcollectorfilter->type = GETPOST('filtertype', 'aZ09');
|
||||||
$emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha');
|
$emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha');
|
||||||
@ -123,16 +135,14 @@ if (GETPOST('addfilter', 'alpha'))
|
|||||||
$emailcollectorfilter->status = 1;
|
$emailcollectorfilter->status = 1;
|
||||||
$result = $emailcollectorfilter->create($user);
|
$result = $emailcollectorfilter->create($user);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$object->fetchFilters();
|
$object->fetchFilters();
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
|
setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'deletefilter')
|
if ($action == 'deletefilter') {
|
||||||
{
|
|
||||||
$emailcollectorfilter = new EmailCollectorFilter($db);
|
$emailcollectorfilter = new EmailCollectorFilter($db);
|
||||||
$emailcollectorfilter->fetch(GETPOST('filterid', 'int'));
|
$emailcollectorfilter->fetch(GETPOST('filterid', 'int'));
|
||||||
if ($emailcollectorfilter->id > 0) {
|
if ($emailcollectorfilter->id > 0) {
|
||||||
@ -145,8 +155,7 @@ if ($action == 'deletefilter')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST('addoperation', 'alpha'))
|
if (GETPOST('addoperation', 'alpha')) {
|
||||||
{
|
|
||||||
$emailcollectoroperation = new EmailCollectorAction($db);
|
$emailcollectoroperation = new EmailCollectorAction($db);
|
||||||
$emailcollectoroperation->type = GETPOST('operationtype', 'aZ09');
|
$emailcollectoroperation->type = GETPOST('operationtype', 'aZ09');
|
||||||
$emailcollectoroperation->actionparam = GETPOST('operationparam', 'restricthtml');
|
$emailcollectoroperation->actionparam = GETPOST('operationparam', 'restricthtml');
|
||||||
@ -177,8 +186,7 @@ if (GETPOST('addoperation', 'alpha'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'updateoperation')
|
if ($action == 'updateoperation') {
|
||||||
{
|
|
||||||
$emailcollectoroperation = new EmailCollectorAction($db);
|
$emailcollectoroperation = new EmailCollectorAction($db);
|
||||||
$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
|
$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
|
||||||
|
|
||||||
@ -193,8 +201,7 @@ if ($action == 'updateoperation')
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
$result = $emailcollectoroperation->update($user);
|
$result = $emailcollectoroperation->update($user);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$object->fetchActions();
|
$object->fetchActions();
|
||||||
} else {
|
} else {
|
||||||
$error++;
|
$error++;
|
||||||
@ -202,8 +209,7 @@ if ($action == 'updateoperation')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($action == 'deleteoperation')
|
if ($action == 'deleteoperation') {
|
||||||
{
|
|
||||||
$emailcollectoroperation = new EmailCollectorAction($db);
|
$emailcollectoroperation = new EmailCollectorAction($db);
|
||||||
$emailcollectoroperation->fetch(GETPOST('operationid', 'int'));
|
$emailcollectoroperation->fetch(GETPOST('operationid', 'int'));
|
||||||
if ($emailcollectoroperation->id > 0) {
|
if ($emailcollectoroperation->id > 0) {
|
||||||
@ -216,13 +222,11 @@ if ($action == 'deleteoperation')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'confirm_collect')
|
if ($action == 'confirm_collect') {
|
||||||
{
|
|
||||||
dol_include_once('/emailcollector/class/emailcollector.class.php');
|
dol_include_once('/emailcollector/class/emailcollector.class.php');
|
||||||
|
|
||||||
$res = $object->doCollectOneCollector();
|
$res = $object->doCollectOneCollector();
|
||||||
if ($res > 0)
|
if ($res > 0) {
|
||||||
{
|
|
||||||
$debuginfo = $object->debuginfo;
|
$debuginfo = $object->debuginfo;
|
||||||
setEventMessages($object->lastresult, null, 'mesgs');
|
setEventMessages($object->lastresult, null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
@ -282,8 +286,7 @@ if ($action == 'create') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Part to edit record
|
// Part to edit record
|
||||||
if (($id || $ref) && $action == 'edit')
|
if (($id || $ref) && $action == 'edit') {
|
||||||
{
|
|
||||||
print load_fiche_titre($langs->trans("EmailCollector"));
|
print load_fiche_titre($langs->trans("EmailCollector"));
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
@ -314,8 +317,7 @@ if (($id || $ref) && $action == 'edit')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Part to show record
|
// Part to show record
|
||||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
|
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
|
||||||
{
|
|
||||||
$res = $object->fetch_optionals();
|
$res = $object->fetch_optionals();
|
||||||
|
|
||||||
$object->fetchFilters();
|
$object->fetchFilters();
|
||||||
@ -327,8 +329,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$formconfirm = '';
|
$formconfirm = '';
|
||||||
|
|
||||||
// Confirmation to delete
|
// Confirmation to delete
|
||||||
if ($action == 'delete')
|
if ($action == 'delete') {
|
||||||
{
|
|
||||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,8 +351,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
// Call Hook formConfirm
|
// Call Hook formConfirm
|
||||||
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
|
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
|
||||||
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
|
if (empty($reshook)) {
|
||||||
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
|
$formconfirm .= $hookmanager->resPrint;
|
||||||
|
} elseif ($reshook > 0) {
|
||||||
|
$formconfirm = $hookmanager->resPrint;
|
||||||
|
}
|
||||||
|
|
||||||
// Print form confirm
|
// Print form confirm
|
||||||
print $formconfirm;
|
print $formconfirm;
|
||||||
@ -370,36 +374,36 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
// Project
|
// Project
|
||||||
if (! empty($conf->projet->enabled))
|
if (! empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||||
if ($user->rights->emailcollector->creer)
|
if ($user->rights->emailcollector->creer)
|
||||||
{
|
{
|
||||||
if ($action != 'classify')
|
if ($action != 'classify')
|
||||||
{
|
{
|
||||||
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||||
if ($action == 'classify') {
|
if ($action == 'classify') {
|
||||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||||
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
|
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||||
$morehtmlref.='</form>';
|
$morehtmlref.='</form>';
|
||||||
} else {
|
} else {
|
||||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (! empty($object->fk_project)) {
|
if (! empty($object->fk_project)) {
|
||||||
$proj = new Project($db);
|
$proj = new Project($db);
|
||||||
$proj->fetch($object->fk_project);
|
$proj->fetch($object->fk_project);
|
||||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||||
$morehtmlref.=$proj->ref;
|
$morehtmlref.=$proj->ref;
|
||||||
$morehtmlref.='</a>';
|
$morehtmlref.='</a>';
|
||||||
} else {
|
} else {
|
||||||
$morehtmlref.='';
|
$morehtmlref.='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
$morehtmlref .= '</div>';
|
$morehtmlref .= '</div>';
|
||||||
@ -414,8 +418,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$connectstringsource = '';
|
$connectstringsource = '';
|
||||||
$connectstringtarget = '';
|
$connectstringtarget = '';
|
||||||
|
|
||||||
if (function_exists('imap_open'))
|
if (function_exists('imap_open')) {
|
||||||
{
|
|
||||||
// Note: $object->host has been loaded by the fetch
|
// Note: $object->host has been loaded by the fetch
|
||||||
$usessl = 1;
|
$usessl = 1;
|
||||||
|
|
||||||
@ -432,8 +435,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
}
|
}
|
||||||
|
|
||||||
$connection = imap_open($connectstringsource, $object->login, $object->password);
|
$connection = imap_open($connectstringsource, $object->login, $object->password);
|
||||||
} catch (Exception $e)
|
} catch (Exception $e) {
|
||||||
{
|
|
||||||
print $e->getMessage();
|
print $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,8 +444,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$morehtml .= 'IMAP functions not available on your PHP. ';
|
$morehtml .= 'IMAP functions not available on your PHP. ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$connection)
|
if (!$connection) {
|
||||||
{
|
|
||||||
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
|
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
|
||||||
if (function_exists('imap_last_error')) {
|
if (function_exists('imap_last_error')) {
|
||||||
$morehtml .= '<br>'.imap_last_error();
|
$morehtml .= '<br>'.imap_last_error();
|
||||||
@ -453,8 +454,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$morehtml .= imap_num_msg($connection);
|
$morehtml .= imap_num_msg($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($connection)
|
if ($connection) {
|
||||||
{
|
|
||||||
imap_close($connection);
|
imap_close($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +534,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
/*$noparam = array();
|
/*$noparam = array();
|
||||||
foreach ($arrayoftypes as $key => $value)
|
foreach ($arrayoftypes as $key => $value)
|
||||||
{
|
{
|
||||||
if ($value['noparam']) $noparam[] = $key;
|
if ($value['noparam']) $noparam[] = $key;
|
||||||
}*/
|
}*/
|
||||||
print '})';
|
print '})';
|
||||||
print '</script>'."\n";
|
print '</script>'."\n";
|
||||||
@ -545,8 +545,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>';
|
print '<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
// List filters
|
// List filters
|
||||||
foreach ($object->filters as $rulefilter)
|
foreach ($object->filters as $rulefilter) {
|
||||||
{
|
|
||||||
$rulefilterobj = new EmailCollectorFilter($db);
|
$rulefilterobj = new EmailCollectorFilter($db);
|
||||||
$rulefilterobj->fetch($rulefilter['id']);
|
$rulefilterobj->fetch($rulefilter['id']);
|
||||||
|
|
||||||
@ -580,9 +579,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
|
'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
|
||||||
'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
|
'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
|
||||||
'recordevent'=>'RecordEvent');
|
'recordevent'=>'RecordEvent');
|
||||||
if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
|
if ($conf->projet->enabled) {
|
||||||
if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
|
$arrayoftypes['project'] = 'CreateLeadAndThirdParty';
|
||||||
if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature';
|
}
|
||||||
|
if ($conf->ticket->enabled) {
|
||||||
|
$arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
|
||||||
|
}
|
||||||
|
if ($conf->recruitment->enabled) {
|
||||||
|
$arrayoftypes['candidature'] = 'CreateCandidature';
|
||||||
|
}
|
||||||
|
|
||||||
// support hook for add action
|
// support hook for add action
|
||||||
$parameters = array('arrayoftypes' => $arrayoftypes);
|
$parameters = array('arrayoftypes' => $arrayoftypes);
|
||||||
@ -591,7 +596,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
if ($res) {
|
if ($res) {
|
||||||
$arrayoftypes = $hookmanager->resArray;
|
$arrayoftypes = $hookmanager->resArray;
|
||||||
} else {
|
} else {
|
||||||
foreach ($hookmanager->resArray as $k=>$desc) {
|
foreach ($hookmanager->resArray as $k => $desc) {
|
||||||
$arrayoftypes[$k] = $desc;
|
$arrayoftypes[$k] = $desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -611,8 +616,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$table_element_line = 'emailcollector_emailcollectoraction';
|
$table_element_line = 'emailcollector_emailcollectoraction';
|
||||||
$fk_element = 'position';
|
$fk_element = 'position';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($object->actions as $ruleaction)
|
foreach ($object->actions as $ruleaction) {
|
||||||
{
|
|
||||||
$ruleactionobj = new EmailcollectorAction($db);
|
$ruleactionobj = new EmailcollectorAction($db);
|
||||||
$ruleactionobj->fetch($ruleaction['id']);
|
$ruleactionobj->fetch($ruleaction['id']);
|
||||||
|
|
||||||
@ -620,16 +624,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
print '<!-- type of action: '.$ruleaction['type'].' -->';
|
print '<!-- type of action: '.$ruleaction['type'].' -->';
|
||||||
print $langs->trans($arrayoftypes[$ruleaction['type']]);
|
print $langs->trans($arrayoftypes[$ruleaction['type']]);
|
||||||
if (in_array($ruleaction['type'], array('recordevent')))
|
if (in_array($ruleaction['type'], array('recordevent'))) {
|
||||||
{
|
|
||||||
print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
|
print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
|
||||||
} elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
|
} elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
|
||||||
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
|
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="wordbreak">';
|
print '<td class="wordbreak">';
|
||||||
if ($action == 'editoperation' && $ruleaction['id'] == $operationid)
|
if ($action == 'editoperation' && $ruleaction['id'] == $operationid) {
|
||||||
{
|
|
||||||
print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
|
print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
|
||||||
print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
|
print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
|
||||||
print '<input type="submit" class="button button-save" name="saveoperation2" value="'.$langs->trans("Save").'">';
|
print '<input type="submit" class="button button-save" name="saveoperation2" value="'.$langs->trans("Save").'">';
|
||||||
@ -640,8 +642,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
// Move up/down
|
// Move up/down
|
||||||
print '<td class="center linecolmove tdlineupdown">';
|
print '<td class="center linecolmove tdlineupdown">';
|
||||||
if ($i > 0)
|
if ($i > 0) {
|
||||||
{
|
|
||||||
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=up&rowid='.$ruleaction['id'].'">'.img_up('default', 0, 'imgupforline').'</a>';
|
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=up&rowid='.$ruleaction['id'].'">'.img_up('default', 0, 'imgupforline').'</a>';
|
||||||
}
|
}
|
||||||
if ($i < count($object->actions) - 1) {
|
if ($i < count($object->actions) - 1) {
|
||||||
@ -681,10 +682,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<div class="tabsAction">'."\n";
|
print '<div class="tabsAction">'."\n";
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook)) {
|
||||||
{
|
|
||||||
// Edit
|
// Edit
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Edit").'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Edit").'</a></div>';
|
||||||
|
|
||||||
@ -703,8 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '</div>'."\n";
|
print '</div>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($debuginfo))
|
if (!empty($debuginfo)) {
|
||||||
{
|
|
||||||
print info_admin($debuginfo);
|
print info_admin($debuginfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
@ -70,13 +72,16 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
|||||||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||||
|
|
||||||
// Default sort order (if not yet defined by previous GETPOST)
|
// Default sort order (if not yet defined by previous GETPOST)
|
||||||
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
|
if (!$sortfield) {
|
||||||
if (!$sortorder) $sortorder = "ASC";
|
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
|
||||||
|
}
|
||||||
|
if (!$sortorder) {
|
||||||
|
$sortorder = "ASC";
|
||||||
|
}
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = 0;
|
$socid = 0;
|
||||||
if ($user->socid > 0) // Protection if external user
|
if ($user->socid > 0) { // Protection if external user
|
||||||
{
|
|
||||||
//$socid = $user->socid;
|
//$socid = $user->socid;
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
@ -85,22 +90,23 @@ if ($user->socid > 0) // Protection if external user
|
|||||||
// Initialize array of search criterias
|
// Initialize array of search criterias
|
||||||
$search_all = GETPOST("search_all", 'alphanohtml');
|
$search_all = GETPOST("search_all", 'alphanohtml');
|
||||||
$search = array();
|
$search = array();
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val) {
|
||||||
{
|
if (GETPOST('search_'.$key, 'alpha') !== '') {
|
||||||
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
|
$search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of fields to search into when doing a "search in all"
|
// List of fields to search into when doing a "search in all"
|
||||||
$fieldstosearchall = array();
|
$fieldstosearchall = array();
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val) {
|
||||||
{
|
if ($val['searchall']) {
|
||||||
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
|
$fieldstosearchall['t.'.$key] = $val['label'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Definition of array of fields for columns
|
// Definition of array of fields for columns
|
||||||
$arrayfields = array();
|
$arrayfields = array();
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val) {
|
||||||
{
|
|
||||||
// If $val['visible']==0, then we never show the field
|
// If $val['visible']==0, then we never show the field
|
||||||
if (!empty($val['visible'])) {
|
if (!empty($val['visible'])) {
|
||||||
$visible = dol_eval($val['visible'], 1);
|
$visible = dol_eval($val['visible'], 1);
|
||||||
@ -113,10 +119,8 @@ foreach ($object->fields as $key => $val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Extra fields
|
// Extra fields
|
||||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
|
||||||
{
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
|
||||||
{
|
|
||||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
|
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
|
||||||
$arrayfields["ef.".$key] = array(
|
$arrayfields["ef.".$key] = array(
|
||||||
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
|
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
|
||||||
@ -138,8 +142,12 @@ $permissiontoread = $user->admin;
|
|||||||
$permissiontoadd = $user->admin;
|
$permissiontoadd = $user->admin;
|
||||||
$permissiontodelete = $user->admin;
|
$permissiontodelete = $user->admin;
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled');
|
accessforbidden();
|
||||||
|
}
|
||||||
|
if (empty($conf->emailcollector->enabled)) {
|
||||||
|
accessforbidden('Module not enabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -147,31 +155,33 @@ if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled')
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
if (GETPOST('cancel', 'alpha')) {
|
||||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
$action = 'list'; $massaction = '';
|
||||||
|
}
|
||||||
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||||
|
$massaction = '';
|
||||||
|
}
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook)) {
|
||||||
{
|
|
||||||
// Selection of new fields
|
// Selection of new fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||||
|
|
||||||
// Purge search criteria
|
// Purge search criteria
|
||||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||||
{
|
foreach ($object->fields as $key => $val) {
|
||||||
foreach ($object->fields as $key => $val)
|
|
||||||
{
|
|
||||||
$search[$key] = '';
|
$search[$key] = '';
|
||||||
}
|
}
|
||||||
$toselect = '';
|
$toselect = '';
|
||||||
$search_array_options = array();
|
$search_array_options = array();
|
||||||
}
|
}
|
||||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
|
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
|
||||||
{
|
|
||||||
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,13 +207,14 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")
|
|||||||
// Build and execute select
|
// Build and execute select
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
$sql = 'SELECT ';
|
$sql = 'SELECT ';
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val) {
|
||||||
{
|
|
||||||
$sql .= 't.'.$key.', ';
|
$sql .= 't.'.$key.', ';
|
||||||
}
|
}
|
||||||
// Add fields from extrafields
|
// Add fields from extrafields
|
||||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||||
|
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Add fields from hooks
|
// Add fields from hooks
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
@ -211,20 +222,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
|
|||||||
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
|
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
|
||||||
$sql = preg_replace('/,\s*$/', '', $sql);
|
$sql = preg_replace('/,\s*$/', '', $sql);
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
$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 (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||||
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
|
||||||
else $sql .= " WHERE 1 = 1";
|
}
|
||||||
foreach ($search as $key => $val)
|
if ($object->ismultientitymanaged == 1) {
|
||||||
{
|
$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
|
||||||
if ($key == 'status' && $search[$key] == -1) continue;
|
} else {
|
||||||
|
$sql .= " WHERE 1 = 1";
|
||||||
|
}
|
||||||
|
foreach ($search as $key => $val) {
|
||||||
|
if ($key == 'status' && $search[$key] == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
||||||
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
|
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
|
||||||
if ($search[$key] == '-1') $search[$key] = '';
|
if ($search[$key] == '-1') {
|
||||||
|
$search[$key] = '';
|
||||||
|
}
|
||||||
$mode_search = 2;
|
$mode_search = 2;
|
||||||
}
|
}
|
||||||
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
|
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);
|
||||||
}
|
}
|
||||||
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
|
||||||
// Add where from extra fields
|
// Add where from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||||
// Add where from hooks
|
// Add where from hooks
|
||||||
@ -253,26 +276,24 @@ $sql .= $db->order($sortfield, $sortorder);
|
|||||||
|
|
||||||
// Count total nb of records
|
// Count total nb of records
|
||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
{
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
$nbtotalofrecords = $db->num_rows($resql);
|
$nbtotalofrecords = $db->num_rows($resql);
|
||||||
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||||
{
|
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
||||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
|
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
|
||||||
{
|
|
||||||
$num = $nbtotalofrecords;
|
$num = $nbtotalofrecords;
|
||||||
} else {
|
} else {
|
||||||
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
|
if ($limit) {
|
||||||
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if (!$resql)
|
if (!$resql) {
|
||||||
{
|
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -281,8 +302,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Direct jump if only one record found
|
// Direct jump if only one record found
|
||||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
|
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$id = $obj->rowid;
|
$id = $obj->rowid;
|
||||||
header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id);
|
header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id);
|
||||||
@ -313,14 +333,24 @@ jQuery(document).ready(function() {
|
|||||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||||
|
|
||||||
$param = '';
|
$param = '';
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
$param .= '&contextpage='.urlencode($contextpage);
|
||||||
foreach ($search as $key => $val)
|
}
|
||||||
{
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
|
$param .= '&limit='.urlencode($limit);
|
||||||
else $param .= '&search_'.$key.'='.urlencode($search[$key]);
|
}
|
||||||
|
foreach ($search as $key => $val) {
|
||||||
|
if (is_array($search[$key]) && count($search[$key])) {
|
||||||
|
foreach ($search[$key] as $skey) {
|
||||||
|
$param .= '&search_'.$key.'[]='.urlencode($skey);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$param .= '&search_'.$key.'='.urlencode($search[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($optioncss != '') {
|
||||||
|
$param .= '&optioncss='.urlencode($optioncss);
|
||||||
}
|
}
|
||||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
|
||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
|
||||||
@ -329,12 +359,18 @@ $arrayofmassactions = array(
|
|||||||
//'presend'=>$langs->trans("SendByMail"),
|
//'presend'=>$langs->trans("SendByMail"),
|
||||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||||
);
|
);
|
||||||
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
if ($permissiontodelete) {
|
||||||
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
$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);
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') {
|
||||||
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
}
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
print '<input type="hidden" name="action" value="list">';
|
print '<input type="hidden" name="action" value="list">';
|
||||||
@ -363,11 +399,13 @@ $moreforfilter.= '</div>';*/
|
|||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
if (empty($reshook)) {
|
||||||
else $moreforfilter = $hookmanager->resPrint;
|
$moreforfilter .= $hookmanager->resPrint;
|
||||||
|
} else {
|
||||||
|
$moreforfilter = $hookmanager->resPrint;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($moreforfilter))
|
if (!empty($moreforfilter)) {
|
||||||
{
|
|
||||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||||
print $moreforfilter;
|
print $moreforfilter;
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -384,20 +422,26 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
|
|||||||
// Fields title search
|
// Fields title search
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val) {
|
||||||
{
|
|
||||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||||
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
if ($key == 'status') {
|
||||||
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||||
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||||
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||||
if (!empty($arrayfields['t.'.$key]['checked']))
|
} elseif (in_array($val['type'], array('timestamp'))) {
|
||||||
{
|
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||||
|
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
|
||||||
|
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||||
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
|
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
|
||||||
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
|
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
|
||||||
elseif (strpos($val['type'], 'integer:') === 0) {
|
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
|
||||||
|
} elseif (strpos($val['type'], 'integer:') === 0) {
|
||||||
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
|
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
|
||||||
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
|
||||||
|
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,15 +463,18 @@ print '</tr>'."\n";
|
|||||||
// Fields title label
|
// Fields title label
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val) {
|
||||||
{
|
|
||||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||||
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
if ($key == 'status') {
|
||||||
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||||
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||||
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||||
if (!empty($arrayfields['t.'.$key]['checked']))
|
} elseif (in_array($val['type'], array('timestamp'))) {
|
||||||
{
|
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||||
|
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
|
||||||
|
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||||
|
}
|
||||||
|
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||||
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
|
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,11 +491,11 @@ print '</tr>'."\n";
|
|||||||
|
|
||||||
// Detect if we need a fetch on each output line
|
// Detect if we need a fetch on each output line
|
||||||
$needToFetchEachLine = 0;
|
$needToFetchEachLine = 0;
|
||||||
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
|
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
|
||||||
{
|
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
|
if (preg_match('/\$object/', $val)) {
|
||||||
{
|
$needToFetchEachLine++; // There is at least one compute field that use $object
|
||||||
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,38 +504,51 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$totalarray = array();
|
$totalarray = array();
|
||||||
while ($i < ($limit ? min($num, $limit) : $num))
|
while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if (empty($obj)) break; // Should not happen
|
if (empty($obj)) {
|
||||||
|
break; // Should not happen
|
||||||
|
}
|
||||||
|
|
||||||
// Store properties in $object
|
// Store properties in $object
|
||||||
$object->setVarsFromFetchObj($obj);
|
$object->setVarsFromFetchObj($obj);
|
||||||
|
|
||||||
// Show here line of result
|
// Show here line of result
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val) {
|
||||||
{
|
|
||||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||||
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||||
|
} elseif ($key == 'status') {
|
||||||
|
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
if (in_array($val['type'], array('timestamp'))) {
|
||||||
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||||
|
} elseif ($key == 'ref') {
|
||||||
|
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) {
|
||||||
|
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||||
|
}
|
||||||
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
|
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
|
||||||
|
|
||||||
if (!empty($arrayfields['t.'.$key]['checked']))
|
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||||
{
|
|
||||||
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
||||||
if ($key == 'status') print $object->getLibStatut(5);
|
if ($key == 'status') {
|
||||||
else print $object->showOutputField($val, $key, $object->$key, '');
|
print $object->getLibStatut(5);
|
||||||
|
} else {
|
||||||
|
print $object->showOutputField($val, $key, $object->$key, '');
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
if (!empty($val['isameasure']))
|
$totalarray['nbfield']++;
|
||||||
{
|
}
|
||||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
|
if (!empty($val['isameasure'])) {
|
||||||
|
if (!$i) {
|
||||||
|
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
|
||||||
|
}
|
||||||
$totalarray['val']['t.'.$key] += $object->$key;
|
$totalarray['val']['t.'.$key] += $object->$key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -501,14 +561,17 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
|||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="nowrap center">';
|
print '<td class="nowrap center">';
|
||||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
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;
|
$selected = 0;
|
||||||
if (in_array($object->id, $arrayofselected)) $selected = 1;
|
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 '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
@ -520,10 +583,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
|||||||
|
|
||||||
|
|
||||||
// If no record found
|
// If no record found
|
||||||
if ($num == 0)
|
if ($num == 0) {
|
||||||
{
|
|
||||||
$colspan = 1;
|
$colspan = 1;
|
||||||
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
foreach ($arrayfields as $key => $val) {
|
||||||
|
if (!empty($val['checked'])) {
|
||||||
|
$colspan++;
|
||||||
|
}
|
||||||
|
}
|
||||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,10 +605,11 @@ print '</div>'."\n";
|
|||||||
|
|
||||||
print '</form>'."\n";
|
print '</form>'."\n";
|
||||||
|
|
||||||
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
|
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
|
||||||
{
|
|
||||||
$hidegeneratedfilelistifempty = 1;
|
$hidegeneratedfilelistifempty = 1;
|
||||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
|
||||||
|
$hidegeneratedfilelistifempty = 0;
|
||||||
|
}
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user