diff --git a/.travis.yml b/.travis.yml
index 5e3f1511266..6dd9dd7dac3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@
# from Dolibarr GitHub repository.
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/
-# We use dist: precise to have php 5.3 available
+# We use dist: precise to have php 5.3 available
dist: trusty
sudo: required
@@ -20,7 +20,7 @@ addons:
# To use the last version of pgloader, we add repo of postgresql
- postgresql
- sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
- - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
+ - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
packages:
# We need a webserver to test the webservices
# Let's install Apache with.
@@ -101,7 +101,7 @@ before_install:
pgloader --version
echo
fi
-
+
install:
- |
echo "Updating Composer"
@@ -133,7 +133,7 @@ install:
- |
echo "Installing PHP CodeSniffer"
- composer -n require squizlabs/php_codesniffer ^2
+ composer -n require squizlabs/php_codesniffer ^3
echo
- |
@@ -195,7 +195,7 @@ before_script:
mysql --version | head -
mysql -e "SELECT VERSION();" | head -
echo
-
+
- |
echo "Setting up database"
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then
@@ -203,7 +203,7 @@ before_script:
mysql -e 'DROP DATABASE IF EXISTS travis;'
mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
- mysql -e 'FLUSH PRIVILEGES;'
+ mysql -e 'FLUSH PRIVILEGES;'
mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
fi
if [ "$DB" = 'postgresql' ]; then
@@ -384,4 +384,3 @@ after_failure:
# TODO: PostgreSQL log file
echo
fi
-
diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml
index 6619cf83754..c1136b668c5 100644
--- a/dev/setup/codesniffer/ruleset.xml
+++ b/dev/setup/codesniffer/ruleset.xml
@@ -4,6 +4,7 @@
Dolibarr coding standard.
build/html
+ build/aps
documents
htdocs/custom
htdocs/includes
@@ -14,40 +15,25 @@
-
+
-
+
0
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
- 0
-
-
- 0
-
+
+
+
+
+
+
+
+
+
+
+
@@ -147,7 +133,7 @@
0
-
+
@@ -163,7 +149,7 @@
0
-
+
@@ -186,7 +172,7 @@
0
-
+
0
@@ -206,14 +192,14 @@
0
-
+
0
-
-
-
-
+
5
-
+
0
0
-
+
@@ -254,11 +240,11 @@
0
-
+
0
-
+
0
@@ -328,14 +314,14 @@
0
-
+
0
-
+
0
@@ -343,7 +329,7 @@
0
-
+
@@ -363,6 +349,9 @@
0
+
+ 0
+
0
@@ -372,19 +361,19 @@
0
-
+
-
+
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index e52da47e11b..d43325f9c58 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -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];
}
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 7012b0ef800..2b8ebd57d06 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -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)) {
diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php
index 1bb17eb4352..f5303074e63 100644
--- a/htdocs/contrat/class/api_contracts.class.php
+++ b/htdocs/contrat/class/api_contracts.class.php
@@ -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 ) {
diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php
index 65699585f4a..b0ad770532b 100644
--- a/htdocs/core/db/Database.interface.php
+++ b/htdocs/core/db/Database.interface.php
@@ -196,7 +196,7 @@ interface Database
*
* @param string $query SQL query string
* @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
- * Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
+ * Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
* @return resource Resultset of answer
*/
diff --git a/htdocs/core/js/lib_photosresize.js b/htdocs/core/js/lib_photosresize.js
index 9c4c6671b1e..37fb21a4a01 100644
--- a/htdocs/core/js/lib_photosresize.js
+++ b/htdocs/core/js/lib_photosresize.js
@@ -21,10 +21,10 @@
/* Enable jcrop plugin onto id cropbox */
jQuery(function() {
- jQuery('#cropbox').Jcrop({
- onSelect: updateCoords,
- onChange: updateCoords
- });
+ jQuery('#cropbox').Jcrop({
+ onSelect: updateCoords,
+ onChange: updateCoords
+ });
});
/* Update fields that store new size */
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 3c308c2c12d..8fec9a5c160 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -35,12 +35,12 @@
* @param string $urloption More parameters on URL request
* @param int $minLength Minimum number of chars to trigger that Ajax search
* @param int $autoselect Automatic selection if just one value
- * @param array $ajaxoptions Multiple options array
- * Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done
- * Ex: array('disabled'=> )
- * Ex: array('show'=> )
- * Ex: array('update_textarea'=> )
- * Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax)
+ * @param array $ajaxoptions Multiple options array
+ * - Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done
+ * - Ex: array('disabled'=> )
+ * - Ex: array('show'=> )
+ * - Ex: array('update_textarea'=> )
+ * - Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax)
* @return string Script
*/
function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
@@ -622,4 +622,3 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=a
return $out;
}
-
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index ea1dbe237de..084c06a08e1 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -162,15 +162,15 @@ function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
*
* @param int $iSecond Number of seconds
* @param string $format Output format ('all': total delay days hour:min like "2 days 12:30",
- * 'allwithouthour': total delay days without hour part like "2 days",
- * 'allhourmin': total delay with format hours:min like "60:30",
- * 'allhour': total delay hours without min/sec like "60:30",
- * 'fullhour': total delay hour decimal like "60.5" for 60:30,
- * 'hour': only hours part "12",
- * 'min': only minutes part "30",
- * 'sec': only seconds part,
- * 'month': only month part,
- * 'year': only year part);
+ * - 'allwithouthour': total delay days without hour part like "2 days",
+ * - 'allhourmin': total delay with format hours:min like "60:30",
+ * - 'allhour': total delay hours without min/sec like "60:30",
+ * - 'fullhour': total delay hour decimal like "60.5" for 60:30,
+ * - 'hour': only hours part "12",
+ * - 'min': only minutes part "30",
+ * - 'sec': only seconds part,
+ * - 'month': only month part,
+ * - 'year': only year part);
* @param int $lengthOfDay Length of day (default 86400 seconds for 1 day, 28800 for 8 hour)
* @param int $lengthOfWeek Length of week (default 7)
* @return string Formated text of duration
@@ -964,4 +964,3 @@ function monthArray($outputlangs,$short=0)
return $montharray;
}
-
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 7fb0c645081..cf8c298f443 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -253,19 +253,19 @@ function GETPOSTISSET($paramname)
* Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder']
* Note: The property $user->default_values is loaded by main.php when loading the user.
*
- * @param string $paramname Name of parameter to found
- * @param string $check Type of check
- * ''=no check (deprecated)
- * 'none'=no check (only for param that should have very rich content)
- * 'int'=check it's numeric (integer or float)
- * 'intcomma'=check it's integer+comma ('1,2,3,4...')
- * 'alpha'=check it's text and sign
- * 'aZ'=check it's a-z only
- * 'aZ09'=check it's simple alpha string (recommended for keys)
- * 'array'=check it's array
- * 'san_alpha'=Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string)
- * 'nohtml', 'alphanohtml'=check there is no html content
- * 'custom'= custom filter specify $filter and $options)
+ * @param string $paramname Name of parameter to found
+ * @param string $check Type of check
+ * ''=no check (deprecated)
+ * 'none'=no check (only for param that should have very rich content)
+ * 'int'=check it's numeric (integer or float)
+ * 'intcomma'=check it's integer+comma ('1,2,3,4...')
+ * 'alpha'=check it's text and sign
+ * 'aZ'=check it's a-z only
+ * 'aZ09'=check it's simple alpha string (recommended for keys)
+ * 'array'=check it's array
+ * 'san_alpha'=Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string)
+ * 'nohtml', 'alphanohtml'=check there is no html content
+ * 'custom'= custom filter specify $filter and $options)
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie)
* @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
* @param mixed $options Options to pass to filter_var when $check is set to 'custom'
@@ -7174,11 +7174,11 @@ function dol_getmypid()
/**
* Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields)
*
- * @param string|string[] $fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR). Example: array("p.field1","p.field2")
- * @param string $value The value to look for.
+ * @param string|string[] $fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR). Example: array("p.field1","p.field2")
+ * @param string $value The value to look for.
* If param $mode is 0, can contains several keywords separated with a space or |
- * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2
- * or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2
+ * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2
+ * or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2
* If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000"
* If param $mode is 2, can contains a list of int id separated by comma like "1,3,4"
* If param $mode is 3, can contains a list of string separated by comma like "a,b,c"
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index d222e54703a..8df3f28da3e 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -377,8 +377,8 @@ class DolibarrModules // Can not be abstract, because we need to insta
*
* @param array $array_sql SQL requests to be executed when enabling module
* @param string $options String with options when disabling module:
- * 'noboxes' = Do not insert boxes
- * 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
+ * - 'noboxes' = Do not insert boxes
+ * - 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
*
* @return int 1 if OK, 0 if KO
*/
@@ -468,7 +468,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
*
* @param string[] $array_sql SQL requests to be executed when module is disabled
* @param string $options Options when disabling module:
- * 'newboxdefonly|noboxes' = We don't remove boxes.
+ * - 'newboxdefonly|noboxes' = We don't remove boxes.
*
* @return int 1 if OK, 0 if KO
*/
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index 5c50597195a..4cd4f6cb8a8 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -803,7 +803,7 @@ class ProductFournisseur extends Product
* @param int $showsuptitle Show "Supplier" into output string
* @param int $maxlen Max length of name
* @param integer $notooltip 1=Disable tooltip
- * @param array $productFournList list of ProductFournisseur objects
+ * @param array $productFournList list of ProductFournisseur objects
* to display in table format.
* @return string String with supplier price
*/
@@ -850,4 +850,3 @@ class ProductFournisseur extends Product
}
}
-
diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php
index cee5d181d45..26f4043ffe9 100644
--- a/htdocs/install/fileconf.php
+++ b/htdocs/install/fileconf.php
@@ -503,19 +503,19 @@ if (! empty($force_install_message))
name="db_pass_root"
class="needroot"
value=""
+ // 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);
+ ?>"
0 && ! empty($force_install_databaserootpass)) {
print ' disabled'; // May be removed by javascript
} ?>
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 797298c4653..acb04734234 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -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='')
@@ -1653,7 +1653,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
* @param array $menu_array_before Table of menu entries to show before entries of menu handler. This param is deprectaed and must be provided to ''.
* @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
* @param string $notused Deprecated. Used in past to add content into left menu. Hooks can be used now.
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
* @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules.
@@ -2071,4 +2071,3 @@ if (! function_exists("llxFooter"))
print "