28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
34$hookmanager->initHooks(array(
'donationindex'));
36$langs->load(
"donations");
38$donation_static =
new Don($db);
55$donstatic =
new Don($db);
57$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
59llxHeader(
'', $langs->trans(
"Donations"), $help_url);
65$sql =
"SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut";
66$sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d WHERE d.entity IN (".
getEntity(
'donation').
")";
67$sql .=
" GROUP BY d.fk_statut";
68$sql .=
" ORDER BY d.fk_statut";
70$result = $db->query($sql);
73 $num = $db->num_rows($result);
75 $objp = $db->fetch_object($result);
77 $somme[$objp->fk_statut] = $objp->somme;
78 $nb[$objp->fk_statut] = $objp->nb;
79 $total += $objp->somme;
88print
load_fiche_titre($langs->trans(
"DonationsArea"),
'',
'object_donation');
91print
'<div class="fichecenter"><div class="fichethirdleft">';
94 if (isModEnabled(
'don') && $user->hasRight(
'don',
'lire')) {
95 $listofsearchfields[
'search_donation'] = array(
'text'=>
'Donation');
98 if (count($listofsearchfields)) {
99 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
100 print
'<input type="hidden" name="token" value="'.newToken().
'">';
101 print
'<table class="noborder nohover centpercent">';
103 foreach ($listofsearchfields as $key => $value) {
105 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
108 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>';
110 print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" class="button" value="'.$langs->trans(
"Search").
'"></td>';
121$dataseries = array();
122$colorseries = array();
124include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
126print
'<table class="noborder nohover centpercent">';
127print
'<tr class="liste_titre">';
128print
'<th colspan="4">'.$langs->trans(
"Statistics").
'</th>';
131$listofstatus = array(0, 1, -1, 2);
132foreach ($listofstatus as $status) {
133 $dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (
int) $nb[$status] : 0));
134 if ($status == Don::STATUS_DRAFT) {
135 $colorseries[$status] =
'-'.$badgeStatus0;
137 if ($status == Don::STATUS_VALIDATED) {
138 $colorseries[$status] = $badgeStatus1;
140 if ($status == Don::STATUS_CANCELED) {
141 $colorseries[$status] = $badgeStatus9;
143 if ($status == Don::STATUS_PAID) {
144 $colorseries[$status] = $badgeStatus6;
148if ($conf->use_javascript_ajax) {
149 print
'<tr><td class="center" colspan="4">';
151 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
153 $dolgraph->SetData($dataseries);
154 $dolgraph->SetDataColor(array_values($colorseries));
155 $dolgraph->setShowLegend(2);
156 $dolgraph->setShowPercent(1);
157 $dolgraph->SetType(array(
'pie'));
158 $dolgraph->setHeight(
'200');
159 $dolgraph->draw(
'idgraphstatus');
160 print $dolgraph->show($total ? 0 : 1);
165print
'<tr class="liste_titre">';
166print
'<td>'.$langs->trans(
"Status").
'</td>';
167print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
168print
'<td class="right">'.$langs->trans(
"Total").
'</td>';
169print
'<td class="right">'.$langs->trans(
"Average").
'</td>';
174foreach ($listofstatus as $status) {
175 print
'<tr class="oddeven">';
176 print
'<td><a href="list.php?search_status='.$status.
'">'.$donstatic->LibStatut($status, 4).
'</a></td>';
177 print
'<td class="right">'.(!empty($nb[$status]) ? $nb[$status] :
' ').
'</td>';
178 print
'<td class="right nowraponall amount">'.(!empty($nb[$status]) ?
price($somme[$status],
'MT') :
' ').
'</td>';
179 print
'<td class="right nowraponall">'.(!empty($nb[$status]) ?
price(
price2num($somme[$status] / $nb[$status],
'MT')) :
' ').
'</td>';
180 $totalnb += (!empty($nb[$status]) ? $nb[$status] : 0);
181 $total += (!empty($somme[$status]) ? $somme[$status] : 0);
185print
'<tr class="liste_total">';
186print
'<td>'.$langs->trans(
"Total").
'</td>';
187print
'<td class="right nowraponall">'.$totalnb.
'</td>';
188print
'<td class="right nowraponall">'.price($total,
'MT').
'</td>';
189print
'<td class="right nowraponall">'.($totalnb ?
price(
price2num($total / $totalnb,
'MT')) :
' ').
'</td>';
194print
'</div><div class="fichetwothirdright">';
203$sql =
"SELECT c.rowid, c.ref, c.fk_statut, c.societe, c.lastname, c.firstname, c.tms as datem, c.amount";
204$sql .=
" FROM ".MAIN_DB_PREFIX.
"don as c";
205$sql .=
" WHERE c.entity = ".$conf->entity;
207$sql .=
" ORDER BY c.tms DESC";
208$sql .= $db->plimit($max, 0);
210$resql = $db->query($sql);
212 print
'<table class="noborder centpercent">';
213 print
'<tr class="liste_titre">';
214 print
'<th colspan="5">'.$langs->trans(
"LastModifiedDonations", $max).
'</th></tr>';
216 $num = $db->num_rows($resql);
220 $obj = $db->fetch_object($resql);
222 print
'<tr class="oddeven">';
224 $donation_static->id = $obj->rowid;
225 $donation_static->ref = $obj->ref ? $obj->ref : $obj->rowid;
227 print
'<td width="96" class="nobordernopadding nowrap">';
228 print $donation_static->getNomUrl(1);
231 print
'<td class="nobordernopadding">';
233 print ($obj->societe && ($obj->lastname || $obj->firstname) ?
' / ' :
'');
237 print
'<td class="right nobordernopadding nowraponall amount">';
238 print
price($obj->amount, 1);
242 print
'<td class="center">'.dol_print_date($db->jdate($obj->datem),
'day').
'</td>';
244 print
'<td class="right">'.$donation_static->LibStatut($obj->fk_statut, 5).
'</td>';
250 print
"</table><br>";
258$parameters = array(
'user' => $user);
259$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()
Empty header.
Class to manage donations.
load_fiche_titre($titre, $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 '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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.