diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7930ef44aa7a8..da6a66741f399 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9139,7 +9139,7 @@ public function setVarsFromFetchObj(&$obj) foreach ($this->fields as $field => $info) { if ($this->isDate($info)) { - if (is_null($obj->$field) || $obj->$field === '' || $obj->$field === '0000-00-00 00:00:00' || $obj->$field === '1000-01-01 00:00:00') { + if (!isset($obj->$field) || is_null($obj->$field) || $obj->$field === '' || $obj->$field === '0000-00-00 00:00:00' || $obj->$field === '1000-01-01 00:00:00') { $this->$field = ''; } else { $this->$field = $db->jdate($obj->$field); @@ -9155,7 +9155,7 @@ public function setVarsFromFetchObj(&$obj) $this->$field = (double) $obj->$field; } } else { - if (!is_null($obj->$field) || (isset($info['notnull']) && $info['notnull'] == 1)) { + if (isset($obj->$field) && !is_null($obj->$field) || (isset($info['notnull']) && $info['notnull'] == 1)) { $this->$field = (int) $obj->$field; } else { $this->$field = null; @@ -9170,7 +9170,7 @@ public function setVarsFromFetchObj(&$obj) $this->$field = (double) $obj->$field; } } else { - if (!is_null($obj->$field) || (isset($info['notnull']) && $info['notnull'] == 1)) { + if (isset($obj->$field) && !is_null($obj->$field) || (isset($info['notnull']) && $info['notnull'] == 1)) { $this->$field = (double) $obj->$field; } else { $this->$field = null; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d38a9c6624e08..288eadc69034e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -116,7 +116,7 @@ public function __construct($db) * * @param string $attrname Code of attribute * @param string $label label of attribute - * @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price', 'pricecy', 'phone','mail','password','url','select','checkbox','separate',...) + * @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datetime','price', 'pricecy', 'phone','mail','password','url','select','checkbox','separate',...) * @param int $pos Position of attribute * @param string $size Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma. * @param string $elementtype Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...) @@ -185,7 +185,7 @@ public function addExtraField($attrname, $label, $type, $pos, $size, $elementtyp * This is a private method. For public method, use addExtraField. * * @param string $attrname code of attribute - * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','pricecy','phone','mail','password','url','select','checkbox', ...) + * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime','price','pricecy','phone','mail','password','url','select','checkbox', ...) * @param string $length Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not @@ -281,7 +281,7 @@ private function create($attrname, $type = 'varchar', $length = 255, $elementtyp * * @param string $attrname code of attribute * @param string $label label of attribute - * @param int $type Type of attribute ('int', 'varchar', 'text', 'html', 'date', 'datehour', 'float') + * @param int $type Type of attribute ('int', 'varchar', 'text', 'html', 'date', 'datetime', 'float') * @param int $pos Position of attribute * @param string $size Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) @@ -529,7 +529,7 @@ private function delete_label($attrname, $elementtype = 'member') * * @param string $attrname Name of attribute * @param string $label Label of attribute - * @param string $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...) + * @param string $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime','price','phone','mail','password','url','select','checkbox', ...) * @param int $length Length of attribute * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 9f239a8c0fcec..9562890c80e17 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -520,6 +520,8 @@ public function update(User $user, $notrigger = 0) $sql .= " auto_validate = ". (!empty($this->auto_validate) ? ((int) $this->auto_validate) : 0); $sql .= " WHERE rowid = ". (int) $this->id; + $this->db->begin(); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -981,7 +983,7 @@ public function addline($fk_product, $ref, $label, $desc, $pu_ht, $pu_ttc, $qty, $sql .= ', fk_user_author'; $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; $sql .= ') VALUES ('; - $sql .= ' ' . (int) $facid; // source supplier invoie id + $sql .= ' ' . (int) $facid; // source supplier invoice id $sql .= ', ' . (!empty($fk_product) ? "'" . $this->db->escape($fk_product) . "'" : 'null'); $sql .= ', ' . (!empty($ref) ? "'" . $this->db->escape($ref) . "'" : 'null'); $sql .= ', ' . (!empty($label) ? "'" . $this->db->escape($label) . "'" : 'null'); @@ -1009,7 +1011,7 @@ public function addline($fk_product, $ref, $label, $desc, $pu_ht, $pu_ttc, $qty, $sql .= ', ' . (int) $special_code; $sql .= ', ' . (int) $rang; $sql .= ', ' . ($fk_unit ? (int) $fk_unit : 'NULL'); - $sql .= ', ' . (int) $user; + $sql .= ', ' . (int) $user->id; $sql .= ', ' . (int) $this->fk_multicurrency; $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'"; $sql .= ', ' . price2num($pu_ht_devise, 'CU'); @@ -2192,7 +2194,7 @@ public function update(User $user, $notrigger = 0) $sql .= ', special_code =' . (int) $this->special_code; $sql .= ', rang = ' . (int) $this->rang; $sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null'); - $sql .= ', fk_user_modif = ' . (int) $user; + $sql .= ', fk_user_modif = ' . (int) $user->id; $sql .= ' WHERE rowid = ' . (int) $this->id; $this->db->begin(); diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index f34acbe308c4f..97dae7e1a14ce 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -372,8 +372,18 @@ function LoadProducts(position, issubcat) { } ?> if (data[parseInt(idata)]['price_formated']) { - $("#proprice"+ishow).attr("class", "productprice"); - $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']); + $("#proprice" + ishow).attr("class", "productprice"); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_formated']); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_ttc_formated']); + } console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']); console.log($("#prodiv"+ishow)); @@ -458,8 +468,18 @@ function MoreProducts(moreorless) { $("#probutton"+ishow).html(data[parseInt(idata)]['label']); $("#probutton"+ishow).show(); if (data[parseInt(idata)]['price_formated']) { - $("#proprice"+ishow).attr("class", "productprice"); - $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']); + $("#proprice" + ishow).attr("class", "productprice"); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_formated']); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_ttc_formated']); + } $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); @@ -670,7 +690,17 @@ function Search2(keyCodeForEnter, moreorless) { $("#probutton" + i).show(); if (data[i]['price_formated']) { $("#proprice" + i).attr("class", "productprice"); - $("#proprice" + i).html(data[i]['price_ttc_formated']); + + $("#proprice" + i).html(data[i]['price_formated']); + + $("#proprice" + i).html(data[i]['price_ttc_formated']); + } $("#proimg" + i).attr("title", titlestring); if( undefined !== data[i]['img']) { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 255289d6e5a08..3a6051ccc6e88 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -289,6 +289,10 @@ function fail($message) if ($pay != "delayed") { $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + if ($res < 0) { + $error++; + dol_htmloutput_errors($langs->trans('ErrorNoPaymentDefined'), $payment->errors, 1); + } $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded } elseif (getDolGlobalInt("TAKEPOS_DELAYED_TERMS")) { $invoice->setPaymentTerms(getDolGlobalInt("TAKEPOS_DELAYED_TERMS"));