diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index e0c3c00adad..f5ea791a02d 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1863,9 +1863,9 @@ class Commande extends CommonOrder
/**
* Load array this->expeditions of lines of shipments with nb of products sent for each order line
- * Note: For a dedicated shipment, the fetch_lines load the qty_asked and qty_shipped. This function return qty_shipped cuulated for order
+ * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
*
- * @param int $filtre_statut Filter on status
+ * @param int $filtre_statut Filter on shipment status
* @return int <0 if KO, Nb of lines found if OK
*/
function loadExpeditions($filtre_statut=-1)
@@ -1934,21 +1934,6 @@ class Commande extends CommonOrder
else dol_print_error($this->db);
}
- /**
- * Return a array with sendings by line
- *
- * @param int $filtre_statut Filtre sur statut
- * @return int 0 si OK, <0 si KO
- *
- * TODO deprecate, move to Shipping class
- */
- function livraison_array($filtre_statut=self::STATUS_CANCELED)
- {
- $delivery = new Livraison($this->db);
- $deliveryArray = $delivery->livraison_array($filtre_statut);
- return $deliveryArray;
- }
-
/**
* Return a array with the pending stock by product
*
diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php
index 584d4ecfc7d..b673a5064ed 100644
--- a/htdocs/compta/sociales/index.php
+++ b/htdocs/compta/sociales/index.php
@@ -69,7 +69,7 @@ else
$typeid=$_REQUEST['typeid'];
}
-if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
+if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_ref="";
$search_label="";
@@ -211,6 +211,8 @@ if ($resql)
print '';
print "\n";
+ $i=0;
+ $totalarray=array();
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($resql);
@@ -244,8 +246,12 @@ if ($resql)
}
print '';
+ // Amount
print '
'.price($obj->amount).' | ';
-
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
+ $totalarray['totalttc'] += $obj->amount;
+
// Due date
print ''.dol_print_date($db->jdate($obj->date_ech), 'day').' | ';
@@ -257,6 +263,22 @@ if ($resql)
$i++;
}
+ // Show total line
+ if (isset($totalarray['totalttcfield']))
+ {
+ print '';
+ if ($num < $limit) print '| '.$langs->trans("Total").' | ';
+ else print ''.$langs->trans("Totalforthispage").' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print ''.price($totalarray['totalttc']).' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print '
';
+ }
+
print '';
}
print '';
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 1e29a2a36f6..ca6abb40e5c 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -93,6 +93,13 @@ class Expedition extends CommonObject
var $meths;
var $listmeths; // List of carriers
+
+ const STATUS_DRAFT = 0;
+ const STATUS_VALIDATED = 1;
+ const STATUS_CLOSED = 2;
+
+
+
/**
* Constructor
*
@@ -1794,9 +1801,9 @@ class Expedition extends CommonObject
}
/**
- * Classify the shipping as closed
+ * Classify the shipping as closed.
*
- * @return int <0 if ko, >0 if ok
+ * @return int <0 if KO, >0 if OK
*/
function setClosed()
{
@@ -1806,15 +1813,43 @@ class Expedition extends CommonObject
$this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut='.self::STATUS_CLOSED;
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
$resql=$this->db->query($sql);
if ($resql)
{
- // TODO: Add option/checkbox to set order billed if 100% of order is shipped
- $this->statut=2;
+ // Set order billed if 100% of order is shipped (qty in shipment lines match qty in order lines)
+ if ($this->origin == 'commande' && $this->origin_id > 0)
+ {
+ $order = new Commande($this->db);
+ $order->fetch($this->origin_id);
+
+ $order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty)
+
+ $shipments_match_order = 1;
+ foreach($order->lines as $line)
+ {
+ $lineid = $line->id;
+ $qty = $line->qty;
+ if (($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->expeditions[$lineid] != $qty)
+ {
+ $shipments_match_order = 0;
+ $text='Qty for order line id '.$lineid.' is '.$qty.' but in shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.', we have '.$order->expeditions[$lineid].' so we can t close order';
+ dol_syslog($text);
+ break;
+ }
+ }
+ if ($shipments_match_order)
+ {
+ dol_syslog("Qty for the ".count($order->lines)." lines of order have same value for shipments with status Expedition::STATUS_CLOSED=".self::STATUS_CLOSED.', so we close order');
+ $order->cloture($user);
+ }
+ }
+
+ $this->statut=self::STATUS_CLOSED;
+
// If stock increment is done on closing
if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE))
{
@@ -1823,7 +1858,7 @@ class Expedition extends CommonObject
$langs->load("agenda");
// Loop on each product line to add a stock movement
- // TODO possibilite d'expedier a partir d'une propale ou autre origine
+ // TODO possibilite d'expedier a partir d'une propale ou autre origine ?
$sql = "SELECT cd.fk_product, cd.subprice,";
$sql.= " ed.rowid, ed.qty, ed.fk_entrepot,";
$sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock";
diff --git a/htdocs/install/mysql/tables/llx_element_lock.sql b/htdocs/install/mysql/tables/llx_element_lock.sql
deleted file mode 100644
index 155deba9169..00000000000
--- a/htdocs/install/mysql/tables/llx_element_lock.sql
+++ /dev/null
@@ -1,27 +0,0 @@
--- ============================================================================
--- Copyright (C) 2011 Regis Houssin
---
--- This program is free software; you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation; either version 3 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program. If not, see .
---
--- ============================================================================
-
-create table llx_element_lock
-(
- rowid integer AUTO_INCREMENT PRIMARY KEY,
- fk_element integer NOT NULL,
- elementtype varchar(32) NOT NULL,
- datel datetime, -- date of lock
- datem datetime, -- date of unlock/modif
- sessionid varchar(255)
-)ENGINE=innodb;
diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang
index 1ec229af6c5..c35aa71c8a1 100644
--- a/htdocs/langs/en_US/sendings.lang
+++ b/htdocs/langs/en_US/sendings.lang
@@ -72,6 +72,7 @@ ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from opened suppli
NoProductToShipFoundIntoStock=No product to ship found into warehouse %s. Correct stock or go back to choose another warehouse.
WeightVolShort=Weight/Vol.
ValidateOrderFirstBeforeShipment=You must first validate the order before being able to make shipments.
+CloseShippeOrdersAutomatically=Classify the order "Delivered" if entirely shipped.
# Sending methods
SendingMethodCATCH=Catch by customer
diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php
index 9ae66ee685e..7b47c17f5c7 100644
--- a/htdocs/livraison/card.php
+++ b/htdocs/livraison/card.php
@@ -300,213 +300,7 @@ $formfile = new FormFile($db);
if ($action == 'create') // Seems to no be used
{
- print load_fiche_titre($langs->trans("CreateADeliveryOrder"));
-
- if ($mesg)
- {
- print $mesg.'
';
- }
-
- $commande = new Commande($db);
- $commande->livraison_array();
-
- if ($commande->fetch(GETPOST("commande_id")))
- {
- $soc = new Societe($db);
- $soc->fetch($commande->socid);
- $author = new User($db);
- $author->fetch($commande->user_author_id);
-
- if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
- {
- $entrepot = new Entrepot($db);
- }
-
- /*
- * Commande
- */
- print '';
- }
- else
- {
- dol_print_error($db);
- }
+
}
else
/* *************************************************************************** */
diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php
index 913fc40e40b..15e44f8602d 100644
--- a/htdocs/product/composition/card.php
+++ b/htdocs/product/composition/card.php
@@ -116,13 +116,14 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se
else if($action==='save_composed_product')
{
$TProduct = GETPOST('TProduct', 'array');
- if(!empty($TProduct))
+ if (!empty($TProduct))
{
foreach ($TProduct as $id_product => $row)
{
if ($row['qty'] > 0) $object->update_sousproduit($id, $id_product, $row['qty'], isset($row['incdec']) ? 1 : 0 );
else $object->del_sousproduit($id, $id_product);
}
+ setEventMessages('RecordSaved', null);
}
$action='';
}
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 4584c8b8a2f..ce2ff974013 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -664,10 +664,11 @@ if ($resql)
else print $langs->trans('PrivateProject');
print '';
}
+ // Amount
if (! empty($arrayfields['p.opp_amount']['checked']))
{
print '';
- if ($obj->opp_status_code) print price($obj->opp_amount, 1, '', 1, -1, -1, $conf->currency);
+ if ($obj->opp_status_code) print price($obj->opp_amount, 1, '', 1, -1, -1, '');
print ' | ';
}
if (! empty($arrayfields['p.fk_opp_status']['checked']))