Fix: uniformize code and force paiement type if cash account

This commit is contained in:
Regis Houssin 2012-02-13 14:49:20 +01:00
parent 1f5a103851
commit c86183e18c
2 changed files with 74 additions and 81 deletions

View File

@ -3,7 +3,7 @@
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2004 Christophe Combelles <ccomb@free.fr> * Copytight (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copytight (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copytight (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copytight (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es> * Copytight (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -37,22 +37,22 @@ require_once(DOL_DOCUMENT_ROOT."/fourn/class/paiementfourn.class.php");
$langs->load("bills"); $langs->load("bills");
$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
$ref = GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check // Security check
if (isset($_GET["account"]) || isset($_GET["ref"])) $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
{ $fieldtype = (! empty($ref) ? 'ref' :'rowid');
$id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:'');
}
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque',$id,'bank_account','','',$fieldid); $result=restrictedArea($user,'banque',$fieldvalue,'bank_account','','',$fieldtype);
$req_nb=GETPOST("req_nb",'',3); $req_nb=GETPOST("req_nb",'',3);
$thirdparty=GETPOST("thirdparty",'',3); $thirdparty=GETPOST("thirdparty",'',3);
$account=GETPOST("account");
$vline=GETPOST("vline"); $vline=GETPOST("vline");
$action=GETPOST("action"); $page=GETPOST('page','int');
$page=isset($_GET["page"])?$_GET["page"]:0; $negpage=GETPOST('negpage','int');
$negpage=isset($_GET["negpage"])?$_GET["negpage"]:0;
if ($negpage) if ($negpage)
{ {
$page=$_GET["nbpage"] - $negpage; $page=$_GET["nbpage"] - $negpage;
@ -61,13 +61,14 @@ if ($negpage)
$mesg=''; $mesg='';
$object = new Account($db);
/* /*
* Action * Action
*/ */
$dateop=-1; $dateop=-1;
if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banque->modifier)
{ {
if (price2num($_POST["credit"]) > 0) if (price2num($_POST["credit"]) > 0)
{ {
@ -90,17 +91,16 @@ if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->
if (! $mesg) if (! $mesg)
{ {
$acct=new Account($db); $object->fetch($id);
$acct->fetch($account); $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
if ($insertid > 0) if ($insertid > 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?account=" . $account."&action=addline"); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline");
exit; exit;
} }
else else
{ {
dol_print_error($db,$acct->error); $mesg=$object->error;
} }
} }
else else
@ -108,7 +108,7 @@ if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->
$action='addline'; $action='addline';
} }
} }
if ($action == 'confirm_delete' && $_POST["confirm"]=='yes' && $user->rights->banque->modifier) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier)
{ {
$accline=new AccountLine($db); $accline=new AccountLine($db);
$accline->fetch($_GET["rowid"]); $accline->fetch($_GET["rowid"]);
@ -131,7 +131,7 @@ $paymentvatstatic=new TVA($db);
$form = new Form($db); $form = new Form($db);
if ($account || $_GET["ref"]) if ($id > 0 || ! empty($ref))
{ {
if ($vline) if ($vline)
{ {
@ -141,16 +141,8 @@ if ($account || $_GET["ref"])
{ {
$viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT; $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT;
} }
$acct = new Account($db);
if ($account) $result=$object->fetch($id, $ref);
{
$result=$acct->fetch($account);
}
if ($_GET["ref"])
{
$result=$acct->fetch(0,$_GET["ref"]);
$account=$acct->id;
}
// Chargement des categories bancaires dans $options // Chargement des categories bancaires dans $options
$nbcategories=0; $nbcategories=0;
@ -187,22 +179,22 @@ if ($account || $_GET["ref"])
$param.='&amp;req_nb='.urlencode($req_nb); $param.='&amp;req_nb='.urlencode($req_nb);
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["req_desc"]) if (GETPOST("req_desc"))
{ {
$sql_rech.= " AND b.label LIKE '%".$db->escape($_REQUEST["req_desc"])."%'"; $sql_rech.= " AND b.label LIKE '%".$db->escape(GETPOST("req_desc"))."%'";
$param.='&amp;req_desc='.urlencode($_REQUEST["req_desc"]); $param.='&amp;req_desc='.urlencode(GETPOST("req_desc"));
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["req_debit"]) if (GETPOST("req_debit"))
{ {
$sql_rech.=" AND b.amount = -".price2num($_REQUEST["req_debit"]); $sql_rech.=" AND b.amount = -".price2num(GETPOST("req_debit"));
$param.='&amp;req_debit='.urlencode($_REQUEST["req_debit"]); $param.='&amp;req_debit='.urlencode(GETPOST("req_debit"));
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["req_credit"]) if (GETPOST("req_credit"))
{ {
$sql_rech.=" AND b.amount = ".price2num($_REQUEST["req_credit"]); $sql_rech.=" AND b.amount = ".price2num(GETPOST("req_credit"));
$param.='&amp;req_credit='.urlencode($_REQUEST["req_credit"]); $param.='&amp;req_credit='.urlencode(GETPOST("req_credit"));
$mode_search = 1; $mode_search = 1;
} }
if ($thirdparty) if ($thirdparty)
@ -211,10 +203,10 @@ if ($account || $_GET["ref"])
$param.='&amp;thirdparty='.urlencode($thirdparty); $param.='&amp;thirdparty='.urlencode($thirdparty);
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["paiementtype"]) if (GETPOST("paiementtype"))
{ {
$sql_rech.=" AND b.fk_type = '".$db->escape($_REQUEST["paiementtype"])."'"; $sql_rech.=" AND b.fk_type = '".$db->escape(GETPOST("paiementtype"))."'";
$param.='&amp;paiementtype='.urlencode($_REQUEST["paiementtype"]); $param.='&amp;paiementtype='.urlencode(GETPOST("paiementtype"));
$mode_search = 1; $mode_search = 1;
} }
@ -226,7 +218,7 @@ if ($account || $_GET["ref"])
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
} }
$sql.= " WHERE b.fk_account = ".$acct->id; $sql.= " WHERE b.fk_account = ".$object->id;
$sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity; $sql.= " AND ba.entity = ".$conf->entity;
$sql.= $sql_rech; $sql.= $sql_rech;
@ -263,7 +255,7 @@ if ($account || $_GET["ref"])
//print $limitsql.'-'.$page.'-'.$viewline; //print $limitsql.'-'.$page.'-'.$viewline;
// Onglets // Onglets
$head=bank_prepare_head($acct); $head=bank_prepare_head($object);
dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -271,12 +263,12 @@ if ($account || $_GET["ref"])
// Ref // Ref
print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>'; print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $form->showrefnav($acct,'ref','',1,'ref'); print $form->showrefnav($object,'ref','',1,'ref');
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr><td valign="top">'.$langs->trans("Label").'</td>'; print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
print '<td colspan="3">'.$acct->label.'</td></tr>'; print '<td colspan="3">'.$object->label.'</td></tr>';
print '</table>'; print '</table>';
@ -287,7 +279,7 @@ if ($account || $_GET["ref"])
/** /**
* Search form * Search form
*/ */
$param.='&amp;account='.$acct->id; $param.='&amp;account='.$object->id;
// Define transaction list navigation string // Define transaction list navigation string
$navig=''; $navig='';
@ -298,16 +290,16 @@ if ($account || $_GET["ref"])
$navig.= $langs->trans("Page")." "; // ' Page '; $navig.= $langs->trans("Page")." "; // ' Page ';
$navig.='<input type="text" name="negpage" size="1" class="flat" value="'.($nbpage-$page).'">'; $navig.='<input type="text" name="negpage" size="1" class="flat" value="'.($nbpage-$page).'">';
$navig.='<input type="hidden" name="req_nb" value="'.$req_nb.'">'; $navig.='<input type="hidden" name="req_nb" value="'.$req_nb.'">';
$navig.='<input type="hidden" name="req_desc" value="'.$_REQUEST["req_desc"].'">'; $navig.='<input type="hidden" name="req_desc" value="'.GETPOST("req_desc").'">';
$navig.='<input type="hidden" name="req_debit" value="'.$_REQUEST["req_debit"].'">'; $navig.='<input type="hidden" name="req_debit" value="'.GETPOST("req_debit").'">';
$navig.='<input type="hidden" name="req_credit" value="'.$_REQUEST["req_credit"].'">'; $navig.='<input type="hidden" name="req_credit" value="'.GETPOST("req_credit").'">';
$navig.='<input type="hidden" name="thirdparty" value="'.$thirdparty.'">'; $navig.='<input type="hidden" name="thirdparty" value="'.$thirdparty.'">';
$navig.='<input type="hidden" name="nbpage" value="'.$nbpage.'">'; $navig.='<input type="hidden" name="nbpage" value="'.$nbpage.'">';
$navig.='<input type="hidden" name="account" value="'.($acct->id).'">'; $navig.='<input type="hidden" name="id" value="'.$object->id.'">';
$navig.='/'.$nbpage.' '; $navig.='/'.$nbpage.' ';
if ($total_lines > $limitsql ) if ($total_lines > $limitsql )
{ {
$navig.= '<a href="account.php?'.$param.'&amp;page='.($page-1).'">'.img_next().'</a>'; $navig.= '<a href="'.$_SERVER["PHP_SELF"].'?'.$param.'&amp;page='.($page-1).'">'.img_next().'</a>';
} }
$navig.='</form>'; $navig.='</form>';
//var_dump($navig); //var_dump($navig);
@ -316,7 +308,7 @@ if ($account || $_GET["ref"])
if ($action == 'delete') if ($action == 'delete')
{ {
$text=$langs->trans('ConfirmDeleteTransaction'); $text=$langs->trans('ConfirmDeleteTransaction');
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?account='.$acct->id.'&amp;rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete'); $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete');
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -331,11 +323,11 @@ if ($account || $_GET["ref"])
// Form to add a transaction with no invoice // Form to add a transaction with no invoice
if ($user->rights->banque->modifier && $action == 'addline') if ($user->rights->banque->modifier && $action == 'addline')
{ {
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="vline" value="' . $vline . '">'; print '<input type="hidden" name="vline" value="'.$vline.'">';
print '<input type="hidden" name="account" value="' . $acct->id . '">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<tr>'; print '<tr>';
print '<td align="left" colspan="10"><b>'.$langs->trans("AddBankRecordLong").'</b></td>'; print '<td align="left" colspan="10"><b>'.$langs->trans("AddBankRecordLong").'</b></td>';
@ -357,18 +349,18 @@ if ($account || $_GET["ref"])
$form->select_date($dateop,'op',0,0,0,'transaction'); $form->select_date($dateop,'op',0,0,0,'transaction');
print '</td>'; print '</td>';
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$form->select_types_paiements((isset($_POST["operation"])?$_POST["operation"]:''),'operation','1,2',2,1); $form->select_types_paiements(($object->courant == 2 ? 'LIQ' : GETPOST('operation')),'operation','1,2',2,1);
print '</td><td>'; print '</td><td>';
print '<input name="num_chq" class="flat" type="text" size="4" value="'.(isset($_POST["num_chq"])?$_POST["num_chq"]:'').'"></td>'; print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq").'"></td>';
print '<td colspan="2">'; print '<td colspan="2">';
print '<input name="label" class="flat" type="text" size="24" value="'.(isset($_POST["label"])?$_POST["label"]:'').'">'; print '<input name="label" class="flat" type="text" size="24" value="'.GETPOST("label").'">';
if ($nbcategories) if ($nbcategories)
{ {
print '<br>'.$langs->trans("Category").': <select class="flat" name="cat1">'.$options.'</select>'; print '<br>'.$langs->trans("Category").': <select class="flat" name="cat1">'.$options.'</select>';
} }
print '</td>'; print '</td>';
print '<td align=right><input name="debit" class="flat" type="text" size="4" value="'.(isset($_POST["debit"])?$_POST["debit"]:'').'"></td>'; print '<td align=right><input name="debit" class="flat" type="text" size="4" value="'.GETPOST("debit").'"></td>';
print '<td align=right><input name="credit" class="flat" type="text" size="4" value="'.(isset($_POST["credit"])?$_POST["credit"]:'').'"></td>'; print '<td align=right><input name="credit" class="flat" type="text" size="4" value="'.GETPOST("credit").'"></td>';
print '<td colspan="2" align="center">'; print '<td colspan="2" align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>'; print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
@ -394,14 +386,14 @@ if ($account || $_GET["ref"])
print '<td align="right">'.$langs->trans("Credit").'</td>'; print '<td align="right">'.$langs->trans("Credit").'</td>';
print '<td align="right" width="80">'.$langs->trans("BankBalance").'</td>'; print '<td align="right" width="80">'.$langs->trans("BankBalance").'</td>';
print '<td align="center" width="60">'; print '<td align="center" width="60">';
if ($acct->type != 2 && $acct->rappro) print $langs->trans("AccountStatementShort"); if ($object->type != 2 && $object->rappro) print $langs->trans("AccountStatementShort");
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param.'" name="search" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param.'" name="search" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="search">'; print '<input type="hidden" name="action" value="search">';
print '<input type="hidden" name="account" value="' . $acct->id . '">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
@ -412,10 +404,10 @@ if ($account || $_GET["ref"])
print $form->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8); print $form->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8);
print '</td>'; print '</td>';
print '<td><input type="text" class="flat" name="req_nb" value="'.$req_nb.'" size="2"></td>'; print '<td><input type="text" class="flat" name="req_nb" value="'.$req_nb.'" size="2"></td>';
print '<td><input type="text" class="flat" name="req_desc" value="'.$_REQUEST["req_desc"].'" size="24"></td>'; print '<td><input type="text" class="flat" name="req_desc" value="'.GETPOST("req_desc").'" size="24"></td>';
print '<td><input type="text" class="flat" name="thirdparty" value="'.$thirdparty.'" size="14"></td>'; print '<td><input type="text" class="flat" name="thirdparty" value="'.$thirdparty.'" size="14"></td>';
print '<td align="right"><input type="text" class="flat" name="req_debit" value="'.$_REQUEST["req_debit"].'" size="4"></td>'; print '<td align="right"><input type="text" class="flat" name="req_debit" value="'.GETPOST("req_debit").'" size="4"></td>';
print '<td align="right"><input type="text" class="flat" name="req_credit" value="'.$_REQUEST["req_credit"].'" size="4"></td>'; print '<td align="right"><input type="text" class="flat" name="req_credit" value="'.GETPOST("req_credit").'" size="4"></td>';
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
print '<td align="center" width="40"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; print '<td align="center" width="40"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
print "</tr>\n"; print "</tr>\n";
@ -461,7 +453,7 @@ if ($account || $_GET["ref"])
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='company'"; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='company'";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu3.url_id = s.rowid"; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu3.url_id = s.rowid";
} }
$sql.= " WHERE b.fk_account=".$acct->id; $sql.= " WHERE b.fk_account=".$object->id;
$sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity; $sql.= " AND ba.entity = ".$conf->entity;
$sql.= $sql_rech; $sql.= $sql_rech;
@ -537,7 +529,7 @@ if ($account || $_GET["ref"])
print dol_trunc($objp->label,60); print dol_trunc($objp->label,60);
} }
// Add links after description // Add links after description
$links = $acct->get_url($objp->rowid); $links = $object->get_url($objp->rowid);
foreach($links as $key=>$val) foreach($links as $key=>$val)
{ {
if ($links[$key]['type']=='payment') if ($links[$key]['type']=='payment')
@ -664,14 +656,14 @@ if ($account || $_GET["ref"])
} }
// Transaction reconciliated or edit link // Transaction reconciliated or edit link
if ($objp->rappro && $acct->canBeConciliated() > 0) // If line not conciliated and account can be conciliated if ($objp->rappro && $object->canBeConciliated() > 0) // If line not conciliated and account can be conciliated
{ {
print '<td align="center" nowrap>'; print '<td align="center" nowrap>';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
print "&nbsp; "; print "&nbsp; ";
print '<a href="releve.php?num='.$objp->num_releve.'&amp;account='.$acct->id.'">'.$objp->num_releve.'</a>'; print '<a href="releve.php?num='.$objp->num_releve.'&amp;account='.$object->id.'">'.$objp->num_releve.'</a>';
print "</td>"; print "</td>";
} }
else else
@ -679,17 +671,17 @@ if ($account || $_GET["ref"])
print '<td align="center">'; print '<td align="center">';
if ($user->rights->banque->modifier || $user->rights->banque->consolidate) if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{ {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
} }
else else
{ {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_view(); print img_view();
print '</a>'; print '</a>';
} }
if ($acct->canBeConciliated() > 0 && empty($objp->rappro)) if ($object->canBeConciliated() > 0 && empty($objp->rappro))
{ {
if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay))
{ {
@ -699,7 +691,7 @@ if ($account || $_GET["ref"])
print '&nbsp;'; print '&nbsp;';
if ($user->rights->banque->modifier) if ($user->rights->banque->modifier)
{ {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?action=delete&amp;rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&amp;rowid='.$objp->rowid.'&amp;id='.$object->id.'&amp;page='.$page.'">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
} }
@ -742,11 +734,11 @@ if ($account || $_GET["ref"])
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($acct->type != 2 && $acct->rappro) // If not cash account and can be reconciliate if ($object->type != 2 && $object->rappro) // If not cash account and can be reconciliate
{ {
if ($user->rights->banque->consolidate) if ($user->rights->banque->consolidate)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$acct->id.'">'.$langs->trans("Conciliate").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.'">'.$langs->trans("Conciliate").'</a>';
} }
else else
{ {
@ -758,7 +750,7 @@ if ($account || $_GET["ref"])
{ {
if ($user->rights->banque->modifier) if ($user->rights->banque->modifier)
{ {
print '<a class="butAction" href="account.php?action=addline&amp;account='.$acct->id.'&amp;page='.$page.'">'.$langs->trans("AddBankRecord").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&amp;id='.$object->id.'&amp;page='.$page.'">'.$langs->trans("AddBankRecord").'</a>';
} }
else else
{ {
@ -776,7 +768,7 @@ else
print $langs->trans("ErrorBankAccountNotFound"); print $langs->trans("ErrorBankAccountNotFound");
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -47,7 +48,7 @@ function bank_prepare_head($object)
$h++; $h++;
} }
$head[$h][0] = DOL_URL_ROOT."/compta/bank/account.php?account=".$object->id; $head[$h][0] = DOL_URL_ROOT."/compta/bank/account.php?id=".$object->id;
$head[$h][1] = $langs->trans("Transactions"); $head[$h][1] = $langs->trans("Transactions");
$head[$h][2] = 'journal'; $head[$h][2] = 'journal';
$h++; $h++;