From 009c73e2c0034e5fba89ea65e7af34171d206f48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Oct 2008 22:48:47 +0000 Subject: [PATCH] Can change value date in conciliation page --- htdocs/compta/bank/ligne.php | 570 +++++++++++++++++----------------- htdocs/compta/bank/rappro.php | 54 +++- 2 files changed, 330 insertions(+), 294 deletions(-) diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 1d9d7b34ebd..346fa21d480 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -18,18 +18,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - + /** - \file htdocs/compta/bank/ligne.php - \ingroup compta - \brief Page edition d'une ecriture bancaire - \version $Id$ -*/ + \file htdocs/compta/bank/ligne.php + \ingroup compta + \brief Page edition d'une ecriture bancaire + \version $Id$ + */ require("./pre.inc.php"); if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) - accessforbidden(); +accessforbidden(); $langs->load("banks"); $langs->load("bills"); @@ -45,94 +45,94 @@ $html = new Form($db); * Actions */ -if ($_GET["action"] == 'dvnext') +if ($user->rights->banque->consolidate && $_GET["action"] == 'dvnext') { - $ac = new Account($db); - $ac->datev_next($_GET["rowid"]); + $ac = new Account($db); + $ac->datev_next($_GET["rowid"]); } -if ($_GET["action"] == 'dvprev') +if ($user->rights->banque->consolidate && $_GET["action"] == 'dvprev') { - $ac = new Account($db); - $ac->datev_previous($_GET["rowid"]); + $ac = new Account($db); + $ac->datev_previous($_GET["rowid"]); } if ($_POST["action"] == 'confirm_delete_categ' && $_POST["confirm"] == "yes") { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_GET["cat1"]; - if (! $db->query($sql)) - { - dolibarr_print_error($db); - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_GET["cat1"]; + if (! $db->query($sql)) + { + dolibarr_print_error($db); + } } if ($_POST["action"] == 'class') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_POST["cat1"]; - if (! $db->query($sql)) - { - dolibarr_print_error($db); - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_POST["cat1"]; + if (! $db->query($sql)) + { + dolibarr_print_error($db); + } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$_GET["rowid"].", ".$_POST["cat1"].")"; - if (! $db->query($sql)) - { - dolibarr_print_error($db); - } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$_GET["rowid"].", ".$_POST["cat1"].")"; + if (! $db->query($sql)) + { + dolibarr_print_error($db); + } } if ($_POST["action"] == "update") { - // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche - $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid; - $result = $db->query($sql); - if ($result) - { - $objp = $db->fetch_object($result); - if ($objp->rappro) - die ("Vous ne pouvez pas modifier une �criture d�j� rapproch�e"); - } - - $db->begin(); - - $amount = price2num($_POST['amount']); - $dateop = $_POST["dateoyear"].'-'.$_POST["dateomonth"].'-'.$_POST["dateoday"]; - $dateval= $_POST["datevyear"].'-'.$_POST["datevmonth"].'-'.$_POST["datevday"]; - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET label='".addslashes($_POST["label"])."',"; // Todo: cr�er une classe pour s�parer les requ�tes sql - if (isset($_POST['amount'])) $sql.=" amount='$amount',"; - $sql.= " dateo = '".$dateop."', datev = '".$dateval."',"; - $sql.= " fk_account = ".$_POST['accountid']; - $sql.= " WHERE rowid = ".$rowid; - - $result = $db->query($sql); - if ($result) - { - $db->commit(); - } - else - { - $db->rollback(); - dolibarr_print_error($db); - } + // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche + $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid; + $result = $db->query($sql); + if ($result) + { + $objp = $db->fetch_object($result); + if ($objp->rappro) + die ("Vous ne pouvez pas modifier une �criture d�j� rapproch�e"); + } + + $db->begin(); + + $amount = price2num($_POST['amount']); + $dateop = $_POST["dateoyear"].'-'.$_POST["dateomonth"].'-'.$_POST["dateoday"]; + $dateval= $_POST["datevyear"].'-'.$_POST["datevmonth"].'-'.$_POST["datevday"]; + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET label='".addslashes($_POST["label"])."',"; // Todo: cr�er une classe pour s�parer les requ�tes sql + if (isset($_POST['amount'])) $sql.=" amount='$amount',"; + $sql.= " dateo = '".$dateop."', datev = '".$dateval."',"; + $sql.= " fk_account = ".$_POST['accountid']; + $sql.= " WHERE rowid = ".$rowid; + + $result = $db->query($sql); + if ($result) + { + $db->commit(); + } + else + { + $db->rollback(); + dolibarr_print_error($db); + } } if ($_POST["action"] == 'type') { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set fk_type='".$_POST["value"]."', num_chq='".$_POST["num_chq"]."' WHERE rowid = $rowid;"; - $result = $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank set fk_type='".$_POST["value"]."', num_chq='".$_POST["num_chq"]."' WHERE rowid = $rowid;"; + $result = $db->query($sql); } if ($_POST["action"] == 'banque') { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set banque='".addslashes($_POST["banque"])."' WHERE rowid = $rowid;"; - $result = $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank set banque='".addslashes($_POST["banque"])."' WHERE rowid = $rowid;"; + $result = $db->query($sql); } if ($_POST["action"] == 'emetteur') { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank set emetteur='".addslashes($_POST["emetteur"])."' WHERE rowid = $rowid;"; - $result = $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank set emetteur='".addslashes($_POST["emetteur"])."' WHERE rowid = $rowid;"; + $result = $db->query($sql); } if ($_POST["action"] == 'num_releve') @@ -152,7 +152,7 @@ if ($_POST["action"] == 'num_releve') $db->commit(); } else - { + { $db->rollback(); dolibarr_print_error($db); } @@ -162,7 +162,7 @@ if ($_POST["action"] == 'num_releve') /* * Affichage fiche ligne ecriture en mode edition */ - + llxHeader(); // On initialise la liste des categories @@ -172,17 +172,17 @@ $sql.= " ORDER BY label"; $result = $db->query($sql); if ($result) { - $var=True; - $num = $db->num_rows($result); - $i = 0; - $options = ""; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $options .= "\n"; - $i++; - } - $db->free($result); + $var=True; + $num = $db->num_rows($result); + $i = 0; + $options = ""; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $options .= "\n"; + $i++; + } + $db->free($result); } $var=False; @@ -196,7 +196,7 @@ $h++; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$_GET["rowid"]; $head[$h][1] = $langs->trans("Info"); -$h++; +$h++; dolibarr_fiche_head($head, $hselected, $langs->trans('LineRecord').': '.$_GET["rowid"]); @@ -210,128 +210,130 @@ $sql.= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { - $i = 0; $total = 0; - if ($db->num_rows($result)) - { - - // Confirmations - if ($_GET["action"] == 'delete_categ') - { + $i = 0; $total = 0; + if ($db->num_rows($result)) + { + + // Confirmations + if ($_GET["action"] == 'delete_categ') + { $html->form_confirm("ligne.php?rowid=".$_GET["rowid"]."&cat1=".$_GET["fk_categ"]."&orig_account=".$orig_account,$langs->trans("RemoveFromCategory"),$langs->trans("RemoveFromCategoryConfirm"),"confirm_delete_categ"); print '
'; - } - - print ''; - - $objp = $db->fetch_object($result); - $total = $total + $objp->amount; - - $acct=new Account($db,$objp->fk_account); - $acct->fetch($objp->fk_account); - $account = $acct->id; - - $links=$acct->get_url($rowid); - - // Tableau sur 4 colonne si deja rapproche, sinon sur 5 colonnes - - // Author - print '"; - if ($objp->fk_user_author) - { + } + + print '
'.$langs->trans("Author")."
'; + + $objp = $db->fetch_object($result); + $total = $total + $objp->amount; + + $acct=new Account($db,$objp->fk_account); + $acct->fetch($objp->fk_account); + $account = $acct->id; + + $links=$acct->get_url($rowid); + + // Tableau sur 4 colonne si deja rapproche, sinon sur 5 colonnes + + // Author + print '"; + if ($objp->fk_user_author) + { $author=new User($db,$objp->fk_user_author); $author->fetch(); print ''; - } - else - { + } + else + { print ''; - } - print ""; - - $i++; - - print "rowid\">"; - print ""; - print ""; - - // Account - print ""; - print ''; - print ''; - - // Date ope - print ''; - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { + } + print ""; + + $i++; + + print "rowid\">"; + print ""; + print ""; + + // Account + print ""; + print ''; + print ''; + + // Date ope + print ''; + if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) + { print ''; - } - else - { + } + else + { print ''; - - // Value date - print ""; - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { - print '"; - - // Description - print ""; - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { - print ''; - print ''; - + } + print ''; + + // Value date + print ""; + if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) + { + print ''; + print ''; + } + else + { + print ''; + } + print ""; + + // Description + print ""; + if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) + { + print ''; + print ''; + // Affiche liens if (sizeof($links)) { @@ -390,80 +392,80 @@ if ($result) } print ''; } - - // Amount - print ""; - if (! $objp->rappro && $user->rights->banque->modifier) - { + + // Amount + print ""; + if (! $objp->rappro && $user->rights->banque->modifier) + { print '"; - - print ""; - - // Type paiement - print ""; + + print ""; + + // Type paiement + print "'; } - print ""; - - // Banque - print ""; + + // Banque + print "'; } - print ""; + print ""; - // Emetteur - print "'; - } - print ""; + // Emetteur + print "'; + } + print ""; - // Releve rappro - if ($acct->rappro) // Si compte rapprochable - { + // Releve rappro + if ($acct->rappro) // Si compte rapprochable + { print ""; if ($user->rights->banque->consolidate) { @@ -474,19 +476,19 @@ if ($result) print $langs->trans("AccountStatement").' '; print ''; print ''; - } - else - { - print ''; - } + } + else + { + print ''; + } print ''; - } - - print "
'.$langs->trans("Author")."'; print img_object($langs->trans("ShowUser"),'user').' '.$author->fullname.' 
".$langs->trans("Account")."'; - print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.''; - print ''; - print '
'.$langs->trans("DateOperation").'
".$langs->trans("Account")."'; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.''; + print ''; + print '
'.$langs->trans("DateOperation").''; $html->select_date($objp->do,'dateo','','','','update'); print ''; print dolibarr_print_date($objp->do); - } - print '
".$langs->trans("DateValue")."'; - $html->select_date($objp->dv,'datev','','','','update'); - print '   '; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - } - else - { - print ''; - print dolibarr_print_date($objp->dv); - } - print "
".$langs->trans("Label")."'; - print ''; - print ''; - } - else - { - print ''; - if (eregi('^\((.*)\)$',$objp->label,$reg)) - { - // Label g�n�rique car entre parenth�ses. On l'affiche en le traduisant - print $langs->trans($reg[1]); - } - else - { - print $objp->label; - } - } - print '
".$langs->trans("DateValue")."'; + $html->select_date($objp->dv,'datev','','','','update'); + print '   '; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print dolibarr_print_date($objp->dv,"day"); + print '
".$langs->trans("Label")."'; + print ''; + print ''; + } + else + { + print ''; + if (eregi('^\((.*)\)$',$objp->label,$reg)) + { + // Label g�n�rique car entre parenth�ses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } + else + { + print $objp->label; + } + } + print '
 
