diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 2d5eaebf8e94244962edee1663361c5ef8300292..2f7db2cc226dada33cdcf9bea1edfcd9aa7d3176 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -37,6 +37,7 @@ class RemiseCheque extends CommonObject var $id; var $num; var $intitule; + var $ref_ext; //! Numero d'erreur Plage 1024-1279 var $errno; @@ -63,7 +64,7 @@ class RemiseCheque extends CommonObject { global $conf; - $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.number, bc.statut, bc.nbcheque"; + $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.number, bc.statut, bc.nbcheque, bc.ref_ext"; $sql.= ", bc.date_bordereau as date_bordereau"; $sql.= ", ba.label as account_label"; $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc"; @@ -86,6 +87,7 @@ class RemiseCheque extends CommonObject $this->author_id = $obj->fk_user_author; $this->nbcheque = $obj->nbcheque; $this->statut = $obj->statut; + $this->ref_ext = $obj->ref_ext; if ($this->statut == 0) { @@ -139,6 +141,7 @@ class RemiseCheque extends CommonObject $sql.= ", number"; $sql.= ", entity"; $sql.= ", nbcheque"; + $sql.= ", ref_ext"; $sql.= ") VALUES ("; $sql.= $this->db->idate($now); $sql.= ", ".$this->db->idate($now); @@ -149,6 +152,7 @@ class RemiseCheque extends CommonObject $sql.= ", 0"; $sql.= ", ".$conf->entity; $sql.= ", 0"; + $sql.= ", ''"; $sql.= ")"; dol_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG); @@ -720,6 +724,41 @@ 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; + } + } /** diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index 7cf5d15f3a270adea276a4d0861b54e62c8a2593..ff20fe04fea55aeb67bc3551c00c29a04e30996c 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -89,6 +89,29 @@ if ($action == 'setdate' && $user->rights->banque->cheque) } } +/* + * Actions + */ + +if ($action == 'setrefext' && $user->rights->banque->cheque) +{ + $result = $object->fetch(GETPOST('id','int')); + if ($result > 0) + { + $ref_ext = GETPOST('ref_ext'); + + $result=$object->set_ref_ext($user, $ref_ext); + if ($result < 0) + { + $mesg='<div class="error">'.$object->error.'</div>'; + } + } + else + { + $mesg='<div class="error">'.$object->error.'</div>'; + } +} + if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque) { if (is_array($_POST['toRemise'])) @@ -491,6 +514,32 @@ else print '</td>'; print '</tr>'; + + // External ref + print '<tr><td>'; + + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('RefExt'); + print '</td>'; + if ($action != 'editrefext') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editrefext&id='.$object->id.'">'.img_edit($langs->trans('SetRefExt'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="2">'; + if ($action == 'editrefext') + { + print '<form name="setrefext" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="setrefext">'; + print '<input type="text" name="ref_ext" value="'.$object->ref_ext.'">'; + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; + print '</form>'; + } + else + { + print $object->ref_ext; + } + + print '</td>'; + print '</tr>'; print '<tr><td>'.$langs->trans('Account').'</td><td colspan="2">'; print $accountstatic->getNomUrl(1); diff --git a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql index 62811bdb70ce8d7d3ddfd4a9b3546b6bc94e257f..76137d75b7f4db1bb38dfeb5cbcce56d2c368d16 100755 --- a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql +++ b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql @@ -275,3 +275,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN22', 1001, '', 0, '', 'Tozeur', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN23', 1001, '', 0, '', 'Tunis', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN24', 1001, '', 0, '', 'Zaghouan', 1); + +# Add ref_ext on bordereau_cheque +ALTER TABLE `llx_bordereau_cheque` ADD `ref_ext` VARCHAR( 255 ) NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_bordereau_cheque.sql b/htdocs/install/mysql/tables/llx_bordereau_cheque.sql index cc93cf188d64e99678edb5fd7e099b11f1381cd8..60365665932769eb6807518451eeb2fedcc61279 100644 --- a/htdocs/install/mysql/tables/llx_bordereau_cheque.sql +++ b/htdocs/install/mysql/tables/llx_bordereau_cheque.sql @@ -33,6 +33,7 @@ create table llx_bordereau_cheque fk_bank_account integer, fk_user_author integer, note text, - statut smallint NOT NULL DEFAULT 0 + statut smallint NOT NULL DEFAULT 0, + ref_ext varchar(255) )ENGINE=innodb; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index cf95e809e4f2cee33dcb4447651fde914482e103..c2a27fe8b7dbc5f859e76304ec0a143a6cb8f1ce 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -154,3 +154,4 @@ InvoiceLinesToDispatch=Invoice lines to dispatch InvoiceDispatched=Dispatched invoices AccountancyDashboard=Accountancy summary ByProductsAndServices=By products and services +RefExt=External ref \ No newline at end of file diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index a86676b36b9d1915964767339ed5957e003ed0b6..0b9cf8b7dda5c5bc71110f969bb1f7d38e97d902 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -165,3 +165,4 @@ InvoiceLinesToDispatch=Lignes de factures à ventiler InvoiceDispatched=Factures ventilées AccountancyDashboard=Synthèse compta/tréso ByProductsAndServices=Par produits et services +RefExt=Référence externe