diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cf64e298784..37083cdf5f8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3637,22 +3637,19 @@ abstract class CommonObject $origin = 'order_supplier'; } - $targettype = $this->element; - - $parameters = array('sourcetype'=>$sourcetype, 'sourceid'=>$sourceid, 'targettype'=>$targettype, 'targetid'=>$targetid); - // Hook for explicitly set the targettype if it must be differtent than $this->element - $reshook = $hookmanager->executeHooks('setLinkedObjectSourceTargetType', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) { - if (!empty($hookmanager->resArray['targettype'])) $targettype = $hookmanager->resArray['targettype']; - if (!empty($hookmanager->resArray['sourcetype'])) $sourcetype = $hookmanager->resArray['sourcetype']; - } - // Elements of the core modules which have `$module` property but may to which we don't want to prefix module part to the element name for finding the linked object in llx_element_element. // It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target. $coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization'); // Add module part to target type if object has $module property and isn't in core modules. $targettype = ((!empty($this->module) && ! in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element; + $parameters = array('targettype'=>$targettype); + // Hook for explicitly set the targettype if it must be differtent than $this->element + $reshook = $hookmanager->executeHooks('setLinkedObjectSourceTargetType', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (!empty($hookmanager->resArray['targettype'])) $targettype = $hookmanager->resArray['targettype']; + } + $this->db->begin(); $error = 0; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index a4b18470be4..5ce2dd0fca7 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1232,7 +1232,7 @@ class FormTicket // External users can't send message email if ($user->rights->ticket->write && !$user->socid) { print ''; - $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ''); + $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?'checked':'')); print ' '; print ''; print ''; diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 6d0c77dc768..90462fdb762 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -238,9 +238,10 @@ class ConferenceOrBooth extends ActionComm * @param string $ref Ref * @param string $ref_ext Ref ext to get * @param string $email_msgid Email msgid + * @param int $loadresources 1=Load also resources * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = null, $ref_ext = '', $email_msgid = '') + public function fetch($id, $ref = null, $ref_ext = '', $email_msgid = '', $loadresources = 1) { global $dolibarr_main_url_root, $conf, $langs; diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 59b4cbfa16b..e6068eb3c81 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -382,7 +382,9 @@ class Mos extends DolibarrApi if (!$error && $value["fk_warehouse"] > 0) { // Record stock movement $id_product_batch = 0; - $stockmove->origin = $this->mo; + + $stockmove->setOrigin($this->mo->element, $this->mo->id); + if ($qtytoprocess >= 0) { $moline = new MoLine($this->db); $moline->fk_mo = $this->mo->id; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 510e7a433f4..533e81f80a2 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -211,7 +211,8 @@ if (empty($reshook)) { if (!$error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) { // Record stock movement $id_product_batch = 0; - $stockmove->origin = $object; + $stockmove->setOrigin($object->element, $object->id); + if ($qtytoprocess >= 0) { $idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); } else { diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index c0b607cde45..9a4d61209ba 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -109,7 +109,7 @@ if ($action == 'cancel_record' && $permissiontoadd) { if ($action == 'update' && !empty($user->rights->stock->mouvement->creer)) { $stockmovment = new MouvementStock($db); - $stockmovment->origin = $object; + $stockmovment->setOrigin($object->element, $object->id); $db->begin(); @@ -117,6 +117,7 @@ if ($action == 'update' && !empty($user->rights->stock->mouvement->creer)) { $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql);