Ask warehouse even when going back to draft
This commit is contained in:
parent
12963265d7
commit
7f77391acb
@ -1045,9 +1045,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1);
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Confirm validate proposal
|
||||||
* Confirmation de la validation de la propale
|
|
||||||
*/
|
|
||||||
if ($action == 'validate')
|
if ($action == 'validate')
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|||||||
@ -382,7 +382,7 @@ if ($action == 'setremise' && $user->rights->commande->creer)
|
|||||||
$object->set_remise($user, $_POST['remise']);
|
$object->set_remise($user, $_POST['remise']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "setabsolutediscount" && $user->rights->commande->creer)
|
if ($action == 'setabsolutediscount' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
if ($_POST["remise_id"])
|
if ($_POST["remise_id"])
|
||||||
{
|
{
|
||||||
@ -775,6 +775,45 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Go back to draft status
|
||||||
|
if ($action == 'confirm_modif' && $user->rights->commande->creer)
|
||||||
|
{
|
||||||
|
$idwarehouse=GETPOST('idwarehouse');
|
||||||
|
|
||||||
|
$object->fetch($id); // Load order and lines
|
||||||
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1))
|
||||||
|
{
|
||||||
|
if (! $idwarehouse || $idwarehouse == -1)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$result = $object->set_draft($user,$idwarehouse);
|
||||||
|
if ($result >= 0)
|
||||||
|
{
|
||||||
|
// Define output language
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang='';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||||
|
if (! empty($newlang))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer)
|
if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer)
|
||||||
{
|
{
|
||||||
$object->fetch($id); // Load order and lines
|
$object->fetch($id); // Load order and lines
|
||||||
@ -790,30 +829,6 @@ if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande-
|
|||||||
$result = $object->cancel($user);
|
$result = $object->cancel($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'modif' && $user->rights->commande->creer)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Repasse la commande en mode brouillon
|
|
||||||
*/
|
|
||||||
$object->fetch($id); // Load order and lines
|
|
||||||
$object->fetch_thirdparty();
|
|
||||||
|
|
||||||
$result = $object->set_draft($user);
|
|
||||||
if ($result >= 0)
|
|
||||||
{
|
|
||||||
// Define output language
|
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
|
||||||
$outputlangs = new Translate("",$conf);
|
|
||||||
$outputlangs->setDefaultLang($newlang);
|
|
||||||
}
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ordonnancement des lignes
|
* Ordonnancement des lignes
|
||||||
@ -1492,9 +1507,30 @@ else
|
|||||||
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
|
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 240);
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Confirm back to draft status
|
||||||
|
if ($action == 'modif')
|
||||||
|
{
|
||||||
|
$text=$langs->trans('ConfirmUnvalidateOrder',$object->ref);
|
||||||
|
$formquestion=array();
|
||||||
|
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $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("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la cloture
|
* Confirmation de la cloture
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -355,56 +355,72 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repasse la facture en mode brouillon (unvalidate)
|
// Go back to draft status (unvalidate)
|
||||||
if ($action == 'confirm_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))
|
||||||
{
|
{
|
||||||
|
$idwarehouse=GETPOST('idwarehouse');
|
||||||
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
// On verifie si la facture a des paiements
|
// Check parameters
|
||||||
$sql = 'SELECT pf.amount';
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
|
||||||
$sql.= ' WHERE pf.fk_facture = '.$object->id;
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
{
|
||||||
$i = 0;
|
if (! $idwarehouse || $idwarehouse == -1)
|
||||||
$num = $db->num_rows($result);
|
|
||||||
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$error++;
|
||||||
$totalpaye += $objp->amount;
|
$errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
|
||||||
$i++;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (! $error)
|
||||||
{
|
{
|
||||||
dol_print_error($db,'');
|
// On verifie si la facture a des paiements
|
||||||
}
|
$sql = 'SELECT pf.amount';
|
||||||
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
||||||
|
$sql.= ' WHERE pf.fk_facture = '.$object->id;
|
||||||
|
|
||||||
$resteapayer = $object->total_ttc - $totalpaye;
|
$result = $db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
|
while ($i < $num)
|
||||||
$ventilExportCompta = $object->getVentilExportCompta();
|
{
|
||||||
|
$objp = $db->fetch_object($result);
|
||||||
|
$totalpaye += $objp->amount;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db,'');
|
||||||
|
}
|
||||||
|
|
||||||
// On verifie si aucun paiement n'a ete effectue
|
$resteapayer = $object->total_ttc - $totalpaye;
|
||||||
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
|
|
||||||
{
|
|
||||||
$object->set_draft($user);
|
|
||||||
|
|
||||||
// Define output language
|
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
|
||||||
$outputlangs = $langs;
|
$ventilExportCompta = $object->getVentilExportCompta();
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
// On verifie si aucun paiement n'a ete effectue
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
|
||||||
if (! empty($newlang))
|
{
|
||||||
{
|
$object->set_draft($user, $idwarehouse);
|
||||||
$outputlangs = new Translate("",$conf);
|
|
||||||
$outputlangs->setDefaultLang($newlang);
|
// Define output language
|
||||||
}
|
$outputlangs = $langs;
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
$newlang='';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||||
|
if (! empty($newlang))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2014,7 +2030,7 @@ else
|
|||||||
//'text' => $langs->trans("ConfirmClone"),
|
//'text' => $langs->trans("ConfirmClone"),
|
||||||
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
|
//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' => '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)));
|
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), '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);
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('UnvalidateBill'),$text,'confirm_modif',$formquestion,"yes",1);
|
||||||
|
|||||||
@ -38,6 +38,7 @@ InvoiceValidatedInDolibarr= Invoice %s validated
|
|||||||
InvoiceBackToDraftInDolibarr=Invoice %s go back to draft status
|
InvoiceBackToDraftInDolibarr=Invoice %s go back to draft status
|
||||||
OrderValidatedInDolibarr= Order %s validated
|
OrderValidatedInDolibarr= Order %s validated
|
||||||
OrderApprovedInDolibarr=Order %s approved
|
OrderApprovedInDolibarr=Order %s approved
|
||||||
|
OrderBackToDraftInDolibarr=Order %s go back to draft status
|
||||||
InterventionValidatedInDolibarr=Intervention %s validated
|
InterventionValidatedInDolibarr=Intervention %s validated
|
||||||
ProposalSentByEMail=Commercial proposal %s sent by EMail
|
ProposalSentByEMail=Commercial proposal %s sent by EMail
|
||||||
OrderSentByEMail=Customer order %s sent by EMail
|
OrderSentByEMail=Customer order %s sent by EMail
|
||||||
|
|||||||
@ -59,6 +59,7 @@ CreateOrder=Create Order
|
|||||||
RefuseOrder=Refuse order
|
RefuseOrder=Refuse order
|
||||||
ApproveOrder=Accept order
|
ApproveOrder=Accept order
|
||||||
ValidateOrder=Validate order
|
ValidateOrder=Validate order
|
||||||
|
UnvalidateOrder=Unvalidate order
|
||||||
DeleteOrder=Delete order
|
DeleteOrder=Delete order
|
||||||
CancelOrder=Cancel order
|
CancelOrder=Cancel order
|
||||||
AddOrder=Add order
|
AddOrder=Add order
|
||||||
@ -83,6 +84,7 @@ ConfirmCloseOrder=Are you sure you want to close this order ? Once an order is c
|
|||||||
ConfirmCloseOrderIfSending=Are you sure you want to close this order ? You must close an order only when all shipping are done.
|
ConfirmCloseOrderIfSending=Are you sure you want to close this order ? You must close an order only when all shipping are done.
|
||||||
ConfirmDeleteOrder=Are you sure you want to delete this order ?
|
ConfirmDeleteOrder=Are you sure you want to delete this order ?
|
||||||
ConfirmValidateOrder=Are you sure you want to validate this order under name <b>%s</b> ?
|
ConfirmValidateOrder=Are you sure you want to validate this order under name <b>%s</b> ?
|
||||||
|
ConfirmUnvalidateOrder=Are you sure you want to restore order <b>%s</b> to draft status ?
|
||||||
ConfirmCancelOrder=Are you sure you want to cancel this order ?
|
ConfirmCancelOrder=Are you sure you want to cancel this order ?
|
||||||
ConfirmMakeOrder=Are you sure you want to confirm you made this order on <b>%s</b> ?
|
ConfirmMakeOrder=Are you sure you want to confirm you made this order on <b>%s</b> ?
|
||||||
GenerateBill=Generate invoice
|
GenerateBill=Generate invoice
|
||||||
|
|||||||
@ -38,6 +38,7 @@ InvoiceValidatedInDolibarr=Facture %s validée
|
|||||||
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
|
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
|
||||||
OrderValidatedInDolibarr=Commande %s validée
|
OrderValidatedInDolibarr=Commande %s validée
|
||||||
OrderApprovedInDolibarr=Commande %s approuvée
|
OrderApprovedInDolibarr=Commande %s approuvée
|
||||||
|
OrderBackToDraftInDolibarr=Commande %s repassée en brouillon
|
||||||
InterventionValidatedInDolibarr=Intervention %s validée
|
InterventionValidatedInDolibarr=Intervention %s validée
|
||||||
ProposalSentByEMail=Proposition commerciale %s envoyée par EMail
|
ProposalSentByEMail=Proposition commerciale %s envoyée par EMail
|
||||||
OrderSentByEMail=Commande client %s envoyée par EMail
|
OrderSentByEMail=Commande client %s envoyée par EMail
|
||||||
|
|||||||
@ -59,6 +59,7 @@ CreateOrder=Créer Commande
|
|||||||
RefuseOrder=Refuser la commande
|
RefuseOrder=Refuser la commande
|
||||||
ApproveOrder=Accepter la commande
|
ApproveOrder=Accepter la commande
|
||||||
ValidateOrder=Valider la commande
|
ValidateOrder=Valider la commande
|
||||||
|
UnvalidateOrder=Dévalider la commande
|
||||||
DeleteOrder=Supprimer la commande
|
DeleteOrder=Supprimer la commande
|
||||||
CancelOrder=Annuler la commande
|
CancelOrder=Annuler la commande
|
||||||
AddOrder=Créer commande
|
AddOrder=Créer commande
|
||||||
@ -83,6 +84,7 @@ ConfirmCloseOrder=Êtes-vous sûr de vouloir clôturer cette commande ? Une fois
|
|||||||
ConfirmCloseOrderIfSending=Êtes-vous sûr de vouloir clôturer cette commande ? Vous ne devez clôturer une commande qu'une fois les produits expédiés.
|
ConfirmCloseOrderIfSending=Êtes-vous sûr de vouloir clôturer cette commande ? Vous ne devez clôturer une commande qu'une fois les produits expédiés.
|
||||||
ConfirmDeleteOrder=Êtes-vous sûr de vouloir effacer cette commande ?
|
ConfirmDeleteOrder=Êtes-vous sûr de vouloir effacer cette commande ?
|
||||||
ConfirmValidateOrder=Êtes-vous sûr de vouloir valider cette commande sous la référence <b>%s</b> ?
|
ConfirmValidateOrder=Êtes-vous sûr de vouloir valider cette commande sous la référence <b>%s</b> ?
|
||||||
|
ConfirmUnvalidateOrder=Êtes-vous sûr de vouloir restaurer la commande <b>%s</b> au statut brouillon ?
|
||||||
ConfirmCancelOrder=Êtes-vous sûr de vouloir annuler cette commande ?
|
ConfirmCancelOrder=Êtes-vous sûr de vouloir annuler cette commande ?
|
||||||
ConfirmMakeOrder=Êtes-vous sûr de vouloir confirmer cette commande en date du <b>%s</b> ?
|
ConfirmMakeOrder=Êtes-vous sûr de vouloir confirmer cette commande en date du <b>%s</b> ?
|
||||||
GenerateBill=Facturer
|
GenerateBill=Facturer
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user