When creating invoice by mass action, message has link to invoice
This commit is contained in:
parent
f95bf56c15
commit
2c6d11e040
@ -590,7 +590,8 @@ if (!$error && $massaction == 'confirm_presend')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($massaction == 'confirm_createbills') // Create bills from orders
|
// TODO Move this action into commande/list.php if called only by this page.
|
||||||
|
if ($massaction == 'confirm_createbills') // Create bills from orders.
|
||||||
{
|
{
|
||||||
$orders = GETPOST('toselect', 'array');
|
$orders = GETPOST('toselect', 'array');
|
||||||
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
|
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
|
||||||
@ -600,6 +601,8 @@ if ($massaction == 'confirm_createbills') // Create bills from orders
|
|||||||
$TFactThird = array();
|
$TFactThird = array();
|
||||||
|
|
||||||
$nb_bills_created = 0;
|
$nb_bills_created = 0;
|
||||||
|
$lastid= 0;
|
||||||
|
$lastref = '';
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
@ -609,8 +612,9 @@ if ($massaction == 'confirm_createbills') // Create bills from orders
|
|||||||
if ($cmd->fetch($id_order) <= 0) continue;
|
if ($cmd->fetch($id_order) <= 0) continue;
|
||||||
|
|
||||||
$objecttmp = new Facture($db);
|
$objecttmp = new Facture($db);
|
||||||
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
|
||||||
else {
|
$objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
||||||
|
} else {
|
||||||
// Load extrafields of order
|
// Load extrafields of order
|
||||||
$cmd->fetch_optionals();
|
$cmd->fetch_optionals();
|
||||||
|
|
||||||
@ -636,7 +640,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders
|
|||||||
|
|
||||||
$res = $objecttmp->create($user);
|
$res = $objecttmp->create($user);
|
||||||
|
|
||||||
if ($res > 0) $nb_bills_created++;
|
if ($res > 0) {
|
||||||
|
$nb_bills_created++;
|
||||||
|
$lastref = $objecttmp->ref;
|
||||||
|
$lastid = $objecttmp->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($objecttmp->id > 0)
|
if ($objecttmp->id > 0)
|
||||||
@ -818,7 +826,14 @@ if ($massaction == 'confirm_createbills') // Create bills from orders
|
|||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
|
if ($nb_bills_created == 1) {
|
||||||
|
$texttoshow = $langs->trans('BillXCreated', '{s1}');
|
||||||
|
$texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
|
||||||
|
setEventMessages($texttoshow, null, 'mesgs');
|
||||||
|
} else {
|
||||||
setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
|
setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
|
||||||
|
}
|
||||||
|
|
||||||
// Make a redirect to avoid to bill twice if we make a refresh or back
|
// Make a redirect to avoid to bill twice if we make a refresh or back
|
||||||
$param = '';
|
$param = '';
|
||||||
|
|||||||
@ -244,7 +244,7 @@ if (empty($reshook))
|
|||||||
$uploaddir = $conf->fournisseur->commande->dir_output;
|
$uploaddir = $conf->fournisseur->commande->dir_output;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||||
|
|
||||||
// TODO Move this into mass action include
|
// Mass action to generate vendor bills
|
||||||
if ($massaction == 'confirm_createsupplierbills')
|
if ($massaction == 'confirm_createsupplierbills')
|
||||||
{
|
{
|
||||||
$orders = GETPOST('toselect', 'array');
|
$orders = GETPOST('toselect', 'array');
|
||||||
@ -255,6 +255,8 @@ if (empty($reshook))
|
|||||||
$TFactThird = array();
|
$TFactThird = array();
|
||||||
|
|
||||||
$nb_bills_created = 0;
|
$nb_bills_created = 0;
|
||||||
|
$lastid = 0;
|
||||||
|
$lastref = '';
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
@ -263,8 +265,9 @@ if (empty($reshook))
|
|||||||
if ($cmd->fetch($id_order) <= 0) continue;
|
if ($cmd->fetch($id_order) <= 0) continue;
|
||||||
|
|
||||||
$objecttmp = new FactureFournisseur($db);
|
$objecttmp = new FactureFournisseur($db);
|
||||||
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
|
||||||
else {
|
$objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
||||||
|
} else {
|
||||||
$objecttmp->socid = $cmd->socid;
|
$objecttmp->socid = $cmd->socid;
|
||||||
$objecttmp->type = $objecttmp::TYPE_STANDARD;
|
$objecttmp->type = $objecttmp::TYPE_STANDARD;
|
||||||
$objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
|
$objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
|
||||||
@ -285,7 +288,11 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$res = $objecttmp->create($user);
|
$res = $objecttmp->create($user);
|
||||||
|
|
||||||
if ($res > 0) $nb_bills_created++;
|
if ($res > 0) {
|
||||||
|
$nb_bills_created++;
|
||||||
|
$lastref = $objecttmp->ref;
|
||||||
|
$lastid = $objecttmp->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($objecttmp->id > 0)
|
if ($objecttmp->id > 0)
|
||||||
@ -442,7 +449,14 @@ if (empty($reshook))
|
|||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
|
if ($nb_bills_created == 1) {
|
||||||
|
$texttoshow = $langs->trans('BillXCreated', '{s1}');
|
||||||
|
$texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
|
||||||
|
setEventMessages($texttoshow, null, 'mesgs');
|
||||||
|
} else {
|
||||||
setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
|
setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
|
||||||
|
}
|
||||||
|
|
||||||
// Make a redirect to avoid to bill twice if we make a refresh or back
|
// Make a redirect to avoid to bill twice if we make a refresh or back
|
||||||
$param = '';
|
$param = '';
|
||||||
@ -459,7 +473,7 @@ if (empty($reshook))
|
|||||||
if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
|
if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
|
||||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||||
if ($search_company) $param .= '&search_company='.urlencode($search_company);
|
if ($search_company) $param .= '&search_company='.urlencode($search_company);
|
||||||
if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer);
|
//if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer);
|
||||||
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
|
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
|
||||||
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
|
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
|
||||||
if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
|
if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
|
||||||
|
|||||||
@ -562,7 +562,8 @@ ToCreateARecurringInvoiceGeneAuto=If you need to have such invoices generated au
|
|||||||
DeleteRepeatableInvoice=Delete template invoice
|
DeleteRepeatableInvoice=Delete template invoice
|
||||||
ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice?
|
ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice?
|
||||||
CreateOneBillByThird=Create one invoice per third party (otherwise, one invoice per order)
|
CreateOneBillByThird=Create one invoice per third party (otherwise, one invoice per order)
|
||||||
BillCreated=%s bill(s) created
|
BillCreated=%s invoice(s) generated
|
||||||
|
BillXCreated=Invoice %s generated
|
||||||
StatusOfGeneratedDocuments=Status of document generation
|
StatusOfGeneratedDocuments=Status of document generation
|
||||||
DoNotGenerateDoc=Do not generate document file
|
DoNotGenerateDoc=Do not generate document file
|
||||||
AutogenerateDoc=Auto generate document file
|
AutogenerateDoc=Auto generate document file
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user