<?php $__env->startSection('page_title'); ?>
    OSAA Staff
<?php $__env->stopSection(); ?>

<?php $__env->startSection('header'); ?>
	Mass E-mail Lists
<?php $__env->stopSection(); ?>

<?php $__env->startSection('jquery_init'); ?>    	

	$('input[type="checkbox"]').css('vertical-align', 'middle');

	$('.button.all').button({ icons : { primary : 'ui-icon-check'}});
	$('.button.none').button({ icons : { primary : 'ui-icon-cancel'}});
	$('.button.create')
		.button({ icons : { primary : 'ui-icon-play'}})
		.css('font-size', '11pt');

	$('.button.create_contacts')
		.button({ icons : { primary : 'ui-icon-play'}})
		.css('font-size', '11pt');

	$('table tbody tr:even').css('background-color', '#f2f2f2');
	
	$("#schools tbody tr[is_retired]").css('background-color', '#7d7b7d');

	function update_select_info ()
	{
		var total = <?php echo count($information['schools']); ?>;

		var selected = $('input[data-school]:checked').size();

		var text = "(" + selected + " of " + total + " selected)";

		$('#select_info').html(text);
	}

	update_select_info();

	$('input[data-school]').change(function ()
	{	    
		update_select_info();
	});

	$('.button.all').click(function ()
	{
		$('input[data-school]').each(function ()
		{
			if (!$(this).is(':checked'))
			{
				$(this).click();
			}
		});

		update_select_info();
	});

	$('.button.none').click(function ()
	{
		$('input[data-school]').each(function ()
		{
			if ($(this).is(':checked'))
			{
				$(this).click();
			}
		});

		update_select_info();
	});

	$('.button.create').click(function ()
	{
		$('form.mail_list_creator').submit();		
	}).hover(
		function ()
		{
			$(this).addClass('ui-state-active');
		},
		function ()
		{
			$(this).removeClass('ui-state-active');
		}
	);

	$('.button.create_contacts')
		.hover(
			function ()
			{
				$(this).addClass('ui-state-active');
			},
			function ()
			{
				$(this).removeClass('ui-state-active');
			}
		)
		.click(function ()
		{
			var form = $('form.mail_list_creator');

			var input = $('<input />')
						    .attr('type', 'hidden')
						    .attr('name', 'contacts')
						    .attr('value', 'true')
						    .appendTo(form);

			form.submit();
		});
		

	$('.button.classification').click(function ()
	{
		var classification = $(this).attr('data-classification');

		$("input[data-school][data-classification='" + classification + "']").each(function ()
		{
			if (!$(this).is(':checked'))
			{
				$(this).click();
			}
		});

		update_select_info();
	});

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
	<div class="admin_page" style="height:100%; min-height:860px; font-size:11pt; padding: 1em 1.4em; background-color:#ffffff;">

		<h1>Create a Mass E-mail List</h1>
		
		<?php echo Form::open(array('url'    => url('/admin/downloadEmailList'),
				            'method' => 'POST',
				            'class'	 => 'mail_list_creator')); ?>
			<div class="columns">

				<div class="fourth">

					<h2>Select School(s)</h2>
					
					<div class="button all" style="font-size: 8pt; display: inline-block;">Select All</div>
					<div class="button none" style="font-size: 8pt; display: inline-block;">Select None</div>					

					<br /><br />

					<div style="display: block; font-weight: bold;">
						Add All Schools in Classification
					</div>
					<div class="button classification" data-classification="6A" style="font-size: 8pt; display: inline-block;">6A</div>
					<div class="button classification" data-classification="5A" style="font-size: 8pt; display: inline-block;">5A</div>
					<div class="button classification" data-classification="4A" style="font-size: 8pt; display: inline-block;">4A</div>
					<div class="button classification" data-classification="3A" style="font-size: 8pt; display: inline-block;">3A</div>
					<div class="button classification" data-classification="2A" style="font-size: 8pt; display: inline-block;">2A</div>
					<div class="button classification" data-classification="1A" style="font-size: 8pt; display: inline-block;">1A</div>	

					<br /><br />			
								
					<div class="school_select">
						<?php if (count($information['schools']) > 0): ?>

							<?php $i = 0; ?>
					    	<?php foreach ($information['schools'] as $school): ?>

					    		<div class="school <?php if ($i % 2 == 1): ?> odd <?php endif; ?>">
						    		<?php echo Form::checkbox('school_' . $school->id,
						    						  true,
						    						  false,
						    						  array('data-school'         => 'true',
						    						  		'id'                  => 'school_' . $school->id,
						    						  		'data-classification' => $school->classification)); ?>
						    		<?php echo Form::label('school_' . $school->id, $school->name); ?>
					    		</div>
					    		
					    		<?php $i++; ?>

					    	<?php endforeach; ?>
					    <?php else: ?>
					    	There are no member schools to select.
					    <?php endif; ?>
					</div>

					<br />

					<div id="select_info" style="font-size: 10pt; display:inline-block;"></div>
				</div>

				<div class="half">
					<h2>Select Administrative Role(s)</h2>
					<div class="select_admin_roles columns">

						<div class="half">

							<?php $i = 0; ?>
							<?php foreach ($information['admin_role_select'] as $key => $value): ?>

								<?php echo Form::checkbox('role_' . $value,
												  true,
												  false,
												  array('data-role-admin' => 'true',
												  		'id'              => 'role_' . $value)); ?>
								<?php echo Form::label('role_' . $value, $value); ?>

								<br />

								<?php
								    $i++;

								    if ($i == count($information['admin_role_select']) / 2)
								    {
								    	echo '</div><div class="half">';
								    }
								?>

							<?php endforeach; ?>
						
						</div>										

					</div>

					<br class="clear" />
					<br />
					<br />

					<h2>Select Activity Specific Role(s)</h2>
					<div class="select_activity_roles columns">						
						
						<?php foreach ($information['coach_role_select'] as $key => $value): ?>

							<div class="fourth">
								<?php echo Form::checkbox('coach_' . $value,
												  true,
												  false,
												  array('data-role-admin' => 'true',
												  		'id'              => 'coach_' . $value)); ?>
								<?php echo Form::label('coach_' . $value, $value); ?>
							</div>							

						<?php endforeach; ?>								

					</div>

					<br class="clear" />
					<br />
					<br />

					<h2>Select Activity(ies)</h2>
					<div class="select_activity columns">						
						
						<div class="third">
							<?php foreach ($information['activities'] as $key => $value): ?>
							
								<?php if (Helpers::strEqual($key, array('BBX', 'BBL'))): ?>
									</div>
									<div class="third">
								<?php endif; ?>

								<?php echo Form::checkbox('act_' . $key,
												  true,
												  false,
												  array('data-role-admin' => 'true',
												  		'id'              => 'act_' . $key)); ?>
								<?php echo Form::label('act_' . $key, $value); ?>	
								<br />											

							<?php endforeach; ?>								
						</div>

					</div>

					<h2>Filter Schools Offering an Activity</h2>
					<div class="columns" style="font-size:12pt;">
						<div class="fourth text_center">
							<?php echo Form::checkbox('filter_activity', true, false, array('class' => 'button',
																					'id'    => 'filter_activity')); ?>
							<?php echo Form::label('filter_activity', 'Filter Activity', array('style' => 'font-size: 10pt;')); ?>
						</div>

						<div class="half">
							Select this option to further filter the list of selected schools to only those that are
							also offering the activity or activities selected above.
						</div>
					</div>

				</div>

				<div class="fourth" style="font-size: 12pt;">
					<h2>Instructions</h2>
					<p class="small">
						First, select the schools you want to e-mail.  Click "Select All" to select all member schools.  Click "Select None" to clear all selections and essentially start over.  The total number of schools selected is shown below the list of schools.
					</p>					
					<br />
					<p class="small">
						You can also add to your school selections all schools within one or more classifications by clicking the corresponding buttons.
					</p>
					<br />
					<p class="small">
						Next, you need to specify who should be receiving the e-mail for the selected schools.  Selecting an administrative role will add all individuals matching that position for each selected school.  
					</p>
					<br />
					<p class="small">
						You can also select activity specific roles.  If you do not specify any activities, then all sport coaches or managers will be collected and added to the list.
					</p>
					<br />
					<p class="small">
						If you want to limit the select schools further to only those that offer a specific activity or several activities, you can click the "Filter Activity" button.
					</p>

					<br />
					<br />

					<?php if (Session::has('errors')): ?>						
						<div class="error ui-state-error" style="font-size:12pt;"><span class="ui-icon ui-icon-alert box_icon"></span><?php foreach ($errors->all() as $error): ?><?php echo $error; ?> <?php endforeach; ?></div>   
						<br />
					<?php endif; ?>		
					
					<h2>Create List</h2>
					<div class="button create">Download BCC List</div>
					<br /><br />
					<p class="small">
						This will download a text file with the compiled e-mail list (showing names and skipping duplicates.)  Select all (CTRL + A), copy (CTRL + C), then paste (CTRL + V) into the BCC filed in a new e-mail.
					</p>

					<br />
					
					<div class="button create_contacts">Download Contacts</div>
					<br /><br />
					<p class="small">
						This will download a CSV file with the compiled e-mail contacts that you can upload into Outlook.
					</p>							

				</div>

			</div>

		<?php echo Form::close(); ?>
		
	</div>

<?php $__env->stopSection(); ?>