From 3896cde2998ca736f74735e0f465b34756214933 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Jul 2013 13:38:57 +0200 Subject: [PATCH] Removed useless method. Prefer using generic method. --- .../cheque/class/remisecheque.class.php | 73 +++++-------------- htdocs/compta/paiement/cheque/fiche.php | 6 +- htdocs/core/class/commonobject.class.php | 24 +++--- 3 files changed, 36 insertions(+), 67 deletions(-) diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 7ccb75793aa..aec7c54d53a 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -21,13 +21,13 @@ /** * \file htdocs/compta/paiement/cheque/class/remisecheque.class.php * \ingroup compta - * \brief Fichier de la classe des bordereau de remise de cheque + * \brief File with class to manage cheque delivery receipts */ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** - * Classe permettant la gestion des remises de cheque + * Class to manage cheque delivery receipts */ class RemiseCheque extends CommonObject { @@ -580,25 +580,25 @@ class RemiseCheque extends CommonObject if ( $resql ) { while ( $row = $this->db->fetch_row($resql) ) - { - $total += $row[0]; - $nb++; - } + { + $total += $row[0]; + $nb++; + } - $this->db->free($resql); + $this->db->free($resql); - $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " SET amount = '".price2num($total)."'"; - $sql.= ", nbcheque = ".$nb; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; + $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql.= " SET amount = '".price2num($total)."'"; + $sql.= ", nbcheque = ".$nb; + $sql.= " WHERE rowid = ".$this->id; + $sql.= " AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errno = -1030; - dol_syslog("RemiseCheque::updateAmount ERREUR UPDATE ($this->errno)"); - } + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errno = -1030; + dol_syslog("RemiseCheque::updateAmount ERREUR UPDATE ($this->errno)"); + } } else { @@ -724,41 +724,6 @@ class RemiseCheque extends CommonObject return -2; } } - - /** - * Set the external ref - * - * @param User $user Object user - * @param timestamp $ref_rext External ref - * @return int <0 if KO, >0 if OK - */ - function set_ref_ext($user, $ref_ext) - { - if ($user->rights->banque->cheque) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " SET ref_ext = '".$ref_ext."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog("RemiseCheque::set_ref_ext sql=$sql",LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->ref_ext = $ref_ext; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("RemiseCheque::set_ref_ext ".$this->error,LOG_ERR); - return -1; - } - } - else - { - return -2; - } - } /** @@ -780,7 +745,7 @@ class RemiseCheque extends CommonObject if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCheckReceipt"),'payment').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; - + return $result; } diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index ff20fe04fea..8c55161ca73 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -100,7 +100,7 @@ if ($action == 'setrefext' && $user->rights->banque->cheque) { $ref_ext = GETPOST('ref_ext'); - $result=$object->set_ref_ext($user, $ref_ext); + $result=$object->setValueFrom('ref_ext', $ref_ext); if ($result < 0) { $mesg='
'.$object->error.'
'; @@ -514,10 +514,10 @@ else print ''; print ''; - + // External ref print ''; - + print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c1b75793220..4cb0f68959e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -736,31 +736,35 @@ abstract class CommonObject } /** - * Update a specific field from an object + * Update a specific field into database * * @param string $field Field to update * @param mixte $value New value - * @param string $table To force other table element or element line - * @param int $id To force other object id - * @param string $format Data format ('text' by default, 'date') - * @param string $id_field To force rowid field name + * @param string $table To force other table element or element line (should not be used) + * @param int $id To force other object id (should not be used) + * @param string $format Data format ('text', 'date'). 'text' is used if not defined + * @param string $id_field To force rowid field name. 'rowid' is used it not defined + * @param string $user Update last update fields also if user object provided * @return int <0 if KO, >0 if OK */ - function setValueFrom($field, $value, $table='', $id='', $format='text', $id_field='rowid') + function setValueFrom($field, $value, $table='', $id='', $format='', $id_field='', $user='') { global $conf; - if (empty($table)) $table=$this->table_element; - if (empty($id)) $id=$this->id; + if (empty($table)) $table=$this->table_element; + if (empty($id)) $id=$this->id; + if (empty($format)) $format='text'; + if (empty($id_field)) $id_field='rowid'; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; else if ($format == 'date') $sql.= $field." = '".$this->db->idate($value)."'"; + if (is_object($user)) $sql.=", fk_user_modif = ".$user->id; $sql.= " WHERE ".$id_field." = ".$id; - dol_syslog(get_class($this)."::setValueFrom sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::".__FUNCTION__." sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -2296,7 +2300,7 @@ abstract class CommonObject }); }); } - + setListDependencies(); }); ';
'; print $langs->trans('RefExt'); print '