test phpcs v3

This commit is contained in:
Frédéric FRANCE 2018-08-09 11:31:48 +02:00
parent b00164ca39
commit 62b83412ee
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
5 changed files with 315 additions and 319 deletions

View File

@ -185,9 +185,9 @@ class Orders extends DolibarrApi
*/
function post($request_data = null)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401, "Insuffisant rights");
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
@ -219,24 +219,24 @@ class Orders extends DolibarrApi
* @return int
*/
function getLines($id) {
if(! DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$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);
}
$this->commande->getLinesArray();
$result = array();
foreach ($this->commande->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->commande->getLinesArray();
$result = array();
foreach ($this->commande->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
/**
@ -250,20 +250,20 @@ class Orders extends DolibarrApi
* @return int
*/
function postLine($id, $request_data = null) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$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);
}
$request_data = (object) $request_data;
$updateRes = $this->commande->addline(
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->commande->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
@ -290,15 +290,14 @@ class Orders extends DolibarrApi
$request_data->origin,
$request_data->origin_id,
$request_data->multicurrency_subprice
);
);
if ($updateRes > 0) {
return $updateRes;
if ($updateRes > 0) {
return $updateRes;
}
else {
} else {
throw new RestException(400, $this->commande->error);
}
}
}
/**
@ -313,50 +312,50 @@ class Orders extends DolibarrApi
* @return object
*/
function putLine($id, $lineid, $request_data = null) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$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);
}
$request_data = (object) $request_data;
$updateRes = $this->commande->updateline(
$lineid,
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->remise_percent,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
'HT',
$request_data->info_bits,
$request_data->date_start,
$request_data->date_end,
$request_data->product_type,
$request_data->fk_parent_line,
0,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->special_code,
$request_data->array_options,
$request_data->fk_unit,
$request_data->multicurrency_subprice
);
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->commande->updateline(
$lineid,
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->remise_percent,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
'HT',
$request_data->info_bits,
$request_data->date_start,
$request_data->date_end,
$request_data->product_type,
$request_data->fk_parent_line,
0,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->special_code,
$request_data->array_options,
$request_data->fk_unit,
$request_data->multicurrency_subprice
);
if ($updateRes > 0) {
$result = $this->get($id);
unset($result->line);
return $this->_cleanObjectDatas($result);
}
return false;
if ($updateRes > 0) {
$result = $this->get($id);
unset($result->line);
return $this->_cleanObjectDatas($result);
}
return false;
}
/**
@ -373,29 +372,27 @@ class Orders extends DolibarrApi
* @throws 404
*/
function deleteLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
$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);
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
// TODO Check the lineid $lineid is a line of ojbect
// TODO Check the lineid $lineid is a line of ojbect
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes > 0) {
return $this->get($id);
}
else
{
throw new RestException(405, $this->commande->error);
}
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes > 0) {
return $this->get($id);
} else {
throw new RestException(405, $this->commande->error);
}
}
/**
@ -407,9 +404,9 @@ class Orders extends DolibarrApi
* @return int
*/
function put($id, $request_data = null) {
if (! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if (! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if (! $result) {
@ -550,21 +547,21 @@ class Orders extends DolibarrApi
function reopen($id) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
throw new RestException(404, 'Order not found');
}
$result = $this->commande->set_reopen(DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(405, $this->commande->error);
throw new RestException(405, $this->commande->error);
}else if( $result == 0) {
throw new RestException(304);
throw new RestException(304);
}
return $result;
@ -587,19 +584,19 @@ class Orders extends DolibarrApi
function setinvoiced($id) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
throw new RestException(404, 'Order not found');
}
$result = $this->commande->classifyBilled(DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(400, $this->commande->error);
throw new RestException(400, $this->commande->error);
}
$result = $this->commande->fetch($id);
@ -675,23 +672,23 @@ class Orders extends DolibarrApi
function settodraft($id, $idwarehouse=-1)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
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);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->commande->set_draft(DolibarrApiAccess::$user, $idwarehouse);
if ($result == 0) {
throw new RestException(304, 'Nothing done. May be object is already closed');
throw new RestException(304, 'Nothing done. May be object is already closed');
}
if ($result < 0) {
throw new RestException(500, 'Error when closing Order: '.$this->commande->error);
throw new RestException(500, 'Error when closing Order: '.$this->commande->error);
}
$result = $this->commande->fetch($id);
@ -728,24 +725,24 @@ class Orders extends DolibarrApi
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(401);
}
if(empty($proposalid)) {
throw new RestException(400, 'Proposal ID is mandatory');
throw new RestException(400, 'Proposal ID is mandatory');
}
$propal = new Propal($this->db);
$result = $propal->fetch($proposalid);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
throw new RestException(404, 'Proposal not found');
}
$result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(405, $this->commande->error);
throw new RestException(405, $this->commande->error);
}
$this->commande->fetchObjectLinked();
@ -785,7 +782,7 @@ class Orders extends DolibarrApi
$commande = array();
foreach (Orders::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
throw new RestException(400, $field ." field missing");
$commande[$field] = $data[$field];
}

