2004-12-20 16:35:15 +00:00
< ?
require ( " ../common.inc.php " );
2004-12-20 17:03:48 +00:00
send_header ( " Configuration - Project Divisions " );
2004-12-20 16:35:15 +00:00
echo " <a href= \" index.php \" ><< " . i18n ( " Back to Configuration " ) . " </a><br /> " ;
2004-12-20 17:03:48 +00:00
if ( $_POST [ 'action' ] == " edit " )
2004-12-20 16:35:15 +00:00
{
2004-12-20 17:03:48 +00:00
if ( $_POST [ 'id' ] && $_POST [ 'division' ] )
{
$q = mysql_query ( " SELECT id FROM projectdivisions WHERE id=' " . $_POST [ 'id' ] . " ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
if ( mysql_num_rows ( $q ) && $_POST [ 'saveid' ] != $_POST [ 'id' ])
{
echo error ( i18n ( " Division ID %1 already exists " , array ( $_POST [ 'id' ])));
}
else
{
mysql_query ( " UPDATE projectdivisions SET " .
" id=' " . $_POST [ 'id' ] . " ', " .
2005-01-13 23:59:22 +00:00
" division=' " . mysql_escape_string ( stripslashes ( $_POST [ 'division' ])) . " ', " .
" division_shortform=' " . mysql_escape_string ( stripslashes ( $_POST [ 'division_shortform' ])) . " ' " .
2004-12-20 17:03:48 +00:00
" WHERE id=' " . $_POST [ 'saveid' ] . " ' " );
echo happy ( i18n ( " Division successfully saved " ));
}
}
else
{
echo error ( i18n ( " All fields are required " ));
}
}
if ( $_POST [ 'action' ] == " new " )
{
if ( $_POST [ 'id' ] && $_POST [ 'division' ])
{
$q = mysql_query ( " SELECT id FROM projectdivisions WHERE id=' " . $_POST [ 'id' ] . " ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
if ( mysql_num_rows ( $q ))
{
echo error ( i18n ( " Division ID %1 already exists " , array ( $_POST [ 'id' ])));
}
else
{
2005-01-13 23:59:22 +00:00
mysql_query ( " INSERT INTO projectdivisions (id,division,division_shortform,year) VALUES ( " .
2004-12-20 17:03:48 +00:00
" ' " . $_POST [ 'id' ] . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'division' ])) . " ', " .
2005-01-13 23:59:22 +00:00
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'division_shortform' ])) . " ', " .
2004-12-20 17:03:48 +00:00
" ' " . $config [ 'FAIRYEAR' ] . " ') " );
echo happy ( i18n ( " Division successfully added " ));
}
}
else
{
echo error ( i18n ( " All fields are required " ));
}
}
if ( $_GET [ 'action' ] == " remove " && $_GET [ 'remove' ])
{
mysql_query ( " DELETE FROM projectdivisions WHERE id=' " . $_GET [ 'remove' ] . " ' " );
echo happy ( i18n ( " Division successfully removed " ));
2004-12-20 16:35:15 +00:00
}
echo " <form method= \" post \" action= \" " . $_SERVER [ 'PHP_SELF' ] . " \" > " ;
2004-12-20 18:31:42 +00:00
echo " <h3> " . i18n ( " Project Divisions " ) . " </h3> " ;
2004-12-20 17:03:48 +00:00
if ( ! ( $_GET [ 'action' ] == " edit " || $_GET [ 'action' ] == " new " ) )
echo " <a href= \" " . $_SERVER [ 'PHP_SELF' ] . " ?action=new \" > " . i18n ( " Add new division " ) . " </a> \n " ;
2004-12-20 16:35:15 +00:00
echo " <table class= \" summarytable \" > " ;
echo " <tr> " ;
2004-12-20 17:03:48 +00:00
echo " <th> " . i18n ( " Division ID " ) . " </th> \n " ;
echo " <th> " . i18n ( " Division Name " ) . " </th> \n " ;
2005-01-13 23:59:22 +00:00
echo " <th> " . i18n ( " Short Form " ) . " </th> \n " ;
2004-12-20 16:35:15 +00:00
echo " <th> " . i18n ( " Actions " ) . " </th> \n " ;
echo " </tr> " ;
2004-12-20 17:03:48 +00:00
if ( $_GET [ 'action' ] == " edit " || $_GET [ 'action' ] == " new " )
2004-12-20 16:35:15 +00:00
{
2004-12-20 17:03:48 +00:00
echo " <input type= \" hidden \" name= \" action \" value= \" " . $_GET [ 'action' ] . " \" > \n " ;
if ( $_GET [ 'action' ] == " edit " )
{
echo " <input type= \" hidden \" name= \" saveid \" value= \" " . $_GET [ 'edit' ] . " \" > \n " ;
$q = mysql_query ( " SELECT * FROM projectdivisions WHERE id=' " . $_GET [ 'edit' ] . " ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
$divisionr = mysql_fetch_object ( $q );
$buttontext = " Save " ;
}
else if ( $_GET [ 'action' ] == " new " )
{
$buttontext = " Add " ;
}
echo " <tr> " ;
2005-01-13 23:59:22 +00:00
echo " <td><input type= \" text \" size= \" 3 \" name= \" id \" value= \" $divisionr->id\ " /></ td > " ;
echo " <td><input type= \" text \" size= \" 40 \" name= \" division \" value= \" $divisionr->division\ " /></ td > " ;
echo " <td align= \" center \" ><input type= \" text \" size= \" 5 \" name= \" division_shortform \" value= \" $divisionr->division_shortform\ " /></ td > " ;
echo " <td><input type= \" submit \" value= \" " . i18n ( $buttontext ) . " \" /></td> " ;
2004-12-20 16:35:15 +00:00
echo " </tr> " ;
}
2004-12-20 17:03:48 +00:00
else
{
$q = mysql_query ( " SELECT * FROM projectdivisions WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY division " );
while ( $r = mysql_fetch_object ( $q ))
{
echo " <tr> " ;
echo " <td> $r->id </td> " ;
echo " <td> $r->division </td> " ;
2005-01-13 23:59:22 +00:00
echo " <td align= \" center \" > $r->division_shortform </td> " ;
2004-12-20 17:03:48 +00:00
echo " <td> " ;
echo " <a title= \" Edit \" href= \" " . $_SERVER [ 'PHP_SELF' ] . " ?action=edit&edit= $r->id\ " >< img src = \ " " . $config [ 'SFIABDIRECTORY' ] . " /images/16/edit. " . $config [ 'icon_extension' ] . " \" border=0></a> " ;
echo " " ;
echo " <a title= \" Remove \" onClick= \" return confirmClick('Are you sure you want to remove this division?'); \" href= \" " . $_SERVER [ 'PHP_SELF' ] . " ?module= $module &action=remove&remove= $r->id\ " >< img src = \ " " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" border=0></a> " ;
echo " </td> " ;
echo " </tr> " ;
}
}
2004-12-20 16:35:15 +00:00
echo " </table> " ;
echo " </form> " ;
2005-01-21 17:30:28 +00:00
echo i18n ( " You should assign the 'Division ID's in numerical order, starting with 1. This Division ID is used to generate the project number " );
2004-12-20 16:35:15 +00:00
send_footer ();
?>