diff --git a/.travis.yml b/.travis.yml index 74d951bf7bf..37c04fecd7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,6 @@ env: matrix: fast_finish: true allow_failures: - - php: '7.0' - php: nightly # FIXME #- env: DB=postgresql @@ -79,7 +78,11 @@ before_install: install: - | echo "Updating Composer" + rm $TRAVIS_BUILD_DIR/composer.json + rm $TRAVIS_BUILD_DIR/composer.lock composer self-update + composer -n init + composer -n config vendor-dir htdocs/includes echo - | @@ -100,13 +103,14 @@ install: - | echo "Installing PHP CodeSniffer" - composer require squizlabs/php_codesniffer ^2 + composer -n require squizlabs/php_codesniffer ^2 echo - | - echo "Adding Composer binaries to the path" + echo "Adding path of binaries tools installed by composer to the PATH" export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" echo + before_script: - | @@ -269,29 +273,31 @@ script: set +e cd htdocs/install php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log - php upgrade2.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360-2.log - php step5.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360-3.log + php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log + php step5.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-3.log php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log - php upgrade2.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370-2.log - php step5.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370-3.log + php upgrade2.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-2.log + php step5.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-3.log php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380-2.log - php step5.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380-3.log + php upgrade2.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-2.log + php step5.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-3.log php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390-2.log - php step5.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390-3.log + php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log + php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log - php upgrade2.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400-2.log - php step5.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400-3.log + php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API > $TRAVIS_BUILD_DIR/upgrade390400-2.log + php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log cd - set +e echo - + #cat $TRAVIS_BUILD_DIR/upgrade390400-2.log + #cat /tmp/dolibarr_install.log + - | echo "Unit testing" # Ensure we catch errors. Set this to +e if you want to go to the end to see log file. set -e - #phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php + phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php set +e - | 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/build/composer/README b/build/composer/README new file mode 100644 index 00000000000..d58359defec --- /dev/null +++ b/build/composer/README @@ -0,0 +1,10 @@ + +To test upgrade of a lib with composer: + +composer update --no-dev --no-autoloader --dry-run ccampbell/chromephp + +To upgrade a lib with composer: + +composer update --no-dev --no-autoloader ccampbell/chromephp + + diff --git a/composer.json b/composer.json index f4ea5de0c73..fb3109fbc40 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,18 @@ "irc": "irc://chat.freenode.net/dolibarr", "source": "https://github.com/Dolibarr/dolibarr" }, + "config": { + "vendor-dir": "htdocs/includes" + }, "require": { "php": ">=5.3.0", "ext-curl": "*", - "ccampbell/chromephp": "^4.1", + "ccampbell/chromephp": "4.1.0", "ckeditor/ckeditor": "dev-full/stable", - "mike42/escpos-php": "dev-master", + "mike42/escpos-php": "1.2.1", "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": { @@ -45,8 +48,5 @@ "ext-xml": "Excel support", "firephp/firephp-core": "Logging to Firebug console support", "raven/raven": "Sentry logging server support" - }, - "config": { - "vendor-dir": "htdocs/includes" } } diff --git a/composer.lock b/composer.lock index 43a9f1d2d7c..2e30ef6bd01 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "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", + "hash": "f666a32d1a59518b8ecc55899e829e79", + "content-hash": "8d110e7d8fca6eca1aa814ee35d0032b", "packages": [ { "name": "ccampbell/chromephp", @@ -56,12 +56,12 @@ "source": { "type": "git", "url": "https://github.com/ckeditor/ckeditor-releases.git", - "reference": "e3eb254641c4c349ffc19e49bd4a1a6831b5b6d0" + "reference": "4a7a6d717f9a408fa8f9ea53ef2dba4d64b83e91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ckeditor/ckeditor-releases/zipball/e3eb254641c4c349ffc19e49bd4a1a6831b5b6d0", - "reference": "e3eb254641c4c349ffc19e49bd4a1a6831b5b6d0", + "url": "https://api.github.com/repos/ckeditor/ckeditor-releases/zipball/4a7a6d717f9a408fa8f9ea53ef2dba4d64b83e91", + "reference": "4a7a6d717f9a408fa8f9ea53ef2dba4d64b83e91", "shasum": "" }, "type": "library", @@ -89,27 +89,28 @@ "text", "wysiwyg" ], - "time": "2016-03-31 16:19:25" + "time": "2016-05-12 15:36:04" }, { "name": "mike42/escpos-php", - "version": "dev-master", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/mike42/escpos-php.git", - "reference": "96f05cbf460f5b67c2184ee4e91aedfbcedeb788" + "reference": "cfea4c4fc95516ac953e1e5b623f854632afa2ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mike42/escpos-php/zipball/96f05cbf460f5b67c2184ee4e91aedfbcedeb788", - "reference": "96f05cbf460f5b67c2184ee4e91aedfbcedeb788", + "url": "https://api.github.com/repos/mike42/escpos-php/zipball/cfea4c4fc95516ac953e1e5b623f854632afa2ee", + "reference": "cfea4c4fc95516ac953e1e5b623f854632afa2ee", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "4.5.*" + "phpunit/phpunit": "4.5.*", + "squizlabs/php_codesniffer": "2.*" }, "type": "library", "autoload": { @@ -152,7 +153,7 @@ "print", "receipt" ], - "time": "2016-03-27 23:08:27" + "time": "2016-04-25 01:14:07" }, { "name": "mobiledetect/mobiledetectlib", @@ -267,17 +268,17 @@ }, { "name": "restler/framework", - "version": "3.0.0", + "version": "3.0.0-RC6", "target-dir": "Luracast/Restler", "source": { "type": "git", "url": "https://github.com/Luracast/Restler-Framework.git", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b" + "reference": "bfe1139b233852b745c6a0ec14d7244ceb3b3fc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/6ee10b3e5dbc6376916fed55ec2340a37cce436b", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b", + "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/bfe1139b233852b745c6a0ec14d7244ceb3b3fc6", + "reference": "bfe1139b233852b745c6a0ec14d7244ceb3b3fc6", "shasum": "" }, "require": { @@ -286,23 +287,14 @@ "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)" + "bshaffer/oauth2-server-php": "If you want to use OAuth2 for authentication", + "illuminate/view": "If you want to use laravel blade templates with Html format", + "mustache/mustache": "If you want to use mustache/handlebar templates with Html format", + "rodneyrehm/plist": "If you need Apple plist binary/xml format", + "symfony/yaml": "If you need YAML format", + "twig/twig": "If you want to use twig templates with Html format", + "zendframework/zendamf": "If you need AMF format" }, "type": "library", "extra": { @@ -323,10 +315,6 @@ { "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", @@ -337,7 +325,7 @@ "rest", "server" ], - "time": "2015-08-04 07:52:49" + "time": "2016-02-28 15:57:37" }, { "name": "tecnickcom/tcpdf", @@ -408,7 +396,7 @@ "minimum-stability": "stable", "stability-flags": { "ckeditor/ckeditor": 20, - "mike42/escpos-php": 20 + "restler/framework": 5 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index a7aed128151..82f364b0c1f 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -116,8 +116,15 @@ JQUERYFILETREE: RESTLER: -------- - if ($className == 'Luracast\Restler\string') return; - if ($className == 'Luracast\Restler\mixed') return; - +* Add 2 lines into function + private function alias($className, $currentClass) + { + ... +to get + private function alias($className, $currentClass) + { + if ($className == 'Luracast\Restler\string') return; + if ($className == 'Luracast\Restler\mixed') return; + ... \ No newline at end of file diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index 4de319dabc9..ecdbbd09dc4 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -180,7 +180,7 @@ if (! $sourcecontent) } // Define output variables -$outfile='out.'.$classmin.'.class.php'; +$outfile=$classmin.'.class.php'; $targetcontent=$sourcecontent; // Substitute module name @@ -259,7 +259,7 @@ foreach($property as $key => $prop) if ($addfield) { $varprop.="\t\t\$sql.= '".$prop['field']; - if ($i <= count($property)-$no_output_field) $varprop.=","; + if ($i < (count($property)-$no_output_field)) $varprop.=","; $varprop.="';"; $varprop.="\n"; } @@ -455,9 +455,9 @@ else $error++; //-------------------------------------------------------------------- $skeletonfiles=array( - $path.'skeleton_script.php' => 'out.'.$classmin.'_script.php', - $path.'skeleton_list.php' => 'out.'.$classmin.'_list.php', - $path.'skeleton_card.php' => 'out.'.$classmin.'_card.php' + $path.'skeleton_script.php' => $classmin.'_script.php', + $path.'skeleton_list.php' => $classmin.'_list.php', + $path.'skeleton_card.php' => $classmin.'_card.php' ); foreach ($skeletonfiles as $skeletonfile => $outfile) @@ -670,5 +670,5 @@ foreach ($skeletonfiles as $skeletonfile => $outfile) // -------------------- END OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- -print "You can now rename generated files by removing the 'out.' prefix in their name and store them into directory /yourmodule/class (for .class.php file) or /yourmodule.\n"; +print "You can now move generated files to store them into directory /yourmodule/class (for .class.php file) or /yourmodule.\n"; return $error; diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 78f17dc1a63..f1413bb3712 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -266,7 +266,8 @@ if ($resql) $num = $db->num_rows($resql); $params=''; - if ($search_field1 != '') $params.= '&search_field1='.urlencode($search_field1); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_field1 != '') $params.= '&search_field1='.urlencode($search_field1); if ($search_field2 != '') $params.= '&search_field2='.urlencode($search_field2); if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields @@ -280,7 +281,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/htdocs/.gitignore b/htdocs/.gitignore index 050707daf91..608ef55d106 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -20,5 +20,5 @@ /allscreens* /ecommerce/ /cabinetmed* -/conf/conf.php /webmail* +/conf/conf.php diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 5bdaa3c5828..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; @@ -154,13 +188,13 @@ if ($result) { 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/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 e663557d22c..c45700ce4f5 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -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,7 +204,7 @@ if ($action == 'create') { // Ref print ""; - print ''; diff --git a/htdocs/accountancy/admin/journal.php b/htdocs/accountancy/admin/journal.php index ca4ab67aee8..b511c6dfd1a 100644 --- a/htdocs/accountancy/admin/journal.php +++ b/htdocs/accountancy/admin/journal.php @@ -1,31 +1,32 @@ * Copyright (C) 2013-2015 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * - * 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 . - * - */ +* Copyright (C) 2014 Florian Henry +* Copyright (C) 2014 Marcos García +* Copyright (C) 2014 Juanjo Menent +* Copyright (C) 2015 Jean-François Ferry +* 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/accountancy/admin/journal.php - * \ingroup Advanced accountancy - * \brief Setup page to configure accounting expert module - */ +* \ingroup Advanced accountancy +* \brief Setup page to configure accounting expert module +*/ require '../../main.inc.php'; // Class @@ -48,24 +49,44 @@ $list = array ( 'ACCOUNTING_PURCHASE_JOURNAL', 'ACCOUNTING_SOCIAL_JOURNAL', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', - 'ACCOUNTING_EXPENSEREPORT_JOURNAL' + 'ACCOUNTING_EXPENSEREPORT_JOURNAL' ); /* * Actions - */ +*/ if ($action == 'update') { $error = 0; - - foreach ( $list as $constname ) { + + // Save vars + foreach ($list as $constname) + { $constvalue = GETPOST($constname, 'alpha'); - + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error ++; } } - + + // Save bank account journals + $arrayofbankaccount = GETPOST('bank_account', 'array'); + foreach($arrayofbankaccount as $key => $code) + { + $bankaccount = new Account($db); + $res = $bankaccount->fetch($key); + if ($res > 0) + { + $bankaccount->accountancy_journal = $code; + $bankaccount->update($user); + } + else + { + $error++; + break; + } + } + if (! $error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -75,7 +96,7 @@ if ($action == 'update') { /* * View - */ +*/ llxHeader(); @@ -99,13 +120,13 @@ print "\n"; foreach ( $list as $key ) { $var = ! $var; - + print ''; - + // Param $label = $langs->trans($key); print ''; - + // Value print '"; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print ""; - //print ""; + print ""; + // print ""; print '"; print '"; print ""; @@ -499,8 +506,8 @@ if ($action == 'export_csv') { print ""; print ""; print ""; - print "" ; - print ""; + print ""; + print ""; print '"; print '"; print ""; @@ -514,11 +521,11 @@ if ($action == 'export_csv') { print ""; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print ""; - print ""; - //print ""; + print ""; + print ""; + // print ""; print '"; print '"; } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index a88d60b8376..5da210ca09a 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -7,7 +7,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2014 Raphal Doursenaud + * Copyright (C) 2014 Rapha�l Doursenaud * * 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 @@ -24,9 +24,9 @@ */ /** - * \file htdocs/accountancy/journal/sellsjournal.php - * \ingroup Advanced accountancy - * \brief Page with sells journal + * \file htdocs/accountancy/journal/sellsjournal.php + * \ingroup Advanced accountancy + * \brief Page with sells journal */ require '../../main.inc.php'; @@ -118,6 +118,7 @@ if ($result) { $tabfac = array (); $tabht = array (); $tabtva = array (); + $def_tva = array (); $tabttc = array (); $tabcompany = array (); @@ -140,10 +141,14 @@ if ($result) { $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + + //Define array for display vat tx + $def_tva[$obj->rowid]=price($obj->tva_tx); + // Situation invoices handling $line = new FactureLigne($db); - $line->fetch($obj->rowid); - $prev_progress = $line->get_prev_progress(); + $line->fetch($obj->fdid); + $prev_progress = $line->get_prev_progress($obj->fdid); if ($obj->type == Facture::TYPE_SITUATION) { // Avoid divide by 0 if ($obj->situation_percent == 0) { @@ -193,14 +198,17 @@ if ($action == 'writebookkeeping') { $error = 0; foreach ( $tabfac as $key => $val ) { - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; -$invoicestatic->id = $key; + $companystatic = new Societe($db); + $invoicestatic = new Facture($db); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; - - + foreach ( $tabttc[$key] as $k => $mt ) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -211,8 +219,8 @@ $invoicestatic->id = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - //$bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); + // $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -242,7 +250,7 @@ $invoicestatic->id = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -272,7 +280,7 @@ $invoicestatic->id = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -296,6 +304,7 @@ $invoicestatic->id = $key; // Export if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; @@ -304,8 +313,7 @@ if ($action == 'export_csv') { $companystatic = new Client($db); // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) - { + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; foreach ( $tabfac as $key => $val ) { @@ -313,9 +321,9 @@ if ($action == 'export_csv') { $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; -$invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; - + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); foreach ( $tabttc[$key] as $k => $mt ) { @@ -325,8 +333,8 @@ $invoicestatic->id = $key; print length_accounta(html_entity_decode($k)) . $sep; print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; - //print utf8_decode($companystatic->name) . $sep; + print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; + // print utf8_decode($companystatic->name) . $sep; print $val["ref"]; print "\n"; } @@ -341,8 +349,8 @@ $invoicestatic->id = $key; print $sep; print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount_static->label)) . $sep; - //print dol_trunc($accountingaccount_static->label, 32) . $sep; + print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount_static->label)) . $sep; + // print dol_trunc($accountingaccount_static->label, 32) . $sep; print $val["ref"]; print "\n"; } @@ -357,22 +365,22 @@ $invoicestatic->id = $key; print $sep; print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . $sep; - //print $langs->trans("VAT") . $sep; + print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep; + // print $langs->trans("VAT") . $sep; print $val["ref"]; print "\n"; } } } - } else { + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { // Model Classic Export foreach ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["ref"]; $date = dol_print_date($db->jdate($val["date"]), 'day'); @@ -380,8 +388,8 @@ $invoicestatic->id = $key; print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; - //print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + // print '"' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -396,8 +404,8 @@ $invoicestatic->id = $key; print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. utf8_decode ( dol_trunc($accountingaccount->label, 32)) . '"' . $sep; - //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; + // print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -410,8 +418,8 @@ $invoicestatic->id = $key; print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . '"' . $sep; - //print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep; + // print '"' . $langs->trans("VAT") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -440,7 +448,11 @@ $invoicestatic->id = $key; 'action' => '' )); - print ''; + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 || $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { + print ''; + } else { + print ''; + } print ''; @@ -496,9 +508,9 @@ $invoicestatic->id = $key; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; print ""; + // print ""; print ""; print ""; } @@ -514,8 +526,8 @@ $invoicestatic->id = $key; print ""; print ""; print ""; - //print ""; - print ""; + // print ""; + print ""; print ""; print ""; print ""; @@ -529,8 +541,8 @@ $invoicestatic->id = $key; print ""; print ""; print ""; - print ""; - //print ""; + print ""; + // print ""; print ""; print ""; print ""; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index e8c5749088a..66de3be2cc5 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1376,17 +1376,12 @@ else print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1); } - /* - * Confirm add in spip - */ + // Confirm add in spip if ($action == 'add_spip') { print $form->formconfirm("card.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip'); } - - /* - * Confirm removed from spip - */ + // Confirm removed from spip if ($action == 'del_spip') { print $form->formconfirm("card.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); @@ -1551,8 +1546,16 @@ else } else { - print $langs->trans("SubscriptionNotReceived"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + if (! $adht->cotisation) + { + print $langs->trans("SubscriptionNotRecorded"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + } + else + { + print $langs->trans("SubscriptionNotReceived"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + } } print ''; diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 998dc53d525..784f6d4dea7 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -722,8 +722,16 @@ if ($rowid > 0) } else { - print $langs->trans("SubscriptionNotReceived"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + if (! $adht->cotisation) + { + print $langs->trans("SubscriptionNotRecorded"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + } + else + { + print $langs->trans("SubscriptionNotReceived"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + } } print ''; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 01ce37ee3a8..5878aac2755 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -49,6 +49,9 @@ $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'); @@ -104,6 +107,9 @@ $arrayfields=array( '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), @@ -151,6 +157,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_town=""; $search_state=""; $search_country=''; + $search_phone=''; + $search_phone_perso=''; + $search_phone_mobile=''; $search_morphy=""; $search_categ=""; $catid=""; @@ -290,6 +299,9 @@ if ($resql) 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); @@ -347,7 +359,7 @@ if ($resql) print ''; if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + print ''; } 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); @@ -361,6 +373,9 @@ if ($resql) 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 @@ -388,6 +403,12 @@ if ($resql) // Line for filters fields print ''; + // Line numbering + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + { + print ''; + } + // Ref if (! empty($arrayfields['d.ref']['checked'])) { @@ -464,6 +485,24 @@ if ($resql) print $form->select_country($search_country,'search_country','',0,'maxwidth100'); 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'])) { @@ -619,14 +658,6 @@ if ($resql) print $obj->address; print ''; } - // Town - if (! empty($arrayfields['d.town']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } // Zip if (! empty($arrayfields['d.zip']['checked'])) { @@ -635,6 +666,14 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } + // Town + if (! empty($arrayfields['d.town']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // State if (! empty($arrayfields['state.nom']['checked'])) { @@ -650,6 +689,30 @@ if ($resql) 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 if (! empty($arrayfields['d.email']['checked'])) { diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 797b35f7c75..353389c98a8 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -551,6 +551,14 @@ if ($id == 25) if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); + + $parameters=array('elementList'=>$elementList); + $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks + if ($reshook == 0) { + foreach ($hookmanager->resArray as $item => $value) { + $elementList[$item] = $value; + } + } } // Define localtax_typeList (used for dictionary "llx_c_tva") @@ -1553,7 +1561,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); - if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); + if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db); foreach ($fieldlist as $field => $value) { diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index f4e3d704121..2dff436ffe6 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; $langs->load("errors"); $langs->load("admin"); -$mode=GETPOST('mode', 'alpha')?GETPOST('mode', 'alpha'):(isset($_SESSION['mode'])?$_SESSION['mode']:0); +$mode=GETPOST('mode', 'alpha')?GETPOST('mode', 'alpha'):0; $action=GETPOST('action','alpha'); $value=GETPOST('value', 'alpha'); $page_y=GETPOST('page_y','int'); @@ -107,8 +107,6 @@ if (GETPOST('buttonreset')) $form = new Form($db); -$_SESSION["mode"]=$mode; - $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('',$langs->trans("Setup"),$help_url); diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index b22ad287302..74684c823e7 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -263,7 +263,7 @@ if ($action == 'edit') // Edit print ''; $var=!$var; - print ''; diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 66d06e91679..262b3f69476 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -1,5 +1,6 @@ + * 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 @@ -19,11 +20,7 @@ * \defgroup api Module DolibarrApi * \brief API loader * Search files htdocs//class/api_.class.php - * \file htdocs/api/indexphp - * - * @todo User authentication with api_key - * - * + * \file htdocs/api/admin/explorer.php */ require_once '../../main.inc.php'; @@ -51,7 +48,6 @@ use \Luracast\Restler\Defaults; $api = new DolibarrApi($db); $api->r->addAPIClass('Luracast\\Restler\\Resources'); //this creates resources.json at API Root -$api->r->addAPIClass('DolibarrApiInit',''); // Just for url root page $api->r->setSupportedFormats('JsonFormat', 'XmlFormat'); $api->r->addAuthenticationClass('DolibarrApiAccess',''); @@ -149,7 +145,6 @@ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; 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 @@ -158,27 +153,46 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain // Show message print '
'; $message=''; -$url=''.$urlwithroot.'/api/index.php/login?login='.urlencode($user->login).'&password=yourpassword'; +$url=''.$urlwithroot.'/api/index.php/login?login='.urlencode($user->login).'&password=yourpassword[&reset=1]'; $message.=$langs->trans("UrlToGetKeyToUseAPIs").':
'; $message.=img_picto('','object_globe.png').' '.$url; print $message; print '
'; print '
'; +$oldclass=''; + 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=$urlwithroot.'/api/index.php/'.$key; - $url.='?api_key=token'; - print img_picto('','object_globe.png').' '.$url."
\n"; - + foreach($val as $method => $val2) + { + $newclass=$val2['className']; + + if (preg_match('/restler/i', $newclass)) continue; + + if ($oldclass != $newclass) + { + print "\n
\n".$langs->trans("Class").': '.$newclass.'
'."\n"; + $oldclass = $newclass; + } + //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
\n"; + $url=$urlwithroot.'/api/index.php/'.$key; + $url.='?api_key=token'; + print img_picto('','object_globe.png').' '.$method.' '.$url."
\n"; + } } } +print '
'; +print '
'; +print $langs->trans("OnlyActiveElementsAreExposed", DOL_URL_ROOT.'/admin/modules.php'); + + llxFooter(); $db->close(); diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 2c31432b63b..3a69dadaaba 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -100,19 +100,6 @@ print ''.$langs->trans("ApiExporerIs").':
'; $url=DOL_MAIN_URL_ROOT.'/api/admin/explorer.php'; print img_picto('','object_globe.png').' '.$url."
\n"; -// API endpoint -/*print ''.$langs->trans("ApiEndPointIs").':
'; -$url=DOL_MAIN_URL_ROOT.'/api/index.php/xxx/list'; -print img_picto('','object_globe.png').' '.$url."
\n"; -$url=DOL_MAIN_URL_ROOT.'/api/xxx/list.json'; -print img_picto('','object_globe.png').' '.$url."
\n"; -*/ - -print '
'; -print '
'; -print $langs->trans("OnlyActiveElementsAreExposed", DOL_URL_ROOT.'/admin/modules.php'); - - llxFooter(); $db->close(); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index bc5b4378c0c..b3a2cdaf9d0 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -140,89 +140,3 @@ class DolibarrApi return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray,$resource_id,$dbtablename,$feature2,$dbt_keyfield,$dbt_select); } } - -/** - * API init - * - */ -class DolibarrApiInit extends DolibarrApi -{ - - function __construct() { - global $db; - $this->db = $db; - } - - /** - * Login - * - * Log user with username and password - * - * @param string $login Username - * @param string $password User password - * @param int $entity User entity - * @return array Response status and user token - * - * @throws RestException - */ - 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'; - // Authentication mode: forceuser - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) - $dolibarr_auto_user = 'auto'; - // Set authmode - $authmode = explode(',', $dolibarr_main_authentication); - - include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; - $login = checkLoginPassEntity($login, $password, $entity, $authmode); - if (empty($login)) - { - throw new RestException(403, 'Access denied'); - } - - // Generate token for user - $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1); - - // We store API token into database - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql.= " SET api_key = '".$this->db->escape($token)."'"; - $sql.= " WHERE login = '".$this->db->escape($login)."'"; - - dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log - $result = $this->db->query($sql); - if (!$result) - { - throw new RestException(500, 'Error when updating user :'.$this->db->error_msg); - } - - //return token - return array( - 'success' => array( - 'code' => 200, - 'token' => $token, - 'message' => 'Welcome ' . $login - ) - ); - } - - /** - * Get status (Dolibarr version) - * - * @access protected - * @class DolibarrApiAccess {@requires admin} - */ - function status() { - require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; - return array( - 'success' => array( - 'code' => 200, - 'dolibarr_version' => DOL_VERSION - ) - ); - } -} diff --git a/htdocs/api/class/api_generic.class.php b/htdocs/api/class/api_generic.class.php new file mode 100644 index 00000000000..038621b6235 --- /dev/null +++ b/htdocs/api/class/api_generic.class.php @@ -0,0 +1,124 @@ + + * + * 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 . + */ + +use Luracast\Restler\Restler; +use Luracast\Restler\RestException; +use Luracast\Restler\Defaults; + +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; + + +/** + * API generic (login, status, ...) + * + */ +class GenericApi extends DolibarrApi +{ + + function __construct() { + global $db; + $this->db = $db; + } + + /** + * Login + * + * Log user with username and password + * + * @param string $login Username + * @param string $password User password + * @param int $entity User entity + * @param int $reset Reset token + * @return array Response status and user token + * + * @throws RestException + */ + public function login($login, $password, $entity=0, $reset=0) { + + global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; + + // Authentication mode + if (empty($dolibarr_main_authentication)) + $dolibarr_main_authentication = 'http,dolibarr'; + // Authentication mode: forceuser + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) + $dolibarr_auto_user = 'auto'; + // Set authmode + $authmode = explode(',', $dolibarr_main_authentication); + + include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; + $login = checkLoginPassEntity($login, $password, $entity, $authmode); + if (empty($login)) + { + throw new RestException(403, 'Access denied'); + } + + $token = 'failedtogenerateorgettoken'; + + $tmpuser=new User($this->db); + $tmpuser->fetch(0, $login); + + // Renew the hash + if (empty($tmpuser->api_key) || $reset) + { + // Generate token for user + $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1); + + // We store API token into database + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql.= " SET api_key = '".$this->db->escape($token)."'"; + $sql.= " WHERE login = '".$this->db->escape($login)."'"; + + dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log + $result = $this->db->query($sql); + if (!$result) + { + throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); + } + } + else + { + $token = $tmpuser->api_key; + } + + //return token + return array( + 'success' => array( + 'code' => 200, + 'token' => $token, + 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - Token was generated by a previous call') + ) + ); + } + + /** + * Get status (Dolibarr version) + * + * @access protected + * @class DolibarrApiAccess {@requires admin} + */ + function status() { + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + return array( + 'success' => array( + 'code' => 200, + 'dolibarr_version' => DOL_VERSION + ) + ); + } +} diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 55a45aea4b9..2fbad04ecbb 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -60,7 +60,6 @@ use \Luracast\Restler\Defaults; $api = new DolibarrApi($db); $api->r->addAPIClass('Luracast\\Restler\\Resources'); //this creates resources.json at API Root -$api->r->addAPIClass('DolibarrApiInit',''); // Just for url root page $api->r->setSupportedFormats('JsonFormat', 'XmlFormat'); $api->r->addAuthenticationClass('DolibarrApiAccess',''); 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/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index ecb11c3e6ee..8ddd7e48a85 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -203,7 +203,7 @@ $langs->load("cashdesk"); ?> " onclick="javascript: verifClic('DIF');" /> trans("DateEcheance").' :'; + print $langs->trans("DateDue").' :'; print $form->select_date(-1,'txtDatePaiement',0,0,0,'paymentmode',1,0,1); print '
'; ?> diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index 047d597a6ef..bb6bd92c8bd 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -83,7 +83,7 @@ $langs->load("bills"); // Affichage des infos en fonction du mode de paiement if ( $obj_facturation->getsetPaymentMode() == 'DIF' ) { - echo ('
'); + echo (''); } else { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b602bc0076d..672ea7b6408 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -48,14 +48,13 @@ class Categorie extends CommonObject const TYPE_CUSTOMER = 2; const TYPE_MEMBER = 3; const TYPE_CONTACT = 4; - const TYPE_USER = 4; // categorie contact and user are same - // bank account - const TYPE_ACCOUNT = 5; + const TYPE_USER = 4; // categorie contact and user are same ! + const TYPE_ACCOUNT = 5; // bank account /** * @var array ID mapping from type string * - * @note Move to const array when PHP 5.6 will be our minimum target + * @note This array should be remove in future, once previous constants are moved to the string value. */ private $MAP_ID = array( 'product' => 0, @@ -1274,14 +1273,12 @@ class Categorie extends CommonObject * Should be named getListOfCategForObject * * @param int $id Id of element - * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode - * (0, 1, 2, ...) is deprecated. + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param string $mode 'object'=Get array of fetched category instances, 'label'=Get array of category * labels, 'id'= Get array of category IDs - * * @return mixed Array of category objects or < 0 if KO */ - function containing($id,$type,$mode='object') + function containing($id, $type, $mode='object') { $cats = array(); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 72c184af113..d3b1f8854b9 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; $langs->load("categories"); @@ -90,6 +91,7 @@ if ($action == 'addthumb' && $_GET["file"]) llxHeader("","",$langs->trans("Categories")); $form = new Form($db); +$formother = new FormOther($db); if ($object->id) { @@ -117,8 +119,8 @@ if ($object->id) print '
' . $langs->trans("Statut") . '' . $langs->trans("Status") . ''; print $form->selectarray('statut', $statut2label, GETPOST('statut')); print '
' . $langs->trans("Ref") . ''; + print '' . $langs->trans("Ref") . ''; print $object->ref; 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..e89799d765e 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -79,7 +79,7 @@ if (empty($search_date_start)) { if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") - $sortfield = "t.rowid"; + $sortfield = "t.numero_compte"; $options = ''; $filter = array (); @@ -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'; @@ -149,22 +151,34 @@ else { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result); - + print ''; print '
' . "\n"; 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=''; - print ''; + $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.='
'; + + 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..557143164a9 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'; @@ -228,251 +236,171 @@ if ($action == 'delbookkeeping') { } else { - if (in_array($conf->global->ACCOUNTING_EXPORT_MODELCSV, array(5,6))) // TODO remove the conditional and keep the code in the "else" - { - $accountancyexport = new AccountancyExport($db); - $accountancyexport->export($object->lines); - if (!empty($accountancyexport->errors)) setEventMessages('', $accountancyexport->errors, 'errors'); - else exit; - } - } - - - // TODO remove next 3 lines and foreach to implement the AccountancyExport method for each model - $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $journal = 'bookkepping'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - - foreach ( $object->lines as $line ) { - - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { - $sep = ";"; - // Model Cegid Expert Export - $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accountg($line->numero_compte) . $sep; - print ' ' . $sep; - print $line->sens . $sep; - print price($line->montant) . $sep; - print dol_trunc($line->label_compte, 32) . $sep; - print $line->doc_ref . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - - // Std export - $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); - print $date . $sep; - print $line->doc_ref . $sep; - print length_accountg($line->numero_compte) . $sep; - print length_accounta($line->code_tiers) . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print $line->code_journal . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - - // Coala export - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accountg($line->numero_compte) . $sep; - print $line->piece_num . $sep; - print $line->doc_ref . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print 'E' . $sep; - print length_accountg($line->code_tiers) . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 4) { - - // Bob50 - print $line->piece_num . $sep; - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $sep; - - if (empty($line->code_tiers)) { - print 'G' . $sep; - print length_accounta($line->numero_compte) . $sep; - } else { - if (substr($line->numero_compte,0,3)=='411') { - print 'C' . $sep; - } - if (substr($line->numero_compte,0,3)=='401') { - print 'F' . $sep; - } - print length_accountg($line->code_tiers) . $sep; - - } - - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print dol_trunc($line->label_compte, 32) . $sep; - print "\n"; + $accountancyexport = new AccountancyExport($db); + $accountancyexport->export($object->lines); + if (!empty($accountancyexport->errors)) { + setEventMessages('', $accountancyexport->errors, 'errors'); } + 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/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index ad5ecd3d1bf..c7920577adc 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1,9 +1,10 @@ - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Florian Henry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Pierre-Henry Favre +/* + * Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Pierre-Henry Favre * * 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 @@ -12,7 +13,7 @@ * * 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 + * 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 @@ -20,7 +21,7 @@ */ /** - * \file htdocs/accountancy/class/accountancyexport.class.php + * \file htdocs/accountancy/class/accountancyexport.class.php */ /** @@ -29,30 +30,34 @@ * Manage the different format accountancy export */ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; - class AccountancyExport { /** + * * @var Type of export */ - public static $EXPORT_TYPE_NORMAL = 1; - public static $EXPORT_TYPE_CEGID = 2; - public static $EXPORT_TYPE_COALA = 3; - public static $EXPORT_TYPE_BOB50 = 4; - public static $EXPORT_TYPE_CIEL = 5; - public static $EXPORT_TYPE_QUADRATUS = 6; + public static $EXPORT_TYPE_NORMAL = 1; + public static $EXPORT_TYPE_CEGID = 2; + public static $EXPORT_TYPE_COALA = 3; + public static $EXPORT_TYPE_BOB50 = 4; + public static $EXPORT_TYPE_CIEL = 5; + public static $EXPORT_TYPE_QUADRATUS = 6; + public static $EXPORT_TYPE_EBP = 7; /** + * * @var string[] Error codes (or messages) */ - public $errors = array(); + public $errors = array (); /** + * * @var string Separator */ public $separator = ''; /** + * * @var string End of line */ public $end_line = ''; @@ -62,8 +67,7 @@ class AccountancyExport * * @param DoliDb $db Database handler */ - public function __construct(DoliDB &$db) - { + public function __construct(DoliDB &$db) { global $conf; $this->db = &$db; @@ -76,17 +80,17 @@ class AccountancyExport * * @return array of type */ - public static function getType() - { + public static function getType() { global $langs; return array ( - self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), - self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), - self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), - self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), - self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), - self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus') + self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), + self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), + self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), + self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), + self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), + self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), + self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), ); } @@ -95,8 +99,7 @@ class AccountancyExport * * @return void */ - public static function downloadFile() - { + public static function downloadFile() { global $conf; $journal = 'bookkepping'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; @@ -107,111 +110,168 @@ class AccountancyExport * * @param unknown $TData data */ - public function export(&$TData) - { + public function export(&$TData) { global $conf, $langs; + self::downloadFile(); + switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) { - case self::$EXPORT_TYPE_NORMAL: + case self::$EXPORT_TYPE_NORMAL : $this->exportNormal($TData); break; - case self::$EXPORT_TYPE_CEGID: + case self::$EXPORT_TYPE_CEGID : $this->exportCegid($TData); break; - case self::$EXPORT_TYPE_COALA: + case self::$EXPORT_TYPE_COALA : $this->exportCoala($TData); break; - case self::$EXPORT_TYPE_BOB50: + case self::$EXPORT_TYPE_BOB50 : $this->exportBob50($TData); break; - case self::$EXPORT_TYPE_CIEL: + case self::$EXPORT_TYPE_CIEL : $this->exportCiel($TData); break; - case self::$EXPORT_TYPE_QUADRATUS: + case self::$EXPORT_TYPE_QUADRATUS : $this->exportQuadratus($TData); break; - default: + case self::$EXPORT_TYPE_EBP : + $this->exportEbp($TData); + break; + default : $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; } - - if (empty($this->errors)) self::downloadFile(); } /** * Export format : Normal * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportNormal(&$TData) - { - + public function exportNormal($objectLines) { + foreach ( $objectLines as $line ) { + // Std export + $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); + print $date . $this->separator; + print $line->doc_ref . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print length_accounta($line->code_tiers) . $this->separator; + print price($line->debit) . $this->separator; + print price($line->credit) . $this->separator; + print $line->code_journal . $this->separator; + print $this->end_line; + } } /** * Export format : CEGID * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportCegid(&$TData) - { + public function exportCegid($objectLines) { + foreach ( $objectLines as $line ) { + $date = dol_print_date($line->doc_date, '%d%m%Y'); + print $date . $this->separator; + print $line->code_journal . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print ' ' . $this->separator; + print $line->sens . $this->separator; + print price($line->montant) . $this->separator; + print dol_trunc($line->label_compte, 32) . $this->separator; + print $line->doc_ref . $this->separator; + print $this->end_line; + } } /** * Export format : COALA * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportCoala(&$TData) - { - + public function exportCoala($objectLines) { + // Coala export + foreach ( $objectLines as $line ) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $this->separator; + print $line->code_journal . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print $line->piece_num . $this->separator; + print $line->doc_ref . $this->separator; + print price($line->debit) . $this->separator; + print price($line->credit) . $this->separator; + print 'E' . $this->separator; + print length_accountg($line->code_tiers) . $this->separator; + print $this->end_line; + } } /** * Export format : BOB50 * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportBob50(&$TData) - { + public function exportBob50($objectLines) { + // Bob50 + foreach ( $objectLines as $line ) { + print $line->piece_num . $this->separator; + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $this->separator; + + if (empty($line->code_tiers)) { + print 'G' . $this->separator; + print length_accounta($line->numero_compte) . $this->separator; + } else { + if (substr($line->numero_compte, 0, 3) == '411') { + print 'C' . $this->separator; + } + if (substr($line->numero_compte, 0, 3) == '401') { + print 'F' . $this->separator; + } + print length_accountg($line->code_tiers) . $this->separator; + } + + print price($line->debit) . $this->separator; + print price($line->credit) . $this->separator; + print dol_trunc($line->label_compte, 32) . $this->separator; + print $this->end_line; + } } /** * Export format : CIEL * - * @param unknown $TData data + * @param array $TData data * * @return void */ - public function exportCiel(&$TData) - { + public function exportCiel(&$TData) { global $conf; - $i=1; + $i = 1; $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd - foreach ($TData as $data) - { + foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (!empty($data->code_tiers)) $code_compta = $data->code_tiers; + if (! empty($data->code_tiers)) + $code_compta = $data->code_tiers; - $Tab = array(); + $Tab = array (); $Tab['num_ecriture'] = str_pad($i, 5); $Tab['code_journal'] = str_pad($data->code_journal, 2); $Tab['date_ecriture'] = $date_ecriture; $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.$data->label_compte, 25), 25); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_compte, 25), 25); $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); @@ -221,41 +281,42 @@ class AccountancyExport $Tab['end_line'] = $this->end_line; print implode($Tab); - $i++; + $i ++; } } /** * Export format : Quadratus * - * @param unknown $TData data + * @param array $TData data * * @return void */ - public function exportQuadratus(&$TData) - { + public function exportQuadratus(&$TData) { global $conf; $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy - foreach ($TData as $data) - { + foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (!empty($data->code_tiers)) $code_compta = $data->code_tiers; + if (! empty($data->code_tiers)) + $code_compta = $data->code_tiers; - $Tab = array(); + $Tab = array (); $Tab['type_ligne'] = 'M'; $Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8); $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2); $Tab['folio'] = '000'; $Tab['date_ecriture'] = $date_ecriture; $Tab['filler'] = ' '; - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.' '.$data->label_compte, 20), 20); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 20), 20); $Tab['sens'] = $data->sens; // C or D $Tab['signe_montant'] = '+'; - $Tab['montant'] = str_pad(abs($data->montant)*100, 12, '0', STR_PAD_LEFT); // TODO manage negative amount + $Tab['montant'] = str_pad(abs($data->montant) * 100, 12, '0', STR_PAD_LEFT); // TODO manage negative amount $Tab['contrepartie'] = str_repeat(' ', 8); - if (!empty($data->date_echeance)) $Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); - else $Tab['date_echeance'] = '000000'; + if (! empty($data->date_echeance)) + $Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); + else + $Tab['date_echeance'] = '000000'; $Tab['lettrage'] = str_repeat(' ', 5); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5); $Tab['filler2'] = str_repeat(' ', 20); @@ -263,7 +324,7 @@ class AccountancyExport $Tab['devis'] = str_pad($conf->currency, 3); $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['filler3'] = str_repeat(' ', 3); - $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref.' '.$data->label_compte, 32), 32); + $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 32), 32); $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['filler4'] = str_repeat(' ', 73); @@ -273,14 +334,45 @@ class AccountancyExport } } + + /** + * Export format : Normal + * + * @param array $objectLines data + * + * @return void + */ + public function exportEbp($objectLines) { + + $this->separator = ','; + + foreach ( $objectLines as $line ) { + + $date = dol_print_date($line->doc_date, '%d%m%Y'); + + print $line->id . $this->separator; + print $date . $this->separator; + print $line->code_journal . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print substr(length_accountg($line->numero_compte),0,2) . $this->separator; + print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1)."'".$this->separator; + print price2num($line->montant).$this->separator; + print $line->sens.$this->separator; + print $date . $this->separator; + print 'EUR'; + print $this->end_line; + } + } + + + /** * * @param unknown $str data * @param integer $size data */ - public static function trunc($str, $size) - { + public static function trunc($str, $size) { return dol_trunc($str, $size, 'right', 'UTF-8', 1); } - } 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/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c360c1ce4cb..5ca1197b3e2 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -22,9 +22,9 @@ */ /** - * \file htdocs/accountancy/journal/purchasesjournal.php - * \ingroup Advanced accountancy - * \brief Page with purchases journal + * \file htdocs/accountancy/journal/purchasesjournal.php + * \ingroup Advanced accountancy + * \brief Page with purchases journal */ require '../../main.inc.php'; @@ -117,13 +117,14 @@ if ($result) { $tabfac = array (); $tabht = array (); $tabtva = array (); + $def_tva = array (); $tabttc = array (); $tabcompany = array (); $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - // contrles + // contrôles $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_prod = $obj->compte; if (empty($compta_prod)) { @@ -134,11 +135,13 @@ if ($result) { } $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + //Define array for display vat tx + $def_tva[$obj->rowid]=price($obj->tva_tx); + $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; - $tabfac[$obj->rowid]["refsologest"] = $obj->ref ; - $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier ; - + $tabfac[$obj->rowid]["refsologest"] = $obj->ref; + $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->description; @@ -164,19 +167,21 @@ if ($action == 'writebookkeeping') { $error = 0; foreach ( $tabfac as $key => $val ) { - - $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; - $invoicestatic->ref = $val["refsologest"]; - $invoicestatic->refsupplier = $val["refsuppliersologest"]; - $invoicestatic->type = $val["type"]; - $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; - - + + $companystatic = new Societe($db); + $invoicestatic = new FactureFournisseur($db); + + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + foreach ( $tabttc[$key] as $k => $mt ) { // get compte id and label @@ -188,7 +193,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; @@ -206,7 +211,7 @@ if ($action == 'writebookkeeping') { // Product / Service foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); + $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); if ($mt) { // get compte id and label @@ -220,7 +225,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode($accountingaccount->label); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode($accountingaccount->label); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -251,7 +256,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->refsupplier .' - '. $langs->trans("VAT"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -282,124 +287,123 @@ $companystatic = new Fournisseur($db); // Export if ($action == 'export_csv') { - $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) - { - $sep = ";"; + // Model Cegid Expert Export + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { + $sep = ";"; - foreach ( $tabfac as $key => $val ) { - $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + foreach ( $tabfac as $key => $val ) { + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + if ($mt) { + print $date . $sep; + print $purchase_journal . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print dol_trunc($val["description"], 32) . $sep; + print $val["ref"]; + print "\n"; + } + } + + // VAT + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $purchase_journal . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $langs->trans("VAT") . $sep; + print $val["ref"]; + print "\n"; + } + } + + foreach ( $tabttc[$key] as $k => $mt ) { + print $date . $sep; + print $purchase_journal . $sep; + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print utf8_decode($companystatic->name) . $sep; + print $val["ref"]; + print "\n"; + } + } + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + // Model Classic Export + foreach ( $tabfac as $key => $val ) { + + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + + $date = dol_print_date($db->jdate($val["date"]), 'day'); - // Product / Service - foreach ( $tabht[$key] as $k => $mt ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - if ($mt) { - print $date . $sep; - print $purchase_journal . $sep; - print length_accountg(html_entity_decode($k)) . $sep; - print $sep; - print ($mt < 0 ? 'C' : 'D') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($val["description"], 32) . $sep; - print $val["ref"]; - print "\n"; + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; + // print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } } - } - - // VAT - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - print $date . $sep; - print $purchase_journal . $sep; - print length_accountg(html_entity_decode($k)) . $sep; - print $sep; - print ($mt < 0 ? 'C' : 'D') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print $langs->trans("VAT") . $sep; - print $val["ref"]; - print "\n"; + // VAT + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + // print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } } - } - foreach ( $tabttc[$key] as $k => $mt ) { - print $date . $sep; - print $purchase_journal . $sep; - print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; - print length_accounta(html_entity_decode($k)) . $sep; - print ($mt < 0 ? 'D' : 'C') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode($companystatic->name) . $sep; - print $val["ref"]; + // Third party + foreach ( $tabttc[$key] as $k => $mt ) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + // print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + } print "\n"; } } - } else { - // Model Classic Export - foreach ( $tabfac as $key => $val ) { - - $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; - $invoicestatic->ref = $val["refsologest"]; - $invoicestatic->refsupplier = $val["refsuppliersologest"]; - $invoicestatic->type = $val["type"]; - $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - - $date = dol_print_date($db->jdate($val["date"]), 'day'); - - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; - - // Product / Service - foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k); - if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; - //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; - print "\n"; - } - } - // VAT - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - //print '"' . $langs->trans("VAT") . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; - print "\n"; - } - } - - // Third party - foreach ( $tabttc[$key] as $k => $mt ) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - //print '"' . utf8_decode($companystatic->name) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; - } - print "\n"; - } - } } else { llxHeader('', $langs->trans("PurchasesJournal")); @@ -423,7 +427,11 @@ if ($action == 'export_csv') { 'action' => '' )); - print ''; + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 || $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { + print ''; + } else { + print ''; + } print ''; @@ -468,7 +476,6 @@ if ($action == 'export_csv') { $invoicestatic->ref = $val["refsologest"]; $invoicestatic->refsupplier = $val["refsuppliersologest"]; - $invoicestatic->type = $val["type"]; $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); @@ -486,8 +493,8 @@ if ($action == 'export_csv') { print "
" . length_accountg($k) . "" . $companystatic->getNomUrl(0, 'supplier', 16). ' - ' .$invoicestatic->refsupplier .' - '. $accountingaccount->label . "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "" . $accountingaccount->label . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("VAT") . "" . length_accountg($k) . "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $invoicestatic->getNomUrl(1) . "" . length_accounta($k)."" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("Code_tiers")."" . $langs->trans("ThirdParty"); - //print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; - //print "" . length_accounta($k) . "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "" . $langs->trans("ThirdParty"); + // print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; + // print "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "" . length_accounta($k); - //print "" . $langs->trans("ThirdParty"); - //print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; - print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"). "" . $langs->trans("ThirdParty"); + // print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; + print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)) . "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount->label)) . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . "" . $langs->trans("VAT") . "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "" . $langs->trans("VAT") . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
 '.$langs->trans("NumberingShort").'
 '; + print ''; + print ''; + print ''; - print $obj->town; - print ''; + print $obj->town; + print ''; + print $obj->phone; + print ''; + print $obj->phone_perso; + print ''; + print $obj->phone_mobile; + print '
'.$langs->trans("ShowDetailsInPDFPageFoot").''; + print '
'.$langs->trans("ShowDetailsInPDFPageFoot").''; print $form->selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS); print '
'.$langs->trans("DateEcheance").''.$obj_facturation->paiementLe().'
'.$langs->trans("DateDue").''.$obj_facturation->paiementLe().'
'; // Path of category - print ''; // Description - print ''; - // Visibility - /* if ($type == 0 && ! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) - { - if ($object->socid) - { - $soc = new Societe($db); - $soc->fetch($object->socid); - - print ''; - - $catsMeres = $object->get_meres (); - - if ($catsMeres < 0) - { - dol_print_error(); - } - else if (count($catsMeres) > 0) - { - print ''; - } - } - else - { - print ''; - } - } - else - { - print ''; - } - */ - + print "
'; - $ways = $object->print_all_ways(); + print '
'; + $ways = $object->print_all_ways(" >> ", '', 1); print $langs->trans("Ref").''; print ''.$langs->trans("Root").' >> '; foreach ($ways as $way) @@ -128,55 +130,17 @@ if ($object->id) print '
'; + print '
'; print $langs->trans("Description").''; print dol_htmlentitiesbr($object->description); print '
'; - print $langs->trans("AssignedToTheCustomer").''; - print $soc->getNomUrl(1); + // Color + print '
'; + print $langs->trans("Color").''; + print $formother->showColor($object->color); print '
'; - print $langs->trans("CategoryContents").''; - print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); - print '
'; - print $langs->trans("CategoryContents").''; - print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); - print '
'; - print $langs->trans("CategoryContents").''; - print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); - print '
\n"; print "\n"; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 9d88098e56b..25fb000a594 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("categories"); $langs->load("languages"); @@ -143,6 +144,7 @@ llxHeader("","",$langs->trans("Translation")); $form = new Form($db); $formadmin=new FormAdmin($db); +$formother = new FormOther($db); if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); @@ -159,8 +161,8 @@ print ''; // Reference print ''; -print ''; print ''; // Description -print ''; +// Color +print ''; + print '
'; -$ways = $object->print_all_ways(); +print ''; +$ways = $object->print_all_ways(" >> ", '', 1); print $langs->trans("Ref").''; print ''.$langs->trans("Root").' >> '; foreach ($ways as $way) @@ -171,11 +173,17 @@ print '
'; +print '
'; print $langs->trans("Description").''; print dol_htmlentitiesbr($object->description); print '
'; +print $langs->trans("Color").''; +print $formother->showColor($object->color); +print '
'; if ($action == 'edit') @@ -194,8 +202,8 @@ if ($action == 'edit') { print "
".$langs->trans('Language_'.$key)." :
"; print ''; - print ''; - print ''; + print ''; @@ -205,7 +213,7 @@ if ($action == 'edit') } } - print '
'; + print '
'; print ''; print '     '; print ''; @@ -225,9 +233,9 @@ else $s=picto_from_langcode($key); print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).":
"; print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; + print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$object->multilangs[$key]["note"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$object->multilangs[$key]["note"].'
'; } } @@ -271,11 +279,11 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; - print ''; - print ''; - print ''; + print ''; @@ -283,7 +291,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print '
'.$langs->trans('Translation').''; + print '
'.$langs->trans('Translation').''; print $formadmin->select_language('','forcelangprod',0,$object->multilangs); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; + print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'; - print '
'; + print '
'; print ''; print '     '; print ''; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 284add47add..b9beb792ba6 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -193,10 +193,10 @@ if ($action == 'delete') print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type,$langs->trans('DeleteCategory'),$langs->trans('ConfirmDeleteCategory'),'confirm_delete'); } -print ''; +print '
'; // Path of category -print '\n"; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 38447c17c5e..e1828e911c7 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -233,11 +233,6 @@ if ($id > 0) print '
'; print '
'; +print '
'; $ways = $object->print_all_ways(" >> ", '', 1); print $langs->trans("Ref").''; print ''.$langs->trans("Root").' >> '; diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 31290318742..1f597ffeddc 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -308,7 +308,7 @@ 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("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 "
'; - // Alias name (commercial, trademark or alias name) - print '"; - // Prospect/Customer print ''; + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + print ''; print '"; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index b4c12fbcdab..82988dfcb0d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -568,15 +568,6 @@ if (empty($reshook)) } } - // Reopen proposal - else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) - { - // prevent browser refresh from reopening proposal several times - if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) { - $object->reopen($user, 1); - } - } - // Close proposal else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { @@ -597,17 +588,6 @@ if (empty($reshook)) } } - // Classify billed - else if ($action == 'classifybilled' && $user->rights->propal->cloturer) - { - $result=$object->cloture($user, 4, ''); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } - // Reopen proposal else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { @@ -623,20 +603,6 @@ if (empty($reshook)) } } - // Close proposal - else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) - { - if (! GETPOST('statut')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); - $action = 'statut'; - } else { - // prevent browser refresh from closing proposal several times - if ($object->statut == Propal::STATUS_VALIDATED) { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); - } - } - } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a22e937da87..cd730352d79 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1536,6 +1536,7 @@ class Commande extends CommonOrder $this->id = $obj->rowid; $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; + $this->ref_customer = $obj->ref_client; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->socid = $obj->fk_soc; diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index fa1b2064ed2..5731535697e 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -123,7 +123,7 @@ if ($resql) foreach ($listofstatus as $status) { $dataseries[]=array('label'=>$commandestatic->LibStatut($status,$bool,1),'data'=>(isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); - if ($status==3 && $bool==false) $bool=true; + if ($status==3 && ! $bool) $bool=true; else $bool=false; } if ($conf->use_javascript_ajax) @@ -147,7 +147,7 @@ if ($resql) print ''; print ''; print "\n"; - if ($status==3 && $bool==false) $bool=true; + if ($status==3 && ! $bool) $bool=true; else $bool=false; } } diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 9b671c50eb1..8f6cd29afdb 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -45,6 +45,11 @@ if (! $user->rights->banque->consolidate) accessforbidden(); $action=GETPOST('action', 'alpha'); $id=GETPOST('account', 'int'); +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="dateo"; + /* * Actions @@ -147,7 +152,7 @@ $sql.= ", bc.ref"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; $sql.= " WHERE rappro=0 AND fk_account=".$acct->id; -$sql.= " ORDER BY dateo ASC"; +$sql.= " ORDER BY $sortfield $sortorder"; $sql.= " LIMIT 1000"; // Limit to avoid page overload /// ajax adjust value date @@ -231,16 +236,19 @@ if ($resql) print '
'; - print '
'.$langs->trans('AliasNames').''; - print $object->name_alias; - print "
'.$langs->trans('ProspectCustomer').''; print $object->getLibCustProspStatut(); @@ -461,8 +456,8 @@ if ($id > 0) } // Categories - if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { - print '
' . $langs->trans( "Categories" ) . '
' . $langs->trans("CustomersCategoriesShort") . ''; print $form->showCategories( $object->id, 'customer', 1 ); print "
'; - print ''."\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $paramlist=''; + $paramlist.="&account=".$acct->id; + + print '
'.$langs->trans("DateOperationShort").''.$langs->trans("DateValueShort").''.$langs->trans("Type").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Action").''.$langs->trans("ToConciliate").'
'; + print ''."\n"; + print_liste_field_titre($langs->trans("DateOperationShort"),$_SERVER["PHP_SELF"],"b.dateo","",$paramlist,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateValueShort"),$_SERVER["PHP_SELF"],"b.datev","",$paramlist,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"b.fk_type","",$paramlist,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"b.label","",$paramlist,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Debit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Credit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$paramlist,' width="80 align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ToConciliate"),$_SERVER["PHP_SELF"],"","",$paramlist,' align="center" width="80" ',$sortfield,$sortorder); print "\n"; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 0cee6211b49..26be80caa68 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -118,7 +118,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Ligne de titre tableau des ecritures print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index cddd511dbe4..13c10a5da0c 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -760,8 +760,120 @@ class FactureRec extends CommonInvoice $arraynow=dol_getdate($now); $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - parent::initAsSpecimen($option); + $prodids = array(); + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $resql = $this->db->query($sql); + if ($resql) + { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) + { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } + // Initialize parameters + $this->id=0; + $this->ref = 'SPECIMEN'; + $this->specimen=1; + $this->socid = 1; + $this->date = $nownotime; + $this->date_lim_reglement = $nownotime + 3600 * 24 *30; + $this->cond_reglement_id = 1; + $this->cond_reglement_code = 'RECEP'; + $this->date_lim_reglement=$this->calculate_date_lim_reglement(); + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR + $this->note_public='This is a comment (public)'; + $this->note_private='This is a comment (private)'; + $this->note='This is a comment (private)'; + $this->fk_incoterms=0; + $this->location_incoterms=''; + + if (empty($option) || $option != 'nolines') + { + // Lines + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) + { + $line=new FactureLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->tva_tx=19.6; + $line->localtax1_tx=0; + $line->localtax2_tx=0; + $line->remise_percent=0; + if ($xnbp == 1) // Qty is negative (product line) + { + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + $line->qty=-1; + $line->total_ht=-100; + $line->total_ttc=-119.6; + $line->total_tva=-19.6; + } + else if ($xnbp == 2) // UP is negative (free line) + { + $line->subprice=-100; + $line->total_ht=-100; + $line->total_ttc=-119.6; + $line->total_tva=-19.6; + $line->remise_percent=0; + } + else if ($xnbp == 3) // Discount is 50% (product line) + { + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + $line->total_ht=50; + $line->total_ttc=59.8; + $line->total_tva=9.8; + $line->remise_percent=50; + } + else // (product line) + { + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + $line->total_ht=100; + $line->total_ttc=119.6; + $line->total_tva=19.6; + $line->remise_percent=00; + } + + $this->lines[$xnbp]=$line; + $xnbp++; + + $this->total_ht += $line->total_ht; + $this->total_tva += $line->total_tva; + $this->total_ttc += $line->total_ttc; + } + $this->revenuestamp = 0; + + // Add a line "offered" + $line=new FactureLigne($this->db); + $line->desc=$langs->trans("Description")." (offered line)"; + $line->qty=1; + $line->subprice=100; + $line->tva_tx=19.6; + $line->localtax1_tx=0; + $line->localtax2_tx=0; + $line->remise_percent=100; + $line->total_ht=0; + $line->total_ttc=0; // 90 * 1.196 + $line->total_tva=0; + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + + $this->lines[$xnbp]=$line; + $xnbp++; + } + $this->usenewprice = 1; } diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 0f03eb8ae47..07b8d95ddbc 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -205,7 +205,7 @@ $linkback = '' . $langs- // Ref -print ''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 9e81180c4fe..62f8c1b6717 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -971,6 +971,17 @@ class Paiement extends CommonObject $result=''; $label = $langs->trans("ShowPayment").': '.$this->ref; + $arraybill = $this->getBillsArray(); + if (count($arraybill) >0) + { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $facturestatic=new Facture($this->db); + foreach ($arraybill as $billid) + { + $facturestatic->fetch($billid); + $label .='
'.$facturestatic->getNomUrl(1).' '.$facturestatic->getLibStatut(2,1); + } + } $link = '
'; $linkend=''; diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php index 143ef55e987..e1b12225aad 100644 --- a/htdocs/compta/paiement/info.php +++ b/htdocs/compta/paiement/info.php @@ -40,25 +40,30 @@ $id=GETPOST('id'); llxHeader(); -$paiement = new Paiement($db); -$paiement->fetch($id); -$paiement->info($id); +$object = new Paiement($db); +$object->fetch($id); +$object->info($id); -$head = payment_prepare_head($paiement); +$head = payment_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("PaymentCustomerInvoice"), 0, 'payment'); print '
'.$langs->trans("DateEcheance").''.$langs->trans("DateDue").''.$langs->trans("Description").''.$langs->trans("ThirdParty").''.$langs->trans("Debit").'
'.$langs->trans('Ref').''; +print '
'.$langs->trans('Ref').''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '
'; +$linkback = '' . $langs->trans("BackToList") . ''; + + // Ref -print ''; +print ''; print '
'.$langs->trans('Ref').''.$paiement->id.'
'.$langs->trans('Ref').''; +print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); +print '
'; print '
'; print '
'; -dol_print_object_info($paiement); +dol_print_object_info($object); print '
'; print '
'; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index bcca56ed645..bd72fcc17f7 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -202,13 +202,14 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $paramlist=''; - $paramlist.=(GETPOST("orphelins")?"&orphelins=1":""); - $paramlist.=($search_ref?"&search_ref=".urlencode($search_ref):""); - $paramlist.=($search_company?"&search_company=".urlencode($search_company):""); - $paramlist.=($search_amount?"&search_amount=".urlencode($search_amount):""); - $paramlist.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); - if ($optioncss != '') $paramlist.='&optioncss='.urlencode($optioncss); + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param.=(GETPOST("orphelins")?"&orphelins=1":""); + $param.=($search_ref?"&search_ref=".urlencode($search_ref):""); + $param.=($search_company?"&search_company=".urlencode($search_company):""); + $param.=($search_amount?"&search_amount=".urlencode($search_amount):""); + $param.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); print '
'; if ($optioncss != '') print ''; @@ -218,24 +219,24 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, $nbtotalofrecords,'title_accountancy.png', 0, '', '', $limit); + print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords,'title_accountancy.png', 0, '', '', $limit); print ''; print ''; - print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"p.rowid","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"dp","",$paramlist,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"c.libelle","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"p.num_paiement","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"p.amount","",$paramlist,'align="right"',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("Invoices"),"","","",$paramlist,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"p.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"dp","",$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("Type"),$_SERVER["PHP_SELF"],"c.libelle","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"p.num_paiement","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"p.amount","",$param,'align="right"',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("Invoices"),"","","",$param,'align="left"',$sortfield,$sortorder); $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$paramlist,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 2d9241301a6..9b4d37d6335 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Dourseanud - * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014-2106 Ferran Marcet * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry * @@ -633,18 +633,18 @@ if (! empty($conf->expensereport->enabled)) $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " WHERE p.entity = ".getEntity('expensereport',1); - $sql.= " AND p.fk_statut>5"; + $sql.= " AND p.fk_statut>=5"; $column='p.date_valid'; } else { - $sql = "SELECT p.rowid, p.ref, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; + $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; $sql.= " WHERE p.entity = ".getEntity('expensereport',1); - $sql.= " AND p.fk_statut=6"; + $sql.= " AND p.fk_statut>=5"; $column='pe.datep'; } @@ -654,7 +654,7 @@ if (! empty($conf->expensereport->enabled)) if (! empty($date_start) && ! empty($date_end)) $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; - $sql.= " GROUP BY p.rowid, p.ref, u.firstname, u.lastname, dm"; + $sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm"; $sql.= " ORDER BY p.ref"; dol_syslog("get expense report outcome"); @@ -677,7 +677,7 @@ if (! empty($conf->expensereport->enabled)) $var = !$var; print ""; - print "\n"; + print "\n"; if ($modecompta == 'CREANCES-DETTES') print ''; print ''; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index a98ce53ae81..861b44edd6c 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014-2016 Ferran Marcet * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry * @@ -529,7 +529,7 @@ if (! empty($conf->expensereport->enabled)) $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " WHERE p.entity = ".getEntity('expensereport',1); - $sql.= " AND p.fk_statut>5"; + $sql.= " AND p.fk_statut>=5"; $column='p.date_valid'; @@ -540,7 +540,7 @@ if (! empty($conf->expensereport->enabled)) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; $sql.= " WHERE p.entity = ".getEntity('expensereport',1); - $sql.= " AND p.fk_statut=6"; + $sql.= " AND p.fk_statut>=5"; $column='pe.datep'; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 36c79c0f7c5..0a34723e2ce 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -328,8 +328,7 @@ if (empty($reshook)) $label = $lines[$i]->product_label; } - if ($conf->global->PRODUIT_DESC_IN_FORM) - $desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):''; + $desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):''; } else { $desc = dol_htmlentitiesbr($lines[$i]->desc); @@ -360,7 +359,6 @@ if (empty($reshook)) $error++; break; } - } } } diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 18a60a3429d..250f1c98199 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -190,7 +190,7 @@ foreach($listofstatus as $status) print ''; print "\n"; } - if ($status==4 && $bool==false) $bool=true; + if ($status==4 && ! $bool) $bool=true; else $bool=false; } if (! empty($conf->use_javascript_ajax)) @@ -210,7 +210,7 @@ foreach($listofstatus as $status) print ''; print ''; print ''; - if ($status==4 && $bool==false) $bool=true; + if ($status==4 && ! $bool) $bool=true; else $bool=false; print "\n"; } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index f50bff34a86..7b5a01d6bca 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -95,7 +95,7 @@ class box_factures extends ModeleBoxes $now=dol_now(); $line = 0; - $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)'; + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { $objp = $db->fetch_object($result); @@ -118,7 +118,7 @@ class box_factures extends ModeleBoxes $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day'))); + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); } $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 7c90bb69683..88b64947f05 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -95,7 +95,7 @@ class box_factures_fourn extends ModeleBoxes $num = $db->num_rows($result); $line = 0; - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)'; + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { $objp = $db->fetch_object($result); diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index 4e54b590955..27441f22ea5 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -88,7 +88,7 @@ class box_factures_fourn_imp extends ModeleBoxes $num = $db->num_rows($result); $line = 0; - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)'; + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; $facturestatic = new FactureFournisseur($db); diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 63ce986e181..783aa8b2c64 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -96,7 +96,7 @@ class box_factures_imp extends ModeleBoxes $now=dol_now(); $line = 0; - $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)'; + $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)'; while ($line < $num) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3ad080d8a55..3287ac5d4b7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3987,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); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0b55e2cc814..914c7077c8b 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -123,8 +123,6 @@ class Conf */ function setValues($db) { - global $conf; - dol_syslog(get_class($this)."::setValues"); /* @@ -205,17 +203,19 @@ class Conf $db->free($resql); } - // Include local constants files and fetch their values to the corresponding database constants - if(! empty($this->global->LOCAL_CONSTS_FILES)) { - $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); - foreach ($filesList as $file) { - $file=dol_sanitizeFileName($file); - include_once DOL_DOCUMENT_ROOT . "/$file/{$file}_consts.php"; - foreach ($file2bddconsts as $key=>$value) { - $conf->global->$key=constant($value); - } - } - } + + // Include other local consts.php files and fetch their values to the corresponding database constants + if (! empty($this->global->LOCAL_CONSTS_FILES)) { + $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); + foreach ($filesList as $file) { + $file=dol_sanitizeFileName($file); + include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; + foreach ($file2bddconsts as $key=>$value) { + $this->global->$key=constant($value); + } + } + } + //var_dump($this->modules); //var_dump($this->modules_parts['theme']); @@ -398,7 +398,7 @@ class Conf unset($this->global->PROJECT_USE_SEARCH_TO_SELECT); } - if (! empty($conf->productbatch->enabled)) + if (! empty($this->productbatch->enabled)) { $this->global->STOCK_CALCULATE_ON_BILL=0; $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0; @@ -419,7 +419,7 @@ class Conf $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; // MAIN_HTML_TITLE - if (! isset($conf->global->MAIN_HTML_TITLE)) $conf->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly'; + if (! isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly'; // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25; @@ -446,7 +446,7 @@ class Conf // conf->mailing->email_from = email pour envoi par Dolibarr des mailings $this->mailing->email_from=$this->email_from; if (! empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from=$this->global->MAILING_EMAIL_FROM; - if (! isset($conf->global->MAIN_EMAIL_ADD_TRACK_ID)) $conf->global->MAIN_EMAIL_ADD_TRACK_ID=1; + if (! isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID=1; // Format for date (used by default when not found or not searched in lang) $this->format_date_short="%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) @@ -579,7 +579,7 @@ class Conf throw new Exception('Log handler does not extend LogHandlerInterface'); } - if (empty($conf->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; + if (empty($this->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; } } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 74cd27bc460..70a4738366d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3145,7 +3145,7 @@ class Form /** * Return list of categories having choosed type * - * @param int $type Type de categories (0=product, 1=supplier, 2=customer, 3=member) + * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element) * @param string $htmlname HTML field name * @param int $maxlength Maximum length for labels @@ -3161,6 +3161,12 @@ class Form include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + // For backward compatibility + if (is_numeric($type)) + { + dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + } + $cat = new Categorie($this->db); $cate_arbo = $cat->get_full_arbo($type,$excludeafterid); @@ -4297,7 +4303,7 @@ class Form } $return.= '>'.vatrate($rate['libtva']); //$return.=($rate['code']?' '.$rate['code']:''); - $return.= (empty($defaultcode) && $rate['nprtva']) ? ' *': ''; // We show the * (old behaviour only if new vat code is not used) + $return.= (empty($rate['code']) && $rate['nprtva']) ? ' *': ''; // We show the * (old behaviour only if new vat code is not used) $return.= ''; } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index f446caa12a2..3664424764d 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -302,7 +302,7 @@ class FormOther /** * Return select list for categories (to use in form search selectors) * - * @param int $type Type of categories (0=product, 1=supplier, 2=customer, 3=member, 4=contact) + * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param integer $selected Preselected value * @param string $htmlname Name of combo list * @param int $nocateg Show also an entry "Not categorized" @@ -315,6 +315,12 @@ class FormOther global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + // For backward compatibility + if (is_numeric($type)) + { + dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + } + // Load list of "categories" $static_categs = new Categorie($this->db); $tab_categs = $static_categs->get_full_arbo($type); 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 34858bc3234..c0757de2d6b 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -857,9 +857,10 @@ class Translate //print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit; // Check if a translation is available (this can call getTradFromKey) - if ($this->transnoentitiesnoconv($key) != $key) + $tmp=$this->transnoentitiesnoconv($key); + if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString') { - return $this->transnoentitiesnoconv($key); // Found in language array + return $tmp; // Found in language array } // Check in cache diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 0be65dfe2e6..97c72160d76 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -192,8 +192,12 @@ class DoliDBMssql extends DoliDB function getVersion() { $resql=$this->query("SELECT @@VERSION"); - $version=$this->fetch_array($resql); - return $version['computed']; + if ($resql) + { + $version=$this->fetch_array($resql); + return $version['computed']; + } + else return ''; } /** @@ -203,10 +207,7 @@ class DoliDBMssql extends DoliDB */ function getDriverInfo() { - // FIXME: Dummy method - // TODO: Implement - - return ''; + return 'php mssql driver'; } /** @@ -359,7 +360,7 @@ class DoliDBMssql extends DoliDB $query_comp[]=$fld->COLUMN_NAME." IS NOT NULL"; } } - if ($query_comp) + if (! empty($query_comp)) $query.=" WHERE ".implode(" AND ",$query_comp); } } @@ -648,7 +649,7 @@ class DoliDBMssql extends DoliDB function last_insert_id($tab,$fieldid='rowid') { $res = $this->query("SELECT @@IDENTITY as id"); - if ($data = $this->fetch_array($res)) + if ($res && $data = $this->fetch_array($res)) { return $data["id"]; } @@ -709,8 +710,12 @@ class DoliDBMssql extends DoliDB function DDLGetConnectId() { $resql=$this->query('SELECT CONNECTION_ID()'); - $row=$this->fetch_row($resql); - return $row[0]; + if ($resql) + { + $row=$this->fetch_row($resql); + return $row[0]; + } + else return '?'; } /** diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 34a7ebdf9f5..a92bb09e0b3 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -549,8 +549,12 @@ class DoliDBMysql extends DoliDB function DDLGetConnectId() { $resql=$this->query('SELECT CONNECTION_ID()'); - $row=$this->fetch_row($resql); - return $row[0]; + if ($resql) + { + $row=$this->fetch_row($resql); + return $row[0]; + } + else return '?'; } diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index d21caecea36..b6df8420490 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -532,8 +532,12 @@ class DoliDBMysqli extends DoliDB function DDLGetConnectId() { $resql=$this->query('SELECT CONNECTION_ID()'); - $row=$this->fetch_row($resql); - return $row[0]; + if ($resql) + { + $row=$this->fetch_row($resql); + return $row[0]; + } + else return '?'; } /** diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 048ef2d450d..c8b72ebcdd9 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -874,31 +874,34 @@ class DoliDBPgsql extends DoliDB */ function DDLInfoTable($table) { - $infotables=array(); + $infotables=array(); - $sql="SELECT "; - $sql.=" infcol.column_name as \"Column\","; - $sql.=" CASE WHEN infcol.character_maximum_length IS NOT NULL THEN infcol.udt_name || '('||infcol.character_maximum_length||')'"; - $sql.=" ELSE infcol.udt_name"; - $sql.=" END as \"Type\","; - $sql.=" infcol.collation_name as \"Collation\","; - $sql.=" infcol.is_nullable as \"Null\","; - $sql.=" '' as \"Key\","; - $sql.=" infcol.column_default as \"Default\","; - $sql.=" '' as \"Extra\","; - $sql.=" '' as \"Privileges\""; - $sql.=" FROM information_schema.columns infcol"; - $sql.=" WHERE table_schema='public' "; - $sql.=" AND table_name='".$table."'"; - $sql.=" ORDER BY ordinal_position;"; + $sql="SELECT "; + $sql.=" infcol.column_name as \"Column\","; + $sql.=" CASE WHEN infcol.character_maximum_length IS NOT NULL THEN infcol.udt_name || '('||infcol.character_maximum_length||')'"; + $sql.=" ELSE infcol.udt_name"; + $sql.=" END as \"Type\","; + $sql.=" infcol.collation_name as \"Collation\","; + $sql.=" infcol.is_nullable as \"Null\","; + $sql.=" '' as \"Key\","; + $sql.=" infcol.column_default as \"Default\","; + $sql.=" '' as \"Extra\","; + $sql.=" '' as \"Privileges\""; + $sql.=" FROM information_schema.columns infcol"; + $sql.=" WHERE table_schema='public' "; + $sql.=" AND table_name='".$table."'"; + $sql.=" ORDER BY ordinal_position;"; - dol_syslog($sql,LOG_DEBUG); - $result = $this->query($sql); - while($row = $this->fetch_row($result)) - { - $infotables[] = $row; - } - return $infotables; + dol_syslog($sql,LOG_DEBUG); + $result = $this->query($sql); + if ($result) + { + while($row = $this->fetch_row($result)) + { + $infotables[] = $row; + } + } + return $infotables; } @@ -1111,8 +1114,12 @@ class DoliDBPgsql extends DoliDB function getDefaultCharacterSetDatabase() { $resql=$this->query('SHOW SERVER_ENCODING'); - $liste=$this->fetch_array($resql); - return $liste['server_encoding']; + if ($resql) + { + $liste=$this->fetch_array($resql); + return $liste['server_encoding']; + } + else return ''; } /** @@ -1127,7 +1134,7 @@ class DoliDBPgsql extends DoliDB if ($resql) { $i = 0; - while ($obj = $this->fetch_object($resql) ) + while ($obj = $this->fetch_object($resql)) { $liste[$i]['charset'] = $obj->server_encoding; $liste[$i]['description'] = 'Default database charset'; @@ -1148,8 +1155,12 @@ class DoliDBPgsql extends DoliDB function getDefaultCollationDatabase() { $resql=$this->query('SHOW LC_COLLATE'); - $liste=$this->fetch_array($resql); - return $liste['lc_collate']; + if ($resql) + { + $liste=$this->fetch_array($resql); + return $liste['lc_collate']; + } + else return ''; } /** diff --git a/htdocs/core/js/select2_locale.js.php b/htdocs/core/js/select2_locale.js.php index 660b41820df..31c6a91bc74 100644 --- a/htdocs/core/js/select2_locale.js.php +++ b/htdocs/core/js/select2_locale.js.php @@ -52,7 +52,10 @@ else header('Cache-Control: no-cache'); $.fn.select2.locales['xx'] = { formatMatches: function (matches) { return matches + " trans("Select2ResultFoundUseArrows")); ?>"; }, formatNoMatches: function () { return "trans("Select2NotFound")); ?>"; }, - formatInputTooShort: function (input, min) { var n = min - input.length; return "trans("Select2Enter")); ?> " + n + " trans("Select2MoreCharacters")); ?>"; }, + formatInputTooShort: function (input, min) { var n = min - input.length; + if (n > 1) return "trans("Select2Enter")); ?> " + n + " trans("Select2MoreCharacters")); ?>"; + else return "trans("Select2Enter")); ?> " + n + " trans("Select2MoreCharacter")); ?>" + }, formatLoadMore: function (pageNumber) { return "trans("Select2LoadingMoreResults")); ?>"; }, formatSearching: function () { return "trans("Select2SearchInProgress")); ?>"; } }; diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 7a73861e71f..773e68913f9 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -37,26 +37,26 @@ function admin_accounting_prepare_head(AccountingAccount $object=null) $head = array (); $head[$h][0] = dol_buildpath('/accountancy/admin/index.php', 1); - $head[$h][1] = $langs->trans("Configuration"); + $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; $h ++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin'); - $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/journal.php'; $head[$h][1] = $langs->trans("Journaux"); $head[$h][2] = 'journal'; $h ++; $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/export.php'; - $head[$h][1] = $langs->trans("Export"); + $head[$h][1] = $langs->trans("ExportOptions"); $head[$h][2] = 'export'; $h ++; + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin', 'remove'); return $head; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 919a72c5ec5..ad40ba84938 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -441,8 +441,14 @@ function actions_prepare_head($object) // Tab to link resources if ($conf->resource->enabled) { + include_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; + $resource=new DolResource($db); + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; + $listofresourcelinked = $resource->getElementResources($object->element, $object->id); + $nbResources=count($listofresourcelinked); $head[$h][1] = $langs->trans("Resources"); + if ($nbResources > 0) $head[$h][1].= ' '.($nbResources).''; $head[$h][2] = 'resources'; $h++; } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8631c576576..b2b6d8274a5 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -186,9 +186,9 @@ function societe_prepare_head(Societe $object) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { $head[$h][1] = $langs->trans("Events"); - $head[$h][1].= ' / '; + $head[$h][1].= '/'; } - $head[$h][1].= $langs->trans("Info"); + $head[$h][1].= $langs->trans("Agenda"); $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 252b51be7d2..f831de667bd 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -373,7 +373,7 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali * @param Societe $targetcompany Target company object * @param Contact $targetcontact Target contact object * @param int $usecontact Use contact instead of company - * @param int $mode Address type ('source', 'target', 'targetwithdetails': target but include also phone/fax/email/url) + * @param int $mode Address type ('source', 'target', 'targetwithdetails', 'targetwithdetails_xxx': target but include also phone/fax/email/url) * @param Object $object Object we want to build document for * @return string String with full address */ @@ -420,7 +420,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target } } - if ($mode == 'target' || $mode == 'targetwithdetails') + if ($mode == 'target' || preg_match('/targetwithdetails/',$mode)) { if ($usecontact) { @@ -439,19 +439,31 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; } - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) { // Phone - if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); - if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) + { + if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; + if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); + if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; + if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); + } // Fax - if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) + { + if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); + } // EMail - if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) + { + if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); + } // Web - if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) + { + if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); + } } } else @@ -460,19 +472,31 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target // Country if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) { // Phone - if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); - if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) + { + if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; + if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); + if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; + if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); + } // Fax - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) + { + if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); + } // EMail - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) + { + if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); + } // Web - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) + { + if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); + } } } @@ -507,17 +531,29 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); } - + if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) + { + $tmp=$outputlangs->transcountrynoentities("ProfId5",$targetcompany->country_code); + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; + $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); + } + if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) + { + $tmp=$outputlangs->transcountrynoentities("ProfId6",$targetcompany->country_code); + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; + $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); + } + // Public note if (! empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) { if ($mode == 'source' && ! empty($sourcecompany->note_public)) { - $stringaddress.="\n".$sourcecompany->note_public; + $stringaddress.="\n".dol_string_nohtmltag($sourcecompany->note_public); } - if (($mode == 'target' || $mode == 'targetwithdetails') && ! empty($targetcompany->note_public)) + if (($mode == 'target' || preg_match('/targetwithdetails/',$mode)) && ! empty($targetcompany->note_public)) { - $stringaddress.="\n".$targetcompany->note_public; + $stringaddress.="\n".dol_string_nohtmltag($targetcompany->note_public); } } } @@ -602,10 +638,10 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) */ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; - global $mysoc, $conf; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); $pdf->SetXY($curx, $cury); @@ -683,7 +719,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default if (empty($onlynumber)) { $pdf->line($curx, $cury + 1, $curx, $cury + 7); } - } + } $curx=$savcurx; $cury+=8; @@ -730,7 +766,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default // Use correct name of bank id according to country $ibankey = FormBank::getIBANLabel($account); - + if (! empty($account->iban)) { //Remove whitespaces to ensure we are dealing with the format we expect @@ -771,7 +807,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default * @param int $marge_gauche Margin left (no more used) * @param int $page_hauteur Page height (no more used) * @param Object $object Object shown in PDF - * @param int $showdetails Show company details into footer. This param seems to not be used by standard version. (1=Show address, 2=Show managers, 3=Both) + * @param int $showdetails Show company adress details into footer (0=Nothing, 1=Show address, 2=Show managers, 3=Both) * @param int $hidefreetext 1=Hide free text, 0=Show free text * @return int Return height of bottom margin including footer text */ @@ -803,7 +839,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass // First line of company infos $line1=""; $line2=""; $line3=""; $line4=""; - if ($showdetails == 1 || $showdetails == 3) + if ($showdetails == 1 || $showdetails == 3) { // Company name if ($fromcompany->name) @@ -1606,7 +1642,7 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) * @param HookManager $hookmanager Hook manager instance - * @return string + * @return string Value for unit cell */ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = false) { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index dd135c10b24..e51862922a0 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -465,6 +465,8 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) } else { + $default='515870'; + if ($conf->theme == 'md') $default='5A3278'; $var=!$var; print ''; print ''; @@ -479,7 +481,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) if ($color) print ''; else print $langs->trans("Default"); } - print '   ('.$langs->trans("Default").': 515870, '.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; + print '   ('.$langs->trans("Default").': '.$default.', '.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print ''; } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index c0fa6b9fad9..98b281d04dd 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -26,7 +26,6 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin', __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 101__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/company.php?leftmenu=setup', 'MenuCompanySetup', 1, 'admin', '', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 102__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/ihm.php?leftmenu=setup', 'GUISetup', 1, 'admin', '', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup" && $conf->accounting->enabled', __HANDLER__, 'left', 115__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=setup', 'Fiscalyear', 1, 'admin', '', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 114__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/translation.php?leftmenu=setup', 'Translation', 1, 'admin', '', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 103__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/modules.php?leftmenu=setup', 'Modules', 1, 'admin', '', '', 2, 2, __ENTITY__); @@ -210,7 +209,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); -- Accounting Expert -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=accounting', 'MenuAccountancy', 0, 'accountancy', '(! empty($conf->accounting->enabled) || $user->rights->accounting->ventilation->read || $user->rights->accounting->ventilation->dispatch || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=accounting', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->ventilation->read || $user->rights->accounting->ventilation->dispatch || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); -- Dispatch insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->ventilation->dispatch', '', 0, 2, __ENTITY__); @@ -235,6 +234,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2447__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 24, __ENTITY__); -- Admin insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'home', '', 2400__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy', 'Chartofaccounts', 1, 'admin', '$user->rights->accounting->chartofaccount', '', 0, 25, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup" && $conf->accounting->enabled', __HANDLER__, 'left', 115__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=setup', 'Fiscalyear', 1, 'admin', '', '', 2, 4, __ENTITY__); -- Rapports compta simple insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'ca', 6__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 11, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index cbd4b035c4e..f7cf130a9a3 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; * @param DoliDB $db Database handler * @param string $atarget Target * @param int $type_user 0=Menu for backoffice, 1=Menu for front office - * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @param array $menu Object Menu to return back list of menu entries + * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @param Menu $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @return int 0 */ @@ -128,7 +128,7 @@ function print_start_menu_entry_auguria($idsel,$classname,$showmode) if ($showmode) { print ' + diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 1f0756a666c..4c5b654a76f 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -117,7 +117,7 @@ $coldisplay=-1; // We remove first td } $coldisplay++; - print ''; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 35ef726be20..6d3f7b05966 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -705,7 +705,9 @@ class Expedition extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); if ($result < 0) { - $error++; break; + $error++; + $this->errors[]=$mouvS->error; + break; } } else @@ -713,17 +715,12 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); + // ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch, $obj->fk_origin_stock); if ($result < 0) { - $error++; break; - } - - // We update content of table llx_product_batch (will be rename into llx_product_stock_batch inantoher version) - // We can set livraison_batch to deprecated and adapt livraison to handle batch too (mouvS->_create also calls mouvS->_create_batch) - if (! empty($conf->productbatch->enabled)) - { - $result=$mouvS->livraison_batch($obj->fk_origin_stock, $qty); // ->fk_origin_stock = id into table llx_product_batch (will be rename into llx_product_stock_batch in another version) - if ($result < 0) { $error++; $this->errors[]=$mouvS->error; break; } + $error++; + $this->errors[]=$mouvS->error; + break; } } } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a946649592a..71b852880fb 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -333,7 +333,7 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -390,6 +390,7 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id else { $mesg=$mailfile->error; + setEventMessages($mesg, null, 'errors'); } // END - Send mail } @@ -438,7 +439,7 @@ if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $u if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -542,7 +543,7 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -583,7 +584,6 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user else { setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - $mesg="Impossible d'envoyer l'email."; } // END - Send mail } @@ -627,7 +627,7 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_ if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -667,6 +667,7 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_ else { $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); } // END - Send mail } @@ -756,7 +757,7 @@ if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -806,9 +807,8 @@ if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) endif; else: - - $mesg="Impossible d'envoyer l'email."; - + $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); endif; // END - Send mail } @@ -921,7 +921,7 @@ if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes") $total_ht = $object_ligne->total_ht; $total_tva = $object_ligne->total_tva; - $result=$object->deleteline(GETPOST("rowid")); + $result=$object->deleteline(GETPOST("rowid"), $user); if ($result >= 0) { if ($result > 0) @@ -961,7 +961,6 @@ if ($action == "updateligne" ) $rowid = $_POST['rowid']; $type_fees_id = GETPOST('fk_c_type_fees'); - $object_ligne->vatrate = price2num(GETPOST('vatrate')); $projet_id = $fk_projet; $comments = GETPOST('comments'); $qty = GETPOST('qty'); @@ -983,6 +982,7 @@ if ($action == "updateligne" ) if (! $error) { + // TODO Use update method of ExpenseReportLine $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id); if ($result >= 0) { @@ -1078,29 +1078,6 @@ $formfile = new FormFile($db); $formproject = new FormProjets($db); $projecttmp = new Project($db); -if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) -{ - if(!empty($_GET['mesg'])) - { - $text_mesg = explode(",",$_GET['mesg']); - - foreach($text_mesg as $text) - { - $mesg.= "- ".$langs->trans($text)."
"; - } - - print "
"; - print $langs->trans("LINE_NOT_ADDED")."
"; - print $mesg; - print "
"; - } - else - { - if ($mesg) print "
".$mesg."
"; - } -} - - // Create if ($action == 'create') { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 07c3e598818..6394b977908 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2015 Laurent Destailleur * 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 @@ -140,6 +141,7 @@ class ExpenseReport extends CommonObject $sql.= ",paid"; $sql.= ",note_public"; $sql.= ",note_private"; + $sql.= ",entity"; $sql.= ") VALUES("; $sql.= "'(PROV)'"; $sql.= ", ".$this->total_ht; @@ -156,6 +158,7 @@ class ExpenseReport extends CommonObject $sql.= ", 0"; $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); + $sql.= ", ".$conf->entity; $sql.= ")"; dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 3e629e05789..fc24d8c8326 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -120,7 +120,7 @@ if ($resql) foreach ($listofstatus as $status) { $dataseries[]=array('label'=>$fichinterstatic->LibStatut($status,$bool,1),'data'=>(isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); - if ($status==3 && $bool==false) $bool=true; + if ($status==3 && ! $bool) $bool=true; else $bool=false; } if ($conf->use_javascript_ajax) @@ -144,7 +144,7 @@ if ($resql) print ''; print ''; print "\n"; - if ($status==3 && $bool==false) $bool=true; + if ($status==3 && ! $bool) $bool=true; else $bool=false; } } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index b64a8ee77e4..8c533f0f547 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -231,7 +231,7 @@ if ($object->id > 0) // Categories if (! empty($conf->categorie->enabled)) { - print ''; + print ''; print '"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index cb7d0ce6e6f..f8c57d7cc94 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1126,7 +1126,7 @@ class CommandeFournisseur extends CommonOrder // insert products details into database for ($i=0;$i<$num;$i++) { - $result = $this->addline( + $result = $this->addline( // This include test on qty if option SUPPLIERORDER_WITH_NOPRICEDEFINED is not set $this->lines[$i]->desc, $this->lines[$i]->subprice, $this->lines[$i]->qty, @@ -1306,11 +1306,11 @@ class CommandeFournisseur extends CommonOrder */ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null) { - global $langs,$mysoc, $conf; + global $langs,$mysoc,$conf; $error = 0; - dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2. $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit"); + dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -1350,40 +1350,45 @@ class CommandeFournisseur extends CommonOrder { $this->db->begin(); - if ($fk_prod_fourn_price > 0) + if ($fk_product > 0) { - $prod = new Product($this->db, $fk_product); - if ($prod->fetch($fk_product) > 0) + if (empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED)) { - $result=$prod->get_buyprice($fk_prod_fourn_price,$qty,$fk_product,$fourn_ref); - if ($result > 0) + // Check quantity is enough + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." fourn_ref=".$fourn_ref); + $prod = new Product($this->db, $fk_product); + if ($prod->fetch($fk_product) > 0) { - $label = $prod->libelle; - $pu = $prod->fourn_pu; - $ref = $prod->ref_fourn; - $product_type = $prod->type; + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, $fourn_ref); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref + if ($result > 0) + { + $label = $prod->libelle; + $pu = $prod->fourn_pu; + $ref = $prod->ref_fourn; + $product_type = $prod->type; + } + if ($result == 0 || $result == -1) + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); + return -1; + } + if ($result < -1) + { + $this->error=$prod->error; + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); + return -1; + } } - if ($result == 0 || $result == -1) - { - $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); - return -1; - } - if ($result < -1) - { + else + { $this->error=$prod->error; - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); return -1; } } - else - { - $this->error=$prod->error; - return -1; - } } else { @@ -1449,7 +1454,6 @@ class CommandeFournisseur extends CommonOrder $sql.= ", ".$multicurrency_total_ttc; $sql.= ")"; - dol_syslog(get_class($this)."::addline", LOG_DEBUG); $resql=$this->db->query($sql); //print $sql; if ($resql) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 48896689dce..05024f9991a 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -216,7 +216,7 @@ class ProductFournisseur extends Product $this->db->begin(); - if ($this->product_fourn_price_id) + if ($this->product_fourn_price_id > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " SET fk_user = " . $user->id." ,"; @@ -237,7 +237,7 @@ class ProductFournisseur extends Product $sql.= " WHERE rowid = ".$this->product_fourn_price_id; // TODO Add price_base_type and price_ttc - dol_syslog(get_class($this).'::update_buyprice', LOG_DEBUG); + dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -249,7 +249,7 @@ class ProductFournisseur extends Product if (empty($error)) { $this->db->commit(); - return 0; + return $this->product_fourn_price_id; } else { @@ -267,94 +267,88 @@ class ProductFournisseur extends Product else { - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - dol_syslog(get_class($this).'::update_buyprice', LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql.= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, info_bits, entity, delivery_time_days,supplier_reputation)"; - $sql.= " values('".$this->db->idate($now)."',"; - $sql.= " ".$this->id.","; - $sql.= " ".$fourn->id.","; - $sql.= " '".$this->db->escape($ref_fourn)."',"; - $sql.= " ".$user->id.","; - $sql.= " ".$buyprice.","; - $sql.= " ".$qty.","; - $sql.= " ".$remise_percent.","; - $sql.= " ".$remise.","; - $sql.= " ".$unitBuyPrice.","; - $sql.= " ".$tva_tx.","; - $sql.= " ".$charges.","; - $sql.= " ".$unitCharges.","; - $sql.= " ".$availability.","; - $sql.= " ".$newnpr.","; - $sql.= $conf->entity.","; - $sql.= $delivery_time_days.","; - $sql.= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'"); - $sql.=")"; - - dol_syslog(get_class($this)."::update_buyprice", LOG_DEBUG); - if (! $this->db->query($sql)) - { - $error++; - } - - if (! $error && !empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql.= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql.= "values('".$this->db->idate($now)."',"; - $sql.= " ".$this->product_fourn_id.","; - $sql.= " ".$user->id.","; - $sql.= " ".price2num($buyprice).","; - $sql.= " ".$qty; - $sql.=")"; - - $resql=$this->db->query($sql); - if (! $resql) - { - $error++; - } - } - - - if (! $error) - { - // Call trigger - $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE',$user); - if ($result < 0) $error++; + dol_syslog(get_class($this) . '::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); + + // Delete price for this quantity + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_fournisseur_price"; + $sql .= " WHERE fk_soc = " . $fourn->id . " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "' AND quantity = " . $qty . " AND entity = " . $conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + // Add price for this quantity to supplier + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; + $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, info_bits, entity, delivery_time_days,supplier_reputation)"; + $sql .= " values('" . $this->db->idate($now) . "',"; + $sql .= " " . $this->id . ","; + $sql .= " " . $fourn->id . ","; + $sql .= " '" . $this->db->escape($ref_fourn) . "',"; + $sql .= " " . $user->id . ","; + $sql .= " " . $buyprice . ","; + $sql .= " " . $qty . ","; + $sql .= " " . $remise_percent . ","; + $sql .= " " . $remise . ","; + $sql .= " " . $unitBuyPrice . ","; + $sql .= " " . $tva_tx . ","; + $sql .= " " . $charges . ","; + $sql .= " " . $unitCharges . ","; + $sql .= " " . $availability . ","; + $sql .= " " . $newnpr . ","; + $sql .= $conf->entity . ","; + $sql .= $delivery_time_days . ","; + $sql .= (empty($supplier_reputation) ? 'NULL' : "'" . $this->db->escape($supplier_reputation) . "'"); + $sql .= ")"; + + $idinserted = 0; + + $resql = $this->db->query($sql); + if ($resql) { + $idinserted = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_fournisseur_price"); + } + else { + $error++; + } + + if (! $error && ! empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { + // Add record into log table + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log("; + $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; + $sql .= "values('" . $this->db->idate($now) . "',"; + $sql .= " " . $this->product_fourn_id . ","; + $sql .= " " . $user->id . ","; + $sql .= " " . price2num($buyprice) . ","; + $sql .= " " . $qty; + $sql .= ")"; + + $resql = $this->db->query($sql); + if (! $resql) { + $error++; + } + } + + if (! $error) { + // Call trigger + $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); + if ($result < 0) + $error++; // End call triggers - - if (empty($error)) - { - $this->db->commit(); - return 0; - } - else - { - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } + + if (empty($error)) { + $this->db->commit(); + return $idinserted; + } else { + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->db->rollback(); + return - 1; + } + } } /** diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 34dd4ad180f..f4685469711 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -381,6 +381,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid"; $sql.= " WHERE l.fk_commande = ".$commande->id; + if(empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND l.product_type = 0"; $sql.= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product $sql.= " ORDER BY p.ref, p.label"; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 50679085f12..81b9dbca14b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1005,7 +1005,7 @@ else print ''; print ''; // Type diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 03ffcf2b465..a31bd28da49 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2012-2014 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Juanjo Menent * * 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 @@ -117,7 +118,7 @@ class Holiday extends CommonObject */ function create($user, $notrigger=0) { - global $conf, $langs; + global $conf; $error=0; $now=dol_now(); @@ -137,7 +138,8 @@ class Holiday extends CommonObject $sql.= "statut,"; $sql.= "fk_validator,"; $sql.= "fk_type,"; - $sql.= "fk_user_create"; + $sql.= "fk_user_create,"; + $sql.= "entity"; $sql.= ") VALUES ("; $sql.= "'".$this->fk_user."',"; $sql.= " '".$this->db->idate($now)."',"; @@ -148,7 +150,8 @@ class Holiday extends CommonObject $sql.= " '1',"; $sql.= " '".$this->fk_validator."',"; $sql.= " '".$this->fk_type."',"; - $sql.= " ".$user->id; + $sql.= " ".$user->id.","; + $sql.= " ".$conf->entity; $sql.= ")"; $this->db->begin(); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index c7bc669535f..6fbd411f420 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -288,7 +288,7 @@ print '
 ".$langs->trans("ExpenseReport")." rowid."\">".$obj->ref.' ('.$obj->firstname." ".$obj->lastname.")".$langs->trans("ExpenseReport")." userid."\">".$obj->firstname." ".$obj->lastname."'.price(-$obj->amount_ht).''.price(-$obj->amount_ttc).''.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status,3,($bool?1:0)).'
