diff --git a/.gitignore b/.gitignore index 1efe4f4bb82..ca0334a63e9 100755 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ Thumbs.db # Vagrant generated files .vagrant # Composer installed repositories +composer.lock /htdocs/includes/**/.git # Composer autoloader and unwanted files htdocs/includes/autoload.php diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 0ca95ace51d..831aa15c68a 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -9,6 +9,7 @@ filter: - dev/* - doc/* - test/* + - htdocs/includes/* paths: - htdocs/* - scripts/* diff --git a/COPYRIGHT b/COPYRIGHT index 99d5a189f99..b8cf93e595a 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -27,7 +27,7 @@ PHPExcel 1.8.1 LGPL-2.1+ Yes php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests -Restler 3.0 LGPL-3+ Yes Library to develop REST Web services +Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services TCPDF 6.2.12 LGPL-3+ Yes PDF generation TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP diff --git a/ChangeLog b/ChangeLog index a009533f07a..21d3ebc66b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,8 +6,8 @@ WARNING: Do not try to make any Dolibarr upgrade if you are running Mysql version 5.5.40. Mysql version 5.5.40 has a very critical bug making your data beeing definitely lost. -You may also experience troubles with Mysql 5.5.41/42/43 with error "Lost connection" -during migration. +You may also experience troubles with Mysql 5.5.41/42/43 with error "Lost connection" during +migration. Upgrading to any other version or any other database system is abolutely required BEFORE trying make a Dolibarr upgrade. @@ -25,6 +25,8 @@ Dolibarr 4.0 should be compatible with PHP 7 but more feedbacks are still expect Following changes may create regression for some external modules, but were necessary to make Dolibarr better: - Function log() of class CommandeFournisseur has been removed. Using it is no more required. +- Class Resource was renamed into DolResource to avoid conflict with a reserved PHP word. +- Method commonobject->add_thumb() has been renamed into commonobject->addThumbs(). - Method select_type_comptes_financiers() has been renamed into selectTypeOfBankAccount() - Property ->client that was deprecated 6 years ago, is replaced in all core code with ->thirdparty. - File '/core/tpl/document_actions_pre_headers.tpl.php' were renamed into '/core/actions_linkedfiles.inc.php'. @@ -33,7 +35,6 @@ So if you included it into your module, change your code like this to be compati if (! $res) include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - ***** ChangeLog for 3.9.1 compared to 3.9.* ***** FIX: #3815 Call to undefined function local_by_date() FIX: #4424 Missing email of user popup in supplier orders area diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index a837450f077..8c6130437ac 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -32,7 +32,7 @@ AppPublisherURL=http://www.nltechno.com AppSupportURL=http://www.dolibarr.org AppUpdatesURL=http://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares. -AppCopyright=Copyright (C) 2008-2015 Laurent Destailleur, NLTechno +AppCopyright=Copyright (C) 2008-2016 Laurent Destailleur, NLTechno DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING @@ -80,7 +80,7 @@ Name: "desktopicon"; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm: Name: "{app}\logs" Name: "{app}\tmp" Name: "{app}\dolibarr_documents" -Name: "{app}\bin\apache\apache2.2.11\logs" +Name: "{app}\bin\apache\apache2.4.9\logs" [Files] ; Stop/start @@ -101,10 +101,10 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi ; Put here path of Wampserver applications ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 or 5.1.36 ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 or 5.1.36 -Source: "C:\Program Files\Wamp\apps\phpmyadmin3.2.0.1\*.*"; DestDir: "{app}\apps\phpmyadmin3.2.0.1"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" -Source: "C:\Program Files\Wamp\bin\apache\apache2.2.11\*.*"; DestDir: "{app}\bin\apache\apache2.2.11"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" -Source: "C:\Program Files\Wamp\bin\php\php5.3.0\*.*"; DestDir: "{app}\bin\php\php5.3.0"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" -Source: "C:\Program Files\Wamp\bin\mysql\mysql5.0.45\*.*"; DestDir: "{app}\bin\mysql\mysql5.0.45"; Flags: ignoreversion recursesubdirs; Excludes: "my.ini,data\*,wampserver.conf,*.log,*_log,MySQLInstanceConfig.exe" +Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" +Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" +Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" +Source: "C:\Program Files\Wamp\bin\mysql\mysql5.6.17\*.*"; DestDir: "{app}\bin\mysql\mysql5.6.17"; Flags: ignoreversion recursesubdirs; Excludes: "my.ini,data\*,wampserver.conf,*.log,*_log,MySQLInstanceConfig.exe" ; Mysql data files (does not overwrite if exists) Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mysql\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db" ; Dolibarr @@ -116,10 +116,10 @@ Source: "*.*"; DestDir: "{app}\www\dolibarr"; Flags: ignoreversion; Excludes: ". ; Config files Source: "build\exe\doliwamp\phpmyadmin.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; Source: "build\exe\doliwamp\dolibarr.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; -Source: "build\exe\doliwamp\config.inc.php.install"; DestDir: "{app}\apps\phpmyadmin3.2.0.1"; Flags: ignoreversion; -Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.2.11\conf"; Flags: ignoreversion; -Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mysql\mysql5.0.45"; Flags: ignoreversion; -Source: "build\exe\doliwamp\php.ini.install"; DestDir: "{app}\bin\php\php5.3.0"; Flags: ignoreversion; +Source: "build\exe\doliwamp\config.inc.php.install"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion; +Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.9\conf"; Flags: ignoreversion; +Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mysql\mysql5.5.12"; Flags: ignoreversion; +Source: "build\exe\doliwamp\php.ini.install"; DestDir: "{app}\bin\php\php5.6.17"; Flags: ignoreversion; Source: "build\exe\doliwamp\index.php.install"; DestDir: "{app}\www"; Flags: ignoreversion; Source: "build\exe\doliwamp\install.forced.php.install"; DestDir: "{app}\www\dolibarr\htdocs\install"; Flags: ignoreversion; Source: "build\exe\doliwamp\openssl.conf"; DestDir: "{app}"; Flags: ignoreversion; @@ -195,10 +195,10 @@ end; procedure InitializeWizard(); begin //version des applis, a modifier pour chaque version de WampServer 2 - apacheVersion := '2.2.11'; - phpVersion := '5.3.0' ; - mysqlVersion := '5.0.45'; - phpmyadminVersion := '3.2.0.1'; + apacheVersion := '2.4.9'; + phpVersion := '5.5.12' ; + mysqlVersion := '5.6.17'; + phpmyadminVersion := '4.1.14'; smtpServer := 'localhost'; apachePort := '80'; @@ -329,10 +329,10 @@ begin winPath := ExpandConstant('{win}'); pathWithSlashes := path; StringChange (pathWithSlashes, '\','/'); - datadirold := pathWithSlashes+'/bin/mysql/mysql5.0.45/data'; + datadirold := pathWithSlashes+'/bin/mysql/mysql5.6.17/data'; datadirnew := pathWithSlashes+'/bin/mysql/data'; - exedirold := pathWithSlashes+'/bin/mysql/mysql5.0.45'; - exedirnew := pathWithSlashes+'/bin/mysql/mysql5.0.45'; + exedirold := pathWithSlashes+'/bin/mysql/mysql5.6.17'; + exedirnew := pathWithSlashes+'/bin/mysql/mysql5.6.17'; // If we have a new database version, we should only copy old my.ini file into new directory // and change only all basedir= strings to use new version. Like this, data dir is still correct. @@ -663,6 +663,7 @@ begin //installDir et version de php StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True); StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True); + StringChangeEx (srcContents, 'WAMPMYSQLVERSION', myport, True); SaveStringToFile(destFile,srcContents, False); end @@ -1002,7 +1003,7 @@ Filename: "{app}\rundoliwamp.bat"; Description: {cm:LaunchNow}; Flags: shellexec [UninstallDelete] Type: files; Name: "{app}\*.*" -Type: files; Name: "{app}\bin\mysql\mysql5.0.45\*.*" +Type: files; Name: "{app}\bin\mysql\mysql5.6.17\*.*" Type: filesandordirs; Name: "{app}\alias" Type: filesandordirs; Name: "{app}\apps" Type: filesandordirs; Name: "{app}\bin\apache" diff --git a/build/exe/doliwamp/my.ini.install b/build/exe/doliwamp/my.ini.install index 40a764b6038..c855cc27a66 100644 --- a/build/exe/doliwamp/my.ini.install +++ b/build/exe/doliwamp/my.ini.install @@ -69,7 +69,7 @@ port=WAMPMYSQLPORT #Path to installation directory. All paths are usually resolved relative to this. -basedir=WAMPROOT/bin/mysql/mysql5.0.45 +basedir=WAMPROOT/bin/mysql/mysqlWAMPMYSQLVERSION #log file log-error=WAMPROOT/logs/mysql.log @@ -226,7 +226,7 @@ port=WAMPMYSQLPORT #Path to installation directory. All paths are usually resolved relative to this. -basedir=WAMPROOT/bin/mysql/mysql5.0.45 +basedir=WAMPROOT/bin/mysql/mysql5.6.17 #log file log-error=WAMPROOT/logs/mysql.log diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index b8c4f2fb475..45c8e0a6f42 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -379,7 +379,7 @@ if ($nboftargetok) { print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n"; $ret=`git tag -a -m "$MAJOR.$MINOR.$BUILD" "$MAJOR.$MINOR.$BUILD" 2>&1`; - if ($ret =~ /already exists/) + if ($ret =~ /(already exists|existe déjà)/) { print "WARNING: Tag ".$MAJOR.'.'.$MINOR.'.'.$BUILD." already exists. Overwrite (y/N) ? "; $QUESTIONOVERWRITETAG=; @@ -595,9 +595,12 @@ if ($nboftargetok) { if ($target eq 'TGZ') { $NEWDESTI=$DESTI; - mkdir($DESTI.'/standard'); - if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } - + if ($NEWPUBLISH =~ /stable/) + { + mkdir($DESTI.'/standard'); + if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } + } + print "Remove target $FILENAMETGZ.tgz...\n"; unlink("$NEWDESTI/$FILENAMETGZ.tgz"); @@ -624,8 +627,11 @@ if ($nboftargetok) { if ($target eq 'XZ') { $NEWDESTI=$DESTI; - mkdir($DESTI.'/standard'); - if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } + if ($NEWPUBLISH =~ /stable/) + { + mkdir($DESTI.'/standard'); + if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } + } print "Remove target $FILENAMEXZ.xz...\n"; unlink("$NEWDESTI/$FILENAMEXZ.xz"); @@ -658,8 +664,11 @@ if ($nboftargetok) { if ($target eq 'ZIP') { $NEWDESTI=$DESTI; - mkdir($DESTI.'/standard'); - if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } + if ($NEWPUBLISH =~ /stable/) + { + mkdir($DESTI.'/standard'); + if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } + } print "Remove target $FILENAMEZIP.zip...\n"; unlink("$NEWDESTI/$FILENAMEZIP.zip"); @@ -696,8 +705,11 @@ if ($nboftargetok) { if ($target =~ /FEDO/i) { $subdir="package_rpm_redhat-fedora"; } if ($target =~ /MAND/i) { $subdir="package_rpm_mandriva"; } if ($target =~ /OPEN/i) { $subdir="package_rpm_opensuse"; } - mkdir($DESTI.'/'.$subdir); - if (-d $DESTI.'/'.$subdir) { $NEWDESTI=$DESTI.'/'.$subdir; } + if ($NEWPUBLISH =~ /stable/) + { + mkdir($DESTI.'/'.$subdir); + if (-d $DESTI.'/'.$subdir) { $NEWDESTI=$DESTI.'/'.$subdir; } + } if ($RPMDIR eq "") { $RPMDIR=$ENV{'HOME'}."/rpmbuild"; } @@ -779,8 +791,11 @@ if ($nboftargetok) { if ($target eq 'DEB') { $NEWDESTI=$DESTI; - mkdir($DESTI.'/package_debian-ubuntu'); - if (-d $DESTI.'/package_debian-ubuntu') { $NEWDESTI=$DESTI.'/package_debian-ubuntu'; } + if ($NEWPUBLISH =~ /stable/) + { + mkdir($DESTI.'/package_debian-ubuntu'); + if (-d $DESTI.'/package_debian-ubuntu') { $NEWDESTI=$DESTI.'/package_debian-ubuntu'; } + } $olddir=getcwd(); @@ -979,8 +994,11 @@ if ($nboftargetok) { if ($target eq 'APS') { $NEWDESTI=$DESTI; - mkdir($DESTI.'/package_aps'); - if (-d $DESTI.'/package_aps') { $NEWDESTI=$DESTI.'/package_aps'; } + if ($NEWPUBLISH =~ /stable/) + { + mkdir($DESTI.'/package_aps'); + if (-d $DESTI.'/package_aps') { $NEWDESTI=$DESTI.'/package_aps'; } + } $newbuild = $BUILD; $newbuild =~ s/(dev|alpha)/0/gi; # dev @@ -1062,8 +1080,11 @@ if ($nboftargetok) { if ($target eq 'EXEDOLIWAMP') { $NEWDESTI=$DESTI; - mkdir($DESTI.'/package_windows'); - if (-d $DESTI.'/package_windows') { $NEWDESTI=$DESTI.'/package_windows'; } + if ($NEWPUBLISH =~ /stable/) + { + mkdir($DESTI.'/package_windows'); + if (-d $DESTI.'/package_windows') { $NEWDESTI=$DESTI.'/package_windows'; } + } print "Remove target $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe...\n"; unlink "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"; @@ -1195,8 +1216,8 @@ if ($nboftargetok) { $command="rsync -s -e 'ssh' \"$file\" \"".$destFolder."\""; print "$command\n"; - my $ret=`$command 2>&1`; - print "$ret\n"; + my $ret2=`$command 2>&1`; + print "$ret2\n"; } } } diff --git a/composer.json b/composer.json index f4ea5de0c73..ab60ce4f1b2 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "mike42/escpos-php": "dev-master", "mobiledetect/mobiledetectlib": "2.8.17", "phpoffice/phpexcel": "1.8.1", - "restler/framework": "^3.0", + "restler/framework": "3.0.0-RC6", "tecnickcom/tcpdf": "6.2.12" }, "require-dev": { diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 43a9f1d2d7c..00000000000 --- a/composer.lock +++ /dev/null @@ -1,420 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "c2b53c577364dbe3a56137043081b511", - "content-hash": "8f7a86cfbc13f45e13b73c49531818cb", - "packages": [ - { - "name": "ccampbell/chromephp", - "version": "4.1.0", - "source": { - "type": "git", - "url": "https://github.com/ccampbell/chromephp.git", - "reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ccampbell/chromephp/zipball/c3c297615d48ae5b2a86a82311152d1ed095fcef", - "reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "ChromePhp": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Craig Campbell", - "email": "iamcraigcampbell@gmail.com", - "homepage": "http://craig.is", - "role": "Developer" - } - ], - "description": "Log variables to the Chrome console (via Chrome Logger Google Chrome extension).", - "homepage": "http://github.com/ccampbell/chromephp", - "keywords": [ - "log", - "logging" - ], - "time": "2013-06-26 03:44:33" - }, - { - "name": "ckeditor/ckeditor", - "version": "dev-full/stable", - "source": { - "type": "git", - "url": "https://github.com/ckeditor/ckeditor-releases.git", - "reference": "e3eb254641c4c349ffc19e49bd4a1a6831b5b6d0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ckeditor/ckeditor-releases/zipball/e3eb254641c4c349ffc19e49bd4a1a6831b5b6d0", - "reference": "e3eb254641c4c349ffc19e49bd4a1a6831b5b6d0", - "shasum": "" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+", - "LGPL-2.1+", - "MPL-1.1+" - ], - "authors": [ - { - "name": "CKSource", - "homepage": "http://cksource.com" - } - ], - "description": "JavaScript WYSIWYG web text editor.", - "homepage": "http://ckeditor.com", - "keywords": [ - "CKEditor", - "editor", - "fckeditor", - "html", - "javascript", - "richtext", - "text", - "wysiwyg" - ], - "time": "2016-03-31 16:19:25" - }, - { - "name": "mike42/escpos-php", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/mike42/escpos-php.git", - "reference": "96f05cbf460f5b67c2184ee4e91aedfbcedeb788" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mike42/escpos-php/zipball/96f05cbf460f5b67c2184ee4e91aedfbcedeb788", - "reference": "96f05cbf460f5b67c2184ee4e91aedfbcedeb788", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "4.5.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "Mike42\\": "src/Mike42" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roni Saha", - "email": "roni.cse@gmail.com" - }, - { - "name": "Michael Billington", - "email": "michael.billington@gmail.com" - }, - { - "name": "Gergely Radics", - "email": "gerifield@ustream.tv" - }, - { - "name": "Warren Doyle", - "email": "w.doyle@fuelled.co" - }, - { - "name": "vharo", - "email": "vharo@geepok.com" - } - ], - "description": "Thermal receipt printer library, for use with ESC/POS compatible printers", - "homepage": "https://github.com/mike42/escpos-php", - "keywords": [ - "ESC-POS", - "driver", - "escpos", - "print", - "receipt" - ], - "time": "2016-03-27 23:08:27" - }, - { - "name": "mobiledetect/mobiledetectlib", - "version": "2.8.17", - "source": { - "type": "git", - "url": "https://github.com/serbanghita/Mobile-Detect.git", - "reference": "b87da5f63a76e9615a0c74fcf168657b1ea7e41d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/b87da5f63a76e9615a0c74fcf168657b1ea7e41d", - "reference": "b87da5f63a76e9615a0c74fcf168657b1ea7e41d", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "require-dev": { - "codeclimate/php-test-reporter": "dev-master", - "johnkary/phpunit-speedtrap": "~1.0@dev", - "phpunit/phpunit": "*" - }, - "type": "library", - "autoload": { - "classmap": [ - "Mobile_Detect.php" - ], - "psr-0": { - "Detection": "namespaced/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Serban Ghita", - "email": "serbanghita@gmail.com", - "homepage": "http://mobiledetect.net", - "role": "Developer" - } - ], - "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.", - "homepage": "https://github.com/serbanghita/Mobile-Detect", - "keywords": [ - "detect mobile devices", - "mobile", - "mobile detect", - "mobile detector", - "php mobile detect" - ], - "time": "2015-09-17 14:45:21" - }, - { - "name": "phpoffice/phpexcel", - "version": "1.8.1", - "source": { - "type": "git", - "url": "https://github.com/PHPOffice/PHPExcel.git", - "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32", - "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32", - "shasum": "" - }, - "require": { - "ext-xml": "*", - "ext-xmlwriter": "*", - "php": ">=5.2.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "PHPExcel": "Classes/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL" - ], - "authors": [ - { - "name": "Maarten Balliauw", - "homepage": "http://blog.maartenballiauw.be" - }, - { - "name": "Mark Baker" - }, - { - "name": "Franck Lefevre", - "homepage": "http://blog.rootslabs.net" - }, - { - "name": "Erik Tilt" - } - ], - "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", - "homepage": "http://phpexcel.codeplex.com", - "keywords": [ - "OpenXML", - "excel", - "php", - "spreadsheet", - "xls", - "xlsx" - ], - "time": "2015-05-01 07:00:55" - }, - { - "name": "restler/framework", - "version": "3.0.0", - "target-dir": "Luracast/Restler", - "source": { - "type": "git", - "url": "https://github.com/Luracast/Restler-Framework.git", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/6ee10b3e5dbc6376916fed55ec2340a37cce436b", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "replace": { - "luracast/restler": "3.*" - }, - "require-dev": { - "bshaffer/oauth2-server-php": "v1.0", - "luracast/explorer": "*", - "mustache/mustache": "dev-master", - "rodneyrehm/plist": "dev-master", - "symfony/yaml": "*", - "twig/twig": "v1.13.0", - "zendframework/zendamf": "dev-master" - }, - "suggest": { - "bshaffer/oauth2-server-php": "Restler can provide OAuth2 authentication using this library (see require-dev for details)", - "luracast/explorer": "Restler's very own api explorer (see require-dev for details)", - "mustache/mustache": "Restler can render HtmlView using mustache/handlebar templates (see require-dev for details)", - "rodneyrehm/plist": "Restler supports tho Apple plist xml format (see require-dev for details)", - "symfony/yaml": "Restler can produce content in yaml format as well (see require-dev for details)", - "twig/twig": "Restler can render HtmlView using twig templates (see require-dev for details)", - "zendframework/zendamf": "Support for the amf document format (see require-dev for details)" - }, - "type": "library", - "extra": { - "branch-alias": { - "master": "v3.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Luracast\\Restler": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1" - ], - "authors": [ - { - "name": "Luracast", - "email": "arul@luracast.com" - }, - { - "name": "Nick nickl- Lombard", - "email": "github@jigsoft.co.za" - } - ], - "description": "Just the Restler Framework without the tests and examples", - "homepage": "http://luracast.com/products/restler/", - "keywords": [ - "api", - "framework", - "rest", - "server" - ], - "time": "2015-08-04 07:52:49" - }, - { - "name": "tecnickcom/tcpdf", - "version": "6.2.12", - "source": { - "type": "git", - "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/2f732eaa91b5665274689b1d40b285a7bacdc37f", - "reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "fonts", - "config", - "include", - "tcpdf.php", - "tcpdf_parser.php", - "tcpdf_import.php", - "tcpdf_barcodes_1d.php", - "tcpdf_barcodes_2d.php", - "include/tcpdf_colors.php", - "include/tcpdf_filters.php", - "include/tcpdf_font_data.php", - "include/tcpdf_fonts.php", - "include/tcpdf_images.php", - "include/tcpdf_static.php", - "include/barcodes/datamatrix.php", - "include/barcodes/pdf417.php", - "include/barcodes/qrcode.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPLv3" - ], - "authors": [ - { - "name": "Nicola Asuni", - "email": "info@tecnick.com", - "homepage": "http://nicolaasuni.tecnick.com" - } - ], - "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", - "homepage": "http://www.tcpdf.org/", - "keywords": [ - "PDFD32000-2008", - "TCPDF", - "barcodes", - "datamatrix", - "pdf", - "pdf417", - "qrcode" - ], - "time": "2015-09-12 10:08:34" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "ckeditor/ckeditor": 20, - "mike42/escpos-php": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.0", - "ext-curl": "*" - }, - "platform-dev": [] -} diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 78f17dc1a63..6fbecbf2675 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -280,7 +280,7 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); - print '
'; + print ''; if ($optioncss != '') print ''; print ''; print ''; diff --git a/doc/images/dolibarr_screenshot1_1280x800.png b/doc/images/dolibarr_screenshot1_1280x800.png index 9aa799a10a7..684feb62390 100644 Binary files a/doc/images/dolibarr_screenshot1_1280x800.png and b/doc/images/dolibarr_screenshot1_1280x800.png differ diff --git a/doc/images/dolibarr_screenshot1_300x188.png b/doc/images/dolibarr_screenshot1_300x188.png index 9fab4daa8ef..b849e202206 100644 Binary files a/doc/images/dolibarr_screenshot1_300x188.png and b/doc/images/dolibarr_screenshot1_300x188.png differ diff --git a/doc/images/dolibarr_screenshot1_640x400.png b/doc/images/dolibarr_screenshot1_640x400.png index 3f0d38832e1..9efefcc2405 100644 Binary files a/doc/images/dolibarr_screenshot1_640x400.png and b/doc/images/dolibarr_screenshot1_640x400.png differ diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 94ce450ff30..2f7228eb9d4 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,6 +1,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,6 +49,8 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->chartofaccount) accessforbidden(); +// Load variable for pagination +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'sortorder'); $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -55,7 +58,7 @@ $page = GETPOST("page", 'int'); if ($page == - 1) { $page = 0; } -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) @@ -63,13 +66,31 @@ if (! $sortfield) if (! $sortorder) $sortorder = "ASC"; -if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); - print $formconfirm; -} - $accounting = new AccountingAccount($db); + +/* + * Actions + */ + +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction')) { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $search_account = ""; + $search_label = ""; + $search_accountparent = ""; + $search_pcgtype = ""; + $search_pcgsubtype = ""; +} + if ($action == 'disable') { if ($accounting->fetch($id)) { $result = $accounting->account_desactivate($id); @@ -89,21 +110,18 @@ if ($action == 'disable') { } } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $search_account = ""; - $search_label = ""; - $search_accountparent = ""; - $search_pcgtype = ""; - $search_pcgsubtype = ""; -} /* * View - * */ + llxHeader('', $langs->trans("ListAccounts")); +if ($action == 'delete') { + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); + print $formconfirm; +} + $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; @@ -128,8 +146,16 @@ if (strlen(trim($search_pcgtype))) { if (strlen(trim($search_pcgsubtype))) { $sql .= " AND aa.pcg_subtype like '%" . $search_pcgsubtype . "%'"; } - $sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/admin/account.php:: $sql=' . $sql); @@ -138,7 +164,15 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); + $params=''; + if ($search_account != "") $params.= '&search_account='.urlencode($search_account); + if ($search_label != "") $params.= '&search_label='.urlencode($search_label); + if ($search_accountparent != "") $params.= '&search_accountparent='.urlencode($search_accountparent); + if ($search_pcgtype != "") $params.= '&search_pcgtype='.urlencode($search_pcgtype); + if ($search_pcgsubtype != "") $params.= '&search_pcgsubtype='.urlencode($search_pcgsubtype); + if ($optioncss != '') $param.='&optioncss='.$optioncss; + + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords); $i = 0; @@ -147,19 +181,20 @@ if ($result) { print '
'; print '' . $langs->trans("Addanaccount") . ''; + print '' . $langs->trans("ApplyMassCategories") . ''; // print '' . $langs->trans("ImportAccount") . ''; // print '' . $langs->trans("CheckProductAccountancyCode") . ''; print '

'; print ''; print ''; - print_liste_field_titre($langs->trans("AccountNumber"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "aa.label", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Accountparent"), $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AccountNumber"), $_SERVER["PHP_SELF"], "aa.account_number", "", $params, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "aa.label", "", $params, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Accountparent"), $_SERVER["PHP_SELF"], "aa.account_parent", "", $params, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $params, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $params, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $params, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $params, "", 'width="60" align="center"', $sortfield, $sortorder); print ''; print ''; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index f1f1218f554..0d927b7305b 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -76,19 +76,17 @@ if ($action == 'add') { $res = $object->create($user); - if ($res == 0) { - } else { - if ($res == - 3) { - $error = 1; - $action = "create"; - } - if ($res == - 4) { - $error = 2; - $action = "create"; - } + if ($res == - 3) { + $error = 1; + $action = "create"; + } + if ($res == - 4) { + $error = 2; + $action = "create"; } } - Header("Location: account.php"); + header("Location: account.php"); + exit; } else if ($action == 'edit') { if (! GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); @@ -134,7 +132,8 @@ if ($action == 'add') { $result = $object->delete($user); if ($result > 0) { - Header("Location: account.php"); + header("Location: account.php"); + exit; } } diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php new file mode 100644 index 00000000000..f0013632b53 --- /dev/null +++ b/htdocs/accountancy/admin/categories.php @@ -0,0 +1,157 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/admin/categories.php + * \ingroup Advanced accountancy + * \brief Page to assign mass categories to accounts + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; + +$error = 0; + +// Langs +$langs->load("bills"); +$langs->load("accountancy"); + +$mesg = ''; +$action = GETPOST('action'); +$cat_id = GETPOST('account_category'); +$selectcpt = GETPOST('cpt_bk'); +$cpt_id = GETPOST('cptid'); + +if($cat_id == 0){ + $cat_id = null; +} + +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'int'); +$cancel = GETPOST('cancel'); + +// Security check +if (! $user->admin) + accessforbidden(); + +$AccCat = new AccountancyCategory($db); + +// si ajout de comptes +if(!empty($selectcpt)){ + $cpts = array(); + $i = 0; + foreach ($selectcpt as $selectedOption){ + $cpts[$i] = "'".$selectedOption."'"; + $i++; + } + + if($AccCat->updateAccAcc($cat_id, $cpts)){ + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + }else{ + setEventMessages($langs->trans('errors'), null, 'errors'); + } + + +} +if ($action == 'delete') { + if($cpt_id){ + if($AccCat->deleteCptCat($cpt_id)){ + setEventMessages($langs->trans('Deleted'), null, 'mesgs'); + }else{ + setEventMessages($langs->trans('errors'), null, 'errors'); + } + } +} + +/* + * View + */ +llxheader('', $langs->trans('AccountAccounting')); + +$formaccounting = new FormAccounting($db); +$form = new Form($db); + + print load_fiche_titre($langs->trans('Categories')); + + print '' . "\n"; + print ''; + print ''; + + dol_fiche_head(); + + print '
'; + // Category + print ''; + print ''; + + + if(!empty($cat_id)){ + $obj = $AccCat->getCptBK($cat_id); + print ''; + print ''; + } + + print '
' . $langs->trans("AccountingCategory") . ''; + $formaccounting->select_accounting_category($cat_id, 'account_category', 1); + print ''; + print '
' . $langs->trans("AddCompteFromBK") . ''; + if(!empty($obj)){ + print ' - '; + } + print '
'; + + dol_fiche_end(); + + print ''; + +if ($action == 'display' || $action == 'delete') { + + print ''; + + print ''; + + if(!empty($cat_id)){ + $obj = $AccCat->display($cat_id); + $j=1; + if(!empty($obj)){ + foreach ( $obj as $cpt ) { + $var = ! $var; + print ""; + print ''; + print ''; + print $form->formconfirm($_SERVER["PHP_SELF"]."?account_category=$cat_id&cptid=".$cpt->rowid, $langs->trans("DeleteCptCategory"), $langs->trans("ConfirmDeleteCptCategory"), "delete", '', 0, "action-delete".$j); + print ''; + print "\n"; + $j++; + } + } + } + + print "
'.$langs->trans("Numerocompte").''.$langs->trans("Description").'Action
' . length_accountg($cpt->account_number) . '' . $cpt->label . '
"; +} + +llxFooter(); + +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 75411d6402f..00cf70b9e73 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -27,6 +27,18 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; $action = GETPOST('action'); +// Load variable for pagination +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield="f.rowid"; // Set here default search field +if (! $sortorder) $sortorder="ASC"; + $langs->load("admin"); $langs->load("compta"); @@ -54,6 +66,8 @@ $object = new Fiscalyear($db); * Actions */ + + /* * View */ @@ -66,11 +80,20 @@ $title = $langs->trans('FiscalYears'); llxHeader('', $title, LOG_ERR); -print load_fiche_titre($langs->trans('FiscalYears')); - $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f"; $sql .= " WHERE f.entity = " . $conf->entity; +$sql.=$db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); if ($result) { @@ -78,6 +101,9 @@ if ($result) { $num = $db->num_rows($result); $i = 0; + + $title = $langs->trans('FiscalYears'); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit, 1); // Load attribute_label print ''; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index e04cc7132f0..c45700ce4f5 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,6 +53,7 @@ $object = new Fiscalyear($db); $date_start = dol_mktime(0, 0, 0, GETPOST('fiscalyearmonth', 'int'), GETPOST('fiscalyearday', 'int'), GETPOST('fiscalyearyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('fiscalyearendmonth', 'int'), GETPOST('fiscalyearendday', 'int'), GETPOST('fiscalyearendyear', 'int')); + /* * Actions */ @@ -143,10 +144,8 @@ llxHeader(); $form = new Form($db); -/* - * Action create - */ -if ($action == 'create') { +if ($action == 'create') +{ print load_fiche_titre($langs->trans("NewFiscalYear")); print '
'; @@ -172,7 +171,7 @@ if ($action == 'create') { // Statut print '
'; - print ''; + print ''; print ''; @@ -205,8 +204,8 @@ if ($action == 'create') { // Ref print ""; - print ''; // Label @@ -252,11 +251,11 @@ if ($action == 'create') { print '
' . $langs->trans("Statut") . '' . $langs->trans("Status") . ''; print $form->selectarray('statut', $statut2label, GETPOST('statut')); print '
' . $langs->trans("Ref") . ''; - print $object->rowid; + print '' . $langs->trans("Ref") . ''; + print $object->ref; print '
'; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; // Ref print ''; @@ -270,16 +269,16 @@ if ($action == 'create') { // Date start print ''; // Date end print ''; // Statut diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index c9041e2a848..7c85212ccb8 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -56,8 +56,9 @@ $list = array ( ); $list_account = array ( - 'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_SUPPLIER', + 'ACCOUNTING_ACCOUNT_CUSTOMER', + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'ACCOUNTING_SERVICE_BUY_ACCOUNT', @@ -67,7 +68,6 @@ $list_account = array ( 'ACCOUNTING_VAT_PAY_ACCOUNT', 'ACCOUNTING_ACCOUNT_SUSPENSE', 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'DONATION_ACCOUNTINGACCOUNT' ); @@ -219,10 +219,9 @@ print ""; print "\n"; foreach ( $list as $key ) { $var = ! $var; - + print ''; - + // Param $label = $langs->trans($key); print ''; - + // Value print ''; } else { - print ''; } @@ -442,7 +428,7 @@ if ($conf->produit->enabled) print "
' . $langs->trans("Ref") . ''; - print $object->rowid; + print $object->ref; print ''; print $linkback; print '
'; - print $form->editfieldkey("Date", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print ''; - print $form->editfieldval("Date", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print '
'; - print $form->editfieldkey("Date", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print ''; - print $form->editfieldval("Date", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print '
" . $langs->trans("Selectchartofaccounts") . ""; print '
'; print ''; @@ -118,11 +139,11 @@ print '
'; print ''; print ''; -print ''; +print ''; print "\n"; // Bank account -$sql = "SELECT rowid, label, accountancy_journal"; +$sql = "SELECT rowid, label, number, accountancy_journal"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; $sql .= " WHERE entity = " . $conf->entity; $sql .= " AND clos = 0"; @@ -132,29 +153,41 @@ $resql = $db->query($sql); if ($resql) { $numr = $db->num_rows($resql); $i = 0; - + if ($numr > 0) - - while ( $i < $numr ) { - $objp = $db->fetch_object($resql); + + $bankaccountstatic=new Account($db); + + while ( $i < $numr ) { + $objp = $db->fetch_object($resql); - $var = ! $var; + $var = ! $var; - print ''; + $bankaccountstatic->id = $objp->rowid; + $bankaccountstatic->label = $objp->label; + $bankaccountstatic->number = $objp->number; + $bankaccountstatic->accountancy_journal = $objp->accountancy_journal; - // Param - print ''; + print ''; - // Value - print ''; + // Param + print ''; - $i ++; - } -} else + // Value + print ''; + + $i ++; + } + $db->free($resql); +} +else +{ dol_print_error($db); -$db->free($resql); +} print "
' . $langs->trans('JournalFinancial') . '' . $langs->trans('JournalFinancial') . ' ('.$langs->trans('Opened').')
'; - print ''; - print '
'; + print ''; + print '
\n"; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index f94557ce0b0..973086e95b9 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -100,9 +100,11 @@ if (! empty($search_accountancy_code_end)) { $options .= '&search_accountancy_code_end=' . $search_accountancy_code_end; } + /* * Action */ + if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = 'bookkepping'; @@ -157,14 +159,26 @@ else { print '
'; print ''; - print '
'; - print $langs->trans('DateStart') . ': '; - print $form->select_date($search_date_start, 'date_start', 0, 0, 1); - print $langs->trans('DateEnd') . ': '; - print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - print '
'; + $moreforfilter=''; + + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('DateStart') . ': '; + $moreforfilter.=$form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); + $moreforfilter.=$langs->trans('DateEnd') . ': '; + $moreforfilter.=$form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); + $moreforfilter.='
'; - print ''; + if (! empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; + } + + print '
'; print ''; print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index f287c0ad9dd..6100e54c9a3 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -87,24 +87,8 @@ $formventilation = new FormVentilation($db); $formother = new FormOther($db); $form = new Form($db); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $search_mvt_num = ''; - $search_doc_type = ''; - $search_doc_ref = ''; - $search_doc_date = ''; - $search_accountancy_code = ''; - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_accountancy_aux_code = ''; - $search_accountancy_aux_code_start = ''; - $search_accountancy_aux_code_end = ''; - $search_mvt_label = ''; - $search_direction = ''; - $search_ledger_code = ''; - $search_date_start = ''; - $search_date_end = ''; -} + + if (empty($search_date_start)) { $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); @@ -178,9 +162,30 @@ if (! empty($search_mvt_num)) { $options .= '&search_mvt_num=' . $search_mvt_num; } + /* * Action */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_mvt_num = ''; + $search_doc_type = ''; + $search_doc_ref = ''; + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_accountancy_aux_code = ''; + $search_accountancy_aux_code_start = ''; + $search_accountancy_aux_code_end = ''; + $search_mvt_label = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; +} + if ($action == 'delbookkeeping') { $import_key = GETPOST('importkey', 'alpha'); @@ -193,7 +198,8 @@ if ($action == 'delbookkeeping') { Header("Location: list.php"); exit(); } -} elseif ($action == 'delbookkeepingyearconfirm') { +} +if ($action == 'delbookkeepingyearconfirm') { $delyear = GETPOST('delyear', 'int'); @@ -205,7 +211,8 @@ if ($action == 'delbookkeeping') { Header("Location: list.php"); exit(); } -} elseif ($action == 'delmouvconfirm') { +} +if ($action == 'delmouvconfirm') { $mvt_num = GETPOST('mvt_num', 'int'); @@ -217,7 +224,8 @@ if ($action == 'delbookkeeping') { Header("Location: list.php"); exit(); } -} elseif ($action == 'export_csv') { +} +if ($action == 'export_csv') { include DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; @@ -311,168 +319,166 @@ if ($action == 'delbookkeeping') { print "\n"; } } + + exit; } /* * View */ -else { - $title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); +$title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); - llxHeader('', $title_page); +llxHeader('', $title_page); - /* - * List - */ +// List - $nbtotalofrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); - if ($nbtotalofrecords < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); - if ($result < 0) { +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - - if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); - print $formconfirm; - } - if ($action == 'delbookkeepingyear') { - - $form_question = array (); - $delyear = GETPOST('delyear'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - - $form_question['delyear'] = array ( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); - print $formconfirm; - } - - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - - print ''; - print '
' . "\n"; - print '
'; - print ''; - print '
'; - - print '
'; - - print '
'; - print ''; - print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); - print "\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - - $var = True; - - $total_debit = 0; - $total_credit = 0; - - foreach ( $object->lines as $line ) { - $var = ! $var; - - $total_debit += $line->debit; - $total_credit += $line->credit; - - print ""; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print "
'; - print $langs->trans('From') . ': '; - print $form->select_date($search_date_start, 'date_start', 0, 0, 1); - print '
'; - print $langs->trans('to') . ': '; - print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - print '
'; - print $langs->trans('From'); - print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - print '
'; - print $langs->trans('to'); - print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); - print '
'; - print $langs->trans('From'); - print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - print '
'; - print $langs->trans('to'); - print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - print '
'; - print ''; - print '  '; - print ''; - print ' '; - print ''; - print '
' . $line->piece_num . '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . $line->code_journal . ''; - print '' . img_edit() . ' '; - print '' . img_delete() . ''; - print '
'; - print price($total_debit); - print ''; - print price($total_credit); - print '
"; - print ''; - - llxFooter(); } +$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); +if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); +} + +if ($action == 'delmouv') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); + print $formconfirm; +} +if ($action == 'delbookkeepingyear') { + + $form_question = array (); + $delyear = GETPOST('delyear'); + + if (empty($delyear)) { + $delyear = dol_print_date(dol_now(), '%Y'); + } + $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + + $form_question['delyear'] = array ( + 'name' => 'delyear', + 'type' => 'select', + 'label' => $langs->trans('DelYear'), + 'values' => $year_array, + 'default' => $delyear + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); + print $formconfirm; +} + +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); + +print '
'; +print '
' . "\n"; +print '
'; +print ''; +print '
'; + +print '
'; + +print ''; +print ''; +print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); +print "\n"; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; + +print ''; + +$var = True; + +$total_debit = 0; +$total_credit = 0; + +foreach ( $object->lines as $line ) { + $var = ! $var; + + $total_debit += $line->debit; + $total_credit += $line->credit; + + print ""; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; +} + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print "
'; +print $langs->trans('From') . ': '; +print $form->select_date($search_date_start, 'date_start', 0, 0, 1); +print '
'; +print $langs->trans('to') . ': '; +print $form->select_date($search_date_end, 'date_end', 0, 0, 1); +print '
'; +print $langs->trans('From'); +print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); +print '
'; +print $langs->trans('to'); +print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print '
'; +print $langs->trans('From'); +print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); +print '
'; +print $langs->trans('to'); +print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); +print '
'; +print ''; +print '  '; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
' . $line->piece_num . '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . $line->code_journal . ''; + print '' . img_edit() . ' '; + print '' . img_delete() . ''; + print '
'; +print price($total_debit); +print ''; +print price($total_credit); +print '
"; +print '
'; + +llxFooter(); + + $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 92ea01660ac..ef880aa8113 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -19,7 +19,7 @@ /** * \file htdocs/accountancy/class/accountancycategory.class.php * \ingroup Advanced accountancy - * \brief File of class to manage categories of an accounting account_category + * \brief File of class to manage categories of an accounting category_type */ // Class @@ -243,7 +243,7 @@ class AccountancyCategory } else { - $sql = "SELECT c.rowid, c.code, c.label, c.account_category "; + $sql = "SELECT c.rowid, c.code, c.label, c.category_type "; $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; $sql.= " WHERE c.active = 1 AND c.fk_country = co.rowid"; $sql.= " AND co.code = '".$mysoc->country_code."'"; @@ -343,7 +343,7 @@ class AccountancyCategory { $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position"; $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; - $sql.= " WHERE c.active = 1 AND c.account_category = 1 "; + $sql.= " WHERE c.active = 1 AND c.category_type = 1 "; $sql.= " AND c.fk_country = ".$mysoc->country_id; $sql.= " ORDER BY c.position ASC"; } @@ -351,7 +351,7 @@ class AccountancyCategory { $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position"; $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; - $sql.= " WHERE c.active = 1 AND c.account_category = 1 AND c.fk_country = co.rowid"; + $sql.= " WHERE c.active = 1 AND c.category_type = 1 AND c.fk_country = co.rowid"; $sql.= " AND co.code = '".$mysoc->country_code."'"; $sql.= " ORDER BY c.position ASC"; } diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index 37f843ec5a6..e3ae592a47f 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -123,7 +123,7 @@ class FormVentilation extends Form $options[$select_value_out] = $label; } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty); + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); $this->db->free($resql); return $out; } @@ -264,7 +264,7 @@ class FormVentilation extends Form // Build select $out = ajax_combobox($htmlname, $event); - $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty); + $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); return $out; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index c32846ae22e..c990465bacf 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -238,7 +238,7 @@ if ($result) { $paymentsalstatic->ref = $links[$key]['url_id']; $paymentsalstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); - $tabtp[$obj->rowid][$account_employee ] += $obj->amount; + $tabtp[$obj->rowid][$account_employee] += $obj->amount; } else if ($links[$key]['type'] == 'banktransfert') { $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); $tabtp[$obj->rowid][$account_transfer] += $obj->amount; @@ -418,12 +418,27 @@ if ($action == 'export_csv') { foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + $reflabel = $val["ref"]; + if ($reflabel == '(SupplierInvoicePayment)') { + $reflabel = $langs->trans('Supplier'); + } + if ($reflabel == '(CustomerInvoicePayment)') { + $reflabel = $langs->trans('Customer'); + } + if ($reflabel == '(SocialContributionPayment)') { + $reflabel = $langs->trans('SocialContribution'); + } + if ($reflabel == '(DonationPayment)') { + $reflabel = $langs->trans('Donation'); + } + if ($reflabel == '(SubscriptionPayment)') { + $reflabel = $langs->trans('Donation'); + } + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - // Bank foreach ( $tabbq[$key] as $k => $mt ) { print $date . $sep; @@ -432,8 +447,12 @@ if ($action == 'export_csv') { print $sep; print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print $val["type_payment"] . $sep; - print utf8_decode($val["ref"]) . $sep; + if ($companystatic->name == '') { + print $langs->trans('Bank')." - ". utf8_decode($val["ref"]) . $sep; + } else { + print $langs->trans("Bank") .' - '.utf8_decode($companystatic->name) . $sep; + } + print utf8_decode($reflabel) . $sep; print "\n"; } @@ -443,33 +462,45 @@ if ($action == 'export_csv') { if ($mt) { print $date . $sep; print $journal . $sep; - if ($val["lib"] == '(SupplierInvoicePayment)') { - print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; - } else { + if ($tabtype[$key] == 'payment') { print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep; + print length_accounta(html_entity_decode($k)) . $sep; + } else if ($tabtype[$key] == 'payment_supplier') { + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; + print length_accounta(html_entity_decode($k)) . $sep; + } else { + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; } - print length_accounta(html_entity_decode($k)) . $sep; print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print $val["type_payment"] . $sep; - print utf8_decode($val["ref"]) . $sep; + if ($companystatic->name == '') { + print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep; + } else { + print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep; + } + print utf8_decode($reflabel) . $sep; print "\n"; } } } else { foreach ( $tabbq[$key] as $k => $mt ) { - print $date . $sep; - print $journal . $sep; - print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . $sep; - print $sep; - print ($mt < 0 ? 'D' : 'C') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print $val["type_payment"] . $sep; - print utf8_decode($val["ref"]) . $sep; - print "\n"; + print $date . $sep; + print $journal . $sep; + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . $sep; + print $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + if ($companystatic->name == '') { + print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep; + } else { + print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep; } + print utf8_decode($reflabel) . $sep; + print "\n"; } } + } } else { // Model Classic Export foreach ( $tabpay as $key => $val ) { @@ -480,6 +511,7 @@ if ($action == 'export_csv') { // Bank foreach ( $tabbq[$key] as $k => $mt ) { + print '"' . $journal . '"' . $sep; print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; @@ -488,7 +520,6 @@ if ($action == 'export_csv') { } else { print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; } - // print '"' . $langs->trans("Bank") . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -498,10 +529,10 @@ if ($action == 'export_csv') { if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { if ($mt) { + print '"' . $journal . '"' . $sep; print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - // print '"' . $companystatic->name . '"' . $sep; if ($companystatic->name == '') { print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($val["ref"]) . '"' . $sep; } else { @@ -514,10 +545,10 @@ if ($action == 'export_csv') { } } else { foreach ( $tabbq[$key] as $k => $mt ) { + print '"' . $journal . '"' . $sep; print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - // print '"' . $langs->trans("Bank") . '"' . $sep; if ($companystatic->name == '') { print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($val["ref"]) . '"' . $sep; } else { @@ -599,6 +630,9 @@ else { if ($reflabel == '(DonationPayment)') { $reflabel = $langs->trans('Donation'); } + if ($reflabel == '(SubscriptionPayment)') { + $reflabel = $langs->trans('SubscriptionPayment'); + } // Bank foreach ( $tabbq[$key] as $k => $mt ) { diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index 8d629175902..a749ff269e5 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -48,7 +48,7 @@ abstract class ActionsAdherentCardCommon /** - * Instantiation of DAO class + * Instantiation of DAO class. Init ->object * * @return int 0 * @deprecated Using getInstanceDao should not be used. @@ -83,18 +83,18 @@ abstract class ActionsAdherentCardCommon */ function getObject($id) { - $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); } else - { + {*/ $object = new Adherent($this->db); if (! empty($id)) $object->fetch($id); $this->object = $object; - } + //} } /** @@ -121,11 +121,11 @@ abstract class ActionsAdherentCardCommon // Creation user $nuser = new User($this->db); - $result=$nuser->create_from_member($this->object,$_POST["login"]); + $result=$nuser->create_from_member($this->object,GETPOST("login")); if ($result > 0) { - $result2=$nuser->setPassword($user,$_POST["password"],0,1,1); + $result2=$nuser->setPassword($user,GETPOST("password"),0,1,1); if ($result2) { $this->db->commit(); @@ -424,13 +424,14 @@ abstract class ActionsAdherentCardCommon if ($resql) { $obj = $this->db->fetch_object($resql); + + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } else { dol_print_error($this->db); } - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 77437667c33..93b013cd29f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1577,7 +1577,7 @@ class Adherent extends CommonObject if ($withpicto) $result.=($link.img_object('', $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend; + $result.=$link.(($withpicto != 2) ? ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref) : '').$linkend; return $result; } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index aea09f73124..5878aac2755 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->load("members"); $langs->load("companies"); @@ -43,6 +44,14 @@ $search_ref=GETPOST("search_ref"); $search_lastname=GETPOST("search_lastname"); $search_firstname=GETPOST("search_firstname"); $search_login=GETPOST("search_login"); +$search_address=GETPOST("search_address"); +$search_zip=GETPOST("search_zip"); +$search_town=GETPOST("search_town"); +$search_state=GETPOST("search_state"); +$search_country=GETPOST("search_country"); +$search_phone=GETPOST("search_phone"); +$search_phone_perso=GETPOST("search_phone_perso"); +$search_phone_mobile=GETPOST("search_phone_mobile"); $type=GETPOST("type"); $search_email=GETPOST("search_email"); $search_categ = GETPOST("search_categ",'int'); @@ -50,6 +59,8 @@ $catid = GETPOST("catid",'int'); $sall=GETPOST("sall"); $optioncss = GETPOST('optioncss','alpha'); +if ($statut < -1) $statut = ''; + $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -61,31 +72,22 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $search=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_login=""; - $type=""; - $search_email=""; - $search_categ=""; - $catid=""; - $sall=""; -} - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('memberlist')); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('adherent'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'd.rowid'=>'Ref', //'d.ref'=>'Ref', 'd.lastname'=>'Lastname', 'd.firstname'=>'Firstname', - 'd.societe'=>"Company", + 'd.login'=>'Login', + 'd.societe'=>"Company", 'd.email'=>'EMail', 'd.address'=>'Address', 'd.zip'=>'Zip', @@ -93,7 +95,79 @@ $fieldstosearchall = array( 'd.note_public'=>'NotePublic', 'd.note_private'=>'NotePrivate', ); - +$arrayfields=array( + 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), + 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), + 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1), + 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), + 'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1), + 't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1), + 'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0), + 'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), + 'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), + 'd.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0), + 'd.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0), + 'd.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>0), + 'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), + /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0), + 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/ + 'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500), + 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + +/* + * Actions + */ + +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction')) { $massaction=''; } + +$parameters=array('socid'=>$socid); +$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'); + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search=""; + $search_ref=""; + $search_lastname=""; + $search_firstname=""; + $search_login=""; + $search_company=""; + $type=""; + $search_email=""; + $search_address=""; + $search_zip=""; + $search_town=""; + $search_state=""; + $search_country=''; + $search_phone=''; + $search_phone_perso=''; + $search_phone_mobile=''; + $search_morphy=""; + $search_categ=""; + $catid=""; + $sall=""; + $statut=''; + $search_array_options=array(); +} + /* * View @@ -109,9 +183,11 @@ llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhé $now=dol_now(); $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; -$sql.= " d.datefin,"; -$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; -$sql.= " t.libelle as type, t.cotisation"; +$sql.= " d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; +$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; +$sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; +$sql.= " t.libelle as type, t.cotisation,"; +$sql.= " state.code_departement as state_code, state.nom as state_name"; // Add fields for extrafields foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; // Add fields from hooks @@ -119,7 +195,10 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_adherent_type = t.rowid "; if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid); @@ -129,7 +208,7 @@ if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; $sql.= " AND d.entity IN (".getEntity('adherent', 1).")"; if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type); -if (isset($_GET["statut"]) || isset($_POST["statut"])) $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules +if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($search_ref) { if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")"; @@ -138,12 +217,31 @@ if ($search_ref) if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); if ($search_login) $sql.= natural_search("d.login", $search_login); if ($search_email) $sql.= natural_search("d.email", $search_email); +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_country) $sql .= " AND d.country IN (".$search_country.')'; if ($filter == 'uptodate') $sql.=" AND datefin >= '".$db->idate($now)."'"; if ($filter == 'outofdate') $sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')"; + +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; + $sql.= $db->order($sortfield,$sortorder); // Count total nb of records with no order and no limits @@ -187,14 +285,35 @@ if ($resql) } $param=''; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($statut != "") $param.="&statut=".$statut; - if ($search_nom) $param.="&search_nom=".$search_nom; - if ($search_login) $param.="&search_login=".$search_login; - if ($search_email) $param.="&search_email=".$search_email; - if ($filter) $param.="&filter=".$filter; - if ($type > 0) $param.="&type=".$type; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($statut != "") $param.="&statut=".urlencode($statut); + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_nom) $param.="&search_nom=".urlencode($search_nom); + if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); + if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); + if ($search_login) $param.="&search_login=".urlencode($search_login); + if ($search_email) $param.="&search_email=".urlencode($search_email); + 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 ($filter) $param.="&filter=".urlencode($filter); + if ($type > 0) $param.="&type=".urlencode($type); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } + + //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); print '
'; if ($optioncss != '') print ''; @@ -222,96 +341,259 @@ if ($resql) $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1); $moreforfilter.=''; } + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; if (! empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; + print ''; } - print ''; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'."\n"; print ''; if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + print ''; } - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"t.libelle",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder); - - $parameters=array(); + if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['d.company']['checked'])) 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($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_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 + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } + } + // Hook fields + $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans(""),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); - print "\n"; + 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.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,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; // Line for filters fields print ''; - print ''; + // Line numbering + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + { + print ''; + } + + // Ref + if (! empty($arrayfields['d.ref']['checked'])) + { + print ''; + } - print ''; + if (! empty($arrayfields['d.firstname']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['d.lastname']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['d.company']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['d.login']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['d.morphy']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['t.libelle']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['d.address']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['d.zip']['checked'])) + { + print ''; + } + if (! empty($arrayfields['d.town']['checked'])) + { + print ''; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print ''; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + } + // Phone pro + if (! empty($arrayfields['d.phone']['checked'])) + { + print ''; + } + // Phone perso + if (! empty($arrayfields['d.phone_perso']['checked'])) + { + print ''; + } + // Phone mobile + if (! empty($arrayfields['d.phone_mobile']['checked'])) + { + print ''; + } + // Email + if (! empty($arrayfields['d.email']['checked'])) + { + print ''; + } - print ''; - - print ''; - - print ''; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['d.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + } + // Status + if (! empty($arrayfields['d.statut']['checked'])) + { + print ''; + } + // Action column + print ''; - - print ''; - - print ''; - - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Status - print ''; - - // Action column - print ''; - + print "\n"; $var=True; while ($i < $num && $i < $conf->liste_limit) { - $objp = $db->fetch_object($resql); + $obj = $db->fetch_object($resql); - $datefin=$db->jdate($objp->datefin); - $memberstatic->id=$objp->rowid; - $memberstatic->ref=$objp->rowid; - $memberstatic->lastname=$objp->lastname; - $memberstatic->firstname=$objp->firstname; - $memberstatic->statut=$objp->statut; + $datefin=$db->jdate($obj->datefin); + $memberstatic->id=$obj->rowid; + $memberstatic->ref=$obj->rowid; + $memberstatic->lastname=$obj->lastname; + $memberstatic->firstname=$obj->firstname; + $memberstatic->societe=$obj->company; + $memberstatic->statut=$obj->statut; $memberstatic->datefin= $datefin; - - if (! empty($objp->fk_soc)) { - $memberstatic->socid = $objp->fk_soc; - $memberstatic->fetch_thirdparty(); + $memberstatic->socid = $obj->fk_soc; + + if (! empty($obj->fk_soc)) { + $memberstatic->fetch_thirdparty(); $companyname=$memberstatic->thirdparty->name; } else { - $companyname=$objp->company; + $companyname=$obj->company; } $var=!$var; @@ -322,85 +604,212 @@ if ($resql) print ''; } - // Ref - print "\n"; - + // Ref + if (! empty($arrayfields['d.ref']['checked'])) + { + print "\n"; + } // Lastname - print "\n"; - - // Login - print "\n"; - - // Type - $membertypestatic->id=$objp->type_id; - $membertypestatic->libelle=$objp->type; - print ''; - - // Moral/Physique - print "\n"; - + if (! empty($arrayfields['d.lastname']['checked'])) + { + print "\n"; + } + // Firstname + if (! empty($arrayfields['d.firstname']['checked'])) + { + print "\n"; + } + // Company + if (! empty($arrayfields['d.company']['checked'])) + { + print "\n"; + } + // Login + if (! empty($arrayfields['d.login']['checked'])) + { + print "\n"; + } + // Moral/Physique + if (! empty($arrayfields['d.morphy']['checked'])) + { + print "\n"; + } + // Type label + if (! empty($arrayfields['t.libelle']['checked'])) + { + $membertypestatic->id=$obj->type_id; + $membertypestatic->libelle=$obj->type; + print ''; + } + // Address + if (! empty($arrayfields['d.address']['checked'])) + { + print ''; + } + // Zip + if (! empty($arrayfields['d.zip']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Town + if (! empty($arrayfields['d.town']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Phone pro + if (! empty($arrayfields['d.phone']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Phone perso + if (! empty($arrayfields['d.phone_perso']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Phone mobile + if (! empty($arrayfields['d.phone_mobile']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // EMail - print "\n"; - - $parameters=array('obj' => $obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Statut - print '"; - + if (! empty($arrayfields['d.email']['checked'])) + { + print "\n"; + } // End of subscription date - if ($datefin) + $datefin=$db->jdate($obj->datefin); + if (! empty($arrayfields['d.datefin']['checked'])) { - print ''; + if ($datefin) + { + print ''; + } + else + { + print ''; + } } - else + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - print ''; + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } } - - // Actions + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['d.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['d.statut']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action column print '"; - + if (! $i) $totalarray['nbfield']++; + print "\n"; $i++; } diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index b7cc6e94bf2..29475d712df 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -62,21 +62,12 @@ if ($action == 'setcoder') } else if ($action == 'update') { - if (GETPOST('submit_GENBARCODE_LOCATION')) - { - $location = GETPOST('GENBARCODE_LOCATION','alpha'); - $res = dolibarr_set_const($db, "GENBARCODE_LOCATION",$location,'chaine',0,'',$conf->entity); - } - if (GETPOST('submit_PRODUIT_DEFAULT_BARCODE_TYPE')) - { - $coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE','alpha'); - $res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity); - } - if (GETPOST('submit_GENBARCODE_BARCODETYPE_THIRDPARTY')) - { - $coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha'); - $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity); - } + $location = GETPOST('GENBARCODE_LOCATION','alpha'); + $res = dolibarr_set_const($db, "GENBARCODE_LOCATION",$location,'chaine',0,'',$conf->entity); + $coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE','alpha'); + $res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity); + $coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha'); + $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity); } else if ($action == 'updateengine') { @@ -195,9 +186,9 @@ $var=true; print '
'; print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'',''); -print ""; -print ''; -print ""; +//print ""; +//print ''; +//print ""; print '
 '.$langs->trans("NumberingShort").'
  '; + print ''; + print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $listetype=$membertypestatic->liste_array(); + print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - $listetype=$membertypestatic->liste_array(); - print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); + if (! empty($arrayfields['d.datefin']['checked'])) + { + print ''; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + $liststatus=array( + '-1'=>$langs->trans("Draft"), + '1'=>$langs->trans("Validated"), + '0'=>$langs->trans("Resiliated") + ); + print $form->selectarray('statut', $liststatus, $statut, -2); + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; print ' '; - print ' '; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
