00001 <?php
00002
00003
00004
00005
00006
00007
00008 require_once ( dirname ( __FILE__ ).'/../pdf_generator/printableList.class.php' );
00009 require_once ( dirname ( __FILE__ ).'/pdf_decls.php' );
00010
00011
00012
00013
00014
00015 class sasna_napdf extends printableList implements IPrintableList
00016 {
00017 var $weekday_names = array ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" );
00018 var $pos = array ( 'start' => 1, 'end' => '', 'count' => 0, 'y' => 0, 'weekday' => 1 );
00019 var $right_offset = 0;
00020 var $formats = 0;
00021
00022
00023
00024
00025
00026
00027
00028 function __construct ( $in_http_vars
00029 )
00030 {
00031 $this->page_x = 11;
00032 $this->page_y = 17;
00033 $this->units = 'in';
00034 $this->font = 'Helvetica';
00035 $this->font_size = 12;
00036 $this->orientation = 'L';
00037
00038 $this->sort_keys = array ( 'weekday_tinyint' => true,
00039 'location_municipality' => true,
00040 'start_time' => true,
00041 'week_starts' => 2
00042 );
00043
00044 $this->out_http_vars = array ('do_search' => 'yes',
00045 'bmlt_search_type' => 'advanced',
00046 'advanced_service_bodies' => array (
00047 1001,
00048 1002,
00049 1003,
00050 1004
00051 )
00052 );
00053
00054 parent::__construct ( $in_http_vars );
00055 }
00056
00057
00058
00059
00060
00061
00062 function AssemblePDF ()
00063 {
00064 $ret = false;
00065
00066 if ( $this->napdf_instance instanceof napdf )
00067 {
00068 $page_margins = 0.35;
00069
00070 $meeting_data =& $this->napdf_instance->meeting_data;
00071
00072 if ( $meeting_data )
00073 {
00074
00075
00076
00077 $panelpage['margin'] = $page_margins;
00078 $panelpage['height'] = $this->napdf_instance->h - ($panelpage['margin'] * 2);
00079 $panelpage['width'] = ($this->napdf_instance->w / 4) - ($panelpage['margin'] * 2);
00080
00081
00082 $listpage['margin'] = $page_margins;
00083 $listpage['height'] = $this->napdf_instance->h - ($listpage['margin'] * 2);
00084 $listpage['width'] = ($this->napdf_instance->w / 2) - ($listpage['margin'] * 2);
00085
00086
00087
00088
00089 $frontpanel_x_offset = $panelpage['width'] + ($panelpage['margin'] * 3);
00090 $frontpanel_max_x_offset = $frontpanel_x_offset + $panelpage['width'];
00091 $frontpanel_y_offset = $panelpage['margin'];
00092 $frontpanel_max_y_offset = $frontpanel_y_offset + $panelpage['height'];
00093
00094
00095 $backpanel_x_offset = $panelpage['margin'];
00096 $backpanel_max_x_offset = $backpanel_x_offset + $panelpage['width'];
00097 $backpanel_y_offset = $panelpage['margin'];
00098 $backpanel_max_y_offset = $backpanel_y_offset + $panelpage['height'];
00099
00100
00101 $vertical_separator_x = ($this->napdf_instance->w / 2);
00102 $vertical_separator_y = $page_margins;
00103 $vertical_separator_y_2 = $this->napdf_instance->h - $page_margins;
00104
00105
00106 $frontlist_x_offset = $frontpanel_max_x_offset + $panelpage['margin'] + $listpage['margin'];
00107 $frontlist_max_x_offset = $frontlist_x_offset + $listpage['width'];
00108 $frontlist_y_offset = $listpage['margin'];
00109 $frontlist_max_y_offset = $frontlist_y_offset + $listpage['height'];
00110
00111
00112 $backlist_page_1_x_offset = $listpage['margin'];
00113 $backlist_page_1_max_x_offset = $backlist_page_1_x_offset + $listpage['width'];
00114 $backlist_page_1_y_offset = $listpage['margin'];
00115 $backlist_page_1_max_y_offset = $backlist_page_1_y_offset + $listpage['height'];
00116
00117 $backlist_page_2_x_offset = $backlist_page_1_max_x_offset + ($listpage['margin'] * 2);
00118 $backlist_page_2_max_x_offset = $backlist_page_2_x_offset + $listpage['width'];
00119 $backlist_page_2_y_offset = $listpage['margin'];
00120 $backlist_page_2_max_y_offset = $backlist_page_2_y_offset + $listpage['height'];
00121
00122 global $columns, $maxwidth, $fSize, $y;
00123 $maxwidth = $listpage['width'] + 1;
00124 $columns = "";
00125 $fSize = $this->napdf_instance->FontSizePt;
00126
00127 foreach ( $meeting_data as &$meeting )
00128 {
00129 $meeting['location'] = $meeting['location_text'].', '.$meeting['location_street'];
00130 }
00131
00132 $this->napdf_instance->AddPage ( );
00133
00134 $pos = $this->DrawListPanel ( $backlist_page_1_x_offset, $backlist_page_1_y_offset, $backlist_page_1_max_x_offset, $backlist_page_1_max_y_offset, $meeting_data );
00135
00136 $this->napdf_instance->Line ( $vertical_separator_x, $vertical_separator_y, $vertical_separator_x, $vertical_separator_y_2 );
00137
00138 $pos = $this->DrawListPanel ( $backlist_page_2_x_offset, $backlist_page_2_y_offset, $backlist_page_2_max_x_offset, $backlist_page_2_max_y_offset, $meeting_data, $pos['day'], $pos['count'] );
00139
00140 $this->napdf_instance->AddPage ( );
00141 $this->DrawRearPanel ( $backpanel_x_offset, $backpanel_y_offset, $backpanel_max_x_offset, $backpanel_max_y_offset, $this->napdf_instance->format_data );
00142
00143 $inPrinter_Date = date ( '\U\p\d\a\t\e\d F jS, Y' );
00144
00145 $this->DrawFrontPanel ( $frontpanel_x_offset, $frontpanel_y_offset, $frontpanel_max_x_offset, $frontpanel_max_y_offset, $inPrinter_Date );
00146
00147 $this->napdf_instance->Line ( $vertical_separator_x, $vertical_separator_y, $vertical_separator_x, $vertical_separator_y_2 );
00148
00149 if ( $pos )
00150 {
00151 $this->DrawListPanel ( $frontlist_x_offset, $frontlist_y_offset, $frontlist_max_x_offset, $frontlist_max_y_offset, $meeting_data, $pos['day'], $pos['count'] );
00152 }
00153 else
00154 {
00155 $y = $frontlist_y_offset;
00156 }
00157
00158 $this->DrawLastPageTrailer ( $frontlist_x_offset, $y, $frontlist_max_x_offset, $frontlist_max_y_offset );
00159 }
00160 $ret = true;
00161 }
00162
00163 return $ret;
00164 }
00165
00166
00167
00168 function OutputPDF ()
00169 {
00170 $d = date ( "Y_m_d" );
00171 $this->napdf_instance->Output( "SASNA_PrintableList_$d.pdf", "D" );
00172 }
00173
00174
00175
00176
00177
00178 private function DrawLastPageTrailer ( $left, $top, $right, $bottom )
00179 {
00180 $y = $top + 0.125;
00181 $fontFamily = $this->napdf_instance->FontFamily;
00182 $fontSize = $this->napdf_instance->FontSizePt;
00183
00184 $s_array = array();
00185 $na_dom = new DOMDocument;
00186 if ( $na_dom )
00187 {
00188 if ( @$na_dom->loadHTML($this->call_curl ( "http://sasna.org/?page_id=421" )) )
00189 {
00190 $div_contents = $na_dom->getElementByID ( "meeting_times" );
00191
00192 if ( $div_contents )
00193 {
00194 $p_list = $div_contents->getElementsByTagName ( "p" );
00195 if ( $p_list && $p_list->length )
00196 {
00197 for ( $i = 0; $i < $p_list->length; $i++ )
00198 {
00199 $the_item = $p_list->item($i);
00200 if ( $the_item )
00201 {
00202 if ( "first" == $the_item->getAttribute ( "class" ) )
00203 {
00204 $p_list2 = $the_item->getElementsByTagName ( "b" );
00205 $a['_name'] = $p_list2->item(0)->nodeValue;
00206 $a['_description'] = '';
00207
00208 while ( $p_list->item($i + 1) && ("first" != $p_list->item($i + 1)->getAttribute ( "class" )) )
00209 {
00210 if ( $a['_description'] )
00211 {
00212 $a['_description'] .= "\n";
00213 }
00214 $a['_description'] .= $p_list->item(++$i)->nodeValue;
00215 }
00216 }
00217
00218 array_push ( $s_array, $a );
00219 }
00220 }
00221 }
00222 }
00223 }
00224 }
00225
00226 $this->napdf_instance->Line ( $left, $y, $right, $y );
00227 $this->napdf_instance->SetXY ( $left, $y );
00228 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 3) );
00229 $this->napdf_instance->SetLeftMargin ( $left );
00230
00231 $y = $this->napdf_instance->GetY ( );
00232
00233 $y += 0.125;
00234
00235 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 3) );
00236 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_SUBCOMMITTEES );
00237
00238 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00239
00240 $this->napdf_instance->SetXY ( $cellleft, $y );
00241
00242 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_SUBCOMMITTEES );
00243
00244 $y += 0.25;
00245
00246 if ( is_array ( $s_array ) && count ( $s_array ) )
00247 {
00248 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 4) );
00249
00250 $count = 0;
00251 $offset = 0;
00252 foreach ( $s_array as $row )
00253 {
00254 $offset = max ( $offset, ($this->napdf_instance->GetStringWidth ( $row['_name'] ) + 0.1) );
00255 $sub_table[$count++] = $row;
00256 }
00257
00258 for ( $c = 0; $c < $count; $c++ )
00259 {
00260 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 4) );
00261 $this->napdf_instance->SetLeftMargin ( $left );
00262 $this->napdf_instance->SetXY ( $left, $y );
00263 $this->napdf_instance->MultiCell ( $offset, ($fontSize - 4) / 72, $sub_table[$c]['_name'] );
00264 $this->napdf_instance->SetFont ( $fontFamily, '', ($fontSize - 4) );
00265 $this->napdf_instance->SetLeftMargin ( $left + $offset );
00266 $this->napdf_instance->SetXY ( $left + $offset, $y );
00267 $this->napdf_instance->MultiCell ( ($right - ($left + $offset)), ($fontSize - 4) / 72, $sub_table[$c]['_description'] );
00268 $y = $this->napdf_instance->GetY ( ) + 0.1;
00269 }
00270 }
00271 }
00272
00273
00274
00275 private function DrawListPanel ( $left, $top, $right, $bottom, $meetings, $day = -1, $count = 0 )
00276 {
00277 $meetings_days = self::break_meetings_by_day ( $meetings );
00278 global $columns, $maxwidth, $fSize, $y;
00279
00280 $pos['day'] = $day;
00281 $pos['count'] = $count;
00282
00283 $y = $top + 0.125;
00284
00285 $last_line = 0;
00286 $daygap = 0.2;
00287 $sep = 0.05;
00288
00289 if ( $day == -1 )
00290 {
00291 $fSize = $this->font_size + 2;
00292
00293 $columns['day'] = 0;
00294 $columns['town'] = 0;
00295 $columns['name'] = 0;
00296 $columns['location'] = 0;
00297 $columns['time'] = 0;
00298 $columns['format'] = 0;
00299
00300 while ( ($maxwidth > ($right - $left)) && ($fSize > 0) )
00301 {
00302 $fSize -= 0.1;
00303 $this->napdf_instance->SetFont ( $this->font, 'B', $fSize );
00304
00305 $columns['day'] = $daygap;
00306 $columns['town'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_TOWN ) + $sep;
00307 $columns['name'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_NAME ) + $sep;
00308 $columns['location'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_LOCATION ) + $sep;
00309 $columns['time'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_TIME ) + $sep;
00310 $columns['format'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_FORMAT );
00311
00312 $this->napdf_instance->SetFont ( $this->font, '', $fSize );
00313
00314 foreach ( $meetings as $meeting )
00315 {
00316 $columns['town'] = max ( $columns['town'], ($this->napdf_instance->GetStringWidth ( $meeting['location_municipality'] ) + $sep) );
00317 $columns['name'] = max ( $columns['name'], ($this->napdf_instance->GetStringWidth ( $meeting['meeting_name'] ) + $sep) );
00318 $columns['location'] = max ( $columns['location'], ($this->napdf_instance->GetStringWidth ( $meeting['location'] ) + $sep) );
00319 $columns['time'] = max ( $columns['time'], ($this->napdf_instance->GetStringWidth ( $this->translate_time ( $meeting['start_time'] ) ) + $sep) );
00320 $columns['format'] = max ( $columns['format'], $this->napdf_instance->GetStringWidth ( $this->RearrangeFormats ( $meeting['formats'] ) ) );
00321 }
00322
00323 $line_height = $fSize / 72;
00324 $duration_width = $line_height;
00325 $duration_gap = $duration_width / 8;
00326 $columns['duration'] = ($duration_width * 2) + ($duration_gap * 2);
00327
00328 $maxwidth = ($columns['day'] + $columns['town'] + $columns['name'] + $columns['location'] + $columns['time'] + $columns['duration'] + $columns['format']);
00329 }
00330 }
00331
00332 $line_height = $fSize / 72;
00333 $duration_width = $line_height;
00334 $duration_gap = $duration_width / 8;
00335 $columns['duration'] = ($duration_width * 2) + ($duration_gap * 2);
00336
00337 $this->napdf_instance->SetFont ( $this->font, 'B', $fSize );
00338 $x = $left + $daygap;
00339
00340 $this->napdf_instance->SetXY ( $x, $y );
00341 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_TOWN );
00342
00343 $x += ($columns['town']);
00344 $this->napdf_instance->SetX ( $x );
00345 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_NAME );
00346 $x += ($columns['name']);
00347 $this->napdf_instance->SetX ( $x );
00348 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_LOCATION );
00349 $x += ($columns['location']);
00350 $this->napdf_instance->SetX ( $x );
00351 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_TIME );
00352 $x += ($columns['time']+$columns['duration']);
00353 $this->napdf_instance->SetX ( $x );
00354 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_FORMAT );
00355
00356 $this->napdf_instance->SetFont ( $this->font, '', $fSize );
00357 $y += $line_height;
00358
00359 if ( $pos['day'] == -1 )
00360 {
00361 $pos['day'] = 1;
00362 }
00363
00364 for ( ; $pos['day'] < 7; $pos['day']++ )
00365 {
00366 $grayLine = 0;
00367 $day_name = $this->weekday_names[$pos['day']];
00368
00369 $slen = strlen ( $day_name );
00370
00371 $ya = $y + $line_height + 0.125;
00372
00373 if ( (max($ya, ($slen * 0.125))) >= $bottom )
00374 {
00375 break;
00376 }
00377
00378 $this->napdf_instance->Line ( $left, $y, $right, $y );
00379 $y += $line_height;
00380 $x = $left + 0.1;
00381
00382 $this->napdf_instance->SetFont ( $this->font, '', $fSize );
00383
00384 $meetings_day = $meetings_days[$pos['day']];
00385 $count = count ( $meetings_day );
00386 for ( ; $pos['count'] < $count; $pos['count']++ )
00387 {
00388 $x = $left + $daygap;
00389
00390 if ( $grayLine == 1 )
00391 {
00392 $this->napdf_instance->SetFillColor ( 220 );
00393 $this->napdf_instance->Rect ( $left + $daygap, $y - ($fSize / 144), $right - ($left + $daygap), $fSize / 72, 'F' );
00394 $grayLine = 0;
00395 }
00396 else
00397 {
00398 $grayLine = 1;
00399 }
00400
00401 $this->napdf_instance->SetXY ( $x, $y );
00402 $this->napdf_instance->Cell ( $columns['town'], 0, $meetings_day[$pos['count']]['location_municipality'] );
00403 $x += $columns['town'];
00404 $this->napdf_instance->SetX ( $x );
00405 $this->napdf_instance->Cell ( $columns['name'], 0, $meetings_day[$pos['count']]['meeting_name'] );
00406 $x += $columns['name'];
00407 $this->napdf_instance->SetX ( $x );
00408 $this->napdf_instance->Cell ( $columns['location'], 0, $meetings_day[$pos['count']]['location'] );
00409 $x += $columns['location'];
00410 $this->napdf_instance->SetX ( $x );
00411 $this->napdf_instance->Cell ( $columns['time'], 0, $this->translate_time ( $meetings_day[$pos['count']]['start_time'] ), 0, 0, 'R' );
00412 $x += $columns['time'];
00413 $this->napdf_instance->SetX ( $x );
00414
00415 if ( $meetings_day[$pos['count']]['duration_time'] == "00:00:00" )
00416 {
00417 $meetings_day[$pos['count']]['duration_time'] = "01:30:00";
00418 }
00419
00420 $base_dir = "images/";
00421 $duration = split ( ":", $meetings_day[$pos['count']]['duration_time'] );
00422
00423 $duration[0] = intval ( $duration[0] );
00424 $duration[1] = intval ( $duration[1] );
00425
00426 $ClockGraphic1 = "";
00427 $ClockGraphic2 = "";
00428
00429 if ( $duration[0] > 0 )
00430 {
00431 $ClockGraphic1 = "C_60";
00432 if ( $duration[0] > 1 )
00433 {
00434 $ClockGraphic2 = "C_60";
00435 }
00436 }
00437
00438 if ( !$ClockGraphic2 )
00439 {
00440 if ( $duration[1] > 45 )
00441 {
00442 $ClockGraphic2 = "C_60";
00443 }
00444 elseif ( $duration[1] > 30 )
00445 {
00446 $ClockGraphic2 = "C_45";
00447 }
00448 elseif ( $duration[1] > 15 )
00449 {
00450 $ClockGraphic2 = "C_30";
00451 }
00452 elseif ( $duration[1] > 0 )
00453 {
00454 $ClockGraphic2 = "C_15";
00455 }
00456 }
00457
00458 if ( $ClockGraphic1 )
00459 {
00460 $this->napdf_instance->Image ( "$base_dir$ClockGraphic1.png", $x, $y-($duration_width/2), $duration_width, 0, 'PNG' );
00461 }
00462
00463 $x += $duration_width + $duration_gap;
00464
00465 if ( $ClockGraphic2 )
00466 {
00467 $this->napdf_instance->Image ( "$base_dir$ClockGraphic2.png", $x, $y-($duration_width/2), $duration_width, 0, 'PNG' );
00468 }
00469
00470 $x += $duration_width + $duration_gap;
00471
00472 $this->napdf_instance->SetXY ( $x, $y );
00473 $this->napdf_instance->Cell ( $columns['format'], 0, $this->RearrangeFormats ( $meetings_day[$pos['count']]['formats'] ) );
00474 $y += $line_height;
00475
00476 if ( ($y + $line_height) >= $bottom )
00477 {
00478 $pos['count']++;
00479 break;
00480 }
00481 }
00482
00483 $this->napdf_instance->SetFont ( $this->font, 'B', 14 );
00484
00485 for ( $a = 0; $a < $slen; $a++ )
00486 {
00487 $letter = $day_name[$a];
00488 $this->napdf_instance->SetXY ( $left, $ya );
00489 $this->napdf_instance->Cell ( $daygap, 0, $letter, 0, 0, 'C' );
00490 $ya += 0.2;
00491
00492 if ( ($ya + 0.125) >= $y )
00493 {
00494 break;
00495 }
00496 }
00497
00498 if ( ($pos['count'] < ($count - 1)) && (($y + $line_height) >= $bottom) )
00499 {
00500 break;
00501 }
00502
00503 $pos['count'] = 0;
00504
00505 if ( $pos['day'] == 0 )
00506 {
00507 $pos = "";
00508 break;
00509 }
00510
00511 if ( $pos['day'] == 6 )
00512 {
00513 $pos['day'] = -1;
00514 }
00515
00516 $next_day = $pos['day'] + 1;
00517
00518 $next_day_count = count ( $meetings_days[$next_day] );
00519 $next_day_y = ($next_day_count * $line_height);
00520 if ( isset ( $this->weekday_names[$next_day_count] ) )
00521 {
00522 $next_day_slen = strlen ( $this->weekday_names[$next_day_count] );
00523 $next_day_y = max ( $next_day_y, ($next_day_slen * 0.125) );
00524 if ( ($y + $next_day_y) >= $bottom )
00525 {
00526 $pos['day']++;
00527 break;
00528 }
00529 }
00530 }
00531 return $pos;
00532 }
00533
00534
00535
00536 private function DrawRearPanel ( $left, $top, $right, $bottom, $formats )
00537 {
00538 $y = $top + 0.125;
00539
00540 $fontSize = $this->font_size;
00541
00542
00543
00544 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 3) );
00545 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_FORMAT_KEY );
00546 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00547
00548 $this->napdf_instance->SetXY ( $cellleft, $y );
00549
00550 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_FORMAT_KEY );
00551 $y += 0.125;
00552
00553 $count = count ( $formats );
00554 $w1 = $left + 0.25;
00555 $fSize = $fontSize - 4;
00556
00557 $this->napdf_instance->SetY ( $y );
00558
00559 foreach ( $formats as $format )
00560 {
00561 $this->napdf_instance->SetFont ( $this->font, 'B', $fSize );
00562 $this->napdf_instance->SetLeftMargin ( $left );
00563 $str = $format['key_string'];
00564 $this->napdf_instance->SetX ( $left );
00565 $this->napdf_instance->Cell ( 0, 0.13, $str );
00566 $this->napdf_instance->SetFont ( $this->font, '', $fSize );
00567 $str = $format['description_string'];
00568 $this->napdf_instance->SetLeftMargin ( $w1 );
00569 $this->napdf_instance->SetX ( $w1 );
00570 $this->napdf_instance->MultiCell ( ($right - $w1), 0.13, $str );
00571 $this->napdf_instance->SetY ( $this->napdf_instance->GetY ( ) + 0.01 );
00572 }
00573
00574 $y = $this->napdf_instance->GetY ( ) + 0.1;
00575
00576 $base_dir = "images/";
00577
00578 $ClockGraphic1 = "C_15";
00579 $ClockGraphic2 = "C_30";
00580 $ClockGraphic3 = "C_45";
00581 $ClockGraphic4 = "C_60";
00582
00583 $duration_width = 0.12;
00584 $duration_gap = $duration_width / 4;
00585
00586 $x = $left;
00587 $this->napdf_instance->SetLeftMargin ( $x );
00588 $this->napdf_instance->SetXY ( $x, $y );
00589 $str = _PDF_SASNA_LIST_DUR_INTRO." ";
00590 $l = $this->napdf_instance->GetStringWidth ( $str );
00591 $this->napdf_instance->Cell ( $l, 0.13, $str );
00592 $x += $l + $duration_gap;
00593
00594 $this->napdf_instance->Image ( "$base_dir$ClockGraphic1.png", $x, $y, $duration_width, 0, 'PNG' );
00595 $x += $duration_width + $duration_gap;
00596 $str = _PDF_SASNA_LIST_DUR_15.", ";
00597 $l = $this->napdf_instance->GetStringWidth ( $str );
00598 $this->napdf_instance->SetX ( $x );
00599 $this->napdf_instance->Cell ( $l, 0.13, $str );
00600 $x += $l + $duration_gap;
00601
00602 $this->napdf_instance->Image ( "$base_dir$ClockGraphic2.png", $x, $y, $duration_width, 0, 'PNG' );
00603 $x += $duration_width + $duration_gap;
00604 $str = _PDF_SASNA_LIST_DUR_30.", ";
00605 $l = $this->napdf_instance->GetStringWidth ( $str );
00606 $this->napdf_instance->SetX ( $x );
00607 $this->napdf_instance->Cell ( $l, 0.13, $str );
00608 $x += $l + $duration_gap;
00609
00610 $this->napdf_instance->Image ( "$base_dir$ClockGraphic3.png", $x, $y, $duration_width, 0, 'PNG' );
00611 $x += $duration_width + $duration_gap;
00612 $str = _PDF_SASNA_LIST_DUR_45.", ";
00613 $l = $this->napdf_instance->GetStringWidth ( $str );
00614 $this->napdf_instance->SetX ( $x );
00615 $this->napdf_instance->Cell ( $l, 0.13, $str );
00616 $x += $l + $duration_gap;
00617
00618 $this->napdf_instance->Image ( "$base_dir$ClockGraphic4.png", $x, $y, $duration_width, 0, 'PNG' );
00619 $x += $duration_width + $duration_gap;
00620 $str = _PDF_SASNA_LIST_DUR_60;
00621 $l = $this->napdf_instance->GetStringWidth ( $str );
00622 $this->napdf_instance->SetX ( $x );
00623 $this->napdf_instance->Cell ( $l, 0.13, $str );
00624
00625 $y = $this->napdf_instance->GetY ( ) + 0.25;
00626
00627 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 1) );
00628 $this->napdf_instance->SetXY ( $left + 0.5, $y );
00629 $this->napdf_instance->MultiCell ( ($right - $left), (($fontSize + 1) / 72), _PDF_SASNA_LIST_MAILING );
00630
00631 $y = $this->napdf_instance->GetY ( ) + 0.05;
00632 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 1) );
00633
00634 $this->napdf_instance->SetXY ( $left + 0.6, $y );
00635 $this->napdf_instance->MultiCell ( ($right - $left), (($fontSize + 1) / 72), _PDF_SASNA_LIST_SASNA );
00636
00637 $y = $this->napdf_instance->GetY ( ) + 0.03;
00638 $this->napdf_instance->SetFont ( $this->font, '', $fontSize - 1 );
00639
00640 $this->napdf_instance->SetXY ( $left + 0.6, $y );
00641 $this->napdf_instance->MultiCell ( ($right - $left), (($fontSize - 1) / 72), _PDF_SASNA_LIST_PO );
00642
00643 $y = $this->napdf_instance->GetY ( ) + 0.03;
00644 $this->napdf_instance->SetFont ( $this->font, '', $fontSize - 1 );
00645
00646 $this->napdf_instance->SetXY ( $left + 0.6, $y );
00647 $this->napdf_instance->MultiCell ( ($right - $left), (($fontSize - 1) / 72), _PDF_SASNA_LIST_TOWN );
00648
00649 $this->napdf_instance->SetFont ( $this->font, '', $fontSize );
00650
00651 $y = $this->napdf_instance->GetY ( ) + 0.125;
00652 $this->napdf_instance->SetFont ( $this->font, 'I', ($fontSize - 4) );
00653 $this->napdf_instance->SetXY ( $left, $y );
00654 $this->napdf_instance->MultiCell ( ($right - $left), (($fontSize - 1) / 72), _PDF_DISCLAIMER );
00655 }
00656
00657
00658
00659 private function DrawFrontPanel ( $left, $top, $right, $bottom, $date )
00660 {
00661 $inTitleGraphic = "../ny_printed_lists/images/SASNA_Cover_Logo.jpg";
00662
00663 $y = $top + 0.125;
00664
00665 $fontSize = $this->font_size;
00666
00667 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 4) );
00668
00669 $stringWidth = $this->napdf_instance->GetStringWidth ( $date );
00670
00671 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00672
00673 $this->napdf_instance->SetXY ( $cellleft, $y );
00674
00675 $this->napdf_instance->Cell ( 0, 0, $date );
00676 $y += 0.2;
00677
00678 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 4) );
00679 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_BANNER );
00680 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00681
00682 $this->napdf_instance->SetXY ( $cellleft, $y );
00683
00684 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_BANNER );
00685 $y += 0.21;
00686
00687 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 4) );
00688 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_BANNER_2 );
00689 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00690
00691 $this->napdf_instance->SetXY ( $cellleft, $y );
00692
00693 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_BANNER_2 );
00694 $y += 0.15;
00695
00696 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 1) );
00697 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_BANNER_3 );
00698 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00699
00700 $this->napdf_instance->SetXY ( $cellleft, $y );
00701 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_BANNER_3 );
00702
00703 $this->napdf_instance->Image ( $inTitleGraphic, ($left + 0.0625), 1.2, (($right - $left) - 0.125), 0, 'JPG' );
00704 $y = 3.3;
00705
00706 $cellleft = $left + 0.6;
00707
00708 $this->napdf_instance->SetXY ( $cellleft, $y );
00709 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINES );
00710 $y += 0.2;
00711
00712 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 2) );
00713
00714 $this->napdf_instance->SetXY ( $cellleft, $y );
00715 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINE_SUFFOLK );
00716
00717 $y += 0.16;
00718
00719 $this->napdf_instance->SetFont ( $this->font, '', ($fontSize - 2) );
00720
00721 $this->napdf_instance->SetXY ( $cellleft, $y );
00722 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINE_NASSAU );
00723 $y += 0.16;
00724
00725 $this->napdf_instance->SetXY ( $cellleft, $y );
00726
00727 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINE_REGION );
00728
00729 $y += 0.25;
00730
00731 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 1) );
00732
00733 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 4) );
00734 $url_string = _PDF_SASNA_LIST_URL;
00735
00736 $stringWidth = $this->napdf_instance->GetStringWidth ( $url_string );
00737 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00738
00739 $this->napdf_instance->SetXY ( $cellleft, $y );
00740
00741 $this->napdf_instance->Cell ( 0, 0, $url_string );
00742 $y += 0.3;
00743
00744 $cellleft = $left;
00745 $this->napdf_instance->SetXY ( $cellleft, $y );
00746 $st_width = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_WELCOME );
00747 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_WELCOME );
00748 $y += 0.125;
00749
00750 $this->napdf_instance->SetFont ( $this->font, '', $fontSize );
00751
00752 $this->napdf_instance->SetLineWidth ( 0.02 );
00753 $this->napdf_instance->Line ( ($st_width + $left) + 0.0625, $y, $right, $y );
00754
00755 while ( $y < ($bottom - 0.3) )
00756 {
00757 $y += 0.3;
00758 $this->napdf_instance->Line ( $left + 0.0625, $y, $right, $y );
00759 }
00760 }
00761
00762
00763
00764 private function RearrangeFormats ( $inFormats )
00765 {
00766 $inFormats = split ( ",", $inFormats );
00767
00768 if ( !in_array ( "C", $inFormats ) && !in_array ( "O", $inFormats ) )
00769 {
00770 array_push ( $inFormats, "C" );
00771 }
00772
00773 if ( !in_array ( "BK", $inFormats ) && ((in_array ( "BT", $inFormats ) || in_array ( "IW", $inFormats ) || in_array ( "JT", $inFormats ) || in_array ( "SG", $inFormats ))) )
00774 {
00775 array_push ( $inFormats, "BK" );
00776 }
00777
00778 uasort ( $inFormats, 'sasna_napdf::sort_cmp' );
00779
00780 $tFormats = $inFormats;
00781
00782 $inFormats = array();
00783
00784 foreach ( $tFormats as $format )
00785 {
00786 $format = trim ( $format );
00787 if ( $format )
00788 {
00789 array_push ( $inFormats, $format );
00790 }
00791 }
00792
00793 return join ( ",", $inFormats );
00794 }
00795
00796
00797
00798 private static function break_meetings_by_day ( $in_meetings_array )
00799 {
00800 $last_day = -1;
00801 $meetings_day = array();
00802
00803 foreach ( $in_meetings_array as $meeting )
00804 {
00805 if ( $meeting['weekday_tinyint'] != $last_day )
00806 {
00807 $last_day = $meeting['weekday_tinyint'] -1;
00808 }
00809
00810 $meetings_day[$last_day][] = $meeting;
00811 }
00812
00813 return $meetings_day;
00814 }
00815
00816
00817
00818 private static function sort_cmp ($a, $b)
00819 {
00820 $order_array = array( 0=>"O", 1=>"C",
00821 2=>"ES", 3=>"B", 4=>"M", 5=>"W", 6=>"GL", 7=>"YP", 8=>"BK", 9=>"IP", 10=>"Pi", 11=>"RF", 12=>"Rr",
00822 13=>"So", 14=>"St", 15=>"To", 16=>"Tr", 17=>"OE", 18=>"D", 19=>"SD", 20=>"TW", 21=>"IL",
00823 22=>"BL", 23=>"IW", 24=>"BT", 25=>"SG", 26=>"JT",
00824 27=>"Ti", 28=>"Sm", 29=>"NS", 30=>"CL", 31=>"CS", 32=>"NC", 33=>"SC", 34=>"CH", 35=>"SL", 36=>"WC" );
00825
00826 if ( in_array ( $a, $order_array ) || in_array ( $b, $order_array ) )
00827 {
00828 return (array_search ( $a, $order_array ) < array_search ( $b, $order_array )) ? -1 : 1;
00829 }
00830 else
00831 {
00832 return 0;
00833 }
00834 }
00835
00836
00837
00838 private static function translate_time ( $in_time_string )
00839 {
00840 $split = split ( ":", $in_time_string );
00841 if ( $in_time_string == "12:00:00" )
00842 {
00843 return "Noon";
00844 }
00845 elseif ( ($split[0] == "23") && (intval ( $split[1] ) > 45) )
00846 {
00847 return "Midnight";
00848 }
00849 else
00850 {
00851 return date ( "g:i A", strtotime ( $in_time_string ) );
00852 }
00853 }
00854
00855
00856
00857 private static function translate_duration ( $in_time_string )
00858 {
00859 $t = split ( ":", $in_time_string );
00860 $hours = intval ( $t[0] );
00861 $minutes = intval ( $t[1] );
00862
00863 $ret = '';
00864
00865 if ( $hours )
00866 {
00867 $ret .= "$hours hour";
00868
00869 if ( $hours > 1 )
00870 {
00871 $ret .= "s";
00872 }
00873
00874 if ( $minutes )
00875 {
00876 $ret .= " and ";
00877 }
00878 }
00879
00880 if ( $minutes )
00881 {
00882 $ret .= "$minutes minutes";
00883 }
00884
00885 return $ret;
00886 }
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 private static function call_curl ( $in_uri,
00897 $in_post = true,
00898 &$http_status = null
00899 )
00900 {
00901 $ret = null;
00902
00903
00904 if ( !extension_loaded ( 'curl' ) )
00905 {
00906 if ( ini_get ( 'allow_url_fopen' ) )
00907 {
00908 $ret = file_get_contents ( $in_uri );
00909 }
00910 }
00911 else
00912 {
00913
00914 $resource = curl_init();
00915
00916
00917 if ( $in_post )
00918 {
00919 $spli = explode ( "?", $in_uri, 2 );
00920
00921 if ( is_array ( $spli ) && count ( $spli ) )
00922 {
00923 $in_uri = $spli[0];
00924 $in_params = $spli[1];
00925
00926 curl_setopt ( $resource, CURLOPT_POST, true );
00927 curl_setopt ( $resource, CURLOPT_POSTFIELDS, $in_params );
00928 }
00929 }
00930
00931
00932 curl_setopt ( $resource, CURLOPT_URL, $in_uri );
00933
00934
00935 curl_setopt ( $resource, CURLOPT_RETURNTRANSFER, true );
00936
00937
00938
00939
00940
00941 curl_setopt ( $resource, CURLOPT_HEADER, false );
00942
00943
00944
00945
00946
00947
00948 curl_setopt ( $resource, CURLOPT_MAXREDIRS, 3 );
00949
00950
00951 curl_setopt ( $resource, CURLOPT_CONNECTTIMEOUT, 10 );
00952
00953
00954 curl_setopt ( $resource, CURLOPT_ENCODING, 'gzip,deflate' );
00955
00956
00957 $content = curl_exec ( $resource );
00958
00959
00960 if ( $content === false )
00961 {
00962
00963 throw new Exception ( "curl failure calling $in_uri, ".curl_error ( $resource ).", ".curl_errno ( $resource ) );
00964 }
00965 else
00966 {
00967
00968
00969
00970
00971 $http_status = curl_getinfo ($resource, CURLINFO_HTTP_CODE );
00972 }
00973
00974
00975 curl_close ( $resource );
00976
00977
00978 if ( $content !== false )
00979 {
00980 $ret = $content;
00981 }
00982 }
00983
00984 return $ret;
00985 }
00986 };
00987 ?>