From 8f66345e9d3d09f37468c9035fe9dfa927e10f20 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 6 May 2011 13:49:34 +0000 Subject: [PATCH] Uniformize code --- htdocs/compta/prelevement/create.php | 8 +++-- htdocs/compta/prelevement/demandes.php | 19 +++++------ htdocs/compta/prelevement/factures.php | 23 +++++++------ htdocs/compta/prelevement/fiche-rejet.php | 13 ++++---- htdocs/compta/prelevement/fiche-stat.php | 10 +++--- htdocs/compta/prelevement/fiche.php | 39 ++++++++++++----------- htdocs/compta/prelevement/index.php | 2 +- htdocs/compta/prelevement/lignes.php | 30 +++++++++-------- 8 files changed, 79 insertions(+), 65 deletions(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index fe31594b93f..6f520a97f42 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -40,21 +40,23 @@ $langs->load("bills"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +// Get supervariables +$action = GETPOST("action"); /* * Actions */ // Change customer bank information to withdraw -if ($_POST["action"] == 'modify') +if ($action == 'modify') { for ($i = 1 ; $i < 9 ; $i++) { - dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, GETPOST("nom$i"), GETPOST("value$i"),'chaine',0,'',$conf->entity); } } -if ($_GET["action"] == 'create') +if ($action == 'create') { $bprev = new BonPrelevement($db); $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET); diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 49292d661e7..4169ab63294 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2005 Rodolphe Quiedeville * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * 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 @@ -33,10 +34,14 @@ $langs->load("companies"); $langs->load("categories"); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST("socid"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); +// Get supervariables +$page = GETPOST("page"); +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); /* * View @@ -47,10 +52,6 @@ llxHeader(); $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); -$page = $_GET["page"]; -$sortorder = $_GET["sortorder"]; -$sortfield = $_GET["sortfield"]; - if ($page == -1) $page = 0 ; $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; @@ -78,9 +79,9 @@ if ($socid) $sql.= " AND f.fk_soc = ".$socid; if (!$statut) $sql.= " AND pfd.traite = 0"; if ($statut) $sql.= " AND pfd.traite = ".$statut; $sql.= " AND pfd.fk_facture = f.rowid"; -if (dol_strlen(trim($_GET["search_societe"]))) +if (dol_strlen(trim(GETPOST("search_societe")))) { - $sql.= " AND s.nom LIKE '%".$_GET["search_societe"]."%'"; + $sql.= " AND s.nom LIKE '%".GETPOST("search_societe")."%'"; } $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit($conf->liste_limit+1, $offset); @@ -109,8 +110,8 @@ if ($resql) print ''; print '
'; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print '
'; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 88709f96505..6d2bdf2a689 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -38,13 +38,20 @@ $langs->load("categories"); // Securite acces client if ($user->societe_id > 0) accessforbidden(); +// Get supervariables +$prev_id = GETPOST("id"); +$socid = GETPOST("socid"); +$page = GETPOST("page"); +$sortorder = ((GETPOST("sortorder")=="")) ? "DESC" : GETPOST("sortorder"); +$sortfield = ((GETPOST("sortfield")=="")) ? "p.ref" : GETPOST("sortfield"); + llxHeader('',$langs->trans("WithdrawalReceipt")); -if ($_GET["id"]) +if ($prev_id) { $bon = new BonPrelevement($db,""); - if ($bon->fetch($_GET["id"]) == 0) + if ($bon->fetch($prev_id) == 0) { $head = prelevement_prepare_head($bon); dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalReceipt"), '', 'payment'); @@ -95,10 +102,6 @@ if ($_GET["id"]) } } - -$page = $_GET["page"]; -$sortorder = (empty($_GET["sortorder"])) ? "DESC" : $_GET["sortorder"]; -$sortfield = (empty($_GET["sortfield"])) ? "p.datec" : $_GET["sortfield"]; $offset = $conf->liste_limit * $page ; /* @@ -117,8 +120,8 @@ $sql.= " AND pl.fk_prelevement_bons = p.rowid"; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity = ".$conf->entity; -if ($_GET["id"]) $sql.= " AND p.rowid=".$_GET["id"]; -if ($_GET["socid"]) $sql.= " AND s.rowid = ".$_GET["socid"]; +if ($prev_id) $sql.= " AND p.rowid=".$prev_id; +if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit($conf->liste_limit+1, $offset); @@ -129,7 +132,7 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $urladd = "&id=".$_GET["id"]; + $urladd = "&id=".$prev_id; print_barre_liste("", $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num); @@ -184,7 +187,7 @@ if ($result) $i++; } - if($_GET["socid"]) + if($socid) { print ""; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index b58c7d7848d..b85f503e611 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -36,18 +36,20 @@ $langs->load("categories"); // Securite acces client if ($user->societe_id > 0) accessforbidden(); +// Get supervariables +$prev_id = GETPOST("id"); +$page = GETPOST("page"); + /* * View */ llxHeader('',$langs->trans("WithdrawalReceipt")); -$prev_id = $_GET["id"]; - -if ($_GET["id"]) +if ($prev_id) { $bon = new BonPrelevement($db,""); - if ($bon->fetch($_GET["id"]) == 0) + if ($bon->fetch($prev_id) == 0) { $head = prelevement_prepare_head($bon); dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalReceipt"), '', 'payment'); @@ -98,7 +100,6 @@ if ($_GET["id"]) } } -$page = $_GET["page"]; $rej = new RejetPrelevement($db, $user); /* @@ -119,7 +120,7 @@ $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND pl.fk_soc = s.rowid"; $sql.= " AND pl.statut = 3 "; $sql.= " AND pr.fk_prelevement_lignes = pl.rowid"; -if ($_GET["socid"]) $sql.= " AND s.rowid = ".$_GET["socid"]; +if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY pl.amount DESC"; $resql = $db->query($sql); diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index dd5a93c68e7..0c87d5cdb29 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -35,6 +35,9 @@ if ($user->societe_id > 0) accessforbidden(); $langs->load("withdrawals"); $langs->load("categories"); +// Get supervariables +$prev_id = GETPOST("id"); +$page = GETPOST("page"); /* * View @@ -42,13 +45,11 @@ $langs->load("categories"); llxHeader('',$langs->trans("WithdrawalReceipt")); -$prev_id = $_GET["id"]; - if ($prev_id) { $bon = new BonPrelevement($db,""); - if ($bon->fetch($_GET["id"]) == 0) + if ($bon->fetch($prev_id) == 0) { $head = prelevement_prepare_head($bon); dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalReceipt"), '', 'payment'); @@ -96,7 +97,8 @@ if ($prev_id) } else { - print "Erreur"; + $langs->load("errors"); + print $langs->trans("Error"); } /* diff --git a/htdocs/compta/prelevement/fiche.php b/htdocs/compta/prelevement/fiche.php index 877e8244fc5..c5f3c23e28f 100644 --- a/htdocs/compta/prelevement/fiche.php +++ b/htdocs/compta/prelevement/fiche.php @@ -40,27 +40,30 @@ $langs->load("categories"); // Security check if ($user->societe_id > 0) accessforbidden(); +// Get supervariables +$action = GETPOST("action"); +$id = GETPOST("id"); /* * Actions */ -if (GETPOST("action") == 'confirm_credite' && GETPOST("confirm") == 'yes') +if ( $action == 'confirm_credite' && GETPOST("confirm") == 'yes') { $bon = new BonPrelevement($db,""); - $bon->id = $_GET["id"]; + $bon->id = $id; $bon->set_credite(); - Header("Location: fiche.php?id=".$_GET["id"]); + Header("Location: fiche.php?id=".$id); exit; } -if (GETPOST("action") == 'infotrans' && $user->rights->prelevement->bons->send) +if ($action == 'infotrans' && $user->rights->prelevement->bons->send) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); $bon = new BonPrelevement($db,""); - $bon->fetch($_GET["id"]); + $bon->fetch($id); if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref) { @@ -68,12 +71,12 @@ if (GETPOST("action") == 'infotrans' && $user->rights->prelevement->bons->send) if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . $_FILES['userfile']['name'],1) > 0) { - $dt = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); + $dt = dol_mktime(12,0,0,GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); - $bon->set_infotrans($user, $dt, $_POST["methode"]); + $bon->set_infotrans($user, $dt, GETPOST("methode")); } - Header("Location: fiche.php?id=".$_GET["id"]); + Header("Location: fiche.php?id=".$id); exit; } else @@ -83,21 +86,21 @@ if (GETPOST("action") == 'infotrans' && $user->rights->prelevement->bons->send) } } -if (GETPOST("action") == 'infocredit' && $user->rights->prelevement->bons->credit) +if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) { $bon = new BonPrelevement($db,""); - $bon->fetch($_GET["id"]); - $dt = mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); + $bon->fetch($id); + $dt = dol_mktime(12,0,0,GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); $error = $bon->set_infocredit($user, $dt); if ($error == 0) { - Header("Location: fiche.php?id=".$_GET["id"]); + Header("Location: fiche.php?id=".$id); } else { - Header("Location: fiche.php?id=".$_GET["id"]."&error=$error"); + Header("Location: fiche.php?id=".$id."&error=$error"); } exit; } @@ -111,21 +114,21 @@ llxHeader('',$langs->trans("WithdrawalReceipt")); $html = new Form($db); -if ($_GET["id"]) +if ($id) { $bon = new BonPrelevement($db,""); - if ($bon->fetch($_GET["id"]) == 0) + if ($bon->fetch($id) == 0) { $head = prelevement_prepare_head($bon); dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalReceipt"), '', 'payment'); - if (isset($_GET["error"])) + if (GETPOST("error")!='') { - print '
'.$bon->ReadError($_GET["error"]).'
'; + print '
'.$bon->ReadError(GETPOST("error")).'
'; } - if ($_GET["action"] == 'credite') + if ($action == 'credite') { $ret=$html->form_confirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); if ($ret == 'html') print '
'; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index b8dd037028f..65924c271d2 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -34,7 +34,7 @@ $langs->load("withdrawals"); $langs->load("categories"); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST("socid"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','',''); diff --git a/htdocs/compta/prelevement/lignes.php b/htdocs/compta/prelevement/lignes.php index 35ca3af5fee..a22133217ff 100644 --- a/htdocs/compta/prelevement/lignes.php +++ b/htdocs/compta/prelevement/lignes.php @@ -37,6 +37,14 @@ if ($user->societe_id > 0) accessforbidden(); $langs->load("categories"); +// Get supervariables +$prev_id = GETPOST("id"); +$socid = GETPOST("socid"); +$page = GETPOST("page"); +$sortorder = ((GETPOST("sortorder")=="")) ? "DESC" : GETPOST("sortorder"); +$sortfield = ((GETPOST("sortfield")=="")) ? "pl.fk_soc" : GETPOST("sortfield"); + + /* * View @@ -44,13 +52,11 @@ $langs->load("categories"); llxHeader('',$langs->trans("WithdrawalReceipt")); -$prev_id = $_GET["id"]; - -if ($_GET["id"]) +if ($prev_id) { $bon = new BonPrelevement($db,""); - if ($bon->fetch($_GET["id"]) == 0) + if ($bon->fetch($prev_id) == 0) { $head = prelevement_prepare_head($bon); dol_fiche_head($head, 'lines', $langs->trans("WithdrawalReceipt"), '', 'payment'); @@ -102,10 +108,6 @@ if ($_GET["id"]) } } -$page = $_GET["page"]; -$sortorder = $_GET["sortorder"]; -$sortfield = $_GET["sortfield"]; - $ligne=new LignePrelevement($db,$user); if ($page == -1) { $page = 0 ; } @@ -114,12 +116,12 @@ $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -if ($sortorder == "") { +/*if ($sortorder == "") { $sortorder="DESC"; } if ($sortfield == "") { $sortfield="pl.fk_soc"; -} +}*/ /* * Liste des lignes de prelevement @@ -133,7 +135,7 @@ $sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE pl.fk_prelevement_bons=".$prev_id; $sql.= " AND pl.fk_soc = s.rowid"; $sql.= " AND s.entity = ".$conf->entity; -if ($_GET["socid"]) $sql.= " AND s.rowid = ".$_GET["socid"]; +if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit($conf->liste_limit+1, $offset); @@ -144,7 +146,7 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $urladd = "&id=".$_GET["id"]; + $urladd = "&id=".$prev_id; print_barre_liste("", $page, "lignes.php", $urladd, $sortfield, $sortorder, '', $num); print"\n\n"; @@ -152,7 +154,7 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Lines"),"lignes.php","pl.rowid",'',$urladd); print_liste_field_titre($langs->trans("ThirdParty"),"lignes.php","s.nom",'',$urladd); - print_liste_field_titre($langs->trans("Amount"),"lignes.php","f.total_ttc","",$urladd,'align="center"'); + print_liste_field_titre($langs->trans("Amount"),"lignes.php","pl.amount","",$urladd,'align="center"'); print ' '; $var=false; @@ -194,7 +196,7 @@ if ($result) $i++; } - if($_GET["socid"]) + if($socid) { print "";