Merge pull request #9743 from atm-maxime/new_mass_generate

New mass generate
This commit is contained in:
Laurent Destailleur 2018-12-14 15:45:24 +01:00 committed by GitHub
commit bcf2e751b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 77 additions and 2 deletions

View File

@ -462,6 +462,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -449,6 +449,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
'cancelorders'=>$langs->trans("Cancel"),

View File

@ -595,6 +595,7 @@ if ($resql)
$arrayofmassactions=array(
'validate'=>$langs->trans("Validate"),
'generate_doc'=>$langs->trans("Generate"),
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -364,6 +364,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -1169,6 +1169,67 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm ==
//var_dump($listofobjectthirdparties);exit;
}
// Generate document foreach object according to model linked to object
// @TODO : propose model selection
if (! $error && $massaction == 'generate_doc' && $permtoread)
{
$db->begin();
$objecttmp=new $objectclass($db);
$nbok = 0;
foreach($toselect as $toselectid)
{
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang=$objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ...
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang=$objecttmp->default_lang; // for thirdparty
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
// To be sure vars is defined
if (empty($hidedetails)) $hidedetails=0;
if (empty($hidedesc)) $hidedesc=0;
if (empty($hideref)) $hideref=0;
if (empty($moreparams)) $moreparams=null;
$result= $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if ($result <= 0)
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
}
else $nbok++;
}
else
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
}
}
if (! $error)
{
if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs');
$db->commit();
}
else
{
$db->rollback();
}
}
$parameters['toselect']=$toselect;
$parameters['uploaddir']=$uploaddir;

View File

@ -359,6 +359,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -269,6 +269,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
//'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -647,6 +647,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -477,6 +477,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'validate'=>$langs->trans("Validate"),
'generate_doc'=>$langs->trans("Generate"),
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -117,6 +117,7 @@ if ($fourn_id)
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -86,6 +86,7 @@ GoToWikiHelpPage=Read online help (Internet access needed)
GoToHelpPage=Read help
RecordSaved=Record saved
RecordDeleted=Record deleted
RecordGenerated=Record generated
LevelOfFeature=Level of features
NotDefined=Not defined
DolibarrInHttpAuthenticationSoPasswordUseless=Dolibarr authentication mode is set to <b>%s</b> in configuration file <b>conf.php</b>.<br>This means that the password database is external to Dolibarr, so changing this field may have no effect.
@ -650,8 +651,9 @@ ValueIsValid=Value is valid
ValueIsNotValid=Value is not valid
RecordCreatedSuccessfully=Record created successfully
RecordModifiedSuccessfully=Record modified successfully
RecordsModified=%s record(s) modified
RecordsDeleted=%s record(s) deleted
RecordsModified=%s record modified
RecordsDeleted=%s record deleted
RecordsGenerated=%s record generated
AutomaticCode=Automatic code
FeatureDisabled=Feature disabled
MoveBox=Move widget

View File

@ -417,6 +417,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -438,6 +438,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
// 'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"),
);

View File

@ -396,6 +396,7 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("Generate"),
//'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);