Ajout possibilité de décrémenter le stock sur la validation de la commande
le stock est incrémenté à l'édition ou l'annulation de la commande et décrémenté à la validation suppression de l'incompatibilité entre la décrémentation du stock à la facturation et l'expédition
This commit is contained in:
parent
2788474b48
commit
f18fff97e2
@ -39,6 +39,11 @@ if (!$user->admin)
|
|||||||
if ($_POST["action"] == 'stock_userstock')
|
if ($_POST["action"] == 'stock_userstock')
|
||||||
{
|
{
|
||||||
dolibarr_set_const($db, "STOCK_USERSTOCK", $_POST["stock_userstock"]);
|
dolibarr_set_const($db, "STOCK_USERSTOCK", $_POST["stock_userstock"]);
|
||||||
|
//On désactive l'autocréation si l'option "stock personnel" est désactivée
|
||||||
|
if ($_POST["stock_userstock"] == 0)
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", 0);
|
||||||
|
}
|
||||||
Header("Location: stock.php");
|
Header("Location: stock.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -51,6 +56,36 @@ elseif ($_POST["action"] == 'stock_userstock_autocreate')
|
|||||||
elseif ($_POST["action"] == 'stock_bill')
|
elseif ($_POST["action"] == 'stock_bill')
|
||||||
{
|
{
|
||||||
dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", $_POST["stock_bill"]);
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", $_POST["stock_bill"]);
|
||||||
|
//Si activée on désactive la décrémentation du stock à la validation de commande et/ou à l'expédition
|
||||||
|
if ($_POST["stock_bill"] == 1)
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", 0);
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", 0);
|
||||||
|
}
|
||||||
|
Header("Location: stock.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
elseif ($_POST["action"] == 'stock_validateorder')
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", $_POST["stock_validateorder"]);
|
||||||
|
//Si activée on désactive la décrémentation du stock à la facturation et/ou à l'expédition
|
||||||
|
if ($_POST["stock_validateorder"] == 1)
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", 0);
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", 0);
|
||||||
|
}
|
||||||
|
Header("Location: stock.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
elseif ($_POST["action"] == 'stock_shipment')
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", $_POST["stock_shipment"]);
|
||||||
|
//Si activée on désactive la décrémentation du stock à la facturation et/ou à la validation de commande
|
||||||
|
if ($_POST["stock_shipment"] == 1)
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", 0);
|
||||||
|
dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", 0);
|
||||||
|
}
|
||||||
Header("Location: stock.php");
|
Header("Location: stock.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -102,8 +137,8 @@ if ($conf->global->STOCK_USERSTOCK == 1)
|
|||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$var=!$var;
|
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
print '<td width="60%">'.$langs->trans("DeStockReStockOnBill").'</td>';
|
print '<td width="60%">'.$langs->trans("DeStockReStockOnBill").'</td>';
|
||||||
print '<td width="160" align="right">';
|
print '<td width="160" align="right">';
|
||||||
@ -113,6 +148,26 @@ print $html->selectyesno("stock_bill",$conf->global->STOCK_CALCULATE_ON_BILL,1);
|
|||||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
print "</form>\n</td>\n</tr>\n";
|
print "</form>\n</td>\n</tr>\n";
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
print '<td width="60%">'.$langs->trans("DeStockReStockOnValidateOrder").'</td>';
|
||||||
|
print '<td width="160" align="right">';
|
||||||
|
print "<form method=\"post\" action=\"stock.php\">";
|
||||||
|
print "<input type=\"hidden\" name=\"action\" value=\"stock_validateorder\">";
|
||||||
|
print $html->selectyesno("stock_validateorder",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1);
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print "</form>\n</td>\n</tr>\n";
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
print '<td width="60%">'.$langs->trans("DeStockReStockOnShipment").'</td>';
|
||||||
|
print '<td width="160" align="right">';
|
||||||
|
print "<form method=\"post\" action=\"stock.php\">";
|
||||||
|
print "<input type=\"hidden\" name=\"action\" value=\"stock_shipment\">";
|
||||||
|
print $html->selectyesno("stock_shipment",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1);
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print "</form>\n</td>\n</tr>\n";
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
@ -258,6 +258,36 @@ class Commande extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Si activé on décrémente le produit principal et ses composants à la validation de commande
|
||||||
|
if($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
||||||
|
|
||||||
|
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
||||||
|
{
|
||||||
|
if ($conf->global->PRODUIT_SOUSPRODUITS == 1)
|
||||||
|
{
|
||||||
|
$prod = new Product($this->db, $this->lignes[$i]->fk_product);
|
||||||
|
$prod -> get_sousproduits_arbo ();
|
||||||
|
$prods_arbo = $prod->get_each_prod();
|
||||||
|
if(sizeof($prods_arbo) > 0)
|
||||||
|
{
|
||||||
|
foreach($prods_arbo as $key => $value)
|
||||||
|
{
|
||||||
|
// on décompte le stock de tous les sousproduits
|
||||||
|
$mouvS = new MouvementStock($this->db);
|
||||||
|
$entrepot_id = "1"; //Todo: ajouter possibilité de choisir l'entrepot
|
||||||
|
$result=$mouvS->livraison($user, $value[1], $entrepot_id, $value[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$mouvP = new MouvementStock($this->db);
|
||||||
|
// on décompte le stock du produit principal
|
||||||
|
$entrepot_id = "1"; //Todo: ajouter possibilité de choisir l'entrepot
|
||||||
|
$result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
@ -284,20 +314,50 @@ class Commande extends CommonObject
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function set_draft($userid)
|
function set_draft($user)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
|
||||||
|
|
||||||
$sql .= " WHERE rowid = $this->id;";
|
$sql .= " WHERE rowid = $this->id;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
return 1;
|
//Si activé on incrémente le produit principal et ses composants à l'édition de la commande
|
||||||
}
|
if($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
||||||
|
|
||||||
|
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
||||||
|
{
|
||||||
|
if ($conf->global->PRODUIT_SOUSPRODUITS == 1)
|
||||||
|
{
|
||||||
|
$prod = new Product($this->db, $this->lignes[$i]->fk_product);
|
||||||
|
$prod -> get_sousproduits_arbo ();
|
||||||
|
$prods_arbo = $prod->get_each_prod();
|
||||||
|
if(sizeof($prods_arbo) > 0)
|
||||||
|
{
|
||||||
|
foreach($prods_arbo as $key => $value)
|
||||||
|
{
|
||||||
|
// on décompte le stock de tous les sousproduits
|
||||||
|
$mouvS = new MouvementStock($this->db);
|
||||||
|
$entrepot_id = "1"; //Todo: ajouter possibilité de choisir l'entrepot
|
||||||
|
$result=$mouvS->reception($user, $value[1], $entrepot_id, $value[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$mouvP = new MouvementStock($this->db);
|
||||||
|
// on décompte le stock du produit principal
|
||||||
|
$entrepot_id = "1"; //Todo: ajouter possibilité de choisir l'entrepot
|
||||||
|
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -309,68 +369,97 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if ($user->rights->commande->valider)
|
if ($user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
||||||
$sql.= ' SET fk_statut = 3,';
|
$sql.= ' SET fk_statut = 3,';
|
||||||
$sql.= ' fk_user_cloture = '.$user->id.',';
|
$sql.= ' fk_user_cloture = '.$user->id.',';
|
||||||
$sql.= ' date_cloture = now()';
|
$sql.= ' date_cloture = now()';
|
||||||
$sql.= " WHERE rowid = $this->id AND fk_statut > 0 ;";
|
$sql.= " WHERE rowid = $this->id AND fk_statut > 0 ;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
if($conf->stock->enabled && $conf->global->PRODUIT_SOUSPRODUITS == 1)
|
if($conf->stock->enabled && $conf->global->PRODUIT_SOUSPRODUITS == 1 && $conf->global->STOCK_CALCULATE_ON_SHIPMENT == 1)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
||||||
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
||||||
{
|
{
|
||||||
$prod = new Product($this->db, $this->lignes[$i]->fk_product);
|
$prod = new Product($this->db, $this->lignes[$i]->fk_product);
|
||||||
$prod -> get_sousproduits_arbo ();
|
$prod -> get_sousproduits_arbo ();
|
||||||
$prods_arbo = $prod->get_each_prod();
|
$prods_arbo = $prod->get_each_prod();
|
||||||
if(sizeof($prods_arbo) > 0)
|
if(sizeof($prods_arbo) > 0)
|
||||||
{
|
{
|
||||||
foreach($prods_arbo as $key => $value)
|
foreach($prods_arbo as $key => $value)
|
||||||
{
|
{
|
||||||
// on décompte le stock de tous les sousproduits
|
// on décompte le stock de tous les sousproduits
|
||||||
$mouvS = new MouvementStock($this->db);
|
$mouvS = new MouvementStock($this->db);
|
||||||
$entrepot_id = "1";
|
$entrepot_id = "1";
|
||||||
$result=$mouvS->livraison($user, $value[1], $entrepot_id, $value[0]);
|
$result=$mouvS->livraison($user, $value[1], $entrepot_id, $value[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// on décompte pas le stock du produit principal, ça serait fait manuellement avec l'expédition
|
// on décompte pas le stock du produit principal, ça serait fait manuellement avec l'expédition
|
||||||
// $result=$mouvS->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
// $result=$mouvS->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annule la commande
|
* Annule la commande
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function cancel($user)
|
function cancel($user)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
if ($user->rights->commande->valider)
|
if ($user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET fk_statut = -1';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET fk_statut = -1';
|
||||||
$sql .= " WHERE rowid = $this->id AND fk_statut = 1 ;";
|
$sql .= " WHERE rowid = $this->id AND fk_statut = 1 ;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
return 1;
|
//Si activé on incrémente le produit principal et ses composants à l'édition de la commande
|
||||||
}
|
if($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
|
||||||
else
|
{
|
||||||
{
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
||||||
dolibarr_print_error($this->db);
|
|
||||||
}
|
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
||||||
}
|
{
|
||||||
|
if ($conf->global->PRODUIT_SOUSPRODUITS == 1)
|
||||||
|
{
|
||||||
|
$prod = new Product($this->db, $this->lignes[$i]->fk_product);
|
||||||
|
$prod -> get_sousproduits_arbo ();
|
||||||
|
$prods_arbo = $prod->get_each_prod();
|
||||||
|
if(sizeof($prods_arbo) > 0)
|
||||||
|
{
|
||||||
|
foreach($prods_arbo as $key => $value)
|
||||||
|
{
|
||||||
|
// on décompte le stock de tous les sousproduits
|
||||||
|
$mouvS = new MouvementStock($this->db);
|
||||||
|
$entrepot_id = "1"; //Todo: ajouter possibilité de choisir l'entrepot
|
||||||
|
$result=$mouvS->reception($user, $value[1], $entrepot_id, $value[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$mouvP = new MouvementStock($this->db);
|
||||||
|
// on décompte le stock du produit principal
|
||||||
|
$entrepot_id = "1"; //Todo: ajouter possibilité de choisir l'entrepot
|
||||||
|
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -442,7 +442,7 @@ if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
|||||||
*/
|
*/
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET['id']);
|
$commande->fetch($_GET['id']);
|
||||||
$commande->set_draft($user->id);
|
$commande->set_draft($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -119,10 +119,10 @@ if (!empty($sref_client))
|
|||||||
{
|
{
|
||||||
$sql .= ' AND c.ref_client like \'%'.addslashes($sref_client).'%\'';
|
$sql .= ' AND c.ref_client like \'%'.addslashes($sref_client).'%\'';
|
||||||
}
|
}
|
||||||
// on ne liste pas les commandes classer facturées, elles apparaissent tout de même avec la recherche
|
// on ne liste pas les commandes classer facturées et annulées, elles apparaissent tout de même avec la recherche
|
||||||
if ($conf->global->COMMANDE_HIDE_TREATED && (!$sref && !$sref_client && !$snom && !$sall && (!strlen($_POST['sf_ref']) > 0)))
|
if ($conf->global->COMMANDE_HIDE_TREATED && (!$sref && !$sref_client && !$snom && !$sall && (!strlen($_POST['sf_ref']) > 0)))
|
||||||
{
|
{
|
||||||
$sql .= ' AND c.facture = 0';
|
$sql .= ' AND c.facture = 0 AND c.fk_statut >= 0';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= ' ORDER BY '.$sortfield.' '.$sortorder;
|
$sql .= ' ORDER BY '.$sortfield.' '.$sortorder;
|
||||||
|
|||||||
@ -324,7 +324,7 @@ class Expedition extends CommonObject
|
|||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
// Si module stock géré et que expedition faite depuis un entrepot
|
// Si module stock géré et que expedition faite depuis un entrepot
|
||||||
if ($conf->stock->enabled && $this->entrepot_id)
|
if ($conf->stock->enabled && $this->entrepot_id && $conf->global->STOCK_CALCULATE_ON_SHIPMENT == 1)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
* Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
||||||
|
|||||||
@ -163,9 +163,9 @@ class modCommande extends DolibarrModules
|
|||||||
$r++;
|
$r++;
|
||||||
$this->export_code[$r]=$this->id.'_'.$r;
|
$this->export_code[$r]=$this->id.'_'.$r;
|
||||||
$this->export_label[$r]='Commandes clients et lignes de commande';
|
$this->export_label[$r]='Commandes clients et lignes de commande';
|
||||||
$this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefClient",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"DateOrder",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"OrderShortStatusInvoicee",'c.fk_statut'=>'Status','c.note'=>"Note",'p.ref'=>'RefProduct','p.label'=>'Label','cd.rowid'=>'LineId','cd.description'=>"LineDescription",'cd.total_ht'=>"TotalHT",'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty");
|
$this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefClient",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"DateOrder",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"OrderShortStatusInvoicee",'c.fk_statut'=>'Status','c.note'=>"Note",'c.date_livraison'=>'DateDelivery','p.ref'=>'RefProduct','p.label'=>'Label','cd.rowid'=>'LineId','cd.description'=>"LineDescription",'cd.total_ht'=>"LineTotalHT",'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty");
|
||||||
$this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>'order','c.note'=>"order",'p.ref'=>'product','p.label'=>'product','cd.rowid'=>'order_line','cd.description'=>"order_line",'cd.total_ht'=>"order_line",'cd.tva_tx'=>"order_line",'cd.qty'=>"order_line");
|
$this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>'order','c.note'=>"order",'c.date_livraison'=>"order",'p.ref'=>'product','p.label'=>'product','cd.rowid'=>'order_line','cd.description'=>"order_line",'cd.total_ht'=>"order_line",'cd.tva_tx'=>"order_line",'cd.qty'=>"order_line");
|
||||||
$this->export_alias_array[$r]=array('s.idp'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','c.rowid'=>"orderid",'c.ref'=>"ref",'c.ref_client'=>"refclient",'c.fk_soc'=>"fk_soc",'c.date_creation'=>"datecreation",'c.date_commande'=>"dateorder",'c.amount_ht'=>"amount",'c.remise_percent'=>"globaldiscount",'c.total_ht'=>"totalht",'c.total_ttc'=>"totalttc",'c.facture'=>"invoicee",'c.fk_statut'=>'status','c.note'=>"note",'p.ref'=>'refproduct','p.label'=>'label','cd.rowid'=>'lineid','cd.description'=>"linedescription",'cd.total_ht'=>"totalht",'cd.tva_tx'=>"linevatrate",'cd.qty'=>"lineqty");
|
$this->export_alias_array[$r]=array('s.idp'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','c.rowid'=>"orderid",'c.ref'=>"ref",'c.ref_client'=>"refclient",'c.fk_soc'=>"fk_soc",'c.date_creation'=>"datecreation",'c.date_commande'=>"dateorder",'c.amount_ht'=>"amount",'c.remise_percent'=>"globaldiscount",'c.total_ht'=>"totalht",'c.total_ttc'=>"totalttc",'c.facture'=>"invoicee",'c.fk_statut'=>'status','c.note'=>"note",'c.date_livraison'=>'datedelivery','p.ref'=>'refproduct','p.label'=>'label','cd.rowid'=>'lineid','cd.description'=>"linedescription",'cd.total_ht'=>"linetotalht",'cd.tva_tx'=>"linevatrate",'cd.qty'=>"lineqty");
|
||||||
$this->export_sql[$r]="select distinct ";
|
$this->export_sql[$r]="select distinct ";
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach ($this->export_alias_array[$r] as $key => $value)
|
foreach ($this->export_alias_array[$r] as $key => $value)
|
||||||
|
|||||||
@ -490,7 +490,7 @@ HideTreadedPropal=Hide the treated commercial proposals in the list
|
|||||||
OrdersSetup=Orders' management setup
|
OrdersSetup=Orders' management setup
|
||||||
OrdersNumberingModules=Orders numbering modules
|
OrdersNumberingModules=Orders numbering modules
|
||||||
OrdersModelModule=Order documents models
|
OrdersModelModule=Order documents models
|
||||||
HideTreadedOrders=Hide the treated orders in the list
|
HideTreadedOrders=Hide the treated or canceled orders in the list
|
||||||
ValidOrderAfterPropalClosed=To validate the order after proposal closer, makes it possible not to step by the provisional order
|
ValidOrderAfterPropalClosed=To validate the order after proposal closer, makes it possible not to step by the provisional order
|
||||||
##### Fiche inter #####
|
##### Fiche inter #####
|
||||||
FicheinterNumberingModules=Intervention numbering modules
|
FicheinterNumberingModules=Intervention numbering modules
|
||||||
|
|||||||
@ -37,6 +37,8 @@ EnhancedValueOfWarehouses=Warehouses value
|
|||||||
UserWarehouseAutoCreate=Create a stock automatically when creating a user
|
UserWarehouseAutoCreate=Create a stock automatically when creating a user
|
||||||
QtyDispatched=Quantity dispatched
|
QtyDispatched=Quantity dispatched
|
||||||
OrderDispatch=Order dispatching
|
OrderDispatch=Order dispatching
|
||||||
DeStockReStockOnBill=Decrease/increase stocks on invoices/credit notes (incompatible with stock decrease on sending/receiving)
|
DeStockReStockOnBill=Decrease/increase stocks on invoices/credit notes
|
||||||
|
DeStockReStockOnValidateOrder=Decrease/increase stocks on orders notes
|
||||||
|
DeStockReStockOnShipment=Decrease/increase stocks on shipment
|
||||||
StockAvailable=Available stock
|
StockAvailable=Available stock
|
||||||
StockInstant=Real stock
|
StockInstant=Real stock
|
||||||
|
|||||||
@ -489,7 +489,7 @@ HideTreadedPropal=Cacher les propositions commerciales trait
|
|||||||
OrdersSetup=Configuration du module Commandes
|
OrdersSetup=Configuration du module Commandes
|
||||||
OrdersNumberingModules=Modules de numérotation des commandes
|
OrdersNumberingModules=Modules de numérotation des commandes
|
||||||
OrdersModelModule=Modèles de document des commandes
|
OrdersModelModule=Modèles de document des commandes
|
||||||
HideTreadedOrders=Cacher les commandes traitées de la liste
|
HideTreadedOrders=Cacher les commandes traitées ou annulées de la liste
|
||||||
ValidOrderAfterPropalClosed=Valider la commande après la clôture de la propale, permet de ne pas passer par la commande provisoire
|
ValidOrderAfterPropalClosed=Valider la commande après la clôture de la propale, permet de ne pas passer par la commande provisoire
|
||||||
##### Fiche inter #####
|
##### Fiche inter #####
|
||||||
FicheinterNumberingModules=Modules de numérotation des fiches interventions
|
FicheinterNumberingModules=Modules de numérotation des fiches interventions
|
||||||
|
|||||||
@ -37,6 +37,8 @@ EnhancedValueOfWarehouses=Valorisation des stocks
|
|||||||
UserWarehouseAutoCreate=Créer un stock automatiquement à la création d'un utilisateur
|
UserWarehouseAutoCreate=Créer un stock automatiquement à la création d'un utilisateur
|
||||||
QtyDispatched=Quantité ventilée
|
QtyDispatched=Quantité ventilée
|
||||||
OrderDispatch=Ventilation commande
|
OrderDispatch=Ventilation commande
|
||||||
DeStockReStockOnBill=Décrémente/Incrémente les stocks sur les factures/avoirs (incompatibles avec le destockage sur les expéditions)
|
DeStockReStockOnBill=Décrémente/Incrémente les stocks sur les factures/avoirs
|
||||||
|
DeStockReStockOnValidateOrder=Décrémente/Incrémente les stocks sur les commandes
|
||||||
|
DeStockReStockOnShipment=Décrémente/Incrémente les stocks sur les expéditions
|
||||||
StockAvailable=Stock disponible
|
StockAvailable=Stock disponible
|
||||||
StockInstant=Stock actuel
|
StockInstant=Stock actuel
|
||||||
@ -307,7 +307,7 @@ class Livraison extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Si module stock géré et que expedition faite depuis un entrepot
|
// Si module stock géré et que expedition faite depuis un entrepot
|
||||||
if (!$conf->expedition->enabled && $conf->stock->enabled && $this->entrepot_id)
|
if (!$conf->expedition->enabled && $conf->stock->enabled && $this->entrepot_id && $conf->global->STOCK_CALCULATE_ON_SHIPMENT == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
//Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
||||||
|
|||||||
@ -53,52 +53,52 @@ class MouvementStock
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement";
|
||||||
$sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, price)";
|
$sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, price)";
|
||||||
$sql.= " VALUES (now(), $fk_product, $entrepot_id, $qty, $type, $user->id";
|
$sql.= " VALUES (now(), $fk_product, $entrepot_id, $qty, $type, $user->id";
|
||||||
$sql.= ",'".ereg_replace(",",".",$price)."');";
|
$sql.= ",'".ereg_replace(",",".",$price)."');";
|
||||||
|
|
||||||
if ($resql = $this->db->query($sql))
|
if ($resql = $this->db->query($sql))
|
||||||
{
|
{
|
||||||
$mvid = $this->db->last_insert_id($resql);
|
$mvid = $this->db->last_insert_id($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("MouvementStock::_Create echec insert ".$this->error);
|
dolibarr_syslog("MouvementStock::_Create echec insert ".$this->error);
|
||||||
$error = -1;
|
$error = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
|
|
||||||
if ($error === 0)
|
if ($error === 0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_stock";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_stock";
|
||||||
$sql.= " WHERE fk_entrepot = $entrepot_id AND fk_product = $fk_product";
|
$sql.= " WHERE fk_entrepot = $entrepot_id AND fk_product = $fk_product";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("MouvementStock::_Create echec update ".$this->error);
|
dolibarr_syslog("MouvementStock::_Create echec update ".$this->error);
|
||||||
$error = -2;
|
$error = -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error === 0)
|
if ($error === 0)
|
||||||
{
|
|
||||||
if ($num > 0)
|
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + $qty";
|
if ($num > 0)
|
||||||
$sql.= " WHERE fk_entrepot = $entrepot_id AND fk_product = $fk_product";
|
{
|
||||||
}
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + $qty";
|
||||||
else
|
$sql.= " WHERE fk_entrepot = $entrepot_id AND fk_product = $fk_product";
|
||||||
{
|
}
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock";
|
else
|
||||||
$sql.= " (reel, fk_entrepot, fk_product) VALUES ";
|
{
|
||||||
$sql.= " ($qty,$entrepot_id,$fk_product);";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock";
|
||||||
}
|
$sql.= " (reel, fk_entrepot, fk_product) VALUES ";
|
||||||
|
$sql.= " ($qty,$entrepot_id,$fk_product);";
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
@ -106,10 +106,10 @@ class MouvementStock
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("MouvementStock::_Create echec update ".$this->error);
|
dolibarr_syslog("MouvementStock::_Create echec update ".$this->error);
|
||||||
$error = -3;
|
$error = -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($error === 0)
|
if ($error === 0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user