Flash Sale for Premium Subscriptions

50% off annual premium licence subscription.

Get 50%off now

Formatting the membership directory

About Support Support Formatting the membership directory

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #5289

    I would like to be able to format the membership directory to change the page heading, increase the font size, and be able to prepare the document for booklet printing. I will be downloading the file and using “pdfbook” (part of the “pdfjam” package on Fedora Linux) to actually generate the booklet.

    So the output is readable after printing, I would like to increase the font to at least 15 pitch and increase the margins to .75 inch or a bit larger.

    Being new to the plugin (and it is an outstanding piece of work!), I hate to go in to modify the source code or database by hand without a bit of instruction.

    In “General Settings” I see the maximum number of entries on a directory page, and where the paper size is set, but there are no further settings I can see. The latest plugin manual does not go into detail. I could find no forum topics which address this question.

    Thank you.

    #5290

    Upon further investigation, it looks like the formatting may be done in the function “church_admin_formatted_household.” Are you using the html2pdf package to convert the membership directory to PDF?

    Would a custom CSS work for the formatting?

    Again, I am very new to this plugin. We began using it to automate our membership directory, though it looks like we will also use the plugin for attendance and birthday lists.

    My blue-sky wish list would be to generate a LaTeX file to format the directory, which would make it a snap to add the front and back matter the congregation desires. That is a bit specialized, however. The next best thing would be to be able to format the membership pages as desired and use various PDF manipulation tools to complete the membership directory.

    Yes, it would be beyond delightful if those who want a membership directory would access it via the smartphone app or via the website, but with an ageing congregation that doesn’t have a lot of people using computers, that is not an option. they want a hard copy.

    Thanks again.

    #5291
    Avatar for Pastor AndresPastor Andres
    Moderator

    Church Admin uses a FPDF script variant called tFPDF. Andy had to modify it some to bring it up to date but you will be able to find general documentation at fpdf.org and a little information on tFPDF at http://www.fpdf.org/en/script/script92.php

    CSS would be helpful for modifying the layout on screen but nothing more.

    Hope this helps.

    #5292

    Thank you.

    This looks like it will help.

    I don’t want to modify the basic source code for the plug-in, but I believe an extension might be in order.

    #5296
    Avatar for Andy MoyleAndy Moyle
    Keymaster

    There are few different versions of the PDF the shortcode can produce. You can use PDF=1 or PDF=2 – PDF=1 is the default and the only one being maintained. You can also modify the title with title=”My new title”

    The nice thing about PDF is that when opened they look the same on anything (unlike Word docs which drive me scatty!) So the tFPDF code is about precise positioning of everything (but you have to take account of differing line lengths etc). The functions to use it are detailed at fpdf.org
    In pdf_creator.php there is a function called church_admin_address_pdf_family_photos() which outputs the default PDF. Always happy to add in a new PDF directory style, so you can use that as a basis and then send me over the new function to add in properly.
    Unfortunately it’s not the cleanest code, but it will give you an idea of how to do it. (Will tidy it one day)
    I would create a data array and then cycle through to output which would make more reproducible coding. Live and learn – some of the plugin is 10 year old!!!

    I use tFPDF because it produces unicode PDF which is important for handle accents and diacritics.

    I will rename the address list pdf functions by PDF version number soon, to make things easier!!!

    #5302

    Greetings,

    So I will work on producing a new directory style using the code in pdf_creator.php as a guideline.

    Things I hope to accomplish:
    1. Increase the margins
    2. Not worry about a photo — we are not doing a photo directory, so that should speed things up.
    3. Differentiate between “Member,” “Non-member,” confirmed children, and baptized children.
    4. Put the street address on a separate line from city, state, and zip.
    5. Increase the font size for printing as a booklet — however we may decide to print in portrait so we still need a wider left margin.
    6. Change the title (although the call the the function seems to do that).

    Are there any other things which I should tackle?

    Thank you.

    #5334

    Hi,

    I am working on increasing the page margins to allow for binding the printed directory. The fpdf manual speaks of the “SetMargins” directive, which works except for the first line of a new page. I believe it may be a problem in fpdf.

    Have you run into this with other modules, and if so, what was the work-around?

    Thanks.

    #5367

    Rejoice with me. I have made the changes to the pdf_creator.php code to meet our formatting requests. Not knowing a better way of giving the changes, I have included them below this message (the complete 256 lines of source code, minus blank lines, to put the changes in context). Thank you, most kind people, for your help and encouragement. Open Source is great, and this is just an example of why it is so important.

    ==================================================================

    /**
    *
    * Address PDF
    *
    * @author Andy Moyle
    * @param $member_type_id
    * @return
    * @version 0.1
    *
    */
    function church_admin_address_pdf_v1($member_type_id=0,$loggedin=1,$showDOB=TRUE,$title=NULL)
    {
    if(defined(‘CA_DEBUG’))church_admin_debug(“*************\r\n PDF v1”);
    update_option(‘church_admin_pdf_title’,$title);
    if(!empty($loggedin)&&!is_user_logged_in())exit(__(‘You must be logged in to view the PDF’,’church-admin’));
    if(!empty($member_type_id)&&is_array($member_type_id))$member_type_id=implode(“,”,$member_type_id);
    //initilaise pdf
    require_once(plugin_dir_path(dirname(__FILE__)).’includes/fpdf.php’);
    class PDF extends FPDF
    {

    function Header()
    {
    $this->SetXY(10,10);
    $this->SetFont(‘DejaVu’,”,’B’,18);
    $title=get_option(‘church_admin_pdf_title’);
    if(empty($title))$title=get_option(‘blogname’).’ ‘.__(‘Family Listing’,’church-admin’).’ ‘.date(get_option(‘date_format’));
    $this->Cell(0,8,$title,0,1,’C’);
    $this->Ln(5);
    }
    function Footer() {
    $footerYLocation = $this->GetPageHeight() -10;
    $this->SetXY(10,$footerYLocation);
    $this->SetFont(‘DejaVu’,”,”,10);
    $footer=__(‘Page: ‘,’church-admin’).$this->PageNo();
    $this->Cell(0,5,$footer,0,1,’C’);
    }
    }
    $pdf = new PDF();
    // Add a Unicode font (uses UTF-8)
    $pdf->AddFont(‘DejaVu’,”,’DejaVuSans.ttf’,true);
    $pdf->AddFont(‘DejaVu’,’B’,’DejaVuSans-Bold.ttf’,true);

    //$pdf->SetAutoPageBreak(1,20);

    // added 1/28/2021 — jbw
    $pdf->SetMargins(25, 25);

    $pdf->AddPage(‘P’,get_option(‘church_admin_pdf_size’));

    global $wpdb;
    //address book cache
    $memb_sql=”;
    if($member_type_id!=0)
    {
    $memb=explode(‘,’,$member_type_id);
    foreach($memb AS $key=>$value){if(ctype_digit($value)) $membsql[]=’a.member_type_id=’.$value;}
    if(!empty($membsql)) {$memb_sql=’ AND (‘.implode(‘ || ‘,$membsql).’)’;}
    }
    // $sql=’SELECT DISTINCT a.household_id,a.*,b.privacy,b.attachment_id AS household_image FROM ‘.CA_PEO_TBL.’ a LEFT JOIN ‘.CA_HOU_TBL.’ b on a.household_id=b.household_id WHERE (b.privacy=0 OR b.privacy iS NULL) AND a.head_of_household=1 ‘.$memb_sql.’ ORDER BY a.last_name,a.first_name,a.middle_name ASC’;
    // added 1/28/2021 — jbw per Andy Moyes
    $sql=’SELECT DISTINCT a.household_id,a.*,b.privacy,b.attachment_id AS household_image FROM ‘.CA_PEO_TBL.’ a LEFT JOIN ‘.CA_HOU_TBL.’ b on a.household_id=b.household_id WHERE (b.privacy=0 OR b.privacy iS NULL) AND a.head_of_household=1 ‘.$memb_sql.’ ORDER BY a.last_name,a.first_name,a.middle_name ASC’;
    if(defined(‘CA_DEBUG’))church_admin_debug($sql);
    if(defined(‘CA_DEBUG’))church_admin_debug($sql);
    $results=$wpdb->get_results($sql);
    church_admin_debug($sql);
    $counter=1;
    $addresses=array();
    $x=0;
    $y=25;
    $pageWidth=$pdf->GetPageWidth();
    $imageTopLeft=$pageWidth-75;//50mm wide and 10mm margin from edge and 5mm from box edge
    foreach($results AS $ordered_row)
    {
    $currentY=$pdf->GetY();
    $outputlines = 0;
    $address=$wpdb->get_row(‘SELECT * FROM ‘.CA_HOU_TBL.’ WHERE household_id=”‘.esc_sql($ordered_row->household_id).'”‘);
    $people_results=$wpdb->get_results(‘SELECT * FROM ‘.CA_PEO_TBL.’ WHERE household_id=”‘.esc_sql($ordered_row->household_id).'” ORDER BY people_type_id ASC,sex DESC’);
    $adults=$children=$emails=$mobiles=$photos=$date_of_birth=array();
    $last_name=”;
    $imageHeight=0;
    $imagePath=NULL;
    if(!empty($ordered_row->household_image))
    {
    $image=church_admin_scaled_image_path($ordered_row->household_image,’medium’) ;
    $imagePath=$image[‘path’];
    $imageHeight=$image[‘height’];
    $imageWidth=$image[‘width’];
    }
    if(($currentY+40)>=($pdf->GetPageHeight()-20))
    {

    // added 1/28/2021 — jbw
    $pdf->SetMargins(25, 25);

    $pdf->AddPage(‘P’,get_option(‘church_admin_pdf_size’));
    // changed 2/5/2021 — jbw
    $pdf->SetXY(25,20);
    // $pdf->SetXY(10,20);
    $x=10;
    $currentY=20;
    }
    //output image on right hand side
    $imageY=$currentY;
    if(!empty($imagePath))
    {
    $height=60*($imageHeight/$imageWidth);
    $pdf->Image($imagePath,$imageTopLeft,$pdf->getY(),60,$height);
    $imageY+=$height;
    }
    foreach($people_results AS $people)
    {
    if($people->people_type_id==’1′)
    {
    if(!empty($people->prefix)){
    $prefix=$people->prefix.’ ‘;
    }else{
    $prefix=”;
    }
    $last_name=$prefix.$people->last_name;
    $adults[$last_name][]=$people->first_name;
    if(!empty($people->email)&&$people->email!=end($emails)) $emails[$people->first_name]=$people->email;
    if(!empty($people->mobile)&&$people->mobile!=end($mobiles))$mobiles[$people->first_name]=$people->mobile;
    if(!empty($people->date_of_birth)&&$people->date_of_birth!=end($date_of_birth) && $people->date_of_birth != ‘0000-00-00’)
    $date_of_birth[$people->first_name]=mysql2date(get_option(‘date_format’),$people->date_of_birth);
    if(!empty($people->attachment_id))$photos[$people->first_name]=$people->attachment_id;
    $x++;
    }
    else
    {
    $children[]=$people->first_name;
    if(!empty($people->attachment_id))$photos[$people->first_name]=$people->attachment_id;
    }

    }
    //create output
    array_filter($adults);$adultline=array();
    // changed 2-5-2021 — jbw
    // foreach($adults as $lastname=>$firstnames){$adultline[]=implode(” & “,$firstnames).’ ‘.$lastname;}
    foreach($adults as $lastname=>$firstnames){$adultline[]=”$lastname, “.implode(” & “,$firstnames);}
    //address name of adults in household

    $pdf->SetFont(‘DejaVu’,’B’,10);
    $pdf->Cell(0,5,implode(” & “,$adultline),0,1,’L’);
    $pdf->SetFont(‘DejaVu’,”,10);
    $outputlines += 1;
    //children
    if(!empty($children)){

    $pdf->Cell(0,5,implode(“, “,$children),0,1,’L’);
    $outputlines += 1;
    }
    //address if stored
    if(!empty($address->address)){

    $pdf->Cell(0,5,$address->address,0,1,’L’);
    $outputlines += 1;
    }
    if(!empty($address->mailing_address)){

    $pdf->Cell(0,5,__(‘Mailing address: ‘,’church-admin’).$address->mailing_address,0,1,’L’);
    $outputlines += 1;
    }
    //emails
    if (!empty($emails))
    {
    array_unique($emails);
    if(count($emails)<2 && $x<=1)
    {

    $pdf->Cell(0,5,end($emails),0,1,’L’,FALSE,’mailto:’.end($emails));
    $outputlines += 1;
    }
    else
    {//more than one email in household
    $text=array();
    foreach($emails AS $name=>$email)
    {
    $content=$name.’: ‘.$email;
    if($email!=end($emails))
    $width=$pdf->GetStringWidth($content);

    $pdf->Cell(0,5,$content,0,1,’L’,FALSE,’mailto:’.$email);
    $outputlines += 1;
    }

    }
    }
    if (!empty($address->phone)) {

    $pdf->Cell(0,5,$address->phone,0,1,’L’,FALSE,’tel:’.$address->phone);
    $outputlines += 1;
    }
    if (!empty($mobiles)) {
    array_unique($mobiles);

    if(count($mobiles)<2 && $x<=1) {
    $pdf->Cell(0,5,end($mobiles),0,0,’L’,FALSE,’tel:’.end($mobiles));
    $outputlines += 1;
    }
    else {//more than one mobile in household
    $text=array();
    foreach($mobiles AS $name=>$mobile) {
    $content=$name.’: ‘.$mobile;
    if($mobile!=end($mobiles))$content.=’, ‘;
    $width=$pdf->GetStringWidth($content);
    $pdf->Cell($width,5,$content,0,0,’L’,FALSE,’tel:’.$mobile);
    //$outputlines += 1;
    }

    }
    $pdf->Ln(5);
    $outputlines += 1;
    }
    //dates of birth
    if (!empty($date_of_birth)&&!empty($showDOB))
    {
    array_unique($date_of_birth);
    if(count($date_of_birth)<2 && $x<=1)
    {

    $pdf->Cell(0,5,__(‘Date of birth’,’church-admin’).’ ‘.end($date_of_birth),0,1,’L’,FALSE,”);
    $outputlines += 1;
    }
    else
    {//more than one email in household
    $text=array();
    foreach($date_of_birth AS $name=>$dob)
    {
    $content=sprintf(__(‘Date of birth for %1$s: %2$s’,’church-admin’),$name,$dob);
    if($dob!=end($date_of_birth))
    $width=$pdf->GetStringWidth($content);

    $pdf->Cell(0,5,$content,0,1,’L’,FALSE,”);
    $outputlines += 1;
    }

    }
    }
    $newY=$pdf->GetY()+5;
    if($imageY>$newY)$newY=$imageY+5;
    $pdf->SetY($newY);

    }

    $pdf->Output();

    exit();
    }

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.