From 0017c159742dfdae473886e0c1064e866bdbf1d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Oct 2021 17:19:46 +0200 Subject: [PATCH] Debug v15 --- htdocs/comm/propal/card.php | 8 +- htdocs/core/bookmarks_page.php | 65 +++++---- htdocs/core/class/html.form.class.php | 3 +- htdocs/core/multicompany_page.php | 147 +++++++++++++++++++++ htdocs/langs/en_US/bookmarks.lang | 1 + htdocs/langs/en_US/propal.lang | 6 +- htdocs/projet/class/project.class.php | 4 +- htdocs/public/onlinesign/newonlinesign.php | 27 +++- htdocs/public/stripe/ipn.php | 25 +++- 9 files changed, 235 insertions(+), 51 deletions(-) create mode 100644 htdocs/core/multicompany_page.php diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c301e054e96..c046281f18e 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2014,15 +2014,15 @@ if ($action == 'create') { $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; } // Project if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if (!$usercancreate) { + $morehtmlref .= '
'.$langs->trans('Project').''; + if ($usercancreate) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } @@ -2041,7 +2041,7 @@ if ($action == 'create') { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ' : '.$proj->getNomUrl(1); + $morehtmlref .= ': '.$proj->getNomUrl(1); if ($proj->title) { $morehtmlref .= ' - '.$proj->title; } diff --git a/htdocs/core/bookmarks_page.php b/htdocs/core/bookmarks_page.php index af2ba15829c..46c4b38988e 100644 --- a/htdocs/core/bookmarks_page.php +++ b/htdocs/core/bookmarks_page.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/bookmarks_page.php - * \brief File to return a page with the complete list of bookmarks (all search input fields) + * \brief File to return a page with the complete list of bookmarks */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language @@ -45,7 +45,7 @@ if (GETPOST('lang', 'aZ09')) { $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php } -$langs->load("main"); +$langs->loadLangs(array("bookmarks")); $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); @@ -57,7 +57,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Bookmarks"); -// URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests +// URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests $head = ''."\n"; $arrayofjs = array(); $arrayofcss = array(); @@ -69,8 +69,6 @@ print ''."\n"; print '
'; //print '
'; -$nbofsearch = 0; - // Instantiate hooks of thirdparty module $hookmanager->initHooks(array('bookmarks')); @@ -78,32 +76,43 @@ $hookmanager->initHooks(array('bookmarks')); $bookmarkList = ''; $searchForm = ''; -$arrayresult = array(); -//include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; - - -// Menu with list of bookmarks -$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; -$sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; -$sql .= " AND entity IN (".getEntity('bookmarks').")"; -$sql .= " ORDER BY position"; -if ($resql = $db->query($sql)) { - $bookmarkList = ''; - - $searchForm .= ''; +if (empty($conf->bookmarks->enabled)) { + $langs->load("admin"); + $bookmarkList .= '
'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Bookmarks")).''; + $bookmarkList .= '

