diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 92e0f0a7543..b5db78e8154 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -497,6 +497,12 @@ if (empty($reshook)) } } + elseif ($action == 'setref' && $usercancreate) + { + $object->fetch($id); + $object->setValueFrom('ref', GETPOST('ref'), '', null, '', '', $user, 'BILL_MODIFY'); + } + elseif ($action == 'setref_client' && $usercancreate) { $object->fetch($id); @@ -3816,6 +3822,12 @@ elseif ($id > 0 || !empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + // Ref invoice + if ($object->status == $object::STATUS_DRAFT && ! $mysoc->isInEEC() && ! empty($conf->global->INVOICE_ALLOW_FREE_REF)) { + $morehtmlref .= $form->editfieldkey("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', null, null, '', 1); + $morehtmlref .= '
'; + } // Ref customer $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7886b62f00e..05b7fc88196 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1378,12 +1378,13 @@ class Facture extends CommonInvoice $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; - if ($rowid) $sql .= " WHERE f.rowid=".$rowid; - else $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid - - if ($ref) $sql .= " AND f.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND f.ref_int='".$this->db->escape($ref_int)."'"; + if ($rowid) $sql .= " WHERE f.rowid=".$rowid; + else { + $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid + if ($ref) $sql .= " AND f.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND f.ref_int='".$this->db->escape($ref_int)."'"; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -1832,7 +1833,6 @@ class Facture extends CommonInvoice { $srcinvoice = new Facture($this->db); $srcinvoice->fetch($remise->fk_facture_source); - $totalcostpriceofinvoice = 0; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject $formmargin = new FormMargin($this->db); $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 01fe1c848c3..1268fb505a7 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -644,7 +644,7 @@ function getFormeJuridiqueLabel($code) /** * Return list of countries that are inside the EEC (European Economic Community) - * TODO Add a field into country dictionary. + * Note: Try to keep this function as a "memory only" function for performance reasons. * * @return array Array of countries code in EEC */