action.printGroup.php 1.28 KB
Newer Older
Leif Andersson's avatar
Leif Andersson committed
1
<?php
2
if( !defined('CMS_VERSION') ) exit;
Leif Andersson's avatar
Leif Andersson committed
3
4
5
6
7
8
9
10
11
12
//echo '<pre>'; print_r($params); echo '</pre>';

$ID = $params['ID'];

$HEAD = <<<EOS
<!doctype html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>Grupp $ID</title>
Leif Andersson's avatar
Leif Andersson committed
13
<!-- meta http-equiv="Content-Type" content="text/html"/ -->
Leif Andersson's avatar
Leif Andersson committed
14
</head>
Leif Andersson's avatar
Leif Andersson committed
15
16
17
<body>
<table>
<tr><td>Kolumn1</td><td>Kolumn2</td><td>Kolumn3</td><td>Kolumn4</td>
Leif Andersson's avatar
Leif Andersson committed
18
<td>Kolumn5</td><td>Kolumn6</td><td>Epost</td></tr>
Leif Andersson's avatar
Leif Andersson committed
19
  
Leif Andersson's avatar
Leif Andersson committed
20
21
EOS;

22
$colmax = 6;
Leif Andersson's avatar
Leif Andersson committed
23
24
25
$members = Person::getGroupMembers($ID);
$addresses = array();
foreach ($members as $member) {
26
27
  $adr = '<tr>'; $col = 0;
  if (trim($member->Namn)) {$adr .= '<td>'.$member->Namn.'</td>'; $col++;}
Leif Andersson's avatar
Leif Andersson committed
28
  
29
30
31
  if ($member->SkolaForetag) {$adr .= '<td>'.$member->SkolaForetag.'</td>';$col++;}
  if ($member->Avdelning) {$adr .=  '<td>'.$member->Avdelning.'</td>'; $col++;}
  if (!$member->Adress) {$member->Adress = $member->Hem; $col++;}
Leif Andersson's avatar
Leif Andersson committed
32
33
  if ($member->Adress) {
    $aas = explode("\n",$member->Adress);
Leif Andersson's avatar
Leif Andersson committed
34
    foreach($aas as $aa) $adr .= '<td>'. $aa .'</td>';
35
    $col++;
Leif Andersson's avatar
Leif Andersson committed
36
  }
Leif Andersson's avatar
Leif Andersson committed
37
38
  for ($i = $col; $i < $colmax; $i++) $adr .= '<td></td>';
  if ($member->Epost) {$adr .= '<td>'.$member->Epost.'</td>';}
Leif Andersson's avatar
Leif Andersson committed
39
40
  $adr .= '</tr>';
  $addresses[] = $adr;
Leif Andersson's avatar
Leif Andersson committed
41
42
}
//print_r($addresses);
Leif Andersson's avatar
Leif Andersson committed
43
44
45
46
47
48
echo $HEAD;
foreach ($addresses as $adr) echo $adr.PHP_EOL;
echo '</body></html>';

exit;
?>