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);
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">';
102$listofsearchfields = array();
105 if (
isModEnabled(
'don') && $user->hasRight(
'don',
'lire')) {
106 $listofsearchfields[
'search_donation'] = array(
'text' =>
'Donation');
109 if (count($listofsearchfields)) {
110 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
111 print
'<input type="hidden" name="token" value="'.newToken().
'">';
112 print
'<table class="noborder nohover centpercent">';
114 foreach ($listofsearchfields as $key => $value) {
116 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
119 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>';
121 print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" class="button" value="'.$langs->trans(
"Search").
'"></td>';
132$dataseries = array();
133$colorseries = array();
135include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
143print
'<table class="noborder nohover centpercent">';
144print
'<tr class="liste_titre">';
145print
'<th colspan="4">'.$langs->trans(
"Statistics").
'</th>';
148$listofstatus = array(0, 1, -1, 2);
149foreach ($listofstatus as $status) {
150 $dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (
int) $nb[$status] : 0));
151 if ($status == Don::STATUS_DRAFT) {
152 $colorseries[$status] =
'-'.$badgeStatus0;
154 if ($status == Don::STATUS_VALIDATED) {
155 $colorseries[$status] = $badgeStatus1;
157 if ($status == Don::STATUS_CANCELED) {
158 $colorseries[$status] = $badgeStatus9;
160 if ($status == Don::STATUS_PAID) {
161 $colorseries[$status] = $badgeStatus6;
165if (
$conf->use_javascript_ajax) {
166 print
'<tr><td class="center" colspan="4">';
168 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
170 $dolgraph->SetData($dataseries);
171 $dolgraph->SetDataColor(array_values($colorseries));
172 $dolgraph->setShowLegend(2);
173 $dolgraph->setShowPercent(1);
174 $dolgraph->SetType(array(
'pie'));
175 $dolgraph->setHeight(
'200');
176 $dolgraph->draw(
'idgraphstatus');
177 print $dolgraph->show($total ? 0 : 1);
182print
'<tr class="liste_titre">';
183print
'<td>'.$langs->trans(
"Status").
'</td>';
184print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
185print
'<td class="right">'.$langs->trans(
"Total").
'</td>';
186print
'<td class="right">'.$langs->trans(
"Average").
'</td>';
191foreach ($listofstatus as $status) {
192 print
'<tr class="oddeven">';
193 print
'<td><a href="list.php?search_status='.$status.
'">'.$donstatic->LibStatut($status, 4).
'</a></td>';
194 print
'<td class="right">'.(!empty($nb[$status]) ? $nb[$status] :
' ').
'</td>';
195 print
'<td class="right nowraponall amount">'.(!empty($nb[$status]) ?
price($somme[$status], 1,
'', 1, -1,
'MT') :
' ').
'</td>';
196 print
'<td class="right nowraponall">'.(!empty($nb[$status]) ?
price(
price2num($somme[$status] / $nb[$status],
'MT')) :
' ').
'</td>';
197 $totalnb += (!empty($nb[$status]) ? $nb[$status] : 0);
198 $total += (!empty($somme[$status]) ? $somme[$status] : 0);
202print
'<tr class="liste_total">';
203print
'<td>'.$langs->trans(
"Total").
'</td>';
204print
'<td class="right nowraponall">'.$totalnb.
'</td>';
205print
'<td class="right nowraponall">'.price($total, 1,
"", 1, -1,
'MT').
'</td>';
206print
'<td class="right nowraponall">'.($totalnb ?
price(
price2num($total / $totalnb,
'MT')) :
' ').
'</td>';
211print
'</div><div class="fichetwothirdright">';
221$sql =
"SELECT c.rowid, c.ref, c.fk_statut, c.societe, c.lastname, c.firstname, c.tms as datem, c.amount, c.fk_soc as socid";
222$sql .=
" FROM ".MAIN_DB_PREFIX.
"don as c";
223$sql .=
" WHERE c.entity IN (".getEntity(
"don").
")";
225$sql .=
" ORDER BY c.tms DESC";
226$sql .=
$db->plimit($max, 0);
228$resql =
$db->query($sql);
230 print
'<table class="noborder centpercent">';
231 print
'<tr class="liste_titre">';
232 print
'<th colspan="5">'.$langs->trans(
"LastModifiedDonations", $max).
' ';
233 print
'<a href="'.DOL_URL_ROOT.
'/don/list.php?sortfield=d.datedon&sortorder=DESC">';
234 print
'<span class="badge">...</span>';
238 $num =
$db->num_rows($resql);
242 $obj =
$db->fetch_object($resql);
244 print
'<tr class="oddeven">';
246 $donation_static->id = $obj->rowid;
247 $donation_static->ref = $obj->ref ? $obj->ref : $obj->rowid;
249 print
'<td width="96" class="nobordernopadding nowrap">';
250 print $donation_static->getNomUrl(1);
253 print
'<td class="nobordernopadding">';
254 if (!empty($obj->socid)) {
256 $ret = $companystatic->fetch($obj->socid);
258 print $companystatic->getNomUrl(1);
262 print($obj->societe && ($obj->lastname || $obj->firstname) ?
' / ' :
'');
267 print
'<td class="right nobordernopadding nowraponall amount">';
268 print
price($obj->amount, 1);
272 print
'<td class="center" title="'.$langs->trans(
"DonationDate").
': '.
dol_print_date(
$db->jdate($obj->datem),
'day').
'">'.
dol_print_date(
$db->jdate($obj->datem),
'day').
'</td>';
274 print
'<td class="right">'.$donation_static->LibStatut($obj->fk_statut, 5).
'</td>';
280 print
"</table><br>";
288$parameters = array(
'user' => $user);
289$reshook = $hookmanager->executeHooks(
'dashboardDonation', $parameters, $object);
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage third parties objects (customers, suppliers, prospects...)
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.