]> git.sur5r.net Git - contagged/blobdiff - index.php
CSV export
[contagged] / index.php
index 3f095738d55e8403b1cf8a959085305e9c5f9043..22d5c10936c3e3fb53bc2d9b309916dc739f7be3 100644 (file)
--- a/index.php
+++ b/index.php
   
   $result = array_merge($result1,$result2);
 
+  // select entry template
+  if($_REQUEST['export'] == 'csv'){
+    $entrytpl = 'export_list_csv_entry.tpl';
+  }else{
+    $entrytpl = 'list_entry.tpl';
+  }
+
   $list = '';
   if(count($result)==1 && $_REQUEST[search]){
     //only one result on a search -> display page
     uksort($keys,"_namesort");
     foreach($keys as $key){
       tpl_entry($result[$key]);
-      $list .= $smarty->fetch('list_entry.tpl');
+      $list .= $smarty->fetch($entrytpl);
     }
   }
 
-  //save location in session
-  $_SESSION[ldapab][lastlocation]=$_SERVER["REQUEST_URI"];
-   
   //prepare templates
   tpl_std();
   tpl_markers();
   $smarty->assign('list',$list);
+  $smarty->assign('filter',$_REQUEST['filter']);
   //display templates
-  $smarty->display('header.tpl');
-  $smarty->display('list_filter.tpl');
-  $smarty->display('list.tpl');
-  $smarty->display('footer.tpl');
+  if($_REQUEST['export'] == 'csv'){
+    header("Content-Type: text/csv");
+    header('Content-Disposition: Attachement; filename="ldapabexport.csv"');
+    $smarty->display('export_list_csv.tpl');
+  }else{
+    //save location in session
+    $_SESSION[ldapab][lastlocation]=$_SERVER["REQUEST_URI"];
+    $smarty->display('header.tpl');
+    $smarty->display('list_filter.tpl');
+    $smarty->display('list.tpl');
+    $smarty->display('footer.tpl');
+  }
 
   //------- functions -----------//