new box replace

This commit is contained in:
Frédéric FRANCE 2021-03-02 22:21:34 +01:00
parent d68de8617b
commit 22bc3b879b
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
3 changed files with 120 additions and 77 deletions

View File

@ -237,74 +237,6 @@ if ($conf->use_javascript_ajax) {
print '<br>'; print '<br>';
// List of subscription by year
$Total = array();
$Number = array();
$tot = 0;
$numb = 0;
$sql = "SELECT c.subscription, c.dateadh as dateh";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.rowid = c.fk_adherent";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
while ($i < $num) {
$objp = $db->fetch_object($result);
$year = dol_print_date($db->jdate($objp->dateh), "%Y");
$Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
$Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
$tot += $objp->subscription;
$numb += 1;
$i++;
}
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Year").'</th>';
print '<th class="right">'.$langs->trans("Subscriptions").'</th>';
print '<th class="right">'.$langs->trans("AmountTotal").'</th>';
print '<th class="right">'.$langs->trans("AmountAverage").'</th>';
print "</tr>\n";
krsort($Total);
$i = 0;
foreach ($Total as $key => $value) {
if ($i >= 8) {
print '<tr class="oddeven">';
print "<td>...</td>";
print "<td class=\"right\"></td>";
print "<td class=\"right\"></td>";
print "<td class=\"right\"></td>";
print "</tr>\n";
break;
}
print '<tr class="oddeven">';
print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
print "<td class=\"right\">".$Number[$key]."</td>";
print "<td class=\"right\">".price($value)."</td>";
print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>";
print "</tr>\n";
$i++;
}
// Total
print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
print "<td class=\"right\">".$numb."</td>";
print '<td class="right">'.price($tot)."</td>";
print "<td class=\"right\">".price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT'))."</td>";
print "</tr>\n";
print "</table></div>";
print "<br>\n";
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print '</div></div></div>'; print '</div></div></div>';

View File

@ -93,15 +93,125 @@ class box_members_subscriptions_by_year extends ModeleBoxes
if ($user->rights->adherent->lire) { if ($user->rights->adherent->lire) {
$num = 0; $num = 0;
$line = 0; $line = 0;
if (1) { // List of subscription by year
$Total = array();
$Number = array();
$tot = 0;
$numb = 0;
$sql = "SELECT c.subscription, c.dateadh as dateh";
$sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "subscription as c";
$sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")";
$sql .= " AND d.rowid = c.fk_adherent";
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num) {
$objp = $this->db->fetch_object($result);
$year = dol_print_date($this->db->jdate($objp->dateh), "%Y");
$Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
$Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
$tot += $objp->subscription;
$numb += 1;
$i++;
}
$line = 0;
$this->info_box_contents[$line][] = array(
'td' => 'class="liste_titre"',
'text' => $langs->trans("Year"),
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("Subscriptions"),
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("AmountTotal"),
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("AmountAverage"),
);
$line++;
krsort($Total);
$i = 0;
foreach ($Total as $key => $value) {
if ($i >= 8) {
// print '<tr class="oddeven">';
// print "<td>...</td>";
// print "<td class=\"right\"></td>";
// print "<td class=\"right\"></td>";
// print "<td class=\"right\"></td>";
// print "</tr>\n";
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => '...',
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => '',
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => '',
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => '',
);
$line++;
break;
}
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => '<a href="./subscription/list.php?date_select='.$key.'">'.$key.'</a>',
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $Number[$key],
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => price($value),
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => price(price2num($value / $Number[$key], 'MT')),
);
$line++;
}
if ($num == 0) { if ($num == 0) {
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="center"', 'td' => 'class="center"',
'text' => $langs->trans("NoRecordedMembers"), 'text' => $langs->trans("NoRecordedMembers"),
); );
} else {
$this->info_box_contents[$line][] = array(
'td' => 'class="liste_total"',
'text' => $langs->trans("Total"),
);
$this->info_box_contents[$line][] = array(
'td' => 'class="liste_total right"',
'text' => $numb,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="liste_total right"',
'text' => price($tot),
);
$this->info_box_contents[$line][] = array(
'td' => 'class="liste_total right"',
'text' => price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')),
);
} }
$this->db->free($result);
} else { } else {
$this->info_box_contents[0][0] = array( $this->info_box_contents[0][0] = array(
'td' => '', 'td' => '',

View File

@ -23,6 +23,7 @@ BoxFicheInter=Latest interventions
BoxCurrentAccounts=Open accounts balance BoxCurrentAccounts=Open accounts balance
BoxTitleMemberNextBirthdays=Birthdays of this month (members) BoxTitleMemberNextBirthdays=Birthdays of this month (members)
BoxTitleMembersByType=Members by type BoxTitleMembersByType=Members by type
BoxTitleMembersSubscriptionsByYear=Members Subscriptions by year
BoxTitleLastRssInfos=Latest %s news from %s BoxTitleLastRssInfos=Latest %s news from %s
BoxTitleLastProducts=Products/Services: last %s modified BoxTitleLastProducts=Products/Services: last %s modified
BoxTitleProductsAlertStock=Products: stock alert BoxTitleProductsAlertStock=Products: stock alert