Add INVOICE_ALLOW_FREE_REF as a quick hack to solve trouble with non

european users.
This commit is contained in:
Laurent Destailleur 2019-12-16 22:30:16 +01:00
parent 6e2e02fd40
commit 138215fc3f
3 changed files with 20 additions and 8 deletions

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
// 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 .= '<br>';
}
// 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);

View File

@ -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);

View File

@ -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
*/