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);
}
/*
* Confirmation de la validation de la propale
*/
// Confirm validate proposal
if ($action == 'validate')
{
$error=0;

View File

@ -382,7 +382,7 @@ if ($action == 'setremise' && $user->rights->commande->creer)
$object->set_remise($user, $_POST['remise']);
}
if ($action == "setabsolutediscount" && $user->rights->commande->creer)
if ($action == 'setabsolutediscount' && $user->rights->commande->creer)
{
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)
{
$object->fetch($id); // Load order and lines
@ -790,30 +829,6 @@ if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande-
$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
@ -1492,9 +1507,30 @@ else
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
*/

View File

@ -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))
{
$idwarehouse=GETPOST('idwarehouse');
$object->fetch($id);
$object->fetch_thirdparty();
// 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;
$result = $db->query($sql);
if ($result)
// Check parameters
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
{
$i = 0;
$num = $db->num_rows($result);
while ($i < $num)
if (! $idwarehouse || $idwarehouse == -1)
{
$objp = $db->fetch_object($result);
$totalpaye += $objp->amount;
$i++;
$error++;
$errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
$action='';
}
}
else
if (! $error)
{
dol_print_error($db,'');
}
$resteapayer = $object->total_ttc - $totalpaye;
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
$ventilExportCompta = $object->getVentilExportCompta();
// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
{
$object->set_draft($user);
// 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)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
// 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;
$result = $db->query($sql);
if ($result)
{
$i = 0;
$num = $db->num_rows($result);
while ($i < $num)
{
$objp = $db->fetch_object($result);
$totalpaye += $objp->amount;
$i++;
}
}
else
{
dol_print_error($db,'');
}
$resteapayer = $object->total_ttc - $totalpaye;
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
$ventilExportCompta = $object->getVentilExportCompta();
// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
{
$object->set_draft($user, $idwarehouse);
// 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)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
}
}
@ -2014,7 +2030,7 @@ else
//'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)));
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);

View File

@ -38,6 +38,7 @@ InvoiceValidatedInDolibarr= Invoice %s validated
InvoiceBackToDraftInDolibarr=Invoice %s go back to draft status
OrderValidatedInDolibarr= Order %s validated
OrderApprovedInDolibarr=Order %s approved
OrderBackToDraftInDolibarr=Order %s go back to draft status
InterventionValidatedInDolibarr=Intervention %s validated
ProposalSentByEMail=Commercial proposal %s sent by EMail
OrderSentByEMail=Customer order %s sent by EMail

View File

@ -59,6 +59,7 @@ CreateOrder=Create Order
RefuseOrder=Refuse order
ApproveOrder=Accept order
ValidateOrder=Validate order
UnvalidateOrder=Unvalidate order
DeleteOrder=Delete order
CancelOrder=Cancel 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.
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> ?
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 ?
ConfirmMakeOrder=Are you sure you want to confirm you made this order on <b>%s</b> ?
GenerateBill=Generate invoice

View File

@ -38,6 +38,7 @@ InvoiceValidatedInDolibarr=Facture %s validée
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
OrderValidatedInDolibarr=Commande %s validée
OrderApprovedInDolibarr=Commande %s approuvée
OrderBackToDraftInDolibarr=Commande %s repassée en brouillon
InterventionValidatedInDolibarr=Intervention %s validée
ProposalSentByEMail=Proposition commerciale %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
ApproveOrder=Accepter la commande
ValidateOrder=Valider la commande
UnvalidateOrder=Dévalider la commande
DeleteOrder=Supprimer la commande
CancelOrder=Annuler la 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.
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> ?
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 ?
ConfirmMakeOrder=Êtes-vous sûr de vouloir confirmer cette commande en date du <b>%s</b> ?
GenerateBill=Facturer