".$langs->trans("Amount")."
".$langs->trans("Amount")."'; print ' '.$langs->trans("Currency".$conf->monnaie); print ''; - } - else - { + } + else + { print ''; print price($objp->amount); - } - print "
".$langs->trans("Type")." / ".$langs->trans("Numero").""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print "
rowid\">"; - print ''; - print ""; - print $html->select_types_paiements($objp->fk_type,"value",'',2); - print ''; - print '
'; - print ""; + } + print "
".$langs->trans("Type")." / ".$langs->trans("Numero").""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print "
rowid\">"; + print ''; + print ""; + print $html->select_types_paiements($objp->fk_type,"value",'',2); + print ''; + print '
'; + print ""; } else { print $objp->fk_type.' '.$objp->num_chq.' 
".$langs->trans("Bank").""; - if ($user->rights->banque->modifier) - { - print "
rowid\">"; - print ''; - print ""; - print ''; - print '
'; - print ""; + print "
".$langs->trans("Bank").""; + if ($user->rights->banque->modifier) + { + print "
rowid\">"; + print ''; + print ""; + print ''; + print '
'; + print ""; } else { print $objp->banque.'  
".$langs->trans("CheckTransmitter").""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print "
rowid\">"; - print ''; - print ""; - print ''; - print '
'; - print ""; - } - else - { - print $objp->emetteur.'  
".$langs->trans("CheckTransmitter").""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print "
rowid\">"; + print ''; + print ""; + print ''; + print '
'; + print ""; + } + else + { + print $objp->emetteur.'  
".$langs->trans("Conciliation")."'.$objp->num_releve.' '.$objp->num_releve.' 
"; - - } - - $db->free($result); + } + + print ""; + + } + + $db->free($result); } print ''; @@ -495,17 +497,17 @@ print ''; * Boutons actions */ /* -print '
'; - -if ($orig_account) -{ - $acct=new Account($db,$orig_account); - $acct->fetch($orig_account); - print ''.$langs->trans("BackToConciliate",$acct->label).''; -} + print '
'; -print '
'; -*/ + if ($orig_account) + { + $acct=new Account($db,$orig_account); + $acct->fetch($orig_account); + print ''.$langs->trans("BackToConciliate",$acct->label).''; + } + + print '
'; + */ // Liste les categories @@ -528,24 +530,24 @@ $sql.= " ORDER BY c.label"; $result = $db->query($sql); if ($result) { - $var=True; - $num = $db->num_rows($result); - $i = 0; $total = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $var=True; + $num = $db->num_rows($result); + $i = 0; $total = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); - $var=!$var; - print ""; - - print "$objp->label"; - print "rowid\">".$langs->trans("List").""; - print "rowid\">".img_delete($langs->trans("Remove")).""; - print ""; + $var=!$var; + print ""; - $i++; - } - $db->free($result); + print "$objp->label"; + print "rowid\">".$langs->trans("List").""; + print "rowid\">".img_delete($langs->trans("Remove")).""; + print ""; + + $i++; + } + $db->free($result); } print ""; diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index a8819216f1e..578eb427b9d 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -15,15 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \file htdocs/compta/bank/rappro.php \ingroup banque \brief Page de rapprochement bancaire - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -36,8 +34,22 @@ if (! $user->rights->banque->consolidate) accessforbidden(); /* - * Action rapprochement + * Actions */ + +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $_GET["action"] == 'dvnext') +{ + $ac = new Account($db); + $ac->datev_next($_GET["rowid"]); +} + +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $_GET["action"] == 'dvprev') +{ + $ac = new Account($db); + $ac->datev_previous($_GET["rowid"]); +} + +// Conciliation if ($user->rights->banque->consolidate && $_POST["action"] == 'rappro') { // Definition, nettoyage parametres @@ -120,12 +132,13 @@ if ($resql) { } +/* + * View + */ +$form=new Form($db); llxHeader(); -/* - * Affichage liste des transactions à rapprocher - */ $acct = new Account($db); $acct->fetch($_GET["account"]); @@ -133,7 +146,7 @@ $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, ".$db->pdate("b.datev"). $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " WHERE rappro=0 AND fk_account=".$_GET["account"]; $sql.= " ORDER BY dateo ASC"; -$sql.= " LIMIT 1000"; // Limite juste pour eviter saturation page. +$sql.= " LIMIT 1000"; // Limit to avoid page overload $resql = $db->query($sql); if ($resql) @@ -204,9 +217,30 @@ if ($resql) print ""; print "rowid."\">"; + // Date op print ''.dolibarr_print_date($objp->do,"day").''; - print ''.dolibarr_print_date($objp->dv,"day").''; - print ''.$objp->type.($objp->num_chq?' '.$objp->num_chq:'').''; + + // Date value + if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) + { + print ''; + print dolibarr_print_date($objp->dv,"day"); + print '   '; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + } + else + { + print ''; + print dolibarr_print_date($objp->dv,"day"); + print ''; + } + + // Number + print ''.$objp->type.($objp->num_chq?' '.$objp->num_chq:'').''; // Description print '';