30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
41$langs->load(
"donations");
45$hookmanager->initHooks(array(
'donationindex'));
47$donation_static =
new Don($db);
64$donstatic =
new Don($db);
66$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
68llxHeader(
'', $langs->trans(
"Donations"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-donation page-index');
74$sql =
"SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut";
75$sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d WHERE d.entity IN (".
getEntity(
'donation').
")";
76$sql .=
" GROUP BY d.fk_statut";
77$sql .=
" ORDER BY d.fk_statut";
79$result = $db->query($sql);
82 $num = $db->num_rows($result);
84 $objp = $db->fetch_object($result);
86 $somme[$objp->fk_statut] = $objp->somme;
87 $nb[$objp->fk_statut] = $objp->nb;
88 $total += $objp->somme;
97print
load_fiche_titre($langs->trans(
"DonationsArea"),
'',
'object_donation');
100print
'<div class="fichecenter"><div class="fichethirdleft">';
102if (!isset($listofsearchfields) || !is_array($listofsearchfields)) {
104 $listofsearchfields = array();
107 if (isModEnabled(
'don') && $user->hasRight(
'don',
'lire')) {
108 $listofsearchfields[
'search_donation'] = array(
'text' =>
'Donation');
111 if (count($listofsearchfields)) {
112 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
113 print
'<input type="hidden" name="token" value="'.newToken().
'">';
114 print
'<table class="noborder nohover centpercent">';
116 foreach ($listofsearchfields as $key => $value) {
118 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
121 print
'<td class="nowrap"><label for="'.$key.
'">'.$langs->trans($value[
"text"]).
'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.
'" id="'.$key.
'"></td>';
123 print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" class="button" value="'.$langs->trans(
"Search").
'"></td>';
134$dataseries = array();
135$colorseries = array();
137include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
139print
'<table class="noborder nohover centpercent">';
140print
'<tr class="liste_titre">';
141print
'<th colspan="4">'.$langs->trans(
"Statistics").
'</th>';
144$listofstatus = array(0, 1, -1, 2);
145foreach ($listofstatus as $status) {
146 $dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (
int) $nb[$status] : 0));
147 if ($status == Don::STATUS_DRAFT) {
148 $colorseries[$status] =
'-'.$badgeStatus0;
150 if ($status == Don::STATUS_VALIDATED) {
151 $colorseries[$status] = $badgeStatus1;
153 if ($status == Don::STATUS_CANCELED) {
154 $colorseries[$status] = $badgeStatus9;
156 if ($status == Don::STATUS_PAID) {
157 $colorseries[$status] = $badgeStatus6;
161if (
$conf->use_javascript_ajax) {
162 print
'<tr><td class="center" colspan="4">';
164 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
166 $dolgraph->SetData($dataseries);
167 $dolgraph->SetDataColor(array_values($colorseries));
168 $dolgraph->setShowLegend(2);
169 $dolgraph->setShowPercent(1);
170 $dolgraph->SetType(array(
'pie'));
171 $dolgraph->setHeight(
'200');
172 $dolgraph->draw(
'idgraphstatus');
173 print $dolgraph->show($total ? 0 : 1);
178print
'<tr class="liste_titre">';
179print
'<td>'.$langs->trans(
"Status").
'</td>';
180print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
181print
'<td class="right">'.$langs->trans(
"Total").
'</td>';
182print
'<td class="right">'.$langs->trans(
"Average").
'</td>';
187foreach ($listofstatus as $status) {
188 print
'<tr class="oddeven">';
189 print
'<td><a href="list.php?search_status='.$status.
'">'.$donstatic->LibStatut($status, 4).
'</a></td>';
190 print
'<td class="right">'.(!empty($nb[$status]) ? $nb[$status] :
' ').
'</td>';
191 print
'<td class="right nowraponall amount">'.(!empty($nb[$status]) ?
price($somme[$status], 1,
'', 1, -1,
'MT') :
' ').
'</td>';
192 print
'<td class="right nowraponall">'.(!empty($nb[$status]) ?
price(
price2num($somme[$status] / $nb[$status],
'MT')) :
' ').
'</td>';
193 $totalnb += (!empty($nb[$status]) ? $nb[$status] : 0);
194 $total += (!empty($somme[$status]) ? $somme[$status] : 0);
198print
'<tr class="liste_total">';
199print
'<td>'.$langs->trans(
"Total").
'</td>';
200print
'<td class="right nowraponall">'.$totalnb.
'</td>';
201print
'<td class="right nowraponall">'.price($total, 1,
"", 1, -1,
'MT').
'</td>';
202print
'<td class="right nowraponall">'.($totalnb ?
price(
price2num($total / $totalnb,
'MT')) :
' ').
'</td>';
207print
'</div><div class="fichetwothirdright">';
217$sql =
"SELECT c.rowid, c.ref, c.fk_statut, c.societe, c.lastname, c.firstname, c.tms as datem, c.amount";
218$sql .=
" FROM ".MAIN_DB_PREFIX.
"don as c";
219$sql .=
" WHERE c.entity IN (".getEntity(
"don").
")";
221$sql .=
" ORDER BY c.tms DESC";
222$sql .= $db->plimit($max, 0);
224$resql = $db->query($sql);
226 print
'<table class="noborder centpercent">';
227 print
'<tr class="liste_titre">';
228 print
'<th colspan="5">'.$langs->trans(
"LastModifiedDonations", $max).
' ';
229 print
'<a href="'.DOL_URL_ROOT.
'/don/list.php?sortfield=d.datem&sortorder=DESC">';
230 print
'<span class="badge">...</span>';
234 $num = $db->num_rows($resql);
238 $obj = $db->fetch_object($resql);
240 print
'<tr class="oddeven">';
242 $donation_static->id = $obj->rowid;
243 $donation_static->ref = $obj->ref ? $obj->ref : $obj->rowid;
245 print
'<td width="96" class="nobordernopadding nowrap">';
246 print $donation_static->getNomUrl(1);
249 print
'<td class="nobordernopadding">';
251 print($obj->societe && ($obj->lastname || $obj->firstname) ?
' / ' :
'');
255 print
'<td class="right nobordernopadding nowraponall amount">';
256 print
price($obj->amount, 1);
260 print
'<td class="center">'.dol_print_date($db->jdate($obj->datem),
'day').
'</td>';
262 print
'<td class="right">'.$donation_static->LibStatut($obj->fk_statut, 5).
'</td>';
268 print
"</table><br>";
276$parameters = array(
'user' => $user);
277$reshook = $hookmanager->executeHooks(
'dashboardDonation', $parameters, $object);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage donations.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.