Commit 4e0809ab authored by Leif Andersson's avatar Leif Andersson
Browse files

Lade till utskrift av grupper

parent 60a94dba
......@@ -2,6 +2,17 @@
if (!isset($gCms)) exit;
//echo '<pre>'; print_r($params); echo '</pre>';
$ID='';
$paramKeys = array_keys($params);
$print = 'print_';
foreach ($paramKeys as $key) {
$pos = strpos($key,$print);
if ($pos === false) continue;
$ID = substr($key,strlen($print));
$this->Redirect($id, 'printGroup', $returnid, array('ID'=>$ID));
return;
}
if (! $this->CheckPermission('Use ReglerAddress')) {
return $this->DisplayErrorPage($id, $params, $returnid,
'ReglerAddress access denied.');
......
<?php
if (!isset($gCms)) exit;
//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>
<meta http-equiv="Content-Type" content="text/plain"/>
</head>
EOS;
$members = Person::getGroupMembers($ID);
$addresses = array();
foreach ($members as $member) {
$adr = '';
if (trim($member->Namn)) $adr .= $member->Namn.PHP_EOL;
if ($member->SkolaForetag) $adr .= $member->SkolaForetag.PHP_EOL;
if ($member->Avdelning) $adr .= $member->Avdelning.PHP_EOL;
if ($member->Adress) $adr .= $member->Adress.PHP_EOL;
$addresses[] = $adr;
}
echo $HEAD;
echo '<body>'.PHP_EOL;
echo '<pre>';
foreach ($addresses as $adr) echo $adr.PHP_EOL;
echo '</pre>';
echo '</body></html>';
exit;
?>
......@@ -2,9 +2,6 @@
class Group {
private static $maildir = '/home/leif/slask/maildir';
private static $queryList = <<<EOS
select ID, Gruppnamn, GruppInfo from Grupper order by Gruppnamn
EOS;
......@@ -165,14 +162,6 @@ EOS;
if ($result === false) {die("Database error!<br>" . $db->ErrorMsg()); }
}
/* public static function getGroup() { */
/* if (!isset(self::$instance)) { */
/* $c = __CLASS__; */
/* self::$instance = new $c; */
/* } */
/* return self::$instance->list; */
/* } */
public static function setMailLists() {
global $gCms; if (!isset($gCms)) exit;
$config =& $gCms->GetConfig();
......
......@@ -18,6 +18,11 @@ EOT;
Grupper.ID=GruppID and AdressID = ?
EOT;
private static $queryGroupMembers = <<<EOS
select distinct *, concat(Fornamn, ' ', Efternamn) as Namn
from Adresser,GruppAdress where Adresser.ID=AdressID and GruppID=?
EOS;
public static $firstFields = array(
'ID','fornamn', 'efternamn', 'foretag','avdelning', 'adress', 'Grupp');
......@@ -167,5 +172,22 @@ EOT;
}
return $records;
}
public static function getGroupMembers($groupID) {
global $gCms; if (!isset($gCms)) exit;
$db = AddressDB::getDB();
$class = __CLASS__;
$records = array();
$values = array($groupID);
$result = $db->Execute(self::$queryGroupMembers,$values);
if (!$result) { die("Database error!<br>" . $db->ErrorMsg()); }
while ($row = $result->FetchRow()) {
$person = new $class();
foreach ($row as $key => $value) {
$person->$key = $value;
}
$records[] = $person;
}
return $records;
}
}
?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment