<?php 

add_action('dslc_hook_register_modules',
     create_function('', 'return dslc_register_module( "Ainex_Pricing_Table_2" );')
);

class Ainex_Pricing_Table_2 extends DSLC_Module {
 		
 	// Module Attributes
    var $module_id = 'Ainex_Pricing_Table_2';
    var $module_title = 'Pricing Table 2';
    var $module_icon = 'dollar';
    var $module_category = 'Ainex - Pricing Table';
 
 	// Module Options
    function options() { 
				
    	// The options array
    	$dslc_options = array(
			array(
				'label' => 'Columns - Pricing Table 2',
				'id' => 'columns',
				'std' => '4',
				'type' => 'select',
				'section' => 'styling',
				'choices' => array(
					array(
						'label' => '3 Columns',
						'value' => '3'
					),
					array(
						'label' => '4 Columns',
						'value' => '4'
					),
				)
			),

			/*
			 * Column 1
			*/
			array(
				'label' => 'Title',
				'id' => 'title1',
				'std' => 'Economy',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Content',
				'id' => 'content1',
				'std' => 'Unlimited Bandwidth
				    100 GB Space
				    10 Databases
				    Free Ad Credits
				    One Free Domain
				    24/7 Unlimited Support
				    100 Email Addresses',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency1',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Price',
				'id' => 'price1',
				'std' => '3.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per1',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 1',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext1',
				'std' => 'Order Now',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link1',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights1',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 1',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),

			/*
			 * Column 2
			*/
			array(
				'label' => 'Title',
				'id' => 'title2',
				'std' => 'Standard',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Content',
				'id' => 'content2',
				'std' => 'Unlimited Bandwidth
				    Unlimited Space
				    100 Databases
				    Free Ad Credits
				    2 Free Domains
				    24/7 Unlimited Support
				    1000 Email Addresses',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency2',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Price',
				'id' => 'price2',
				'std' => '9.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per2',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 2',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext2',
				'std' => 'Order Now',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link2',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights2',
				'std' => '1',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 2',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),

			/*
			 * Column 3
			*/
			array(
				'label' => 'Title',
				'id' => 'title3',
				'std' => 'Professional',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Content',
				'id' => 'content3',
				'std' => 'Unlimited Bandwidth
					Unlimited Space
					1000 Databases
					Free Ad Credits
					5 Free Domain
					24/7 Unlimited Support
					  Unlimited    Emails',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency3',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Price',
				'id' => 'price3',
				'std' => '18.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per3',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 3',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext3',
				'std' => 'Order Now',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link3',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights3',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 3',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),

			/*
			 * Column 4
			*/
			array(
				'label' => 'Title',
				'id' => 'title4',
				'std' => 'Ultimate',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Content',
				'id' => 'content4',
				'std' => 'Unlimited Bandwidth
				    Unlimited Space
				    Unlimited Databases
				    Free Ad Credits
				    10 Free Domain
				    24/7 Unlimited Support
				    Unlimited Emails',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency4',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Price',
				'id' => 'price4',
				'std' => '60.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per4',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 4',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext4',
				'std' => 'Order Now',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link4',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights4',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 4',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),
		);

		$dslc_options = array_merge( $dslc_options, $this->shared_options('animation_options') );
		
    	// Return the array
    	return apply_filters( 'dslc_module_options', $dslc_options, $this->module_id );

    }
 
 	// Module Output
    function output( $options ) {

    	global $dslc_active;
    	
		if ( $dslc_active && is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) )
			$dslc_is_admin = true;
		else
			$dslc_is_admin = false;
		
		//REQUIRED
		$this->module_start( $options );

	?>
	
	<div class="pricing-tables-main">
		<?php if($options['columns']==4){ ?>
			<?php for($i=1; $i<5; $i++){ ?>
				<div class="pricing-tables<?php if($options['highlights'.$i]==1){ echo '-helight'; } ?>">
	            	<div class="title"><?php echo $options['title'.$i]; ?></div>
	                <div class="price"><?php echo $options['currency'.$i].$options['price'.$i]; ?> <i>/ <?php echo $options['price_per'.$i]; ?></i></div>
	                <div class="cont-list">
	                	<ul>
	                        <?php 
								$content = stripcslashes( $options['content'.$i] );
								$content = trim($content);
								$items   = preg_split( '/\r\n|\r|\n/', $content );

								$output = '';
								$dem    = 1;
								foreach($items as $item){
									if ($dem==count($items)) {
										$output .= '<li class="last">&nbsp;' . htmlspecialchars_decode( $item ) . '</li>';
									} else {
										$output .= '<li>' . htmlspecialchars_decode( $item ) . '</li>';
									}
									$dem++;
								}
								
								echo $output;
							?>
	                    </ul>
	                </div>
	                <div class="ordernow"><a href="<?php echo $options['button_link'.$i]; ?>" class="<?php if($options['highlights'.$i]==1){ echo 'colorchan'; } else { echo 'normalbut'; } ?>"><?php echo $options['buttontext'.$i] ?></a></div>
	            </div>
		    <?php } ?>
		<?php } else { ?>
			<?php for($i=1; $i<4; $i++){ ?>
				<div class="pricing-tables<?php if($options['highlights'.$i]==1){ echo '-helight'; } ?>-two">
	            	<div class="title"><?php echo $options['title'.$i]; ?></div>
	                <div class="price"><?php echo $options['currency'.$i].$options['price'.$i]; ?> <i>/ <?php echo $options['price_per'.$i]; ?></i></div>
	                <div class="cont-list">
	                	<ul>
	                        <?php 
								$content = stripcslashes( $options['content'.$i] );
								$content = trim($content);
								$items   = preg_split( '/\r\n|\r|\n/', $content );

								$output = '';
								$dem    = 1;
								foreach($items as $item){
									if ($dem==count($items)) {
										$output .= '<li class="last">&nbsp;' . htmlspecialchars_decode( $item ) . '</li>';
									} else {
										$output .= '<li>' . htmlspecialchars_decode( $item ) . '</li>';
									}
									$dem++;
								}
								
								echo $output;
							?>
	                    </ul>
	                </div>
	                <div class="ordernow"><a href="<?php echo $options['button_link'.$i]; ?>" class="<?php if($options['highlights'.$i]==1){ echo 'colorchan'; } else { echo 'normalbut'; } ?>"><?php echo $options['buttontext'.$i] ?></a></div>
	            </div>
		    <?php } ?>
		<?php } ?>
	</div>
	<div class="clearfix"></div>
	<?php
    	// REQUIRED
    	$this->module_end( $options );

    }
 
}