diff --git a/.travis.yml b/.travis.yml index 718356e8075..1a6cae1e792 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ php: - '5.5' - '5.6' - '7.0' +- '7.1' - nightly addons: @@ -96,7 +97,7 @@ install: if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then composer -n require phpunit/phpunit ^4 fi - if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then composer -n require phpunit/phpunit ^5 fi echo @@ -136,7 +137,7 @@ before_script: echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini echo echo "Enabling Memcached for PHP <= 5.4" - # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0 and nightly! + # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1 and nightly! echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini fi phpenv rehash @@ -208,7 +209,7 @@ before_script: echo "Setting up Apache + FPM" # enable php-fpm cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf fi diff --git a/ChangeLog b/ChangeLog index dd2fc646f7f..798f3ef91f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -403,6 +403,115 @@ So if you included it into your module, change your code like this to be compati if (! $res) include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; + +***** ChangeLog for 3.9.4 compared to 3.9.3 ***** +FIX: #2853 +FIX: #3128 +FIX: #4447 +FIX: #5128 if create method return duplicated code error not use GETPOST in order to get a new code +FIX: #5340 +FIX: #5473 +FIX: #5474 Country_id of "Don" object is still empty +FIX: #5534 +FIX: #5535 bad dependency. +FIX: #5537 AJAX project search does not work properly +FIX: #5540 getFormMail is not registered as addReplace hook +FIX: #5544 Disabled Contact still appear in lists to send emails +FIX: #5549 getNomUrl tooltips show Order info even if user has no rights to read them +FIX: #5568 +FIX: #5594 +FIX: #5629 PgSQL Interger string stylish error +FIX: #5651 +FIX: #5660 +FIX: #5853 $conf->global->$calc==0 || $conf->global->$calc==1 +FIX: #5907 +FIX: #5966 Bug: getNomUrl tooltips show Proposal info even if user has no rights to read them +FIX: #6051 +FIX: #6088 +FIX: Can correct stock of lot using eatby or sell by date +FIX: Can make a movement on "out of sell" products +FIX: cannot update bank account on invoice if module order not activated +FIX: Can't create withdrawal document +FIX: delete contract extrafields on contract deletion +FIX: Direction of movement lost if an error occurs +FIX: Error when CATEGORIE_RECURSIV_ADD is enabled and new category is daughter of an already linked to object +FIX: export extrafields must not include separe type +FIX: External user must not be able to edit its discounts +FIX: Failed to export contact categories with contact extra fields +FIX: header title in commercial area +FIX: HT and TTC price should always be displayed together +FIX: incoterms +FIX: incoterms do not output into crabe invoice PDF +FIX: in PgSQL no quote "word style" is permitted around column name +FIX: Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email. +FIX: margin tab on customer card must filter on current entity invoices +FIX: missing column into SQL on thridparty list +FIX: only show projects of related third if external user +FIX: PgSQL Module Ressource list crash #5637 +FIX: php Strict +FIX: Regression when deleting product +FIX: Security to restrict email sending was not efficient +FIX: tag for date rfc in odt substitution +FIX: Update intervention lline crash with PgSQL +FIX: update limit stock on product stock +FIX: vat dictionary should allow enter and edit multiple values for localtaxes, separated by: (ex -19:-15) +FIX: wrong test on dict.php + + +***** ChangeLog for 3.9.4 compared to 3.9.3 ***** +FIX: #2853 +FIX: #3128 +FIX: #4447 +FIX: #5128 if create method return duplicated code error not use GETPOST in order to get a new code +FIX: #5340 +FIX: #5473 +FIX: #5474 Country_id of "Don" object is still empty +FIX: #5534 +FIX: #5535 bad dependency. +FIX: #5537 AJAX project search does not work properly +FIX: #5540 getFormMail is not registered as addReplace hook +FIX: #5544 Disabled Contact still appear in lists to send emails +FIX: #5549 getNomUrl tooltips show Order info even if user has no rights to read them +FIX: #5568 +FIX: #5594 +FIX: #5629 PgSQL Interger string stylish error +FIX: #5651 +FIX: #5660 +FIX: #5853 $conf->global->$calc==0 || $conf->global->$calc==1 +FIX: #5907 +FIX: #5966 Bug: getNomUrl tooltips show Proposal info even if user has no rights to read them +FIX: #6051 +FIX: #6088 +FIX: Can correct stock of lot using eatby or sell by date +FIX: Can make a movement on "out of sell" products +FIX: cannot update bank account on invoice if module order not activated +FIX: Can't create withdrawal document +FIX: delete contract extrafields on contract deletion +FIX: Direction of movement lost if an error occurs +FIX: Error when CATEGORIE_RECURSIV_ADD is enabled and new category is daughter of an already linked to object +FIX: export extrafields must not include separe type +FIX: External user must not be able to edit its discounts +FIX: Failed to export contact categories with contact extra fields +FIX: header title in commercial area +FIX: HT and TTC price should always be displayed together +FIX: incoterms +FIX: incoterms do not output into crabe invoice PDF +FIX: in PgSQL no quote "word style" is permitted around column name +FIX: Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email. +FIX: margin tab on customer card must filter on current entity invoices +FIX: missing column into SQL on thridparty list +FIX: only show projects of related third if external user +FIX: PgSQL Module Ressource list crash #5637 +FIX: php Strict +FIX: Regression when deleting product +FIX: Security to restrict email sending was not efficient +FIX: tag for date rfc in odt substitution +FIX: Update intervention lline crash with PgSQL +FIX: update limit stock on product stock +FIX: vat dictionary should allow enter and edit multiple values for localtaxes, separated by: (ex -19:-15) +FIX: wrong test on dict.php + + ***** ChangeLog for 3.9.3 compared to 3.9.2 ***** FIX: #4383 $userid not defined FIX: #4448 $filebonprev is not used, $this->filename now diff --git a/build/debian/README.howto b/build/debian/README.howto index 1b64380cc26..afc2d391e1e 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -320,8 +320,8 @@ x.y.z+dfsgw Note: If there was errors solved manually after get-orig-sources.sh, you may need to make a git commit * Update/fix debian/* files used to build package. -At least, add an entry into debian/changelog -> dch -v x.y.z+dfsgw-v "My comment" will add entry. +At least, add an entry into debian/changelog with command +> dch -v x.y.z+dfsgw-1 "My comment" For example: dch -v x.y.z+dfsgw-1 "New upstream release." for a new version (x.y.z = version, w start from 1 and increased for each new import) Then check/modify changelog to replace "version" or "unstable" with "UNRELEASED". Then check/modify also the user/date signature: @@ -332,7 +332,9 @@ Then check/modify also the user/date signature: To update dolibarr debian package when only files into debian has changed: * Change files and commit. -* Add a tag debian/x.y.z+dfsgw-2 (increase the last 1 into 2, 3...) +* Add a line into changelog for version debian/x.y.z+dfsgw-v (increase the last v into 2, 3...) +> dch -v x.y.z+dfsgw-v "My comment" +* git tag will be added when package is pushed. To update dolibarr debian package when only files not into debian has changed: diff --git a/build/debian/control b/build/debian/control index 37689ef9bcc..75ffb43b2c0 100755 --- a/build/debian/control +++ b/build/debian/control @@ -26,11 +26,11 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | # Misc dependencies # fonts-dejavu-core | ttf-dejavu-core, xdg-utils, - virtual-mysql-client, + mariadb-client | virtual-mysql-client, ${misc:Depends}, ${perl:Depends} Recommends: apache2 | lighttpd | httpd, - virtual-mysql-server + mariadb-server | virtual-mysql-server Suggests: www-browser, php5-geoip Description: Web based software to manage a company or foundation Dolibarr ERP & CRM is an easy to use open source/free software package for diff --git a/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index 497d3abbf50..c34d9e2ffda 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -162,7 +162,7 @@ export res=$? # ---------------------------- copy demo files -export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" ` +export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g' ` if [ "x$documentdir" != "x" ] then echo cp -pr $mydir/documents_demo/* "$documentdir/" @@ -174,7 +174,7 @@ then echo cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" else - echo Detection of documents directory failed so demo files were not copied. + echo Detection of documents directory $documentdir failed so demo files were not copied. fi diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index 62ad1188759..d9e30b23501 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -303,7 +303,7 @@ foreach($property as $key => $prop) $varprop.="\$this->db->escape(\$this->".$prop['field'].")"; $varprop.=".\"'\")"; } - elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_author') + elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_m' || $prop['field']=='fk_user_author') { $varprop.="'.\$user->id"; } @@ -367,7 +367,7 @@ foreach($property as $key => $prop) $varprop.=')."\'" : \'null\')'; } - elseif ($prop['field']=='fk_user_mod') { + elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_m') { $varprop.="'.\$user->id"; } else diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 4f725fa2dbe..01b48c35f75 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -188,11 +188,13 @@ class Skeleton_Class extends CommonObject // Retrieve all extrafields for invoice // fetch optionals attributes and labels + /* require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $this->fetch_optionals($this->id,$extralabels); - + */ + // $this->fetch_lines(); $this->db->free($resql); @@ -251,23 +253,19 @@ class Skeleton_Class extends CommonObject $sql .= $this->db->order($sortfield,$sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + $sql .= ' ' . $this->db->plimit($limit, $offset); } - $this->lines = array(); - $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); while ($obj = $this->db->fetch_object($resql)) { - $line = new Skeleton_ClassLine(); + $line = new self($this->db); $line->id = $obj->rowid; $line->prop1 = $obj->field1; $line->prop2 = $obj->field2; - - $this->lines[$line->id] = $line; //... } $this->db->free($resql); diff --git a/dev/tools/github_authors_peryear.sh b/dev/tools/github_authors_peryear.sh new file mode 100755 index 00000000000..99b28d4d417 --- /dev/null +++ b/dev/tools/github_authors_peryear.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FROM=2016-01-01 +TO=2016-12-31 + +echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" +git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l + diff --git a/dev/tools/github_commits_perversion.sh b/dev/tools/github_commits_perversion.sh new file mode 100755 index 00000000000..40ddafee617 --- /dev/null +++ b/dev/tools/github_commits_perversion.sh @@ -0,0 +1,15 @@ +#/bin/bash +Releases=("3.8" "3.9" "4.0" "5.0", "develop") +Dates=("2010-01-01", "2011-01-01", "2012-01-01", "2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01") +let "counter = 1" + +for i in "${Releases[@]}" +do + git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]} + echo -n "Total $i: " + git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l + echo "=======================" + echo + let "counter +=1" +done + diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d4b5407c912..ba2643a04b8 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -888,18 +888,18 @@ if ($id) { if ($value == 'country') { - print ''; + print ''; print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print ''; } else { - print ''; + print ''; } } } if ($id == 4) print ''; - print ''; + print ''; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 6308c2d3edc..ca6a3657774 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -235,9 +235,8 @@ print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" print "\n"; print ''; -print '
'; -print '' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . ''; -print ''; +print '' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . ''; +print ''; print ''; print $langs->trans('From') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); @@ -247,10 +246,10 @@ print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print ''; print ''; print ''; -print ' '; -print ' '; -print ''; -print ''; +print ' '; +print ' '; +print ''; +print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; print ''; diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index 376e5b00d56..e1a21d852ea 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -83,6 +83,8 @@ class FormVentilation extends Form require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; + $out = ''; + $options = array(); if ($usecache && ! empty($this->options_cache[$usecache])) { @@ -109,7 +111,7 @@ class FormVentilation extends Form return -1; } - $out = ajax_combobox($htmlname, $event); + $out .= ajax_combobox($htmlname, $event); $selected = 0; while ($obj = $this->db->fetch_object($resql)) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index ef5c512179a..dddc7c896c0 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -29,6 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; // Langs $langs->load("compta"); @@ -179,7 +180,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 1) print 'global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} +$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); @@ -222,6 +230,11 @@ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "' $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); @@ -273,6 +286,11 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; @@ -301,97 +319,105 @@ print "\n"; - - -print '
'; -print '
'; - - -print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - -print "
\n"; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? +{ + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print '
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '
'; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM(fd.total_ht) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php'); + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + $i ++; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; + + if (! empty($conf->margin->enabled)) { + print "
\n"; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; + } } -print '' . $langs->trans("Total") . ''; -$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; -for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - -dol_syslog('htdocs/accountancy/customer/index.php'); -$resql = $db->query($sql); -if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { - print '' . price($row[$i]) . ''; - } - print '' . price($row[13]) . ''; - print ''; - $i ++; - } - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print "\n"; - -if (! empty($conf->margin->enabled)) { - print "
\n"; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; - for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - - dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; -} -print "\n"; -print ''; llxFooter(); $db->close(); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 7f214ffdf3c..dbb34299104 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -210,6 +210,11 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx",$search_vat,1); } +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index b4c5da80af4..b4d7c0bbb7a 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -290,55 +290,55 @@ print "\n"; -print '
'; -print '
'; - - -print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - - -print "
\n"; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? +{ + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print '
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '
'; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " ROUND(SUM(erd.total_ht),2) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND er.fk_statut > 0 "; + $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + + dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; } -print '' . $langs->trans("Total") . ''; - -$sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; -for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " ROUND(SUM(erd.total_ht),2) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; -$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND er.fk_statut > 0 "; -$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy - -dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - while ( $row = $db->fetch_row($resql)) { - - - print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { - print '' . price($row[$i]) . ''; - } - print '' . price($row[13]) . ''; - print ''; - } - - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print "\n"; llxFooter(); $db->close(); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index ef7d470bb07..a747342a508 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -289,58 +289,56 @@ print "\n"; - -print '
'; -print '
'; - - -print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - - - - -print "
\n"; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? +{ + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print '
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '
'; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " ROUND(SUM(ffd.total_ht),2) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND ff.fk_statut > 0 "; + $sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy + + dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; } -print '' . $langs->trans("Total") . ''; -$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; -for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " ROUND(SUM(ffd.total_ht),2) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND ff.fk_statut > 0 "; -$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy - -dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - while ( $row = $db->fetch_row($resql)) { - - - print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { - print '' . price($row[$i]) . ''; - } - print '' . price($row[13]) . ''; - print ''; - } - - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print "\n"; llxFooter(); $db->close(); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index cab52dceccc..85b591f0fca 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -91,10 +91,10 @@ if ($action == 'add' && $user->rights->adherent->configurer) $object = new AdherentType($db); $object->libelle = trim($label); - $object->subscription = trim($subscription); + $object->subscription = (int) trim($subscription); $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); - $object->vote = trim($vote); + $object->mail_valid = (boolean) trim($mail_valid); + $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -129,10 +129,10 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object = new AdherentType($db); $object->id = $rowid; $object->libelle = trim($label); - $object->subscription = trim($subscription); + $object->subscription = (int) trim($subscription); $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); - $object->vote = trim($vote); + $object->mail_valid = (boolean) trim($mail_valid); + $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index b41ae78d4c7..2433575e553 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -104,6 +104,11 @@ if ($action == 'setvalue' && $user->admin) * View */ +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + $form = new Form($db); llxHeader('',$langs->trans("PrintingSetup")); @@ -127,70 +132,179 @@ if ($mode == 'setup' && $user->admin) if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1; if (! $supported) continue; // show only supported + + $OAUTH_SERVICENAME='Unknown'; + if ($key[0] == 'OAUTH_GITHUB_NAME') + { + $OAUTH_SERVICENAME='GitHub'; + $urltorenew=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms='https://github.com/settings/applications/'; + } + if ($key[0] == 'OAUTH_GOOGLE_NAME') + { + $OAUTH_SERVICENAME='Google'; + $urltorenew=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms='https://security.google.com/settings/security/permissions'; + } + + // Show value of token + $tokenobj=null; + // Token + require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; + // Dolibarr storage + $storage = new DoliStorage($db, $conf); + try + { + $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); + } + catch(Exception $e) + { + // Return an error if token not found + } + + // Set other properties + $refreshtoken=false; + $expiredat=''; + + $expire = false; + // Is token expired or will token expire in the next 30 seconds + if (is_object($tokenobj)) { + $expire = ($tokenobj->getEndOfLife() !== $tokenobj::EOL_NEVER_EXPIRES && $tokenobj->getEndOfLife() !== $tokenobj::EOL_UNKNOWN && time() > ($tokenobj->getEndOfLife() - 30)); + } + + if ($key[1] != '' && $key[2] != '') { + if (is_object($tokenobj)) { + $refreshtoken = $tokenobj->getRefreshToken(); + + $endoflife = $tokenobj->getEndOfLife(); + if ($endoflife == $tokenobj::EOL_NEVER_EXPIRES) + { + $expiredat = $langs->trans("Never"); + } + elseif ($endoflife == $tokenobj::EOL_UNKNOWN) + { + $expiredat = $langs->trans("Unknown"); + } + else + { + $expiredat=dol_print_date($endoflife, "dayhour"); + } + } + } + + $submit_enabled=0; + print ''; print ''; print ''; print ''."\n"; - $var=true; + + $var=false; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print "\n"; - $submit_enabled=0; - + print ''; - print ''.$langs->trans($key['varname']).''; - print ''; + print ''; + //var_dump($key); + print $langs->trans("OAuthIDSecret").''; + print ''; print ''; print ''."\n"; - // Show value of token - if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("IsTokenGenerated"); + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''."\n"; + //test on $storage->hasAccessToken($OAUTH_SERVICENAME) ? + print ''.$langs->trans('DeleteAccess').'

