New: Nav works on bank line

This commit is contained in:
Laurent Destailleur 2010-08-22 13:40:44 +00:00
parent 9d781afe1d
commit 75f3b9e631
6 changed files with 771 additions and 772 deletions

File diff suppressed because it is too large Load Diff

View File

@ -903,10 +903,12 @@ class Account extends CommonObject
* \class AccountLine
* \brief Classe permettant la gestion des lignes de transactions bancaires
*/
class AccountLine
class AccountLine extends CommonObject
{
var $error;
var $db;
var $element='bank';
var $table_element='bank';
var $id;
var $ref;
@ -940,15 +942,19 @@ class AccountLine
}
/**
* \brief Charge en memoire depuis la base, une ecriture sur le compte
* \param id Id de la ligne ecriture a recuperer
* \return int <0 if KO, >0 if OK
* \brief Charge en memoire depuis la base, une ecriture sur le compte
* \param id Id de la ligne ecriture a recuperer
* \param ref Ref of object
* \return int <0 if KO, >0 if OK
*/
function fetch($rowid)
function fetch($rowid,$ref='')
{
global $conf;
$sql = "SELECT b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,";
// Check parameters
if (empty($rowid) && empty($ref)) return -1;
$sql = "SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,";
$sql.= " b.fk_user_author, b.fk_user_rappro,";
$sql.= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,";
$sql.= " ba.label as bank_account_label";
@ -956,19 +962,19 @@ class AccountLine
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND b.rowid = ".$rowid;
if ($ref) $sql.= " AND b.rowid='".$ref."'";
else $sql.= " AND b.rowid=".$rowid;
dol_syslog("AccountLine::fetch sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $rowid;
$this->rowid = $rowid;
$this->ref = $rowid;
$obj = $this->db->fetch_object($result);
if ($obj)
{
$this->id = $obj->rowid;
$this->rowid = $obj->rowid;
$this->ref = $obj->rowid;
$this->datec = $obj->datec;
$this->datev = $obj->datev;

View File

@ -38,6 +38,7 @@ $langs->load("categories");
if ($conf->adherent->enabled) $langs->load("members");
$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
$ref=isset($_GET["ref"])?$_GET["ref"]:$_POST["ref"];
$orig_account=isset($_GET["orig_account"])?$_GET["orig_account"]:$_POST["orig_account"];
$html = new Form($db);
@ -228,40 +229,32 @@ if ($result)
$objp = $db->fetch_object($result);
$total = $total + $objp->amount;
$acct=new Account($db,$objp->fk_account);
$acct=new Account($db);
$acct->fetch($objp->fk_account);
$account = $acct->id;
$bankline = new AccountLine($db);
$bankline->fetch($rowid,$ref);
$links=$acct->get_url($rowid);
$bankline->load_previous_next_ref('','rowid');
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref")."</td>";
print '<td colspan="4">'.$objp->rowid.'</td>';
print '<td colspan="4">';
print $html->showrefnav($bankline,'rowid','',1,'rowid','rowid');
print '</td>';
print '</tr>';
// Author
print '<tr><td width="20%">'.$langs->trans("Author")."</td>";
if ($objp->fk_user_author)
{
$author=new User($db);
$author->fetch($objp->fk_user_author);
print '<td colspan="4"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$author->id.'">';
print img_object($langs->trans("ShowUser"),'user').' '.$author->getFullName($langs).'</a></td>';
}
else
{
print '<td colspan="4">&nbsp;</td>';
}
print "</tr>";
$i++;
$i++;
print '<form name="update" method="post" action="ligne.php?rowid='.$objp->rowid.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print "<input type=\"hidden\" name=\"orig_account\" value=\"".$orig_account."\">";
// Account
// Account
print "<tr><td>".$langs->trans("Account")."</td>";
print '<td colspan="4">';
print '<a href="account.php?account='.$acct->id.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.'</a>';
@ -269,7 +262,72 @@ if ($result)
print '</td>';
print '</tr>';
// Date ope
// Show links of bank transactions
if (sizeof($links))
{
print "<tr><td>".$langs->trans("Links")."</td>";
print '<td colspan="4">';
foreach($links as $key=>$val)
{
if ($key) print '<br>';
if ($links[$key]['type']=='payment') {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='payment_supplier') {
print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='company') {
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowCustomer'),'company').' ';
print $links[$key]['label'];
print '</a>';
}
else if ($links[$key]['type']=='sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowSocialContribution'),'bill').' ';
print $langs->trans("SocialContribution").($links[$key]['label']?' - '.$links[$key]['label']:'');
print '</a>';
}
else if ($links[$key]['type']=='payment_sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("SocialContributionPayment");
print '</a>';
}
else if ($links[$key]['type']=='payment_vat') {
print '<a href="'.DOL_URL_ROOT.'/compta/tva/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowVAT'),'payment').' ';
print $langs->trans("VATPayment");
print '</a>';
}
else if ($links[$key]['type']=='member') {
print '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowMember'),'user').' ';
print $links[$key]['label'];
print '</a>';
}
else if ($links[$key]['type']=='banktransfert') {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowTransaction'),'payment').' ';
print $langs->trans("TransactionOnTheOtherAccount");
print '</a>';
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';
}
}
print '</td></tr>';
}
// Date ope
print '<tr><td>'.$langs->trans("DateOperation").'</td>';
if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate))
{
@ -340,71 +398,6 @@ if ($result)
}
print '</td></tr>';
// Affiche liens
if (sizeof($links))
{
print "<tr><td>".$langs->trans("Links")."</td>";
print '<td colspan="3">';
foreach($links as $key=>$val)
{
if ($key) print '<br>';
if ($links[$key]['type']=='payment') {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='payment_supplier') {
print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='company') {
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowCustomer'),'company').' ';
print $links[$key]['label'];
print '</a>';
}
else if ($links[$key]['type']=='sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowBill'),'bill').' ';
print $langs->trans("SocialContribution");
print '</a>';
}
else if ($links[$key]['type']=='payment_sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("SocialContributionPayment");
print '</a>';
}
else if ($links[$key]['type']=='payment_vat') {
print '<a href="'.DOL_URL_ROOT.'/compta/tva/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowVAT'),'payment').' ';
print $langs->trans("VATPayment");
print '</a>';
}
else if ($links[$key]['type']=='member') {
print '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowMember'),'user').' ';
print $links[$key]['label'];
print '</a>';
}
else if ($links[$key]['type']=='banktransfert') {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowTransaction'),'payment').' ';
print $langs->trans("TransactionOnTheOtherAccount");
print '</a>';
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';
}
}
print '</td><td>&nbsp;</td></tr>';
}
// Amount
print "<tr><td>".$langs->trans("Amount")."</td>";
if (! $objp->rappro && $user->rights->banque->modifier)

