<?php
require_once('../php/fredlSession.php');
/****************************************************************
* FREMO Asset Management
* Module: locolist.php
* Description: List of all locos
*
* Created: 12/2003
* $Log: locolist.php,v $
* Revision 1.21 2005/11/21 19:23:21 dirkj
* Removed close to row-icons (created visible underscore)
* and added align=center.
*
* Revision 1.20 2005/10/10 21:16:44 dirkj
* Migration to enhanced tablefunc module.
*
* Revision 1.19 2005/07/15 22:05:25 dirkj
* Added list filter features -- 1st revision, still work in progress.
*
* Revision 1.18 2005/05/28 17:15:32 dirkj
* Added donate-function
*
* Revision 1.17 2005/05/21 19:41:28 dirkj
* Added/updated lang handling.
*
* Revision 1.16 2005/04/17 17:21:23 dirkj
* Lola Work in progress: step 4
*
* Revision 1.15.2.2 2005/04/09 22:54:31 dirkj
* Moved user configuration and defaults to an own table userconfig
*
* Revision 1.15.2.1 2005/03/31 21:49:16 dirkj
* Work in progress: step 3
*
* Revision 1.15 2005/02/21 10:09:44 dirkj
* Added backuri navigation for edit cargo/loco.
*
* Revision 1.14 2004/11/01 12:35:47 dirkj
* Modified session handling.
*
* Revision 1.13 2004/10/20 18:44:42 dirkj
* Added visibility column to objects and handling of that to control
* security aspects.
*
* Revision 1.12 2004/09/30 08:38:20 dirkj
* Added option to open PDFs in separate window.
*
* Revision 1.11 2004/09/26 13:09:22 dirkj
* Fixed bug that standard users could not delete their locos.
*
* Revision 1.10 2004/09/18 17:03:48 dirkj
* Added call of FRED-card generation.
*
* Revision 1.9 2004/08/22 08:23:37 dirkj
* Made config of LinesPerPage a user configurable variable.
*
* Revision 1.8 2004/08/13 21:00:03 dirkj
* Added paging for long DB results.
*
* Revision 1.7 2004/08/09 16:43:47 dirkj
* Added title attribute to links (this supports browsers other
* than IE to show a popup with a hint for a link).
*
* Revision 1.6 2004/07/21 07:15:27 dirkj
* Added userHasAcecss calls
*
* Revision 1.5 2004/07/19 17:15:35 klk32002
* Added some old and new fields.
*
* Revision 1.4 2004/07/13 20:56:28 dirkj
* Fixed #989384: Added wheeltype (Rad) attribute.
*
* Revision 1.3 2004/06/23 19:09:25 dirkj
* Update of deleteloco call.
*
* Revision 1.2 2004/06/23 14:34:28 dirkj
* Changed commands to use icons instead of text links.
*
* Revision 1.1 2004/06/21 18:40:25 dirkj
* New loco functions and dialogues.
* Reduce the number of files to manage locos.
* Changed loco db-table and introduced lookup table.
*
****************************************************************/
require_once '../php/sessionhelpers.inc.php';
require_once '../php/tablefunc.php';
require_once '../php/navigator.php';
require_once '../lib/lang.php';
/*
* rowFunctionButtonsCallback is called by the tablefunc class and should return
* a string defining the functions per row of a table.
* @param row[] is the sql result for this row
* @param usrObj is the current user's object
* @param l is the language object
*/
function rowFunctionButtonsCallback($row, $usrObj, $l)
{
$ownerid=$row[0]; // the owner of a cargo car will be set when displaying columns
$locoid=$row[1];
$thisuri = $_SERVER['REQUEST_URI'];
$s = "";
$s .= "<td align='center'>";
if ((userHasAccess($usrObj->id, 'editloco') && ($usrObj->id == $ownerid))
|| userHasAccess($usrObj->id,'editloco4other'))
{
$titleText = $l->get('general-edit','ändern');
$s .= "<a href='editloco.php?mode=edit&locoid=$row[1]&backuri=".urlencode($thisuri)."'>
<img src=../img/edit_record.gif title='$titleText' alt='$titleText' border=0>
</a>";
}
$s .= "</td>";
$s .= "<td align='center'>";
if (userHasAccess($usrObj->id, 'newloco'))
{
$titleText = $l->get('general-copy','kopieren');
$s .= "<a href='editloco.php?mode=copy&locoid=$row[1]'>
<img src=../img/copy_record.gif title='$titleText' alt='$titleText' border=0>
</a>";
}
$s .= "</td>";
if ($usrObj->id == $ownerid)
{
$s .= "<td align='center'>";
$titleText = $l->get('general-donate','verschenken');
$s .= "<a href='../php/donate.php?what=loco&id=$row[1]&backuri=".urlencode($thisuri)."'>
<img src=../img/gift.gif title='$titleText' alt='$titleText' border=0>
</a> ";
$s .= "</td>";
}
$s .= "<td align='center'>";
if ((userHasAccess($usrObj->id, 'deleteloco') && ($usrObj->id == $ownerid))
|| userHasAccess($usrObj->id,'deleteloco4other'))
{
$titleText = $l->get('general-delete','löschen');
$s .= "<a href='deleteloco.php?locoid=$row[1]&backuri=".urlencode($thisuri)."'>
<img src=../img/delete_record.gif title='$titleText' alt='$titleText' border=0>
</a>";
}
$s .= "</td>";
return $s;
}
$usrObj=getUserObject();
$l = new Lang($usrObj->langid, "loco-list", "general");
$nl="\r\n";
print "<html>";
print "<head>";
print '<link rel="stylesheet" type="text/css" href="../'.$myStyleSheet.'">';
print "</head>";
print $nl;
print '<body class=right>';
print $nl;
$openPdfInNewWindow = $usrObj->getConfig("Layout","OpenPdfInNewWindow");
$table=new reportTable('loco',$usrObj->id,$usrObj->langid);
$table->setFunctionButtonsCallback('rowFunctionButtonsCallback');
$displayMyList=false;
if (isset($_GET['mylist']))
{
$table->setFilter(" AND l.ownerid=".$usrObj->id);
$displayMyList=true;
} else {
$table->setFilter(" AND l.released!=0 ");
$displayMyList=false;
if (($usrObj->userroleid == USERROLE_ORG) or ($usrObj->userroleid == USERROLE_DEVELOPER))
{
$table->setFilter(" AND (l.visibility=".VISIBLE_ALL." OR l.visibility=".VISIBLE_ORG.") ");
} else {
$table->setFilter(" AND l.visibility=".VISIBLE_ALL." ");
}
}
if (isset($_GET['offset'])) { $sqlOffset=$_GET['offset']; } else {$sqlOffset=0;}
if (isset($_GET['numrows'])) { $sqlNumrows=$_GET['numrows']; } else {$sqlNumrows=0;}
$thisuri=$_SERVER['REQUEST_URI'];
print '<h1>';
if ($displayMyList)
{
print $l->get('loco-mylocos-title','Liste meiner Tfz');
} else {
print $l->get('loco-alllocos-title','Liste aller Tfz');
}
print '</h1>'.$nl;
$self="locolist.php?";
if ($displayMyList) $self .= "mylist"; else $self .= "alllist";
$table->setURI($self);
print '<form action="lococard.php" method="POST"';
if ($openPdfInNewWindow) { print ' target="_blank" '; }
print '>';
$result=$table->displayHeader(true,true,$sqlOffset,$sqlNumrows);
$table->displayRows();
echo '<p>';
$titleText = $l->get('loco-card-button','FRED-Karten erzeugen');
echo '<input type=Submit value="'.$titleText.'" name="lococard">';
echo '</p>';
echo '</form>';
$table->displayFooter();
print '<p>'.$l->getTranslationHelperUI().'</p>';
print '</body></html>';
?>