'; } + // Request remote token + print ''.$langs->trans('RequestAccess').'

'; + // Check remote access + if ($urltocheckperms) + { + print $langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME).': '.$urltocheckperms.''; + } + print ''; + print ''; + + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("Token").''; + print ''; + print ''."\n"; + + if (is_object($tokenobj)) + { + // Token refresh + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("TOKEN_REFRESH").''; + print ''; + print ''; + // Token expired + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("TOKEN_EXPIRED").''; + print ''; + print ''; + + // Token expired at + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("TOKEN_EXPIRE_AT").''; + print ''; + print ''; + } + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").' '.$langs->trans($key[0]).'
'.$langs->trans($key['info']).''; + print $langs->trans("SeePreviousTab"); + print ''; - if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') - { - // Delete remote tokens - if (! empty($key['delete'])) print ''.$langs->trans('DeleteAccess').'

'; - // Request remote token - print ''.$langs->trans('RequestAccess').'

'; - // Check remote access - print $langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME_GOOGLE).': https://security.google.com/settings/security/permissions'; - } print '
'; + if (is_object($tokenobj)) print $langs->trans("HasAccessToken"); + else print $langs->trans("NoAccessToken"); + print ''; + // Links to delete/checks token + if (is_object($tokenobj)) { - // Token - print '
'.$langs->trans("Token").''; - // Dolibarr storage - $storage = new DoliStorage($db, $conf); - try - { - $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE); - } - catch(Exception $e) - { - // Return an error if token not found - } - if (is_object($tokenobj)) - { - //var_dump($tokenobj); - print $tokenobj->getAccessToken().'
'; - //print 'Refresh: '.$tokenobj->getRefreshToken().'
'; - //print 'EndOfLife: '.$tokenobj->getEndOfLife().'
'; - //var_dump($tokenobj->getExtraParams()); - /*print '
Extra:
';*/ - } - print '
'; - print '
'; + if (is_object($tokenobj)) + { + //var_dump($tokenobj); + print $tokenobj->getAccessToken().'
'; + //print 'Refresh: '.$tokenobj->getRefreshToken().'
'; + //print 'EndOfLife: '.$tokenobj->getEndOfLife().'
'; + //var_dump($tokenobj->getExtraParams()); + /*print '
Extra:
';*/ + } + print '
'; + print yn($refreshtoken); + print '
'; + print yn($expire); + print '
'; + print $expiredat; + print '
'; if (! empty($driver)) @@ -199,7 +313,8 @@ if ($mode == 'setup' && $user->admin) print '
'; } } - + + print '
'; } diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 1340b5ae3c1..c0ff5d75819 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -82,8 +82,8 @@ $xmlremote = GETPOST('xmlremote')?GETPOST('xmlremote'):'https://www.dolibarr.org // Test if remote test is ok $enableremotecheck = True; -if (preg_match('/beta|alpha/i', DOL_VERSION)) $enableremotecheck=False; - +if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=False; +$enableremotecheck = true; print '
'; print $langs->trans("MakeIntegrityAnalysisFrom").':
'; @@ -101,7 +101,8 @@ else print ''."\n"; if ($enableremotecheck) { - print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote.'
'; + print ' '.$langs->trans("RemoteSignature").' = '; + print '
'; } else { @@ -156,19 +157,25 @@ if ($xml) $file_list = array(); $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list + print_fiche_titre($langs->trans("FilesMissing")); + print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''."\n"; $var = true; $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); if (is_array($tmpfilelist) && count($tmpfilelist)) { + $i = 0; foreach ($tmpfilelist as $file) { + $i++; $var = !$var; print ''; + print '' . "\n"; print '' . "\n"; print '' . "\n"; print "\n"; @@ -176,15 +183,18 @@ if ($xml) } else { - print ''; + print ''; } print '
' . $langs->trans("FilesMissing") . '#' . $langs->trans("Filename") . '' . $langs->trans("ExpectedChecksum") . '
'.$i.''.$file['filename'].''.$file['expectedmd5'].'
'.$langs->trans("None").'
'.$langs->trans("None").'
'; print '
'; + print_fiche_titre($langs->trans("FilesUpdated")); + print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -194,10 +204,13 @@ if ($xml) $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); if (is_array($tmpfilelist2) && count($tmpfilelist2)) { + $i = 0; foreach ($tmpfilelist2 as $file) { + $i++; $var = !$var; print ''; + print '' . "\n"; print '' . "\n"; print '' . "\n"; print '' . "\n"; @@ -241,14 +254,12 @@ if ($xml) //var_dump($checksumconcat); $checksumget = md5(join(',',$checksumconcat)); $checksumtoget = $xml->dolibarr_htdocs_dir_checksum; - if ($checksumtoget) - { - print '
'; - print ''.$langs->trans("GlobalChecksum").'
'; - print $langs->trans("ExpectedChecksum").' = '.$checksumtoget.'
'; - print $langs->trans("CurrentChecksum").' = '.$checksumget; - } - + + print '
'; + + print_fiche_titre($langs->trans("GlobalChecksum")).'
'; + print $langs->trans("ExpectedChecksum").' = '. ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")) .'
'; + print $langs->trans("CurrentChecksum").' = '.$checksumget; } diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index e306862b67a..5cebb1dac4e 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -39,7 +39,7 @@ if (GETPOST('msg','alpha')) { } -$urldolibarr='http://www.dolibarr.org/downloads/'; +$urldolibarr='https://www.dolibarr.org/downloads/'; $urldolibarrmodules='https://www.dolistore.com/'; $urldolibarrthemes='https://www.dolistore.com/'; $dolibarrroot=preg_replace('/([\\/]+)$/i','',DOL_DOCUMENT_ROOT); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 43f2953ccda..7d07f7ead94 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -105,7 +105,7 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) } if (! $error) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue) VALUE ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."')"; $result = $db->query($sql); if ($result > 0) { diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 240b32e34db..579d244246b 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -37,7 +37,7 @@ class Facturation * int $prix => Prix HT du produit en cours * int $tva => 'rowid' du taux de tva dans llx_c_tva */ - var $id; + public $id; protected $ref; protected $qte; protected $stock; diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css index e606c8d2807..2931ad7638e 100644 --- a/htdocs/cashdesk/css/style.css +++ b/htdocs/cashdesk/css/style.css @@ -115,7 +115,7 @@ li.menu_choix0 { float: right; } -/* ------------------- R�capitulatif des articles ------------------- */ +/* ------------------- Remind of products ------------------- */ .liste_articles { min-width: 215px; float: right; @@ -212,6 +212,9 @@ p.titre { max-width: 900px; } +.blocksellfinished { + min-width: 215px; +} .titre1 { font-weight: bold; color: #ff9900; diff --git a/htdocs/cashdesk/css/ticket.css b/htdocs/cashdesk/css/ticket.css new file mode 100644 index 00000000000..248e0f7b9b6 --- /dev/null +++ b/htdocs/cashdesk/css/ticket.css @@ -0,0 +1,61 @@ +/* + * TPV ticket.css + */ +body { + font-size: 1.5em; + position: relative; +} + +.entete { /* position: relative; */ + +} + +.address { /* float: left; */ + font-size: 12px; +} + +.date_heure { + position: absolute; + top: 0; + right: 0; + font-size: 16px; +} + +.infos { + position: relative; +} + +.liste_articles { + width: 100%; + border-bottom: 1px solid #000; + text-align: center; +} + +.liste_articles tr.titres th { + border-bottom: 1px solid #000; +} + +.liste_articles td.total { + text-align: right; +} + +.totaux { + margin-top: 20px; + width: 30%; + float: right; + text-align: right; +} + +.lien { + position: absolute; + top: 0; + left: 0; + display: none; +} + +@media print { + .lien { + display: none; + } +} + diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index d20eb4c3299..208727a7644 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -106,23 +106,23 @@ $langs->load("cashdesk"); - - + - - + '; - print ''; - print ''; - print ''; - print '
' . $langs->trans("FilesUpdated") . '#' . $langs->trans("Filename") . '' . $langs->trans("ExpectedChecksum") . '' . $langs->trans("CurrentChecksum") . '' . $langs->trans("Size") . '
'.$i.''.$file['filename'].''.$file['expectedmd5'].''.$file['md5'].'trans("VATRate"); ?>
+ - + + @@ -155,17 +155,17 @@ $langs->load("cashdesk");
trans("Amount"); ?> - +
- + - - +
trans("TotalTicket"); ?>trans("Received"); ?>trans("Change"); ?>
+
diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index 9ea8cb70943..78ce86f45f7 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -28,130 +28,84 @@ $object->fetch($facid); ?> - -<?php echo $langs->trans('PrintTicket') ?> - - - + + <?php echo $langs->trans('PrintTicket') ?> +
- -
-

name; ?>
-
-

+ +
+

name; ?>
+
+

-

'; -print $object->ref; -?>

-
+

'; + print $object->ref; + ?>

+

+ - - - - - + + + + + + + + '."\n"); + ?> + + + + + + + + + ?> +
trans("Code"); ?>trans("Label"); ?>trans("Qty"); ?>trans("Discount").' (%)'; ?>trans("TotalHT"); ?>trans("Code"); ?>trans("Label"); ?>trans("Qty"); ?>trans("Discount").' (%)'; ?>trans("TotalHT"); ?>
'.$tab[$i]['ref'].''.$tab[$i]['label'].''.$tab[$i]['qte'].''.$tab[$i]['remise_percent'].''.price(price2num($tab[$i]['total_ht'],'MT'),0,$langs,0,0,-1,$conf->currency).'
currency);?>
-\n"; -echo '\n"; -echo '\n"; -?> + + + + + + + + + +
'.$langs->trans("TotalHT").''.price(price2num($obj_facturation->prixTotalHt(),'MT'),'',$langs,0,-1,-1,$conf->currency)."
'.$langs->trans("TotalVAT").''.price(price2num($obj_facturation->montantTva(),'MT'),'',$langs,0,-1,-1,$conf->currency)."
'.$langs->trans("TotalTTC").''.price(price2num($obj_facturation->prixTotalTtc(),'MT'),'',$langs,0,-1,-1,$conf->currency)."
trans("TotalHT");?>prixTotalHt(),'MT'),'',$langs,0,-1,-1,$conf->currency)."\n";?>
trans("TotalVAT").''.price(price2num($obj_facturation->montantTva(),'MT'),'',$langs,0,-1,-1,$conf->currency)."\n";?>
trans("TotalTTC").''.price(price2num($obj_facturation->prixTotalTtc(),'MT'),'',$langs,0,-1,-1,$conf->currency)."\n";?>
-trans("Close"); ?> - +trans("Close"); ?> diff --git a/htdocs/cashdesk/tpl/validation2.tpl.php b/htdocs/cashdesk/tpl/validation2.tpl.php index b74f5afdd52..844522f55e0 100644 --- a/htdocs/cashdesk/tpl/validation2.tpl.php +++ b/htdocs/cashdesk/tpl/validation2.tpl.php @@ -22,9 +22,10 @@ $langs->load("bills"); ?> -

