X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fhooks.inc;h=d2096c17004362352f2c95020d1fad6f45955396;hb=9988555dbed61bdf6a11a19eb6a4ec52dc0d586c;hp=71717fc154202a4071612a4060bb428b3f371e6b;hpb=a5dcd87f46080a624b1a9ad4b0dd035bbd24ac50;p=fa-stable.git diff --git a/includes/hooks.inc b/includes/hooks.inc index 71717fc1..d2096c17 100644 --- a/includes/hooks.inc +++ b/includes/hooks.inc @@ -116,6 +116,7 @@ class hooks { function price_in_words($amount, $doc_type) { } + // // Exchange rate currency $curr as on date $date. // Keep in mind FA has internally implemented 3 exrate providers @@ -202,9 +203,9 @@ class hooks { * more than one in the cart. */ /* Default behavior check if there is enough quantity on hand and change the css - * class if needed */ + * class if needed */ static function default_get_dispatchable_quantity($line_item, $location, $date, $qoh) { - global $SysPrefs; + global $SysPrefs; if ($SysPrefs->allow_negative_stock() || ($line_item->qty_dispatched <= $qoh)) { return true; @@ -236,20 +237,20 @@ function install_hooks() } // install hooks provided by active extensions foreach($installed_extensions as $ext) { - $hook_class = 'hooks_'.$ext['package']; - if ($ext['active'] && class_exists($hook_class)) { - $Hooks[$ext['package']] = new $hook_class; - } + $hook_class = 'hooks_'.$ext['package']; + if ($ext['active'] && class_exists($hook_class)) { + $Hooks[$ext['package']] = new $hook_class; + } } } /* Non active hooks are not included in $Hooks array, so we can use special function to activate. */ -function activate_hooks($ext, $comp) +function activate_hooks($ext, $comp, $on=true) { global $Hooks; - + $hooks = @$Hooks[$ext]; if (!$hooks) { $hookclass = 'hooks_'.$ext; @@ -260,8 +261,10 @@ function activate_hooks($ext, $comp) } if (!$hooks) return false; - else + elseif ($on) return $hooks->activate_extension($comp, false); + else + return $hooks->deactivate_extension($comp, false); } /* Calls hook $method defined in extension $ext (if any) @@ -312,7 +315,7 @@ function hook_invoke_first($method, &$data, $opts=null) { global $Hooks; - + $result = null; foreach($Hooks as $ext => $hook) { if (method_exists($hook, $method)) {