<?php
/**
* @version 1.0.0
* @package RStickets! 1.0.0
* @copyright (C) 2007-2008 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined('_JEXEC') or die('Restricted access');

class rstickets_HTML
{


//////////////////////////////////////// CONTROL PANEL ////////////////////////////////////////

/**
 * Display the main component control panel
 */
function controlPanel()
{
	global $option, $T_SETTINGS;

	$RST_adapter = $GLOBALS['RST_adapter'];

    //$RST_adapter=new RST_adapter();
    $RST_adapter->addHeadTag(RST_BACKEND_REL_PATH.'/style.css','css');
    ?>
    <form action="<?php echo RST_BACKEND_SCRIPT_PATH;?>" method="post" name="adminForm">
    <table class="thisform">
   		<tr class="thisform">
      		<td width="50%" valign="top" class="thisform">
      			<table width="100%" class="thisform2" border="1">
					<tr class="thisform2">
						<td align="center" height="100px" width="33%" class="thisform2">
				            <a href="<?php echo RST_BACKEND_SCRIPT_PATH;?>?option=com_rstickets&task=departments" style="text-decoration:none;" title="<?php echo RST_BACKEND_CPANEL_DEPARTMENTS;?>">
				            <img src="components/com_rstickets/images/categories.png" width="48px" height="48px" align="middle" border="0"/>
				            <br />
				            <?php echo RST_BACKEND_CPANEL_DEPARTMENTS;?>
				            </a>
						</td>
						<td align="center" height="100px" width="33%" class="thisform2">
				            <a href="<?php echo RST_BACKEND_SCRIPT_PATH;?>?option=com_rstickets&task=groups" style="text-decoration:none;" title="<?php echo RST_BACKEND_CPANEL_GROUPS;?>">
				            <img src="components/com_rstickets/images/groups.png" width="48px" height="48px" align="middle" border="0"/>
				            <br />
				            <?php echo RST_BACKEND_CPANEL_GROUPS;?>
				            </a>
						</td>
						<td align="center" height="100px" width="33%" class="thisform2">
				            <a href="<?php echo RST_BACKEND_SCRIPT_PATH;?>?option=com_rstickets&task=staff" style="text-decoration:none;" title="<?php echo RST_BACKEND_CPANEL_STAFF;?>">
				            <img src="components/com_rstickets/images/staff.png" width="48px" height="48px" align="middle" border="0"/>
				            <br />
				            <?php echo RST_BACKEND_CPANEL_STAFF;?>
				            </a>
						</td>
					</tr>
      				<tr class="thisform2">
	      				<td align="center" height="100px" class="thisform2">
				            <a href="<?php echo RST_BACKEND_SCRIPT_PATH;?>?option=com_rstickets&task=settings" style="text-decoration:none;" title="<?php echo RST_BACKEND_CPANEL_CONFIGURATION_EDIT;?>">
				            <img src="components/com_rstickets/images/config.png" width="48px" height="48px" align="middle" border="0"/>
				            <br />
				            <?php echo RST_BACKEND_CPANEL_CONFIGURATION_EDIT;?>
				            </a>
						</td>
	      				<td align="center" height="100px" class="thisform2">
				            <a href="<?php echo RST_BACKEND_SCRIPT_PATH;?>?option=com_rstickets&task=updates.manage" style="text-decoration:none;" title="<?php echo RST_BACKEND_CPANEL_UPDATES_MANAGE;?>">
				            <img src="components/com_rstickets/images/restore.png" width="48px" height="48px" align="middle" border="0"/>
				            <br />
				            <?php echo RST_BACKEND_CPANEL_UPDATES_MANAGE;?>
				            </a>
						</td>
	      				<td align="center" height="100px" width="33%" class="thisform2">
				            <a href="http://www.rsjoomla.com/index.php/Customer-Support.html" style="text-decoration:none;" title="<?php echo RST_BACKEND_CPANEL_SUPPORT;?>" target="_blank">
				            <img src="components/com_rstickets/images/support.png" width="48px" height="48px" align="middle" border="0"/>
				            <br />
				            <?php echo RST_BACKEND_CPANEL_SUPPORT;?>
				            </a>
						</td>
					</tr>
					<tr class="thisform2">
						<td align="center" height="100px" width="33%" class="thisform2">
				            <a href="<?php echo RST_FRONTEND_SCRIPT_PATH;?>?option=com_rstickets" style="text-decoration:none;" title="<?php echo RST_BACKEND_CPANEL_FRONTEND;?>" target="_blank">
				            <img src="components/com_rstickets/images/frontpage.png" width="48px" height="48px" align="middle" border="0"/>
				            <br />
				            <?php echo RST_BACKEND_CPANEL_FRONTEND;?>
				            </a>
						</td>
					</tr>
				</table>

			</td>
		    <td width="50%" valign="top" align="center">

			    <table border="1" width="100%" class="thisform">
					<tr class="thisform">
			            <th class="cpanel" colspan="2"><?php echo RST_PRODUCT . ' ' . RST_VERSION. ' rev ' . RST_REVISION;?></th></td>
			         </tr>
			         <tr class="thisform"><td bgcolor="#FFFFFF" colspan="2"><br />
			      <div style="width=100%" align="center">
			      <img src="components/com_rstickets/images/rstickets.jpg" align="middle" alt="RStickets! Logo"/>
			      <br /><br /></div>
			      </td></tr>
			         <tr class="thisform">
			            <td width="120" bgcolor="#FFFFFF"><?php echo RST_VERSION_TITLE;?></td>
			            <td bgcolor="#FFFFFF"><?php echo RST_VERSION;?></td>
			         </tr>
			         <tr class="thisform">
			            <td bgcolor="#FFFFFF">Copyright:</td>
			            <td bgcolor="#FFFFFF"><?php echo RST_COPYRIGHT;?></td>
			         </tr>
			         <tr class="thisform">
			            <td bgcolor="#FFFFFF">License:</td>
			            <td bgcolor="#FFFFFF"><?php echo RST_LICENSE;?></td>
			         </tr>
			         <tr class="thisform">
			            <td valign="top" bgcolor="#FFFFFF"><?php echo RST_AUTHOR_TITLE;?></td>
			            <td bgcolor="#FFFFFF">
			            <?php echo RST_AUTHOR;?>
						</td>
			         </tr>
			         <tr class="<?php echo $T_SETTINGS['License_Code']=='' ? 'thisformError' : 'thisformOk'; ?>">
						<td valign="top">
							<?php echo RST_CODE_TITLE;?>
						</td>
						<td>
							<?php echo $T_SETTINGS['License_Code']=='' ? '<input type="text" name="License_Code" value=""/>' : $T_SETTINGS['License_Code']; ?>
						</td>
			         </tr>
			         <tr class="<?php echo $T_SETTINGS['License_Code']=='' ? 'thisformError' : 'thisformOk'; ?>">
						<td valign="top">&nbsp;</td>
						<td>
							<?php if ($T_SETTINGS['License_Code']=='') { ?>
							<input type="submit" name="register" value="<?php echo RST_REGISTER; ?>" /><br/>
							<?php } else { ?>
							<input type="button" name="modify_register" value="<?php echo RST_REGISTER_MODIFY;?>" onclick="javascript:document.location = '<?php echo RST_BACKEND_SCRIPT_PATH;?>?option=com_rstickets&task=settings';"/><br/>
							<?php } ?>
						</td>
			         </tr>
			         <tr class="<?php echo $T_SETTINGS['License_Code']=='' ? 'thisformError' : 'thisformOk';?>">
			         	<td colspan="2">
			         		<?php if(RST_REVISION == 'TRYOUT') echo RST_CODE_TRYOUT; ?>
			         	</td>
			         </tr>
			      </table>
				  <p align="center"><a href="http://www.rsjoomla.com/joomla-components/joomla-security.html" target="_blank"><img src="components/com_rstickets/images/rsfirewall-approved.gif" align="middle" alt="RSFirewall! Approved"/></a></p>
		      </td>
		   </tr>
		</table>
		<input type="hidden" name="option" value="<?php echo $option;?>" />
		<input type="hidden" name="task" value="saveRegistration" />
	</form>
<?php
}