'; } else { - dol_print_error($db); -} + // Menu with list of bookmarks + $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; + $sql .= " AND entity IN (".getEntity('bookmarks').")"; + $sql .= " ORDER BY position"; + if ($resql = $db->query($sql)) { + $bookmarkList = ''; + + + $searchForm .= ''; + } else { + dol_print_error($db); + } +} // Execute hook printBookmarks $parameters = array('bookmarks'=>$bookmarkList); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 98ba6ca3cc2..56f7c41994b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5088,8 +5088,7 @@ class Form if ($selected) { $projet = new Project($this->db); $projet->fetch($selected); - //print ''.$projet->title.''; - $out .= $projet->getNomUrl(0, '', 1); + $out .= $projet->getNomUrl(1, '', 1); } else { $out .= " "; } diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php new file mode 100644 index 00000000000..239e5c46392 --- /dev/null +++ b/htdocs/core/multicompany_page.php @@ -0,0 +1,147 @@ + + * + * This file is a modified version of datepicker.php from phpBSM to fix some + * bugs, to add new features and to dramatically increase speed. + * + * 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/multicompany_page.php + * \brief File to return a page with the list of all entities user can switch to + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); + +require_once '../main.inc.php'; + +$action = GETPOST('action', 'aZ09'); +$entityid = GETPOST('entity', 'int'); +$backtourl = GETPOST('backtourl'); +if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT; +} + +if (GETPOST('lang', 'aZ09')) { + $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php +} + +$langs->load("main"); + +$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); +$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); + + + +/* + * Actions + */ + +if (GETPOST('acction', 'aZ') == 'switchentity') { + if (is_object($mc)) { + $mc->switchEntity($entityid); + } + + header("Location: ".$backtourl); + exit(0); +} + + + +/* + * View + */ + +$title = $langs->trans("Multicompanies"); + +// URL http://mydolibarr/core/multicompany_page?dol_use_jmobile=1 can be used for tests +$head = ''."\n"; +$arrayofjs = array(); +$arrayofcss = array(); +top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); + + +print ''."\n"; +print '
'; +//print '
'; + + +if (empty($conf->multicompany->enabled)) { + $langs->load("admin"); + $bookmarkList .= '
'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("MultiCompany")).''; + $bookmarkList .= '

