Skip to content

Commit

Permalink
Fix: change the parameter value of dol_getIdFromCode
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Oct 2, 2017
1 parent 09e71f1 commit e65b21a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion dev/initdata/import-thirdparties.php
Expand Up @@ -149,7 +149,7 @@
$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";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/subscription.php
Expand Up @@ -461,7 +461,7 @@
$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;

Expand Down
6 changes: 3 additions & 3 deletions htdocs/cashdesk/validation_verif.php
Expand Up @@ -136,7 +136,7 @@
$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";
Expand All @@ -145,11 +145,11 @@
$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;
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/facture/class/facture.class.php
Expand Up @@ -3660,7 +3660,7 @@ function demande_prelevement($fuser, $amount=0)
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);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/paiement.php
Expand Up @@ -251,7 +251,7 @@
$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');

Expand Down
32 changes: 16 additions & 16 deletions htdocs/compta/paiement/cheque/class/remisecheque.class.php
Expand Up @@ -478,8 +478,8 @@ function getNextNumRef($mode='next')
return "";
}
}


/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
Expand All @@ -489,9 +489,9 @@ function getNextNumRef($mode='next')
function load_board($user)
{
global $conf, $langs;

if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe

$sql = "SELECT b.rowid, b.datev as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
Expand All @@ -500,28 +500,28 @@ function load_board($user)
$sql.= " AND b.fk_type = 'CHQ'";
$sql.= " AND b.fk_bordereau = 0";
$sql.= " AND b.amount > 0";

$resql=$this->db->query($sql);
if ($resql)
{
$langs->load("banks");
$now=dol_now();

$response = new WorkboardResponse();
$response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24;
$response->label=$langs->trans("BankChecksToReceipt");
$response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank';
$response->img=img_object('',"payment");

while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;

if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->cheque->warning_delay)) {
$response->nbtodolate++;
}
}

return $response;
}
else
Expand All @@ -531,8 +531,8 @@ function load_board($user)
return -1;
}
}


/**
* Charge indicateurs this->nb de tableau de bord
*
Expand All @@ -541,21 +541,21 @@ function load_board($user)
function load_state_board()
{
global $user;

if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe

$sql = "SELECT count(b.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.fk_type = 'CHQ'";
$sql.= " AND b.amount > 0";

$resql=$this->db->query($sql);
if ($resql)
{

while ($obj=$this->db->fetch_object($resql))
{
$this->nb["cheques"]=$obj->nb;
Expand Down Expand Up @@ -792,7 +792,7 @@ function rejectCheck($bank_id, $rejection_date)
$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))
Expand Down
20 changes: 10 additions & 10 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -5954,16 +5954,16 @@ function dol_osencode($str)
* Return an id or code from a code or id.
* Store also Code-Id into a cache to speed up next request on same key.
*
* @param DoliDB $db Database handler
* @param string $key Code or Id to get Id or Code
* @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
* @return int <0 if KO, Id of code if OK
* @param DoliDB $db Database handler
* @param string $key Code or Id to get Id or Code
* @param string $tablename Table name without prefix
* @param string $fieldkey Field for code
* @param string $fieldid Field for id
* @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;

Expand All @@ -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)
Expand Down

0 comments on commit e65b21a

Please sign in to comment.