/*************************************************************************** * This script edits templates for reports * * * * Copyright (c) 2006 by Nico Stuurman * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * \**************************************************************************/ require('./include.php'); require('./includes/db_inc.php'); require('./includes/general_inc.php'); require('./includes/tablemanage_inc.php'); include_once ('./includes/defines_inc.php'); $editreport=$_GET['editreport']; $editreport=true; $post_vars='table_id,tablename'; globalize_vars($post_vars, $_POST); globalize_vars($post_vars, $_GET); // this needs to be done before headers are sent in printheader while((list($key, $val) = each($_POST))) { if (substr($key, 0, 9) == 'expreport') { $modarray = explode('_', $key); export_report($db,$modarray[1]); exit; } } reset($_POST); printheader($httptitle,false,$jsfiles); while((list($key, $val) = each($_POST))) { if (substr($key, 0, 9) == "modreport") { $modarray = explode("_", $key); $tplmessage=mod_report($db,$modarray[1]); break; } elseif (substr($key, 0, 9) == "delreport") { $modarray = explode("_", $key); rm_report($db,$modarray[1]); break; } elseif (substr($key, 0, 10) == "testreport") { $modarray = explode("_", $key); $tplmessage=test_report($db,$modarray[1],$editreport); break; } elseif ($key=="addreport") { $tplmessage=add_report($db); break; } } navbar($USER['permissions']); // when no tablename is given, list all tables this user can write to if (!$tablename) { echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "

Edit report templates for table:

"; // make dropdown with accessible tablenames, select the current tablename if ($USER['permissions'] & $SUPER) { $r=$db->Execute ("SELECT label,tablename FROM tableoftables ORDER by sortkey "); } else { $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"); } echo $r->GetMenu2('tablename',$tablename,true,false,0,'OnChange="document.views.submit()"'); echo "
\n"; printfooter(); exit; } echo $tplmessage; $r=$db->Execute("SELECT id,table_desc_name,label FROM tableoftables WHERE tablename='$tablename'"); $tableid=$r->fields['id']; $tablelabel=$r->fields['label']; $tabledesc=$r->fields[1]; echo "

$string

"; echo "

Edit report templates for table $tablelabel


"; echo "
\n"; // Tableheader echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; // New addition echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n\n"; // Loop through existing templates $rp=$db->Execute("SELECT id,label,sortkey,filesize FROM reports WHERE tableid='$tableid' ORDER BY sortkey"); $rownr=0; while ($rp && !$rp->EOF) { $id=$rp->fields["id"]; echo "\n"; if ($rownr % 2) echo "\n"; else echo "\n"; echo "\n"; echo "\n"; echo "\n"; else echo "\n"; $modstring = "\n"; $exportstring = "\n"; $teststring = "\n"; $delstring = "fields["label"] ." should be removed? (No undo possible!)')){return true;}return false;\">"; echo "\n"; echo "\n"; $rp->MoveNext(); $rownr++; } echo "
Report NameSortkeyTemplate File Add/ChangeFile presentAction
\n"; echo " 
\n"; if (is_readable($system_settings["templatedir"]."/$id.tpl")) echo "YesNo$modstring  \n$delstring  \n$exportstring  \n$teststring
\n"; echo "
\n"; // list all available fields and field labels : echo "\n"; echo "\n"; echo "\n"; $r=$db->Execute("SELECT columnname,label FROM {$tabledesc}"); // show the help text in the left most column $rowspan=$r->RecordCount() + 1; echo "\n"; $first=true; while ($r && !$r->EOF) { if ($first) { echo "\n"; $first=false; } else { echo "\n"; } $r->MoveNext(); } echo "
Column names available:
Column NameColumn Label
"; include 'documents/help_reports.php'; echo "{$r->fields[0]}{$r->fields[1]}
{$r->fields[0]}{$r->fields[1]}