mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Uniformize way to report error after "buildoc" action.
This commit is contained in:
@@ -847,13 +847,10 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
$ret = $object->fetch($id); // Reload to get new records
|
$ret = $object->fetch($id); // Reload to get new records
|
||||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
if ($result <= 0)
|
||||||
if ($result <= 0) {
|
{
|
||||||
dol_print_error($db, $result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit();
|
$action='';
|
||||||
} else {
|
|
||||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1760,7 +1757,8 @@ if ($action == 'create')
|
|||||||
// Build document if it not exists
|
// Build document if it not exists
|
||||||
if (! $file || ! is_readable($file)) {
|
if (! $file || ! is_readable($file)) {
|
||||||
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if ($result <= 0) {
|
if ($result <= 0)
|
||||||
|
{
|
||||||
dol_print_error($db, $result);
|
dol_print_error($db, $result);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1065,13 +1065,10 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
$ret = $object->fetch($id); // Reload to get new records
|
$ret = $object->fetch($id); // Reload to get new records
|
||||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
if ($result <= 0)
|
||||||
if ($result <= 0) {
|
{
|
||||||
dol_print_error($db, $result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit();
|
$action='';
|
||||||
} else {
|
|
||||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1091,10 +1091,10 @@ if (empty($reshook))
|
|||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
if ($result <= 0)
|
||||||
if ($result <= 0) {
|
{
|
||||||
dol_print_error($db, $result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit();
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1316,7 +1316,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
||||||
|
|
||||||
dol_fiche_head('');
|
dol_fiche_head('');
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Reference
|
// Reference
|
||||||
@@ -1548,7 +1548,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
// Button "Create Draft"
|
// Button "Create Draft"
|
||||||
print '<div class="center"><input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '"></div>';
|
print '<div class="center"><input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '"></div>';
|
||||||
|
|
||||||
|
|||||||
@@ -1743,8 +1743,8 @@ if (empty($reshook))
|
|||||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db, $result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit();
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1970,7 +1970,7 @@ if ($action == 'create')
|
|||||||
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
||||||
|
|
||||||
dol_fiche_head('');
|
dol_fiche_head('');
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
@@ -2475,7 +2475,7 @@ if ($action == 'create')
|
|||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
// Button "Create Draft"
|
// Button "Create Draft"
|
||||||
print '<div class="center">';
|
print '<div class="center">';
|
||||||
print '<input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '">';
|
print '<input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '">';
|
||||||
|
|||||||
@@ -807,13 +807,10 @@ else if ($action == 'builddoc' && $user->rights->contrat->creer) {
|
|||||||
}
|
}
|
||||||
$ret = $object->fetch($id); // Reload to get new records
|
$ret = $object->fetch($id); // Reload to get new records
|
||||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
if ($result <= 0)
|
||||||
if ($result <= 0) {
|
{
|
||||||
dol_print_error($db, $result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit();
|
$action='';
|
||||||
} else {
|
|
||||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,8 +409,8 @@ if (empty($reshook))
|
|||||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,7 +611,7 @@ if ($action == 'create')
|
|||||||
$liste = ModelePdfExpedition::liste_modeles($db);
|
$liste = ModelePdfExpedition::liste_modeles($db);
|
||||||
print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF);
|
print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('colspan' => ' colspan="3"');
|
$parameters=array('colspan' => ' colspan="3"');
|
||||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
|||||||
@@ -1030,13 +1030,8 @@ if ($action == 'builddoc') // GET or POST
|
|||||||
$result=expensereport_pdf_create($db, $depl, '', $depl->modelpdf, $outputlangs);
|
$result=expensereport_pdf_create($db, $depl, '', $depl->modelpdf, $outputlangs);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$depl->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -815,8 +815,8 @@ if (empty($reshook))
|
|||||||
$result= $object->generateDocument($object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result= $object->generateDocument($object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1479,7 +1479,7 @@ if ($action=='create')
|
|||||||
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
||||||
|
|
||||||
dol_fiche_head('');
|
dol_fiche_head('');
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
@@ -1603,7 +1603,7 @@ if ($action=='create')
|
|||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
print '<div class="center"><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></div>';
|
print '<div class="center"><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></div>';
|
||||||
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
|
|||||||
@@ -1083,8 +1083,8 @@ if (empty($reshook))
|
|||||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Make calculation according to calculationrule
|
// Make calculation according to calculationrule
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ if ($action == 'add')
|
|||||||
$object->note = $_POST["note"];
|
$object->note = $_POST["note"];
|
||||||
$object->commande_id = $_POST["commande_id"];
|
$object->commande_id = $_POST["commande_id"];
|
||||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||||
|
|
||||||
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
|
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
|
||||||
{
|
{
|
||||||
$expedition->entrepot_id = $_POST["entrepot_id"];
|
$expedition->entrepot_id = $_POST["entrepot_id"];
|
||||||
@@ -199,15 +199,12 @@ if ($action == 'builddoc') // En get ou en post
|
|||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
{
|
$result= $object->generateDocument($object->modelpdf, $outputlangs);
|
||||||
$ret=$object->fetch($id); // Reload to get new records
|
|
||||||
$result= $object->generateDocument($object->modelpdf, $outputlangs);
|
|
||||||
}
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +586,7 @@ else
|
|||||||
|
|
||||||
// Incoterms
|
// Incoterms
|
||||||
if (!empty($conf->incoterm->enabled))
|
if (!empty($conf->incoterm->enabled))
|
||||||
{
|
{
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||||
print $langs->trans('IncotermLabel');
|
print $langs->trans('IncotermLabel');
|
||||||
@@ -603,7 +600,7 @@ else
|
|||||||
{
|
{
|
||||||
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
|
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
|
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,8 +274,8 @@ if (empty($reshook))
|
|||||||
$result= $object->generateDocument($object->modelpdf, $outputlangs);
|
$result= $object->generateDocument($object->modelpdf, $outputlangs);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,8 +162,8 @@ if ($action == 'builddoc' && $user->rights->projet->creer)
|
|||||||
$result= $object->generateDocument($object->modelpdf, $outputlangs);
|
$result= $object->generateDocument($object->modelpdf, $outputlangs);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user