/** * Overloading the doActions function : replacing the parent's function with the one below * * @param array() $parameters Hook metadatas (context, etc...) * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) * @param string &$action Current action (if set). Generally create or edit or null * @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @return int < 0 on error, 0 on success, 1 to replace standard code */ function formObjectOptions($parameters, &$object, &$action, $hookmanager) { if (empty($object->element)) { return 0; } if (defined('TWIIITOR_ADDED')) { return 0; } define('TWIIITOR_ADDED', true); define('INC_FROM_DOLIBARR', true); dol_include_once('/twiiitor/config.php'); dol_include_once('/twiiitor/class/twiiitor.class.php'); $ref = TTwiiit::getRefByObject($object); if (empty($ref)) { return 0; } ?> <script type="text/javascript" src="<?php echo dol_buildpath('/twiiitor/js/twiiitor.js.php?element=' . $object->element . '&id=' . $object->id . '&ref=' . $ref, 1); ?> "></script> <?php }
static function getRef($fk_object, $type_object) { global $db; $object_name = ucfirst($type_object); if (class_exists($object_name)) { $object = new $object_name($db); if ($object->fetch($fk_object) > 0) { return TTwiiit::getRefByObject($object); } } return ''; }