View File

@ -97,6 +97,9 @@ if ($_POST["action"] == 'add_paiement')
$paiement->note = $_POST["note"];
$paymentid = $paiement->create($user);
$socialcontrib = new ChargeSociales($db);
$socialcontrib->fetch($paiement->chid);
if ($paymentid > 0)
{
// On determine le montant total du paiement
@ -123,7 +126,7 @@ if ($_POST["action"] == 'add_paiement')
// Mise a jour liens (pour chaque charge concernee par le paiement)
foreach ($paiement->amounts as $key => $value)
{
//$acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/charges.php?id=', '(socialcontribution)','payment_sc');
$acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc');
$acc->add_url_line($bank_line_id, $paymentid, DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id=', '(paiement)','payment_sc');
}

View File

@ -728,7 +728,7 @@ class CommonObject
}
/**
*
*
* Enter description here ...
* @param unknown_type $rowid
*/
@ -744,7 +744,7 @@ class CommonObject
}
/**
*
*
* Enter description here ...
* @param unknown_type $rowid
*/
@ -761,7 +761,7 @@ class CommonObject
// Update position of line
$this->updateLineDown($rowid, $rang, $max);
}
/**
* Update position of line (rang)
*/
@ -774,7 +774,7 @@ class CommonObject
dol_print_error($this->db);
}
}
/**
* Update position of line up (rang)
*/
@ -800,7 +800,7 @@ class CommonObject
}
}
}
/**
* Update position of line down (rang)
*/
@ -826,7 +826,7 @@ class CommonObject
}
}
}
/**
* Get position of line (rang)
* @result int Value of rang in table of lines
@ -842,7 +842,7 @@ class CommonObject
return $row[0];
}
}
/**
* Get rowid of the line relative to its position
* @result int Rowid of the line

View File

@ -2975,17 +2975,17 @@ class Form
}
/**
* \brief Return a HTML area with the reference of object and a naviagation bar for a business object
* \param object Object to show
* \param paramid Name of parameter to use to name the id into the URL link
* \param morehtml More html content to output just before the nav bar
* \param shownav Show Condition (navigation is shown if value is 1)
* \param fieldid Nom du champ en base a utiliser pour select next et previous
* \param fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* \param morehtmlref Code html supplementaire a afficher apres ref
* \param moreparam More param to add in nav link url.
* \return string Portion HTML avec ref + boutons nav
* \remarks To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
* Return a HTML area with the reference of object and a naviagation bar for a business object
* To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
* @param object Object to show
* @param paramid Name of parameter to use to name the id into the URL link
* @param morehtml More html content to output just before the nav bar
* @param shownav Show Condition (navigation is shown if value is 1)
* @param fieldid Nom du champ en base a utiliser pour select next et previous
* @param fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* @param morehtmlref Code html supplementaire a afficher apres ref
* @param moreparam More param to add in nav link url.
* @return string Portion HTML avec ref + boutons nav
*/
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='')
{