Ask warehouse even when going back to draft

This commit is contained in:
Laurent Destailleur 2011-11-14 16:57:26 +01:00
parent 12963265d7
commit 7f77391acb
7 changed files with 126 additions and 70 deletions

View File

@ -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;

View File

@ -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,30 +775,28 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->command
} }
} }
if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer) // Go back to draft status
if ($action == 'confirm_modif' && $user->rights->commande->creer)
{ {
$object->fetch($id); // Load order and lines $idwarehouse=GETPOST('idwarehouse');
$result = $object->cloture($user);
if ($result < 0) $mesgs=$object->errors;
}
if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider)
{
$object->fetch($id); // Load order and lines
$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($id); // Load order and lines
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$result = $object->set_draft($user); // 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) if ($result >= 0)
{ {
// Define output language // Define output language
@ -814,6 +812,23 @@ if ($action == 'modif' && $user->rights->commande->creer)
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); 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)
{
$object->fetch($id); // Load order and lines
$result = $object->cloture($user);
if ($result < 0) $mesgs=$object->errors;
}
if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider)
{
$object->fetch($id); // Load order and lines
$result = $object->cancel($user);
}
/* /*
* 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
*/ */

View File

@ -355,12 +355,27 @@ 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();
// Check parameters
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
{
if (! $idwarehouse || $idwarehouse == -1)
{
$error++;
$errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
$action='';
}
}
if (! $error)
{
// On verifie si la facture a des paiements // On verifie si la facture a des paiements
$sql = 'SELECT pf.amount'; $sql = 'SELECT pf.amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
@ -392,7 +407,7 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS
// On verifie si aucun paiement n'a ete effectue // On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
{ {
$object->set_draft($user); $object->set_draft($user, $idwarehouse);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
@ -407,6 +422,7 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
} }
} }
}
// Classify "paid" // Classify "paid"
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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