Uniformize code

This commit is contained in:
Juanjo Menent 2011-05-06 13:49:34 +00:00
parent d56219b43f
commit 8f66345e9d
8 changed files with 79 additions and 65 deletions

View File

@ -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);

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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 '</tr>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_facture" size="12" value="'.$GET["search_facture"].'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" size="18" value="'.$GET["search_societe"].'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_facture" size="12" value="'.GETPOST("search_facture").'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" size="18" value="'.GETPOST("search_societe").'"></td>';
print '<td colspan="2" class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
print '</tr>';
print '</form>';

View File

@ -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 = "&amp;id=".$_GET["id"];
$urladd = "&amp;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 "<tr $bc[$var]><td>";

View File

@ -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);

View File

@ -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");
}
/*

View File

@ -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 '<div class="error">'.$bon->ReadError($_GET["error"]).'</div>';
print '<div class="error">'.$bon->ReadError(GETPOST("error")).'</div>';
}
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 '<br>';

View File

@ -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','','');

View File

@ -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 = "&amp;id=".$_GET["id"];
$urladd = "&amp;id=".$prev_id;
print_barre_liste("", $page, "lignes.php", $urladd, $sortfield, $sortorder, '', $num);
print"\n<!-- debut table -->\n";
@ -152,7 +154,7 @@ if ($result)
print '<tr class="liste_titre">';
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 '<td colspan="2">&nbsp;</td></tr>';
$var=false;
@ -194,7 +196,7 @@ if ($result)
$i++;
}
if($_GET["socid"])
if($socid)
{
print "<tr $bc[$var]><td>";