stock on supplier invoice back to draft
This commit is contained in:
parent
a1217d61b6
commit
8baad70f6c
@ -1302,8 +1302,9 @@ class FactureFournisseur extends CommonInvoice
|
||||
if ($this->lines[$i]->fk_product > 0)
|
||||
{
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increase stock for product
|
||||
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref));
|
||||
$mouvP->origin = &$this;
|
||||
// We increase stock for product
|
||||
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1154,7 +1154,7 @@ if (empty($reshook))
|
||||
|
||||
|
||||
// Set invoice to draft status
|
||||
elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'confirm_edit' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
|
||||
@ -1167,7 +1167,33 @@ if (empty($reshook))
|
||||
// On verifie si aucun paiement n'a ete effectue
|
||||
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
|
||||
{
|
||||
$object->set_draft($user);
|
||||
$idwarehouse = GETPOST('idwarehouse');
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$qualified_for_stock_change=0;
|
||||
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
$qualified_for_stock_change=$object->hasProductsOrServices(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$qualified_for_stock_change=$object->hasProductsOrServices(1);
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
|
||||
{
|
||||
$langs->load("stocks");
|
||||
if (! $idwarehouse || $idwarehouse == -1)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
$object->set_draft($user, $idwarehouse);
|
||||
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
@ -1974,14 +2000,57 @@ else
|
||||
$langs->load("stocks");
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
$formproduct=new FormProduct($db);
|
||||
$formquestion=array(
|
||||
//'text' => $langs->trans("ConfirmClone"),
|
||||
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
|
||||
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
|
||||
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
|
||||
$warehouse = new Entrepot($db);
|
||||
$warehouse_array = $warehouse->list_array();
|
||||
if (count($warehouse_array) == 1) {
|
||||
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array));
|
||||
$value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="' . key($warehouse_array) . '">';
|
||||
} else {
|
||||
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
|
||||
$value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
|
||||
}
|
||||
$formquestion = array(
|
||||
array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value)
|
||||
);
|
||||
}
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1, 240);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
// Confirmation edit (back to draft)
|
||||
if ($action == 'edit')
|
||||
{
|
||||
$formquestion = array();
|
||||
|
||||
$qualified_for_stock_change = 0;
|
||||
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
$qualified_for_stock_change = $object->hasProductsOrServices(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$qualified_for_stock_change = $object->hasProductsOrServices(1);
|
||||
}
|
||||
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
|
||||
{
|
||||
$langs->load("stocks");
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
$formproduct = new FormProduct($db);
|
||||
$warehouse = new Entrepot($db);
|
||||
$warehouse_array = $warehouse->list_array();
|
||||
if (count($warehouse_array) == 1) {
|
||||
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array));
|
||||
$value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="' . key($warehouse_array) . '">';
|
||||
} else {
|
||||
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease");
|
||||
$value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
|
||||
}
|
||||
$formquestion = array(
|
||||
array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value)
|
||||
);
|
||||
}
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateBill'), $langs->trans('ConfirmUnvalidateBill', $object->ref), 'confirm_edit', $formquestion, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
@ -2666,7 +2735,7 @@ else
|
||||
{
|
||||
|
||||
// Modify a validated invoice with no payments
|
||||
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
|
||||
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a></div>';
|
||||
}
|
||||
@ -2699,13 +2768,13 @@ else
|
||||
}
|
||||
|
||||
// Make payments
|
||||
if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
|
||||
if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&action=create'.($object->fk_account>0?'&accountid='.$object->fk_account:'').'">'.$langs->trans('DoPayment').'</a></div>'; // must use facid because id is for payment id not invoice
|
||||
}
|
||||
|
||||
// Classify paid
|
||||
if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
|
||||
if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=paid"';
|
||||
print '>'.$langs->trans('ClassifyPaid').'</a></div>';
|
||||
@ -2740,7 +2809,7 @@ else
|
||||
}
|
||||
|
||||
// Validate
|
||||
if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_DRAFT)
|
||||
if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT)
|
||||
{
|
||||
if (count($object->lines))
|
||||
{
|
||||
@ -2765,7 +2834,7 @@ else
|
||||
}
|
||||
|
||||
// Clone
|
||||
if ($action != 'edit' && $user->rights->fournisseur->facture->creer)
|
||||
if ($action != 'confirm_edit' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=clone&socid='.$object->socid.'">'.$langs->trans('ToClone').'</a></div>';
|
||||
}
|
||||
@ -2780,7 +2849,7 @@ else
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer)
|
||||
if ($action != 'confirm_edit' && $user->rights->fournisseur->facture->supprimer)
|
||||
{
|
||||
if ($object->getSommePaiement()) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecausePayments") . '">' . $langs->trans('Delete') . '</a></div>';
|
||||
@ -2790,7 +2859,7 @@ else
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
if ($action != 'edit')
|
||||
if ($action != 'confirm_edit')
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user