Fix: change the parameter value of dol_getIdFromCode

This commit is contained in:
Regis Houssin
2017-10-02 11:59:17 +02:00
parent 09e71f1390
commit e65b21a3bf
7 changed files with 33 additions and 33 deletions

View File

@@ -149,7 +149,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
$condpayment = trim($fields[36]);
if ($condpayment == 'A la commande') $condpayment = 'A réception de commande';
if ($condpayment == 'A reception facture') $condpayment = 'Réception de facture';
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', getEntity('c_payment_term'));
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', 1);
if (empty($object->cond_reglement_id))
{
print " - Error cant find payment mode for ".$condpayment."\n";

View File

@@ -461,7 +461,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$paiement = new Paiement($db);
$paiement->datepaye = $paymentdate;
$paiement->amounts = $amounts;
$paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',getEntity('c_paiement'));
$paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',1);
$paiement->num_paiement = $num_chq;
$paiement->note = $label;

View File

@@ -136,7 +136,7 @@ switch ($action)
$cond_reglement_id = 0;
break;
case 'ESP':
$mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement','code','id',getEntity('c_paiement'));
$mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement','code','id',1);
$cond_reglement_id = 0;
$note .= $langs->trans("Cash")."\n";
$note .= $langs->trans("Received").' : '.$obj_facturation->montantEncaisse()." ".$conf->currency."\n";
@@ -145,11 +145,11 @@ switch ($action)
$note .= '--------------------------------------'."\n\n";
break;
case 'CB':
$mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement','code','id',getEntity('c_paiement'));
$mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement','code','id',1);
$cond_reglement_id = 0;
break;
case 'CHQ':
$mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement','code','id',getEntity('c_paiement'));
$mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement','code','id',1);
$cond_reglement_id = 0;
break;
}

View File

@@ -3660,7 +3660,7 @@ class Facture extends CommonInvoice
if (! $error)
{
// Force payment mode of invoice to withdraw
$payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', getEntity('c_paiement'));
$payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1);
if ($payment_mode_id > 0)
{
$result=$this->setPaymentMethods($payment_mode_id);

View File

@@ -251,7 +251,7 @@ if (empty($reshook))
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement','code','id',getEntity('c_paiement'));
$paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement','code','id',1);
$paiement->num_paiement = GETPOST('num_paiement');
$paiement->note = GETPOST('comment');

View File

@@ -792,7 +792,7 @@ class RemiseCheque extends CommonObject
$rejectedPayment = new Paiement($db);
$rejectedPayment->amounts = array();
$rejectedPayment->datepaye = $rejection_date;
$rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement','code','id',getEntity('c_paiement'));
$rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement','code','id',1);
$rejectedPayment->num_paiement = $payment->numero;
while($obj = $db->fetch_object($resql))

View File

@@ -5959,11 +5959,11 @@ function dol_osencode($str)
* @param string $tablename Table name without prefix
* @param string $fieldkey Field for code
* @param string $fieldid Field for id
* @param int $entity Field for filter by entity
* @param int $entityfilter Filter by entity
* @return int <0 if KO, Id of code if OK
* @see $langs->getLabelFromKey
*/
function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id',$entity=null)
function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id',$entityfilter=0)
{
global $cache_codes;
@@ -5979,8 +5979,8 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id',$e
$sql = "SELECT ".$fieldid." as valuetoget";
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'";
if (! is_null($entity))
$sql.= " AND entity = " . (int) $entity;
if (! empty($entityfilter))
$sql.= " AND entity IN (" . getEntity($tablename) . ")";
dol_syslog('dol_getIdFromCode', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)