| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:45:06 2008 ] | [ PhpLabware 0.6 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 // editreports.php - Design and change reports 4 // editreports.php - author: Nico Stuurman <nicost@soureforge.net> 5 6 /*************************************************************************** 7 * This script edits templates for reports * 8 * * 9 * Copyright (c) 2006 by Nico Stuurman * 10 * ------------------------------------------------------------------------ * 11 * This program is free software; you can redistribute it and/or modify it * 12 * under the terms of the GNU General Public License as published by the * 13 * Free Software Foundation; either version 2 of the License, or (at your * 14 * option) any later version. * 15 \**************************************************************************/ 16 17 18 require ('./include.php'); 19 require ('./includes/db_inc.php'); 20 require ('./includes/general_inc.php'); 21 require ('./includes/tablemanage_inc.php'); 22 include_once ('./includes/defines_inc.php'); 23 24 $editreport=$_GET['editreport']; 25 $editreport=true; 26 $post_vars='table_id,tablename'; 27 globalize_vars($post_vars, $_POST); 28 globalize_vars($post_vars, $_GET); 29 30 // this needs to be done before headers are sent in printheader 31 while((list($key, $val) = each($_POST))) { 32 if (substr($key, 0, 9) == 'expreport') { 33 $modarray = explode('_', $key); 34 export_report($db,$modarray[1]); 35 exit; 36 } 37 } 38 reset($_POST); 39 40 printheader($httptitle,false,$jsfiles); 41 42 while((list($key, $val) = each($_POST))) { 43 if (substr($key, 0, 9) == "modreport") { 44 $modarray = explode("_", $key); 45 $tplmessage=mod_report($db,$modarray[1]); 46 break; 47 } elseif (substr($key, 0, 9) == "delreport") { 48 $modarray = explode("_", $key); 49 rm_report($db,$modarray[1]); 50 break; 51 } elseif (substr($key, 0, 10) == "testreport") { 52 $modarray = explode("_", $key); 53 $tplmessage=test_report($db,$modarray[1],$editreport); 54 break; 55 } elseif ($key=="addreport") { 56 $tplmessage=add_report($db); 57 break; 58 } 59 } 60 61 navbar($USER['permissions']); 62 // when no tablename is given, list all tables this user can write to 63 if (!$tablename) { 64 echo "<br><br>\n"; 65 echo "<form name='views' method='post' action='$PHP_SELF'>\n"; 66 echo "<table width='100%' border='0'>\n"; 67 echo "<tr>\n"; 68 echo "<td align='center'><h3>Edit report templates for table: </h3>"; 69 70 // make dropdown with accessible tablenames, select the current tablename 71 if ($USER['permissions'] & $SUPER) { 72 $r=$db->Execute ("SELECT label,tablename FROM tableoftables ORDER by sortkey "); 73 } else { 74 $r=$db->Execute("SELECT tableoftables.label,tableoftables.tablename FROM tableoftables LEFT JOIN groupxtable_display ON tableoftables.id=groupxtable_display.tableid WHERE groupxtable_display.groupid IN ({$USER['group_list']}) ORDER BY tableoftables.sortkey"); 75 } 76 echo $r->GetMenu2('tablename',$tablename,true,false,0,'OnChange="document.views.submit()"'); 77 echo "</td></tr></table></form>\n"; 78 printfooter(); 79 exit; 80 } 81 82 echo $tplmessage; 83 84 $r=$db->Execute("SELECT id,table_desc_name,label FROM tableoftables WHERE tablename='$tablename'"); 85 $tableid=$r->fields['id']; 86 $tablelabel=$r->fields['label']; 87 $tabledesc=$r->fields[1]; 88 echo "<h3 align='center'>$string</h3>"; 89 echo "<h3 align='center'>Edit report templates for table <i>$tablelabel</i></h3><br>"; 90 91 echo "<form method='post' name='reportform' id='repedit' enctype='multipart/form-data' "; 92 $dbstring=$PHP_SELF; 93 echo "action='$dbstring?editreport=$editreport&".SID."'>\n"; 94 95 // Tableheader 96 echo "<table align='center' border='0' cellpadding='2' cellspacing='0'>\n"; 97 echo "<tr>\n"; 98 echo "<th>Report Name</th>\n"; 99 echo "<th>Sortkey</th>\n"; 100 echo "<th>Template File Add/Change</th>\n"; 101 echo "<th>File present</th>"; 102 echo "<th>Action</th>\n"; 103 echo "</tr>\n"; 104 105 // New addition 106 echo "<input type='hidden' name='table_name' value='$editreport'>\n"; 107 echo "<tr align='center' >\n"; 108 echo "<td><input type='text' name='addrep_label' value='' size='10'></td>\n"; 109 echo "<td><input type='text' name='addrep_sortkey' value='' size='5'></td>\n"; 110 echo "<td><input type='file' name='addrep_template'</td>\n"; 111 echo "<td> </td>\n"; 112 echo "<td align='center'><input type='submit' name='addreport' value='Add'></td></tr>\n\n"; 113 114 // Loop through existing templates 115 $rp=$db->Execute("SELECT id,label,sortkey,filesize FROM reports WHERE tableid='$tableid' ORDER BY sortkey"); 116 $rownr=0; 117 while ($rp && !$rp->EOF) { 118 $id=$rp->fields["id"]; 119 echo "<input type='hidden' name='report_id[$rownr]' value='$id'>\n"; 120 if ($rownr % 2) 121 echo "<tr class='row_odd' align='center'>\n"; 122 else 123 echo "<tr class='row_even' align='center'>\n"; 124 125 echo "<td><input type='text' name='report_label[$rownr]' value='".$rp->fields["label"]."' size=10></td>\n"; 126 echo "<td><input type='text' name='report_sortkey[$rownr]' value='".$rp->fields["sortkey"]."'size=5></td>\n"; 127 echo "<td><input type='file' name='report_template[$rownr]'</td>\n"; 128 if (is_readable($system_settings["templatedir"]."/$id.tpl")) 129 echo "<td>Yes</td>\n"; 130 else 131 echo "<td>No</td>\n"; 132 $modstring = "<input type='submit' name='modreport"."_$rownr' value='Modify'>\n"; 133 $exportstring = "<input type='submit' name='expreport"."_$rownr' value='Export'>\n"; 134 $teststring = "<input type='submit' name='testreport"."_$rownr' value='Test'>\n"; 135 $delstring = "<input type='submit' name='delreport"."_$rownr' value='Remove' "; 136 $delstring .= "Onclick=\"if(confirm('Are you absolutely sure that the report ".$rp->fields["label"] ." should be removed? (No undo possible!)')){return true;}return false;\">"; 137 echo "<td>$modstring \n$delstring \n$exportstring \n$teststring</td>\n"; 138 echo "</tr>\n"; 139 $rp->MoveNext(); 140 $rownr++; 141 } 142 echo "</table>\n"; 143 144 echo "<br>\n"; 145 // list all available fields and field labels : 146 echo "<table width=75% align='center' border='0' cellpadding='2' cellspacing='0'>\n"; 147 echo "<tr><td> </td><td colspan=2 align='right' >Column names available:</td></tr>\n"; 148 echo "<tr><td> </td><th>Column Name</th><th>Column Label</th></tr>\n"; 149 $r=$db->Execute("SELECT columnname,label FROM {$tabledesc}"); 150 // show the help text in the left most column 151 $rowspan=$r->RecordCount() + 1; 152 echo "<tr><td rowspan=$rowspan valign='top'>"; 153 include 'documents/help_reports.php'; 154 echo "</td>\n"; 155 $first=true; 156 while ($r && !$r->EOF) { 157 if ($first) { 158 echo "<td>{$r->fields[0]}</td><td>{$r->fields[1]}</td></tr>\n"; 159 $first=false; 160 } else { 161 echo "<tr><td>{$r->fields[0]}</td><td>{$r->fields[1]}</td></tr>\n"; 162 } 163 164 $r->MoveNext(); 165 } 166 echo "</table\n"; 167 168 169 170 171 printfooter(); 172 exit; 173 174 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |