diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index f743357d00e..60323fd8b58 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -121,25 +121,37 @@ class Account } } - /* - * + /** + * \brief Renvoi tableau des liens + * \param line_id Id ligne écriture + * \retuen array Tableau des liens */ function get_url($line_id) { $lines = array(); - $sql = "SELECT fk_bank, url_id, url, label FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank = $line_id"; + $sql = "SELECT url_id, url, label, type"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_url"; + $sql.= " WHERE fk_bank = ".$line_id; + $sql.= " ORDER BY type, label"; + $result = $this->db->query($sql); - if ($result) { $i = 0; - $num = $this->db->num_rows(); + $num = $this->db->num_rows($result); while ($i < $num) { $obj = $this->db->fetch_object($result); + // Anciens liens (pour compatibilité) $lines[$i][0] = $obj->url; $lines[$i][1] = $obj->url_id; $lines[$i][2] = $obj->label; + $lines[$i][3] = $obj->type; + // Nouveaux liens + $lines[$i]['url'] = $obj->url; + $lines[$i]['url_id'] = $obj->url_id; + $lines[$i]['label'] = $obj->label; + $lines[$i]['type'] = $obj->type; $i++; } return $lines; diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 9ad973ab3c6..4be51a02ba8 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -365,7 +365,7 @@ llxFooter('$Date$ - $Revision$'); */ function _print_lines($db,$result,$sql,$acct) { - global $bc, $nbline, $viewline, $user, $page; + global $langs, $bc, $nbline, $viewline, $user, $page; $var=true; $total=0; @@ -395,18 +395,19 @@ function _print_lines($db,$result,$sql,$acct) print "".dolibarr_print_date($objp->do,"%d/%m/%y")."\n"; print " ".dolibarr_print_date($objp->dv,"%d/%m/%y")."\n"; print " ".$objp->fk_type." ".($objp->num_chq?$objp->num_chq:"")."\n"; - print "rowid&account=$acct->id\">$objp->label"; + print ''.$objp->label.''; /* * Ajout les liens */ - $urls_line = $acct->get_url($objp->rowid); - $numurl = sizeof($urls_line); - $k = 0; - while ($k < $numurl) + $links = $acct->get_url($objp->rowid); + foreach($links as $key=>$val) { - print ' '.$urls_line[$k][2].''; - $k++; + print ' - '; + print ''; + // if ($links[$key]['type']=='payment') { print img_object($langs->trans('ShowPayment'),'payment').' '; } + // if ($links[$key]['type']=='company') { print img_object($langs->trans('ShowCustomer'),'company').' '; } + print $links[$key]['label'].''; } print ''; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index a6fba55eb63..f8e87b05e24 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -129,8 +129,21 @@ if ($_POST["action"] == 'type') if ($_POST["action"] == 'num_releve') { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set num_releve=".$_POST["num_rel"]." WHERE rowid = $rowid;"; - $result = $db->query($sql); + $db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET num_releve='".$_POST["num_rel"]."'"; + $sql.= " WHERE rowid = ".$rowid; + + $result = $db->query($sql); + if ($result) + { + $db->commit(); + } + else + { + $db->rollback(); + dolibarr_print_error($db); + } } @@ -198,6 +211,8 @@ if ($result) $acct->fetch($objp->fk_account); $account = $acct->id; + $links=$acct->get_url($rowid); + // Tableau sur 4 colonne si déja rapproché, sinon sur 5 colonnes // Author @@ -211,7 +226,7 @@ if ($result) } else { - print ' '; + print ' '; } print ""; @@ -246,7 +261,10 @@ if ($result) else { */ - print '".$acct->label.""; + print ''; + print ''.$acct->label.''; + print ''; + print ''; /* } */ @@ -254,23 +272,24 @@ if ($result) // Date ope print ''.$langs->trans("Date").''; - print ''; if (! $objp->rappro) { + print ''; $html->select_date($objp->do,'do'); print ''; } else { + print ''; print dolibarr_print_date($objp->do); } print ''; // Value date print "".$langs->trans("DateValue").""; - print ''; if (! $objp->rappro) { + print ''; $html->select_date($objp->dv,'dv'); print '   '; print ''; @@ -281,6 +300,7 @@ if ($result) } else { + print ''; print dolibarr_print_date($objp->dv); } print ""; @@ -290,26 +310,43 @@ if ($result) if (! $objp->rappro) { print ''; + print ''; + print ''; + print ''; } else { - print ''; + print ''; + print $objp->label; } - print ''; - print ''; - print ''; print ''; - + + // Affiche liens + if (sizeof($links)) { + print "".$langs->trans("Links").""; + print ''; + foreach($links as $key=>$val) + { + if ($key) print '
'; + print '
'; + if ($links[$key]['type']=='payment') { print img_object($langs->trans('ShowPayment'),'payment').' '; } + if ($links[$key]['type']=='company') { print img_object($langs->trans('ShowCustomer'),'company').' '; } + print $links[$key]['label'].''; + } + print ' '; + } + // Amount print "".$langs->trans("Amount").""; - print ''; if (! $objp->rappro) { - print ''; + print ''; + print ' '.$conf->monnaie; print ''; } else { + print ''; print price($objp->amount); } print ""; diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 4490d6f1ec1..8db71973c55 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -122,109 +122,123 @@ $acct = new Account($db); $acct->fetch($_GET["account"]); $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, ".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type"; -$sql .= " FROM ".MAIN_DB_PREFIX."bank as b WHERE rappro=0 AND fk_account=".$_GET["account"]; -$sql .= " ORDER BY dateo"; -$sql .= " ASC LIMIT ".$conf->liste_limit; +$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql.= " WHERE rappro=0 AND fk_account=".$_GET["account"]; +$sql.= " ORDER BY dateo"; +$sql.= " ASC LIMIT ".$conf->liste_limit; $resql = $db->query($sql); if ($resql) { - $var=True; - $num = $db->num_rows($resql); + $var=True; + $num = $db->num_rows($resql); - print_titre('Rapprochement compte bancaire : '.$acct->label.''); - print '
'; - - if ($msg) { - print "$msg

"; - } - - // Affiche nom des derniers relevés - $nbmax=5; - $liste=""; - - $sql = "SELECT distinct num_releve FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$_GET["account"]; - $sql.= " ORDER BY num_releve DESC"; - $sql.= " LIMIT ".($nbmax+1); - print $langs->trans("LastAccountStatements").' : '; - $resqlr=$db->query($sql); - if ($resqlr) - { - $numr=$db->num_rows($resqlr); - $i=0; - while (($i < $numr) && ($i < $nbmax)) - { - $objr = $db->fetch_object($resqlr); - $last_releve = $objr->num_releve; - $i++; - $liste=''.$objr->num_releve.'   '.$liste; - } - if ($num >= $nbmax) $liste="...   ".$liste; - print "$liste"; - if ($num > 0) print '

'; - else print $langs->trans("None").'

'; - } - else - { - dolibarr_print_error($db); + print_titre($langs->trans("Reconciliation").': '.$acct->label.''); + print '
'; + + if ($msg) { + print "$msg

"; } - - print ''; - print "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - - $i = 0; - while ($i < $num) + + // Affiche nom des derniers relevés + $nbmax=5; + $liste=""; + + $sql = "SELECT distinct num_releve FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_account=".$_GET["account"]; + $sql.= " ORDER BY num_releve DESC"; + $sql.= " LIMIT ".($nbmax+1); + print $langs->trans("LastAccountStatements").' : '; + $resqlr=$db->query($sql); + if ($resqlr) { - $objp = $db->fetch_object($resql); - - $var=!$var; - print ""; - print ''; - print ""; - print ""; - print "rowid."\">"; - - print ''; - print ''; - print ''; - print ''; - - if ($objp->amount < 0) + $numr=$db->num_rows($resqlr); + $i=0; + while (($i < $numr) && ($i < $nbmax)) { - print "\n"; + $objr = $db->fetch_object($resqlr); + $last_releve = $objr->num_releve; + $i++; + $liste=''.$objr->num_releve.'   '.$liste; } - else + if ($num >= $nbmax) $liste="...   ".$liste; + print "$liste"; + if ($num > 0) print '

'; + else print $langs->trans("None").'

'; + } + else + { + dolibarr_print_error($db); + } + + print '
'.$langs->trans("Date").''.$langs->trans("DateValue").''.$langs->trans("Type").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Action").''.$langs->trans("AccountStatement").' (Ex: YYYYMM)
'.dolibarr_print_date($objp->do).''.dolibarr_print_date($objp->dv).''.$objp->type.($objp->num_chq?' '.$objp->num_chq:'').''.$objp->label.'".price($objp->amount * -1)." 
'; + print "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ""; + print ''; + print ""; + print ""; + print "rowid."\">"; + + print ''; + print ''; + print ''; + print '\n"; + print ' - '; + print ''; + // if ($links[$key]['type']=='payment') { print img_object($langs->trans('ShowPayment'),'payment').' '; } + // if ($links[$key]['type']=='company') { print img_object($langs->trans('ShowCustomer'),'company').' '; } + print $links[$key]['label'].''; } - - if ($objp->rappro) + print ''; + + if ($objp->amount < 0) { - // Si ligne déjà rapprochée, on affiche relevé. - print ""; + print "\n"; } - else + else { - // Si pas encore rapproch + print "\n"; + } + + if ($objp->rappro) + { + // Si ligne déjà rapprochée, on affiche relevé. + print ""; + } + else + { + // Si pas encore rapprochée if ($user->rights->banque->modifier) { print '"; } } - - - // Affiche bouton "Rapprocher" - if ($objp->do <= mktime() ) { - print ""; - print ""; - } - else - { - print ""; - } - - print "\n"; - print "\n"; - $i++; + + + // Affiche bouton "Rapprocher" + if ($objp->do <= mktime() ) { + print ""; + print ""; + } + else + { + print ""; + } + + print "\n"; + print "\n"; + $i++; } - $db->free($resql); - - if ($num != 0) + $db->free($resql); + + if ($num != 0) { - print "
'.$langs->trans("Date").''.$langs->trans("DateValue").''.$langs->trans("Type").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Action").''.$langs->trans("AccountStatement").' (Ex: YYYYMM)
'.dolibarr_print_date($objp->do).''.dolibarr_print_date($objp->dv).''.$objp->type.($objp->num_chq?' '.$objp->num_chq:'').''.$objp->label.''; + /* + * Ajout les liens + */ + $links = $acct->get_url($objp->rowid); + foreach($links as $key=>$val) { - print " ".price($objp->amount)."num_releve&account=$acct->id\">$objp->num_releve".price($objp->amount * -1)."  ".price($objp->amount)."num_releve&account=$acct->id\">$objp->num_releve'; - + print ''; print img_edit(); print '   '; - + if ($objp->do <= mktime() ) { print ''; print img_delete(); @@ -240,39 +254,39 @@ if ($resql) print " "; - print ""; - if ($options) - { - print "
"; - } - print "
trans("Rapprocher")."\">"; - print ""; - print "Ecriture future. Ne peut pas encore être rapprochée."; - print "
"; + print ""; + if ($options) + { + print "
"; + } + print "
trans("Rapprocher")."\">"; + print ""; + print "Ecriture future. Ne peut pas encore être rapprochée."; + print "
\n"; + print "
\n"; } - + } else {