';
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 756613d6a8f..6158848ceed 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -1644,7 +1644,7 @@ else if ($id > 0 || ! empty($ref))
{
print '
';
}
// create intervention model
@@ -1663,7 +1663,7 @@ else if ($id > 0 || ! empty($ref))
if ($object->statut < Fichinter::STATUS_BILLED)
{
if ($user->rights->propal->creer) print '
';
}
}
@@ -1674,7 +1674,7 @@ else if ($id > 0 || ! empty($ref))
if ($object->statut < Fichinter::STATUS_BILLED)
{
if ($user->rights->facture->creer) print '
';
}
if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php
index c26e642a651..85f92f55f85 100644
--- a/htdocs/fichinter/list.php
+++ b/htdocs/fichinter/list.php
@@ -269,6 +269,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
+ 'generate_doc'=>$langs->trans("Generate"),
//'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 235a3c85396..f017cce90ab 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -780,7 +780,7 @@ if ($object->id > 0)
{
if ($object->status != 1)
{
- print '
';
}
if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer)
@@ -792,7 +792,7 @@ if ($object->id > 0)
}
else
{
- print '
';
}
}
@@ -805,7 +805,7 @@ if ($object->id > 0)
}
else
{
- print '
';
}
}
@@ -818,7 +818,7 @@ if ($object->id > 0)
}
else
{
- print '
';
}
}
@@ -832,10 +832,10 @@ if ($object->id > 0)
}
else
{
- print '
';
}
// Add action
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 9f17e9afdf2..8dc10d82b3b 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -3146,6 +3146,54 @@ class CommandeFournisseur extends CommonOrder
}
return 0;
}
+
+ /**
+ * Load array this->receptions of lines of shipments with nb of products sent for each order line
+ * 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 shipment status
+ * @return int <0 if KO, Nb of lines found if OK
+ */
+ function loadReceptions($filtre_statut=-1)
+ {
+ $this->receptions = array();
+
+ $sql = 'SELECT cd.rowid, cd.fk_product,';
+ $sql.= ' sum(cfd.qty) as qty';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as cfd,';
+ if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'reception as e,';
+ $sql.= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
+ $sql.= ' WHERE';
+ if ($filtre_statut >= 0) $sql.= ' cfd.fk_reception = e.rowid AND';
+ $sql.= ' cfd.fk_commandefourndet = cd.rowid';
+ $sql.= ' AND cd.fk_commande =' .$this->id;
+ if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product;
+ if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut;
+ $sql.= ' GROUP BY cd.rowid, cd.fk_product';
+
+
+ dol_syslog(get_class($this)."::loadReceptions", LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $num = $this->db->num_rows($result);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+ empty($this->receptions[$obj->rowid])?$this->receptions[$obj->rowid] = $obj->qty:$this->receptions[$obj->rowid] += $obj->qty;
+ $i++;
+ }
+ $this->db->free();
+
+ return $num;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
}
diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
index c7b5d00c797..9bc6ec3fbc3 100644
--- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
@@ -25,6 +25,7 @@
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
+require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php";
//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
@@ -136,7 +137,7 @@ class CommandeFournisseurDispatch extends CommonObject
*/
function create($user, $notrigger=0)
{
- global $conf, $langs;
+ global $conf, $langs, $hookmanager;
$error=0;
// Clean parameters
@@ -150,6 +151,8 @@ class CommandeFournisseurDispatch extends CommonObject
if (isset($this->comment)) $this->comment=trim($this->comment);
if (isset($this->status)) $this->status=trim($this->status);
if (isset($this->batch)) $this->batch=trim($this->batch);
+ if(empty($this->datec)) $this->datec = dol_now();
+
// Check parameters
// Put here code to add control on parameters values
@@ -167,7 +170,10 @@ class CommandeFournisseurDispatch extends CommonObject
$sql.= "status,";
$sql.= "batch,";
$sql.= "eatby,";
- $sql.= "sellby";
+ $sql.= "sellby,";
+ $sql.= "fk_reception";
+
+
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->fk_commande)?'NULL':"'".$this->db->escape($this->fk_commande)."'").",";
$sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->db->escape($this->fk_product)."'").",";
@@ -180,7 +186,8 @@ class CommandeFournisseurDispatch extends CommonObject
$sql.= " ".(! isset($this->status)?'NULL':"'".$this->db->escape($this->status)."'").",";
$sql.= " ".(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").",";
$sql.= " ".(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").",";
- $sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'")."";
+ $sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'").",";
+ $sql.= " ".(! isset($this->fk_reception)?'NULL':"'".$this->db->escape($this->fk_reception)."'")."";
$sql.= ")";
$this->db->begin();
@@ -205,6 +212,24 @@ class CommandeFournisseurDispatch extends CommonObject
}
}
+ // Actions on extra fields (by external module or standard code)
+ // TODO le hook fait double emploi avec le trigger !!
+ $hookmanager->initHooks(array('commandefournisseurdispatchdao'));
+ $parameters=array('id'=>$this->id);
+ $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if (empty($reshook))
+ {
+ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ {
+ $result=$this->insertExtraFields();
+
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
+ }
+
// Commit or rollback
if ($error)
{
@@ -249,7 +274,8 @@ class CommandeFournisseurDispatch extends CommonObject
$sql.= " t.tms,";
$sql.= " t.batch,";
$sql.= " t.eatby,";
- $sql.= " t.sellby";
+ $sql.= " t.sellby,";
+ $sql.= " t.fk_reception";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
@@ -349,14 +375,21 @@ class CommandeFournisseurDispatch extends CommonObject
if (! $error)
{
+ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ {
+ if(empty($this->id) && !empty($this->rowid))$this->id=$this->rowid;
+ $result=$this->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
+
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
-
- //// Call triggers
- //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
- //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ $result=$this->call_trigger('LINERECEPTION_UPDATE',$user);
+ if ($result < 0) $error++;
//// End call triggers
}
}
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index a4b89edff42..42189a30380 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -2902,6 +2902,8 @@ class SupplierInvoiceLine extends CommonObjectLine
}
}
+ $this->deleteObjectLinked();
+
if (!$error) {
// Supprime ligne
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
@@ -3125,10 +3127,10 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql.= " ".$this->product_type.",";
$sql.= " ".price2num($this->remise_percent).",";
$sql.= " ".price2num($this->subprice).",";
- $sql.= " ".price2num($this->total_ttc/$this->qty).",";
+ $sql.= " ".(! empty($this->qty)?price2num($this->total_ttc / $this->qty):price2num($this->total_ttc)).",";
$sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").",";
$sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").",";
- $sql.= ' '.(!empty($this->fk_code_ventilation)?$this->fk_code_ventilation:0).',';
+ $sql.= ' '.(! empty($this->fk_code_ventilation)?$this->fk_code_ventilation:0).',';
$sql.= ' '.$this->rang.',';
$sql.= ' '.$this->special_code.',';
$sql.= " '".$this->db->escape($this->info_bits)."',";
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 8098946b186..c60b2dc2cbd 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -404,7 +404,7 @@ if (empty($reshook))
$desc = $productsupplier->desc_supplier;
} else $desc = $productsupplier->description;
- if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
+ if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
$type = $productsupplier->type;
$price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT');
@@ -1579,7 +1579,7 @@ if ($action=='create')
if (! empty($conf->multicurrency->enabled))
{
print '
';
print '';
print '| ';
- print fieldLabel('Currency','multicurrency_code');
+ print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0);
print ' | ';
if ($action != 'editmulticurrencycode' && ! empty($object->brouillon))
print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ' | ';
@@ -1981,7 +1981,7 @@ elseif (! empty($object->id))
print ' ';
print '';
print '| ';
- print fieldLabel('CurrencyRate','multicurrency_tx');
+ print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0);
print ' | ';
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency)
print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ' | ';
@@ -2097,17 +2097,17 @@ elseif (! empty($object->id))
if (!empty($conf->multicurrency->enabled))
{
// Multicurrency Amount HT
- print ' | ' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ' | ';
+ print ' | ' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . ' | ';
print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' | ';
print ' ';
// Multicurrency Amount VAT
- print '| ' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ' | ';
+ print ' | ' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . ' | ';
print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' | ';
print ' ';
// Multicurrency Amount TTC
- print '| ' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ' | ';
+ print ' | ' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . ' | ';
print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' | ';
print ' ';
}
@@ -2275,7 +2275,7 @@ elseif (! empty($object->id))
{
if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && ! empty($object->user_approve_id))
{
- print ''.$langs->trans("ApproveOrder").'';
+ print ''.$langs->trans("ApproveOrder").'';
}
else
{
@@ -2284,7 +2284,7 @@ elseif (! empty($object->id))
}
else
{
- print ''.$langs->trans("ApproveOrder").'';
+ print ''.$langs->trans("ApproveOrder").'';
}
}
@@ -2297,7 +2297,7 @@ elseif (! empty($object->id))
{
if (! empty($object->user_approve_id2))
{
- print ''.$langs->trans("Approve2Order").'';
+ print ''.$langs->trans("Approve2Order").'';
}
else
{
@@ -2306,7 +2306,7 @@ elseif (! empty($object->id))
}
else
{
- print ''.$langs->trans("Approve2Order").'';
+ print ''.$langs->trans("Approve2Order").'';
}
}
}
@@ -2320,7 +2320,7 @@ elseif (! empty($object->id))
}
else
{
- print ''.$langs->trans("RefuseOrder").'';
+ print ''.$langs->trans("RefuseOrder").'';
}
}
@@ -2364,13 +2364,14 @@ elseif (! empty($object->id))
}
// Ship
- if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+
+ if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
{
if (in_array($object->statut, array(3,4,5))) {
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) {
print '';
} else {
- print '';
+ print '';
}
}
}
@@ -2383,7 +2384,7 @@ elseif (! empty($object->id))
}
else
{
- print '';
+ print '';
}
}
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 5b5ae13f86b..931942debb7 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -41,7 +41,7 @@ if (! empty($conf->projet->enabled))
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks"));
+$langs->loadLangs(array("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks","receptions"));
if (! empty($conf->productbatch->enabled))
$langs->load('productbatch');
@@ -459,9 +459,12 @@ if ($id > 0 || ! empty($ref)) {
$entrepot = new Entrepot($db);
$listwarehouses = $entrepot->list_array(1);
- print '
|
|