forked from Wavyzz/dolibarr
wip
This commit is contained in:
@@ -55,10 +55,10 @@ class Interventions extends DolibarrApi
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
$this->fichinter = new Fichinter($this->db);
|
||||
}
|
||||
|
||||
@@ -72,23 +72,23 @@ class Interventions extends DolibarrApi
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
public function get($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention report not found');
|
||||
}
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention report not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$this->fichinter->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->fichinter);
|
||||
$this->fichinter->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->fichinter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ class Interventions extends DolibarrApi
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
|
||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
@@ -141,7 +141,7 @@ class Interventions extends DolibarrApi
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class Interventions extends DolibarrApi
|
||||
$obj = $db->fetch_object($result);
|
||||
$fichinter_static = new Fichinter($db);
|
||||
if($fichinter_static->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($fichinter_static);
|
||||
$obj_ret[] = $this->_cleanObjectDatas($fichinter_static);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ class Interventions extends DolibarrApi
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No finchinter found');
|
||||
}
|
||||
return $obj_ret;
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +189,7 @@ class Interventions extends DolibarrApi
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of intervention
|
||||
*/
|
||||
function post($request_data = null)
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->creer) {
|
||||
throw new RestException(401, "Insuffisant rights");
|
||||
@@ -218,28 +218,28 @@ class Interventions extends DolibarrApi
|
||||
* @return int
|
||||
*/
|
||||
/* TODO
|
||||
function getLines($id)
|
||||
public function getLines($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->fichinter->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->fichinter->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->fichinter->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->fichinter->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add a line to given intervention
|
||||
@@ -251,7 +251,7 @@ class Interventions extends DolibarrApi
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function postLine($id, $request_data = null)
|
||||
public function postLine($id, $request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->creer) {
|
||||
throw new RestException(401, "Insuffisant rights");
|
||||
@@ -292,30 +292,30 @@ class Interventions extends DolibarrApi
|
||||
* @param int $id Order ID
|
||||
* @return array
|
||||
*/
|
||||
function delete($id)
|
||||
public function delete($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error);
|
||||
}
|
||||
if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error);
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Intervention deleted'
|
||||
)
|
||||
);
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Intervention deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +333,7 @@ class Interventions extends DolibarrApi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function validate($id, $notrigger = 0)
|
||||
public function validate($id, $notrigger = 0)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->creer) {
|
||||
throw new RestException(401, "Insuffisant rights");
|
||||
@@ -369,7 +369,7 @@ class Interventions extends DolibarrApi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function closeFichinter($id)
|
||||
public function closeFichinter($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->ficheinter->creer)
|
||||
{
|
||||
@@ -406,7 +406,7 @@ class Interventions extends DolibarrApi
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate($data)
|
||||
private function _validate($data)
|
||||
{
|
||||
$fichinter = array();
|
||||
foreach (Interventions::$FIELDS as $field) {
|
||||
@@ -424,16 +424,16 @@ class Interventions extends DolibarrApi
|
||||
* @param object $object Object to clean
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object)
|
||||
private function _cleanObjectDatas($object)
|
||||
{
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
unset($object->statuts_short);
|
||||
unset($object->statuts_logo);
|
||||
unset($object->statuts);
|
||||
unset($object->statuts_short);
|
||||
unset($object->statuts_logo);
|
||||
unset($object->statuts);
|
||||
|
||||
return $object;
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,7 +444,7 @@ class Interventions extends DolibarrApi
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validateLine($data)
|
||||
private function _validateLine($data)
|
||||
{
|
||||
$fichinter = array();
|
||||
foreach (Interventions::$FIELDSLINE as $field) {
|
||||
|
||||
Reference in New Issue
Block a user