Add RefExt field on RemiseCheque

This commit is contained in:
Maxime Kohlhaas 2013-07-19 08:54:11 +02:00
parent aff2be1bc0
commit 7abc53698a
6 changed files with 96 additions and 2 deletions

View File

@ -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;
}
}
/**

View File

@ -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&amp;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);

View File

@ -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;

View File

@ -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;

View File

@ -154,3 +154,4 @@ InvoiceLinesToDispatch=Invoice lines to dispatch
InvoiceDispatched=Dispatched invoices
AccountancyDashboard=Accountancy summary
ByProductsAndServices=By products and services
RefExt=External ref

View File

@ -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