2
0
forked from Wavyzz/dolibarr

FIX dolGetElementUrl and agenda page for external modules

This commit is contained in:
Laurent Destailleur
2020-07-24 11:53:44 +02:00
parent 195ad9e5fb
commit 46fccf8eb1
8 changed files with 27 additions and 21 deletions

View File

@@ -1077,6 +1077,7 @@ if ($action == 'create')
print '<input type="hidden" name="origin" size="10" value="'.GETPOST('origin').'">';
}
$reg = array();
if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg))
{
$object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);

View File

@@ -1257,7 +1257,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
* @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object
* @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket... to list events linked to an object
* @param Contact $objcon Filter on object contact to filter events on a contact
* @param int $noprint Return string but does not output it
* @param string $actioncode Filter on actioncode
@@ -1265,9 +1265,10 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
* @param array $filters Filter on other fields
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param string $module You can add module name here if elementtype in table llx_actioncomm is objectkey@module
* @return string|void Return html part or void if noprint is 1
*/
function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC')
function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
{
global $user, $conf;
global $form;
@@ -1367,7 +1368,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
if ($force_filter_contact === false) {
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id;
elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id;
elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ }
elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id;
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent')
{
$sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
@@ -1394,7 +1396,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
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)."'";
// Generic case
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
}
}

View File

@@ -1747,12 +1747,12 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
$ret = '';
$regs = array();
// If we ask an resource form external module (instead of default path)
// If we ask a resource form external module (instead of default path)
if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) {
$myobject = $regs[1];
$module = $regs[2];
}
else {
// Parse $objecttype (ex: project_task)
$module = $myobject = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
@@ -1760,6 +1760,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
$module = $regs[1];
$myobject = $regs[2];
}
}
// Generic case for $classpath
$classpath = $module.'/class';
@@ -1821,7 +1822,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
// Generic case for $classfile and $classname
$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." classpath=".$classpath;
if ($objecttype == 'invoice_supplier') {
$classfile = 'fournisseur.facture';

View File

@@ -1041,3 +1041,4 @@ SwitchInEditModeToAddTranslation=Switch in edit mode to add translations for thi
NotUsedForThisCustomer=Not used for this customer
AmountMustBePositive=Amount must be positive
ByStatus=By status
InformationMessage=Information

View File

@@ -830,7 +830,7 @@ class MyObject extends CommonObject
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
global $langs;
//$langs->load("mymodule");
//$langs->load("mymodule@mymodule");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
@@ -939,7 +939,7 @@ class MyObject extends CommonObject
public function getNextNumRef()
{
global $langs, $conf;
$langs->load("mymodule@myobject");
$langs->load("mymodule@mymodule");
if (empty($conf->global->MYMODULE_MYOBJECT_ADDON)) {
$conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard';

View File

@@ -147,7 +147,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$this->db = $db;
$this->name = "standard";
$this->description = $langs->trans('PDFStandardDescription');
$this->description = $langs->trans('DocumentModelStandardPDF');
$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
// Dimension page

View File

@@ -244,7 +244,7 @@ if ($object->id > 0)
$filters['search_agenda_label'] = $search_agenda_label;
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, 'mymmodule');
}
}

View File

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