diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index f8f8d37ce17..dede8690c06 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -134,8 +134,11 @@ class DolibarrApi unset($object->fk_element); unset($object->table_element); unset($object->table_element_line); + unset($object->class_element_line); unset($object->picto); + unset($object->facturee); // Replace with billed + unset($object->skip_update_total); unset($object->context); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 17ff8ae22f1..02f764ec0ba 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -387,7 +387,7 @@ class Orders extends DolibarrApi /** * Update order general fields (won't touch lines of order) * - * @param int $id Id of commande to update + * @param int $id Id of order to update * @param array $request_data Datas * * @return int @@ -498,6 +498,53 @@ class Orders extends DolibarrApi ); } + /** + * Close an order (Classify it as "Delivered") + * + * @param int $id Order ID + * @param int $notrigger Disabled triggers + * + * @url POST {id}/close + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "notrigger": 0 + * } + */ + function close($id, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + $result = $this->commande->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->commande->cloture(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(500, 'Error nothing done. May be object is already closed'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Order: '.$this->commande->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Order closed (Ref='.$this->commande->ref.')' + ) + ); + } + + /** * Clean sensible object datas * @@ -509,6 +556,10 @@ class Orders extends DolibarrApi $object = parent::_cleanObjectDatas($object); unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); return $object; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4cda7e931d4..8937d2c16c2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -557,9 +557,10 @@ class Commande extends CommonOrder * Close order * * @param User $user Objet user that close + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function cloture($user) + function cloture($user, $notrigger=0) { global $conf; @@ -580,10 +581,13 @@ class Commande extends CommonOrder if ($this->db->query($sql)) { - // Call trigger - $result=$this->call_trigger('ORDER_CLOSE',$user); - if ($result < 0) $error++; - // End call triggers + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('ORDER_CLOSE',$user); + if ($result < 0) $error++; + // End call triggers + } if (! $error) { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3d94595f558..ca6a4cec0c4 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -600,6 +600,10 @@ class Invoices extends DolibarrApi $object = parent::_cleanObjectDatas($object); unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); return $object; } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 92792428a38..12d2117bfd7 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -336,6 +336,10 @@ class SupplierInvoices extends DolibarrApi $object = parent::_cleanObjectDatas($object); unset($object->rowid); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); return $object; } diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 2695727c3ee..dbe3cf79c01 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -340,6 +340,10 @@ class SupplierOrders extends DolibarrApi $object = parent::_cleanObjectDatas($object); unset($object->rowid); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); return $object; }