FIX Bad management of elementtype not llx_actioncomm

This commit is contained in:
Laurent Destailleur 2020-01-07 13:48:44 +01:00
parent a1803f5d62
commit 6029e82e90
3 changed files with 40 additions and 22 deletions

View File

@ -1335,6 +1335,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref";
elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref";
elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref";
elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", o.ref";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
@ -1359,6 +1361,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o";
elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o";
elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o";
elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o";
$sql .= " WHERE a.entity IN (".getEntity('agenda').")"; $sql .= " WHERE a.entity IN (".getEntity('agenda').")";
if ($force_filter_contact === false) { if ($force_filter_contact === false) {
@ -1394,6 +1397,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
} }
elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element)
{
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element)."'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
}
} }
// Condition on actioncode // Condition on actioncode
@ -1712,7 +1720,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
// Title of event // Title of event
//$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>'; //$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
// Objet lie // Linked object
$out .= '<td>'; $out .= '<td>';
if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element']))
{ {

View File

@ -1797,7 +1797,7 @@ function getSoapParams()
* Return link url to an object * Return link url to an object
* *
* @param int $objectid Id of record * @param int $objectid Id of record
* @param string $objecttype Type of object ('invoice', 'order', 'expedition_bon', ...) * @param string $objecttype Type of object ('invoice', 'order', 'expedition_bon', 'myobject@mymodule', ...)
* @param int $withpicto Picto to show * @param int $withpicto Picto to show
* @param string $option More options * @param string $option More options
* @return string URL of link to object id/type * @return string URL of link to object id/type
@ -1807,28 +1807,35 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
global $db, $conf, $langs; global $db, $conf, $langs;
$ret = ''; $ret = '';
$regs = array();
// Parse element/subelement (ex: project_task) // If we ask an resource form external module (instead of default path)
$module = $element = $subelement = $objecttype; if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) {
$myobject = $regs[1];
$module = $regs[2];
}
// Parse $objecttype (ex: project_task)
$module = $myobject = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
{ {
$module = $element = $regs[1]; $module = $regs[1];
$subelement = $regs[2]; $myobject = $regs[2];
} }
// Generic case for $classpath // Generic case for $classpath
$classpath = $element.'/class'; $classpath = $module.'/class';
// Special cases, to work with non standard path // Special cases, to work with non standard path
if ($objecttype == 'facture' || $objecttype == 'invoice') { if ($objecttype == 'facture' || $objecttype == 'invoice') {
$classpath = 'compta/facture/class'; $classpath = 'compta/facture/class';
$module='facture'; $module='facture';
$subelement='facture'; $myobject='facture';
} }
elseif ($objecttype == 'commande' || $objecttype == 'order') { elseif ($objecttype == 'commande' || $objecttype == 'order') {
$classpath = 'commande/class'; $classpath = 'commande/class';
$module='commande'; $module='commande';
$subelement='commande'; $myobject='commande';
} }
elseif ($objecttype == 'propal') { elseif ($objecttype == 'propal') {
$classpath = 'comm/propal/class'; $classpath = 'comm/propal/class';
@ -1838,52 +1845,52 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
} }
elseif ($objecttype == 'shipping') { elseif ($objecttype == 'shipping') {
$classpath = 'expedition/class'; $classpath = 'expedition/class';
$subelement = 'expedition'; $myobject = 'expedition';
$module = 'expedition_bon'; $module = 'expedition_bon';
} }
elseif ($objecttype == 'delivery') { elseif ($objecttype == 'delivery') {
$classpath = 'livraison/class'; $classpath = 'livraison/class';
$subelement = 'livraison'; $myobject = 'livraison';
$module = 'livraison_bon'; $module = 'livraison_bon';
} }
elseif ($objecttype == 'contract') { elseif ($objecttype == 'contract') {
$classpath = 'contrat/class'; $classpath = 'contrat/class';
$module='contrat'; $module='contrat';
$subelement='contrat'; $myobject='contrat';
} }
elseif ($objecttype == 'member') { elseif ($objecttype == 'member') {
$classpath = 'adherents/class'; $classpath = 'adherents/class';
$module='adherent'; $module='adherent';
$subelement='adherent'; $myobject='adherent';
} }
elseif ($objecttype == 'cabinetmed_cons') { elseif ($objecttype == 'cabinetmed_cons') {
$classpath = 'cabinetmed/class'; $classpath = 'cabinetmed/class';
$module='cabinetmed'; $module='cabinetmed';
$subelement='cabinetmedcons'; $myobject='cabinetmedcons';
} }
elseif ($objecttype == 'fichinter') { elseif ($objecttype == 'fichinter') {
$classpath = 'fichinter/class'; $classpath = 'fichinter/class';
$module='ficheinter'; $module='ficheinter';
$subelement='fichinter'; $myobject='fichinter';
} }
elseif ($objecttype == 'task') { elseif ($objecttype == 'task') {
$classpath = 'projet/class'; $classpath = 'projet/class';
$module='projet'; $module='projet';
$subelement='task'; $myobject='task';
} }
elseif ($objecttype == 'stock') { elseif ($objecttype == 'stock') {
$classpath = 'product/stock/class'; $classpath = 'product/stock/class';
$module='stock'; $module='stock';
$subelement='stock'; $myobject='stock';
} }
elseif ($objecttype == 'inventory') { elseif ($objecttype == 'inventory') {
$classpath = 'product/inventory/class'; $classpath = 'product/inventory/class';
$module='stock'; $module='stock';
$subelement='inventory'; $myobject='inventory';
} }
// Generic case for $classfile and $classname // Generic case for $classfile and $classname
$classfile = strtolower($subelement); $classname = ucfirst($subelement); $classfile = strtolower($myobject); $classname = ucfirst($myobject);
//print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname; //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname;
if ($objecttype == 'invoice_supplier') { if ($objecttype == 'invoice_supplier') {
@ -1903,6 +1910,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
$classfile = 'entrepot'; $classfile = 'entrepot';
$classname = 'Entrepot'; $classname = 'Entrepot';
} }
if (!empty($conf->$module->enabled)) if (!empty($conf->$module->enabled))
{ {
$res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
@ -2048,11 +2056,13 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent)
/** /**
* Get an array with properties of an element * Get an array with properties of an element
* *
* @param string $element_type Element type: 'action', 'facture', 'project_task' or 'object@modulext'... * @param string $element_type Element type: 'action', 'facture', 'project_task' or 'object@mymodule'...
* @return array (module, classpath, element, subelement, classfile, classname) * @return array (module, classpath, element, subelement, classfile, classname)
*/ */
function getElementProperties($element_type) function getElementProperties($element_type)
{ {
$regs = array();
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$module = $element_type; $module = $element_type;
$element = $element_type; $element = $element_type;

View File

@ -571,7 +571,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'myobject', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
print '</div></div></div>'; print '</div></div></div>';
} }