'.$staticcontratligne->LibStatut($status,0,($bool?1:0)).''.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status,3,($bool?1:0)).'
'.$langs->trans("TopMenuBackgroundColor").'
global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
trans('AddNewLine'); ?>trans("FreeZone"); ?>
situation_counter > 1) print ' readonly'; print '>
' . $langs->trans("Categories") . '
' . $langs->trans("SuppliersCategoriesShort") . ''; print $form->showCategories($object->id, 'supplier', 1); print "
'.$langs->trans("User").''; - print $userRequest->getNomUrl(1); + print $userRequest->getNomUrl(1, 'leave'); print '
'; print ""; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cp.rowid","",'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreateCP"),$_SERVER["PHP_SELF"],"cp.date_create","",'','align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("Employe"),$_SERVER["PHP_SELF"],"cp.fk_user","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Employee"),$_SERVER["PHP_SELF"],"cp.fk_user","",'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ValidatorCP"),$_SERVER["PHP_SELF"],"cp.fk_validator","",'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],'','','','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],'','','','align="right"',$sortfield,$sortorder); @@ -405,7 +405,7 @@ if (! empty($holiday->holiday)) print $holidaystatic->getNomUrl(1); print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; diff --git a/htdocs/includes/ckeditor/ckeditor/CHANGES.md b/htdocs/includes/ckeditor/ckeditor/CHANGES.md index f751de99327..f1fb5c7a31d 100644 --- a/htdocs/includes/ckeditor/ckeditor/CHANGES.md +++ b/htdocs/includes/ckeditor/ckeditor/CHANGES.md @@ -1,6 +1,21 @@ CKEditor 4 Changelog ==================== +## CKEditor 4.5.9 + +Fixed Issues: + +* [#10685](http://dev.ckeditor.com/ticket/10685): Fixed: Unreadable toolbar icons after updating to the new editor version. Fixed with [6876179](https://github.com/ckeditor/ckeditor-dev/commit/6876179db4ee97e786b07b8fd72e6b4120732185) in [ckeditor-dev](https://github.com/ckeditor/ckeditor-dev) and [6c9189f4](https://github.com/ckeditor/ckeditor-presets/commit/6c9189f46392d2c126854fe8889b820b8c76d291) in [ckeditor-presets](https://github.com/ckeditor/ckeditor-presets). +* [#14573](https://dev.ckeditor.com/ticket/14573): Fixed: Missing [Widget](http://ckeditor.com/addon/widget) drag handler CSS when there are multiple editor instances. +* [#14620](https://dev.ckeditor.com/ticket/14620): Fixed: Setting both the `min-height` style for the `` element and the `height` style for the `` element breaks the [Auto Grow](http://ckeditor.com/addon/autogrow) plugin. +* [#14538](http://dev.ckeditor.com/ticket/14538): Fixed: Keyboard focus goes into an embedded `
'.dol_print_date($date,'day').''.$userstatic->getNomUrl('1').''.$userstatic->getNomUrl('1', 'leave').''.$approbatorstatic->getNomUrl('1').''; $label=$alltypeleaves[$infos_CP['fk_type']]['label']; diff --git a/htdocs/hrm/hrm.php b/htdocs/hrm/hrm.php index 2a23c7e19c9..bce42359453 100644 --- a/htdocs/hrm/hrm.php +++ b/htdocs/hrm/hrm.php @@ -189,7 +189,7 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) $userstatic->firstname=$obj->firstname; print '
'.$holidaystatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$userstatic->getNomUrl(1, 'leave').''.$typeleaves[$obj->fk_type]['label'].'