//////////////////////////////////////// UPDATES ////////////////////////////////////////

	function updatesManage($option)
	{
		$RST_adapter = $GLOBALS['RST_adapter'];
		$RST_adapter->addHeadTag( RST_BACKEND_REL_PATH."/style.css",'css' );
 		$RST_adapter->addHeadTag( RST_FRONTEND_REL_PATH.'/js/script.js','js' );

    ?>

		<form enctype="multipart/form-data" action="<?php echo RST_BACKEND_SCRIPT_PATH;?>" method="post" name="adminForm">
		<table class="adminform">
            <tr>
                <th>
                    Checking for updates
                </th>
            </tr>
		    <tr>
			    <td>
				    <iframe src="http://www.rsjoomla.com/index.php?option=com_rshelp&task=rev.check&sess=<?php echo rstickets_HTML::genKeyCode();?>&amp;rev=<?php echo RST_REVISION;?>&amp;Itemid=43&amp;joomla=<?php echo $RST_adapter->version;?>" style="border:0px solid;width:100%;height:18px;" scrolling="no"></iframe>
			    </td>
		    </tr>
		</table>
        <br />
        <table class="adminform">
            <tr>
                <th>
                <?php echo RST_BACKEND_UPDATESMANAGE_UPDATE_TITLE;?>
                </th>
            </tr>
            	<?php
            	//check permissions
            	if(is_writable($RST_adapter->getConfig('absolute_path').'/administrator/components/com_rstickets/')&&is_writable($RST_adapter->getConfig('absolute_path').'/components/com_rstickets/')){
            	?>
            <tr>
                <td align="left">                
                <?php echo RST_BACKEND_UPDATESMANAGE_UPDATE_FILE;?>
                <input class="text_area" name="userfile" type="file" size="70"/>
                <input class="button" type="button" value="<?php echo RST_BACKEND_UPDATESMANAGE_BUTTON;?>" onclick="if (confirm('Please read the following:\nIf you have made any changes to the RSTickets! files, your files will be overwritten after this update (even language or css files). So please make sure you backup any files you have modified from the components/com_rstickets and administrator/components/com_rstickets directories.\nYour current settings and uploaded files will remain untouched.')) submitbutton('update.upload.process')"/>
                </td>
            </tr>
            <tr>
                <td align="left">
                <?php echo RST_BACKEND_UPDATESMANAGE_INSTRUCTIONS;?>
                </td>
            </tr>
            	<?php
            	}else{
            	?>
            <tr>
                <td align="left">
                <?php 
                echo $RST_adapter->getConfig('absolute_path').'/administrator/components/com_rstickets/ '.(is_writable($RST_adapter->getConfig('absolute_path').'/administrator/components/com_rstickets/') ? RST_BACKEND_UPDATESMANAGE_WRITABLE:RST_BACKEND_UPDATESMANAGE_NOTWRITABLE).'<br/>';
                echo $RST_adapter->getConfig('absolute_path').'/components/com_rstickets/ '.(is_writable($RST_adapter->getConfig('absolute_path').'/components/com_rstickets/') ? RST_BACKEND_UPDATESMANAGE_WRITABLE:RST_BACKEND_UPDATESMANAGE_NOTWRITABLE).'<br/>';
                echo '<br/><br/>';
                echo RST_BACKEND_UPDATESMANAGE_PERMISSIONS;
                
                ?>
                </td>
           	</tr>
            	<?php	
            	}
            	?>
        </table>

		<input type="hidden" name="filetype" value="rstupdate"/>
		<input type="hidden" name="task" value="update.upload.process"/>
		<input type="hidden" name="option" value="<?php echo $option;?>"/>
		</form>
		<?php
	}





	function genKeyCode(){
		$T_SETTINGS = $GLOBALS['T_SETTINGS'];
		return md5($T_SETTINGS['License_Code'].RST_KEY);
	}


}
?>