View File

@ -250,24 +250,24 @@ class Invoices extends DolibarrApi
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
if(! DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
throw new RestException(401);
}
if(empty($orderid)) {
throw new RestException(400, 'Order ID is mandatory');
throw new RestException(400, 'Order ID is mandatory');
}
$order = new Commande($this->db);
$result = $order->fetch($orderid);
if( ! $result ) {
throw new RestException(404, 'Order not found');
throw new RestException(404, 'Order not found');
}
$result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(405, $this->invoice->error);
throw new RestException(405, $this->invoice->error);
}
$this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
@ -512,66 +512,66 @@ class Invoices extends DolibarrApi
* @throws 400
*/
function postLine($id, $request_data = null) {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$request_data = (object) $request_data;
// Reset fk_parent_line for no child products and special product
if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
$request_data->fk_parent_line = 0;
}
// Reset fk_parent_line for no child products and special product
if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
$request_data->fk_parent_line = 0;
}
// calculate pa_ht
$marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht);
$pa_ht = $marginInfos[0];
// calculate pa_ht
$marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht);
$pa_ht = $marginInfos[0];
$updateRes = $this->invoice->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start,
$request_data->date_end,
$request_data->fk_code_ventilation,
$request_data->info_bits,
$request_data->fk_remise_except,
'HT',
0,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
$request_data->origin,
$request_data->origin_id,
$request_data->fk_parent_line,
empty($request_data->fk_fournprice)?null:$request_data->fk_fournprice,
$pa_ht,
$request_data->label,
$request_data->array_options,
$request_data->situation_percent,
$request_data->fk_prev_id,
$request_data->fk_unit
);
$updateRes = $this->invoice->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start,
$request_data->date_end,
$request_data->fk_code_ventilation,
$request_data->info_bits,
$request_data->fk_remise_except,
'HT',
0,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
$request_data->origin,
$request_data->origin_id,
$request_data->fk_parent_line,
empty($request_data->fk_fournprice)?null:$request_data->fk_fournprice,
$pa_ht,
$request_data->label,
$request_data->array_options,
$request_data->situation_percent,
$request_data->fk_prev_id,
$request_data->fk_unit
);
if ($updateRes < 0) {
if ($updateRes < 0) {
throw new RestException(400, 'Unable to insert the new line. Check your inputs. '.$this->invoice->error);
}
}
return $updateRes;
return $updateRes;
}
/**
@ -647,23 +647,23 @@ class Invoices extends DolibarrApi
function settodraft($id, $idwarehouse=-1)
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_draft(DolibarrApiAccess::$user, $idwarehouse);
if ($result == 0) {
throw new RestException(304, 'Nothing done.');
throw new RestException(304, 'Nothing done.');
}
if ($result < 0) {
throw new RestException(500, 'Error : '.$this->invoice->error);
throw new RestException(500, 'Error : '.$this->invoice->error);
}
$result = $this->invoice->fetch($id);
@ -750,23 +750,23 @@ class Invoices extends DolibarrApi
function settopaid($id, $close_code='', $close_note='')
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_paid(DolibarrApiAccess::$user, $close_code, $close_note);
if ($result == 0) {
throw new RestException(304, 'Error nothing done. May be object is already validated');
throw new RestException(304, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error : '.$this->invoice->error);
throw new RestException(500, 'Error : '.$this->invoice->error);
}
@ -801,23 +801,23 @@ class Invoices extends DolibarrApi
function settounpaid($id)
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_unpaid(DolibarrApiAccess::$user);
if ($result == 0) {
throw new RestException(304, 'Nothing done');
throw new RestException(304, 'Nothing done');
}
if ($result < 0) {
throw new RestException(500, 'Error : '.$this->invoice->error);
throw new RestException(500, 'Error : '.$this->invoice->error);
}
@ -852,27 +852,27 @@ class Invoices extends DolibarrApi
function useDiscount($id, $discountid) {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Invoice ID is mandatory');
throw new RestException(400, 'Invoice ID is mandatory');
}
if(empty($discountid)) {
throw new RestException(400, 'Discount ID is mandatory');
throw new RestException(400, 'Discount ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->insert_discount($discountid);
if( $result < 0) {
throw new RestException(405, $this->invoice->error);
throw new RestException(405, $this->invoice->error);
}
return $result;
@ -899,27 +899,27 @@ class Invoices extends DolibarrApi
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Invoice ID is mandatory');
throw new RestException(400, 'Invoice ID is mandatory');
}
if(empty($discountid)) {
throw new RestException(400, 'Credit ID is mandatory');
throw new RestException(400, 'Credit ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$discount = new DiscountAbsolute($this->db);
$result = $discount->fetch($discountid);
if( ! $result ) {
throw new RestException(404, 'Credit not found');
throw new RestException(404, 'Credit not found');
}
$result = $discount->link_to_invoice(0, $id);
if( $result < 0) {
throw new RestException(405, $discount->error);
throw new RestException(405, $discount->error);
}
return $result;
@ -941,24 +941,24 @@ class Invoices extends DolibarrApi
function getPayments($id) {
if(! DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401);
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Invoice ID is mandatory');
throw new RestException(400, 'Invoice ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->getListOfPayments();
if( $result < 0) {
throw new RestException(405, $this->invoice->error);
throw new RestException(405, $this->invoice->error);
}
return $result;
@ -1111,7 +1111,7 @@ class Invoices extends DolibarrApi
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(403);
throw new RestException(403);
}
foreach($arrayofamounts as $id => $amount) {
if(empty($id)) {

View File

@ -248,45 +248,45 @@ class Contracts extends DolibarrApi
* @return int
*/
function postLine($id, $request_data = null) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contract not found');
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contract not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->contract->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start, // date_start = date planned start, date ouverture = date_start_real
$request_data->date_end, // date_end = date planned end, date_cloture = date_end_real
$request_data->HT,
$request_data->subprice_excl_tax,
$request_data->info_bits,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->array_options,
$request_data->fk_unit,
$request_data->rang
);
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->contract->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start, // date_start = date planned start, date ouverture = date_start_real
$request_data->date_end, // date_end = date planned end, date_cloture = date_end_real
$request_data->HT,
$request_data->subprice_excl_tax,
$request_data->info_bits,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->array_options,
$request_data->fk_unit,
$request_data->rang
);
if ($updateRes > 0) {
return $updateRes;
if ($updateRes > 0) {
return $updateRes;
}
return false;
}
return false;
}
/**
@ -301,49 +301,49 @@ class Contracts extends DolibarrApi
* @return object
*/
function putLine($id, $lineid, $request_data = null) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contrat not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$request_data = (object) $request_data;
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contrat not found');
}
$updateRes = $this->contract->updateline(
$lineid,
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->remise_percent,
$request_data->date_ouveture_prevue,
$request_data->date_fin_validite,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->date_ouverture,
$request_data->date_cloture,
'HT',
$request_data->info_bits,
$request_data->fk_fourn_price,
$request_data->pa_ht,
$request_data->array_options,
$request_data->fk_unit
);
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if ($updateRes > 0) {
$result = $this->get($id);
unset($result->line);
return $this->_cleanObjectDatas($result);
}
$request_data = (object) $request_data;
return false;
$updateRes = $this->contract->updateline(
$lineid,
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->remise_percent,
$request_data->date_ouveture_prevue,
$request_data->date_fin_validite,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->date_ouverture,
$request_data->date_cloture,
'HT',
$request_data->info_bits,
$request_data->fk_fourn_price,
$request_data->pa_ht,
$request_data->array_options,
$request_data->fk_unit
);
if ($updateRes > 0) {
$result = $this->get($id);
unset($result->line);
return $this->_cleanObjectDatas($result);
}
return false;
}
/**
@ -437,29 +437,29 @@ class Contracts extends DolibarrApi
* @throws 404
*/
function deleteLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contrat not found');
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contrat not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
// TODO Check the lineid $lineid is a line of ojbect
// TODO Check the lineid $lineid is a line of ojbect
$updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user);
if ($updateRes > 0) {
return $this->get($id);
}
else
{
throw new RestException(405, $this->contract->error);
}
$updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user);
if ($updateRes > 0) {
return $this->get($id);
}
else
{
throw new RestException(405, $this->contract->error);
}
}
/**
@ -471,9 +471,9 @@ class Contracts extends DolibarrApi
* @return int
*/
function put($id, $request_data = null) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {

View File

@ -503,19 +503,19 @@ if (! empty($force_install_message))
name="db_pass_root"
class="needroot"
value="<?php
// If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1.
$autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : @$db_pass_root);
if (!empty($dolibarr_main_prod)) {
$autofill = '';
}
// Do not autofill password if instance is a production instance
if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"],
array('127.0.0.1', 'localhost', 'localhostgit'))
) {
$autofill = '';
} // Do not autofill password for remote access
print dol_escape_htmltag($autofill);
?>"
// If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1.
$autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : @$db_pass_root);
if (!empty($dolibarr_main_prod)) {
$autofill = '';
}
// Do not autofill password if instance is a production instance
if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"],
array('127.0.0.1', 'localhost', 'localhostgit'))
) {
$autofill = '';
} // Do not autofill password for remote access
print dol_escape_htmltag($autofill);
?>"
<?php if ($force_install_noedit > 0 && ! empty($force_install_databaserootpass)) {
print ' disabled'; // May be removed by javascript
} ?>

View File

@ -1453,7 +1453,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
* @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails)
* @param string $helppagename Name of wiki page for help ('' by default).
* Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage
* For other external page: http://server/url
* For other external page: http://server/url
* @return void
*/
function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $helppagename='')
@ -2071,4 +2071,3 @@ if (! function_exists("llxFooter"))
print "</html>\n";
}
}