--- /tmp/dsg/dolibarr/htdocs/compta/paiement/cheque/class/github_19.0.3_remisecheque.class.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/cheque/class/client_remisecheque.class.php @@ -56,2 +55,0 @@ - public $type = 'CHQ'; // 'CHQ', 'TRA', ... - @@ -79,2 +77,2 @@ - public function __construct($db) - { + public function __construct($db) + { @@ -82 +80,3 @@ - } + $this->next_id = 0; + $this->previous_id = 0; + } @@ -89,4 +89,4 @@ - * @return int Return integer <0 if KO, > 0 if OK - */ - public function fetch($id, $ref = '') - { + * @return int <0 if KO, > 0 if OK + */ + public function fetch($id, $ref = '') + { @@ -95,3 +95,3 @@ - $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext,"; - $sql .= " bc.date_bordereau as date_bordereau, bc.type,"; - $sql .= " ba.label as account_label"; + $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext"; + $sql .= ", bc.date_bordereau as date_bordereau"; + $sql .= ", ba.label as account_label"; @@ -101,6 +101,2 @@ - if ($id) { - $sql .= " AND bc.rowid = ".((int) $id); - } - if ($ref) { - $sql .= " AND bc.ref = '".$this->db->escape($ref)."'"; - } + if ($id) $sql .= " AND bc.rowid = ".$id; + if ($ref) $sql .= " AND bc.ref = '".$this->db->escape($ref)."'"; @@ -110,2 +106,4 @@ - if ($resql) { - if ($obj = $this->db->fetch_object($resql)) { + if ($resql) + { + if ($obj = $this->db->fetch_object($resql)) + { @@ -121,3 +119,3 @@ - $this->type = $obj->type; - - if ($this->statut == 0) { + + if ($this->statut == 0) + { @@ -125 +123,3 @@ - } else { + } + else + { @@ -132,2 +132,4 @@ - } else { - $this->error = $this->db->lasterror(); + } + else + { + $this->error = $this->db->lasterror(); @@ -136 +138 @@ - } + } @@ -145,4 +147,4 @@ - * @return int Return integer <0 if KO, >0 if OK - */ - public function create($user, $account_id, $limit, $toRemise) - { + * @return int <0 if KO, >0 if OK + */ + public function create($user, $account_id, $limit, $toRemise) + { @@ -157,5 +158,0 @@ - - // Clean parameters - if (empty($this->type)) { - $this->type = 'CHQ'; - } @@ -176 +172,0 @@ - $sql .= ", type"; @@ -180,2 +176,2 @@ - $sql .= ", ".((int) $user->id); - $sql .= ", ".((int) $account_id); + $sql .= ", ".$user->id; + $sql .= ", ".$account_id; @@ -185 +181 @@ - $sql .= ", ".((int) $conf->entity); + $sql .= ", ".$conf->entity; @@ -188 +183,0 @@ - $sql .= ", '".$this->db->escape($this->type)."'"; @@ -192 +187,2 @@ - if ($resql) { + if ($resql) + { @@ -194 +190,2 @@ - if ($this->id == 0) { + if ($this->id == 0) + { @@ -199 +196,2 @@ - if ($this->id > 0 && $this->errno == 0) { + if ($this->id > 0 && $this->errno == 0) + { @@ -201,2 +199,2 @@ - $sql .= " SET ref = '(PROV".$this->id.")'"; - $sql .= " WHERE rowid=".((int) $this->id); + $sql .= " SET ref='(PROV".$this->id.")'"; + $sql .= " WHERE rowid=".$this->id.""; @@ -205 +203,2 @@ - if (!$resql) { + if (!$resql) + { @@ -211,3 +210,3 @@ - $lines = array(); - - if ($this->id > 0 && $this->errno == 0) { + if ($this->id > 0 && $this->errno == 0) + { + $lines = array(); @@ -216 +215 @@ - $sql .= " WHERE b.fk_type = '".$this->db->escape($this->type)."'"; + $sql .= " WHERE b.fk_type = 'CHQ'"; @@ -219,4 +218,2 @@ - $sql .= " AND b.fk_account = ".((int) $account_id); - if ($limit) { - $sql .= $this->db->plimit($limit); - } + $sql .= " AND b.fk_account='".$account_id."'"; + if ($limit) $sql .= $this->db->plimit($limit); @@ -226,2 +223,4 @@ - if ($resql) { - while ($row = $this->db->fetch_row($resql)) { + if ($resql) + { + while ($row = $this->db->fetch_row($resql)) + { @@ -231 +230,3 @@ - } else { + } + else + { @@ -237,2 +238,4 @@ - if ($this->id > 0 && $this->errno == 0) { - foreach ($lines as $lineid) { + if ($this->id > 0 && $this->errno == 0) + { + foreach ($lines as $lineid) + { @@ -240,4 +243,3 @@ - foreach ($toRemise as $linetoremise) { - if ($linetoremise == $lineid) { - $checkremise = true; - } + foreach ($toRemise as $linetoremise) + { + if ($linetoremise == $lineid) $checkremise = true; @@ -246 +248,2 @@ - if ($checkremise) { + if ($checkremise) + { @@ -248,2 +251,2 @@ - $sql .= " SET fk_bordereau = ".((int) $this->id); - $sql .= " WHERE rowid = ".((int) $lineid); + $sql .= " SET fk_bordereau = ".$this->id; + $sql .= " WHERE rowid = ".$lineid; @@ -252 +255,2 @@ - if (!$resql) { + if (!$resql) + { @@ -260,2 +264,4 @@ - if ($this->id > 0 && $this->errno == 0) { - if ($this->updateAmount() != 0) { + if ($this->id > 0 && $this->errno == 0) + { + if ($this->updateAmount() <> 0) + { @@ -266 +272,3 @@ - } else { + } + else + { @@ -272,14 +280,18 @@ - if (!$this->errno && (getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') || getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_CHEQUE'))) { - $res = $this->validate($user); - //if ($res < 0) $error++; - } - - if (!$this->errno) { - $this->db->commit(); - dol_syslog("RemiseCheque::Create end", LOG_DEBUG); - return $this->id; - } else { - $this->db->rollback(); - dol_syslog("RemiseCheque::Create end", LOG_DEBUG); - return $this->errno; - } + if (!$this->errno && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) + { + $res = $this->validate($user); + //if ($res < 0) $error++; + } + + if (!$this->errno) + { + $this->db->commit(); + dol_syslog("RemiseCheque::Create end", LOG_DEBUG); + return $this->id; + } + else + { + $this->db->rollback(); + dol_syslog("RemiseCheque::Create end", LOG_DEBUG); + return $this->errno; + } @@ -289,3 +301,3 @@ - * Delete deposit from database - * - * @param User $user User that delete + * Supprime la remise en base + * + * @param User $user Utilisateur qui effectue l'operation @@ -294,2 +306,2 @@ - public function delete($user = null) - { + public function delete($user = '') + { @@ -299 +310,0 @@ - @@ -303 +314 @@ - $sql .= " WHERE rowid = ".((int) $this->id); + $sql .= " WHERE rowid = ".$this->id; @@ -307 +318,2 @@ - if ($resql) { + if ($resql) + { @@ -310 +322 @@ - if ($num != 1) { + if ($num <> 1) { @@ -316,13 +328,15 @@ - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql .= " SET fk_bordereau = 0"; - $sql .= " WHERE fk_bordereau = ".((int) $this->id); - - $resql = $this->db->query($sql); - if (!$resql) { - $this->errno = -1028; - dol_syslog("RemiseCheque::Delete ERREUR UPDATE ($this->errno)"); - } - } - } - - if ($this->errno === 0) { + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql .= " SET fk_bordereau = 0"; + $sql .= " WHERE fk_bordereau = ".$this->id; + + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errno = -1028; + dol_syslog("RemiseCheque::Delete ERREUR UPDATE ($this->errno)"); + } + } + } + + if ($this->errno === 0) + { @@ -330 +344,3 @@ - } else { + } + else + { @@ -342,4 +358,4 @@ - * @return int Return integer <0 if KO, >0 if OK - */ - public function validate($user) - { + * @return int <0 if KO, >0 if OK + */ + public function validate($user) + { @@ -354 +370,2 @@ - if ($this->errno == 0 && $numref) { + if ($this->errno == 0 && $numref) + { @@ -356,2 +373,2 @@ - $sql .= " SET statut = 1, ref = '".$this->db->escape($numref)."'"; - $sql .= " WHERE rowid = ".((int) $this->id); + $sql .= " SET statut = 1, ref = '".$numref."'"; + $sql .= " WHERE rowid = ".$this->id; @@ -363 +380,2 @@ - if ($resql) { + if ($resql) + { @@ -366,2 +384,3 @@ - if ($num == 1) { - $this->ref = $numref; + if ($num == 1) + { + $this->ref = $numref; @@ -369 +388,3 @@ - } else { + } + else + { @@ -373 +394,3 @@ - } else { + } + else + { @@ -380 +403,2 @@ - if ($this->errno == 0) { + if ($this->errno == 0) + { @@ -383 +407,3 @@ - } else { + } + else + { @@ -386 +412 @@ - return $this->errno; + return $this->errno; @@ -397,2 +423,2 @@ - public function getNextNumRef($mode = 'next') - { + public function getNextNumRef($mode = 'next') + { @@ -403,9 +429,6 @@ - if (!getDolGlobalString('CHEQUERECEIPTS_ADDON')) { - $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; - } elseif (getDolGlobalString('CHEQUERECEIPTS_ADDON') == 'thyme') { - $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_thyme'; - } elseif (getDolGlobalString('CHEQUERECEIPTS_ADDON') == 'mint') { - $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; - } - - if (getDolGlobalString('CHEQUERECEIPTS_ADDON')) { + if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; + elseif ($conf->global->CHEQUERECEIPTS_ADDON == 'thyme') $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_thyme'; + elseif ($conf->global->CHEQUERECEIPTS_ADDON == 'mint') $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; + + if (!empty($conf->global->CHEQUERECEIPTS_ADDON)) + { @@ -414 +437 @@ - $file = getDolGlobalString('CHEQUERECEIPTS_ADDON') . ".php"; + $file = $conf->global->CHEQUERECEIPTS_ADDON.".php"; @@ -424 +447,2 @@ - if (is_file($dir.$file) && is_readable($dir.$file)) { + if (is_file($dir.$file) && is_readable($dir.$file)) + { @@ -430,3 +454,4 @@ - if (!$mybool) { - $file = getDolGlobalString('CHEQUERECEIPTS_ADDON') . ".php"; - $classname = "mod_chequereceipt_" . getDolGlobalString('CHEQUERECEIPTS_ADDON'); + if (!$mybool) + { + $file = $conf->global->CHEQUERECEIPTS_ADDON.".php"; + $classname = "mod_chequereceipt_".$conf->global->CHEQUERECEIPTS_ADDON; @@ -435 +460,2 @@ - foreach ($conf->file->dol_document_root as $dirroot) { + foreach ($conf->file->dol_document_root as $dirroot) + { @@ -445 +471,2 @@ - if (!$mybool) { + if (!$mybool) + { @@ -464 +491,3 @@ - } else { + } + else + { @@ -469,4 +498,4 @@ - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -476,7 +505,6 @@ - * @param User $user Objet user - * @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...) - * @return WorkboardResponse|int Return integer <0 if KO, WorkboardResponse if OK - */ - public function load_board($user, $type = 'CHQ') - { - // phpcs:enable + * @param User $user Objet user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + */ + public function load_board($user) + { + // phpcs:enable @@ -485,3 +513 @@ - if ($user->socid) { - return -1; // protection pour eviter appel par utilisateur externe - } + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe @@ -494 +520 @@ - $sql .= " AND b.fk_type = '".$this->db->escape($type)."'"; + $sql .= " AND b.fk_type = 'CHQ'"; @@ -499 +525,2 @@ - if ($resql) { + if ($resql) + { @@ -510 +537,2 @@ - while ($obj = $this->db->fetch_object($resql)) { + while ($obj = $this->db->fetch_object($resql)) + { @@ -519 +547,3 @@ - } else { + } + else + { @@ -524,4 +554,4 @@ - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -531,6 +561,5 @@ - * @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...) - * @return int Return integer <0 if ko, >0 if ok - */ - public function load_state_board($type = 'CHQ') - { - // phpcs:enable + * @return int <0 if ko, >0 if ok + */ + public function load_state_board() + { + // phpcs:enable @@ -539,3 +568 @@ - if ($user->socid) { - return -1; // protection pour eviter appel par utilisateur externe - } + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe @@ -548 +575 @@ - $sql .= " AND b.fk_type = '".$this->db->escape($type)."'"; + $sql .= " AND b.fk_type = 'CHQ'"; @@ -552,2 +579,4 @@ - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { + if ($resql) + { + while ($obj = $this->db->fetch_object($resql)) + { @@ -558 +587,3 @@ - } else { + } + else + { @@ -563 +594 @@ - } + } @@ -571,4 +602,4 @@ - * @return int Return integer <0 if KO, >0 if OK - */ - public function generatePdf($model, $outputlangs) - { + * @return int <0 if KO, >0 if OK + */ + public function generatePdf($model, $outputlangs) + { @@ -577,3 +608 @@ - if (empty($model)) { - $model = 'blochet'; - } + if (empty($model)) $model = 'blochet'; @@ -587 +616,2 @@ - if (file_exists($dir.$file)) { + if (file_exists($dir.$file)) + { @@ -600 +630 @@ - $sql .= " AND bc.rowid = ".((int) $this->id); + $sql .= " AND bc.rowid = ".$this->id; @@ -606 +636,2 @@ - if ($result) { + if ($result) + { @@ -608 +639,2 @@ - while ($objp = $this->db->fetch_object($result)) { + while ($objp = $this->db->fetch_object($result)) + { @@ -629,2 +661 @@ - $sav_charset_output = $outputlangs->charset_output; - + $sav_charseSupprimert_output = $outputlangs->charset_output; @@ -632 +663,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -635 +667,3 @@ - } else { + } + else + { @@ -641 +675,3 @@ - } else { + } + else + { @@ -645 +681 @@ - } + } @@ -652,2 +688,2 @@ - public function updateAmount() - { + public function updateAmount() + { @@ -657 +692,0 @@ - @@ -663 +698 @@ - $sql .= " WHERE fk_bordereau = ".((int) $this->id); + $sql .= " WHERE fk_bordereau = ".$this->id; @@ -666,2 +701,4 @@ - if ($resql) { - while ($row = $this->db->fetch_row($resql)) { + if ($resql) + { + while ($row = $this->db->fetch_row($resql)) + { @@ -675,4 +712,4 @@ - $sql .= " SET amount = ".price2num($total); - $sql .= ", nbcheque = ".((int) $nb); - $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= " AND entity = ".((int) $conf->entity); + $sql .= " SET amount = '".price2num($total)."'"; + $sql .= ", nbcheque = ".$nb; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; @@ -681 +718,2 @@ - if (!$resql) { + if (!$resql) + { @@ -685 +723,3 @@ - } else { + } + else + { @@ -690 +730,2 @@ - if ($this->errno === 0) { + if ($this->errno === 0) + { @@ -692 +733,3 @@ - } else { + } + else + { @@ -698 +741 @@ - } + } @@ -706,2 +749,2 @@ - public function removeCheck($account_id) - { + public function removeCheck($account_id) + { @@ -710 +753,2 @@ - if ($this->id > 0) { + if ($this->id > 0) + { @@ -713,2 +757,2 @@ - $sql .= " WHERE rowid = ".((int) $account_id); - $sql .= " AND fk_bordereau = ".((int) $this->id); + $sql .= " WHERE rowid = '".$account_id."'"; + $sql .= " AND fk_bordereau = ".$this->id; @@ -717 +761,2 @@ - if ($resql) { + if ($resql) + { @@ -719 +764,3 @@ - } else { + } + else + { @@ -725 +772 @@ - } + } @@ -735,2 +782,2 @@ - public function rejectCheck($bank_id, $rejection_date) - { + public function rejectCheck($bank_id, $rejection_date) + { @@ -745 +792 @@ - /* Reconciliation is allowed because when check is returned, a new line is created onto bank transaction log. + /* Conciliation is allowed because when check is returned, a new line is created onto bank transaction log. @@ -748,2 +795,2 @@ - $this->error='ActionRefusedLineAlreadyConciliated'; - return -1; + $this->error='ActionRefusedLineAlreadyConciliated'; + return -1; @@ -754 +801 @@ - // Not reconciled, we can delete it + // Not conciliated, we can delete it @@ -762,5 +809,6 @@ - $sql .= ' WHERE pf.fk_paiement = '.((int) $payment->id); - - $resql = $this->db->query($sql); - if ($resql) { - $rejectedPayment = new Paiement($this->db); + $sql .= ' WHERE pf.fk_paiement = '.$payment->id; + + $resql = $db->query($sql); + if ($resql) + { + $rejectedPayment = new Paiement($db); @@ -772,2 +820,3 @@ - while ($obj = $this->db->fetch_object($resql)) { - $invoice = new Facture($this->db); + while ($obj = $db->fetch_object($resql)) + { + $invoice = new Facture($db); @@ -775 +824 @@ - $invoice->setUnpaid($user); + $invoice->set_unpaid($user); @@ -781,11 +830,11 @@ - if ($result > 0) { - // We created a negative payment, we also add the line as bank transaction - $result = $rejectedPayment->addPaymentToBank($user, 'payment', '(CheckRejected)', $bankaccount, '', ''); - if ($result > 0) { - $result = $payment->reject(); - if ($result > 0) { - $this->db->commit(); - return $rejectedPayment->id; - } else { - $this->db->rollback(); - return -1; + if ($result > 0) + { + // We created a negative payment, we also add the line as bank transaction + $result = $rejectedPayment->addPaymentToBank($user, 'payment', '(CheckRejected)', $bankaccount, '', ''); + if ($result > 0) + { + $result = $payment->reject(); + if ($result > 0) + { + $this->db->commit(); + return $rejectedPayment->id; @@ -793,4 +842,11 @@ - } else { - $this->error = $rejectedPayment->error; - $this->errors = $rejectedPayment->errors; - $this->db->rollback(); + else + { + $this->db->rollback(); + return -1; + } + } + else + { + $this->error = $rejectedPayment->error; + $this->errors = $rejectedPayment->errors; + $this->db->rollback(); @@ -799 +855,3 @@ - } else { + } + else + { @@ -802 +860 @@ - $this->db->rollback(); + $this->db->rollback(); @@ -805 +863,3 @@ - } else { + } + else + { @@ -812,3 +872,82 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set the creation date + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Charge les proprietes ref_previous et ref_next + * + * @return int <0 if KO, 0 if OK + */ + public function load_previous_next_id() + { + // phpcs:enable + global $conf; + + $this->errno = 0; + + $sql = "SELECT MAX(rowid)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql .= " WHERE rowid < ".$this->id; + $sql .= " AND entity = ".$conf->entity; + + $result = $this->db->query($sql); + if (!$result) + { + $this->errno = -1035; + } + $row = $this->db->fetch_row($result); + $this->previous_id = $row[0]; + + $sql = "SELECT MIN(rowid)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql .= " WHERE rowid > ".$this->id; + $sql .= " AND entity = ".$conf->entity; + + $result = $this->db->query($sql); + if (!$result) + { + $this->errno = -1035; + } + $row = $this->db->fetch_row($result); + $this->next_id = $row[0]; + + return $this->errno; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set the creation date + * + * @param User $user Object user + * @param int $date Date creation + * @return int <0 if KO, >0 if OK + */ + public function set_date($user, $date) + { + // phpcs:enable + if ($user->rights->banque->cheque) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql .= " SET date_bordereau = ".($date ? "'".$this->db->idate($date)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; + + dol_syslog("RemiseCheque::set_date", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->date_bordereau = $date; + return 1; + } + else + { + $this->error = $this->db->error(); + return -1; + } + } + else + { + return -2; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set the ref of bordereau @@ -817,7 +956,8 @@ - * @param int $date Date creation - * @return int Return integer <0 if KO, >0 if OK - */ - public function set_date($user, $date) - { - // phpcs:enable - if ($user->hasRight('banque', 'cheque')) { + * @param int $ref ref of bordereau + * @return int <0 if KO, >0 if OK + */ + public function set_number($user, $ref) + { + // phpcs:enable + if ($user->rights->banque->cheque) + { @@ -825,4 +965,4 @@ - $sql .= " SET date_bordereau = ".($date ? "'".$this->db->idate($date)."'" : 'null'); - $sql .= " WHERE rowid = ".((int) $this->id); - - dol_syslog("RemiseCheque::set_date", LOG_DEBUG); + $sql .= " SET ref = '".$ref."'"; + $sql .= " WHERE rowid = ".$this->id; + + dol_syslog("RemiseCheque::set_number", LOG_DEBUG); @@ -830,2 +970,2 @@ - if ($resql) { - $this->date_bordereau = $date; + if ($resql) + { @@ -833 +973,3 @@ - } else { + } + else + { @@ -837,30 +979,3 @@ - } else { - return -2; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set the ref of bordereau - * - * @param User $user Object user - * @param int $ref ref of bordereau - * @return int Return integer <0 if KO, >0 if OK - */ - public function set_number($user, $ref) - { - // phpcs:enable - if ($user->hasRight('banque', 'cheque')) { - $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " SET ref = '".$this->db->escape($ref)."'"; - $sql .= " WHERE rowid = ".((int) $this->id); - - dol_syslog("RemiseCheque::set_number", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } else { + } + else + { @@ -879,2 +994,2 @@ - public function initAsSpecimen($option = '') - { + public function initAsSpecimen($option = '') + { @@ -892 +1007 @@ - } + } @@ -899,3 +1014,3 @@ - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking @@ -904,2 +1019,2 @@ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { @@ -914,24 +1029,22 @@ - $url = DOL_URL_ROOT.'/compta/paiement/cheque/card.php?id='.$this->id; - - if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { - $add_save_lastsearch_values = 1; - } - if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; - } - } - - $linkclose = ''; - if (empty($notooltip)) { - if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { - $label = $langs->trans("ShowCheckReceipt"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - } + $url = DOL_URL_ROOT.'/compta/paiement/cheque/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } + + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowCheckReceipt"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); @@ -944,6 +1057,2 @@ - if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - } - if ($withpicto != 2) { - $result .= $this->ref; - } + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; @@ -953,84 +1062,39 @@ - } - - /** - * Return the label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->statut, $mode); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the label of a given status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - global $langs; - $langs->load('compta'); - $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('ToValidate'); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('ToValidate'); - $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - } - - $statusType = 'status'.$status; - if ($status == self::STATUS_VALIDATED) { - $statusType = 'status4'; - } - - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } - - /** - * Return clicable link of object (with eventually picto) - * - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) - * @param array $arraydata Array of data - * @return string HTML Code for Kanban thumb. - */ - public function getKanbanView($option = '', $arraydata = null) - { - global $langs; - - $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); - - $return = '