Extrafields in expense report lines

Hi all,

I’m developing a module for some customiziation in dolibarr, one of this is on expense report.
The module unfortunatly doesn’t manage extrafields on detail lines, I was able to use them in the logic by creating table and adding the missing element_name in the object, this allow to use all common fetch and save features. But now i have to change the core card.php to show them (i found no way to change the detail list it with hooks…).

Will be good if this is a part of the dolibarr core.

Thanks

1 Like

You can write a custom module and use actions hook to replace the card with your own. Something like this:

public function doActions($parameters, &$object, &$action, $hookmanager)
	{
		global $conf, $user, $langs;

		$error = 0; // Error counter

		if (in_array($parameters['currentcontext'], array('expensereportcard')))	
		{
			
				$urlparam =  $_SERVER['REQUEST_URI'];
                $paramsuffix = substr($urlparam, strpos($urlparam, "?") + 1);  

			     header('Location: '.DOL_URL_ROOT.'/custom/{your_module}/card.php?'.$paramsuffix);
			
			
		}
		

		if (!$error) {
			$this->results = array('myreturn' => 999);
			$this->resprints = 'A text to show';
			return 0; // or return 1 to replace standard code
		} else {
			$this->errors[] = 'Error message';
			return -1;
		}
	}

Thanks for the hint,
anyway I did a litte change also on the class since missed the table name field and is required for extrafields

I would really love to see this a part of core module