/** * 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 doActions($parameters, &$object, &$action, $hookmanager) { //var_dump($parameters, $action); if (!empty($parameters['currentcontext'])) { $currentcontext = $parameters['currentcontext']; } else { $currentcontext = $parameters['context']; } // Retrocompatibility <= 3.6 $routeAction = $currentcontext . ':' . $action; define('INC_FROM_DOLIBARR', true); dol_include_once('/routing/config.php'); TRouting::route($routeAction, $object); }
static function route($action, &$object) { $PDOdb = new TPDOdb(); $sql = "SELECT rowid\n FROM " . MAIN_DB_PREFIX . "routing\n WHERE trigger_code='" . $action . "'"; $Tab = $PDOdb->ExecuteAsArray($sql); foreach ($Tab as $row) { $route = new TRouting(); $route->load($PDOdb, $row->rowid); $route->routeLines($object); } // mvt inverse pour annulation $sql = "SELECT rowid\n FROM " . MAIN_DB_PREFIX . "routing\n WHERE trigger_code_reverse='" . $action . "'"; $Tab = $PDOdb->ExecuteAsArray($sql); foreach ($Tab as $row) { $route = new TRouting(); $route->load($PDOdb, $row->rowid); $route->routeLines($object, -1); } }
<?php /* * Script créant et vérifiant que les champs requis s'ajoutent bien */ if (!defined('INC_FROM_DOLIBARR')) { define('INC_FROM_CRON_SCRIPT', true); require '../config.php'; } $PDOdb = new TPDOdb(); $o = new TRouting($db); $o->init_db_by_vars($PDOdb);
/** * Function called when a Dolibarrr business event is done. * All functions "run_trigger" are triggered if file * is inside directory core/triggers * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ public function run_trigger($action, $object, $user, $langs, $conf) { define('INC_FROM_DOLIBARR', true); dol_include_once('/routing/config.php'); if (class_exists('TRouting')) { TRouting::route($action, $object); } return 0; }
$r->set_values($rem); $r->check_old = !empty($rem['check_old']) ? 1 : 0; $r->fk_societe = GETPOST('TRouting_' . $r->getId() . '_fk_soc'); $r->fk_user = GETPOST('TRouting_' . $r->getId() . '_fk_user'); $r->save($PDOdb); } setEventMessage('Saved'); } } else { if ($action == 'delete') { $r = new TRouting(); $r->load($PDOdb, GETPOST('id')); $r->delete($PDOdb); } else { if ($action == 'add') { $r = new TRouting(); $r->save($PDOdb); } } } /* * View */ $page_name = "RoutingSetup"; llxHeader('', $langs->trans($page_name)); // Subheader $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>'; print_fiche_titre($langs->trans($page_name), $linkback); // Configuration header $head = routingAdminPrepareHead(); dol_fiche_head($head, 'settings', $langs->trans("Module104760Name"), 0, "rememberme@rememberme");