Fix error management on direct print
This commit is contained in:
parent
77dfb05647
commit
d74baea1d3
@ -36,7 +36,7 @@ if ($action == 'print_file' and $user->rights->printing->read)
|
|||||||
$list = $objectprint->listDrivers($db, 10);
|
$list = $objectprint->listDrivers($db, 10);
|
||||||
if (! empty($list)) {
|
if (! empty($list)) {
|
||||||
$errorprint=0;
|
$errorprint=0;
|
||||||
$printed=0;
|
$printerfound=0;
|
||||||
foreach ($list as $driver) {
|
foreach ($list as $driver) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||||
$langs->load($driver);
|
$langs->load($driver);
|
||||||
@ -46,12 +46,15 @@ if ($action == 'print_file' and $user->rights->printing->read)
|
|||||||
|
|
||||||
if (! empty($conf->global->{$printer->active}))
|
if (! empty($conf->global->{$printer->active}))
|
||||||
{
|
{
|
||||||
|
$printerfound++;
|
||||||
|
|
||||||
$subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':'');
|
$subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':'');
|
||||||
$module = GETPOST('printer', 'alpha');
|
$module = GETPOST('printer', 'alpha');
|
||||||
if ($module =='commande_fournisseur') {
|
if ($module =='commande_fournisseur') {
|
||||||
$module = 'fournisseur';
|
$module = 'fournisseur';
|
||||||
$subdir = 'commande';
|
$subdir = 'commande';
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
$ret = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir);
|
$ret = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir);
|
||||||
if ($ret > 0) {
|
if ($ret > 0) {
|
||||||
//print '<pre>'.print_r($printer->errors, true).'</pre>';
|
//print '<pre>'.print_r($printer->errors, true).'</pre>';
|
||||||
@ -62,11 +65,16 @@ if ($action == 'print_file' and $user->rights->printing->read)
|
|||||||
//print '<pre>'.print_r($printer->errors, true).'</pre>';
|
//print '<pre>'.print_r($printer->errors, true).'</pre>';
|
||||||
setEventMessages($printer->error, $printer->errors);
|
setEventMessages($printer->error, $printer->errors);
|
||||||
setEventMessages($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null);
|
setEventMessages($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null);
|
||||||
$printed++;
|
}
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
$ret = 1;
|
||||||
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($printed==0) setEventMessages($langs->trans("NoActivePrintingModuleFound"), null, 'warnings');
|
if ($printerfound==0) setEventMessages($langs->trans("NoActivePrintingModuleFound"), null, 'warnings');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("NoModuleFound"), null, 'warnings');
|
setEventMessages($langs->trans("NoModuleFound"), null, 'warnings');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2205,7 +2205,7 @@ table.borderplus {
|
|||||||
border: 1px solid #BBB;
|
border: 1px solid #BBB;
|
||||||
}
|
}
|
||||||
.border tbody tr, .border tbody tr td, div.tabBar table.border tr, div.tabBar table.border tr td, div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar div.border .table-val-border-col {
|
.border tbody tr, .border tbody tr td, div.tabBar table.border tr, div.tabBar table.border tr td, div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar div.border .table-val-border-col {
|
||||||
height: 20px;
|
height: 22px;
|
||||||
}
|
}
|
||||||
div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar .table-val-border-col {
|
div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar .table-val-border-col {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|||||||
@ -2292,7 +2292,7 @@ table.borderplus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.border tbody tr, .border tbody tr td, div.tabBar table.border tr {
|
.border tbody tr, .border tbody tr td, div.tabBar table.border tr {
|
||||||
height: 20px;
|
height: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.border td, div.border div div.tagtd {
|
table.border td, div.border div div.tagtd {
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
|
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -28,10 +27,10 @@ $ref = GETPOST('ref');
|
|||||||
$confirm = GETPOST('confirm');
|
$confirm = GETPOST('confirm');
|
||||||
$cancel = GETPOST('cancel');
|
$cancel = GETPOST('cancel');
|
||||||
|
|
||||||
$prodattr = new ProductAttribute($db);
|
$object = new ProductAttribute($db);
|
||||||
$prodattrval = new ProductAttributeValue($db);
|
$objectval = new ProductAttributeValue($db);
|
||||||
|
|
||||||
if ($prodattr->fetch($id) < 1) {
|
if ($object->fetch($id) < 1) {
|
||||||
dol_print_error($db, $langs->trans('ErrorRecordNotFound'));
|
dol_print_error($db, $langs->trans('ErrorRecordNotFound'));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@ -47,10 +46,10 @@ if ($_POST) {
|
|||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
|
|
||||||
$prodattr->label = $label;
|
$object->label = $label;
|
||||||
$prodattr->ref = $ref;
|
$object->ref = $ref;
|
||||||
|
|
||||||
if ($prodattr->update() < 1) {
|
if ($object->update() < 1) {
|
||||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($langs->trans('RecordSaved'));
|
setEventMessage($langs->trans('RecordSaved'));
|
||||||
@ -59,19 +58,19 @@ if ($_POST) {
|
|||||||
}
|
}
|
||||||
} elseif ($action == 'edit_value') {
|
} elseif ($action == 'edit_value') {
|
||||||
|
|
||||||
if ($prodattrval->fetch($valueid) > 0) {
|
if ($objectval->fetch($valueid) > 0) {
|
||||||
|
|
||||||
$prodattrval->ref = $ref;
|
$objectval->ref = $ref;
|
||||||
$prodattrval->value = GETPOST('value');
|
$objectval->value = GETPOST('value');
|
||||||
|
|
||||||
if ($prodattrval->update() > 0) {
|
if ($objectval->update() > 0) {
|
||||||
setEventMessage($langs->trans('RecordSaved'));
|
setEventMessage($langs->trans('RecordSaved'));
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2));
|
header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,12 +81,12 @@ if ($confirm == 'yes') {
|
|||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$res = $prodattrval->deleteByFkAttribute($prodattr->id);
|
$res = $objectval->deleteByFkAttribute($object->id);
|
||||||
|
|
||||||
if ($res < 1 || ($prodattr->delete() < 1)) {
|
if ($res < 1 || ($object->delete() < 1)) {
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2));
|
header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2));
|
||||||
} else {
|
} else {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
setEventMessage($langs->trans('RecordSaved'));
|
setEventMessage($langs->trans('RecordSaved'));
|
||||||
@ -97,15 +96,15 @@ if ($confirm == 'yes') {
|
|||||||
exit();
|
exit();
|
||||||
} elseif ($action == 'confirm_deletevalue') {
|
} elseif ($action == 'confirm_deletevalue') {
|
||||||
|
|
||||||
if ($prodattrval->fetch($valueid) > 0) {
|
if ($objectval->fetch($valueid) > 0) {
|
||||||
|
|
||||||
if ($prodattrval->delete() < 1) {
|
if ($objectval->delete() < 1) {
|
||||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($langs->trans('RecordSaved'));
|
setEventMessage($langs->trans('RecordSaved'));
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2));
|
header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,38 +117,50 @@ if ($confirm == 'yes') {
|
|||||||
|
|
||||||
$langs->load('products');
|
$langs->load('products');
|
||||||
|
|
||||||
$title = $langs->trans('ProductAttributeName', dol_htmlentities($prodattr->label));
|
$title = $langs->trans('ProductAttributeName', dol_htmlentities($object->label));
|
||||||
$var = false;
|
$var = false;
|
||||||
|
|
||||||
llxHeader('', $title);
|
llxHeader('', $title);
|
||||||
|
|
||||||
print_fiche_titre($title);
|
//print_fiche_titre($title);
|
||||||
|
|
||||||
dol_fiche_head();
|
$h=0;
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/variants/card.php?id='.$object->id;
|
||||||
|
$head[$h][1] = $langs->trans("Card");
|
||||||
|
$head[$h][2] = 'variant';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
dol_fiche_head($head, 'variant', $langs->trans('ProductAttributeName'), -1, 'generic');
|
||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
print '<form method="post">';
|
print '<form method="POST">';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($action != 'edit')
|
||||||
|
{
|
||||||
|
print '<div class="fichecenter">';
|
||||||
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<table class="border" style="width: 100%">
|
<table class="border" style="width: 100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 15%" class="fieldrequired"><?php echo $langs->trans('Ref') ?></td>
|
<td class="titlefield fieldrequired"><?php echo $langs->trans('Ref') ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($action == 'edit') {
|
<?php if ($action == 'edit') {
|
||||||
print '<input type="text" name="ref" value="'.$prodattr->ref.'">';
|
print '<input type="text" name="ref" value="'.$object->ref.'">';
|
||||||
} else {
|
} else {
|
||||||
print dol_htmlentities($prodattr->ref);
|
print dol_htmlentities($object->ref);
|
||||||
} ?>
|
} ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 15%" class="fieldrequired"><?php echo $langs->trans('Label') ?></td>
|
<td class="fieldrequired"><?php echo $langs->trans('Label') ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($action == 'edit') {
|
<?php if ($action == 'edit') {
|
||||||
print '<input type="text" name="label" value="'.$prodattr->label.'">';
|
print '<input type="text" name="label" value="'.$object->label.'">';
|
||||||
} else {
|
} else {
|
||||||
print dol_htmlentities($prodattr->label);
|
print dol_htmlentities($object->label);
|
||||||
} ?>
|
} ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -157,6 +168,12 @@ if ($action == 'edit') {
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if ($action != 'edit')
|
||||||
|
{
|
||||||
|
print '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
if ($action == 'edit') { ?>
|
if ($action == 'edit') { ?>
|
||||||
@ -173,7 +190,7 @@ if ($action == 'edit') { ?>
|
|||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
print $form->formconfirm(
|
print $form->formconfirm(
|
||||||
"card.php?id=".$prodattr->id,
|
"card.php?id=".$object->id,
|
||||||
$langs->trans('Delete'),
|
$langs->trans('Delete'),
|
||||||
$langs->trans('ProductAttributeDeleteDialog'),
|
$langs->trans('ProductAttributeDeleteDialog'),
|
||||||
"confirm_delete",
|
"confirm_delete",
|
||||||
@ -183,14 +200,14 @@ if ($action == 'edit') { ?>
|
|||||||
);
|
);
|
||||||
} elseif ($action == 'delete_value') {
|
} elseif ($action == 'delete_value') {
|
||||||
|
|
||||||
if ($prodattrval->fetch($valueid) > 0) {
|
if ($objectval->fetch($valueid) > 0) {
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
print $form->formconfirm(
|
print $form->formconfirm(
|
||||||
"card.php?id=".$prodattr->id."&valueid=".$prodattrval->id,
|
"card.php?id=".$object->id."&valueid=".$objectval->id,
|
||||||
$langs->trans('Delete'),
|
$langs->trans('Delete'),
|
||||||
$langs->trans('ProductAttributeValueDeleteDialog', dol_htmlentities($prodattrval->value), dol_htmlentities($prodattrval->ref)),
|
$langs->trans('ProductAttributeValueDeleteDialog', dol_htmlentities($objectval->value), dol_htmlentities($objectval->ref)),
|
||||||
"confirm_deletevalue",
|
"confirm_deletevalue",
|
||||||
'',
|
'',
|
||||||
0,
|
0,
|
||||||
@ -203,8 +220,8 @@ if ($action == 'edit') { ?>
|
|||||||
|
|
||||||
<div class="tabsAction">
|
<div class="tabsAction">
|
||||||
<div class="inline-block divButAction">
|
<div class="inline-block divButAction">
|
||||||
<a href="card.php?id=<?php echo $prodattr->id ?>&action=edit" class="butAction"><?php echo $langs->trans('Modify') ?></a>
|
<a href="card.php?id=<?php echo $object->id ?>&action=edit" class="butAction"><?php echo $langs->trans('Modify') ?></a>
|
||||||
<a href="card.php?id=<?php echo $prodattr->id ?>&action=delete" class="butAction"><?php echo $langs->trans('Delete') ?></a>
|
<a href="card.php?id=<?php echo $object->id ?>&action=delete" class="butAction"><?php echo $langs->trans('Delete') ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -219,7 +236,7 @@ if ($action == 'edit') { ?>
|
|||||||
<th class="liste_titre"></th>
|
<th class="liste_titre"></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php foreach ($prodattrval->fetchAllByProductAttribute($prodattr->id) as $attrval): ?>
|
<?php foreach ($objectval->fetchAllByProductAttribute($object->id) as $attrval): ?>
|
||||||
<tr <?php echo $bc[!$var] ?>>
|
<tr <?php echo $bc[!$var] ?>>
|
||||||
<?php if ($action == 'edit_value' && ($valueid == $attrval->id)): ?>
|
<?php if ($action == 'edit_value' && ($valueid == $attrval->id)): ?>
|
||||||
<td><input type="text" name="ref" value="<?php echo $attrval->ref ?>"></td>
|
<td><input type="text" name="ref" value="<?php echo $attrval->ref ?>"></td>
|
||||||
@ -233,8 +250,8 @@ if ($action == 'edit') { ?>
|
|||||||
<td><?php echo dol_htmlentities($attrval->ref) ?></td>
|
<td><?php echo dol_htmlentities($attrval->ref) ?></td>
|
||||||
<td><?php echo dol_htmlentities($attrval->value) ?></td>
|
<td><?php echo dol_htmlentities($attrval->value) ?></td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
<a href="card.php?id=<?php echo $prodattr->id ?>&action=edit_value&valueid=<?php echo $attrval->id ?>"><?php echo img_edit() ?></a>
|
<a href="card.php?id=<?php echo $object->id ?>&action=edit_value&valueid=<?php echo $attrval->id ?>"><?php echo img_edit() ?></a>
|
||||||
<a href="card.php?id=<?php echo $prodattr->id ?>&action=delete_value&valueid=<?php echo $attrval->id ?>"><?php echo img_delete() ?></a>
|
<a href="card.php?id=<?php echo $object->id ?>&action=delete_value&valueid=<?php echo $attrval->id ?>"><?php echo img_delete() ?></a>
|
||||||
</td>
|
</td>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</tr>
|
</tr>
|
||||||
@ -250,7 +267,7 @@ if ($action == 'edit') { ?>
|
|||||||
|
|
||||||
<div class="tabsAction">
|
<div class="tabsAction">
|
||||||
<div class="inline-block divButAction">
|
<div class="inline-block divButAction">
|
||||||
<a href="create_val.php?id=<?php echo $prodattr->id ?>" class="butAction"><?php echo $langs->trans('Create') ?></a>
|
<a href="create_val.php?id=<?php echo $object->id ?>" class="butAction"><?php echo $langs->trans('Create') ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -258,3 +275,4 @@ if ($action == 'edit') { ?>
|
|||||||
}
|
}
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user