latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Looking for help with coding

Home Forums Community Forum Unofficial Extensions/Hacks Looking for help with coding

This topic contains 1 reply, has 1 voice. Last updated by  Sean Hodgson 4 years, 6 months ago.

Topic Author Topic
Posted: Tuesday Jul 3rd, 2012 at 11:36 pm #18236

I want to print membership cards and envelopes from my s2member list. I just took over as webmaster of my local radio control flying club. The last webmaster was using Joomla. I’m switching everything to WP. There is a php file for printing the cards, but it is written for Joomla specifically the community builder extension. I’d either like some help in recoding the file for s2member, or if someone has another idea on printing the cards I’d welcome it. Here is the code for the file:

<?php

/**
* This is an php page for membership card creation
* @author Per Hquery();
$db->setQuery($query);
$RowsFromMembers = $db->loadRowList();


//Find out who is the Treasurer
$dbT =& JFactory::getDBO(); 
$queryT = "SELECT * FROM #__comprofiler WHERE cb_appointments like '%Treasurer%';";
$dbT->setQuery($queryT);
$RowsFromUsersT = $dbT->loadRow();






//Fish out the positioning and color data we want to use from the parameter table
$dbP =& JFactory::getDBO(); 
$queryP = "SELECT * FROM #__member_renewals WHERE id = 1;";
$dbP->setQuery($queryP);
$RowsFromUsersP = $dbP->loadRow();

$cardposx = $RowsFromUsersP[4];
$cardposy = $RowsFromUsersP[5];
$envlposx = $RowsFromUsersP[6];
$envlposy = $RowsFromUsersP[7];
$red = $RowsFromUsersP[8];
$green = $RowsFromUsersP[9];
$blue = $RowsFromUsersP[10];


$spinn1 = 0;
$HowMany =count($RowsFromMembers);

require('FPDF/fpdf.php');  
// Construct the PDF pages
$mcard=new FPDF('L','mm','Letter');
$mcard->SetMargins(0,10,2);
$mstat=new FPDF('P','mm','Letter');
$mstat->SetMargins(2,2,2);
$envelope=new FPDF('L', 'mm', array(105,243));
$envelope->SetMargins(2,2,2);


while ($spinn1 AddPage();
$envelope->AddPage();
// Find out the user parameters from the query
$UserIDno = $RowsFromMembers[$spinn1]['1'];
$LocExpire = strtotime($RowsFromMembers[$spinn1]['28']);
$spinn1Year = Date(Y,$LocExpire);
$spinn1Level = $RowsFromMembers[$spinn1]['26'];
$FirstName = $RowsFromMembers[$spinn1]['2'];
$LastName = $RowsFromMembers[$spinn1]['4'];
$FullName = $RowsFromMembers[$spinn1]['2'].' '.$RowsFromMembers[$spinn1]['4'];
$Street = $RowsFromMembers[$spinn1]['36']."n".$RowsFromMembers[$spinn1]['37'].", ".$RowsFromMembers[$spinn1]['38']." ".$RowsFromMembers[$spinn1]['39'];
if ($RowsFromMembers[$spinn1]['40'] != "USA"){
  $Street = $Street."n".$RowsFromMembers[$spinn1]['40'];
}
$AMA = $RowsFromMembers[$spinn1]['22'];
$AltEmail = $RowsFromMembers[$spinn1]['32'];
$LocQual = $RowsFromMembers[$spinn1]['43'];
$LocBirth = Date('M/d/Y',strtotime($RowsFromMembers[$spinn1]['41']));
$LocJoin = Date('M/d/Y',strtotime($RowsFromMembers[$spinn1]['27']));
$HomePhone = $RowsFromMembers[$spinn1]['33'];
$MobilePhone = $RowsFromMembers[$spinn1]['34'];
$WorkPhone = $RowsFromMembers[$spinn1]['35'];

//Fish out the email address of the member which is not kept in CB, but in the regular users table.
$dbU =& JFactory::getDBO();
$queryU = "SELECT email FROM #__users WHERE id = ".$UserIDno;
$dbU->setQuery($queryU);
$dbU->query();
$LocEmail = $dbU->loadResult();

// Set up the font to Times bold 20 black
$mcard->SetFont('Times','B',20);
$mcard->SetTextColor(0,0,0);

// Set the staring point X Y
$mcard->SetXY(7,7);

// Begin writing to the page
// This is the header
$mcard->MultiCell(160,8,'Prince William County Radio Control Flyers, Inc. Membership Card and Receipt',0,'C');
$mcard->Image('membership/images/PWCRCF Logo.jpg',10,35,35,46.9);


// Set the font to Times normal 11
$mcard->SetFont('Times','',11);

// Change the start point for text again
$mcard->SetXY(50,35);

// Print the main text anf place the correct year.
$mcard->MultiCell(115,5.5,'Thank you for your continued membership in Prince William County Radio Control Flyers, Inc. (PWCRCF) club for year '.$spinn1Year.'. Attached is your new membership card, please make sure you bring it every time you are flying at the field. Everyone need to use a frequency pin at all times, even for the 2.4Ghz radios to ensure everyone flying are displaying their membership card.',0,L,false);

if ($LocQual == "Restricted"){
$mcard->SetFont('Times','B',11);
$mcard->SetXY(50,70);
$mcard->MultiCell(115,5.5,'Your pilot qualification level prohibits you from flying without an instructor. For liability reasons you must refrain from flying unaccompanied. Please seek out an instructor to help you gain "Unrestricted" qualification to lift this limitation.',0,L,false);
}


//Build the reference data portion
$mcard->SetTextColor(92,131,180);
$mcard->SetFont('Arial','',9);

$mcard->SetXY(10,100);
$mcard->Cell(30,5,'Name:',0,1,R,false);

$mcard->SetXY(100,100);
$mcard->Cell(30,5,'AMA Number:',0,1,R,false);

$mcard->SetXY(10,107);
$mcard->Cell(30,5,'Address:',0,1,R,false);

$mcard->SetXY(100,107);
$mcard->Cell(30,5,'Pilot Qualification:',0,1,R,false);

$mcard->SetXY(100,114);
$mcard->Cell(30,5,'Birth Date:',0,1,R,false);

$mcard->SetXY(10,121);
$mcard->Cell(30,5,'eMail:',0,1,R,false);

$mcard->SetXY(100,121);
$mcard->Cell(30,5,'Joined Date:',0,1,R,false);

$mcard->SetXY(10,128);
$mcard->Cell(30,5,'Alt eMail:',0,1,R,false);

$mcard->SetXY(100,128);
$mcard->Cell(30,5,'Home Phone:',0,1,R,false);

$mcard->SetXY(100,135);
$mcard->Cell(30,5,'Mobile Phone:',0,1,R,false);

$mcard->SetXY(100,142);
$mcard->Cell(30,5,'Work Phone:',0,1,R,false);

$mcard->SetXY(41,100);
$mcard->SetTextColor(0);
$mcard->SetFont('Times','',11);
$mcard->MultiCell(58,5,$FullName,0,L,false);
$mcard->SetXY(41,107);
$mcard->MultiCell(58,4.5,$Street,0,L,false);
$mcard->SetXY(41,121);
$mcard->MultiCell(58,5,$LocEmail,0,L,false);
$mcard->SetXY(41,128);
$mcard->MultiCell(58,5,$AltEmail,0,L,false);

$mcard->SetXY(131,100);
$mcard->MultiCell(30,5,$AMA,0,L,false);
$mcard->SetXY(131,107);
$mcard->MultiCell(30,5,$LocQual,0,L,false);
$mcard->SetXY(131,114);
$mcard->MultiCell(30,5,$LocBirth,0,L,false);
$mcard->SetXY(131,121);
$mcard->MultiCell(30,5,$LocJoin,0,L,false);
$mcard->SetXY(131,128);
$mcard->MultiCell(30,5,$HomePhone,0,L,false);
$mcard->SetXY(131,135);
$mcard->MultiCell(30,5,$MobilePhone,0,L,false);
$mcard->SetXY(131,142);
$mcard->MultiCell(30,5,$WorkPhone,0,L,false);


// Paint the actual Membership Card area
// Set the base position
//$cardposx = 146;
//$cardposy = 44;
// Build the area
$mcard->SetFont('Arial','B',22);
// Use this rectangle to see the main placement if required
//$mcard->Rect($cardposx + 60,$cardposy + 18,60,92,D);
$mcard->Image('membership/images/PWCRCF Logo 20 percent watermark.jpg',$cardposx + 65,$cardposy + 30,50,67);
$mcard->Image('membership/images/AMA.jpg',$cardposx + 99,$cardposy + 97,17.3,10);

$mcard->SetXY($cardposx + 60,$cardposy + 22);
$mcard->MultiCell(60,10,"PWCRCF",0,C,false);

$mcard->SetXY($cardposx + 60,$cardposy + 34);
$mcard->SetFont('Arial','B',26);
$mcard->MultiCell(60,10,$FirstName,0,C,false);
$mcard->SetXY($cardposx + 60,$cardposy + 44);
$mcard->MultiCell(60,10,$LastName,0,C,false);
$mcard->SetXY($cardposx + 60,$cardposy + 52);
$mcard->SetFont('Arial','B',10);
$mcard->MultiCell(60,10,"Member in Good Standing At",0,C,false);
$mcard->SetXY($cardposx + 60,$cardposy + 98);
$mcard->SetFont('Arial','B',12);
$mcard->MultiCell(38,10,"AMA # ".$AMA,0,C,false);
$mcard->SetXY($cardposx + 60,$cardposy + 62);
//(2010 was red) $mcard->SetTextColor(237,28,36);
$mcard->SetTextColor($red,$green,$blue);
$mcard->SetFont('Arial','B',30);
if ($spinn1Level == "Honorary"){
$mcard->MultiCell(60,10,$spinn1Level,0,C,false);
}
else
{
$mcard->MultiCell(60,10,$spinn1Level." ".$spinn1Year,0,C,false);
}
$mcard->SetXY($cardposx + 58,$cardposy + 85);
$mcard->SetFont('Arial','B',10);
$mcard->SetTextColor(0,0,0);
if ($LocQual == "Restricted"){
$mcard->SetFillColor(255,0,0);
$mcard->MultiCell(64,10,$LocQual." Membership Level",0,C,true);
}
if ($LocQual == "Unrestricted"){
$mcard->MultiCell(64,10,$LocQual." Membership Level",0,C,false);
}
if ($LocQual == "Instructor"){
$mcard->SetFillColor(0,255,0);
$mcard->MultiCell(64,10,$LocQual." Membership Level",0,C,true);
}
$mcard->SetXY($cardposx + 50,$cardposy - 20);
//(2010 was red) $mcard->SetTextColor(237,28,36);
$mcard->SetTextColor($red,$green,$blue);
$mcard->SetFont('Arial','B',26);
$mcard->MultiCell(80,10,"Always fly within your abilities!!!",0,C,false);


//Build the footer text and place the signature
$mcard->Image('membership/images/Treasurer.jpg',10,148,60,20);
$mcard->SetTextColor(92,131,180);
$mcard->SetFont('Arial','',9);
$mcard->SetXY(10,168);
$FullNameT = $RowsFromUsersT['2'].' '.$RowsFromUsersT['4'];
$StreetT = $RowsFromUsersT['36']."n".$RowsFromUsersT['37'].", ".$RowsFromUsersT['38']." ".$RowsFromUsersT['39'];
if ($RowsFromUsersT['40'] != "USA"){
  $StreetT = $StreetT."n".$RowsFromUsersT['40'];
}
$mcard->MultiCell(100,4.5,$FullNameT.", Treasurer PWCRCF, Inc.n".$StreetT."n"."treasurer@pwcrcf.org",0,L,false);

// Print the envelope info
// print the return info
//$envlposx = 25;
//$envlposy = 0;
// Draw the envelope
$envelope->SetTextColor(0,0,0);
$envelope->SetFont('Arial','',7);
$envelope->Image('membership/images/PWCRCF Logo.jpg',$envlposx + 0,$envlposy + 5,20,26.8);
$envelope->SetXY($envlposx + 23, $envlposy + 5);
$envelope->MultiCell(100,3,"PWCRCF, Inc.nOffice of the Treasurern".$StreetT,0,L,false);
// Print the envelope address
$envelope->SetXY($envlposx + 120,$envlposy + 60);
$envelope->SetFont('Arial','B',14);
$envelope->MultiCell(100,6,$FullName."n".$Street,0,L,false);

// Increment the counter
$spinn1++;
}




// Club status
$mstat->AddPage();
$mstat->Image('membership/images/PWCRCF Logo.jpg',10,10,35,46.9);
$mstat->SetTextColor(0,0,0);
$mstat->SetFont('Arial','B',24);
$mstat->SetXY(60,20);
$nowdate = date("j F, Y");
$mstat->MultiCell(100,10,"PWCRCF Membership Status Snapshotn".$nowdate,0,C,false);
//Fish out all the CB data about memberstatus
$dbS =& JFactory::getDBO();
// Don't bring in members in history or Murray Groundhog or Test Man in the report
$queryS = "SELECT cb_membertype,cb_expirationdate,COUNT(cb_membertype) FROM #__comprofiler WHERE cb_membertype != 'History' and user_id != 147 and user_id !=69 GROUP BY cb_membertype,cb_expirationdate";
$dbS->query();
$dbS->setQuery($queryS);
$StatRows = $dbS->loadRowList();
$HowMany2 = count($StatRows);
$coltype = "Typen----------";
$colyear = "Yearn----------";
$colnumber = "Totaln----------";
$gtotal = 0;
$spinn2 = 0;
while ($spinn2 Line(60, 80, 180, 80);
$mstat->SetTextColor(0,0,0);
$mstat->SetFont('Arial','B',18);
$mstat->SetXY(60,90);
$mstat->MultiCell(100,8,$coltype,0,L,false);
$mstat->SetXY(100,90);
$mstat->MultiCell(100,8,$colyear,0,L,false);
$mstat->SetXY(130,90);
$mstat->MultiCell(30,8,$colnumber,0,R,false);




// Enforce security and check the active user is the treasurer
// Check authority
$user =& JFactory::getUser();
if ($user->id != $RowsFromUsersT['0']) {
	print "<br><br>Sorry, must be the treasurer to run membership processing!";
} else {	
	// Place the PDF's in the temp dir
	$mcard-&gt;Output('tmp/'.$user-&gt;username.'MCARD.pdf','F');
	$envelope-&gt;Output('tmp/'.$user-&gt;username.'ENV.pdf','F');
	$mstat-&gt;Output('tmp/'.$user-&gt;username.'MSTAT.pdf','F');
	if ($HowMany == 0){
		print "<br><br>No membership card data required to print...";
	} else {
		print "<br><br><a>username."MCARD.pdf' target='_blank'&gt;MemberCard (".$HowMany.")</a>";
		print "<br><br><a>username."ENV.pdf' target='_blank'&gt;Envelope (".$HowMany.")</a>";
	}
	print "<br><br><a>username."MSTAT.pdf' target='_blank'&gt;Member Status Snap (".$gtotal.")</a>";
}



?&gt;

This is the second file, of two, for this process:

setQuery($queryT);
$RowsFromUsersT = $dbT-&gt;loadRow();



// Enforce security and check the active user is the treasurer
// Check authority
$user =&amp; JFactory::getUser();
if ($user-&gt;id != $RowsFromUsersT['0']) {
	print "<br><br>Sorry, must be the treasurer to run membership processing!";
} else {	
	//Update all the CB data about unprinted members to printed.
	$db =&amp; JFactory::getDBO();
	$query = "update #__comprofiler set cb_cardissued=1 WHERE cb_cardissued = 0";
	$db-&gt;setQuery($query);
	$db-&gt;query();
	print "<br><br>Cleared all rows.";
}


?&gt;

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Wednesday Jul 4th, 2012 at 10:49 pm #18325

I just found the export feature, I’ll play around with that and MS Office.

Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.