本文整理汇总了PHP中Commande::callHooks方法的典型用法代码示例。如果您正苦于以下问题:PHP Commande::callHooks方法的具体用法?PHP Commande::callHooks怎么用?PHP Commande::callHooks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commande
的用法示例。
在下文中一共展示了Commande::callHooks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromClone
/**
* Load an object from its id and create a new one in database
* @param fromid Id of object to clone
* @param invertdetail Reverse sign of amounts for lines
* @param socid Id of thirdparty
* @return int New id of clone
*/
function createFromClone($fromid, $invertdetail = 0, $socid = 0)
{
global $conf, $user, $langs;
$error = 0;
$object = new Commande($this->db);
// Instantiate hooks of thirdparty module
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) {
$object->callHooks('ordercard');
}
$this->db->begin();
// Load source object
$object->fetch($fromid);
$objFrom = $object;
// Change socid if needed
if (!empty($socid) && $socid != $object->socid) {
$objsoc = new Societe($this->db);
if ($objsoc->fetch($socid) > 0) {
$object->socid = $objsoc->id;
$object->cond_reglement_id = !empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0;
$object->mode_reglement_id = !empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0;
$object->fk_project = '';
$object->fk_delivery_address = '';
}
// TODO Change product price if multi-prices
}
$object->id = 0;
$object->statut = 0;
// Clear fields
$object->user_author_id = $user->id;
$object->user_valid = '';
$object->date_creation = '';
$object->date_validation = '';
$object->ref_client = '';
// Create clone
$result = $object->create($user);
// Other options
if ($result < 0) {
$this->error = $object->error;
$error++;
}
if (!$error) {
// Hook of thirdparty module
if (!empty($object->hooks)) {
foreach ($object->hooks as $hook) {
if (!empty($hook['modules'])) {
foreach ($hook['modules'] as $module) {
if (method_exists($module, 'createfrom')) {
$result = $module->createfrom($objFrom, $result, $object->element);
if ($result < 0) {
$error++;
}
}
}
}
}
}
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('ORDER_CLONE', $object, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
// End
if (!$error) {
$this->db->commit();
return $object->id;
} else {
$this->db->rollback();
return -1;
}
}
示例2: GETPOST
$id = GETPOST("id") ? GETPOST("id") : GETPOST("orderid");
$ref = GETPOST('ref');
$socid = GETPOST('socid');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
$lineid = GETPOST('lineid');
$mesg = GETPOST('mesg');
$object = new Commande($db);
// Security check
if ($user->societe_id) {
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $id, '');
// Instantiate hooks of thirdparty module
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) {
$object->callHooks('ordercard');
}
/******************************************************************************/
/* Actions */
/******************************************************************************/
// Hook of actions
if (!empty($object->hooks)) {
foreach ($object->hooks as $hook) {
if (!empty($hook['modules'])) {
foreach ($hook['modules'] as $module) {
if (method_exists($module, 'doActions')) {
$reshook += $module->doActions($object);
if (!empty($module->error) || !empty($module->errors) && sizeof($module->errors) > 0) {
$mesg = $module->error;
$mesgs = $module->errors;
if ($action == 'add') {