add initila support for correspondents

This commit is contained in:
Uwe Steinmann 2023-02-08 20:47:58 +01:00
parent 7fe0f08ba5
commit 959b8bea7d
2 changed files with 29 additions and 2 deletions

View File

@ -291,10 +291,29 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
} /* }}} */
function correspondents($request, $response) { /* {{{ */
$dms = $this->container->dms;
$userobj = $this->container->userobj;
$settings = $this->container->config;
$logger = $this->container->logger;
//file_put_contents("php://stdout", var_dump($request, true));
$correspondents = array(
);
$correspondents = array();
if(!empty($settings->_extensions['paperless']['correspondentsattr']) && $attrdef = $dms->getAttributeDefinition($settings->_extensions['paperless']['correspondentsattr'])) {
$valueset = $attrdef->getValueSetAsArray();
foreach($valueset as $id=>$val) {
$correspondents[] = array(
'id'=>$id+1,
'slug'=>strtolower($val),
'name'=>$val,
'match'=>'',
'matching_algorithm'=>1,
'is_insensitive'=>true,
'document_count'=>0,
'last_correspondence'=>null
);
}
}
return $response->withJson(array('count'=>count($correspondents), 'next'=>null, 'previous'=>null, 'results'=>$correspondents), 200);
} /* }}} */

View File

@ -50,6 +50,14 @@ $EXT_CONF['paperless'] = array(
'options'=>['title'=>'Title', 'content'=>'Content'],
'allow_empty'=>true,
),
'correspondentsattr' => array(
'title'=>'Attribute for storing the correspondence',
'help'=>'This attribute stores the correspondence of a document and must have a list of correspondents.',
'type'=>'select',
'internal'=>'attributedefinitions',
'objtype'=>'2',
'allow_empty'=>true,
),
),
'constraints' => array(
'depends' => array('php' => '7.4.0-', 'seeddms' => array('5.1.29-5.1.99', '6.0.22-6.0.99')),