<?php
/**
 * @version		3.0.0
 * @package		JomLand TicketCenter
 * @copyright	Copyright (C) 2010 JomLand.com. All rights reserved.
 * @license		GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

class JLTicketCenterViewSetup extends JViewLegacy
{
	function display($tpl = null)
	{
		$mainframe = JFactory::getApplication();

		$task =  JRequest::getVar('task');

		if ($task=='add' ||$task=='edit' ){
			$this->edit($tpl);
			return;
		}

		JToolBarHelper::title(JText::_( 'Setup - JomLand TicketCenter' ), 'generic.png' );

		JToolBarHelper::save('save');

		$pparams = new JLTicketCenterHelperSetup;

		// Get data from the model
		$items	= $this->get('Data');
                
        $lang = JFactory::getLanguage();
        $extension = 'com_jlticketcenter';
        $base_dir = JPATH_SITE;
        $language_tag = $lang->getTag();
        $reload = true;
        $lang->load($extension, $base_dir, $language_tag, $reload);


		$links_select = array();
		$links_select['display_venue'] = $this->buildLinksSelect('display_venue', $items['display_venue']);
		$links_select['display_city'] = $this->buildLinksSelect('display_city', $items['display_city']);
		$links_select['display_state'] = $this->buildLinksSelect('display_state', $items['display_state']);
		$links_select['display_country'] = $this->buildLinksSelect('display_country', $items['display_country']);

		$hide_soldout = JHTML::_('select.genericlist', array(0=>JText::_('JNO'),1=>JText::_('JYES')), 'hide_soldout', null, $optKey = 'value', $optText = 'text',$items['hide_soldout']);
		$display_stock = JHTML::_('select.genericlist', array(0=>JText::_('JNO'),1=>JText::_('JYES')), 'display_stock', null, $optKey = 'value', $optText = 'text',$items['display_stock']);

		$images_on_tables = JHTML::_('select.genericlist', array(0=>JText::_('JNO'),1=>JText::_('JYES')), 'images_on_tables', null, $optKey = 'value', $optText = 'text',$items['images_on_tables']);


		$bcc_order_to_admin = JHTML::_('select.genericlist', array(0=>JText::_('JNO'),1=>JText::_('JYES')), 'bcc_order_to_admin', null, $optKey = 'value', $optText = 'text',$items['bcc_order_to_admin']);

		// push data into the template
		$this->assignRef('items',$items);
		$this->assignRef('hide_soldout',$hide_soldout);
		$this->assignRef('display_stock',$display_stock);
		$this->assignRef('images_on_tables',$images_on_tables );

		$this->assignRef('links_select', $links_select);
		$this->assignRef('params', $pparams);

		if(file_exists(JPATH_ADMINISTRATOR.'/components/com_jlticketcenter/views/setup/tmpl/default_fb.php')){
			$delivery_methods = $this->get('DeliveryMethods');
			$this->assignRef('delivery_methods', $delivery_methods);
		}

		if(file_exists(JPATH_ADMINISTRATOR.'/components/com_jlticketcenter/helpers/jlticketcenter_pro_helper.php')){
			JLoader::import('components.com_jlticketcenter.helpers.jlticketcenter_pro_helper',JPATH_ADMINISTRATOR);
			$commission= JLTicketCenterPro::displaySetupComission($items);
			$this->assignRef('commission', $commission);

			$admin_notify= JLTicketCenterPro::setupAdmin_notify($items);
			$this->assignRef('admin_notify', $admin_notify);
				
			$individual_tickets = JLTicketCenterPro::setupAdmin_individual_tickets($items);
			$this->assignRef('individual_tickets', $individual_tickets);
				

			$this->assignRef('individual_tickets', $individual_tickets);

			$tos_article = JLTicketCenterPro::setupTOS($items);
			$this->assignRef('tos_article', $tos_article);
				
			$pdf_tickets = JLTicketCenterPro::displaySetupPDFtickets($items);
			$this->assignRef('pdf_tickets', $pdf_tickets);
                        
            $cartFields = $this->buildCartFeildsSelectBox($items);
            $this->assignRef('cartFields', $cartFields);
                        
		}

		$smart_cart_manage = JHTML::_('select.genericlist', array(0=>JText::_('JNO'),1=>JText::_('JYES')), 'smart_cart_manage', null, $optKey = 'value', $optText = 'text',$items['smart_cart_manage']);
		$this->assignRef('smart_cart_manage', $smart_cart_manage);

		parent::display($tpl);

		JLTicketCenterController::renderinfo();
	}

	function buildLinksSelect($name,$value){

		$options   = array();
		$options[] = JHTML::_('select.option',0,JText::_('No'));
		$options[] = JHTML::_('select.option',1,JText::_('Yes'));
		$options[] = JHTML::_('select.option',2,JText::_('Events Link'));
		$options[] = JHTML::_('select.option',3,JText::_('Venues Link'));
			
		$dropdown = JHTML::_('select.genericlist',   $options, $name, 'class="inputbox"', 'value', 'text', $value);

		return $dropdown ;
	}//EOF

        
        function buildCartFeildsSelectBox($items){
            $cartFeildsSelectBoxes = array();
            
            
            $cartFeildsSelectBoxes['first_name'] = array('text'=>JText::_('FIRST_NAME'),
                                                        'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                'cart_first_name', 
                                                                null, 
                                                                $optKey = 'value', 
                                                                $optText = 'text',
                                                                (int)$items['cart_first_name'])
                                                        );
            
            $cartFeildsSelectBoxes['last_name'] = array('text'=>JText::_('LAST_NAME'),
                                                        'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_last_name', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_last_name'])
                                                        );
            
            $cartFeildsSelectBoxes['phone'] = array('text'=>JText::_('PHONE'),
                                                        'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_phone_num', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_phone_num'])
                                                        );
            
            $cartFeildsSelectBoxes['street'] = array('text'=>JText::_('STREET'),
                                                    'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_street', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_street'])
                                                        );
            
            $cartFeildsSelectBoxes['city'] = array('text'=>JText::_('CITY'),
                                                   'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_city', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_city'])
                                                        );
            
            $cartFeildsSelectBoxes['zipcode'] = array('text'=>JText::_('JLTC_CLIENT_ZIPCODE'),
                                                   'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_zip_code', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_zip_code'])
                                                        );
            
            $cartFeildsSelectBoxes['state'] = array('text'=>JText::_('STATE'),
                                                   'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_state', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_state'])
                                                        );
            $cartFeildsSelectBoxes['country'] = array('text'=>JText::_('COUNTRY'),
                                                   'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_country', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_country'])
                                                        );
            
            $cartFeildsSelectBoxes['hear_us'] = array('text'=>JText::_('JLTC_HEAR_ABOUT_US'),
                                                   'value'=>JHTML::_('select.genericlist', array(0=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_REQUIRE'),
                                                                                        1=>  JText::_('JLTC_CART_FEILDS_SETTING_REQUIRE'),
                                                                                        -1=>  JText::_('JLTC_CART_FEILDS_SETTING_NOT_DISPLAY'),
                                                                                    ), 
                                                                    'cart_hear_us', 
                                                                    null, $optKey = 'value',
                                                                    $optText = 'text',
                                                                    (int)$items['cart_hear_us'])
                                                        );
              
            return $cartFeildsSelectBoxes;
            
        }//EOF
}//EOC