29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
35$hookmanager->initHooks(array(
'donationindex'));
37$langs->load(
"donations");
39$donation_static =
new Don($db);
56$donstatic =
new Don($db);
58$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
60llxHeader(
'', $langs->trans(
"Donations"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-donation page-index');
66$sql =
"SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut";
67$sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d WHERE d.entity IN (".
getEntity(
'donation').
")";
68$sql .=
" GROUP BY d.fk_statut";
69$sql .=
" ORDER BY d.fk_statut";
71$result = $db->query($sql);
74 $num = $db->num_rows($result);
76 $objp = $db->fetch_object($result);
78 $somme[$objp->fk_statut] = $objp->somme;
79 $nb[$objp->fk_statut] = $objp->nb;
80 $total += $objp->somme;
89print
load_fiche_titre($langs->trans(
"DonationsArea"),
'',
'object_donation');
92print
'<div class="fichecenter"><div class="fichethirdleft">';
94if (!isset($listofsearchfields) || !is_array($listofsearchfields)) {
96 $listofsearchfields = array();
99 if (isModEnabled(
'don') && $user->hasRight(
'don',
'lire')) {
100 $listofsearchfields[
'search_donation'] = array(
'text' =>
'Donation');
103 if (count($listofsearchfields)) {
104 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
105 print
'<input type="hidden" name="token" value="'.newToken().
'">';
106 print
'<table class="noborder nohover centpercent">';
108 foreach ($listofsearchfields as $key => $value) {
110 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
113 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>';
115 print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" class="button" value="'.$langs->trans(
"Search").
'"></td>';
126$dataseries = array();
127$colorseries = array();
129include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
131print
'<table class="noborder nohover centpercent">';
132print
'<tr class="liste_titre">';
133print
'<th colspan="4">'.$langs->trans(
"Statistics").
'</th>';
136$listofstatus = array(0, 1, -1, 2);
137foreach ($listofstatus as $status) {
138 $dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (
int) $nb[$status] : 0));
139 if ($status == Don::STATUS_DRAFT) {
140 $colorseries[$status] =
'-'.$badgeStatus0;
142 if ($status == Don::STATUS_VALIDATED) {
143 $colorseries[$status] = $badgeStatus1;
145 if ($status == Don::STATUS_CANCELED) {
146 $colorseries[$status] = $badgeStatus9;
148 if ($status == Don::STATUS_PAID) {
149 $colorseries[$status] = $badgeStatus6;
153if ($conf->use_javascript_ajax) {
154 print
'<tr><td class="center" colspan="4">';
156 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
158 $dolgraph->SetData($dataseries);
159 $dolgraph->SetDataColor(array_values($colorseries));
160 $dolgraph->setShowLegend(2);
161 $dolgraph->setShowPercent(1);
162 $dolgraph->SetType(array(
'pie'));
163 $dolgraph->setHeight(
'200');
164 $dolgraph->draw(
'idgraphstatus');
165 print $dolgraph->show($total ? 0 : 1);
170print
'<tr class="liste_titre">';
171print
'<td>'.$langs->trans(
"Status").
'</td>';
172print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
173print
'<td class="right">'.$langs->trans(
"Total").
'</td>';
174print
'<td class="right">'.$langs->trans(
"Average").
'</td>';
179foreach ($listofstatus as $status) {
180 print
'<tr class="oddeven">';
181 print
'<td><a href="list.php?search_status='.$status.
'">'.$donstatic->LibStatut($status, 4).
'</a></td>';
182 print
'<td class="right">'.(!empty($nb[$status]) ? $nb[$status] :
' ').
'</td>';
183 print
'<td class="right nowraponall amount">'.(!empty($nb[$status]) ?
price($somme[$status], 1,
'', 1, -1,
'MT') :
' ').
'</td>';
184 print
'<td class="right nowraponall">'.(!empty($nb[$status]) ?
price(
price2num($somme[$status] / $nb[$status],
'MT')) :
' ').
'</td>';
185 $totalnb += (!empty($nb[$status]) ? $nb[$status] : 0);
186 $total += (!empty($somme[$status]) ? $somme[$status] : 0);
190print
'<tr class="liste_total">';
191print
'<td>'.$langs->trans(
"Total").
'</td>';
192print
'<td class="right nowraponall">'.$totalnb.
'</td>';
193print
'<td class="right nowraponall">'.price($total, 1,
"", 1, -1,
'MT').
'</td>';
194print
'<td class="right nowraponall">'.($totalnb ?
price(
price2num($total / $totalnb,
'MT')) :
' ').
'</td>';
199print
'</div><div class="fichetwothirdright">';
208$sql =
"SELECT c.rowid, c.ref, c.fk_statut, c.societe, c.lastname, c.firstname, c.tms as datem, c.amount";
209$sql .=
" FROM ".MAIN_DB_PREFIX.
"don as c";
210$sql .=
" WHERE c.entity = ".$conf->entity;
212$sql .=
" ORDER BY c.tms DESC";
213$sql .= $db->plimit($max, 0);
215$resql = $db->query($sql);
217 print
'<table class="noborder centpercent">';
218 print
'<tr class="liste_titre">';
219 print
'<th colspan="5">'.$langs->trans(
"LastModifiedDonations", $max).
'</th></tr>';
221 $num = $db->num_rows($resql);
225 $obj = $db->fetch_object($resql);
227 print
'<tr class="oddeven">';
229 $donation_static->id = $obj->rowid;
230 $donation_static->ref = $obj->ref ? $obj->ref : $obj->rowid;
232 print
'<td width="96" class="nobordernopadding nowrap">';
233 print $donation_static->getNomUrl(1);
236 print
'<td class="nobordernopadding">';
238 print($obj->societe && ($obj->lastname || $obj->firstname) ?
' / ' :
'');
242 print
'<td class="right nobordernopadding nowraponall amount">';
243 print
price($obj->amount, 1);
247 print
'<td class="center">'.dol_print_date($db->jdate($obj->datem),
'day').
'</td>';
249 print
'<td class="right">'.$donation_static->LibStatut($obj->fk_statut, 5).
'</td>';
255 print
"</table><br>";
263$parameters = array(
'user' => $user);
264$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.
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.
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.