Documents
class Documents extends DolibarrApi (View source)
API class for receive files
Properties
| protected DoliDB | $db | from DolibarrApi | |
| Restler | $r | from DolibarrApi |
Methods
Constructor
Check and convert a string depending on its type/name.
Filter properties that will be returned on object
Check access by user to a given resource
Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules
Function to forge a SQL criteria from a Generic filter string.
Download a document
Build a document
List documents of an element
Upload a document
Delete a document
Details
__construct()
Constructor
protected string|array<string, mixed>
_checkValForAPI(string $field, string|string[] $value, object $object)
Check and convert a string depending on its type/name.
protected object
_filterObjectProperties(object $object, string $properties)
Filter properties that will be returned on object
protected object
_cleanObjectDatas(object $object)
Clean sensitive object data
static protected bool
_checkAccessToResource(string $resource, int $resource_id = 0, string $dbtablename = '', string $feature2 = '', string $dbt_keyfield = 'fk_soc', string $dbt_select = 'rowid')
Check access by user to a given resource
protected bool|string
_checkFilters(string $sqlfilters, string $error = '')
Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules
static protected string
_forge_criteria_callback(string[] $matches)
Function to forge a SQL criteria from a Generic filter string.
Function no more used. Kept for backward compatibility with old APIs of modules
array
index(string $modulepart, string $original_file = '')
Download a document
Note that, this API is similar to using the wrapper link "documents.php" to download a file (used for internal HTML links of documents into application), but with no need to have a session cookie (the token is used instead).
array
builddoc(string $modulepart, string $original_file = '', string $doctemplate = '', string $langcode = '')
Build a document
Test sample 1: { "modulepart": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }.
Supported modules: invoice, order, proposal, contract, supplier invoice, shipment, mrp
array
getDocumentsListByElement(string $modulepart, int $id = 0, string $ref = '', string $sortfield = '', string $sortorder = '', int $limit = 100, int $page = 0, string $content_type = '', bool $pagination_data = false)
List documents of an element
Use element ID or Ref. Supported modules: thirdparty, user, member, proposal, order, supplier_order, shipment, invoice, supplier_invoice, product, event, expensereport, knowledgemanagement, category, contract, project, project_task
string
post(string $filename, string $modulepart, string $ref = '', string $subdir = '', string $filecontent = '', string $fileencoding = '', int $overwriteifexists = 0, int $createdirifnotexists = 1, int $position = 0, string $cover = '', array $array_options = [], int $generateThumbs = 0)
Upload a document
Test sample for invoice: { "filename": "mynewfile.txt", "modulepart": "invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }.
Supported modules: invoice, order, supplier_order, task/project_task, product/service, expensereport, fichinter, member, propale, agenda, contact
array
delete(string $modulepart, string $original_file)
Delete a document