Merge pull request #20766 from altairis-melina/hookinvoice

NEW add hook doaction in takepos invoice
This commit is contained in:
Laurent Destailleur 2022-05-03 23:59:08 +02:00 committed by GitHub
commit 0ccd0931ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,6 +49,8 @@ if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager->initHooks(array('takeposinvoice'));
global $mysoc; global $mysoc;
@ -168,11 +170,6 @@ if ($invoice->socid > 0) {
$soc->fetch(getDolGlobalString("$constforcompanyid")); $soc->fetch(getDolGlobalString("$constforcompanyid"));
} }
/*
* Actions
*/
// Change the currency of invoice if it was modified // Change the currency of invoice if it was modified
if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercurrency"])) { if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercurrency"])) {
if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) { if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) {
@ -180,7 +177,15 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu
} }
} }
/*
* Actions
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
// Action to record a payment on a TakePOS invoice // Action to record a payment on a TakePOS invoice
if ($action == 'valid' && $user->rights->facture->creer) { if ($action == 'valid' && $user->rights->facture->creer) {
$bankaccount = 0; $bankaccount = 0;
@ -902,7 +907,7 @@ if ($action == "valid" || $action == "history" || $action == 'creditnote') {
$sectionwithinvoicelink .= '<script type="text/javascript">$("#buttonprint").click();</script>'; $sectionwithinvoicelink .= '<script type="text/javascript">$("#buttonprint").click();</script>';
} }
} }
}
/* /*
* View * View