diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index 0a39e596ba3..9d0d9f1befc 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -65,6 +65,8 @@ $socid = GETPOST("socid", 'int');
if ($user->socid > 0) {
$action = '';
$id = $user->socid;
+} else {
+ $id = 0;
}
restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 6c670c82364..940e0156c7e 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -2535,12 +2535,12 @@ class Propal extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
// Status self::STATUS_REFUSED by default
- $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf;
+ $modelpdf = !empty($conf->global->PROPALE_ADDON_PDF_ODT_CLOSED) ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf;
$trigger_name = 'PROPAL_CLOSE_REFUSED';
if ($status == self::STATUS_SIGNED) { // Status self::STATUS_SIGNED
$trigger_name = 'PROPAL_CLOSE_SIGNED';
- $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->model_pdf;
+ $modelpdf = !empty($conf->global->PROPALE_ADDON_PDF_ODT_TOBILL) ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->model_pdf;
// The connected company is classified as a client
$soc=new Societe($this->db);
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 52ec6741682..aa9897f9dc7 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1368,7 +1368,7 @@ class Commande extends CommonOrder
}
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
- if (is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) {
+ if (isset($object->other_linked_objects) && is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) {
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php
index 428589aa844..a0641c4c493 100644
--- a/htdocs/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php
@@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
}
echo '
';
echo ''.$langs->trans("CustomerOrder");
- if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
+ if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) {
print ' ';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index b44b7d22fd8..1f6a03ca351 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -112,7 +112,12 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
if ($action != 'add') {
- $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION);
+ if (empty($conf->global->INVOICE_USE_SITUATION)) {
+ $fetch_situation = false;
+ } else {
+ $fetch_situation = true;
+ }
+ $ret = $object->fetch($id, $ref, '', '', $fetch_situation);
}
}
@@ -607,7 +612,7 @@ if (empty($reshook)) {
}
// Check for mandatory fields in invoice
- $array_to_check = array('REF_CUSTOMER'=>'RefCustomer');
+ $array_to_check = array('REF_CLIENT'=>'RefCustomer');
foreach ($array_to_check as $key => $val) {
$keymin = strtolower($key);
$vallabel = $object->$keymin;
@@ -2362,20 +2367,21 @@ if (empty($reshook)) {
$line = new FactureLigne($db);
$line->fetch(GETPOST('lineid', 'int'));
$percent = $line->get_prev_progress($object->id);
+ $progress = price2num(GETPOST('progress', 'alpha'));
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) {
// in case of situation credit note
- if (GETPOST('progress') >= 0) {
+ if ($progress >= 0) {
$mesg = $langs->trans("CantBeNullOrPositive");
setEventMessages($mesg, null, 'warnings');
$error++;
$result = -1;
- } elseif (GETPOST('progress') < $line->situation_percent) { // TODO : use a modified $line->get_prev_progress($object->id) result
+ } elseif ($progress < $line->situation_percent) { // TODO : use a modified $line->get_prev_progress($object->id) result
$mesg = $langs->trans("CantBeLessThanMinPercent");
setEventMessages($mesg, null, 'warnings');
$error++;
$result = -1;
- } elseif (GETPOST('progress') < $percent) {
+ } elseif ($progress < $percent) {
$mesg = ''.$langs->trans("CantBeLessThanMinPercent").'
';
setEventMessages($mesg, null, 'warnings');
$error++;
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index b3ed477596c..0b1504d229a 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5085,7 +5085,12 @@ class Form
} else {
if ($selected) {
$this->load_cache_conditions_paiements();
- print $this->cache_conditions_paiements[$selected]['label'];
+ if (isset($this->cache_conditions_paiements[$selected])) {
+ print $this->cache_conditions_paiements[$selected]['label'];
+ } else {
+ $langs->load('errors');
+ print $langs->trans('ErrorNotInDictionaryPaymentConditions');
+ }
} else {
print " ";
}
@@ -7778,7 +7783,7 @@ class Form
print ' ';
print ' ';
print ''.$objp->ref.' ';
- print ''.(!empty($objp->ref_client) ? $objp->ref_client : $objp->ref_supplier).' ';
+ print ''.(!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier : '')).' ';
print '';
if ($possiblelink['label'] == 'LinkToContract') {
$form = new Form($this->db);
diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php
index 6d6df3a5408..88c643c641d 100644
--- a/htdocs/core/tpl/ajaxrow.tpl.php
+++ b/htdocs/core/tpl/ajaxrow.tpl.php
@@ -79,7 +79,6 @@ $(document).ready(function(){
function() {
console.log("tableDND end of ajax call");
if (reloadpage == 1) {
- //console.log('');
0) {
- if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) {
+ if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) {
$translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.';
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index e181acd16e1..474b1a24957 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -128,7 +128,7 @@ if ($nolinesbefore) {
trans('ReductionShort'); ?>
situation_cycle_ref) {
+ if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
print ''.$langs->trans('Progress').' ';
print ' ';
}
@@ -416,7 +416,7 @@ if ($nolinesbefore) {
?>
">%
situation_cycle_ref) {
+ if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
$coldisplay++;
print ' % ';
$coldisplay++;
diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php
index b530f5215cc..e1f89b18937 100644
--- a/htdocs/core/tpl/objectline_title.tpl.php
+++ b/htdocs/core/tpl/objectline_title.tpl.php
@@ -105,7 +105,7 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) {
print ''.$langs->trans('ReductionShort').' ';
// Fields for situation invoice
-if ($this->situation_cycle_ref) {
+if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
print ''.$langs->trans('Progress').' ';
print ''.$form->textwithpicto($langs->trans('TotalHT100Short'), $langs->trans('UnitPriceXQtyLessDiscount')).' ';
}
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index 8e9d72d40b4..c0339c28fc4 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -132,7 +132,7 @@ if (($line->info_bits & 2) == 2) {
}
}
} else {
- $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE ? 'dayhour' : 'day';
+ $format = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 'dayhour' : 'day');
if ($line->fk_product > 0) {
print $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : ''));
@@ -288,7 +288,7 @@ if (!empty($line->remise_percent) && $line->special_code != 3) {
}
// Fields for situation invoices
-if ($this->situation_cycle_ref) {
+if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
$coldisplay++;
print ''.$line->situation_percent.'% ';
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index c4e8a1d7226..3ed7441afa5 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -301,3 +301,4 @@ ErrorActionCommPropertyUserowneridNotDefined=User's owner is required
ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary
CheckVersionFail=Version check fail
ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it
+ErrorNotInDictionaryPaymentConditions=Not in Payment Terms Dictionary, please modify.
diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php
index ac2e70e3287..77acafbbd55 100644
--- a/htdocs/product/ajax/products.php
+++ b/htdocs/product/ajax/products.php
@@ -235,7 +235,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
// When used from jQuery, the search term is added as GET param "term".
$searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : ''));
- if (!is_object($form)) {
+ if (!isset($form) || !is_object($form)) {
$form = new Form($db);
}