'; +} else { + // Instantiate hooks of thirdparty module + $hookmanager->initHooks(array('multicompany')); + + // Define $bookmarks + $multicompanyList = ''; + $searchForm = ''; + + + if (is_object($mc)) { + $listofentities = $mc->getEntitiesList($user->login, false, true); + } + + foreach ($listofentities as $entityid => $entitycursor) { + $url = DOL_URL_ROOT.'/core/multicompany_page.php?action=switchentity&token='.newToken().'&entity='.((int) $entityid).($backtourl ? '&backtourl='.urlencode($backtourl) : ''); + $multicompanyList .= ''; + $multicompanyList .= dol_escape_htmltag($entitycursor); + $multicompanyList .= ''; + } + $multicompanyList .= '
'; + + $searchForm .= ''; + + + // Execute hook printBookmarks + $parameters = array('multicompany'=>$multicompanyList); + $reshook = $hookmanager->executeHooks('printMultiCompanyEntities', $parameters); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) { + $multicompanyList .= $hookmanager->resPrint; + } else { + $multicompanyList = $hookmanager->resPrint; + } + + + print "\n"; + print "\n"; + print '
'; + print ''; + print '
'."\n"; + print $multicompanyList; + print '
'."\n"; + print '
'; + print "\n\n"; +} + +print '
'; +print ''."\n"; + +$db->close(); diff --git a/htdocs/langs/en_US/bookmarks.lang b/htdocs/langs/en_US/bookmarks.lang index 87466cadcfa..d2378963a21 100644 --- a/htdocs/langs/en_US/bookmarks.lang +++ b/htdocs/langs/en_US/bookmarks.lang @@ -19,3 +19,4 @@ UseAnExternalHttpLinkOrRelativeDolibarrLink=Use an external/absolute link (https ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choose if the linked page should open in the current tab or a new tab BookmarksManagement=Bookmarks management BookmarksMenuShortCut=Ctrl + shift + m +NoBookmarks=No bookmarks defined diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 7141c1d38ae..ed07831fcba 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -89,11 +89,11 @@ IdProposal=Proposal ID IdProduct=Product ID PrParentLine=Proposal Parent Line LineBuyPriceHT=Buy Price Amount net of tax for line -SignPropal=Sign proposal +SignPropal=Accept proposal RefusePropal=Refuse proposal Sign=Sign +PropalAlreadySigned=Proposal already accepted PropalAlreadyRefused=Proposal already refused -PropalAlreadySigned=Proposal already signed -PropalSigned=Proposal signed +PropalSigned=Proposal accepted PropalRefused=Proposal refused ConfirmRefusePropal=Are you sure you want to refuse this commercial proposal? diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index aa823dc44d6..6d8b54d1954 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1183,7 +1183,7 @@ class Project extends CommonObject $label = ''; if ($option != 'nolink') { - $label = img_picto('', $this->picto).' '.$langs->trans("Project").''; + $label = img_picto('', $this->picto, 'class="pictofixedwidth"').' '.$langs->trans("Project").''; } if (isset($this->status)) { $label .= ' '.$this->getLibStatut(5); @@ -1252,7 +1252,7 @@ class Project extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 65b12a91342..66b4af425e7 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -61,6 +61,7 @@ $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $refusepropal = GETPOST('refusepropal', 'alpha'); +$message = GETPOST('message', 'aZ09'); // Input are: // type ('invoice','order','contractline'), @@ -120,25 +121,33 @@ $creditor = $mysoc->name; $object = new Propal($db); $object->fetch(0, $ref); + /* * Actions */ if ($action == 'confirm_refusepropal') { + $db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql .= " SET fk_statut = ".((int) $object::STATUS_NOTSIGNED).", note_private = '".$object->note_private."', date_signature='".$db->idate(dol_now())."'"; + $sql .= " SET fk_statut = ".((int) $object::STATUS_NOTSIGNED).", note_private = '".$db->escape($object->note_private)."', date_signature='".$db->idate(dol_now())."'"; $sql .= " WHERE rowid = ".((int) $object->id); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { $error++; } + if (!$error) { $db->commit(); - setEventMessage("PropalRefused"); + + $message = 'refused'; + setEventMessages("PropalRefused", null, 'warning'); } else { $db->rollback(); } + $object->fetch(0, $ref); } @@ -367,7 +376,7 @@ if ($action == "dosign" && empty($cancel)) { success: function(response) { if(response == "success"){ console.log("Success on saving signature"); - window.location.replace("'.$_SERVER["SELF"].'?ref='.$ref.'"); + window.location.replace("'.$_SERVER["SELF"].'?ref='.$ref.'&message=signed"); }else{ console.error(response); } @@ -390,10 +399,18 @@ if ($action == "dosign" && empty($cancel)) { } else { if ($object->status == $object::STATUS_SIGNED) { print '
'; - print ''.$langs->trans("PropalAlreadySigned").''; + if ($message == 'signed') { + print ''.$langs->trans("PropalSigned").''; + } else { + print ''.$langs->trans("PropalAlreadySigned").''; + } } elseif ($object->status == $object::STATUS_NOTSIGNED) { print '
'; - print ''.$langs->trans("PropalAlreadyRefused").''; + if ($message == 'refused') { + print ''.$langs->trans("PropalRefused").''; + } else { + print ''.$langs->trans("PropalAlreadyRefused").''; + } } else { print ''; print ''; diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index f44bc0b1c99..6674ce9c6de 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -83,6 +83,21 @@ if (empty($endpoint_secret)) { exit(); } +if (!empty($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS)) { + // We set the user to use for all ipn actions in Dolibarr + $user = new User($db); + $user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); + $user->getrights(); +} else { + print 'Error: Setup of module Stripe not complete for mode '.$service.'. The STRIPE_USER_ACCOUNT_FOR_ACTIONS is not defined.'; + http_response_code(400); // PHP 5.4 or greater + exit(); +} + + +// TODO Add a check on a security key + + /* * Actions @@ -110,10 +125,6 @@ try { $langs->load("main"); -// TODO Do we really need a user in setup just to have a name to fill an email topic when it is a technical system notification email -$user = new User($db); -$user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); -$user->getrights(); if (!empty($conf->multicompany->enabled) && !empty($conf->stripeconnect->enabled) && is_object($mc)) { $sql = "SELECT entity"; @@ -276,11 +287,11 @@ if ($event->type == 'payout.created') { $ret = $mailfile->sendfile(); - http_response_code(200); // PHP 5.4 or greater + http_response_code(200); return 1; } else { $error++; - http_response_code(500); // PHP 5.4 or greater + http_response_code(500); return -1; } } elseif ($event->type == 'customer.source.created') { @@ -385,4 +396,4 @@ if ($event->type == 'payout.created') { // This event is deprecated. } -http_response_code(200); // PHP 5.4 or greater +http_response_code(200);