Fix upload api for invoices and bad id for bank account

This commit is contained in:
Laurent Destailleur 2017-11-17 11:44:52 +01:00
parent ba372bfc5c
commit 92753273b9
2 changed files with 12 additions and 7 deletions

View File

@ -23,8 +23,6 @@ use Luracast\Restler\Format\UploadFormat;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
/** /**
* API class for receive files * API class for receive files
@ -177,6 +175,8 @@ class Documents extends DolibarrApi
if ($modulepart == 'societe' || $modulepart == 'thirdparty') if ($modulepart == 'societe' || $modulepart == 'thirdparty')
{ {
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
if (!DolibarrApiAccess::$user->rights->societe->lire) { if (!DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401); throw new RestException(401);
} }
@ -239,7 +239,7 @@ class Documents extends DolibarrApi
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* *
* @param string $filename Name of file to create ('FA1705-0123') * @param string $filename Name of file to create ('FA1705-0123.txt')
* @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...) * @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...)
* @param string $ref Reference of object (This will define subdir automatically and store submited file into it) * @param string $ref Reference of object (This will define subdir automatically and store submited file into it)
* @param string $subdir Subdirectory (Only if ref not provided) * @param string $subdir Subdirectory (Only if ref not provided)
@ -285,15 +285,20 @@ class Documents extends DolibarrApi
if ($modulepart == 'facture' || $modulepart == 'invoice') if ($modulepart == 'facture' || $modulepart == 'invoice')
{ {
$modulepart='facture'; $modulepart='facture';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($this->db); $object = new Facture($this->db);
} }
elseif ($modulepart == 'project') elseif ($modulepart == 'project')
{ {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$object = new Project($this->db); $object = new Project($this->db);
} }
elseif ($modulepart == 'task' || $modulepart == 'project_task') elseif ($modulepart == 'task' || $modulepart == 'project_task')
{ {
$modulepart = 'project_task'; $modulepart = 'project_task';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$object = new Task($this->db); $object = new Task($this->db);
$task_result = $object->fetch('', $ref); $task_result = $object->fetch('', $ref);

View File

@ -344,7 +344,7 @@ class BankAccounts extends DolibarrApi
/** /**
* Add a link to an account line * Add a link to an account line
* *
* @param int $account_id ID of account * @param int $id ID of account
* @param int $line_id ID of account line * @param int $line_id ID of account line
* @param int $url_id ID to set in the URL {@from body} * @param int $url_id ID to set in the URL {@from body}
* @param string $url URL of the link {@from body} * @param string $url URL of the link {@from body}
@ -352,16 +352,16 @@ class BankAccounts extends DolibarrApi
* @param string $type Type of link ('payment', 'company', 'member', ...) {@from body} * @param string $type Type of link ('payment', 'company', 'member', ...) {@from body}
* @return int ID of link * @return int ID of link
* *
* @url POST {account_id}/lines/{line_id}/links * @url POST {id}/lines/{line_id}/links
*/ */
function addLink($account_id, $line_id, $url_id, $url, $label, $type) function addLink($id, $line_id, $url_id, $url, $label, $type)
{ {
if (! DolibarrApiAccess::$user->rights->banque->modifier) { if (! DolibarrApiAccess::$user->rights->banque->modifier) {
throw new RestException(401); throw new RestException(401);
} }
$account = new Account($this->db); $account = new Account($this->db);
$result = $account->fetch($account_id); $result = $account->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'account not found'); throw new RestException(404, 'account not found');
} }