当前位置: 首页>>代码示例>>PHP>>正文


PHP Commande::callHooks方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:ripasch,项目名称:dolibarr,代码行数:82,代码来源:commande.class.php

示例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') {
开发者ID:ripasch,项目名称:dolibarr,代码行数:31,代码来源:fiche.php


注:本文中的Commande::callHooks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。