diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index dc91cbd0404..adbc17a4161 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -93,7 +93,7 @@ if ($action == 'builddoc' && $permissioncreate) setEventMessages($langs->trans("FileGenerated"), null); header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc'); - die; + exit; } } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 16aa9332232..83e913f9718 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -35,9 +35,9 @@ class FormFile { private $db; - private $numoffiles; - public $error; + public $error; + public $numoffiles; public $infofiles; // Used to return informations by function getDocumentsLink diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 6f242a00544..070c739e85c 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -248,7 +248,7 @@ if (empty($object->ref)) // For survey, id is a hex string llxFooterSurvey(); $db->close(); - exit; + exit(); } // Define format of choices @@ -287,7 +287,7 @@ if (!$canbemodified) { llxFooterSurvey(); $db->close(); - die; + exit; } print '
'."\n"; diff --git a/htdocs/variants/ajax/getCombinations.php b/htdocs/variants/ajax/getCombinations.php index ce2a59c386f..8b7baaee27e 100644 --- a/htdocs/variants/ajax/getCombinations.php +++ b/htdocs/variants/ajax/getCombinations.php @@ -34,7 +34,7 @@ if (!$id) { print json_encode(array( 'error' => 'ID not set' )); - die; + exit(); } $product = new Product($db); diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php index b3e602bd0f5..6f3571c1856 100644 --- a/htdocs/variants/ajax/get_attribute_values.php +++ b/htdocs/variants/ajax/get_attribute_values.php @@ -35,7 +35,7 @@ if (!$id) { print json_encode(array( 'error' => 'ID not set' )); - die; + exit(); } $prodattr = new ProductAttribute($db); @@ -44,7 +44,7 @@ if ($prodattr->fetch($id) < 0) { print json_encode(array( 'error' => 'Attribute not found' )); - die; + exit(); } $prodattrval = new ProductAttributeValue($db); @@ -55,7 +55,7 @@ if ($res == -1) { print json_encode(array( 'error' => 'Internal error' )); - die; + exit(); } print json_encode($res); \ No newline at end of file diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index b49c5092acf..a80b6b982e3 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -33,7 +33,7 @@ $prodattrval = new ProductAttributeValue($db); if ($prodattr->fetch($id) < 1) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); - die; + exit(); } /* @@ -54,7 +54,7 @@ if ($_POST) { } else { setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2)); - die; + exit(); } } elseif ($action == 'edit_value') { @@ -71,7 +71,7 @@ if ($_POST) { } header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2)); - die; + exit(); } } @@ -93,7 +93,7 @@ if ($confirm == 'yes') { header('Location: '.dol_buildpath('/variants/list.php', 2)); } - die; + exit(); } elseif ($action == 'confirm_deletevalue') { if ($prodattrval->fetch($valueid) > 0) { @@ -105,7 +105,7 @@ if ($confirm == 'yes') { } header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2)); - die; + exit(); } } } diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 5cce16c4029..477108f9998 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -46,15 +46,22 @@ $prodstatic = new Product($db); $prodattr = new ProductAttribute($db); $prodattr_val = new ProductAttributeValue($db); -$product = new Product($db); - -$product->fetch($id); - -if (!$product->isProduct()) { - header('Location: '.dol_buildpath('/product/card.php?id='.$product->id, 2)); - die; +$object = new Product($db); +if ($id > 0 || $ref) +{ + $object->fetch($id, $ref); } +/* + * Actions + */ + +if (! $object->isProduct()) { + header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2)); + exit(); +} + + $prodcomb = new ProductCombination($db); $prodcomb2val = new ProductCombination2ValuePair($db); @@ -103,7 +110,7 @@ if ($_POST) { $db->commit(); setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); - die; + exit(); } else { setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); } @@ -171,7 +178,7 @@ if ($_POST) { if ($prodcomb->fetch($valueid) < 0) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); - die; + exit(); } $prodcomb->variation_price_percentage = $price_impact_percent; @@ -181,14 +188,14 @@ if ($_POST) { if ($prodcomb->update() > 0) { setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); - die; + exit(); } else { setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); } } } -$productCombinations = $prodcomb->fetchAllByFkProductParent($id); +$productCombinations = $prodcomb->fetchAllByFkProductParent($object->id); if ($action === 'confirm_deletecombination') { @@ -199,8 +206,8 @@ if ($action === 'confirm_deletecombination') { if ($prodcomb->delete() > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete() > 0) { $db->commit(); setEventMessage($langs->trans('RecordSaved')); - header('Location: '.dol_buildpath('/variants/combinations.php?id='.$product->id, 2)); - die; + header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); + exit(); } $db->rollback(); @@ -211,7 +218,7 @@ if ($action === 'confirm_deletecombination') { if ($prodcomb->fetch($valueid) < 0) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); - die; + exit(); } $weight_impact = $prodcomb->variation_weight; @@ -227,10 +234,10 @@ if ($action === 'confirm_deletecombination') { if ($prodstatic->fetch('', $dest_product) > 0) { //To prevent from copying to the same product - if ($prodstatic->ref != $product->ref) { - if ($prodcomb->copyAll($product->id, $prodstatic) > 0) { + if ($prodstatic->ref != $object->ref) { + if ($prodcomb->copyAll($object->id, $prodstatic) > 0) { header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2)); - die; + exit(); } else { setEventMessage($langs->trans('ErrorCopyProductCombinations'), 'errors'); } @@ -242,47 +249,31 @@ if ($action === 'confirm_deletecombination') { } + + /* * View */ if (! empty($id) || ! empty($ref)) { - $object = new Product($db); - $result = $object->fetch($id, $ref); llxHeader("", "", $langs->trans("CardProduct".$object->type)); - if ($result) { - $head = product_prepare_head($object); - $titre = $langs->trans("CardProduct".$object->type); - $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); - - dol_fiche_head($head, 'combinations', $titre, 0, $picto); - - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Label - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', '', 0); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2, 0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2, 1); - print '
'; - + if ($result) + { + $showbarcode=empty($conf->barcode->enabled)?0:1; + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; + + $head=product_prepare_head($object); + $titre=$langs->trans("CardProduct".$object->type); + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); + dol_fiche_head($head, 'combinations', $titre, 0, $picto); + + $linkback = ''.$langs->trans("BackToList").''; + $object->next_prev_filter=" fk_product_type = ".$object->type; + + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); + dol_fiche_end(); } @@ -535,7 +526,9 @@ if (! empty($id) || ! empty($ref)) { $comb2val = new ProductCombination2ValuePair($db); - if ($productCombinations): ?> + if ($productCombinations) + { + ?>