Fix: Count of up to date members
This commit is contained in:
parent
f5b246f5bb
commit
eef7a7ec02
@ -26,9 +26,9 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/member/PDF_card.class.php");
|
||||
//require_once(DOL_DOCUMENT_ROOT."/adherents/cartes/PDF_card.class.php");
|
||||
|
||||
|
||||
// liste des patterns remplacable dans le texte a imprimer
|
||||
@ -49,14 +49,6 @@ $patterns = array (
|
||||
'/%ANNEE%/'
|
||||
);
|
||||
|
||||
/*
|
||||
*-------------------------------------------------
|
||||
* Pour cr<EFBFBD>er l'objet on a 2 moyens :
|
||||
* Soit on donne les valeurs en les passant dans un tableau (sert pour un format personnel)
|
||||
* Soit on donne le type d'<EFBFBD>tiquette au format AVERY
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
$dir = $conf->adherent->dir_tmp;
|
||||
$file = $dir . "/tmpcard.pdf";
|
||||
@ -88,7 +80,7 @@ $sql.= " t.libelle as type,";
|
||||
$sql.= " p.libelle as pays";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
|
||||
$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1 AND datefin >= ".$db->idate(mktime());
|
||||
$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
|
||||
$sql.= " ORDER BY d.rowid ASC";
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -132,16 +124,22 @@ if ($result)
|
||||
|
||||
$db->close();
|
||||
|
||||
// Output file
|
||||
$type = 'application/octet-stream';
|
||||
|
||||
if ($type) header('Content-Type: '.$type);
|
||||
header('Content-Disposition: attachment; filename="tmpcard.pdf"');
|
||||
clearstatcache();
|
||||
|
||||
$attachment=true;
|
||||
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
|
||||
$filename='tmpcards.pdf';
|
||||
$type=dol_mimetype($filename);
|
||||
|
||||
if ($encoding) header('Content-Encoding: '.$encoding);
|
||||
if ($type) header('Content-Type: '.$type);
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
else header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
header('Cache-Control: Public, must-revalidate');
|
||||
header('Pragma: public');
|
||||
|
||||
|
||||
readfile($file);
|
||||
}
|
||||
else
|
||||
|
||||
@ -26,17 +26,10 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/member/PDF_card.class.php');
|
||||
|
||||
/*
|
||||
*-------------------------------------------------
|
||||
* Pour cr<EFBFBD>er l'objet on a 2 moyens :
|
||||
* Soit on donne les valeurs en les passant dans un tableau (sert pour un format personnel)
|
||||
* Soit on donne le type d'<EFBFBD>tiquette au format AVERY
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
$dir = $conf->adherent->dir_tmp;
|
||||
$file = $dir . "/tmplabel.pdf";
|
||||
@ -75,7 +68,7 @@ $sql.= " t.libelle as type,";
|
||||
$sql.= " p.libelle as pays";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
|
||||
$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1 AND datefin >= ".$db->idate(mktime());
|
||||
$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
|
||||
$sql.= " ORDER BY d.rowid ASC";
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -100,16 +93,22 @@ if ($result)
|
||||
|
||||
$db->close();
|
||||
|
||||
// Output file
|
||||
$type = 'application/octet-stream';
|
||||
|
||||
if ($type) header('Content-Type: '.$type);
|
||||
header('Content-Disposition: attachment; filename="tmplabel.pdf"');
|
||||
clearstatcache();
|
||||
|
||||
$attachment=true;
|
||||
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
|
||||
$filename='tmplabels.pdf';
|
||||
$type=dol_mimetype($filename);
|
||||
|
||||
if ($encoding) header('Content-Encoding: '.$encoding);
|
||||
if ($type) header('Content-Type: '.$type);
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
else header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
header('Cache-Control: Public, must-revalidate');
|
||||
header('Pragma: public');
|
||||
|
||||
|
||||
readfile($file);
|
||||
}
|
||||
else
|
||||
|
||||
@ -166,7 +166,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"])
|
||||
$adh->email = trim($_POST["email"]);
|
||||
$adh->naiss = $datenaiss;
|
||||
|
||||
$adh->typeid = $_POST["type"];
|
||||
$adh->typeid = $_POST["typeid"];
|
||||
$adh->note = trim($_POST["comment"]);
|
||||
$adh->morphy = $_POST["morphy"];
|
||||
|
||||
@ -244,7 +244,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add')
|
||||
$datecotisation=dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
}
|
||||
|
||||
$type=$_POST["type"];
|
||||
$typeid=$_POST["typeid"];
|
||||
$nom=$_POST["nom"];
|
||||
$prenom=$_POST["prenom"];
|
||||
$societe=$_POST["societe"];
|
||||
@ -279,7 +279,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add')
|
||||
$adh->pass = $pass;
|
||||
$adh->naiss = $datenaiss;
|
||||
$adh->photo = $photo;
|
||||
$adh->typeid = $type;
|
||||
$adh->typeid = $typeid;
|
||||
$adh->note = $comment;
|
||||
$adh->morphy = $morphy;
|
||||
foreach($_POST as $key => $value){
|
||||
@ -291,12 +291,12 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add')
|
||||
}
|
||||
|
||||
// Test validite des parametres
|
||||
if(!isset($type) || $type==''){
|
||||
if (empty($typeid)) {
|
||||
$error++;
|
||||
$errmsg .= $langs->trans("ErrorMemberTypeNotDefined")."<br>\n";
|
||||
}
|
||||
// Test si le login existe deja
|
||||
if(!isset($login) || $login==''){
|
||||
if (empty($login)) {
|
||||
$error++;
|
||||
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."<br>\n";
|
||||
}
|
||||
@ -312,7 +312,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add')
|
||||
$errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."<br>\n";
|
||||
}
|
||||
}
|
||||
if (!isset($nom) || $nom=='') {
|
||||
if (empty($nom)) {
|
||||
$error++;
|
||||
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."<br>\n";
|
||||
}
|
||||
@ -324,7 +324,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add')
|
||||
$error++;
|
||||
$errmsg .= $langs->trans("ErrorBadEMail",$email)."<br>\n";
|
||||
}
|
||||
if (!isset($pass) || $pass == '' ) {
|
||||
if (empty($pass)) {
|
||||
$error++;
|
||||
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."<br>\n";
|
||||
}
|
||||
@ -627,12 +627,12 @@ if ($action == 'edit')
|
||||
print '<tr><td>'.$langs->trans("Type").'*</td><td>';
|
||||
if ($user->rights->adherent->creer) // If $user->rights->adherent->self->creer, we do not allow.
|
||||
{
|
||||
$htmls->select_array("type", $adht->liste_array(), $adh->typeid);
|
||||
$htmls->select_array("typeid", $adht->liste_array(), $adh->typeid);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $adht->getNomUrl(1);
|
||||
print '<input type="hidden" name="type" value="'.$adh->typeid.'">';
|
||||
print '<input type="hidden" name="typeid" value="'.$adh->typeid.'">';
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
@ -748,7 +748,7 @@ if ($action == 'create')
|
||||
$listetype=$adht->liste_array();
|
||||
if (sizeof($listetype))
|
||||
{
|
||||
$htmls->select_array("type", $listetype, $typeid);
|
||||
$htmls->select_array("typeid", $listetype, $typeid);
|
||||
} else {
|
||||
print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>';
|
||||
}
|
||||
|
||||
@ -46,9 +46,10 @@ $var=True;
|
||||
|
||||
$Adherents=array();
|
||||
$AdherentsAValider=array();
|
||||
$MemberUpToDate=array();
|
||||
$AdherentsResilies=array();
|
||||
|
||||
$AdherentType=array();
|
||||
$Cotisants=array();
|
||||
|
||||
# Liste les adherents
|
||||
$sql = "SELECT t.rowid, t.libelle, t.cotisation,";
|
||||
@ -57,6 +58,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON t.rowid = d.fk_adherent_type";
|
||||
$sql.= " GROUP BY t.rowid, t.libelle, t.cotisation, d.statut";
|
||||
|
||||
dol_syslog("index.php::select nb of members by type sql=".$sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -72,30 +74,27 @@ if ($result)
|
||||
$adhtype->libelle=$objp->libelle;
|
||||
$AdherentType[$objp->rowid]=$adhtype;
|
||||
|
||||
if ($objp->statut == -1) { $AdherentsAValider[$objp->rowid]=$objp->somme; }
|
||||
if ($objp->statut == 1) { $Adherents[$objp->rowid]=$objp->somme; }
|
||||
if ($objp->statut == 0) { $AdherentsResilies[$objp->rowid]=$objp->somme; }
|
||||
if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; }
|
||||
if ($objp->statut == 1) { $MembersValidated[$objp->rowid]=$objp->somme; }
|
||||
if ($objp->statut == 0) { $MembersResiliated[$objp->rowid]=$objp->somme; }
|
||||
|
||||
if ($objp->cotisation != 'yes')
|
||||
{
|
||||
$Cotisants[$objp->rowid]=$Adherents[$objp->rowid]=$objp->somme;
|
||||
}
|
||||
else
|
||||
{
|
||||
$Cotisants[$objp->rowid]=0; // Calcule plus loin
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
|
||||
# Liste les cotisants a jour
|
||||
// List members up to date
|
||||
// current rule: uptodate = the end date is in future whatever is type
|
||||
// old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future)
|
||||
$sql = "SELECT count(*) as somme , d.fk_adherent_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql.= " WHERE d.statut = 1 AND d.datefin >= ".$db->idate(mktime());
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
|
||||
//$sql.= " WHERE d.statut = 1 AND ((t.cotisation = 0 AND d.datefin IS NULL) OR d.datefin >= ".$db->idate(gmmktime()).')';
|
||||
$sql.= " WHERE d.statut = 1 AND d.datefin >= ".$db->idate(gmmktime());
|
||||
$sql.= " AND t.rowid = d.fk_adherent_type";
|
||||
$sql.= " GROUP BY d.fk_adherent_type";
|
||||
|
||||
dol_syslog("index.php::select nb of uptodate members by type sql=".$sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -104,7 +103,7 @@ if ($result)
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$Cotisants[$objp->fk_adherent_type]=$objp->somme;
|
||||
$MemberUpToDate[$objp->fk_adherent_type]=$objp->somme;
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
@ -145,7 +144,7 @@ $SommeD=0;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td>'.$langs->trans("MembersTypes").'</td>';
|
||||
print '<td align=right>'.$langs->trans("MembersStatusToValid").'</td>';
|
||||
print '<td align=right>'.$langs->trans("MenuMembersNotUpToDate").'</td>';
|
||||
print '<td align=right>'.$langs->trans("MenuMembersUpToDate").'</td>';
|
||||
@ -157,21 +156,21 @@ foreach ($AdherentType as $key => $adhtype)
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="type.php?rowid='.$adhtype->id.'">'.img_object($langs->trans("ShowType"),"group").' '.$adhtype->libelle.'</a></td>';
|
||||
print '<td align="right">'.(isset($AdherentsAValider[$key]) && $AdherentsAValider[$key] > 0?$AdherentsAValider[$key]:'').' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</td>';
|
||||
print '<td align="right">'.(isset($Adherents[$key]) && ($Adherents[$key]-$Cotisants[$key] > 0) ? $Adherents[$key]-$Cotisants[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
|
||||
print '<td align="right">'.(isset($Cotisants[$key]) && $Cotisants[$key] > 0 ? $Cotisants[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,mktime(),3).'</td>';
|
||||
print '<td align="right">'.(isset($AdherentsResilies[$key]) && $AdherentsResilies[$key]> 0 ?$AdherentsResilies[$key]:'').' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
|
||||
print '<td align="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</td>';
|
||||
print '<td align="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-$MemberUpToDate[$key] > 0) ? $MembersValidated[$key]-$MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
|
||||
print '<td align="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,gmmktime(),3).'</td>';
|
||||
print '<td align="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
|
||||
print "</tr>\n";
|
||||
$SommeA+=isset($AdherentsAValider[$key])?$AdherentsAValider[$key]:0;
|
||||
$SommeB+=isset($Adherents[$key])?$Adherents[$key]-$Cotisants[$key]:0;
|
||||
$SommeC+=isset($Cotisants[$key])?$Cotisants[$key]:0;
|
||||
$SommeD+=isset($AdherentsResilies[$key])?$AdherentsResilies[$key]:0;
|
||||
$SommeA+=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
|
||||
$SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0;
|
||||
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
||||
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
||||
}
|
||||
print '<tr class="liste_total">';
|
||||
print '<td> <b>'.$langs->trans("Total").'</b> </td>';
|
||||
print '<td align="right"><b>'.$SommeA.' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</b></td>';
|
||||
print '<td align="right"><b>'.$SommeB.' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</b></td>';
|
||||
print '<td align="right"><b>'.$SommeC.' '.$staticmember->LibStatut(1,$adhtype->cotisation,mktime(),3).'</b></td>';
|
||||
print '<td align="right"><b>'.$SommeC.' '.$staticmember->LibStatut(1,$adhtype->cotisation,gmmktime(),3).'</b></td>';
|
||||
print '<td align="right"><b>'.$SommeD.' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</b></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -229,7 +228,7 @@ else
|
||||
|
||||
|
||||
|
||||
// Tableau r<>sum<75> par an
|
||||
// List of subscription by year
|
||||
$Total=array();
|
||||
$Number=array();
|
||||
$tot=0;
|
||||
@ -261,7 +260,7 @@ if ($result)
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Year").'</td>';
|
||||
print '<td>'.$langs->trans("Subscriptions").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Number").'</td>';
|
||||
print '<td align="right">'.$langs->trans("AmountTotal").'</td>';
|
||||
print '<td align="right">'.$langs->trans("AmountAverage").'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user