trans("SellFinished"); ?>


+
+

trans("SellFinished"); ?>


'; } - print ''; + print ''; } if ($page > 0) { @@ -3393,7 +3393,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) { $morelabel=''; - + if (preg_match('/%/',$rate)) { $rate=str_replace('%','',$rate); @@ -3596,7 +3596,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) /** * Output a dimension with best unit - * + * * @param float $dimension Dimension * @param int $unit Unit of dimension (0, -3, ...) * @param string $type 'weight', 'volume', ... @@ -3608,16 +3608,16 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no') { require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; - - if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) + + if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) { $dimension = $dimension * 1000000; - $unit = $unit - 6; + $unit = $unit - 6; } elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) { $dimension = $dimension * 1000; - $unit = $unit - 3; + $unit = $unit - 3; } elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) { @@ -3629,9 +3629,9 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round= $dimension = $dimension / 1000; $unit = $unit + 3; } - + $ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type); - + return $ret; } @@ -3662,12 +3662,12 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller $vatratecleaned = trim($reg[1]); $vatratecode = $reg[2]; } - + /*if ($thirdparty_buyer->country_code != $thirdparty_seller->country_code) { return 0; }*/ - + // Some test to guess with no need to make database access if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local taxe { @@ -3765,7 +3765,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller if ($local==1) return $obj->localtax1; elseif ($local==2) return $obj->localtax2; } - + return 0; } @@ -3825,7 +3825,7 @@ function get_localtax_by_third($local) /** * Get vat rate and npr from id. - * You can call getLocalTaxesFromRate after to get other fields + * You can call getLocalTaxesFromRate after to get other fields * * @param int $vatrowid Line ID into vat rate table. * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) @@ -3879,7 +3879,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi $vatratecleaned = $reg[1]; $vatratecode = $reg[2]; } - + // Search local taxes $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; @@ -3892,7 +3892,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; } - + $resql=$db->query($sql); if ($resql) { @@ -4299,7 +4299,7 @@ function yn($yesno, $case=1, $color=0) /** * Return a path to have a directory according to object. * New usage: $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'modulepart') - * Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/" + * Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/" * * @param string $num Id of object (deprecated, $object will be used in future) * @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future) @@ -4316,7 +4316,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) $path = ''; $arrayforoldpath=array('cheque','user','category','holiday','shipment','supplier_invoice','invoice_supplier','mailing'); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product'; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product'; if (! empty($level) && in_array($modulepart, $arrayforoldpath)) { // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided @@ -4469,7 +4469,7 @@ function dolGetFirstLineOfText($text) { $firstline=preg_replace('/]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters $firstline=preg_replace('/]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters - + } else { @@ -5375,7 +5375,7 @@ function picto_from_langcode($codelang) } /** - * Complete or removed entries into a head array (used to build tabs). + * Complete or removed entries into a head array (used to build tabs). * For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab']. * Or by change using hook completeTabsHead * @@ -5405,7 +5405,7 @@ function picto_from_langcode($codelang) function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add') { global $hookmanager; - + if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type])) { foreach ($conf->modules_parts['tabs'][$type] as $value) @@ -5471,7 +5471,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= } } } - + // No need to make a return $head. Var is modified as a reference if (! empty($hookmanager)) { @@ -5509,11 +5509,11 @@ function printCommonFooter($zone='private') { print ''."\n"; print ''."\n"; } - + // Google Analytics (need Google module) if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID)) { @@ -5677,7 +5677,7 @@ function dol_getmypid() * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" * If param $mode is 2, can contains a list of id separated by comma like "1,3,4" * @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4') - * @param integer $nofirstand 1=Do now output the first 'AND' + * @param integer $nofirstand 1=Do not output the first 'AND' * @return string $res The statement to append to the SQL query */ function natural_search($fields, $value, $mode=0, $nofirstand=0) @@ -5692,6 +5692,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } + + $value = preg_replace('/\s*\|\s*/','|', $value); + $crits = explode(' ', $value); $res = ''; if (! is_array($fields)) $fields = array($fields); @@ -5746,15 +5749,15 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) $tmpcrit=trim($tmpcrit); $tmpcrit2=$tmpcrit; $tmpbefore='%'; $tmpafter='%'; - if (preg_match('/^[\^\$]/', $tmpcrit)) - { + if (preg_match('/^[\^\$]/', $tmpcrit)) + { $tmpbefore=''; - $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2); + $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2); } - if (preg_match('/[\^\$]$/', $tmpcrit)) - { + if (preg_match('/[\^\$]$/', $tmpcrit)) + { $tmpafter=''; - $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2); + $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2); } $newres .= $tmpbefore; $newres .= $db->escape($tmpcrit2); @@ -5819,7 +5822,7 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') function getAdvancedPreviewUrl($modulepart, $relativepath) { global $conf; - + if (empty($conf->use_javascript_ajax)) return ''; $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css'); diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 9cf745a0da0..00153a7849d 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -37,8 +37,10 @@ $quality = 80; */ function image_format_supported($file) { + $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into product.class.php + // Case filename is not a format image - if (! preg_match('/(\.gif|\.jpg|\.jpeg|\.png|\.bmp)$/i',$file,$reg)) return -1; + if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1; // Case filename is a format image but not supported by this PHP $imgfonction=''; @@ -47,6 +49,8 @@ function image_format_supported($file) if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg'; if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; + if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; + if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; if ($imgfonction) { if (! function_exists($imgfonction)) diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index 6f47ef6e62b..0149b581fa2 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -26,9 +26,13 @@ // Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) $supportedoauth2array=array( 'OAUTH_GOOGLE_NAME'=>'google', - 'OAUTH_GITHUB_NAME'=>'github' ); +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +{ + $supportedoauth2array['OAUTH_GITHUB_NAME']='github'; +} +$supportedoauth2array['OAUTH_GITHUB_NAME']='github'; // API access parameters OAUTH $list = array ( array( @@ -264,7 +268,7 @@ function oauthadmin_prepare_head() $h++; $head[$h][0] = dol_buildpath('/admin/oauthlogintokens.php', 1); - $head[$h][1] = $langs->trans("ManualTokenGeneration"); + $head[$h][1] = $langs->trans("TokenManager"); $head[$h][2] = 'tokengeneration'; $h++; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 082089b429f..107111a8986 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1248,11 +1248,15 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl { if ($issupplierline) { - //$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref - if (! empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) $ref_prodserv =$ref_supplier; - else $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref + if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) + $ref_prodserv = $ref_supplier; + elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) + $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; + else + $ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')'; } - else $ref_prodserv = $prodser->ref; // Show local ref only + else + $ref_prodserv = $prodser->ref; // Show local ref only if (! empty($libelleproduitservice)) $ref_prodserv .= " - "; } diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index fa05e632983..f58aa180d88 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -110,12 +110,9 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat if ($exportlink) print '
'.$langs->trans("Export").''.$exportlink; print '
'; + print '
'; print '
'; dol_fiche_end(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a88e180b16a..8c6c7311f82 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -111,13 +111,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $chaine=""; if (! empty($conf->product->enabled)) { - $chaine.=$langs->trans("Products"); + $chaine.=$langs->trans("TMenuProducts"); } if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) { - $chaine.="/"; + $chaine.=" | "; } if (! empty($conf->service->enabled)) { - $chaine.=$langs->trans("Services"); + $chaine.=$langs->trans("TMenuServices"); } if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); @@ -261,7 +261,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $idsel='tools'; if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Tools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_text_menu_entry($langs->trans("TMenuTools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); if (empty($noout)) print_end_menu_entry($showmode); $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", ''); } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index b1c674ef5ca..a3ff1af0726 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -110,8 +110,8 @@ class pdf_einstein extends ModelePDFCommandes { $this->posxtva=99; $this->posxup=114; - $this->posxqty=133; - $this->posxunit=150; + $this->posxqty=130; + $this->posxunit=147; } else { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index cd864e0d766..6b9b2bf5dd0 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -119,8 +119,8 @@ class pdf_crabe extends ModelePDFFactures { $this->posxtva=99; $this->posxup=114; - $this->posxqty=133; - $this->posxunit=150; + $this->posxqty=130; + $this->posxunit=147; } else { diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 0e3dedb0109..e9c7fb309ad 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -50,8 +50,8 @@ class modAccounting extends DolibarrModules $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Advanced accounting management"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); $this->special = 0; diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index a0c2a6e9de4..2ba37ad3cbd 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -189,7 +189,7 @@ class modAgenda extends DolibarrModules // $r++; $this->menu[$r]=array('fk_menu'=>0, 'type'=>'top', - 'titre'=>'Agenda', + 'titre'=>'TMenuAgenda', 'mainmenu'=>'agenda', 'url'=>'/comm/action/index.php', 'langs'=>'agenda', diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index ab4e7a0095f..9563e11aaa2 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -135,10 +135,13 @@ class modDeplacement extends DolibarrModules $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement',1).')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; - $childids = $user->getAllChildIds(); - $childids[]=$user->id; - - if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; + if (! empty($user)) // Not defined during migration process + { + $childids = $user->getAllChildIds(); + $childids[]=$user->id; + + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; + } } diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 43e49ce55d3..7eb58e32a3a 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -62,7 +62,7 @@ class modMultiCurrency extends DolibarrModules $this->description = "Module to enter elements with a foreign currency"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version - $this->version = 'experimental'; + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b217d452a86..af4da616ce9 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -281,7 +281,14 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) { + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; + } // Export list of contacts and attributes $r++; @@ -311,7 +318,14 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) { + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; + } // Imports diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php new file mode 100644 index 00000000000..83c3da66a47 --- /dev/null +++ b/htdocs/core/modules/oauth/github_oauthcallback.php @@ -0,0 +1,171 @@ + + * + * 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/core/modules/oauth/github_oauthcallback.php + * \ingroup oauth + * \brief Page to get oauth callback + */ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; +use OAuth\Common\Storage\DoliStorage; +use OAuth\Common\Consumer\Credentials; +use OAuth\OAuth2\Service\GitHub; + +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + + +$action = GETPOST('action', 'alpha'); +$backtourl = GETPOST('backtourl', 'alpha'); + + +/** + * Create a new instance of the URI class with the current URI, stripping the query string + */ +$uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); +//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); +//$currentUri->setQuery(''); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/github_oauthcallback.php'); + + +/** + * Load the credential for the service + */ + +/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */ +$serviceFactory = new \OAuth\ServiceFactory(); +$httpClient = new \OAuth\Common\Http\Client\CurlClient(); +// TODO Set options for proxy and timeout +// $params=array('CURLXXX'=>value, ...) +//$httpClient->setCurlParameters($params); +$serviceFactory->setHttpClient($httpClient); + +// Dolibarr storage +$storage = new DoliStorage($db, $conf); + +// Setup the credentials for the requests +$credentials = new Credentials( + $conf->global->OAUTH_GITHUB_ID, + $conf->global->OAUTH_GITHUB_SECRET, + $currentUri->getAbsoluteUri() +); + +$requestedpermissionsarray=array(); +if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back +if ($action != 'delete' && empty($requestedpermissionsarray)) +{ + print 'Error, parameter state is not defined'; + exit; +} +//var_dump($requestedpermissionsarray);exit; + +// Instantiate the Api service using the credentials, http client and storage mechanism for the token +/** @var $apiService Service */ +$apiService = $serviceFactory->createService('GitHub', $credentials, $storage, $requestedpermissionsarray); + +// access type needed to have oauth provider refreshing token +//$apiService->setAccessType('offline'); + +$langs->load("oauth"); + + +/* + * Actions + */ + + +if ($action == 'delete') +{ + $storage->clearToken('GitHub'); + + setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); + + header('Location: ' . $backtourl); + exit(); +} + +if (! empty($_GET['code'])) // We are coming from oauth provider page +{ + //llxHeader('',$langs->trans("OAuthSetup")); + + //$linkback=''.$langs->trans("BackToModuleList").''; + //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup'); + + //dol_fiche_head(); + // retrieve the CSRF state parameter + $state = isset($_GET['state']) ? $_GET['state'] : null; + //print ''; + + // This was a callback request from service, get the token + try { + //var_dump($_GET['code']); + //var_dump($state); + //var_dump($apiService); // OAuth\OAuth2\Service\GitHub + + //$token = $apiService->requestAccessToken($_GET['code'], $state); + $token = $apiService->requestAccessToken($_GET['code']); + // Github is a service that does not need state yo be stored. + // Into constructor of GitHub, the call + // parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri) + // has not the ending parameter to true like the Google class constructor. + + setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token + } catch (Exception $e) { + print $e->getMessage(); + } + + $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; + unset($_SESSION["backtourlsavedbeforeoauthjump"]); + + header('Location: ' . $backtourl); + exit(); +} +else // If entry on page with no parameter, we arrive here +{ + $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; + + // This may create record into oauth_state before the header redirect. + // Creation of record with state in this tables depend on the Provider used (see its constructor). + if (GETPOST('state')) + { + $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); + } + else + { + $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated + } + + // we go on oauth provider authorization page + header('Location: ' . $url); + exit(); +} + + +/* + * View + */ + +// No view at all, just actions + +$db->close(); + diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 3068a29098c..c69493ed9a5 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/modules/oauth/getoauthcallback.php + * \file htdocs/core/modules/oauth/google_oauthcallback.php * \ingroup oauth * \brief Page to get oauth callback */ @@ -83,7 +83,7 @@ if ($action != 'delete' && empty($requestedpermissionsarray)) /** @var $apiService Service */ $apiService = $serviceFactory->createService('Google', $credentials, $storage, $requestedpermissionsarray); -// access type needed for google refresh token +// access type needed to have oauth provider refreshing token $apiService->setAccessType('offline'); $langs->load("oauth"); @@ -104,7 +104,7 @@ if ($action == 'delete') exit(); } -if (! empty($_GET['code'])) // We are coming from Google oauth page +if (! empty($_GET['code'])) // We are coming from oauth provider page { //llxHeader('',$langs->trans("OAuthSetup")); @@ -121,6 +121,7 @@ if (! empty($_GET['code'])) // We are coming from Google oauth page //var_dump($_GET['code']); //var_dump($state); //var_dump($apiService); // OAuth\OAuth2\Service\Google + $token = $apiService->requestAccessToken($_GET['code'], $state); setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token @@ -138,6 +139,8 @@ else // If entry on page with no parameter, we arrive here { $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; + // This may create record into oauth_state before the header redirect. + // Creation of record with state in this tables depend on the Provider used (see its constructor). if (GETPOST('state')) { $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); @@ -146,7 +149,8 @@ else // If entry on page with no parameter, we arrive here { $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated } - // we go on google authorization page + + // we go on oauth provider authorization page header('Location: ' . $url); exit(); } diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 3d086466c87..baa5106ae93 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -66,6 +66,7 @@ class printing_printgcp extends PrintingDriver $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + $this->db = $db; if (!$conf->oauth->enabled) { @@ -117,10 +118,28 @@ class printing_printgcp extends PrintingDriver $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); if ($token_ok) { + $expiredat=''; + $refreshtoken = $token->getRefreshToken(); + + $endoflife=$token->getEndOfLife(); + + if ($endoflife == $token::EOL_NEVER_EXPIRES) + { + $expiredat = $langs->trans("Never"); + } + elseif ($endoflife == $token::EOL_UNKNOWN) + { + $expiredat = $langs->trans("Unknown"); + } + else + { + $expiredat=dol_print_date($endoflife, "dayhour"); + } + $this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info'); - $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info'); + $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info'); } /* if ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index c5b546bd72f..fc2e7a0e5d6 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -108,8 +108,8 @@ class pdf_azur extends ModelePDFPropales { $this->posxtva=99; $this->posxup=114; - $this->posxqty=133; - $this->posxunit=150; + $this->posxqty=130; + $this->posxunit=147; } else { diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 01d5da92d50..dd29a839a48 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -102,8 +102,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if($conf->global->PRODUCT_USE_UNITS) { $this->posxtva=99; $this->posxup=114; - $this->posxqty=133; - $this->posxunit=150; + $this->posxqty=130; + $this->posxunit=147; } //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 9a5132a8bea..d6d904ecb35 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -111,8 +111,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders { $this->posxtva=99; $this->posxup=114; - $this->posxqty=133; - $this->posxunit=150; + $this->posxqty=130; + $this->posxunit=147; } else { $this->posxtva=112; $this->posxup=126; diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 778c37f686a..8fcd0d2b930 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -134,11 +134,50 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS { $fullpath=$dir."/".$original_file; $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); - + if ($result == $fullpath) { $object->addThumbs($fullpath); + // Update/create database for file $fullpath + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); + $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($db); + $result = $ecmfile->fetch(0, '', $rel_filename); + if ($result > 0) // If found + { + $filename = basename($rel_filename); + $rel_dir = dirname($rel_filename); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + $ecmfile->label = md5_file(dol_osencode($fullpath)); + $result = $ecmfile->update($user); + } + elseif ($result == 0) // If not found + { + $filename = basename($rel_filename); + $rel_dir = dirname($rel_filename); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file + $ecmfile->fullpath_orig = $fullpath; + $ecmfile->gen_or_uploaded = 'unknown'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->create($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + $result = $ecmfile->create($user); + } + if ($backtourl) { header("Location: ".$backtourl); @@ -168,6 +207,45 @@ if ($action == 'confirm_crop') { $object->addThumbs($fullpath); + // Update/create database for file $fullpath + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); + $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($db); + $result = $ecmfile->fetch(0, '', $rel_filename); + if ($result > 0) // If found + { + $filename = basename($rel_filename); + $rel_dir = dirname($rel_filename); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + $ecmfile->label = md5_file(dol_osencode($fullpath)); + $result = $ecmfile->update($user); + } + elseif ($result == 0) // If not found + { + $filename = basename($rel_filename); + $rel_dir = dirname($rel_filename); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file + $ecmfile->fullpath_orig = $fullpath; + $ecmfile->gen_or_uploaded = 'unknown'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->create($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + $result = $ecmfile->create($user); + } + if ($backtourl) { header("Location: ".$backtourl); @@ -218,10 +296,11 @@ print ''.$langs->trans("Resize").''; print $langs->trans("ResizeDesc").'
'; print $langs->trans("NewLength").': px   '.$langs->trans("or").'   '; print $langs->trans("NewHeight").': px  
'; + print ''; print ''; print ''; -print ''; +print ''; print ''; print '
'; print ''; diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 123fcef662c..d0a7b45efea 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -17,18 +17,19 @@ * * Javascript code to activate drag and drop on lines * You can use this if you want to be abale to drag and drop rows of a table. - * You must add id="tablelines" on table level tag and have count($object->lines) or count($taskarray) > 0 + * You must add id="tablelines" on table level tag and have ($nboflines or count($object->lines) or count($taskarray) > 0) */ ?> - +id; $fk_element=$object->fk_element; -$table_element_line=$object->table_element_line; -$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):0)); +$table_element_line=(empty($table_element_line)?$object->table_element_line:$table_element_line); +$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines))); $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); +$filepath=(empty($filepath)?'':$filepath); if (GETPOST('action') != 'editline' && $nboflines > 1) { ?>