'.($i+1).'"; - print $memberstatic->getNomUrl(1); - print ""; + print $memberstatic->getNomUrl(1); + print "rowid\">"; - print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); - print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : ''); - print (! empty($companyname) ? dol_trunc($companyname, 32) : ''); - print "".$objp->login."'; - print $membertypestatic->getNomUrl(1,32); - print '".$memberstatic->getmorphylib($objp->morphy).""; + print $obj->lastname; + print ""; + print $obj->firstname; + print ""; + print $companyname; + print "".$obj->login."".$memberstatic->getmorphylib($obj->morphy)."'; + print $membertypestatic->getNomUrl(1,32); + print ''; + print $obj->address; + print ''; + print $obj->zip; + print ''; + print $obj->town; + print '".$obj->state_name."'; + $tmparray=getCountry($obj->country,'all'); + print $tmparray['label']; + print ''; + print $obj->phone; + print ''; + print $obj->phone_perso; + print ''; + print $obj->phone_mobile; + print '".dol_print_email($objp->email,0,0,1)."'; - print $memberstatic->LibStatut($objp->statut,$objp->cotisation,$datefin,2); - print "".dol_print_email($obj->email,0,0,1)."'; - print dol_print_date($datefin,'day'); - if ($memberstatic->hasDelay()) { - print " ".img_warning($langs->trans("SubscriptionLate")); - } - print ''; + print dol_print_date($datefin,'day'); + if ($memberstatic->hasDelay()) { + print " ".img_warning($langs->trans("SubscriptionLate")); + } + print ''; + if ($obj->cotisation == 'yes') + { + print $langs->trans("SubscriptionNotReceived"); + if ($obj->statut > 0) print " ".img_warning(); + } + else + { + print ' '; + } + print ''; - if ($objp->cotisation == 'yes') - { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->statut > 0) print " ".img_warning(); - } - else - { - print ' '; - } - print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print ''; + print $memberstatic->LibStatut($obj->statut,$obj->cotisation,$datefin,2); + print ''; if ($user->rights->adherent->creer) { - print "rowid."&action=edit&backtopage=1\">".img_edit().""; + print "rowid."&action=edit&backtopage=1\">".img_edit().""; } print ' '; - if ($user->rights->adherent->supprimer && $objp->statut == -1) + if ($user->rights->adherent->supprimer && $obj->statut == -1) { - print "rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png').""; + print "rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png').""; } - if ($user->rights->adherent->supprimer && $objp->statut == 1) + if ($user->rights->adherent->supprimer && $obj->statut == 1) { - print "rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png').""; + print "rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png').""; } print "
'; print ''; @@ -261,7 +252,7 @@ if ($resql) // Build barcode on disk (not used, this is done to make debug easier) $result=$module->writeBarCode($obj->example,$obj->encoding,'Y'); // Generate on the fly and output barcode with generator - $url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); + $url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); //print $url; print ''; } @@ -296,7 +287,7 @@ if (empty($conf->use_javascript_ajax)) // TODO Implement code behind action updateengine //print '
'; } -print ''; +//print ''; print "
"; @@ -331,9 +322,7 @@ if (! isset($_SERVER['WINDIR'])) $langs->load("errors"); print '
'.$langs->trans("ErrorFileNotFound",$conf->global->GENBARCODE_LOCATION).''; } - print ''; - print ''; - print ''; + print ''; } // Module products @@ -344,10 +333,7 @@ if (! empty($conf->product->enabled)) print ''; print '"; - print ''; + print ''; } // Module thirdparty @@ -358,13 +344,13 @@ if (! empty($conf->societe->enabled)) print ''; print '"; - print ''; + print ''; } print "
'.$langs->trans("SetDefaultBarcodeTypeProducts").''; $formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"PRODUIT_DEFAULT_BARCODE_TYPE",1); - print ''; - print ''; - print "
'.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; print $formbarcode->select_barcode_type($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,"GENBARCODE_BARCODETYPE_THIRDPARTY",1); - print ''; - print ''; - print "
\n"; +print '
'; +print ''; +print "
"; print ''; print '
'; @@ -419,13 +405,13 @@ if ($conf->produit->enabled) if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") { - print '
'; + print ''; print img_picto($langs->trans("Activated"),'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"),'switch_off'); print '
\n"; } -print ''; +//print ''; print "
"; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index c9e07677512..ee6cbac057f 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -731,7 +731,9 @@ else $var=!$var; print ''.$langs->trans("CompanyCurrency").''; print currency_name($conf->currency,1); - print ' ('.$langs->getCurrencySymbol($conf->currency).')'; + print ' ('.$conf->currency; + print ($conf->currency != $langs->getCurrencySymbol($conf->currency) ? ' - '.$langs->getCurrencySymbol($conf->currency) : ''); + print ')'; print ''; $var=!$var; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ea745e45df7..797b35f7c75 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -188,8 +188,8 @@ $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREF $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; -$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, c.code as country_code, c.label as country, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_pays=c.rowid and c.active=1"; -$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; +$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; +$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; @@ -226,7 +226,7 @@ $tabsqlsort[28]="country ASC, code ASC"; $tabsqlsort[29]="position ASC"; $tabsqlsort[30]="code ASC"; $tabsqlsort[31]="pcg_version ASC"; -$tabsqlsort[32]="code ASC, label ASC"; +$tabsqlsort[32]="position ASC"; $tabsqlsort[33]="code ASC"; $tabsqlsort[34]="code ASC"; @@ -262,8 +262,8 @@ $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; $tabfield[29]= "code,label,percent,position"; $tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; -$tabfield[31]= "pcg_version,country_id,country,label"; -$tabfield[32]= "code,label,range,position,country_id,country"; +$tabfield[31]= "pcg_version,label"; +$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country"; $tabfield[33]= "code,label"; $tabfield[34]= "code,label"; @@ -299,8 +299,8 @@ $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; $tabfieldvalue[29]= "code,label,percent,position"; $tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; -$tabfieldvalue[31]= "pcg_version,country,label"; -$tabfieldvalue[32]= "code,label,range_account,position,country"; +$tabfieldvalue[31]= "pcg_version,label"; +$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country"; $tabfieldvalue[33]= "code,label"; $tabfieldvalue[34]= "code,label"; @@ -336,8 +336,8 @@ $tabfieldinsert[27]= "code,libelle"; $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; $tabfieldinsert[29]= "code,label,percent,position"; $tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; -$tabfieldinsert[31]= "pcg_version,fk_pays,label"; -$tabfieldinsert[32]= "code,label,range_account,position,fk_country"; +$tabfieldinsert[31]= "pcg_version,label"; +$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; $tabfieldinsert[33]= "code,label"; $tabfieldinsert[34]= "code,label"; @@ -524,6 +524,7 @@ if ($id == 11) 'propal' => $langs->trans('Proposal'), 'commande' => $langs->trans('Order'), 'facture' => $langs->trans('Bill'), + 'resource' => $langs->trans('Resource'), // 'facture_fourn' => $langs->trans('SupplierBill'), 'fichinter' => $langs->trans('InterventionCard') ); @@ -585,6 +586,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; if ($value == 'color' && empty($_POST['color'])) continue; + if ($value == 'formula' && empty($_POST['formula'])) continue; if ((! isset($_POST[$value]) || $_POST[$value]=='') && (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy'))) // Fields that are not mandatory ) @@ -605,6 +607,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode'; if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible'; if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder'; + if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated'; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } @@ -999,6 +1002,9 @@ if ($id) if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } + if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } if ($id == 2) // Special cas for state page { @@ -1064,7 +1070,7 @@ if ($id) } print ''; print ""; - + if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates') { print '* '.$langs->trans("AvailableVariables").": "; @@ -1167,6 +1173,9 @@ if ($id) if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } + if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } // Affiche nom du champ if ($showfield) @@ -1248,7 +1257,7 @@ if ($id) $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); } } - else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm' || $fieldlist[$field] == 'deductible') { + else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { $valuetoshow=yn($valuetoshow); $align="center"; } @@ -1618,7 +1627,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print 'user'; print ''; } - elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') { + elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { print ''; print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1); print ''; @@ -1697,7 +1706,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($fieldlist[$field]=='position') $size='size="4" '; if ($fieldlist[$field]=='libelle') $size='centpercent'; if ($fieldlist[$field]=='tracking') $class='centpercent'; - if ($fieldlist[$field]=='sortorder') $size='size="2" '; + if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; print ''; print ''; } diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index b5bd4d045f6..e244941ff58 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -189,7 +189,19 @@ else show_skin(null,1); print '
'."\n"; - print load_fiche_titre($langs->trans("TestSubmitForm"),'(mode='.$mode.')',''); + $listofmodes=array('dolibarr_mailings','dolibarr_notes','dolibarr_details','Full'); + $linkstomode=''; + foreach($listofmodes as $newmode) + { + if ($linkstomode) $linkstomode.=' - '; + $linkstomode.=''; + if ($mode == $newmode) $linkstomode.=''; + $linkstomode.=$newmode; + if ($mode == $newmode) $linkstomode.=''; + $linkstomode.=''; + } + $linkstomode.=''; + print load_fiche_titre($langs->trans("TestSubmitForm"),$linkstomode,''); print ''; $uselocalbrowser=true; $readonly=($mode=='dolibarr_readonly'?1:0); diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index 1cc55bd5a36..3213503835d 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ require '../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; $langs->load("admin"); $langs->load("loan"); @@ -76,6 +77,7 @@ if ($action == 'update') llxHeader(); $form = new Form($db); +if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigLoan'),$linkback,'title_setup'); @@ -104,7 +106,14 @@ foreach ($list as $key) // Value print ''; - print ''; + if (! empty($conf->accounting->enabled)) + { + print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1); + } + else + { + print ''; + } print ''; } diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index f4f1bbb96bf..5fc39432c8e 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -75,6 +75,7 @@ if ($action == 'update') $menu->perms=$_POST['perms']; $menu->target=$_POST['target']; $menu->user=$_POST['user']; + $menu->fk_menu=$_POST['fk_menu']; $result=$menu->update($user); if ($result > 0) { @@ -275,6 +276,8 @@ if ($action == 'create') print '
'; print ''; + dol_fiche_head(); + print ''; // Id @@ -368,8 +371,10 @@ if ($action == 'create') print '
'; + dol_fiche_end(); + // Boutons - print '
'; + print '
'; print ''; print '     '; print ''; @@ -387,6 +392,8 @@ elseif ($action == 'edit') print ''; print ''; + dol_fiche_head(); + print ''; $menu = new Menubase($db); @@ -416,9 +423,9 @@ elseif ($action == 'edit') // MenuId Parent print ''; + print ''; //$menu_handler //print ''; - print ''; print ''; // Niveau @@ -454,8 +461,10 @@ elseif ($action == 'edit') print '
'.$langs->trans('MenuIdParent').''.$menu->fk_menu.''.$langs->trans('DetailMenuIdParent').'
'; + dol_fiche_end(); + // Bouton - print '
'; + print '
'; print ''; print '     '; print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 3b968af09c3..b22ad287302 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -63,6 +63,7 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'',$conf->entity); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -94,6 +95,13 @@ $form=new Form($db); $formother=new FormOther($db); $formadmin=new FormAdmin($db); +$arraydetailsforpdffoot = array( + 0 => $langs->trans('NoDetails'), + 1 => $langs->trans('DisplayCompanyInfo'), + 2 => $langs->trans('DisplayManagersInfo'), + 3 => $langs->trans('DisplayCompanyInfoAndManagers') +); + print load_fiche_titre($langs->trans("PDF"),'','title_setup'); print $langs->trans("PDFDesc")."
\n"; @@ -253,7 +261,11 @@ if ($action == 'edit') // Edit print ''.$langs->trans("PlaceCustomerAddressToIsoLocation").''; print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION',(! empty($conf->global->MAIN_PDF_USE_ISO_LOCATION))?$conf->global->MAIN_PDF_USE_ISO_LOCATION:0,1); print ''; - + + $var=!$var; + print ''.$langs->trans("ShowDetailsInPDFPageFoot").''; + print $form->selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS); + print ''; print ''; @@ -455,6 +467,11 @@ else // Show print ''.$langs->trans("PlaceCustomerAddressToIsoLocation").''; print yn($conf->global->MAIN_PDF_USE_ISO_LOCATION,1); print ''; + + $var=!$var; + print ''.$langs->trans("ShowDetailsInPDFPageFoot").''; + print $arraydetailsforpdffoot[$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS]; + print ''; print ''; diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 588170fbb90..5a142f3e51e 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -119,19 +119,19 @@ function create_script_table($list) global $sortby,$bc,$langs; $var=true; - if (isset($_GET['order']) && ($_GET['order'] == "asc" || $_GET['order'] =="desc")) { - $order = $_GET['order']; + if (GETPOT('order') == "asc" || GETPOST('order') =="desc") { + $order = GETPOST('order'); } else { $order = "asc"; } - if (isset($_GET['sort'])) { - switch ($_GET['sort']) { + if (GETPOST('order')) { + switch (GETPOST('order')) { case "mtime": case "size": case "reloads": case "hits": - $sortby = $_GET['sort']; + $sortby = GETPOST('sort'); ($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare')); break; default: diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index b827fe88737..175aaa65665 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -318,7 +318,7 @@ function backup_tables($outputfile, $tables='*') $columns = count($row); for($j=0; $j<$columns; $j++) { // Processing each columns of the row to ensure that we correctly save the value (eg: add quotes for string - in fact we add quotes for everything, it's easier) - if ($row[$j] == null and !is_string($row[$j])) { + if ($row[$j] == null && !is_string($row[$j])) { // IMPORTANT: if the field is NULL we set it NULL $row[$j] = 'NULL'; } elseif(is_string($row[$j]) && $row[$j] == '') { diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 3db5dd93e49..ecc6b6a0166 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -417,14 +417,7 @@ if ($id) if (empty($reshook)) { - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') - { - fieldList($fieldlist,$obj,$tabname[$id],'hide'); - } - else - { - fieldList($fieldlist,$obj,$tabname[$id],'add'); - } + fieldListWebsites($fieldlist,$obj,$tabname[$id],'add'); } if ($id == 4) print ''; @@ -487,46 +480,9 @@ if ($id) */ $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $align='right'; - } - if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $sortable=0; } - if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $sortable=0; } - if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { - $valuetoshow=$langs->trans("Label"); - if ($id != 25) $valuetoshow.="*"; - } - if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; } - if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } - if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } - if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } - if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } - if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); } - if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } - if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } - if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; } - if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); } - if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } - if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } - if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } // Affiche nom du champ if ($showfield) @@ -534,8 +490,6 @@ if ($id) print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); } } - // Favorite - Only activated on country dictionary - if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"),0,$_SERVER["PHP_SELF"],"favorite",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList(''); @@ -562,7 +516,7 @@ if ($id) $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); + if (empty($reshook)) fieldListWebsites($fieldlist,$obj,$tabname[$id],'edit'); print ' '; print ' '; @@ -582,172 +536,6 @@ if ($id) $showfield=1; $align="left"; $valuetoshow=$obj->$fieldlist[$field]; - if ($value == 'type_template') - { - $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; - } - if ($value == 'element') - { - $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; - } - else if ($value == 'source') - { - $valuetoshow = isset($sourceList[$valuetoshow])?$sourceList[$valuetoshow]:$valuetoshow; - } - else if ($valuetoshow=='all') { - $valuetoshow=$langs->trans('All'); - } - else if ($fieldlist[$field]=='country') { - if (empty($obj->country_code)) - { - $valuetoshow='-'; - } - else - { - $key=$langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); - } - } - else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm' || $fieldlist[$field] == 'deductible') { - $valuetoshow=yn($valuetoshow); - $align="center"; - } - else if ($fieldlist[$field]=='price' || preg_match('/^amount/i',$fieldlist[$field])) { - $valuetoshow=price($valuetoshow); - } - else if ($fieldlist[$field]=='libelle_facture') { - $langs->load("bills"); - $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - $valuetoshow=nl2br($valuetoshow); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { - $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { - $langs->load("propal"); - $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { - $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { - $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { - $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { - $langs->load('agenda'); - $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { - $langs->load("bills"); - $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { - $langs->load("bills"); - $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { - $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { - $langs->load("orders"); - $key=$langs->trans($obj->code); - $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field]; - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { - $langs->load("sendings"); - $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') - { - $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); - } - else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') - { - $langs->load('trips'); - $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { - $showfield=0; - } - else if ($fieldlist[$field]=='unicode') { - $valuetoshow = $langs->getCurrencySymbol($obj->code,1); - } - else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { - $langs->load("products"); - $valuetoshow=$langs->trans($obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { - $langs->load("products"); - $valuetoshow = $langs->trans($obj->$fieldlist[$field]); - } - else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) - { - $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]); - } - - else if ($fieldlist[$field]=='localtax1_type') { - if ($obj->localtax1 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; - else - $valuetoshow = ''; - $align="center"; - } - else if ($fieldlist[$field]=='localtax2_type') { - if ($obj->localtax2 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; - else - $valuetoshow = ''; - $align="center"; - } - else if ($fieldlist[$field]=='localtax1') { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - if ($obj->localtax1 == 0) - $valuetoshow = ''; - $align="right"; - } - else if ($fieldlist[$field]=='localtax2') { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - if ($obj->localtax2 == 0) - $valuetoshow = ''; - $align="right"; - } - else if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) - { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - $align="right"; - } - else if (in_array($fieldlist[$field],array('recuperableonly'))) - { - $align="center"; - } - else if ($fieldlist[$field]=='accountancy_code' || $fieldlist[$field]=='accountancy_code_sell' || $fieldlist[$field]=='accountancy_code_buy') { - $valuetoshow = length_accountg($valuetoshow); - } // Show value for field if ($showfield) print ''.$valuetoshow.''; @@ -757,16 +545,6 @@ if ($id) // Can an entry be erased or disabled ? $iserasable=1;$isdisable=1; // true by default - if (isset($obj->code) && $id != 10) - { - if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $isdisable = 0; } - else if ($obj->code == 'RECEP') { $iserasable = 0; $isdisable = 0; } - else if ($obj->code == 'EF0') { $iserasable = 0; $isdisable = 0; } - } - - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; } - if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $isdisable=0; $isdisable = 0; } - $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; // Favorite @@ -823,7 +601,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldList($fieldlist, $obj='', $tabname='', $context='') +function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='') { global $conf,$langs,$db; global $form; diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 44a14f99675..66d06e91679 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -150,12 +150,30 @@ $linkback=''.$langs->trans("BackToM print load_fiche_titre($langs->trans("ApiSetup"),$linkback,'title_setup'); +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + +// Show message +print '
'; +$message=''; +$url='
'.$urlwithroot.'/api/index.php/login?login='.urlencode($user->login).'&password=yourpassword'; +$message.=$langs->trans("UrlToGetKeyToUseAPIs").':
'; +$message.=img_picto('','object_globe.png').' '.$url; +print $message; +print '
'; +print '
'; + +print $langs->trans("ListOfAvailableAPIs").':
'; foreach($listofapis['v1'] as $key => $val) { + if ($key == 'login') continue; if ($key) { //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
\n"; - $url=DOL_MAIN_URL_ROOT.'/api/index.php/'.$key; + $url=$urlwithroot.'/api/index.php/'.$key; + $url.='?api_key=token'; print img_picto('','object_globe.png').' '.$url."
\n"; } diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index a5020d4e112..bc5b4378c0c 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -167,6 +167,8 @@ class DolibarrApiInit extends DolibarrApi */ public function login($login, $password, $entity = 0) { + global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; + // Authentication mode if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 9d29c60e26a..bebf9a6667b 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -70,6 +70,7 @@ class DolibarrApiAccess implements iAuthenticate { global $db; + $login = ''; $stored_key = ''; $userClass = Defaults::$userIdentifierClass; @@ -95,11 +96,15 @@ class DolibarrApiAccess implements iAuthenticate throw new RestException(503, 'Error when fetching user api_key :'.$db->error_msg); } - if ( $stored_key != $_GET['api_key']) { + if ($stored_key != $_GET['api_key']) { $userClass::setCacheIdentifier($_GET['api_key']); return false; } + if (! $login) + { + throw new RestException(503, 'Error when searching logn user fro mapi key'); + } $fuser = new User($db); if(! $fuser->fetch('',$login)) { throw new RestException(503, 'Error when fetching user :'.$fuser->error); @@ -116,16 +121,13 @@ class DolibarrApiAccess implements iAuthenticate else { throw new RestException(401, "Failed to login to API. No parameter 'api_key' provided"); - //dol_syslog("Failed to login to API. No parameter key provided", LOG_DEBUG); - //return false; } - $userClass::setCacheIdentifier(static::$role); - Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; - - $requirefortest = static::$requires; - if (! is_array($requirefortest)) $requirefortest=explode(',',$requirefortest); - return in_array(static::$role, (array) static::$requirefortest) || static::$role == 'admin'; + $userClass::setCacheIdentifier(static::$role); + Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; + $requirefortest = static::$requires; + if (! is_array($requirefortest)) $requirefortest=explode(',',$requirefortest); + return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin'; } /** diff --git a/htdocs/api/index.php b/htdocs/api/index.php index d7bcedb5fd7..55a45aea4b9 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -141,6 +141,8 @@ foreach ($modulesdir as $dir) // TODO If not found, redirect to explorer + +// Call API (we suppose we found it) $api->r->handle(); diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 3a5b54519a8..4a892f909e5 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -59,7 +59,7 @@ top_htmlhead('','',0,0,'',$arrayofcss);
diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index e17bb273758..f5a5b1f037d 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -45,6 +45,7 @@ class CategoryApi extends DolibarrApi 2 => 'customer', 3 => 'member', 4 => 'contact', + 5 => 'account', ); /** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4cd38a693b6..b602bc0076d 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016 Charlie Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,6 +49,8 @@ class Categorie extends CommonObject const TYPE_MEMBER = 3; const TYPE_CONTACT = 4; const TYPE_USER = 4; // categorie contact and user are same + // bank account + const TYPE_ACCOUNT = 5; /** * @var array ID mapping from type string @@ -62,6 +64,7 @@ class Categorie extends CommonObject 'member' => 3, 'contact' => 4, 'user' => 4, + 'account' => 5, ); /** * @var array Foreign keys mapping from type string @@ -75,6 +78,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'socpeople', 'user' => 'user', + 'account' => 'account', ); /** * @var array Category tables mapping from type string @@ -88,6 +92,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'contact', 'user' => 'user', + 'account' => 'account', ); /** * @var array Object class mapping from type string @@ -101,6 +106,7 @@ class Categorie extends CommonObject 'member' => 'Adherent', 'contact' => 'Contact', 'user' => 'User', + 'account' => 'Account', ); /** * @var array Object table mapping from type string @@ -114,6 +120,7 @@ class Categorie extends CommonObject 'member' => 'adherent', 'contact' => 'socpeople', 'user' => 'user', + 'account' => 'bank_account', ); public $element='category'; @@ -138,6 +145,8 @@ class Categorie extends CommonObject * @see Categorie::TYPE_CUSTOMER * @see Categorie::TYPE_MEMBER * @see Categorie::TYPE_CONTACT + * @see Categorie::TYPE_USER + * @see Categorie::TYPE_ACCOUNT */ var $type; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 02b83fcaef8..f7102bc44e2 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -53,6 +53,7 @@ elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCateg elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoriesArea"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoriesArea"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactsCategoriesArea"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesArea"); else $title=$langs->trans("CategoriesArea"); $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 783326c1e4f..72c184af113 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -93,12 +93,13 @@ $form = new Form($db); if ($object->id) { - $title=$langs->trans("ProductsCategoryShort"); if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); + elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); + else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); dol_fiche_head($head, 'photos', $title, 0, 'category'); diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index f3969793ef0..9d88098e56b 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -149,6 +149,7 @@ elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCateg elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index a1486ff344f..284add47add 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -107,7 +107,14 @@ if ($id > 0 && $removeelem > 0) $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; - } + } + else if ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $tmpobject = new Account($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'account'; + } $result=$object->del_type($tmpobject,$elementtype); if ($result < 0) dol_print_error('',$object->error); @@ -169,6 +176,7 @@ elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCateg elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); @@ -580,6 +588,59 @@ if($object->type == Categorie::TYPE_CONTACT) } } +// List of accounts +if ($object->type == Categorie::TYPE_ACCOUNT) +{ + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $accounts = $object->getObjectsInCateg("account"); + if ($accounts < 0) + { + dol_print_error($db, $accounts->error, $accounts->errors); + } + else + { + print "
"; + print "\n"; + print '\n"; + + if (count($accounts) > 0) + { + $var=true; + foreach ($accounts as $key => $account) + { + $var=!$var; + print "\t\n"; + print '\n"; + print '\n"; + print '\n"; + // Link to delete from category + print '\n"; + } + } + else + { + print ""; + } + print "
'.$langs->trans("Account")."
'; + print $account->getNomUrl(1,0); + print "'.$account->bank."'.$account->number."'; + $typeid=$object->type; + $permission=0; + if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer; + if ($permission) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + print "
'.$langs->trans("ThisCategoryHasNoAccount")."
\n"; + } +} llxFooter(); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 9734602c41d..7a2f231879d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1173,7 +1173,7 @@ if ($id > 0) // Clone event if($action == 'clone') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . GETPOST('id'), $langs->trans('CloneAction'), $langs->trans('ConfirmCloneAction', $object->label), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . GETPOST('id'), $langs->trans('CloneAction'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', $formquestion, 'yes', 1); print $formconfirm; } diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index cfb3bc92333..1f597ffeddc 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -308,8 +308,8 @@ if ($resql) print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ActionsOwnedByShort"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre(""); print "\n"; @@ -432,7 +432,7 @@ if ($resql) print ''; // Status/Percent - print ''.$actionstatic->LibStatut($obj->percent,6).''; + print ''.$actionstatic->LibStatut($obj->percent,6).''; print ''; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 17098310769..38447c17c5e 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -961,82 +961,84 @@ if ($id > 0) * Barre d'actions */ + print '
'; + $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - - print '
'; - - if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1) - { - $langs->load("propal"); - print ''; - } - - if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1) - { - $langs->load("orders"); - print ''; - } - - if ($user->rights->contrat->creer && $object->status==1) - { - $langs->load("contracts"); - print ''; - } - - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1) - { - $langs->load("fichinter"); - print ''; - } - - // Add invoice - if ($user->societe_id == 0) - { - if (! empty($conf->deplacement->enabled) && $object->status==1) - { - $langs->load("trips"); - print ''; - } - - if (! empty($conf->facture->enabled)) - { - if ($user->rights->facture->creer && $object->status==1) - { - $langs->load("bills"); - $langs->load("orders"); - - if (! empty($conf->commande->enabled)) - { - if (! empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; - } - - if ($object->client != 0) print ''; - else print ''; - - } - else - { - print ''; - } - } - } - - // Add action - if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - if ($user->rights->agenda->myactions->create) - { - print ''; - } - else - { - print ''; - } - } - + if (empty($reshook)) + { + if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1) + { + $langs->load("propal"); + print ''; + } + + if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1) + { + $langs->load("orders"); + print ''; + } + + if ($user->rights->contrat->creer && $object->status==1) + { + $langs->load("contracts"); + print ''; + } + + if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1) + { + $langs->load("fichinter"); + print ''; + } + + // Add invoice + if ($user->societe_id == 0) + { + if (! empty($conf->deplacement->enabled) && $object->status==1) + { + $langs->load("trips"); + print ''; + } + + if (! empty($conf->facture->enabled)) + { + if ($user->rights->facture->creer && $object->status==1) + { + $langs->load("bills"); + $langs->load("orders"); + + if (! empty($conf->commande->enabled)) + { + if (! empty($orders2invoice) && $orders2invoice > 0) print ''; + else print ''; + } + + if ($object->client != 0) print ''; + else print ''; + + } + else + { + print ''; + } + } + } + + // Add action + if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + if ($user->rights->agenda->myactions->create) + { + print ''; + } + else + { + print ''; + } + } + } + print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 5265f73e595..59aa71b5595 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -87,6 +87,11 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { $listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder'); } +// Search supplier proposal +if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) +{ + $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort'); +} // Search supplier order if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { @@ -100,12 +105,7 @@ if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) // Search contract if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $listofsearchfields['search_contract']=array('text'=>'Contrat'); -} -// Search supplier proposal -if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) -{ - $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort'); + $listofsearchfields['search_contract']=array('text'=>'Contract'); } if (count($listofsearchfields)) @@ -197,7 +197,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) else { $var=!$var; - print ''.$langs->trans("NoProposal").''; + print ''.$langs->trans("NoProposal").''; } print "
"; @@ -277,7 +277,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos else { $var=!$var; - print ''.$langs->trans("NoProposal").''; + print ''.$langs->trans("NoProposal").''; } print "
"; @@ -357,7 +357,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) else { $var=!$var; - print ''.$langs->trans("NoOrder").''; + print ''.$langs->trans("NoOrder").''; } print "
"; @@ -438,7 +438,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande else { $var=!$var; - print ''.$langs->trans("NoSupplierOrder").''; + print ''.$langs->trans("NoSupplierOrder").''; } print "
"; diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php new file mode 100644 index 00000000000..be8a63225fe --- /dev/null +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -0,0 +1,979 @@ + + * Copyright (C) 2016 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/comm/mailing/advtargetemailing.php + * \ingroup mailing + * \brief Page to define emailing targets + */ + +require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/emailing.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/advtargetemailing.class.php'; +require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/html.formadvtargetemailing.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/modules/mailings/advthirdparties.modules.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; + +// Translations +$langs->load("mails"); +$langs->load("companies"); +if (! empty($conf->categorie->enabled)) { + $langs->load("categories"); +} + +// Security check +if (! $user->rights->mailing->lire || $user->societe_id > 0) + accessforbidden(); + +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if ($page == - 1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) + $sortorder = "ASC"; +if (! $sortfield) + $sortfield = "email"; + +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'int'); +$action = GETPOST("action"); +$search_nom = GETPOST("search_nom"); +$search_prenom = GETPOST("search_prenom"); +$search_email = GETPOST("search_email"); +$template_id = GETPOST('template_id', 'int'); + +// Do we click on purge search criteria ? +if (GETPOST("button_removefilter_x")) { + $search_nom = ''; + $search_prenom = ''; + $search_email = ''; +} + +$array_query = array (); + +$object = new Mailing($db); +$advTarget = new AdvanceTargetingMailing($db); +if (empty($template_id)) { + $advTarget->fk_mailing = $id; + $result = $advTarget->fetch_by_mailing(); +} else { + $result = $advTarget->fetch($template_id); +} + +if ($result < 0) { + setEventMessage($advTarget->error, 'errors'); +} else { + if (! empty($advTarget->id)) { + $array_query = json_decode($advTarget->filtervalue, true); + } +} + + +/* + * Actions + */ + +if ($action == 'loadfilter') { + if (! empty($template_id)) { + $result = $advTarget->fetch($template_id); + if ($result < 0) { + setEventMessage($advTarget->error, 'errors'); + } else { + if (! empty($advTarget->id)) { + $array_query = json_decode($advTarget->filtervalue, true); + } + } + } +} + +if ($action == 'add') { + + $user_contact_query = false; + + $array_query = array (); + + // Get extra fields + + foreach ( $_POST as $key => $value ) { + // print '$key='.$key.' $value='.$value.'
'; + if (preg_match("/^options_.*(?query_thirdparty($array_query); + if ($result < 0) { + setEventMessage($advTarget->error, 'errors'); + } + /*} else { + $advTarget->thirdparty_lines = array (); + }*/ + + if ($user_contact_query && ($array_query['type_of_target'] == 1 || $array_query['type_of_target'] == 2)) { + $result = $advTarget->query_contact($array_query); + if ($result < 0) { + setEventMessage($advTarget->error, 'errors'); + } + // If use contact but no result use artefact to so not use socid into add_to_target + if (count($advTarget->contact_lines) == 0) { + $advTarget->contact_lines = array ( + 0 + ); + } + } else { + $advTarget->contact_lines = array (); + } + + if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) { + // Add targets into database + $obj = new mailing_advthirdparties($db); + $result = $obj->add_to_target($id, $advTarget->thirdparty_lines, $array_query['type_of_target'], $advTarget->contact_lines); + } else { + $result = 0; + } + + if ($result > 0) { + $query_temlate_id = ''; + if (! empty($template_id)) { + $query_temlate_id = '&template_id=' . $template_id; + } + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id . $query_temlate_id); + exit(); + } + if ($result == 0) { + setEventMessage($langs->trans("WarningNoEMailsAdded"), 'warnings'); + } + if ($result < 0) { + setEventMessage($obj->error, 'errors'); + } +} + +if ($action == 'clear') { + // Chargement de la classe + $classname = "MailingTargets"; + $obj = new $classname($db); + $obj->clear_target($id); + + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + exit(); +} + +if ($action == 'savefilter' || $action == 'createfilter') { + + $template_name = GETPOST('template_name'); + $error = 0; + + if ($action == 'createfilter' && empty($template_name)) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('AdvTgtOrCreateNewFilter')), 'errors'); + $error ++; + } + + if (empty($error)) { + + $array_query = array (); + + // Get extra fields + foreach ( $_POST as $key => $value ) { + if (preg_match("/^options_.*(?filtervalue = json_encode($array_query); + + if ($action == 'createfilter') { + $advTarget->name = $template_name; + $result = $advTarget->create($user); + if ($result < 0) { + setEventMessage($advTarget->error, 'errors'); + } + } elseif ($action == 'savefilter') { + $result = $advTarget->update($user); + if ($result < 0) { + setEventMessage($advTarget->error, 'errors'); + } + } + $template_id = $advTarget->id; + } +} + +if ($action == 'deletefilter') { + $result = $advTarget->delete($user); + if ($result < 0) { + setEventMessage($advTarget->error, 'errors'); + } + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + exit(); +} + +if ($action == 'delete') { + // Ici, rowid indique le destinataire et id le mailing + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing_cibles WHERE rowid=" . $rowid; + $resql = $db->query($sql); + if ($resql) { + if (! empty($id)) { + $classname = "MailingTargets"; + $obj = new $classname($db); + $obj->update_nb($id); + + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + exit(); + } else { + header("Location: liste.php"); + exit(); + } + } else { + dol_print_error($db); + } +} + +if ($_POST["button_removefilter"]) { + $search_nom = ''; + $search_prenom = ''; + $search_email = ''; +} + + +/* + * View + */ + +$extrajs = array ( + '/includes/jquery/plugins/multiselect/js/ui.multiselect.js' +); +$extracss = array ( + '/includes/jquery/plugins/multiselect/css/ui.multiselect.css', +); + +llxHeader('', $langs->trans("MailAdvTargetRecipients"), '', '', '', '', $extrajs, $extracss); + +print ''; + +$form = new Form($db); +$formadvtargetemaling = new FormAdvTargetEmailing($db); +$formcompany = new FormCompany($db); +$formother = new FormOther($db); + +if ($object->fetch($id) >= 0) { + + $head = emailing_prepare_head($object); + + dol_fiche_head($head, 'advtargets', $langs->trans("Mailing"), 0, 'email'); + + print ''; + + $linkback = '' . $langs->trans("BackToList") . ''; + + print ''; + print ''; + + print ''; + + print ''; + + // Errors to + print ''; + + // Status + print ''; + + // Nb of distinct emails + print ''; + + print '
' . $langs->trans("Ref") . ''; + print $form->showrefnav($object, 'id', $linkback); + print '
' . $langs->trans("MailTitle") . '' . $object->titre . '
' . $langs->trans("MailFrom") . '' . dol_print_email($object->email_from, 0, 0, 0, 0, 1) . '
' . $langs->trans("MailErrorsTo") . '' . dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); + print '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
'; + print $langs->trans("TotalNbOfDistinctRecipients"); + print ''; + $nbemail = ($object->nbemail ? $object->nbemail : '0'); + if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { + $text = $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + print $form->textwithpicto($nbemail, $text, 1, 'warning'); + } else { + print $nbemail; + } + print '
'; + + print "
"; + + // Show email selectors + if ($object->statut == 0 && $user->rights->mailing->creer) { + print_fiche_titre($langs->trans("AdvTgtTitle")); + + print '
' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + + print '' . "\n"; + + print '' . "\n"; + + // Customer name + print '' . "\n"; + + // Code Client + print '' . "\n"; + + // Address Client + print '' . "\n"; + + // Zip Client + print '' . "\n"; + + // City Client + print '' . "\n"; + + // Customer Country + print '' . "\n"; + + // State Customer + print '' . "\n"; + + // Mother Company + print '' . "\n"; + + // Prospect/Customer + $selected = $array_query['cust_typecust']; + print '' . "\n"; + + // Prospection status + print '' . "\n"; + + // Prospection comm status + print '' . "\n"; + + // Customer Type + print '' . "\n"; + + // Staff number + print '' . "\n"; + + // Sales manager + print '' . "\n"; + + // Customer Default Langauge + if (! empty($conf->global->MAIN_MULTILANGS)) { + + print '' . "\n"; + } + + if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . "\n"; + } + + // Standard Extrafield feature + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label('societe'); + foreach ( $extralabels as $key => $val ) { + if ($key != 'ts_nameextra' && $key != 'ts_payeur') { + print '' . "\n"; + } + } + } else { + $std_soc = new Societe($db); + $action_search = 'query'; + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + $hookmanager->initHooks(array ( + 'thirdpartycard' + )); + if (! empty($advTarget->id)) { + $parameters = array ( + 'array_query' => $advTarget->filtervalue + ); + } + // Module extrafield feature + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); + } + + // State Contact + print '' . "\n"; + + // Civility + print ''; + + // contact name + print '' . "\n"; + print '' . "\n"; + + // Contact Country + print '' . "\n"; + + // Never send mass mailing + print '' . "\n"; + + // Contact Date Create + print '' . "\n"; + + // Contact update Create + print '' . "\n"; + + if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . "\n"; + } + + // Standard Extrafield feature + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label('socpeople'); + foreach ( $extralabels as $key => $val ) { + + print '' . "\n"; + } + } + + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '
' . "\n"; + + print '' . "\n"; + + print '
' . $langs->trans('AdvTgtNameTemplate') . ''; + if (! empty($template_id)) { + $default_template = $template_id; + } else { + $default_template = $advTarget->id; + } + print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template); + print ''; + print ''; + print ''; + print $langs->trans('AdvTgtOrCreateNewFilter'); + print ''; + print ''; + print '' . "\n"; + print '
' . $langs->trans('AdvTgtTypeOfIncude') . ''; + print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']); + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help'); + print '
' . $langs->trans('ThirdPartyName'); + if (! empty($array_query['cust_name'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('CustomerCode'); + if (! empty($array_query['cust_code'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Address'); + if (! empty($array_query['cust_adress'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Zip'); + if (! empty($array_query['cust_zip'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Town'); + if (! empty($array_query['cust_city'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans("Country"); + if (count($array_query['cust_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']); + print '' . "\n"; + print '
' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty'); + if (count($array_query['cust_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray('cust_status', array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), $array_query['cust_status']); + print '' . "\n"; + print '
' . $langs->trans("Maison mère"); + if (! empty($array_query['cust_mothercompany'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty'); + if (count($array_query['cust_typecust']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + $options_array = array ( + 2 => $langs->trans('Prospect'), + 3 => $langs->trans('ProspectCustomer'), + 1 => $langs->trans('Customer'), + 0 => $langs->trans('NorProspectNorCustomer') + ); + print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']); + print '' . "\n"; + print '
' . $langs->trans('ProspectLevel'); + if (count($array_query['cust_prospect_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); + print '' . "\n"; + print '
' . $langs->trans('StatusProsp'); + if (count($array_query['cust_comm_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']); + print '' . "\n"; + print '
' . $langs->trans("ThirdPartyType"); + if (count($array_query['cust_typeent']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']); + print '' . "\n"; + print '
' . $langs->trans("Staff"); + if (count($array_query['cust_effectif_id']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']); + print '' . "\n"; + print '
' . $langs->trans("SalesRepresentatives"); + if (count($array_query['cust_saleman']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user); + print '' . "\n"; + print '
' . $langs->trans("DefaultLang"); + if (count($array_query['cust_language']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']); + print '' . "\n"; + print '
' . $langs->trans("CustomersCategoryShort"); + if (count($array_query['cust_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']); + print '' . "\n"; + print '
' . $extrafields->attribute_label[$key]; + if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) { + + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date('', 'options_' . $key . '_st_dt'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date('', 'options_' . $key . '_end_dt'); + print '
'; + + print '
' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'boolean')) { + print $form->selectarray('options_' . $key, array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), $array_query['options_' . $key]); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } else { + + print ''; + print '
'; + if (is_array($array_query['options_' . $key])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key])); + } else { + print $extrafields->showInputField($key, $array_query['options_' . $key]); + } + print '
'; + + print '
' . "\n"; + } + print '
' . $langs->trans('Status') . ' ' . $langs->trans('Contact'); + if (count($array_query['contact_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray('contact_status', array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), $array_query['contact_status']); + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help'); + print '
' . $langs->trans("UserTitle"); + if (count($array_query['contact_civility']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']); + print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname'); + if (! empty($array_query['contact_lastname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname'); + if (! empty($array_query['contact_firstname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("Country"); + if (count($array_query['contact_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']); + print '' . "\n"; + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email"); + if (! empty($array_query['contact_no_email'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->selectarray('contact_no_email', array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), $array_query['contact_no_email']); + print '' . "\n"; + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation"); + if (! empty($array_query['contact_create_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1); + print '
'; + print '
' . "\n"; + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification"); + if (! empty($array_query['contact_update_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1); + print '
'; + print '
' . "\n"; + print '
' . $langs->trans("ContactCategoriesShort"); + if (count($array_query['contact_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']); + print '' . "\n"; + print '
' . $extrafields->attribute_label[$key]; + if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) { + + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date('', 'options_' . $key . '_st_dt' . '_cnct'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date('', 'options_' . $key . '_end_dt' . '_cnct'); + print '
'; + + print '
' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'boolean')) { + print $form->selectarray('options_' . $key . '_cnct', array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } else { + + print ''; + print '
'; + if (is_array($array_query['options_' . $key . '_cnct'])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct'); + } else { + print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct'); + } + print '
'; + + print '
' . "\n"; + } + print '
' . "\n"; + + print '' . "\n"; + + print '
' . "\n"; + print '' . "\n"; + print '
' . "\n"; + + print '
'; + print ''; + print_titre($langs->trans("ToClearAllRecipientsClickHere")); + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + } + + + if (empty($conf->mailchimp->enabled) || (! empty($conf->mailchimp->enabled) && $object->statut != 3)) + { + // List of recipients (TODO Move code of page cibles.php into a .tpl.php file and make an include here to avoid duplicate content) + } +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 9a7d0349f41..1a54340e7ce 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -948,7 +948,7 @@ else } } - print '

'; + print '
'; } // Affichage formulaire de TEST @@ -1052,20 +1052,25 @@ else print ''; - // Ref - print ''; + $linkback = ''.$langs->trans("BackToList").''; + + print ''; + print ''; + // Topic - print ''; + print ''; // From - print ''; + print ''; // To - print ''; + print ''; // Status - print ''; + print ''; // Nb of distinct emails - print ''; + $notshippable=0; + $warning = 0; + $text_info=''; + $text_warning=''; + $nbprod=0; + if (! empty($arrayfields['c.ref']['checked'])) { print ''; // Show shippable Icon (create subloop, so may be slow) - if ($conf->stock->enabled) + if ($conf->stock->enabled) { - $langs->load("stocks"); - if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) - { - $notshippable=0; - $warning = 0; - $text_info=''; - $text_warning=''; - $nbprod=0; - + $langs->load("stocks"); + if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) + { $numlines = count($generic_commande->lines); // Loop on each line of order for ($lig=0; $lig < $numlines; $lig++) { @@ -712,17 +712,19 @@ if ($resql) { $nbprod++; // order contains real products $generic_product->id = $generic_commande->lines[$lig]->fk_product; + + // Get local and virtual stock and store it into cache if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { - $generic_product->load_stock(); - $generic_product->load_virtual_stock(); + $generic_product->load_stock('nobatch'); + //$generic_product->load_virtual_stock(); Already included into load_stock $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } else { $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } - - if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code is when this option is not set, setting it create strange result + + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default is when this option is not set, setting it create strange result { $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel; @@ -795,7 +797,7 @@ if ($resql) { print $form->textwithtooltip('',$text_info,2,1,$text_icon,'',2); } - if ($warning) { + if ($warning) { // Always false in default mode print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'),'',2); } print ''; @@ -989,6 +991,7 @@ if ($resql) if (! empty($arrayfields['c.facture']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; } // Action column diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index e2cecacb83c..e6043167b22 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2014-2015 Alexandre Spangaro + * Copyright (C) 2014-2016 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Marcos García * @@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; $langs->load("banks"); $langs->load("bills"); @@ -131,6 +132,10 @@ if ($_POST["action"] == 'add') $id = $account->create($user); if ($id > 0) { + // Category association + $categories = GETPOST('categories'); + $account->setCategories($categories); + $_GET["id"]=$id; // Force chargement page en mode visu } else { @@ -207,6 +212,10 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $result = $account->update($user); if ($result >= 0) { + // Category association + $categories = GETPOST('categories'); + $account->setCategories($categories); + $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu } else @@ -337,6 +346,20 @@ if ($action == 'create') print ''; print ''; + // Tags-Categories + if ($conf->categorie->enabled) + { + print '"; + } + // Comment print ''; print '\n"; + // Categories + if($conf->categorie->enabled) { + print '"; + } + print ''; print ''; @@ -675,7 +705,13 @@ else print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'id', $linkback); + print '
'.$langs->trans("MailTitle").''.$object->titre.'
'.$langs->trans("MailTitle").''.$object->titre.'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from,0,0,0,0,1).'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from,0,0,0,0,1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto,0,0,0,0,1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto,0,0,0,0,1).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'; + print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail?$object->nbemail:img_warning('').' '.$langs->trans("NoTargetYet").''); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 0c133fac6df..2ce7d5c110d 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2015 Laurent Destailleur + * Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2014 Florian Henry * @@ -227,7 +227,7 @@ if ($object->fetch($id) >= 0) // Show email selectors if ($allowaddtarget && $user->rights->mailing->creer) { - print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"),($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''),''); + print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''), 'title_generic'); print ''; print ''; @@ -398,12 +398,12 @@ if ($object->fetch($id) >= 0) print ''; print ''; + $cleartext=''; if ($allowaddtarget) { - $cleartext='
'.$langs->trans("ToClearAllRecipientsClickHere").': '.''; + $cleartext=$langs->trans("ToClearAllRecipientsClickHere").' '.''; } - - print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$nbtotalofrecords,'',0,'','',$limit); - + print_barre_liste($langs->trans("MailSelectedRecipients"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$cleartext,$num,$nbtotalofrecords,'title_generic',0,'','',$limit); + print ''; print "\n\n"; @@ -540,7 +540,7 @@ if ($object->fetch($id) >= 0) print ''; } - //Sreach Icon + // Search Icon print '
'; + } print "
'; if ($obj->statut == 0) { diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php new file mode 100644 index 00000000000..62cf5f2436f --- /dev/null +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -0,0 +1,777 @@ + +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/** + * \file comm/mailing/class/advtargetemailing.class.php + * \ingroup mailing + * \brief This file is an example CRUD class file (Create/Read/Update/Delete) + */ + + +/** + * Class to manage advanced emailing target selector + */ +class AdvanceTargetingMailing extends CommonObject +{ + + var $db; //!< To store db handler + var $error; //!< To return error code (or message) + var $errors = array(); //!< To return several error codes (or messages) + var $element='advtargetemailing'; //!< Id that identify managed objects + var $table_element='advtargetemailing'; //!< Name of table without prefix where object is stored + + var $id; + + var $name; + var $entity; + var $fk_mailing; + var $filtervalue; + var $fk_user_author; + var $datec=''; + var $fk_user_mod; + var $tms=''; + + var $select_target_type = array(); + var $type_statuscommprospect=array(); + var $thirdparty_lines; + var $contact_lines; + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + function __construct($db) + { + global $langs; + $langs->load('customers'); + + $this->db = $db; + + $this->select_target_type = array('2'=>$langs->trans('Contacts'),'1'=>$langs->trans('Contacts').'+'.$langs->trans('ThirdParty'), + '3'=>$langs->trans('ThirdParty'), + ); + $this->type_statuscommprospect=array( + -1=>$langs->trans("StatusProspect-1"), + 0=>$langs->trans("StatusProspect0"), + 1=>$langs->trans("StatusProspect1"), + 2=>$langs->trans("StatusProspect2"), + 3=>$langs->trans("StatusProspect3")); + + + return 1; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->fk_mailing)) $this->fk_mailing=trim($this->fk_mailing); + if (isset($this->name)) $this->name=trim($this->name); + if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); + if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); + if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."advtargetemailing("; + + $sql.= "name,"; + $sql.= "entity,"; + $sql.= "fk_mailing,"; + $sql.= "filtervalue,"; + $sql.= "fk_user_author,"; + $sql.= "datec,"; + $sql.= "fk_user_mod"; + + + $sql.= ") VALUES ("; + + $sql.= " ".(! isset($this->name)?'NULL':"'".$this->db->escape($this->name)."'").","; + $sql.= " ".$conf->entity.","; + $sql.= " ".(! isset($this->fk_mailing)?'NULL':"'".$this->fk_mailing."'").","; + $sql.= " ".(! isset($this->filtervalue)?'NULL':"'".$this->db->escape($this->filtervalue)."'").","; + $sql.= " ".$user->id.","; + $sql.= " ".$this->db->idate(dol_now()).","; + $sql.= " ".$user->id; + + + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."advtargetemailing"); + + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch($id) + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + + $sql.= " t.name,"; + $sql.= " t.entity,"; + $sql.= " t.fk_mailing,"; + $sql.= " t.filtervalue,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.datec,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.tms"; + + $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql.= " WHERE t.rowid = ".$id; + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->name = $obj->name; + $this->entity = $obj->entity; + $this->fk_mailing = $obj->fk_mailing; + $this->filtervalue = $obj->filtervalue; + $this->fk_user_author = $obj->fk_user_author; + $this->datec = $this->db->jdate($obj->datec); + $this->fk_user_mod = $obj->fk_user_mod; + $this->tms = $this->db->jdate($obj->tms); + + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch_by_mailing($id=0) + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + + $sql.= " t.name,"; + $sql.= " t.entity,"; + $sql.= " t.fk_mailing,"; + $sql.= " t.filtervalue,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.datec,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.tms"; + + $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + if (!empty($id)) { + $sql.= " WHERE t.fk_mailing = ".$id; + }else { + $sql.= " WHERE t.fk_mailing = ".$this->fk_mailing; + } + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->name = $obj->name; + $this->entity = $obj->entity; + $this->fk_mailing = $obj->fk_mailing; + $this->filtervalue = $obj->filtervalue; + $this->fk_user_author = $obj->fk_user_author; + $this->datec = $this->db->jdate($obj->datec); + $this->fk_user_mod = $obj->fk_user_mod; + $this->tms = $this->db->jdate($obj->tms); + + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->fk_mailing)) $this->fk_mailing=trim($this->fk_mailing); + if (isset($this->name)) $this->name=trim($this->name); + if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); + if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); + if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); + + + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."advtargetemailing SET"; + + $sql.= " name=".(isset($this->name)?"'".$this->db->escape($this->name)."'":"''").","; + $sql.= " entity=".$conf->entity.","; + $sql.= " fk_mailing=".(isset($this->fk_mailing)?$this->fk_mailing:"null").","; + $sql.= " filtervalue=".(isset($this->filtervalue)?"'".$this->db->escape($this->filtervalue)."'":"null").","; + $sql.= " fk_user_mod=".$user->id; + + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."advtargetemailing"; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete sql=".$sql); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Save query in database to retreive it + * + * @param User $user User that deletes + * @param array $arrayquery All element to Query + * @return int <0 if KO, >0 if OK + */ + function savequery($user,$arrayquery) + { + global $langs,$conf; + + if (!empty($arrayquery)) { + $result=$this->fetch_by_mailing($this->fk_mailing); + $this->filtervalue=json_encode($arrayquery); + if ($result<0) { + return -1; + } + if (!empty($this->id)) { + $this->update($user); + }else { + $this->create($user); + } + } + } + + + + /** + * Load object in memory from database + * + * @param array $arrayquery All element to Query + * @return int <0 if KO, >0 if OK + */ + function query_thirdparty($arrayquery) + { + global $langs,$conf; + + $sql = "SELECT"; + $sql.= " t.rowid"; + $sql.= " FROM " . MAIN_DB_PREFIX . "societe as t"; + $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_extrafields as te ON te.fk_object=t.rowid "; + + $sqlwhere=array(); + + $sqlwhere[]= 't.entity IN ('.getEntity('societe',1).')'; + + if (count($arrayquery)>0) { + + if (array_key_exists('cust_saleman', $arrayquery)) { + $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as saleman ON saleman.fk_soc=t.rowid "; + } + if (array_key_exists('cust_categ', $arrayquery)) { + $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_societe=t.rowid "; + } + + if (!empty($arrayquery['cust_name'])) { + + $sqlwhere[]= $this->transformToSQL('t.nom',$arrayquery['cust_name']); + } + if (!empty($arrayquery['cust_code'])) { + $sqlwhere[]= $this->transformToSQL('t.code_client',$arrayquery['cust_code']); + } + if (!empty($arrayquery['cust_adress'])) { + $sqlwhere[]= $this->transformToSQL('t.address',$arrayquery['cust_adress']); + } + if (!empty($arrayquery['cust_zip'])) { + $sqlwhere[]= $this->transformToSQL('t.zip',$arrayquery['cust_zip']); + } + if (!empty($arrayquery['cust_city'])) { + $sqlwhere[]= $this->transformToSQL('t.town',$arrayquery['cust_city']); + } + if (!empty($arrayquery['cust_mothercompany'])) { + $str=$this->transformToSQL('nom',$arrayquery['cust_mothercompany']); + $sqlwhere[]= " (t.parent IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "societe WHERE ('.$str.')))"; + } + if (!empty($arrayquery['cust_status']) && count($arrayquery['cust_status'])>0) { + $sqlwhere[]= " (t.status IN (".implode(',',$arrayquery['cust_status'])."))"; + } + if (!empty($arrayquery['cust_typecust']) && count($arrayquery['cust_typecust'])>0) { + $sqlwhere[]= " (t.client IN (".implode(',',$arrayquery['cust_typecust'])."))"; + } + if (!empty($arrayquery['cust_comm_status']) && count($arrayquery['cust_comm_status']>0)) { + $sqlwhere[]= " (t.fk_stcomm IN (".implode(',',$arrayquery['cust_comm_status'])."))"; + } + if (!empty($arrayquery['cust_prospect_status']) && count($arrayquery['cust_prospect_status'])>0) { + $sqlwhere[]= " (t.fk_prospectlevel IN ('".implode("','",$arrayquery['cust_prospect_status'])."'))"; + } + if (!empty($arrayquery['cust_typeent']) && count($arrayquery['cust_typeent'])>0) { + $sqlwhere[]= " (t.fk_typent IN (".implode(',',$arrayquery['cust_typeent'])."))"; + } + if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman'])>0) { + $sqlwhere[]= " (saleman.fk_user IN (".implode(',',$arrayquery['cust_saleman'])."))"; + } + if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country'])>0) { + $sqlwhere[]= " (t.fk_pays IN (".implode(',',$arrayquery['cust_country'])."))"; + } + if (!empty($arrayquery['cust_effectif_id']) && count($arrayquery['cust_effectif_id'])>0) { + $sqlwhere[]= " (t.fk_effectif IN (".implode(',',$arrayquery['cust_effectif_id'])."))"; + } + if (!empty($arrayquery['cust_categ']) && count($arrayquery['cust_categ'])>0) { + $sqlwhere[]= " (custcateg.fk_categorie IN (".implode(',',$arrayquery['cust_categ'])."))"; + } + if (!empty($arrayquery['cust_language']) && count($arrayquery['cust_language'])>0) { + $sqlwhere[]= " (t.default_lang IN ('".implode("','",$arrayquery['cust_language'])."'))"; + } + + //Standard Extrafield feature + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label('societe'); + + foreach($extralabels as $key=>$val) { + + if (($extrafields->attribute_type[$key] == 'varchar') || + ($extrafields->attribute_type[$key] == 'text')) { + if (!empty($arrayquery['options_'.$key])) { + $sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key]."')"; + } + } elseif (($extrafields->attribute_type[$key] == 'int') || + ($extrafields->attribute_type[$key] == 'double')) { + if (!empty($arrayquery['options_'.$key.'_max'])) { + $sqlwhere[]= " (te.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND te.".$key." <= ".$arrayquery['options_'.$key.'_min'].")"; + } + } else if (($extrafields->attribute_type[$key] == 'date') || + ($extrafields->attribute_type[$key] == 'datetime')) { + if (!empty($arrayquery['options_'.$key.'_end_dt'])){ + $sqlwhere[]= " (te.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND te.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')"; + } + }else if ($extrafields->attribute_type[$key] == 'boolean') { + if ($arrayquery['options_'.$key]!=''){ + $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; + } + }else{ + if (is_array($arrayquery['options_'.$key])) { + $sqlwhere[]= " (te.".$key." IN ('".implode("','",$arrayquery['options_'.$key])."'))"; + } elseif (!empty($arrayquery['options_'.$key])) { + $sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key]."')"; + } + } + + } + + + } + + if (count($sqlwhere)>0) $sql.= " WHERE ".implode(" AND ",$sqlwhere); + + } + + + dol_syslog(get_class($this) . "::query_thirdparty sql=" . $sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $this->thirdparty_lines = array(); + $num = $this->db->num_rows($resql); + $i = 0; + + if ($num) + { + while( $i < $num) + { + $obj = $this->db->fetch_object($resql); + + $this->thirdparty_lines[$i] = $obj->rowid; + + $i++; + } + } + $this->db->free($resql); + + return $num; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::query_thirdparty " . $this->error, LOG_ERR); + return -1; + } + } + + /** + * Load object in memory from database + * + * @param array $arrayquery All element to Query + * @return int <0 if KO, >0 if OK + */ + function query_contact($arrayquery) + { + global $langs,$conf; + + $sql = "SELECT"; + $sql.= " t.rowid"; + $sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t"; + $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object=t.rowid "; + + $sqlwhere=array(); + + $sqlwhere[]= 't.entity IN ('.getEntity('socpeople',1).')'; + + if (count($arrayquery)>0) { + + if (array_key_exists('contact_categ', $arrayquery)) { + $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_contact as contactcateg ON contactcateg.fk_socpeople=t.rowid "; + } + + if (!empty($arrayquery['contact_lastname'])) { + $sqlwhere[]=$this->transformToSQL('t.lastname',$arrayquery['contact_lastname']); + } + if (!empty($arrayquery['contact_firstname'])) { + $sqlwhere[]=$this->transformToSQL('t.firstname',$arrayquery['contact_firstname']); + } + if (!empty($arrayquery['contact_country']) && count($arrayquery['contact_country'])) { + $sqlwhere[]= " (t.fk_pays IN (".implode(',',$arrayquery['contact_country'])."))"; + } + if (!empty($arrayquery['contact_status']) && count($arrayquery['contact_status'])>0) { + $sqlwhere[]= " (t.statut IN (".implode(',',$arrayquery['contact_status'])."))"; + } + if (!empty($arrayquery['contact_civility']) && count($arrayquery['contact_civility'])>0) { + $sqlwhere[]= " (t.civility IN ('".implode("','",$arrayquery['contact_civility'])."'))"; + } + if ($arrayquery['contact_no_email']!='') { + $sqlwhere[]= " (t.no_email='".$arrayquery['contact_no_email']."')"; + } + if ($arrayquery['contact_update_st_dt']!='') { + $sqlwhere[]= " (t.tms >= '".$this->db->idate($arrayquery['contact_update_st_dt'])."' AND t.tms <= '".$this->db->idate($arrayquery['contact_update_end_dt'])."')"; + } + if ($arrayquery['contact_create_st_dt']!='') { + $sqlwhere[]= " (t.datec >= '".$this->db->idate($arrayquery['contact_create_st_dt'])."' AND t.datec <= '".$this->db->idate($arrayquery['contact_create_end_dt'])."')"; + } + if (!empty($arrayquery['contact_categ']) && count($arrayquery['contact_categ'])>0) { + $sqlwhere[]= " (contactcateg.fk_categorie IN (".implode(",",$arrayquery['contact_categ'])."))"; + } + + //Standard Extrafield feature + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label('socpeople'); + + foreach($extralabels as $key=>$val) { + + if (($extrafields->attribute_type[$key] == 'varchar') || + ($extrafields->attribute_type[$key] == 'text')) { + if (!empty($arrayquery['options_'.$key.'_cnct'])) { + $sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key.'_cnct']."')"; + } + } elseif (($extrafields->attribute_type[$key] == 'int') || + ($extrafields->attribute_type[$key] == 'double')) { + if (!empty($arrayquery['options_'.$key.'_max'.'_cnct'])) { + $sqlwhere[]= " (te.".$key." >= ".$arrayquery['options_'.$key.'_max'.'_cnct']." AND te.".$key." <= ".$arrayquery['options_'.$key.'_min'.'_cnct'].")"; + } + } else if (($extrafields->attribute_type[$key] == 'date') || + ($extrafields->attribute_type[$key] == 'datetime')) { + if (!empty($arrayquery['options_'.$key.'_end_dt'.'_cnct'])){ + $sqlwhere[]= " (te.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'.'_cnct'])."' AND te.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'.'_cnct'])."')"; + } + }else if ($extrafields->attribute_type[$key] == 'boolean') { + if ($arrayquery['options_'.$key.'_cnct']!=''){ + if ($arrayquery['options_'.$key.'_cnct']==0) { + $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key.'_cnct']." OR ((te.".$key." IS NULL) AND (te.fk_object IS NOT NULL)))"; + }else { + $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key.'_cnct'].")"; + } + } + }else{ + if (is_array($arrayquery['options_'.$key.'_cnct'])) { + $sqlwhere[]= " (te.".$key." IN ('".implode("','",$arrayquery['options_'.$key.'_cnct'])."'))"; + } elseif (!empty($arrayquery['options_'.$key.'_cnct'])) { + $sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key.'_cnct']."')"; + } + } + + } + + + } + + if (count($sqlwhere)>0) $sql.= " WHERE ".implode(" AND ",$sqlwhere); + + } + + + dol_syslog(get_class($this) . "::query_contact sql=" . $sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $this->contact_lines = array(); + $num = $this->db->num_rows($resql); + $i = 0; + + if ($num) + { + while( $i < $num) + { + $obj = $this->db->fetch_object($resql); + + $this->contact_lines[$i] = $obj->rowid; + + $i++; + } + } + $this->db->free($resql); + + return $num; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::query_contact " . $this->error, LOG_ERR); + return -1; + } + } + + + /** + * Parse criteria to return a SQL qury formated + * + * @param string $column_to_test column to test + * @param string $criteria Use %% as magic caracters. For exemple to find all item like jean, joe, jim, you can input j%%, you can also use ; as separator for value, + * and use ! for except this value. + * For exemple jean;joe;jim%%;!jimo;!jima%> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima + * @return string Sql to use for the where condition + */ + public function transformToSQL($column_to_test,$criteria) { + $return_sql_criteria = '('; + + //This is a multiple value test + if (preg_match('/;/',$criteria)) { + $return_sql_not_like=array(); + $return_sql_like=array(); + + $criteria_array=explode(';',$criteria); + foreach($criteria_array as $inter_criteria) { + if (preg_match('/!/',$inter_criteria)) { + $return_sql_not_like[]= '('.$column_to_test.' NOT LIKE \''.str_replace('!', '', $inter_criteria).'\')'; + } else { + $return_sql_like[]= '('.$column_to_test.' LIKE \''.$inter_criteria.'\')'; + } + } + + if (count($return_sql_like)>0) { + $return_sql_criteria .= '(' . implode (' OR ', $return_sql_like) .')'; + } + if (count($return_sql_not_like)>0) { + $return_sql_criteria .= ' AND (' . implode (' AND ', $return_sql_not_like).')'; + } + + }else { + $return_sql_criteria .= $column_to_test . ' LIKE \''.$this->db->escape($criteria).'\''; + } + + $return_sql_criteria .= ')'; + + return $return_sql_criteria; + } + + +} \ No newline at end of file diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php new file mode 100644 index 00000000000..69fb747f364 --- /dev/null +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -0,0 +1,505 @@ + +* +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/** + * \file comm/mailing/class/html.formadvtragetemaling.class.php + * \ingroup mailing + * \brief Fichier de la classe des fonctions predefinie de composants html advtargetemaling + */ + +/** + * Class to manage building of HTML components + */ +class FormAdvTargetEmailing extends Form +{ + var $db; + var $error; + + /** + * Constructor + * + * @param DoliDB $db handler + */ + function __construct($db) { + global $langs; + + $this->db = $db; + } + + /** + * Affiche un champs select contenant une liste + * + * @param array $selected_array à preselectionner + * @param string $htmlname select field + * @return string select field + */ + function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') { + global $conf, $langs; + $options_array = array (); + + $sql = "SELECT code, label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectlevel"; + $sql .= " WHERE active > 0"; + $sql .= " ORDER BY sortorder"; + dol_syslog ( get_class ( $this ) . '::multiselectProspectionStatus sql=' . $sql, LOG_DEBUG ); + $resql = $this->db->query ( $sql ); + if ($resql) { + $num = $this->db->num_rows ( $resql ); + $i = 0; + while ( $i < $num ) { + $obj = $this->db->fetch_object ( $resql ); + + $level = $langs->trans ( $obj->code ); + if ($level == $obj->code) + $level = $langs->trans ( $obj->label ); + $options_array [$obj->code] = $level; + + $i ++; + } + } else { + dol_print_error ( $this->db ); + } + return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + } + + /** + * Return combo list of activated countries, into language of user + * + * @param string $htmlname of html select object + * @param array $selected_array or Code or Label of preselected country + * @return string HTML string with select + */ + function multiselectCountry($htmlname = 'country_id', $selected_array=array()) { + global $conf, $langs; + + $langs->load("dict"); + $maxlength = 0; + + $out = ''; + $countryArray = array(); + $label = array (); + + $options_array = array(); + + $sql = "SELECT rowid, code as code_iso, label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "c_country"; + $sql .= " WHERE active = 1 AND code<>''"; + $sql .= " ORDER BY code ASC"; + + dol_syslog(get_class($this) . "::select_country sql=" . $sql); + $resql = $this->db->query($sql); + if ($resql) { + + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) { + $foundselected = false; + + while ($i < $num) { + $obj = $this->db->fetch_object ( $resql ); + $countryArray [$i] ['rowid'] = $obj->rowid; + $countryArray [$i] ['code_iso'] = $obj->code_iso; + $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso ) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv ( "Country" . $obj->code_iso ) : ($obj->label != '-' ? $obj->label : '')); + $label[$i] = $countryArray[$i]['label']; + $i ++; + } + + array_multisort($label, SORT_ASC, $countryArray); + + foreach ($countryArray as $row) { + $label = dol_trunc($row['label'], $maxlength, 'middle'); + if ($row['code_iso']) + $label .= ' (' . $row['code_iso'] . ')'; + + $options_array[$row['rowid']] = $label; + } + } + } else { + dol_print_error($this->db); + } + + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); + } + + /** + * Return select list for categories (to use in form search selectors) + * + * @param string $htmlname control name + * @param array $selected_array array of data + * @param User $user User action + * @return string combo list code + */ + function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) { + + global $conf; + + $options_array = array (); + + $sql_usr = ''; + $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; + $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")"; + $sql_usr .= " AND u2.rowid = sc.fk_user "; + + if (! empty ( $conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX )) + $sql_usr .= " AND u2.statut<>0 "; + $sql_usr .= " ORDER BY name ASC"; + // print $sql_usr;exit; + + $resql_usr = $this->db->query ( $sql_usr ); + if ($resql_usr) { + while ( $obj_usr = $this->db->fetch_object ( $resql_usr ) ) { + + $label = $obj_usr->firstname . " " . $obj_usr->name . " (" . $obj_usr->login . ')'; + + $options_array [$obj_usr->rowid] = $label; + + } + $this->db->free ( $resql_usr ); + } else { + dol_print_error ( $this->db ); + } + + return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + } + + /** + * Return select list for categories (to use in form search selectors) + * + * @param string $htmlname of combo list (example: 'search_sale') + * @param array $selected_array selected array + * @return string combo list code + */ + function multiselectselectLanguage($htmlname='', $selected_array=array()) { + + global $conf,$langs; + + $options_array = array (); + + $langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT,12); + + foreach ($langs_available as $key => $value) + { + $label = $value; + $options_array[$key] = $label; + } + asort($options_array); + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); + } + + /** + * Return multiselect list of entities for extrafeild type sellist + * + * @param string $htmlname control name + * @param array $sqlqueryparam array + * @param array $selected_array array + * + * @return string HTML combo + */ + function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) { + + if (is_array ( $sqlqueryparam )) { + $options_array=array(); + + $param_list = array_keys ( $sqlqueryparam ); + $InfoFieldList = explode ( ":", $param_list [0] ); + + // 0 1 : tableName + // 1 2 : label field name Nom du champ contenant le libelle + // 2 3 : key fields name (if differ of rowid) + // 3 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value + + $keyList = 'rowid'; + + if (count ( $InfoFieldList ) >= 3) { + if (strpos ( $InfoFieldList [3], 'extra.' ) !== false) { + $keyList = 'main.' . $InfoFieldList [2] . ' as rowid'; + } else { + $keyList = $InfoFieldList [2] . ' as rowid'; + } + } + + $sql = 'SELECT ' . $keyList . ', ' . $InfoFieldList [1]; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList [0]; + if (! empty ( $InfoFieldList [3] )) { + + // We have to join on extrafield table + if (strpos ( $InfoFieldList [3], 'extra' ) !== false) { + $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList [0] . '_extrafields as extra'; + $sql .= ' WHERE extra.fk_object=main.' . $InfoFieldList [2] . ' AND ' . $InfoFieldList [3]; + } else { + $sql .= ' WHERE ' . $InfoFieldList [3]; + } + } + if (! empty($InfoFieldList[1])) { + $sql .= " ORDER BY nom"; + } + // $sql.= ' WHERE entity = '.$conf->entity; + + $options_array = array(); + + dol_syslog(get_class($this) . "::".__METHOD__,LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) { + while ( $i < $num ) { + $obj = $this->db->fetch_object ( $resql ); + $labeltoshow = dol_trunc ( $obj->$InfoFieldList [1], 90 ); + $options_array[$obj->rowid]=$labeltoshow; + $i ++; + } + } + $this->db->free ( $resql ); + } + } + + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); + } + + /** + * Return combo list with people title + * + * @param string $htmlname Name of HTML select combo field + * @param array $selected_array Array + * @return string HTML combo + */ + function multiselectCivility($htmlname='civilite_id',$selected_array = array()) + { + global $conf,$langs,$user; + $langs->load("dict"); + + $options_array=array(); + + + $sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility"; + $sql.= " WHERE active = 1"; + + dol_syslog(get_class($this)."::".__METHOD__,LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $label= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:'')); + + + $options_array[$obj->code]=$label; + + $i++; + } + } + + } + else + { + dol_print_error($this->db); + } + + return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + } + + /** + * Return multiselect list of entities. + * + * @param string $htmlname select + * @param array $options_array to manage + * @param array $selected_array to manage + * @param int $showempty show empty + * @return string HTML combo + */ + function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) { + global $conf, $langs; + + $return = ''; + $return .= ''; + $return .= ''; + + if ($showempty) + $return .= ''; + + // Find if keys is in selected array value + if (is_array($selected_array) && count($selected_array)>0) { + $intersect_array = array_intersect_key($options_array, array_flip($selected_array)); + } else { + $intersect_array=array(); + } + + if (count($options_array) > 0) { + foreach ($options_array as $keyoption => $valoption) { + // If key is in intersect table then it have to e selected + $selected = ''; + if (count ( $intersect_array ) > 0) { + if (array_key_exists ( $keyoption, $intersect_array )) { + $selected = ' selected="selected"'; + } + } + $return .= '' . $valoption . ''; + } + } + + $return .= ''; + + return $return; + } + + /** + * Return combo list with customer categories + * + * @param string $htmlname Name of categorie + * @param array $selected_array value selected + * @return string HTML combo + */ + function multiselectCustomerCategories($htmlname='cust_cat',$selected_array = array()) + { + return $this->multiselectCategories($htmlname,$selected_array,2); + } + + /** + * Return combo list with customer contact + * + * @param string $htmlname Name of categorie + * @param array $selected_array value selected + * @return string HTML combo + */ + function multiselectContactCategories($htmlname='contact_cat',$selected_array = array()) + { + return $this->multiselectCategories($htmlname,$selected_array,4); + } + + /** + * Return combo list of categories + * + * @param string $htmlname Name of categorie + * @param array $selected_array value selected + * @param int $type type + * @return string HTML combo + */ + public function multiselectCategories($htmlname='',$selected_array = array(), $type=0) + { + global $conf,$langs,$user; + $langs->load("dict"); + + $options_array=array(); + + $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE type=".$type; + + dol_syslog(get_class($this)."::".__METHOD__,LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + $options_array[$obj->rowid]=$obj->label; + + $i++; + } + } + + } + else + { + dol_print_error($this->db); + } + + return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + } + + /** + * selectAdvtargetemailingTemplate + * + * @param string $htmlname control name + * @param integer $selected defaut selected + * @param integer $showempty empty lines + * + * @return string HTML combo + */ + public function selectAdvtargetemailingTemplate($htmlname='template_id',$selected=0,$showempty=0) { + global $conf, $user, $langs; + + $out = ''; + + $sql = "SELECT c.rowid, c.name, c.fk_mailing"; + $sql .= " FROM " . MAIN_DB_PREFIX . "advtargetemailing as c"; + $sql .= " ORDER BY c.name"; + + dol_syslog ( get_class ( $this ) . "::".__METHOD__, LOG_DEBUG ); + $resql = $this->db->query ( $sql ); + if ($resql) { + + + $out .= ''; + } else { + dol_print_error ( $this->db ); + } + $this->db->free ( $resql ); + return $out; + } +} \ No newline at end of file diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3d43d6b00f2..56c3839dcb6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -780,7 +780,7 @@ class Propal extends CommonObject */ function create($user, $notrigger=0) { - global $langs,$conf,$mysoc,$hookmanager; + global $conf,$hookmanager; $error=0; $now=dol_now(); @@ -1080,7 +1080,7 @@ class Propal extends CommonObject */ function createFromClone($socid=0) { - global $db, $user,$langs,$conf,$hookmanager; + global $user,$conf,$hookmanager; dol_include_once('/projet/class/project.class.php'); @@ -1214,7 +1214,6 @@ class Propal extends CommonObject */ function fetch($rowid,$ref='') { - global $conf; $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; @@ -1508,7 +1507,7 @@ class Propal extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $conf,$langs; + global $conf; $error=0; $now=dol_now(); @@ -1868,7 +1867,6 @@ class Propal extends CommonObject */ function reopen($user, $statut, $note='', $notrigger=0) { - global $langs,$conf; $this->statut = $statut; $error=0; @@ -1979,7 +1977,7 @@ class Propal extends CommonObject $outputlangs->setDefaultLang($newlang); } //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $this->generateDocument($modelpdf, $outputlangs); } // Call trigger @@ -2082,7 +2080,7 @@ class Propal extends CommonObject */ function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC') { - global $conf,$user; + global $user; $ga = array(); @@ -2247,7 +2245,7 @@ class Propal extends CommonObject */ function delete($user, $notrigger=0) { - global $conf,$langs; + global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; @@ -2610,7 +2608,7 @@ class Propal extends CommonObject */ function initAsSpecimen() { - global $user,$langs,$conf; + global $langs; // Charge tableau des produits prodids $prodids = array(); @@ -2696,7 +2694,7 @@ class Propal extends CommonObject */ function load_state_board() { - global $conf, $user; + global $user; $this->nb=array(); $clause = "WHERE"; @@ -2741,7 +2739,7 @@ class Propal extends CommonObject */ function getNextNumRef($soc) { - global $conf, $db, $langs; + global $conf,$langs; $langs->load("propal"); if (! empty($conf->global->PROPALE_ADDON)) @@ -2942,7 +2940,7 @@ class Propal extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$langs; $langs->load("propale"); @@ -3196,7 +3194,7 @@ class PropaleLigne extends CommonObjectLine */ function insert($notrigger=0) { - global $conf,$langs,$user; + global $conf,$user; $error=0; @@ -3332,7 +3330,7 @@ class PropaleLigne extends CommonObjectLine */ function delete() { - global $conf,$langs,$user; + global $conf,$user; $error=0; $this->db->begin(); @@ -3383,7 +3381,7 @@ class PropaleLigne extends CommonObjectLine */ function update($notrigger=0) { - global $conf,$langs,$user; + global $conf,$user; $error=0; diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index 04d78f30a1d..d6a2a3d0f82 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -207,9 +207,9 @@ class CommandeApi extends DolibarrApi */ function post($request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401, "Insuffisant rights"); + } // Check mandatory fields $result = $this->_validate($request_data); @@ -224,7 +224,7 @@ class CommandeApi extends DolibarrApi $this->commande->lines = $lines; } if(! $this->commande->create(DolibarrApiAccess::$user) ) { - throw new RestException(401); + throw new RestException(500, "Error while creating order"); } return $this->commande->id; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c4569418968..a22e937da87 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3,12 +3,13 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -203,7 +204,7 @@ class Commande extends CommonOrder */ function getNextNumRef($soc) { - global $db, $langs, $conf; + global $langs, $conf; $langs->load("order"); if (! empty($conf->global->COMMANDE_ADDON)) @@ -238,7 +239,7 @@ class Commande extends CommonOrder } else { - dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); + dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } } @@ -499,7 +500,6 @@ class Commande extends CommonOrder */ function set_reopen($user) { - global $conf,$langs; $error=0; if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED) @@ -559,7 +559,7 @@ class Commande extends CommonOrder */ function cloture($user) { - global $conf, $langs; + global $conf; $error=0; @@ -696,7 +696,7 @@ class Commande extends CommonOrder */ function create($user, $notrigger=0) { - global $conf,$langs,$mysoc,$hookmanager; + global $conf,$langs; $error=0; // Clean parameters @@ -970,7 +970,7 @@ class Commande extends CommonOrder */ function createFromClone($socid=0) { - global $conf,$user,$langs,$hookmanager; + global $user,$hookmanager; $error=0; @@ -1060,7 +1060,7 @@ class Commande extends CommonOrder */ function createFromProposal($object) { - global $db, $conf,$user,$langs,$hookmanager; + global $conf,$user,$hookmanager; dol_include_once('/core/class/extrafields.class.php'); @@ -1133,7 +1133,7 @@ class Commande extends CommonOrder // get extrafields from original line $object->fetch_optionals($object->id); - $e = new ExtraFields($db); + $e = new ExtraFields($this->db); $element_extrafields = $e->fetch_name_optionals_label($this->element); foreach($object->array_options as $options_key => $value) { @@ -1494,7 +1494,6 @@ class Commande extends CommonOrder */ function fetch($id, $ref='', $ref_ext='', $ref_int='') { - global $conf; // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; @@ -1850,10 +1849,9 @@ class Commande extends CommonOrder * Note: For a dedicated shipment, the fetch_lines load the qty_asked and qty_shipped. This function return qty_shipped cuulated for order * * @param int $filtre_statut Filter on status - * @param int $fk_product Filter on a product * @return int <0 if KO, Nb of lines found if OK */ - function loadExpeditions($filtre_statut=-1, $fk_product=0) + function loadExpeditions($filtre_statut=-1) { $this->expeditions = array(); @@ -1982,7 +1980,6 @@ class Commande extends CommonOrder */ function deleteline($lineid) { - global $user; if ($this->statut == self::STATUS_DRAFT) { @@ -2261,7 +2258,7 @@ class Commande extends CommonOrder */ function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='c.date_commande', $sortorder='DESC') { - global $conf,$user; + global $user; $ga = array(); @@ -2429,7 +2426,7 @@ class Commande extends CommonOrder */ function classifyBilled(User $user) { - global $conf, $user, $langs; + global $user; $error = 0; $this->db->begin(); @@ -2516,7 +2513,7 @@ class Commande extends CommonOrder */ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null) { - global $conf, $mysoc; + global $conf, $mysoc, $langs; dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2585,6 +2582,26 @@ class Commande extends CommonOrder $line = new OrderLine($this->db); $line->fetch($rowid); + if (!empty($line->fk_product)) + { + $product=new Product($this->db); + $result=$product->fetch($line->fk_product); + $product_type=$product->type; + + if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty) + { + $this->error=$langs->trans('ErrorStockIsNotEnough'); + dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR); + $this->db->rollback(); + unset($_POST['productid']); + unset($_POST['tva_tx']); + unset($_POST['price_ht']); + unset($_POST['qty']); + unset($_POST['buying_price']); + return self::STOCK_NOT_ENOUGH_FOR_ORDER; + } + } + $staticline = clone $line; $line->oldline = $staticline; @@ -2677,7 +2694,6 @@ class Commande extends CommonOrder */ function update($user=null, $notrigger=0) { - global $conf, $langs; $error=0; // Clean parameters @@ -3184,7 +3200,7 @@ class Commande extends CommonOrder */ function initAsSpecimen() { - global $user,$langs,$conf; + global $langs; dol_syslog(get_class($this)."::initAsSpecimen"); @@ -3266,7 +3282,7 @@ class Commande extends CommonOrder */ function load_state_board() { - global $conf, $user; + global $user; $this->nb=array(); $clause = "WHERE"; diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 0aa828dc77a..fa1b2064ed2 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -216,6 +216,11 @@ if (! empty($conf->commande->enabled)) $i++; } } + else + { + $var=!$var; + print '
'.$langs->trans("NoOrder").'

"; } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index f3b690ad5d1..769e2ba5054 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent @@ -127,7 +127,7 @@ $arrayfields=array( 'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'c.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) + 'c.facture'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -673,6 +673,12 @@ if ($resql) $var=!$var; print '
'; @@ -694,17 +700,11 @@ if ($resql) print ''.yn($obj->billed).'
'.$langs->trans("Web").'
'.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); + $c = new Categorie($db); + $cats = $c->containing($account->id,Categorie::TYPE_ACCOUNT); + foreach($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print "
'.$langs->trans("Comment").''; @@ -591,6 +614,13 @@ else if ($account->url) print ''; print "
'.$langs->trans("Categories").''; + print $form->showCategories($account->id,'account',1); + print "
'.$langs->trans("Comment").''.dol_htmlentitiesbr($account->comment).'
'; // Accountancy code print ''; - print ''; + print ''; + } else { + print $account->account_number; + } + print ''; // Accountancy journal if (! empty($conf->accounting->enabled)) @@ -828,6 +864,20 @@ else print ''; + // Tags-Categories + if ($conf->categorie->enabled) + { + print '"; + } + // Comment print ''; print ''; $var=!$var; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 55f259aa2fe..27ba03499c8 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -83,6 +83,7 @@ $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility +$fac_rec=GETPOST('fac_rec','int'); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -2082,8 +2083,9 @@ if ($action == 'create') $(document).ready(function() { $("#socid").change(function() { var socid = $(this).val(); + var fac_rec = $(\'#fac_rec\').val(); // reload page - window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid; + window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec; }); }); '; @@ -2098,6 +2100,8 @@ if ($action == 'create') $invoice_predefined = new FactureRec($db); $invoice_predefined->fetch(GETPOST('fac_rec','int')); + $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later + $sql = 'SELECT r.rowid, r.titre, r.total_ttc'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r'; $sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid; @@ -2111,7 +2115,7 @@ if ($action == 'create') if ($num > 0) { print ''; + print ''; + // Option to reload page to retrieve customer informations. Note, this clear other input + if (!empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE)) + { + print ''; + } + print ''; } $db->free($resql); } else { @@ -2402,7 +2421,7 @@ if ($action == 'create') $langs->load('projects'); print ''; } @@ -3548,7 +3567,7 @@ else if ($id > 0 || ! empty($ref)) print '
'.$langs->trans("AccountancyCode").''.length_accountg($account->account_number).'
'; + if (! empty($conf->accounting->enabled)) { + print length_accountg($account->account_number).'
url).'">'; print '
'.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT); + foreach($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print "
'.$langs->trans("Comment").''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 123f4537a58..92c21742baa 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -588,7 +589,7 @@ class Account extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account"); - $result=$this->update(); + $result=$this->update($user); if ($result > 0) { $accline = new AccountLine($this->db); @@ -892,6 +893,49 @@ class Account extends CommonObject } } + /** + * Sets object to supplied categories. + * + * Deletes object from existing categories not supplied. + * Adds it to non existing supplied categories. + * Existing categories are left untouch. + * + * @param int[]|int $categories Category or categories IDs + */ + public function setCategories($categories) { + // Handle single category + if (! is_array($categories)) { + $categories = array($categories); + } + + // Get current categories + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $c = new Categorie($this->db); + $existing = $c->containing($this->id, Categorie::TYPE_ACCOUNT, 'id'); + + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $categories); + $to_add = array_diff($categories, $existing); + } else { + $to_del = array(); // Nothing to delete + $to_add = $categories; + } + + // Process + foreach($to_del as $del) { + if ($c->fetch($del) > 0) { + $c->del_type($this, 'account'); + } + } + foreach ($to_add as $add) { + if ($c->fetch($add) > 0) { + $c->add_type($this, 'account'); + } + } + + return; + } /** * Delete bank account from database @@ -1100,15 +1144,19 @@ class Account extends CommonObject */ public static function countAccountToReconcile() { - global $db, $conf, $langs; - - if ($user->societe_id) return 0; // protection pour eviter appel par utilisateur externe + global $db, $conf, $user; + + //Protection against external users + if ($user->societe_id) { + return 0; + } $nb=0; $sql = "SELECT COUNT(ba.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; + $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2"; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index db7f37cb3e5..0cee6211b49 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -136,7 +136,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print '
'.$langs->trans("RemainderToPay").' 
' . $langs->trans('CreateFromRepeatableInvoice') . ''; - print ''; print ''; while ($i < $num) { @@ -2122,7 +2126,22 @@ if ($action == 'create') print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')'; $i ++; } - print '
' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id.($fac_rec?'&fac_rec='.$fac_rec:'')).'">' . $langs->trans("AddProject") . ''; print '
'; print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 0acd58f0202..cddd511dbe4 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -53,7 +53,7 @@ class FactureRec extends CommonInvoice var $propalid; var $date_last_gen; - var $next_gen; + var $date_when; var $nb_gen_done; var $nb_gen_max; @@ -341,6 +341,17 @@ class FactureRec extends CommonInvoice } + /** + * Create an array of invoice lines + * + * @return int >0 if OK, <0 if KO + */ + function getLinesArray() + { + return $this->fetch_lines(); + } + + /** * Recupere les lignes de factures predefinies dans this->lines * @@ -348,16 +359,23 @@ class FactureRec extends CommonInvoice */ function fetch_lines() { + $this->lines=array(); + $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; $sql.= ' l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.total_ht, l.total_tva, l.total_ttc,'; + $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + //$sql.= ' l.situation_percent, l.fk_prev_id,'; + //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; + //$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.fk_unit, l.fk_contract_line,'; + //$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; - + $sql.= ' ORDER BY l.rang'; + dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); if ($result) @@ -387,10 +405,6 @@ class FactureRec extends CommonInvoice $line->remise_percent = $objp->remise_percent; $line->fk_remise_except = $objp->fk_remise_except; $line->fk_product = $objp->fk_product; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -415,7 +429,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error=$this->db-lasterror(); return -3; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4dbf4b9020a..bea200f2656 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -7,13 +7,14 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Cedric Gross * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -280,24 +281,27 @@ class Facture extends CommonInvoice $this->socid = $_facrec->socid; + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; - $this->fk_account = $_facrec->fk_account; - $this->cond_reglement_id = $_facrec->cond_reglement_id; - $this->mode_reglement_id = $_facrec->mode_reglement_id; + $this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; + $this->note_private = GETPOST('note_private') ? GETPOST('note_private') : $_facrec->note_private; + $this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf; + $this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id; + $this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; + $this->fk_account = GETPOST('fk_account') > 0 ? GETPOST('fk_account') : $_facrec->fk_account; + + // Fields always coming from template $this->remise_absolue = $_facrec->remise_absolue; $this->remise_percent = $_facrec->remise_percent; $this->fk_incoterms = $_facrec->fk_incoterms; $this->location_incoterms= $_facrec->location_incoterms; - $this->note_public = $_facrec->note_public; - $this->note_private = $_facrec->note_private; - // Clean parameters if (! $this->type) $this->type = self::TYPE_STANDARD; $this->ref_client=trim($this->ref_client); $this->note_public=trim($this->note_public); $this->note_private=trim($this->note_private); - $this->note_private=dol_concatdesc($facture->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); //if (! $this->remise) $this->remise = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; @@ -730,7 +734,7 @@ class Facture extends CommonInvoice */ function createFromClone($socid=0) { - global $conf,$user,$langs,$hookmanager; + global $user,$hookmanager; $error=0; @@ -845,7 +849,7 @@ class Facture extends CommonInvoice */ function createFromOrder($object) { - global $conf,$user,$langs,$hookmanager; + global $user,$hookmanager; $error=0; @@ -1285,7 +1289,6 @@ class Facture extends CommonInvoice */ function update($user=null, $notrigger=0) { - global $conf, $langs; $error=0; // Clean parameters @@ -1678,7 +1681,6 @@ class Facture extends CommonInvoice */ function set_paid($user,$close_code='',$close_note='') { - global $conf,$langs; $error=0; if ($this->paye != 1) @@ -1736,7 +1738,6 @@ class Facture extends CommonInvoice */ function set_unpaid($user) { - global $conf,$langs; $error=0; $this->db->begin(); @@ -1786,9 +1787,6 @@ class Facture extends CommonInvoice */ function set_canceled($user,$close_code='',$close_note='') { - global $conf,$langs; - - $error=0; dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); @@ -2459,6 +2457,7 @@ class Facture extends CommonInvoice */ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null) { + global $conf,$user; // Deprecation warning if ($label) { dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); @@ -2537,6 +2536,19 @@ class Facture extends CommonInvoice $line = new FactureLigne($this->db); $line->fetch($rowid); + if (!empty($line->fk_product)) + { + $product=new Product($this->db); + $result=$product->fetch($line->fk_product); + $product_type=$product->type; + + if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + $this->error=$langs->trans('ErrorStockIsNotEnough'); + $this->db->rollback(); + return -3; + } + } + $staticline = clone $line; $line->oldline = $staticline; @@ -2589,7 +2601,7 @@ class Facture extends CommonInvoice $this->line->array_options=$array_options; } - $result=$this->line->update(); + $result=$this->line->update($user); if ($result > 0) { // Reorder if child line @@ -2650,7 +2662,7 @@ class Facture extends CommonInvoice */ function update_percent($line, $percent) { - global $mysoc; + global $mysoc,$user; include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); @@ -2663,7 +2675,7 @@ class Facture extends CommonInvoice $line->total_ttc = $tabprice[2]; $line->total_localtax1 = $tabprice[9]; $line->total_localtax2 = $tabprice[10]; - $line->update(); + $line->update($user); $this->update_price(1); $this->db->commit(); } @@ -2676,7 +2688,6 @@ class Facture extends CommonInvoice */ function deleteline($rowid) { - global $langs, $conf; dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); @@ -2914,7 +2925,7 @@ class Facture extends CommonInvoice */ function getNextNumRef($soc,$mode='next') { - global $conf, $db, $langs; + global $conf, $langs; $langs->load("bills"); // Clean parameters (if not defined or using deprecated value) @@ -2976,7 +2987,7 @@ class Facture extends CommonInvoice * set up mask. */ if ($mode != 'last' && !$numref) { - dol_print_error($db,"Facture::getNextNumRef ".$obj->error); + dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); return ""; } @@ -3290,7 +3301,6 @@ class Facture extends CommonInvoice */ function demande_prelevement($fuser, $amount=0) { - global $langs; $error=0; @@ -3510,7 +3520,7 @@ class Facture extends CommonInvoice */ function initAsSpecimen($option='') { - global $user,$langs,$conf; + global $langs; $now=dol_now(); $arraynow=dol_getdate($now); @@ -3695,7 +3705,7 @@ class Facture extends CommonInvoice */ public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$langs; $langs->load("bills"); @@ -3795,7 +3805,6 @@ class Facture extends CommonInvoice */ function setFinal() { - global $conf, $langs, $user; $this->db->begin(); @@ -4259,7 +4268,7 @@ class FactureLigne extends CommonInvoiceLine */ function update($user='',$notrigger=0) { - global $user,$langs,$conf; + global $user,$conf; $error=0; @@ -4385,9 +4394,7 @@ class FactureLigne extends CommonInvoiceLine */ function delete() { - global $conf,$langs,$user; - - $error=0; + global $user; $this->db->begin(); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index ad9626718c6..b826e4f266d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load('bills'); $langs->load('compta'); @@ -50,18 +51,29 @@ if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); $projectid = GETPOST('projectid','int'); -if ($page == -1) -{ - $page = 0 ; -} +$search_ref=GETPOST('search_ref'); +$search_societe=GETPOST('search_societe'); +$search_montant_ht=GETPOST('search_montant_ht'); +$search_montant_vat=GETPOST('search_montant_vat'); +$search_montant_ttc=GETPOST('search_montant_ttc'); +$day=GETPOST('day'); +$year=GETPOST('year'); +$month=GETPOST('month'); +$day_date_when=GETPOST('day_date_when'); +$year_date_when=GETPOST('year_date_when'); +$month_date_when=GETPOST('month_date_when'); +$search_frequency=GETPOST('search_frequency'); + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page ; - -if ($sortorder == "") -$sortorder="DESC"; - -if ($sortfield == "") -$sortfield="f.datef"; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +if (! $sortorder) $sortorder='DESC'; +if (! $sortfield) $sortfield='f.titre'; +$pageprev = $page - 1; +$pagenext = $page + 1; $object = new FactureRec($db); if (($id > 0 || $ref) && $action != 'create' && $action != 'add') @@ -73,13 +85,45 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } } +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('invoicecard','globalcard')); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('facturerec'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php + +$arrayfields=array( + 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), + 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), + 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), + 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), + 'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), + 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), + 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), + 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + /* * Actions */ // Set note -$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once @@ -101,7 +145,7 @@ if ($action == 'add') $rehour=GETPOST('rehour'); $remin=GETPOST('remin'); $nb_gen_max=GETPOST('nb_gen_max', 'int'); - if (empty($nb_gen_max)) $nb_gen_max =0; + //if (empty($nb_gen_max)) $nb_gen_max =0; if (GETPOST('frequency')) { @@ -111,7 +155,7 @@ if ($action == 'add') $action = "create"; $error++; } - if ($nb_gen_max == '') + if ($nb_gen_max === '') { setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); $action = "create"; @@ -122,7 +166,8 @@ if ($action == 'add') if (! $error) { $object->titre = GETPOST('titre', 'alpha'); - $object->note_private = GETPOST('note_private'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); $object->usenewprice = GETPOST('usenewprice'); $object->frequency = $frequency; @@ -570,6 +615,24 @@ if ($action == 'addline' && $user->rights->facture->creer) } } +// Do we click on purge search criteria ? +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=''; + $search_societe=''; + $search_montant_ht=''; + $search_montant_vat=''; + $search_montant_ttc=''; + $day=''; + $year=''; + $month=''; + $day_date_when=''; + $year_date_when=''; + $month_date_when=''; + $search_frequency=''; + $search_array_options=array(); +} + /* @@ -579,6 +642,7 @@ if ($action == 'addline' && $user->rights->facture->creer) llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec'); $form = new Form($db); +$formother = new FormOther($db); $companystatic = new Societe($db); $now = dol_now(); @@ -599,7 +663,9 @@ if ($action == 'create') if ($object->fetch($id, $ref) > 0) { - print '
'; + $result = $object->getLinesArray(); + + print ''; print ''; print ''; print ''; @@ -616,20 +682,23 @@ if ($action == 'create') // Third party print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; - print ''; - print $langs->trans("Comment"); - print ''; + print ''; // Title print ''.$langs->trans("Title").''; print ''; - print ''; - - // Note - print ''; - print ''; print ''; + // Note public + print ''.$langs->trans("NotePublic").''; + print ''; + print ''; + + // Note private + print ''.$langs->trans("NotePrivate").''; + print ''; + print ''; + // Author print "".$langs->trans("Author")."".$user->getFullName($langs).""; @@ -648,7 +717,7 @@ if ($action == 'create') { $projectid = $object->fk_project; $langs->load('projects'); - print '' . $langs->trans('Project') . ''; + print '' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); print '   id).'">' . $langs->trans("AddProject") . ''; print ''; @@ -707,10 +776,22 @@ if ($action == 'create') print load_fiche_titre($title, '', ''); - /* * Invoice lines */ + print ''; + // Show object lines + if (! empty($object->lines)) + { + $disableedit=1; + $disablemove=1; + $disableremove=1; + $ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice + } + + print "
\n"; + + /* print ''; print '
'; @@ -877,7 +958,8 @@ if ($action == 'create') print $db->error(); } print "
"; - + */ + print ''; if ($flag_price_may_change) @@ -1007,7 +1089,15 @@ else } print ''; + // Note public + print ''; + print $form->editfieldkey($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer); + print ''; + print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60'); + print ''; + print ''; + // Note private print ''; print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer); print ''; @@ -1208,7 +1298,7 @@ else if (! empty($object->lines)) { $disableedit=1; - $disablemove=1; + //$disablemove=1; $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 0); // No date selector for template invoice } @@ -1287,15 +1377,47 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($search_ref) $sql .= natural_search('f.titre', $search_ref); + if ($search_societe) $sql .= natural_search('s.nom', $search_societe); + if ($search_frequency) $sql .= natural_search('f.frequency', $search_frequency); + if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); + if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); + if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); + if ($month > 0) + { + if ($year > 0 && empty($day)) + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + else + $sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'"; + } + else if ($year > 0) + { + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } + if ($month_date_when > 0) + { + if ($year_date_when > 0 && empty($day_date_when)) + $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'"; + else if ($year_date_when > 0 && ! empty($day_date_when)) + $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'"; + else + $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'"; + } + else if ($year_date_when > 0) + { + $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'"; + } - $nbtotalofrecords = 0; + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - + + $sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); @@ -1305,6 +1427,29 @@ else $param='&socid='.$socid; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($day) $param.='&day='.$day; + if ($month) $param.='&month='.$month; + if ($year) $param.='&year=' .$year; + if ($day_date_when) $param.='&day_date_when='.$day_date_when; + if ($month_date_when) $param.='&month_date_when='.$month_date_when; + if ($year_date_when) $param.='&year_date_when=' .$year_date_when; + if ($search_ref) $param.='&search_ref=' .$search_ref; + if ($search_societe) $param.='&search_societe=' .$search_societe; + if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; + if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; + if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; + if ($search_frequency) $param.='&search_frequency=' .$search_frequency; + if ($option) $param.="&option=".$option; + if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } + + $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); print ''."\n"; if ($optioncss != '') print ''; @@ -1313,25 +1458,133 @@ else print ''; print ''; print ''; - - print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecord,'title_accountancy.png',0,'','',$limit); + + print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; $i = 0; print ''; print ''; - print_liste_field_titre($langs->trans("Ref")); - print_liste_field_titre($langs->trans("Company"),$_SERVER['PHP_SELF'],"s.nom","","&socid=$socid","",$sortfiled,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),'','','','','align="right"'); - print_liste_field_titre($langs->trans("AmountVAT"),'','','','','align="right"'); - print_liste_field_titre($langs->trans("AmountTTC"),'','','','','align="right"'); - print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),'','','','','align="center"'); - print_liste_field_titre($langs->trans("DateLastGeneration"),'','','','','align="center"'); - print_liste_field_titre($langs->trans("NextDateToExecution"),'','','','','align="center"'); + print_liste_field_titre($langs->trans("Ref"),$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountHT"),$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountVAT"),$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateLastGeneration"),$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("NextDateToExecution"),$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); // Field may contains ling text print "\n"; + + // Filters lines + print ''; + // Ref + if (! empty($arrayfields['f.titre']['checked'])) + { + print ''; + } + // Thirpdarty + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.total']['checked'])) + { + // Amount + print ''; + } + if (! empty($arrayfields['f.tva']['checked'])) + { + // Amount + print ''; + } + if (! empty($arrayfields['f.total_ttc']['checked'])) + { + // Amount + print ''; + } + if (! empty($arrayfields['f.frequency']['checked'])) + { + // Amount + print ''; + } + // Date invoice + if (! empty($arrayfields['f.date_last_gen']['checked'])) + { + print ''; + } + // Date due + if (! empty($arrayfields['f.date_when']['checked'])) + { + print ''; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['f.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['f.tms']['checked'])) + { + print ''; + } + // Action column + print ''; + print "\n"; + + if ($num > 0) { $var=true; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e2883081452..68eb4240226 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -153,6 +153,7 @@ $arrayfields=array( 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), 'am'=>array('label'=>$langs->trans("Received"), 'checked'=>0), + 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), @@ -694,7 +695,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search('f.total', $search_montant_vat, 1); +if ($search_montant_vat != '') $sql.= natural_search('f.total_vat', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; @@ -997,6 +998,7 @@ if ($resql) if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'],$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['am']['checked'])) print_liste_field_titre($arrayfields['am']['label'],$_SERVER['PHP_SELF'],'am','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'rtp','',$param,'align="right"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -1117,6 +1119,11 @@ if ($resql) print ''; } + if (! empty($arrayfields['rtp']['checked'])) + { + print ''; + } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -1195,6 +1202,7 @@ if ($resql) $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); $notetoshow=dol_string_nohtmltag(($user->societe_id>0?$obj->note_public:$obj->note_private),1); $paiement = $facturestatic->getSommePaiement(); + $remaintopay = $obj->total_ttc - $paiement; print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5); + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); + print $searchpitco; + print '
'; print ''; + print '
'; @@ -1347,6 +1355,14 @@ if ($resql) if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; $totalarray['totalam'] += $paiement; } + + if (! empty($arrayfields['rtp']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; + $totalarray['totalrtp'] += $remaintopay; + } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -1425,6 +1441,7 @@ if ($resql) elseif ($totalarray['totalvatfield'] == $i) print ''; elseif ($totalarray['totalttcfield'] == $i) print ''; elseif ($totalarray['totalamfield'] == $i) print ''; + elseif ($totalarray['totalrtpfield'] == $i) print ''; else print ''; } print ''; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 0f513412a93..f0a8c82df1b 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -199,7 +199,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) } else { - print ''; + print ''; } print "
'.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).''.price($totalarray['totalam']).''.price($totalarray['totalrtp']).'
'.$langs->trans("NoInvoice").'
'.$langs->trans("NoInvoice").'

"; $db->free($resql); @@ -275,7 +275,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- } else { - print ''.$langs->trans("NoInvoice").''; + print ''.$langs->trans("NoInvoice").''; } print "
"; $db->free($resql); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 6a31fc02b4c..2d9241301a6 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -382,7 +382,7 @@ print ''; * Charges sociales non deductibles */ -print ''.$langs->trans("SocialContributions").' ('.$langs->trans("Type").' 0)'; +print ''.$langs->trans("SocialContributionsNondeductibles").''; if ($modecompta == 'CREANCES-DETTES') { @@ -456,7 +456,7 @@ print ''; * Charges sociales deductibles */ -print ''.$langs->trans("SocialContributions").' ('.$langs->trans("Type").' 1)'; +print ''.$langs->trans("SocialContributionsDeductibles").''; if ($modecompta == 'CREANCES-DETTES') { diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index ca58ff334b5..8e4aabd9339 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -181,6 +181,8 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl // SQL request $catotal=0; +$catotal_ht=0; +$qtytotal=0; if ($modecompta == 'CREANCES-DETTES') { @@ -401,6 +403,8 @@ if ($modecompta == 'CREANCES-DETTES') // Total print ''; print ''.$langs->trans("Total").''; + print ''.price($qtytotal).''; + print ' '; print ''.price($catotal_ht).''; print ''.price($catotal).''; print ' '; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 88cd24af359..259918c5aa9 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -107,6 +107,47 @@ class Contact extends CommonObject $this->db = $db; $this->statut = 1; // By default, status is enabled } + + /** + * Load indicators into this->nb for board + * + * @return int <0 if KO, >0 if OK + */ + function load_state_board() + { + global $user; + + $this->nb=array(); + $clause = "WHERE"; + + $sql = "SELECT count(sp.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (sp.fk_soc = s.rowid)"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = "AND"; + } + $sql.= ' '.$clause.' s.entity IN ('.getEntity($this->element, 1).')'; + + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["contacts"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->lasterror(); + return -1; + } + } /** * Add a contact into database diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index f962a9e82ae..18a60a3429d 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -273,7 +273,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) } else { - print ''.$langs->trans("NoContracts").''; + print ''.$langs->trans("NoContracts").''; } print "
"; $db->free($resql); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ec02fce3dae..3287ac5d4b7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -229,12 +229,13 @@ abstract class CommonObject public $mode_reglement_id; /** - * @var string Payment terms ID + * @var int Payment terms ID * @see setPaymentTerms() */ public $cond_reglement_id; /** - * @deprecated + * @var int Payment terms ID + * @deprecated Kept for compatibility * @see cond_reglement_id; */ public $cond_reglement; @@ -3236,7 +3237,9 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $langs, $user; + global $conf, $hookmanager, $langs, $user; + // TODO We should not use global var for this ! + global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove; // Define usemargins $usemargins=0; @@ -3984,7 +3987,7 @@ abstract class CommonObject function call_trigger($trigger_name, $user) { global $langs,$conf; - + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); $result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf); @@ -4248,7 +4251,7 @@ abstract class CommonObject if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used - if (! empty($this->array_options) && !empty($this->array_options["options_$key"])) + if (! empty($this->array_options) && isset($this->array_options["options_".$key])) { // Check parameters $langs->load('admin'); @@ -4256,7 +4259,7 @@ abstract class CommonObject $extrafields = new ExtraFields($this->db); $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); - $value=$this->array_options["options_$key"]; + $value=$this->array_options["options_".$key]; $attributeType = $extrafields->attribute_type[$key]; $attributeLabel = $extrafields->attribute_label[$key]; $attributeParam = $extrafields->attribute_param[$key]; @@ -4270,17 +4273,17 @@ abstract class CommonObject } elseif ($value=='') { - $this->array_options["options_$key"] = null; + $this->array_options["options_".$key] = null; } break; case 'price': - $this->array_options["options_$key"] = price2num($this->array_options["options_$key"]); + $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); break; case 'date': - $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); + $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); break; case 'datetime': - $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); + $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); break; case 'link': $param_list=array_keys($attributeParam ['options']); @@ -4292,13 +4295,13 @@ abstract class CommonObject if ($value) { $object->fetch(0,$value); - $this->array_options["options_$key"]=$object->id; + $this->array_options["options_".$key]=$object->id; } break; } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key='".$this->db->escape($this->array_options["options_$key"])."'"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key."='".$this->db->escape($this->array_options["options_".$key])."'"; $sql .= " WHERE fk_object = ".$this->id; $resql = $this->db->query($sql); if (! $resql) @@ -4559,7 +4562,7 @@ abstract class CommonObject $productFournisseur = new ProductFournisseur($this->db); if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0) { - $buyPrice = $productFournisseur->fourn_price; + $buyPrice = $productFournisseur->fourn_unitprice; } else if ($result < 0) { diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 8564a18822e..ff31823976e 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -52,7 +52,7 @@ class DolEditor * @param string $content Content of WYSIWIG field * @param int $width Width in pixel of edit area (auto by default) * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', ') + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly') * @param string $toolbarlocation Where bar is stored : * 'In' each window has its own toolbar * 'Out:name' share toolbar into the div called 'name' @@ -148,7 +148,10 @@ class DolEditor { global $conf,$langs; - $found=0; + $fullpage=False; + $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed + + $found=0; $out=''; if ($this->tool == 'fckeditor') @@ -186,7 +189,8 @@ class DolEditor customConfig : ckeditorConfig, readOnly : '.($this->readonly?'true':'false').', htmlEncodeOutput :'.$htmlencode_force.', - allowedContent :'.(empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)?'false':'true').', + allowedContent :'.($disallowAnyContent?'false':'true').', + fullPage : '.($fullpage?'true':'false').', toolbar: \''.$this->toolbarname.'\', toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').', width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').', diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 97645487d45..8d61733e138 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -63,7 +63,7 @@ class ExtraFields var $errno; var $attribute_hidden; - + public static $type2label=array( 'varchar'=>'String', 'text'=>'TextLong', @@ -665,6 +665,7 @@ class ExtraFields $param=$this->attribute_param[$key]; $perms=$this->attribute_perms[$key]; $list=$this->attribute_list[$key]; + $hidden=$this->attribute_hidden[$key]; if (empty($showsize)) { @@ -686,7 +687,7 @@ class ExtraFields if ($showsize > 48) $showsize=48; } } - + if (in_array($type,array('date','datetime'))) { $tmp=explode(',',$size); @@ -823,7 +824,7 @@ class ExtraFields if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); } - + // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); @@ -841,14 +842,14 @@ class ExtraFields $sqlwhere.= ' WHERE '.$InfoFieldList[4]; } } - else + else { $sqlwhere.= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. - if (in_array($InfoFieldList[0],array('tablewithentity'))) + if (in_array($InfoFieldList[0],array('tablewithentity'))) { - $sqlwhere.= ' AND entity = '.$conf->entity; + $sqlwhere.= ' AND entity = '.$conf->entity; } $sql.=$sqlwhere; //print $sql; @@ -1007,19 +1008,19 @@ class ExtraFields $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (! empty($InfoFieldList[4])) { - + // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); } - + // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); } else { $InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]); } - + // We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; @@ -1031,13 +1032,13 @@ class ExtraFields $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. - if (in_array($InfoFieldList[0], array ('tablewithentity'))) + if (in_array($InfoFieldList[0], array ('tablewithentity'))) { $sqlwhere .= ' AND entity = ' . $conf->entity; } // $sql.=preg_replace('/^ AND /','',$sqlwhere); // print $sql; - + $sql .= $sqlwhere; dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG); $resql = $this->db->query($sql); @@ -1143,6 +1144,9 @@ class ExtraFields $out.='Error bad setup of extrafield'; } } + if (!empty($hidden)) { + $out=''; + } /* Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; @@ -1171,6 +1175,7 @@ class ExtraFields $params=$this->attribute_param[$key]; $perms=$this->attribute_perms[$key]; $list=$this->attribute_list[$key]; + $hidden=$this->attribute_hidden[$key]; $showsize=0; if ($type == 'date') @@ -1402,10 +1407,14 @@ class ExtraFields $showsize=round($size); if ($showsize > 48) $showsize=48; } - + //print $type.'-'.$size; $out=$value; - + + if (!empty($hidden)) { + $out=''; + } + return $out; } @@ -1422,7 +1431,7 @@ class ExtraFields $type=$this->attribute_type[$key]; $align=''; - + if ($type == 'date') { $align="center"; @@ -1451,10 +1460,10 @@ class ExtraFields { $align="center"; } - + return $align; } - + /** * Return HTML string to print separator extrafield * @@ -1534,7 +1543,7 @@ class ExtraFields return 0; } } - + /** * return array_options array for object by extrafields value (using for data send by forms) * diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 7d4dff8de44..ef990d8edf3 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -39,6 +39,7 @@ class Fiscalyear extends CommonObject var $label; var $date_start; var $date_end; + var $datec; var $statut; // 0=open, 1=closed var $entity; diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index f92056893b6..484b6518f77 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -135,6 +135,7 @@ class HookManager $method, array( 'addMoreActionsButtons', + 'addSearchEntry', 'addStatisticLine', 'deleteFile', 'doActions', diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 697e5e8bdeb..74cd27bc460 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -390,6 +390,7 @@ class Form * @param int $noencodehtmltext Do not encode into html entity the htmltext * @return string Code html du tooltip (texte+picto) * @see Use function textwithpicto if you can. + * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip */ function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0) { @@ -2057,17 +2058,27 @@ class Form { global $langs,$conf; global $price_level, $status, $finished; - + + $selected_input_value=''; if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { + if ($selected > 0) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $producttmpselect = new Product($this->db); + $producttmpselect->fetch($selected); + $selected_input_value=$producttmpselect->ref; + unset($producttmpselect); + } + if (!empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) { print ''; } // mode=2 means suppliers products $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished; - print ajax_autocompleter('', $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); - print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').''; + print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').''; } else { @@ -2089,7 +2100,7 @@ class Form * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param string $filtre Pour filtre sql * @param string $filterkey Filtre des produits - * @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell (not used here, a filter on tobuy is already hard coded in request) * @param int $outputmode 0=HTML select string, 1=Array * @param int $limit Limit of line number * @return array Array of keys for json @@ -2106,7 +2117,7 @@ class Form $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, p.fk_product_type,"; $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; - $sql.= " pfp.supplier_reputation"; + $sql.= " pfp.supplier_reputation"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; if ($socid) $sql.= " AND pfp.fk_soc = ".$socid; @@ -2390,10 +2401,10 @@ class Form $form.= $opt; $i++; } - $form.= ''; - - $this->db->free($result); } + + $form.= ''; + $this->db->free($result); return $form; } else @@ -5239,7 +5250,7 @@ class Form * * @param CommonObject $object Object we want to show links to * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order') - * @return int <0 if KO, >0 if OK + * @return string <0 if KO, >0 if OK */ function showLinkToObjectBlock($object, $restrictlinksto=array()) { @@ -5457,7 +5468,7 @@ class Form * @param int $option 0 return yes/no, 1 return 1/0 * @param bool $disabled true or false * @param int $useempty 1=Add empty line - * @return mixed See option + * @return string See option */ function selectyesno($htmlname,$value='',$option=0,$disabled=false,$useempty='') { @@ -5799,7 +5810,7 @@ class Form * @param string $include Array list of groups id to include * @param int $enableonly Array list of groups id to be enabled. All other must be disabled * @param int $force_entity 0 or Id of environment to force - * @return void + * @return string * @see select_dolusers */ function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 04d643d4b2f..9abf943d948 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -82,7 +82,7 @@ class FormAccounting $sql.= " ORDER BY c.label ASC"; } - dol_syslog("Form::select_accounting_category", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); $resql=$db->query($sql); if ($resql) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 5af984ba659..f446caa12a2 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -805,6 +805,7 @@ class FormOther $select_week .= ''; } $select_week .= ''; return $select_week; @@ -844,6 +845,7 @@ class FormOther $select_month .= ''; } $select_month .= ''; return $select_month; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index c532fd799bd..f160e4cd500 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -138,7 +138,7 @@ class FormProjets $sql.= " WHERE p.entity IN (".getEntity('project', 1).")"; if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; - if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; + if ($socid > 0 && empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; if (!empty($filterkey)) { $sql .= ' AND p.title LIKE "%'.$this->db->escape($filterkey).'%"'; $sql .= ' OR p.ref LIKE "%'.$this->db->escape($filterkey).'%"'; @@ -204,7 +204,7 @@ class FormProjets if ($discard_close == 2) $disabled=1; $labeltoshow.=' - '.$langs->trans("Closed"); } - else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) + else if ( empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) { $disabled=1; $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 7b233a4fff8..1ac219029fd 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -77,7 +77,7 @@ class Interfaces $modules = array(); $orders = array(); $i=0; - + $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); foreach($dirtriggers as $reldir) { @@ -100,9 +100,9 @@ class Interfaces $part3=$reg[3]; $nbfile++; - + $modName = "Interface".ucfirst($reg[3]); - //print "file=$file"; print "modName=$modName"; exit; + //print "file=$file - modName=$modName\n"; if (in_array($modName,$modules)) { $langs->load("errors"); @@ -111,9 +111,17 @@ class Interfaces } else { - include_once $newdir.'/'.$file; + try { + //print 'Todo for '.$modName." : ".$newdir.'/'.$file."\n"; + include_once $newdir.'/'.$file; + //print 'Done for '.$modName."\n"; + } + catch(Exception $e) + { + dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERROR); + } } - + // Check if trigger file is disabled by name if (preg_match('/NORUN$/i',$file)) continue; // Check if trigger file is for a particular module @@ -142,7 +150,7 @@ class Interfaces } asort($orders); - + // Loop on each trigger foreach ($orders as $key => $value) { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 866b746362b..34858bc3234 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -908,7 +908,8 @@ class Translate } /** - * Return a currency code into its symbol + * Return a currency code into its symbol. + * If mb_convert_encoding is not available, return currency code. * * @param string $currency_code Currency code * @param integer $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency. diff --git a/htdocs/core/filemanagerdol/browser/default/browser.php b/htdocs/core/filemanagerdol/browser/default/browser.php index f542bdf59b6..15e44621bcf 100644 --- a/htdocs/core/filemanagerdol/browser/default/browser.php +++ b/htdocs/core/filemanagerdol/browser/default/browser.php @@ -19,15 +19,20 @@ * along with this program. If not, see . */ -define('NOTOKENRENEWAL',1); // Disables token renewal +//define('NOTOKENRENEWAL',1); // Disables token renewal +//require '../../../../main.inc.php'; +require '../../connectors/php/config.php'; // This include the define('NOTOKENRENEWAL',1) and the require main.in.php + +global $Config; + + -require '../../../../main.inc.php'; ?> - FCKeditor - Resources Browser + <?php echo $langs->trans("MediaBrowser").' - '.$Config['UserFilesAbsolutePathRelative']; ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 967d9f81970..559cae91464 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -31,7 +31,7 @@ * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $usemargins (0 to disable all margins columns, 1 to show according to margin setup) * $object_rights->creer initialized from = $object->getRights() - * $disableedit, $disablemove + * $disableedit, $disablemove, $disableremove * * $type, $text, $description, $line */ @@ -46,7 +46,6 @@ if (empty($forceall)) $forceall=0; if (empty($senderissupplier)) $senderissupplier=0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; if (empty($usemargins)) $usemargins=0; - ?> @@ -216,7 +215,7 @@ if (empty($usemargins)) $usemargins=0; situation_counter == 1 || !$this->situation_cycle_ref) { + if (($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) { print 'id . '">'; print img_delete(); print ''; diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index e2add5fb266..482dad50085 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -13,7 +13,7 @@ $out .= ''; $out .= ''; $out .= ''; $out .= ''; -$out .= ''; +$out .= ''; // Place diff --git a/htdocs/custom/README.md b/htdocs/custom/README.md index 5f15148f685..82f92dfbeff 100644 --- a/htdocs/custom/README.md +++ b/htdocs/custom/README.md @@ -14,11 +14,9 @@ Then create the symbolic link ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule WARNING !!! -You must also enable the custom directory into dolibarr conf/conf.php file by adding the following +Check also that the custom directory into dolibarr conf/conf.php file by adding the following two lines, so dolibarr will also scan this directories to find external external modules: $dolibarr_main_url_root_alt='/custom'; $dolibarr_main_document_root_alt='/path_to_dolibarr/htdocs/custom/'; -(This is not enabled by default because enabling external module may slow down application) - diff --git a/htdocs/document.php b/htdocs/document.php index 1b3d494d1a1..52b1584e7af 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -65,6 +65,7 @@ $entity=GETPOST('entity')?GETPOST('entity','int'):$conf->entity; // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); +if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; @@ -97,7 +98,7 @@ if (preg_match('/\.(html|htm)$/i',$original_file)) $attachment = false; if (isset($_GET["attachment"])) $attachment = GETPOST("attachment")?true:false; if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; -// Suppression de la chaine de caractere ../ dans $original_file +// Security: Delete string ../ into $original_file $original_file = str_replace("../","/", $original_file); // Find the subdirectory name as the reference @@ -169,7 +170,6 @@ if (! file_exists($original_file_osencoded)) } // Permissions are ok and file found, so we return it - header('Content-Description: File Transfer'); if ($encoding) header('Content-Encoding: '.$encoding); if ($type) header('Content-Type: '.$type.(preg_match('/text/',$type)?'; charset="'.$conf->file->character_set_client:'')); @@ -183,7 +183,7 @@ header('Pragma: public'); //ob_clean(); //flush(); - + readfile($original_file_osencoded); if (is_object($db)) $db->close(); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4547a94566a..b4b82be7726 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -533,6 +533,12 @@ if (empty($reshook)) $object->set_billed(); } + elseif ($action == 'classifyclosed') + { + $object->fetch($id); + $object->setClosed(); + } + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails @@ -885,6 +891,7 @@ if ($action == 'create') //ship from preselected location $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number $deliverableQty=min($quantityToBeDelivered, $stock); + if ($deliverableQty < 0) $deliverableQty = 0; if (empty($conf->productbatch->enabled) || ! ($product->hasbatch() && is_object($product->stock_warehouse[$warehouse_id]))) { // Quantity to send @@ -1729,69 +1736,80 @@ else if ($id || $ref) { print '
'; - if ($object->statut == 0 && $num_prod > 0) + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))) - { - print ''.$langs->trans("Validate").''; - } - else - { - print ''.$langs->trans("Validate").''; - } - } - // TODO add alternative status - // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) - if ($object->statut == 2 && $object->billed && $user->rights->expedition->creer) - { - print ''.$langs->trans("ReOpen").''; + if ($object->statut == 0 && $num_prod > 0) + { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))) + { + print ''.$langs->trans("Validate").''; + } + else + { + print ''.$langs->trans("Validate").''; + } + } + + // TODO add alternative status + // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) + if ($object->statut == 2 && $object->billed && $user->rights->expedition->creer) + { + print ''.$langs->trans("ReOpen").''; + } + + // Send + if ($object->statut > 0) + { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) + { + print ''.$langs->trans('SendByMail').''; + } + else print ''.$langs->trans('SendByMail').''; + } + + // Create bill and Close shipment + if (! empty($conf->facture->enabled) && $object->statut > 0) + { + if ($user->rights->facture->creer) + { + print ''.$langs->trans("CreateBill").''; + } + } + + // This is just to generate a delivery receipt + //var_dump($object->linkedObjectsIds['delivery']); + if ($conf->livraison_bon->enabled && ($object->statut == 1 || $object->statut == 2) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0) + { + print ''.$langs->trans("CreateDeliveryOrder").''; + } + // Close + if (! empty($conf->facture->enabled) && $object->statut > 0) + { + if ($user->rights->expedition->creer && $object->statut > 0 && ! $object->billed) + { + $label="Close"; $paramaction='classifyclosed'; // = Transferred/Received + // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders + if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // TODO Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close. + { + $label="ClassifyBilled"; + $paramaction='classifybilled'; + } + print ''.$langs->trans($label).''; + } + } + + if ($user->rights->expedition->supprimer) + { + print ''.$langs->trans("Delete").''; + } + } - // Send - if ($object->statut > 0) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) - { - print ''.$langs->trans('SendByMail').''; - } - else print ''.$langs->trans('SendByMail').''; - } - - // Create bill and Close shipment - if (! empty($conf->facture->enabled) && $object->statut > 0) - { - if ($user->rights->facture->creer) - { - print ''.$langs->trans("CreateBill").''; - } - } - - // This is just to generate a delivery receipt - //var_dump($object->linkedObjectsIds['delivery']); - if ($conf->livraison_bon->enabled && ($object->statut == 1 || $object->statut == 2) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0) - { - print ''.$langs->trans("CreateDeliveryOrder").''; - } - - // Close - if (! empty($conf->facture->enabled) && $object->statut > 0) - { - if ($user->rights->expedition->creer && $object->statut > 0 && ! $object->billed) - { - $label="Close"; - // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders - if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $label="ClassifyBilled"; - print ''.$langs->trans($label).''; - } - } - - if ($user->rights->expedition->supprimer) - { - print ''.$langs->trans("Delete").''; - } - print '
'; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 9468475c32c..21e0adf518b 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2006-2012 Laurent Destailleur - * Copyright (C) 2011-2015 Juanjo Menent + * Copyright (C) 2011-2016 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Marcos García @@ -90,6 +90,7 @@ class Expedition extends CommonObject var $date_creation; var $date_valid; + var $meths; var $listmeths; // List of carriers /** @@ -119,7 +120,7 @@ class Expedition extends CommonObject */ function getNextNumRef($soc) { - global $db, $langs, $conf; + global $langs, $conf; $langs->load("sendings"); if (!empty($conf->global->EXPEDITION_ADDON_NUMBER)) @@ -156,7 +157,7 @@ class Expedition extends CommonObject } else { - dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); + dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } } @@ -176,7 +177,7 @@ class Expedition extends CommonObject */ function create($user, $notrigger=0) { - global $conf, $langs, $hookmanager; + global $conf, $hookmanager; $now=dol_now(); @@ -664,7 +665,7 @@ class Expedition extends CommonObject $langs->load("agenda"); // Loop on each product line to add a stock movement - // TODO possibilite d'expedier a partir d'une propale ou autre origine + // TODO in future, shipment lines may not be linked to order line $sql = "SELECT cd.fk_product, cd.subprice,"; $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; @@ -738,7 +739,7 @@ class Expedition extends CommonObject if (! $error && ! $notrigger) { // Call trigger - $result=$this->call_trigger('SHIPPING_VALIDATE',$user); + $result=$this->call_trigger('SHIPPING_VALIDATE',$user); // TODO Add option in workflow module on this trigger to close order if sum of shipment = product to ship of order if ($result < 0) { $error++; } // End call triggers } @@ -878,16 +879,14 @@ class Expedition extends CommonObject $product=new Product($this->db); $result=$product->fetch($fk_product); - $product_type=$product->type; if ($entrepot_id > 0) { - $product->load_stock(); - $product_stock = $product->stock_warehouse[$entrepot_id]->real; + $product->load_stock(); + $product_stock = $product->stock_warehouse[$entrepot_id]->real; } - else - { - $product_stock = $product->stock_reel; - } - + else + $product_stock = $product->stock_reel; + + $product_type=$product->type; if ($product_type == 0 && $product_stock < $qty) { $this->error=$langs->trans('ErrorStockIsNotEnough'); @@ -980,7 +979,7 @@ class Expedition extends CommonObject */ function update($user=null, $notrigger=0) { - global $conf, $langs; + global $conf; $error=0; // Clean parameters @@ -1534,7 +1533,7 @@ class Expedition extends CommonObject */ function initAsSpecimen() { - global $user,$langs,$conf; + global $langs; $now=dol_now(); @@ -1646,7 +1645,7 @@ class Expedition extends CommonObject function fetch_delivery_methods() { global $langs; - $meths = array(); + $this->meths = array(); $sql = "SELECT em.rowid, em.code, em.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; @@ -1795,11 +1794,11 @@ class Expedition extends CommonObject } /** - * Classify the shipping as invoiced + * Classify the shipping as closed * * @return int <0 if ko, >0 if ok */ - function set_billed() + function setClosed() { global $conf,$langs,$user; @@ -1809,13 +1808,11 @@ class Expedition extends CommonObject $resql=$this->db->query($sql); if ($resql) { - //TODO: Add option/checkbox to set order billed if 100% of order is shipped + // TODO: Add option/checkbox to set order billed if 100% of order is shipped $this->statut=2; - $this->billed=1; - - - // If stock increment is done on sending (recommanded choice) - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) + + // If stock increment is done on closing + if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -1892,6 +1889,32 @@ class Expedition extends CommonObject } } + + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) + * + * @return int <0 if ko, >0 if ok + */ + function set_billed() + { + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; + + $resql=$this->db->query($sql); + if ($resql) + { + $this->statut=2; + $this->billed=1; return 1; } else @@ -2021,7 +2044,7 @@ class Expedition extends CommonObject */ public function generateDocument($modele, $outputlangs,$hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$langs; $langs->load("sendings"); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index be9d8ab49bd..a946649592a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1625,7 +1625,7 @@ else $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid'; $sql.= ' WHERE fde.fk_expensereport = '.$object->id; @@ -1691,7 +1691,7 @@ else } print ''; } - print ''.$langs->trans("TF_".strtoupper($objp->type_fees_libelle)).''; + print ''.$langs->trans("TF_".strtoupper(empty($objp->type_fees_libelle)?'OTHER':$objp->type_fees_libelle)).''; print ''.$objp->comments.''; print ''.vatrate($objp->vatrate,true).''; print ''.price($objp->value_unit).''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 2a281bda595..07c3e598818 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -746,7 +746,7 @@ class ExpenseReport extends CommonObject $sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $sql.= ' p.ref as ref_projet, p.title as title_projet'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid'; $sql.= ' WHERE de.'.$this->fk_element.' = '.$this->id; @@ -776,7 +776,7 @@ class ExpenseReport extends CommonObject $deplig->total_tva = $objp->total_tva; $deplig->total_ttc = $objp->total_ttc; - $deplig->type_fees_code = $objp->code_type_fees; + $deplig->type_fees_code = empty($objp->code_type_fees)?'TF_OTHER':$objp->code_type_fees; $deplig->type_fees_libelle = $objp->libelle_type_fees; $deplig->tva_tx = $objp->tva_tx; $deplig->vatrate = $objp->tva_tx; @@ -850,12 +850,9 @@ class ExpenseReport extends CommonObject { global $conf,$langs; + $this->oldref = $this->ref; $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; - // Sélection du numéro de ref suivant - $ref_next = $this->getNextNumRef(); - $ref_number_int = ($this->ref+1)-1; - // Sélection de la date de début de la NDF $sql = 'SELECT date_debut'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -864,21 +861,59 @@ class ExpenseReport extends CommonObject $objp = $this->db->fetch_object($result); $this->date_debut = $this->db->jdate($objp->date_debut); - // Création du ref_number suivant - if($ref_next) + $update_number_int = false; + + // Create next ref if ref is PROVxx + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { - $prefix="ER"; - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; - $this->ref = strtoupper($fuser->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d'); + // Sélection du numéro de ref suivant + $ref_next = $this->getNextNumRef(); + $ref_number_int = ($this->ref+1)-1; + $update_number_int = true; + // Création du ref_number suivant + if($ref_next) + { + $prefix="ER"; + if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; + $this->ref = strtoupper($fuser->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d'); + } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // We rename directory in order to avoid losing the attachments + $oldref = dol_sanitizeFileName($this->oldref); + $newref = dol_sanitizeFileName($this->ref); + $dirsource = $conf->expensereport->dir_output.'/'.$oldref; + $dirdest = $conf->expensereport->dir_output.'/'.$newref; + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->expensereport->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } } if ($this->fk_statut != 2) { $now = dol_now(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.", date_valid='".$this->db->idate($now)."',"; - $sql.= " ref_number_int = ".$ref_number_int; + $sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.", date_valid='".$this->db->idate($now)."'"; + if ($update_number_int) { + $sql.= ", ref_number_int = ".$ref_number_int; + } $sql.= ' WHERE rowid = '.$this->id; $resql=$this->db->query($sql); @@ -1265,7 +1300,9 @@ class ExpenseReport extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.rowid = ".$projet_id; $result = $this->db->query($sql); - $objp_projet = $this->db->fetch_object($result); + if ($result) { + $objp_projet = $this->db->fetch_object($result); + } $ligne->projet_ref = $objp_projet->ref_projet; $ligne->projet_title = $objp_projet->title_projet; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 7912b4f189f..6632f050550 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -225,7 +225,7 @@ class Export else $i++; if (strpos($key, ' as ')===false) { - $newfield=$key.' as '.str_replace(array('.', '-'),'_',$key); + $newfield=$key.' as '.str_replace(array('.', '-','(',')'),'_',$key); } else { $newfield=$key; } @@ -587,14 +587,14 @@ class Export if ($this->array_export_special[$indice][$key]=='NULLIFNEG') { //$alias=$this->array_export_alias[$indice][$key]; - $alias=str_replace(array('.', '-'),'_',$key); + $alias=str_replace(array('.', '-','(',')'),'_',$key); if ($objp->$alias < 0) $objp->$alias=''; } // Operation ZEROIFNEG if ($this->array_export_special[$indice][$key]=='ZEROIFNEG') { //$alias=$this->array_export_alias[$indice][$key]; - $alias=str_replace(array('.', '-'),'_',$key); + $alias=str_replace(array('.', '-','(',')'),'_',$key); if ($objp->$alias < 0) $objp->$alias='0'; } } diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index d78a2564e7c..50ca1e09a91 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("exports"); $langs->load("users"); $langs->load("companies"); +$langs->load("projects"); // Everybody should be able to go on this page //if (! $user->admin) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 69f01613f50..66fb1031d6e 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -89,6 +89,46 @@ class Fichinter extends CommonObject $this->statuts_logo[3]='statut4'; } + /** + * Load indicators into this->nb for board + * + * @return int <0 if KO, >0 if OK + */ + function load_state_board() + { + global $user; + + $this->nb=array(); + $clause = "WHERE"; + + $sql = "SELECT count(fi.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as fi"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = "AND"; + } + $sql.= " ".$clause." fi.entity IN (".getEntity($this->element, 1).")"; + + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["fichinters"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } /** * Create an intervention into data base diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 255d7f2cda0..b64a8ee77e4 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -518,15 +518,14 @@ if ($object->id > 0) /* * Barre d'actions */ + print '
'; + $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { - - print '
'; - - if ($user->rights->fournisseur->commande->creer) + if ($user->rights->fournisseur->commande->creer) { $langs->load("orders"); print ''.$langs->trans("AddOrder").''; @@ -562,9 +561,11 @@ if ($object->id > 0) print ''.$langs->trans("AddAction").''; } } - - print '
'; - print '
'; + } + + print '
'; + + print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) { @@ -589,7 +590,6 @@ if ($object->id > 0) // List of done actions show_actions_done($conf,$langs,$db,$object); } - } } else { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6f20c509fd8..cb7d0ce6e6f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1415,6 +1415,7 @@ class CommandeFournisseur extends CommonOrder $subprice = price2num($pu,'MU'); + // TODO We should use here $this->line=new CommandeFournisseurLigne($this->db); and $this->line->insert(); to work loke other object (proposal, order, invoice) $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql.= " (fk_commande, label, description, date_start, date_end,"; $sql.= " fk_product, product_type,"; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e209dd741d6..30296bc2e22 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry - * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2015 Ferran Marcet * @@ -694,7 +694,16 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (!$resql) { + $error++; + + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->errors[] = $langs->trans('ErrorRefAlreadyExists'); + } else { + $this->errors[] = "Error ".$this->db->lasterror(); + } + } if (! $error) { diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 03be7e77d36..48896689dce 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -613,7 +613,9 @@ class ProductFournisseur extends Product if ($fourn_unitprice < $min || $min == -1) { $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->fourn_ref = $record["ref_fourn"]; + $this->ref_supplier = $record["ref_fourn"]; + $this->ref_fourn = $record["ref_fourn"]; // deprecated + $this->fourn_ref = $record["ref_fourn"]; // deprecated $this->fourn_price = $fourn_price; $this->fourn_qty = $record["quantity"]; $this->fourn_remise_percent = $record["remise_percent"]; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8b9c6267b18..8d18914d62c 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -984,9 +984,16 @@ if (empty($reshook)) // If creation from another object of another module (Example: origin=propal, originid=1) if (! empty($origin) && ! empty($originid)) { - $element = 'supplier_proposal'; - $subelement = 'supplier_proposal'; - + if ($origin == 'order' || $origin == 'commande') + { + $element = $subelement = 'commande'; + } + else + { + $element = 'supplier_proposal'; + $subelement = 'supplier_proposal'; + } + $object->origin = $origin; $object->origin_id = $originid; @@ -1046,35 +1053,41 @@ if (empty($reshook)) $lines[$i]->fetch_optionals($lines[$i]->rowid); $array_option = $lines[$i]->array_options; } - - $res = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty); - /*if ($productsupplier->id > 0) - { - $res = $productsupplier->fetch($productsupplier->id); - }*/ - - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $productsupplier->product_fourn_price_id, - $productsupplier->ref_fourn, - $lines[$i]->remise_percent, - 'HT', - 0, - $lines[$i]->product_type, - '', - '', - null, - null, - array(), - $lines[$i]->fk_unit - ); + $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty); + if ($result>0) + { + $tva_tx = $lines[$i]->tva_tx; + + if ($origin=="commande") + { + $soc=new societe($db); + $soc->fetch($socid); + $tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $productsupplier->product_fourn_price_id); + } + + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $productsupplier->product_fourn_price_id, + $productsupplier->ref_supplier, + $lines[$i]->remise_percent, + 'HT', + 0, + $lines[$i]->product_type, + '', + '', + null, + null, + array(), + $lines[$i]->fk_unit + ); + } if ($result < 0) { $error++; break; @@ -2771,15 +2784,17 @@ elseif (! empty($object->id)) /** * Boutons actions */ - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if (empty($reshook)) + + if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') { - if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') - { - print '
'; + print '
'; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) + { + // Validate if ($object->statut == 0 && $num > 0) { @@ -2961,9 +2976,11 @@ elseif (! empty($object->id)) print ''.$langs->trans("Delete").''; } - print "
"; } + + print "
"; } + print "
"; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c1346c357d5..eb6392eba06 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -247,8 +247,11 @@ if (empty($reshook)) // Set supplier ref if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { - $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); - if ($result < 0) dol_print_error($db, $object->error); + $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); + + if ($object->update($user) < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // payments conditions diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index dafe95e419d..42810962275 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -225,10 +225,19 @@ if ($search_amount_all_tax != '') $sql .= natural_search('fac.total_ttc', $search_amount_all_tax, 1); } -if ($search_status != '') +if ($search_status != '' && $search_status>=0) { $sql.= " AND fac.fk_statut = ".$search_status; } +if ($filter && $filter != -1) +{ + $aFilter = explode(',', $filter); + foreach ($aFilter as $fil) + { + $filt = explode(':', $fil); + $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]); + } +} $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -265,7 +274,7 @@ if ($resql) if ($search_amount_no_tax) $param.='&search_amount_no_tax='.urlencode($search_amount_no_tax); if ($search_amount_all_tax) $param.='&search_amount_all_tax='.urlencode($search_amount_all_tax); if ($filter && $filter != -1) $param.='&filtre='.urlencode($filter); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($search_status >= 0) $param.="&search_status=".$search_status; print ''; diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index fb6f41f4f39..11179d218f8 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -136,7 +136,7 @@ else if ($action == 'update') $object->country_id = $_POST["country_id"]; $object->fk_user_mod = $user->id; - $result = $object->update(); + $result = $object->update($user); if ($result > 0) { diff --git a/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt b/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt new file mode 100755 index 00000000000..1076f8b4b2b --- /dev/null +++ b/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2009 Michael Aufreiter, http://www.quasipartikel.at + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css b/htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css new file mode 100755 index 00000000000..2072baa57c4 --- /dev/null +++ b/htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css @@ -0,0 +1,144 @@ +/* Multiselect +----------------------------------*/ +.multiselect { + width: 600px; + height: 150px; +} + +.ui-multiselect { + border: solid 1px; + font-size: 0.8em; +} + +.ui-multiselect ul { + -moz-user-select: none; +} + +.ui-multiselect li { + margin: 0; + padding: 0; + cursor: default; + line-height: 20px; + height: 20px; + font-size: 11px; + list-style: none; +} + +.ui-multiselect li a { + color: #999; + text-decoration: none; + padding: 0; + display: block; + float: left; + cursor: pointer; +} + +.ui-multiselect li.ui-draggable-dragging { + padding-left: 10px; +} + +.ui-multiselect div.selected { + position: relative; + padding: 0; + margin: 0; + border: 0; + float: left; +} + +.ui-multiselect ul.selected { + position: relative; + padding: 0; + overflow: auto; + overflow-x: hidden; + background: #fff; + margin: 0; + list-style: none; + border: 0; + position: relative; + width: 100%; +} + +.ui-multiselect ul.selected li { + +} + +.ui-multiselect div.available { + position: relative; + padding: 0; + margin: 0; + border: 0; + float: left; + border-left: 1px solid; +} + +.ui-multiselect ul.available { + position: relative; + padding: 0; + overflow: auto; + overflow-x: hidden; + background: #fff; + margin: 0; + list-style: none; + border: 0; + width: 100%; +} + +.ui-multiselect ul.available li { + padding-left: 10px; +} + +.ui-multiselect .ui-state-default { + border: none; + margin-bottom: 1px; + position: relative; + padding-left: 20px; +} + +.ui-multiselect .ui-state-hover { + border: none; +} + +.ui-multiselect .ui-widget-header { + border: none; + font-size: 11px; + margin-bottom: 1px; +} + +.ui-multiselect .add-all { + float: right; + padding: 7px; +} + +.ui-multiselect .remove-all { + float: right; + padding: 7px; +} + +.ui-multiselect .search { + float: left; + padding: 4px; +} + +.ui-multiselect .count { + float: left; + padding: 7px; +} + +.ui-multiselect li span.ui-icon-arrowthick-2-n-s { + position: absolute; + left: 2px; +} + +.ui-multiselect li a.action { + position: absolute; + right: 2px; + top: 2px; +} + +.ui-multiselect input.search { + height: 14px; + padding: 1px; + opacity: 0.5; + margin: 4px; + width: 100px; +} \ No newline at end of file diff --git a/htdocs/includes/jquery/plugins/multiselect/js/ui.multiselect.js b/htdocs/includes/jquery/plugins/multiselect/js/ui.multiselect.js new file mode 100755 index 00000000000..1234fa7a957 --- /dev/null +++ b/htdocs/includes/jquery/plugins/multiselect/js/ui.multiselect.js @@ -0,0 +1,336 @@ +/* + * jQuery UI Multiselect + * + * Authors: + * Michael Aufreiter (quasipartikel.at) + * Yanick Rochon (yanick.rochon[at]gmail[dot]com) + * + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://www.quasipartikel.at/multiselect/ + * + * + * Depends: + * ui.core.js + * ui.sortable.js + * + * Optional: + * localization (http://plugins.jquery.com/project/localisation) + * scrollTo (http://plugins.jquery.com/project/ScrollTo) + * + * Todo: + * Make batch actions faster + * Implement dynamic insertion through remote calls + */ + + +(function($) { + +$.widget("ui.multiselect", { + options: { + sortable: true, + searchable: true, + doubleClickable: true, + animated: 'fast', + show: 'slideDown', + hide: 'slideUp', + dividerLocation: 0.6, + nodeComparator: function(node1,node2) { + var text1 = node1.text(), + text2 = node2.text(); + return text1 == text2 ? 0 : (text1 < text2 ? -1 : 1); + } + }, + _create: function() { + this.element.hide(); + this.id = this.element.attr("id"); + this.container = $('
').insertAfter(this.element); + this.count = 0; // number of currently selected options + this.selectedContainer = $('
').appendTo(this.container); + this.availableContainer = $('
').appendTo(this.container); + this.selectedActions = $('
0 '+$.ui.multiselect.locale.itemsCount+''+$.ui.multiselect.locale.removeAll+'
').appendTo(this.selectedContainer); + this.availableActions = $('').appendTo(this.availableContainer); + this.selectedList = $('
').bind('selectstart', function(){return false;}).appendTo(this.selectedContainer); + this.availableList = $('
').bind('selectstart', function(){return false;}).appendTo(this.availableContainer); + + var that = this; + + // set dimensions + this.container.width(this.element.width()+1); + this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation)); + this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation))); + + // fix list height to match