Location: PHPKode > scripts > Purple Beanie Web Booking For Joomla > com_pbbooking/admin/controllers/timeslot.php
<?php
/**
 * @package    PurpleBeanie.PBBooking
 * @subpackage Components
 * @link http://www.purplebeanie.com
 * @license    GNU/GPL
 */
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport('joomla.application.component.controller');
 
/**
 * PBBooking Component Controller
 *
 * @package    PurpleBeanie.PBBooking
 * @subpackage Components
 */

class PbbookingsControllertimeslot extends JController
{
	
	/**
	 * constructor (registers additional tasks to methods)
	 * @return void
	 */
	function __construct()
	{
	    parent::__construct();

	    // Register Extra tasks
	    $this->registerTask( 'add'  ,     'edit' );
	}
	
	/**
	 * display the edit form
	 * @return void
	 */
	function edit()
	{
	    JRequest::setVar( 'view', 'timeslot' );
	    JRequest::setVar( 'layout', 'form'  );
	    JRequest::setVar('hidemainmenu', 1);
		
		$cid = JRequest::getVar('cid');
		if ($cid) {
			$sql = "select * from #__pbbooking_slots where id = ".$cid[0];
			$db =& JFactory::getDBO();
			$db->setQuery( $sql );
			$timeslot = $db->loadAssocList();
			JRequest::setVar('timeslot',$timeslot[0]);
		} else {
			$timeslot = Array("english"=>"","start_hour"=>0,"start_min"=>0,"end_hour"=>0,"end_min"=>0,"id"=>0);
			JRequest::setVar('timeslot',$timeslot);
		}

	    parent::display();
	}
	
	function save()
	{
		$english = JRequest::getVar('english');
		$start_hour = JRequest::getVar('start_hour');
		$start_min = JRequest::getVar('start_min');
		$end_hour = JRequest::getVar('end_hour');
		$end_min = JRequest::getVar('end_min');
		$id = JRequest::getVar('id');
		if ($id !=0) {
			$sql = sprintf("update #__pbbooking_slots set english = '%s',start_hour=%s,start_min=%s,end_hour=%s,end_min=%s where id = %s",
				$english,$start_hour,$start_min,$end_hour,$end_min,$id);
			//echo $sql;
		} else {
			$sql = sprintf("insert into #__pbbooking_slots (english,start_hour,start_min,end_hour,end_min) values
				('%s',%s,%s,%s,%s)",$english,$start_hour,$start_min,$end_hour,$end_min,$id);
			//echo $sql;
		}
		$db =& JFactory::getDBO();
		$db->setQuery($sql);
		$db->Execute($sql);
		$this->setRedirect( 'index.php?option=com_pbbooking', null );
	}
	
	function remove()
	{
		$ids = JRequest::getVar('cid');
		foreach ($ids as $id) 
		{
			$sql = sprintf("delete from #__pbbooking_slots where id = %s",$id);
			//echo $sql;
			$db =& JFactory::getDBO();
			$db->setQuery($sql);
			$db->Execute($sql);
		}
		$this->setRedirect( 'index.php?option=com_pbbooking', null );
	}

}
Return current item: Purple Beanie Web Booking For Joomla