fhiiqm/test/ma_tel_pdf_mc.php
changeset 34 fc60ef80a7ad
equal deleted inserted replaced
33:f1a8785434e4 34:fc60ef80a7ad
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * @author Bettina Schwarzer, Fritz-Haber-Institut
       
     5  * @copyright 01/2013
       
     6  * 
       
     7  * Telefonliste als pdf erstellen
       
     8  * 
       
     9  */
       
    10 
       
    11     error_reporting(E_ALL ^ E_NOTICE);
       
    12     include ($_SERVER['DOCUMENT_ROOT']."/fhiiqm/inc/pdf_ma_tel.inc.php");
       
    13 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
       
    14     $dbc = new dbconnection();
       
    15     $sub = $_POST['sub'];
       
    16     $sortp = $_POST['sortp'];
       
    17     if (!$sortp) $sortp = $_GET['sp'];
       
    18     $abt = $_POST['abt'];
       
    19     if (!$abt) $abt  = $_GET['a'];
       
    20     $fmt = $_POST['form'];
       
    21     if (!fmt) $fmt  = $_GET['t'];
       
    22 
       
    23 	$sort   = $_GET["s"];   // Sortierung nach Spalte
       
    24     $dir    = $_GET["d"];   // Sortierrichtung
       
    25     $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
       
    26     $filter = $_GET["b"];  // Filterbegriff
       
    27     $edit   = $_GET["e"];   // Telefonliste editierbar 
       
    28     $getp = "e=$edit&s=$sort&d=$dir&f=$fnum&b=$filter"; // Parameter Listenanzeige Mitarbeiter/Objekte-Telefonliste
       
    29       
       
    30     if (!$sub)
       
    31     {
       
    32     ?>
       
    33         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
    34         <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
       
    35         
       
    36         <head>
       
    37         	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
       
    38            	<link href="/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
       
    39            	<link href="/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> 
       
    40         	<title>MA/O-Telefonliste -&gt; PDF</title>
       
    41          </head>
       
    42          <body>
       
    43          <div align="center">
       
    44          <p><b>PDF: Mitarbeiter/Objekte - Telefonliste</b></p>
       
    45     <?php
       
    46         echo "<form action=" . $_SERVER['PHP_SELF'] . " method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
       
    47         echo "<table width=\"30%\" border=\"0\">\n";
       
    48         echo "<tr><td>Format</td>";
       
    49         echo "    <td><select name=\"form\">
       
    50                         <option value=1>normal</option>
       
    51                         <option value=2>small</option>
       
    52                         <option value=3>tiny</option>
       
    53                         <option value=4>new</option>
       
    54                     </select>\n";
       
    55         echo "  </td></tr>\n";
       
    56         echo "<tr><td>filtern nach Abteilung</td>";
       
    57         echo "   <td valign=\"top\">
       
    58                  <select name=\"abt\">";
       
    59                     echo "<option value=\"-1\"></option>\n";
       
    60                     $sql = "SELECT abt_ID, abt_name, abt_long FROM `fhiiqm`.`Abteilung` ORDER BY abt_ID+0";
       
    61                     if ($result = $dbc->queryObjectArray($sql))
       
    62                     {
       
    63                         foreach ($result as $row)
       
    64                         {
       
    65                             if ($row->abt_ID == $ma['abt'])
       
    66         					   echo "<option selected value=\"$row->abt_ID\">$row->abt_name: $row->abt_long</option>\n";
       
    67         				    else
       
    68         					   echo "<option value=\"$row->abt_ID\">$row->abt_name: $row->abt_long</option>\n";
       
    69                         }
       
    70                 }
       
    71         echo "       </select></td></tr>\n";
       
    72         echo "<tr><td>sortieren nach</td>";
       
    73         echo "  <td><select name='sortp'>";
       
    74         echo "      <option value=\"-1\"></option>\n";
       
    75         echo "      <option value='2'>Name</option>\n";    
       
    76         echo "      <option value='12'>Abteilung</option>\n";    
       
    77         echo "       </select></td></tr>\n";
       
    78         echo "<tr><td>&nbsp;</td><td><input  class=\"button\" type=\"submit\" name=\"sub\" value=\"  pdf erstellen  \" /></td></tr>\n";
       
    79         echo "</table>\n";
       
    80         echo "</form>\n";
       
    81         echo "</div>\n";
       
    82         echo "<p><br /><br />&nbsp;&nbsp;&nbsp;<a href=/fhiiqm/ma_tel_flist.php?$getp>&laquo; zur Telefon-Liste</a></p>\n";
       
    83         echo "</body></html>\n";
       
    84     }
       
    85     else
       
    86     {
       
    87         if ($fmt == 2 || $fmt == 3) $wher = " WHERE sort=1 "; else $wher = " WHERE 1=1 ";
       
    88         $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email, abt_tel+0 
       
    89                 FROM v_tel_list_ma_raum " . $wher; 
       
    90 
       
    91         // intern/extern
       
    92     	$ip=getenv("REMOTE_ADDR");
       
    93     	$ippart=explode(".",$ip);
       
    94         if (($ippart[0] == 141 && $ippart[1] == 14) || ($ippart[0] == 172 && $ippart[1] == 16))
       
    95             $wip = "";
       
    96         else
       
    97             $wip = " AND public=1 ";        
       
    98         if ($sortp == '2') $sortp = "name COLLATE latin1_general_ci,3,12,5,IFNULL(sort,99),6"; // Name
       
    99         elseif ($sortp == '12') $sortp = "12,5,name COLLATE latin1_general_ci,3,IFNULL(sort,99),6"; // abt_ID
       
   100         else $sortp = "name COLLATE latin1_general_ci,3,12,5,IFNULL(sort,99),6";
       
   101         
       
   102         if ($abt > '-1') $wher = " AND abt_tel = $abt "; else $wher = "";
       
   103         
       
   104         $sql .= $wher . $wip . " ORDER BY $sortp";
       
   105         if ($result = $dbc ->queryObjectArray($sql))
       
   106         { 
       
   107             $pdf = new PDF();
       
   108             $pdf->SetLeftMargin(25);
       
   109             if ($fmt == 4)
       
   110             {  
       
   111                 $header=array('Name','Abteilung','Tel/Fax','Raum','E-Mail');
       
   112                 $pdf->anzcol = null;
       
   113             }
       
   114             $pdf->AddPage();
       
   115             $pdf->AliasNbPages();   // Anzahl Seiten
       
   116             $pdf->Image($_SERVER['DOCUMENT_ROOT']."/fhiiqm/img/tel/tellist_kopf1n.jpg",$pdf->lMargin-20,$pdf->tMargin+17,210);
       
   117             $pdf->AddPage();
       
   118             $pdf->Image($_SERVER['DOCUMENT_ROOT']."/fhiiqm/img/tel/tellist_kopf2n.jpg",$pdf->lMargin-20,$pdf->tMargin+14,210);
       
   119             $pdf->AddPage();
       
   120             $pdf->Image($_SERVER['DOCUMENT_ROOT']."/fhiiqm/img/tel/tellist_kopf3n.jpg",$pdf->lMargin-20,$pdf->tMargin+14,210);
       
   121             $pdf->AddPage();
       
   122             $pdf->Image($_SERVER['DOCUMENT_ROOT']."/fhiiqm/img/tel/tellist_kopf4n.jpg",$pdf->lMargin-20,$pdf->tMargin+14,210);
       
   123             $pdf->AddPage();
       
   124             $pdf->height = 3.5;
       
   125             $pdf->SetFont('times','','');
       
   126             switch ($fmt)
       
   127             {
       
   128                 case 1:
       
   129                     $pdf->anzcol = 1;
       
   130                     $pdf->Normal($result);
       
   131                     break;
       
   132                 case 2:
       
   133                     $pdf->xa = $pdf->lMargin;
       
   134                     $pdf->fancy = 0;    // mehrspaltig
       
   135                     $pdf->anzcol = 2;
       
   136                     $colwidth = 85;
       
   137                     $pdf->Small($result,$colwidth,$pdf->height);
       
   138                     break;
       
   139                 case 3:
       
   140                     $pdf->xa = $pdf->lMargin;
       
   141                     $pdf->fancy = 0;    // mehrspaltig
       
   142                     $pdf->anzcol = 3;
       
   143                     $colwidth = 55;
       
   144                     $pdf->Small($result,$colwidth,$pdf->height);
       
   145                     break;
       
   146                 case 4:                    
       
   147                     $pdf->fancy = 1;    // einspaltig
       
   148                     $pdf->SetFont('helvetica','',9);
       
   149                     $pdf->FancyTable($header,$result);
       
   150                     break;
       
   151             }
       
   152             
       
   153             $pdf->Ln();
       
   154             $pdf->SetDisplayMode('real');
       
   155             $pdf->Output();
       
   156             // als Download
       
   157 //            $pdf->Output('ma_tel_list.pdf','D');
       
   158         }
       
   159     }
       
   160 ?>