diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php
index 176c816d18c..d067d6e2ad6 100644
--- a/htdocs/api/class/api_access.class.php
+++ b/htdocs/api/class/api_access.class.php
@@ -107,7 +107,7 @@ class DolibarrApiAccess implements iAuthenticate
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.api_key = '".$db->escape($api_key)."'";
// TODO Check if 2 users has same API key.
-
+
$result = $db->query($sql);
if ($result)
{
@@ -118,9 +118,12 @@ class DolibarrApiAccess implements iAuthenticate
$stored_key = $obj->api_key;
$userentity = $obj->entity;
- if (! defined("DOLENTITY")) // If API was not forced with HTTP_DOLENTITY, we set entity to entity of user
+ if (! defined("DOLENTITY") && $conf->entity != ($obj->entity?$obj->entity:1)) // If API was not forced with HTTP_DOLENTITY, and user is on another entity, so we reset entity to entity of user
{
$conf->entity = ($obj->entity?$obj->entity:1);
+ // We must also reload global conf to get params from the entity
+ dol_syslog("Entity was not set on http header with HTTP_DOLAPIENTITY (recommanded for performance purpose), so we switch now on entity of user (".$conf->entity .") and we have to reload configuration.", LOG_WARNING);
+ $conf->setValues($db);
}
}
}
diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index 248b1541f6c..21f284ebfe1 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -37,7 +37,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not lo
if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
-// Force entity if a value provided int HTTP header. Otherwise, will use the entity of user of token used.
+// Force entity if a value is provided into HTTP header. Otherwise, will use the entity of user of token used.
if (! empty($_SERVER['HTTP_DOLAPIENTITY'])) define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']);
diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php
index ea03bc0eb71..40af3d72292 100644
--- a/htdocs/comm/propal/class/api_proposals.class.php
+++ b/htdocs/comm/propal/class/api_proposals.class.php
@@ -257,39 +257,39 @@ class Proposals extends DolibarrApi
$request_data = (object) $request_data;
- $updateRes = $this->propal->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,
- 'HT',
- 0,
- $request_data->info_bits,
- $request_data->product_type,
- $request_data->rang,
- $request_data->special_code,
- $fk_parent_line,
- $request_data->fk_fournprice,
- $request_data->pa_ht,
- $request_data->label,
- $request_data->date_start,
- $request_data->date_end,
- $request_data->array_options,
- $request_data->fk_unit,
- $this->element,
- $request_data->id,
- $request_data->multicurrency_subprice,
- $request_data->fk_remise_except
- );
-
- if ($updateRes > 0) {
- return $updateRes;
+ $updateRes = $this->propal->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,
+ 'HT',
+ 0,
+ $request_data->info_bits,
+ $request_data->product_type,
+ $request_data->rang,
+ $request_data->special_code,
+ $fk_parent_line,
+ $request_data->fk_fournprice,
+ $request_data->pa_ht,
+ $request_data->label,
+ $request_data->date_start,
+ $request_data->date_end,
+ $request_data->array_options,
+ $request_data->fk_unit,
+ $request_data->origin,
+ $request_data->origin_id,
+ $request_data->multicurrency_subprice,
+ $request_data->fk_remise_except
+ );
+ if ($updateRes > 0) {
+ return $updateRes;
}
+
return false;
}
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index e0c2ca59835..19e70235e9e 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -569,28 +569,33 @@ class Propal extends CommonObject
// Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
- // Mise a jour informations denormalisees au niveau de la propale meme
- $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
- if ($result > 0)
- {
- $this->db->commit();
- return $this->line->rowid;
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$this->line->error;
- $this->db->rollback();
- return -2;
- }
+ // Mise a jour informations denormalisees au niveau de la propale meme
+ $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return $this->line->rowid;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$this->line->error;
+ $this->db->rollback();
+ return -2;
+ }
+ }
+ else
+ {
+ dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
+ return -3;
}
- }
+ }
/**
@@ -955,13 +960,55 @@ class Propal extends CommonObject
$resql=$this->db->query($sql);
if (! $resql) $error++;
- /*
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $tmp_origin_id)
+ {
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
+ {
+ $origin_id = $tmp_origin_id;
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ }
+
+ // Add linked object (deprecated, use ->linkedObjectsIds instead)
+ if (! $error && $this->origin && $this->origin_id)
+ {
+ $ret = $this->add_object_linked();
+ if (! $ret) dol_print_error($this->db);
+ }
+
+ /*
* Insertion du detail des produits dans la base
- */
- if (! $error)
- {
- $fk_parent_line=0;
- $num=count($this->lines);
+ */
+ if (! $error)
+ {
+ $fk_parent_line=0;
+ $num=count($this->lines);
for ($i=0;$i<$num;$i++)
{
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index cec9e5dc8f7..e31aaa4e060 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -52,9 +52,9 @@ class Orders extends DolibarrApi
}
/**
- * Get properties of a commande object
+ * Get properties of an order object
*
- * Return an array with commande informations
+ * Return an array with order informations
*
* @param int $id ID of order
* @return array|mixed data without useless information
@@ -176,7 +176,7 @@ class Orders extends DolibarrApi
* Create order object
*
* @param array $request_data Request data
- * @return int ID of commande
+ * @return int ID of order
*/
function post($request_data = NULL)
{
@@ -196,6 +196,7 @@ class Orders extends DolibarrApi
}
$this->commande->lines = $lines;
}*/
+
if ($this->commande->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->commande->error), $this->commande->errors));
}
@@ -236,8 +237,8 @@ class Orders extends DolibarrApi
/**
* Add a line to given order
*
- * @param int $id Id of commande to update
- * @param array $request_data Orderline data
+ * @param int $id Id of order to update
+ * @param array $request_data OrderLine data
*
* @url POST {id}/lines
*
@@ -281,8 +282,9 @@ class Orders extends DolibarrApi
$request_data->label,
$request_data->array_options,
$request_data->fk_unit,
- $this->element,
- $request_data->id
+ $request_data->origin,
+ $request_data->origin_id,
+ $request_data->multicurrency_subprice
);
if ($updateRes > 0) {
@@ -295,9 +297,9 @@ class Orders extends DolibarrApi
/**
* Update a line to given order
*
- * @param int $id Id of commande to update
+ * @param int $id Id of order to update
* @param int $lineid Id of line to update
- * @param array $request_data Orderline data
+ * @param array $request_data OrderLine data
*
* @url PUT {id}/lines/{lineid}
*
@@ -310,7 +312,7 @@ class Orders extends DolibarrApi
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Commande not found');
+ throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
@@ -338,7 +340,8 @@ class Orders extends DolibarrApi
$request_data->label,
$request_data->special_code,
$request_data->array_options,
- $request_data->fk_unit
+ $request_data->fk_unit,
+ $request_data->multicurrency_subprice
);
if ($updateRes > 0) {
@@ -399,7 +402,7 @@ class Orders extends DolibarrApi
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Commande not found');
+ throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index d3f2feac763..e475615a3d1 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -877,6 +877,11 @@ class Commande extends CommonOrder
{
$this->ref = $initialref;
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
// Add object linked
if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
{
@@ -889,7 +894,7 @@ class Commande extends CommonOrder
$ret = $this->add_object_linked($origin, $origin_id);
if (! $ret)
{
- dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
$error++;
}
}
@@ -900,7 +905,7 @@ class Commande extends CommonOrder
$ret = $this->add_object_linked($origin, $origin_id);
if (! $ret)
{
- dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
$error++;
}
}
@@ -1434,10 +1439,10 @@ class Commande extends CommonOrder
return -2;
}
}
- else
- {
+ else
+ {
dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
- return -3;
+ return -3;
}
}
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index ca6a4cec0c4..f7e5162d673 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -15,9 +15,9 @@
* along with this program. If not, see .
*/
- use Luracast\Restler\RestException;
+use Luracast\Restler\RestException;
- require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
/**
* API class for invoices
@@ -75,6 +75,7 @@ class Invoices extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
+ $this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
}
@@ -210,6 +211,190 @@ class Invoices extends DolibarrApi
return $this->invoice->id;
}
+ /**
+ * Get lines of an invoice
+ *
+ * @param int $id Id of invoice
+ *
+ * @url GET {id}/lines
+ *
+ * @return int
+ */
+ function getLines($id) {
+ if(! DolibarrApiAccess::$user->rights->facture->lire) {
+ throw new RestException(401);
+ }
+
+ $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);
+ }
+ $this->invoice->getLinesArray();
+ $result = array();
+ foreach ($this->invoice->lines as $line) {
+ array_push($result,$this->_cleanObjectDatas($line));
+ }
+ return $result;
+ }
+
+ /**
+ * Add a line to a given invoice
+ *
+ * @param int $id Id of invoice to update
+ * @param array $request_data InvoiceLine data
+ *
+ * @url POST {id}/lines
+ *
+ * @return int
+ */
+ function postLine($id, $request_data = NULL) {
+ if(! DolibarrApiAccess::$user->rights->facture->creer) {
+ throw new RestException(401);
+ }
+
+ $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);
+ }
+ $request_data = (object) $request_data;
+ $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,
+ 0,
+ $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,
+ $fk_parent_line,
+ $request_data->fk_fournprice,
+ $request_data->pa_ht,
+ $request_data->label,
+ $request_data->array_options,
+ $request_data->situation_percent,
+ $request_data->prev_id,
+ $request_data->fk_unit,
+ $request_data->multicurrency_subprice
+ );
+
+ if ($updateRes > 0) {
+ return $updateRes;
+
+ }
+ return false;
+ }
+
+ /**
+ * Update a line to a given invoice
+ *
+ * @param int $id Id of invoice to update
+ * @param int $lineid Id of line to update
+ * @param array $request_data InvoiceLine data
+ *
+ * @url PUT {id}/lines/{lineid}
+ *
+ * @return object
+ */
+ function putLine($id, $lineid, $request_data = NULL) {
+ if(! DolibarrApiAccess::$user->rights->facture->creer) {
+ throw new RestException(401);
+ }
+
+ $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);
+ }
+ $request_data = (object) $request_data;
+ $updateRes = $this->invoice->updateline(
+ $lineid,
+ $request_data->desc,
+ $request_data->subprice,
+ $request_data->qty,
+ $request_data->remise_percent,
+ $request_data->date_start,
+ $request_data->date_end,
+ $request_data->tva_tx,
+ $request_data->localtax1_tx,
+ $request_data->localtax2_tx,
+ 'HT',
+ $request_data->info_bits,
+ $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->situation_percent,
+ $request_data->fk_unit,
+ $request_data->multicurrency_subprice
+ );
+
+ if ($updateRes > 0) {
+ $result = $this->get($id);
+ unset($result->line);
+ return $this->_cleanObjectDatas($result);
+ }
+ return false;
+ }
+
+ /**
+ * Delete a line to a given invoice
+ *
+ *
+ * @param int $id Id of invoice to update
+ * @param int $lineid Id of line to delete
+ *
+ * @url DELETE {id}/lines/{lineid}
+ *
+ * @return int
+ */
+ function delLine($id, $lineid) {
+ if(! DolibarrApiAccess::$user->rights->facture->creer) {
+ throw new RestException(401);
+ }
+
+ $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);
+ }
+ $request_data = (object) $request_data;
+ $updateRes = $this->invoice->deleteline($lineid);
+ if ($updateRes > 0) {
+ return $this->get($id);
+ }
+ return false;
+ }
+
/**
* Update invoice
*
@@ -482,7 +667,7 @@ class Invoices extends DolibarrApi
/**
* Validate an invoice
*
- * @param int $id Order ID
+ * @param int $id Invoice ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index dd42c8d3fb7..b46c249d1b0 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -201,19 +201,40 @@ class FactureRec extends CommonInvoice
}
}
- // Add object linked
- if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
- {
- foreach($this->linked_objects as $origin => $origin_id)
- {
- $ret = $this->add_object_linked($origin, $origin_id);
- if (! $ret)
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- }
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $tmp_origin_id)
+ {
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
+ {
+ $origin_id = $tmp_origin_id;
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ }
if ($error)
{
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 5921a5f0a12..c38eef5940f 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -448,6 +448,11 @@ class Facture extends CommonInvoice
$resql=$this->db->query($sql);
if (! $resql) $error++;
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
// Add object linked
if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
{
@@ -460,7 +465,7 @@ class Facture extends CommonInvoice
$ret = $this->add_object_linked($origin, $origin_id);
if (! $ret)
{
- dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
$error++;
}
}
@@ -471,7 +476,7 @@ class Facture extends CommonInvoice
$ret = $this->add_object_linked($origin, $origin_id);
if (! $ret)
{
- dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
$error++;
}
}
@@ -2688,6 +2693,11 @@ class Facture extends CommonInvoice
return -2;
}
}
+ else
+ {
+ dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
+ return -3;
+ }
}
/**
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index d54c2b521ff..5c350b9cb60 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -1008,7 +1008,12 @@ class Contrat extends CommonObject
if (! $error)
{
- // Add object linked
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
{
foreach($this->linked_objects as $origin => $tmp_origin_id)
@@ -1020,7 +1025,7 @@ class Contrat extends CommonObject
$ret = $this->add_object_linked($origin, $origin_id);
if (! $ret)
{
- dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
$error++;
}
}
@@ -1031,7 +1036,7 @@ class Contrat extends CommonObject
$ret = $this->add_object_linked($origin, $origin_id);
if (! $ret)
{
- dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
$error++;
}
}
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 4aec6179365..0e9d405d44c 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -322,14 +322,14 @@ if (! $error && $massaction == 'confirm_presend')
$replyto = $from;
$subject = GETPOST('subject','none');
$message = GETPOST('message','none');
- $sendtocc = GETPOST('sentocc');
- $sendtobcc = '';
- if ($objectclass == 'Propale') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO);
- if ($objectclass == 'Commande') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO);
- if ($objectclass == 'Facture') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO);
- if ($objectclass == 'Supplier_Proposal') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO);
- if ($objectclass == 'CommandeFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO);
- if ($objectclass == 'FactureFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO);
+
+ $sendtobcc = GETPOST('sendtoccc');
+ if ($objectclass == 'Propale') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
+ if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
+ if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
+ if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
+ if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
+ if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
// $listofqualifiedid is array with key = object id of qualified objects for the current thirdparty
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
index 539d5df8c2a..4bdc083228e 100644
--- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
+++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
@@ -150,7 +150,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
$texte.='
';
}
-
+
$texte.= '';
$texte.= '
';
@@ -272,53 +272,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
//print $odfHandler->__toString()."\n";
- // Make substitutions into odt of user info
- $tmparray=$this->get_substitutionarray_user($user,$outputlangs);
- //var_dump($tmparray); exit;
- foreach($tmparray as $key=>$value)
- {
- try {
- if (preg_match('/logo$/',$key)) // Image
- {
- //var_dump($value);exit;
- if (file_exists($value)) $odfHandler->setImage($key, $value);
- else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- }
- else // Text
- {
- //print $key.' '.$value;exit;
- $odfHandler->setVars($key, $value, true, 'UTF-8');
- }
- }
- catch(OdfException $e)
- {
- // setVars failed, probably because key not found
- }
- }
- // Make substitutions into odt of mysoc info
- $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
- //var_dump($tmparray); exit;
- foreach($tmparray as $key=>$value)
- {
- try {
- if (preg_match('/logo$/',$key)) // Image
- {
- //var_dump($value);exit;
- if (file_exists($value)) $odfHandler->setImage($key, $value);
- else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- }
- else // Text
- {
- $odfHandler->setVars($key, $value, true, 'UTF-8');
- }
- }
- catch(OdfException $e)
- {
- // setVars failed, probably because key not found
- }
- }
-
-
// Replace tags of lines for contacts
$contact_arrray=array();
@@ -333,7 +286,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
if ($num)
{
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
-
+
$i=0;
$contactstatic = new Contact($this->db);
@@ -380,13 +333,18 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
}
- // Make substitutions into odt of thirdparty + external modules
- $tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs);
+ // Make substitutions into odt
+ $array_user=$this->get_substitutionarray_user($user,$outputlangs);
+ $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
+ $array_thirdparty=$this->get_substitutionarray_thirdparty($object,$outputlangs);
+ $array_other=$this->get_substitutionarray_other($outputlangs);
+
+ $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
- $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Replace variables into document
foreach($tmparray as $key=>$value)
@@ -438,13 +396,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$odfHandler->creator = $user->getFullName($outputlangs);
$odfHandler->title = $object->builddoc_filename;
$odfHandler->subject = $object->builddoc_filename;
-
+
if (! empty($conf->global->ODT_ADD_DOLIBARR_ID))
{
$odfHandler->userdefined['dol_id'] = $object->id;
$odfHandler->userdefined['dol_element'] = $object->element;
}
-
+
$odfHandler->saveToDisk($file);
}catch (Exception $e){
$this->error=$e->getMessage();
@@ -453,7 +411,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
-
+
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index cf1c7afad9c..32e11c871e9 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -3,7 +3,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2007 Franky Van Liedekerke
* Copyright (C) 2006-2012 Laurent Destailleur
- * Copyright (C) 2011-2016 Juanjo Menent
+ * Copyright (C) 2011-2017 Juanjo Menent
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014 Cedric GROSS
* Copyright (C) 2014-2015 Marcos GarcĂa
@@ -1400,10 +1400,13 @@ class Expedition extends CommonObject
$line->pa_ht = $obj->pa_ht;
+ // Local taxes
$localtax_array=array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx);
+ $localtax1_tx = get_localtax($obj->tva_tx, 1, $this->thirdparty);
+ $localtax2_tx = get_localtax($obj->tva_tx, 2, $this->thirdparty);
// For invoicing
- $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0
+ $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0
$line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements)
$line->qty = $line->qty_shipped;
$line->total_ht = $tabprice[0];
diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php
index 12d2117bfd7..4a2c5876b0e 100644
--- a/htdocs/fourn/class/api_supplier_invoices.class.php
+++ b/htdocs/fourn/class/api_supplier_invoices.class.php
@@ -76,6 +76,7 @@ class SupplierInvoices extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
+ $this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
}
diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php
index dbe3cf79c01..1dce6cd3ef4 100644
--- a/htdocs/fourn/class/api_supplier_orders.class.php
+++ b/htdocs/fourn/class/api_supplier_orders.class.php
@@ -76,6 +76,7 @@ class SupplierOrders extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
+ $this->order->fetchObjectLinked();
return $this->_cleanObjectDatas($this->order);
}
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index e835130de4a..12d29cb7eb2 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1235,23 +1235,44 @@ class CommandeFournisseur extends CommonOrder
{
// Add link with price request and supplier order
if ($this->id)
- {
- $this->ref="(PROV".$this->id.")";
+ {
+ $this->ref="(PROV".$this->id.")";
- // Add object linked
- if (is_array($this->linked_objects) && ! empty($this->linked_objects))
- {
- foreach($this->linked_objects as $origin => $origin_id)
- {
- $ret = $this->add_object_linked($origin, $origin_id);
- if (! $ret)
- {
- dol_print_error($this->db);
- $error++;
- }
- }
- }
- }
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $tmp_origin_id)
+ {
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ dol_print_error($this->db);
+ $error++;
+ }
+ }
+ }
+ else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
+ {
+ $origin_id = $tmp_origin_id;
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ dol_print_error($this->db);
+ $error++;
+ }
+ }
+ }
+ }
+ }
if (! $error)
{
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index e813268b8b2..8f7ed4af9f1 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -306,7 +306,42 @@ class FactureFournisseur extends CommonInvoice
$resql=$this->db->query($sql);
if (! $resql) $error++;
- // Add object linked
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $tmp_origin_id)
+ {
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ dol_print_error($this->db);
+ $error++;
+ }
+ }
+ }
+ else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
+ {
+ $origin_id = $tmp_origin_id;
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ dol_print_error($this->db);
+ $error++;
+ }
+ }
+ }
+ }
+
+ // Add linked object (deprecated, use ->linkedObjectsIds instead)
if (! $error && $this->id && ! empty($this->origin) && ! empty($this->origin_id))
{
$ret = $this->add_object_linked();
diff --git a/htdocs/index.php b/htdocs/index.php
index f8e90919c6a..0bbdbb0fbad 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -265,23 +265,23 @@ if (empty($user->societe_id))
// Dashboard Link lines
$links=array(
DOL_URL_ROOT.'/user/index.php',
- DOL_URL_ROOT.'/societe/list.php?type=c',
- DOL_URL_ROOT.'/societe/list.php?type=p',
- DOL_URL_ROOT.'/societe/list.php?type=f',
- DOL_URL_ROOT.'/contact/list.php',
+ DOL_URL_ROOT.'/societe/list.php?type=c&mainmenu=companies',
+ DOL_URL_ROOT.'/societe/list.php?type=p&mainmenu=companies',
+ DOL_URL_ROOT.'/societe/list.php?type=f&mainmenu=companies',
+ DOL_URL_ROOT.'/contact/list.php?mainmenu=companies',
DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members',
DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products',
DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products',
- DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial',
- DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial',
- DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy',
- DOL_URL_ROOT.'/contrat/list.php',
- DOL_URL_ROOT.'/fichinter/list.php',
- DOL_URL_ROOT.'/fourn/commande/list.php',
- DOL_URL_ROOT.'/fourn/facture/list.php',
- DOL_URL_ROOT.'/supplier_proposal/list.php',
+ DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial&leftmenu=propals',
+ DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial&leftmenu=orders',
+ DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy&leftmenu=customers_bills',
+ DOL_URL_ROOT.'/contrat/list.php?mainmenu=commercial&leftmenu=contracts',
+ DOL_URL_ROOT.'/fichinter/list.php?mainmenu=commercial&leftmenu=ficheinter',
+ DOL_URL_ROOT.'/fourn/commande/list.php?mainmenu=commercial&leftmenu=orders_suppliers',
+ DOL_URL_ROOT.'/fourn/facture/list.php?mainmenu=accountancy&leftmenu=suppliers_bills',
+ DOL_URL_ROOT.'/supplier_proposal/list.php?mainmenu=commercial&leftmenu=',
DOL_URL_ROOT.'/projet/list.php?mainmenu=project',
- DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm',
+ DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&leftmenu=expensereport',
DOL_URL_ROOT.'/don/list.php?leftmenu=donations'
);
// Translation lang files
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index 29f48f03d35..edaaecc9cc7 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -848,9 +848,41 @@ class SupplierProposal extends CommonObject
$resql=$this->db->query($sql);
if (! $resql) $error++;
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $tmp_origin_id)
+ {
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ dol_print_error($this->db);
+ $error++;
+ }
+ }
+ }
+ }
+ }
+
+ // Add linked object (deprecated, use ->linkedObjectsIds instead)
+ if (! $error && $this->origin && $this->origin_id)
+ {
+ $ret = $this->add_object_linked();
+ if (! $ret) dol_print_error($this->db);
+ }
+
/*
* Insertion du detail des produits dans la base
- */
+ */
if (! $error)
{
$fk_parent_line=0;
@@ -903,13 +935,6 @@ class SupplierProposal extends CommonObject
}
}
- // Add linked object
- if (! $error && $this->origin && $this->origin_id)
- {
- $ret = $this->add_object_linked();
- if (! $ret) dol_print_error($this->db);
- }
-
if (! $error)
{
// Mise a jour infos denormalisees
diff --git a/htdocs/theme/eldy/img/statut9.png b/htdocs/theme/eldy/img/statut9.png
index e5304dd791b..49397d25520 100644
Binary files a/htdocs/theme/eldy/img/statut9.png and b/htdocs/theme/eldy/img/statut9.png differ
diff --git a/htdocs/theme/eldy/img/statut9_40x40.png b/htdocs/theme/eldy/img/statut9_40x40.png
index 445eac35387..ab82e6dfe30 100644
Binary files a/htdocs/theme/eldy/img/statut9_40x40.png and b/htdocs/theme/eldy/img/statut9_40x40.png differ
|