Skip to content

Commit

Permalink
FIX API upload/download doc for expensereport
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 25, 2020
1 parent 7ec3227 commit 2438b48
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions htdocs/api/class/api_documents.class.php
Expand Up @@ -401,6 +401,22 @@ public function getDocumentsListByElement($modulepart, $id = 0, $ref = '', $sort

$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
}
elseif ($modulepart == 'expensereport')
{
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';

if (!DolibarrApiAccess::$user->rights->expensereport->read && !DolibarrApiAccess::$user->rights->expensereport->read) {
throw new RestException(401);
}

$object = new ExpenseReport($this->db);
$result = $object->fetch($id, $ref);
if (!$result) {
throw new RestException(404, 'Expense report not found');
}

$upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref);
}
else
{
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
Expand Down Expand Up @@ -523,6 +539,11 @@ public function post($filename, $modulepart, $ref = '', $subdir = '', $fileconte
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($this->db);
}
elseif ($modulepart == 'expensereport')
{
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$object = new ExpenseReport($this->db);
}
// TODO Implement additional moduleparts
else
{
Expand Down

0 comments on commit 2438b48

Please sign in to comment.