forked from Wavyzz/dolibarr
FIX dolGetElementUrl and agenda page for external modules
This commit is contained in:
@@ -1077,6 +1077,7 @@ if ($action == 'create')
|
|||||||
print '<input type="hidden" name="origin" size="10" value="'.GETPOST('origin').'">';
|
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))
|
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]);
|
$object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
|
||||||
|
|||||||
@@ -1257,7 +1257,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
|||||||
* @param Conf $conf Object conf
|
* @param Conf $conf Object conf
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @param DoliDB $db Object db
|
* @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 Contact $objcon Filter on object contact to filter events on a contact
|
||||||
* @param int $noprint Return string but does not output it
|
* @param int $noprint Return string but does not output it
|
||||||
* @param string $actioncode Filter on actioncode
|
* @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 array $filters Filter on other fields
|
||||||
* @param string $sortfield Sort field
|
* @param string $sortfield Sort field
|
||||||
* @param string $sortorder Sort order
|
* @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
|
* @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 $user, $conf;
|
||||||
global $form;
|
global $form;
|
||||||
@@ -1367,7 +1368,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
|||||||
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
|
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
|
||||||
if ($force_filter_contact === false) {
|
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;
|
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')
|
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent')
|
||||||
{
|
{
|
||||||
$sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
|
$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;
|
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)
|
} 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;
|
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1747,12 +1747,12 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
|||||||
$ret = '';
|
$ret = '';
|
||||||
$regs = array();
|
$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)) {
|
if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) {
|
||||||
$myobject = $regs[1];
|
$myobject = $regs[1];
|
||||||
$module = $regs[2];
|
$module = $regs[2];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// Parse $objecttype (ex: project_task)
|
// Parse $objecttype (ex: project_task)
|
||||||
$module = $myobject = $objecttype;
|
$module = $myobject = $objecttype;
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
|
if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
|
||||||
@@ -1760,6 +1760,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
|||||||
$module = $regs[1];
|
$module = $regs[1];
|
||||||
$myobject = $regs[2];
|
$myobject = $regs[2];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generic case for $classpath
|
// Generic case for $classpath
|
||||||
$classpath = $module.'/class';
|
$classpath = $module.'/class';
|
||||||
@@ -1821,7 +1822,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
|||||||
|
|
||||||
// Generic case for $classfile and $classname
|
// Generic case for $classfile and $classname
|
||||||
$classfile = strtolower($myobject); $classname = ucfirst($myobject);
|
$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') {
|
if ($objecttype == 'invoice_supplier') {
|
||||||
$classfile = 'fournisseur.facture';
|
$classfile = 'fournisseur.facture';
|
||||||
|
|||||||
@@ -1041,3 +1041,4 @@ SwitchInEditModeToAddTranslation=Switch in edit mode to add translations for thi
|
|||||||
NotUsedForThisCustomer=Not used for this customer
|
NotUsedForThisCustomer=Not used for this customer
|
||||||
AmountMustBePositive=Amount must be positive
|
AmountMustBePositive=Amount must be positive
|
||||||
ByStatus=By status
|
ByStatus=By status
|
||||||
|
InformationMessage=Information
|
||||||
@@ -830,7 +830,7 @@ class MyObject extends CommonObject
|
|||||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
//$langs->load("mymodule");
|
//$langs->load("mymodule@mymodule");
|
||||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||||
$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
|
$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
|
||||||
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
|
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
|
||||||
@@ -939,7 +939,7 @@ class MyObject extends CommonObject
|
|||||||
public function getNextNumRef()
|
public function getNextNumRef()
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
$langs->load("mymodule@myobject");
|
$langs->load("mymodule@mymodule");
|
||||||
|
|
||||||
if (empty($conf->global->MYMODULE_MYOBJECT_ADDON)) {
|
if (empty($conf->global->MYMODULE_MYOBJECT_ADDON)) {
|
||||||
$conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard';
|
$conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard';
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
|
|||||||
|
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->name = "standard";
|
$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
|
$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
|
// Dimension page
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ if ($object->id > 0)
|
|||||||
$filters['search_agenda_label'] = $search_agenda_label;
|
$filters['search_agenda_label'] = $search_agenda_label;
|
||||||
|
|
||||||
// TODO Replace this with same code than into list.php
|
// 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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -583,7 +583,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, $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>';
|
print '</div></div></div>';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user