Fix: uniformize code
This commit is contained in:
parent
ff0668e908
commit
b53d108c50
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -34,14 +35,16 @@ $langs->load("companies");
|
||||
$langs->load("donations");
|
||||
$langs->load("bills");
|
||||
|
||||
$id=GETPOST('rowid')?GETPOST('rowid'):GETPOST('id','int');
|
||||
$action=GETPOST('action');
|
||||
$id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int');
|
||||
$action=GETPOST('action','alpha');
|
||||
$cancel=GETPOST('cancel');
|
||||
$amount=GETPOST('amount');
|
||||
|
||||
$mesg="";
|
||||
$mesgs=array();
|
||||
|
||||
$don = new Don($db);
|
||||
$donation_date=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'don', $id);
|
||||
@ -53,9 +56,9 @@ $result = restrictedArea($user, 'don', $id);
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
if (! empty($_POST['cancel']))
|
||||
if (! empty($cancel))
|
||||
{
|
||||
Header("Location: fiche.php?rowid=".$_POST["rowid"]);
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -68,7 +71,7 @@ if ($action == 'update')
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $_POST["amount"] > 0)
|
||||
if (empty($amount))
|
||||
{
|
||||
$mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Amount"));
|
||||
$action = "create";
|
||||
@ -77,8 +80,7 @@ if ($action == 'update')
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$don->id = $_POST["rowid"];
|
||||
$don->fetch($_POST["rowid"]);
|
||||
$don->fetch($id);
|
||||
|
||||
$don->prenom = $_POST["prenom"];
|
||||
$don->nom = $_POST["nom"];
|
||||
@ -100,7 +102,7 @@ if ($action == 'update')
|
||||
|
||||
if ($don->update($user) > 0)
|
||||
{
|
||||
Header("Location: fiche.php?rowid=".$don->id);
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$don->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -108,7 +110,7 @@ if ($action == 'update')
|
||||
|
||||
if ($action == 'add')
|
||||
{
|
||||
if (! empty($_POST['cancel']))
|
||||
if (! empty($cancel))
|
||||
{
|
||||
Header("Location: index.php");
|
||||
exit;
|
||||
@ -119,14 +121,14 @@ if ($action == 'add')
|
||||
if (empty($donation_date))
|
||||
{
|
||||
$mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Date"));
|
||||
$_GET["action"] = "create";
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $_POST["amount"] > 0)
|
||||
if (empty($amount))
|
||||
{
|
||||
$mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Amount"));
|
||||
$_GET["action"] = "create";
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -160,48 +162,47 @@ if ($action == 'add')
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$don->delete($_GET["rowid"]);
|
||||
$don->delete($id);
|
||||
Header("Location: liste.php");
|
||||
exit;
|
||||
}
|
||||
if ($action == 'commentaire')
|
||||
{
|
||||
$don->fetch($_POST["rowid"]);
|
||||
$don->fetch($id);
|
||||
$don->update_note($_POST["commentaire"]);
|
||||
$_GET["rowid"] = $_POST["rowid"];
|
||||
}
|
||||
if ($action == 'valid_promesse')
|
||||
{
|
||||
if ($don->valid_promesse($_GET["rowid"], $user->id) >= 0)
|
||||
if ($don->valid_promesse($id, $user->id) >= 0)
|
||||
{
|
||||
Header("Location: fiche.php?rowid=".$_GET["rowid"]);
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else $mesg=$don->error;
|
||||
}
|
||||
if ($action == 'set_cancel')
|
||||
{
|
||||
if ($don->set_cancel($_GET["rowid"]) >= 0)
|
||||
if ($don->set_cancel($id) >= 0)
|
||||
{
|
||||
Header("Location: fiche.php?rowid=".$_GET["rowid"]);
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else $mesg=$don->error;
|
||||
}
|
||||
if ($action == 'set_paid')
|
||||
{
|
||||
if ($don->set_paye($_GET["rowid"], $modepaiement) >= 0)
|
||||
if ($don->set_paye($id, $modepaiement) >= 0)
|
||||
{
|
||||
Header("Location: fiche.php?rowid=".$_GET["rowid"]);
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else $mesg=$don->error;
|
||||
}
|
||||
if ($action == 'set_encaisse')
|
||||
{
|
||||
if ($don->set_encaisse($_GET["rowid"]) >= 0)
|
||||
if ($don->set_encaisse($id) >= 0)
|
||||
{
|
||||
Header("Location: fiche.php?rowid=".$_GET["rowid"]);
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else $mesg=$don->error;
|
||||
@ -213,7 +214,7 @@ if ($action == 'set_encaisse')
|
||||
if ($action == 'builddoc')
|
||||
{
|
||||
$donation = new Don($db);
|
||||
$donation->fetch($_GET['rowid']);
|
||||
$donation->fetch($id);
|
||||
|
||||
if ($_REQUEST['model'])
|
||||
{
|
||||
@ -238,7 +239,7 @@ if ($action == 'builddoc')
|
||||
}
|
||||
else
|
||||
{
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?rowid='.$donation->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$donation->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -332,12 +333,12 @@ if ($action == 'create')
|
||||
/* */
|
||||
/* ************************************************************ */
|
||||
|
||||
if ($id && $_GET["action"] == 'edit')
|
||||
if (! empty($id) && $action == 'edit')
|
||||
{
|
||||
$don->fetch($id);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"];
|
||||
$head[$h][0] = $_SERVER['PHP_SELF']."?id=".$don->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
@ -401,11 +402,11 @@ if ($id && $_GET["action"] == 'edit')
|
||||
print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$don->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Project
|
||||
if ($conf->projet->enabled)
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load('projects');
|
||||
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
||||
select_projects($soc->id, isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project, 'projectid');
|
||||
select_projects(-1, (isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project), 'projectid');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -425,12 +426,12 @@ if ($id && $_GET["action"] == 'edit')
|
||||
/* Fiche don en mode visu */
|
||||
/* */
|
||||
/* ************************************************************ */
|
||||
if ($id && $action != 'edit')
|
||||
if (! empty($id) && $action != 'edit')
|
||||
{
|
||||
$result=$don->fetch($id);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"];
|
||||
$head[$h][0] = $_SERVER['PHP_SELF']."?id=".$don->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
@ -565,8 +566,6 @@ if ($id && $action != 'edit')
|
||||
}
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -27,7 +28,8 @@ require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php");
|
||||
|
||||
$langs->load("donations");
|
||||
|
||||
if (!$user->rights->don->lire) accessforbidden();
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'don');
|
||||
|
||||
$donation_static=new Don($db);
|
||||
|
||||
@ -48,17 +50,19 @@ $donstatic=new Don($db);
|
||||
$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Subvenciones';
|
||||
llxHeader('',$langs->trans("Donations"),$help_url);
|
||||
|
||||
$nb=array();
|
||||
$somme=array();
|
||||
|
||||
$sql = "SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
|
||||
$sql.= " GROUP BY d.fk_statut";
|
||||
$sql.= " ORDER BY d.fk_statut";
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
@ -107,17 +111,19 @@ print '<td align="right">'.$langs->trans("Total").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Average").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$total=0;
|
||||
$totalnb=0;
|
||||
$var=true;
|
||||
foreach ($listofstatus as $status)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td><a href="liste.php?statut='.$status.'">'.$donstatic->LibStatut($status,4).'</a></td>';
|
||||
print '<td align="right">'.$nb[$status].'</td>';
|
||||
print '<td align="right">'.($nb[$status]?price($somme[$status],'MT'):' ').'</td>';
|
||||
print '<td align="right">'.($nb[$status]?price(price2num($somme[$status]/$nb[$status],'MT')):' ').'</td>';
|
||||
$totalnb += $nb[$status];
|
||||
$total += $somme[$status];
|
||||
print '<td align="right">'.(! empty($nb[$status])?$nb[$status]:' ').'</td>';
|
||||
print '<td align="right">'.(! empty($nb[$status])?price($somme[$status],'MT'):' ').'</td>';
|
||||
print '<td align="right">'.(! empty($nb[$status])?price(price2num($somme[$status]/$nb[$status],'MT')):' ').'</td>';
|
||||
$totalnb += (! empty($nb[$status])?$nb[$status]:0);
|
||||
$total += (! empty($somme[$status])?$somme[$status]:0);
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -24,7 +25,7 @@
|
||||
|
||||
require("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php");
|
||||
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
|
||||
if (! empty($conf->projet->enabled)) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("donations");
|
||||
@ -83,10 +84,10 @@ if (trim($search_name) != '')
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
$sql.= $db->plimit($limit+1, $offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param="&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
|
||||
@ -110,7 +111,7 @@ if ($result)
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"d.societe","&page=$page&statut=$statut","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"d.nom","&page=$page&statut=$statut","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"d.datedon","&page=$page&statut=$statut","",'align="center"',$sortfield,$sortorder);
|
||||
if ($conf->projet->enabled)
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"fk_don_projet","&page=$page&statut=$statut","","",$sortfield,$sortorder);
|
||||
@ -133,7 +134,7 @@ if ($result)
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
if ($conf->projet->enabled)
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
print '<td class="liste_titre" align="right">';
|
||||
print ' ';
|
||||
|
||||
@ -435,7 +435,7 @@ class FormFile
|
||||
$out.= '</tr>';
|
||||
|
||||
// Execute hooks
|
||||
$parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBALS['id'],'modulepart'=>$modulepart);
|
||||
$parameters=array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart);
|
||||
if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions',$parameters,$GLOBALS['object']);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2006 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -51,7 +52,7 @@ class html_cerfafr extends ModeleDon
|
||||
|
||||
/**
|
||||
* Return if a module can be used or not
|
||||
*
|
||||
*
|
||||
* @return boolean true if module can be used
|
||||
*/
|
||||
function isEnabled()
|
||||
@ -62,7 +63,7 @@ class html_cerfafr extends ModeleDon
|
||||
|
||||
/**
|
||||
* Write the object to document file to disk
|
||||
*
|
||||
*
|
||||
* @param Don $don Donation object
|
||||
* @param Translate $outputlangs Lang object for output language
|
||||
* @return int >0 if OK, <0 if KO
|
||||
@ -72,6 +73,7 @@ class html_cerfafr extends ModeleDon
|
||||
global $user,$conf,$langs,$mysoc;
|
||||
|
||||
$now=dol_now();
|
||||
$id = (! is_object($don)?$don:'');
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
|
||||
@ -81,18 +83,18 @@ class html_cerfafr extends ModeleDon
|
||||
$outputlangs->load("bills");
|
||||
$outputlangs->load("products");
|
||||
|
||||
if ($conf->don->dir_output)
|
||||
if (! empty($conf->don->dir_output))
|
||||
{
|
||||
// Definition de l'objet $don (pour compatibilite ascendante)
|
||||
if (! is_object($don))
|
||||
{
|
||||
$id = $don;
|
||||
$don = new Don($this->db);
|
||||
$ret=$don->fetch($id);
|
||||
$id=$don->id;
|
||||
}
|
||||
|
||||
// Definition de $dir et $file
|
||||
if ($don->specimen)
|
||||
if (! empty($don->specimen))
|
||||
{
|
||||
$dir = $conf->don->dir_output;
|
||||
$file = $dir . "/SPECIMEN.html";
|
||||
@ -120,7 +122,7 @@ class html_cerfafr extends ModeleDon
|
||||
$form = implode('', file($donmodel));
|
||||
$form = str_replace('__REF__',$id,$form);
|
||||
$form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form);
|
||||
$form = str_replace('__IP__',$user->ip,$form);
|
||||
//$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
|
||||
$form = str_replace('__AMOUNT__',$don->amount,$form);
|
||||
$form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$conf->currency),$form);
|
||||
$form = str_replace('__CURRENCYCODE__',$conf->currency,$form);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user