Add confirm message when going back to draft
This commit is contained in:
parent
7384096d56
commit
12963265d7
@ -318,9 +318,10 @@ class Commande extends CommonObject
|
|||||||
* Set draft status
|
* Set draft status
|
||||||
*
|
*
|
||||||
* @param User $user Object user that modify
|
* @param User $user Object user that modify
|
||||||
|
* @param int $idwarehouse Id warehouse to use for stock change.
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function set_draft($user, $idwarehouse=1)
|
function set_draft($user, $idwarehouse=-1)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
|
|||||||
@ -321,7 +321,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
|
|||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
||||||
{
|
{
|
||||||
if (! $idwarehouse || $idwarehouse == -1)
|
if (! $idwarehouse || $idwarehouse == -1)
|
||||||
{
|
{
|
||||||
@ -356,7 +356,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Repasse la facture en mode brouillon (unvalidate)
|
// Repasse la facture en mode brouillon (unvalidate)
|
||||||
if ($action == 'modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate))
|
if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate))
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
@ -1985,7 +1985,7 @@ else
|
|||||||
$text.=$notify->confirmMessage('NOTIFY_VAL_FAC',$object->socid);
|
$text.=$notify->confirmMessage('NOTIFY_VAL_FAC',$object->socid);
|
||||||
}
|
}
|
||||||
$formquestion=array();
|
$formquestion=array();
|
||||||
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
||||||
{
|
{
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
|
||||||
@ -2000,6 +2000,26 @@ else
|
|||||||
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,"yes",($conf->notification->enabled?0:2));
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,"yes",($conf->notification->enabled?0:2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Confirm back to draft status
|
||||||
|
if ($action == 'modif')
|
||||||
|
{
|
||||||
|
$text=$langs->trans('ConfirmUnvalidateBill',$object->ref);
|
||||||
|
$formquestion=array();
|
||||||
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
||||||
|
{
|
||||||
|
$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("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('UnvalidateBill'),$text,'confirm_modif',$formquestion,"yes",1);
|
||||||
|
}
|
||||||
|
|
||||||
// Confirmation du classement paye
|
// Confirmation du classement paye
|
||||||
if ($action == 'paid' && $resteapayer <= 0)
|
if ($action == 'paid' && $resteapayer <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1481,6 +1481,7 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag invoice as validated + call trigger BILL_VALIDATE
|
* Tag invoice as validated + call trigger BILL_VALIDATE
|
||||||
|
* Object must have lines loaded with fetch_lines
|
||||||
*
|
*
|
||||||
* @param User $user Object user that validate
|
* @param User $user Object user that validate
|
||||||
* @param string $force_number Reference to force on invoice
|
* @param string $force_number Reference to force on invoice
|
||||||
@ -1494,7 +1495,7 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Protection
|
// Check parameters
|
||||||
if (! $this->brouillon)
|
if (! $this->brouillon)
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING);
|
dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING);
|
||||||
@ -1698,10 +1699,10 @@ class Facture extends CommonObject
|
|||||||
* Set draft status
|
* Set draft status
|
||||||
*
|
*
|
||||||
* @param User $user Object user that modify
|
* @param User $user Object user that modify
|
||||||
* @param int $idwarehouse Id warehouse to use for stock change
|
* @param int $idwarehouse Id warehouse to use for stock change.
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function set_draft($user,$idwarehouse=1)
|
function set_draft($user,$idwarehouse=-1)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
@ -1720,7 +1721,8 @@ class Facture extends CommonObject
|
|||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::set_draft sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::set_draft sql=".$sql, LOG_DEBUG);
|
||||||
if ($this->db->query($sql))
|
$result=$this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
// Si on decremente le produit principal et ses composants a la validation de facture, on réincrement
|
// Si on decremente le produit principal et ses composants a la validation de facture, on réincrement
|
||||||
if ($this->type != 3 && $result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL)
|
if ($this->type != 3 && $result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL)
|
||||||
|
|||||||
@ -383,9 +383,10 @@ class CommandeFournisseur extends Commande
|
|||||||
* TODO This method seems to be never called.
|
* TODO This method seems to be never called.
|
||||||
*
|
*
|
||||||
* @param User $user Object user that modify
|
* @param User $user Object user that modify
|
||||||
|
* @param int $idwarehouse Id warehouse to use for stock change.
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function set_draft($user)
|
function set_draft($user, $idwarehouse=-1)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
@ -425,8 +426,7 @@ class CommandeFournisseur extends Commande
|
|||||||
{
|
{
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
// We increment stock of product (and sub-products)
|
// We increment stock of product (and sub-products)
|
||||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
|
||||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
|
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -836,10 +836,12 @@ class FactureFournisseur extends Facture
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set draft status
|
* Set draft status
|
||||||
* @param user Object user that modify
|
*
|
||||||
* @param int <0 if KO, >0 if OK
|
* @param User $user Object user that modify
|
||||||
|
* @param int $idwarehouse Id warehouse to use for stock change.
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function set_draft($user)
|
function set_draft($user, $idwarehouse=-1)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
@ -847,7 +849,7 @@ class FactureFournisseur extends Facture
|
|||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
dol_syslog("FactureFournisseur::set_draft already draft status", LOG_WARNING);
|
dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,8 +859,9 @@ class FactureFournisseur extends Facture
|
|||||||
$sql.= " SET fk_statut = 0";
|
$sql.= " SET fk_statut = 0";
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog("FactureFournisseur::set_draft sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::set_draft sql=".$sql, LOG_DEBUG);
|
||||||
if ($this->db->query($sql))
|
$result=$this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
// Si on incremente le produit principal et ses composants a la validation de facture fournisseur, on decremente
|
// Si on incremente le produit principal et ses composants a la validation de facture fournisseur, on decremente
|
||||||
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)
|
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)
|
||||||
@ -873,8 +876,7 @@ class FactureFournisseur extends Facture
|
|||||||
{
|
{
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
// We increase stock for product
|
// We increase stock for product
|
||||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref));
|
||||||
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,6 +144,7 @@ SuppliersDraftInvoices=Suppliers draft invoices
|
|||||||
Unpaid=Unpaid
|
Unpaid=Unpaid
|
||||||
ConfirmDeleteBill=Are you sure you want to delete this invoice ?
|
ConfirmDeleteBill=Are you sure you want to delete this invoice ?
|
||||||
ConfirmValidateBill=Are you sure you want to validate this invoice with reference <b>%s</b> ?
|
ConfirmValidateBill=Are you sure you want to validate this invoice with reference <b>%s</b> ?
|
||||||
|
ConfirmUnvalidateBill=Are you sure you want to change invoice <b>%s</b> to draft status ?
|
||||||
ConfirmClassifyPaidBill=Are you sure you want to change invoice <b>%s</b> to status paid ?
|
ConfirmClassifyPaidBill=Are you sure you want to change invoice <b>%s</b> to status paid ?
|
||||||
ConfirmCancelBill=Are you sure you want to cancel invoice <b>%s</b> ?
|
ConfirmCancelBill=Are you sure you want to cancel invoice <b>%s</b> ?
|
||||||
ConfirmCancelBillQuestion=Why do you want to classify this invoice 'abandoned' ?
|
ConfirmCancelBillQuestion=Why do you want to classify this invoice 'abandoned' ?
|
||||||
@ -166,6 +167,7 @@ ConfirmClassifyAbandonReasonOtherDesc=This choice will be used in all other case
|
|||||||
ConfirmCustomerPayment=Do you confirm this payment input for <b>%s</b> %s ?
|
ConfirmCustomerPayment=Do you confirm this payment input for <b>%s</b> %s ?
|
||||||
ConfirmValidatePayment=Are you sure you want to validate this payment ? No change can be made once payment is validated.
|
ConfirmValidatePayment=Are you sure you want to validate this payment ? No change can be made once payment is validated.
|
||||||
ValidateBill=Validate invoice
|
ValidateBill=Validate invoice
|
||||||
|
UnvalidateBill=Unvalidate invoice
|
||||||
NumberOfBills=Nb of invoices
|
NumberOfBills=Nb of invoices
|
||||||
NumberOfBillsByMonth=Nb of invoices by month
|
NumberOfBillsByMonth=Nb of invoices by month
|
||||||
AmountOfBills=Amount of invoices
|
AmountOfBills=Amount of invoices
|
||||||
|
|||||||
@ -140,6 +140,7 @@ SuppliersDraftInvoices=Factures fournisseurs brouillons
|
|||||||
Unpaid=Impayées
|
Unpaid=Impayées
|
||||||
ConfirmDeleteBill=Êtes-vous sûr de vouloir supprimer cette facture ?
|
ConfirmDeleteBill=Êtes-vous sûr de vouloir supprimer cette facture ?
|
||||||
ConfirmValidateBill=Êtes-vous sûr de vouloir valider cette facture sous la référence <b>%s</b> ?
|
ConfirmValidateBill=Êtes-vous sûr de vouloir valider cette facture sous la référence <b>%s</b> ?
|
||||||
|
ConfirmUnvalidateBill=Êtes-vous sûr de vouloir repasser la facture <b>%s</b> au statut brouillon ?
|
||||||
ConfirmClassifyPaidBill=Êtes-vous sûr de vouloir classer la facture <b>%s</b> comme payée ?
|
ConfirmClassifyPaidBill=Êtes-vous sûr de vouloir classer la facture <b>%s</b> comme payée ?
|
||||||
ConfirmCancelBill=Êtes-vous sûr de vouloir annuler la facture <b>%s</b> ?
|
ConfirmCancelBill=Êtes-vous sûr de vouloir annuler la facture <b>%s</b> ?
|
||||||
ConfirmCancelBillQuestion=Pour quelle raison voulez-vous classer la facture abandonnée ?
|
ConfirmCancelBillQuestion=Pour quelle raison voulez-vous classer la facture abandonnée ?
|
||||||
@ -162,6 +163,7 @@ ConfirmClassifyAbandonReasonOtherDesc=Ce choix sera celui choisi dans tout autre
|
|||||||
ConfirmCustomerPayment=Confirmez-vous la saisie de ce règlement de <b>%s</b> %s ?
|
ConfirmCustomerPayment=Confirmez-vous la saisie de ce règlement de <b>%s</b> %s ?
|
||||||
ConfirmValidatePayment=Êtes-vous sûr de vouloir valider ce paiement, aucune modification n'est possible une fois le paiement validé ?
|
ConfirmValidatePayment=Êtes-vous sûr de vouloir valider ce paiement, aucune modification n'est possible une fois le paiement validé ?
|
||||||
ValidateBill=Valider facture
|
ValidateBill=Valider facture
|
||||||
|
UnvalidateBill=Repasser facture en brouillon
|
||||||
NumberOfBills=Nb de factures
|
NumberOfBills=Nb de factures
|
||||||
NumberOfBillsByMonth=Nb de factures par mois
|
NumberOfBillsByMonth=Nb de factures par mois
|
||||||
AmountOfBills=Montant de factures
|
AmountOfBills=Montant de factures
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class MouvementStock
|
|||||||
$movestock=0;
|
$movestock=0;
|
||||||
if ($product->type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1;
|
if ($product->type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1;
|
||||||
|
|
||||||
if ($movestock) // Change stock for current product, change for subproduct is done after
|
if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after
|
||||||
{
|
{
|
||||||
$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, label, price)";
|
$sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, label, price)";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user