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

<?php $__env->startSection('page_sub_title'); ?>    
    
    Edit OWWMP BIA Assessment Reconciliation Report Form

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

<?php $__env->startSection('scripts'); ?>
    @parent

    <style type="text/css">
    	h3 {
    		color: #1C43A6 !important;
    	}    	

    	.success_bar {
    		position: fixed;
    		top: 600px;
    		left: 0;
    		width: 100%;
    		padding: 0.25em 0;
    		line-height: 1.5em;
    		background-color: rgba(176, 255, 190, 0.0);
    		border-bottom: 2px solid rgba(13, 88, 27, 0.50);
    		border-top: 2px solid rgba(13, 88, 27, 0.50);
    		z-index: 500;
    	}

    	.success_bar .message {
    		width: 1200px;
    		margin: 0 auto;
    		font-size: 14pt;
    		color: #151515;
    	}    	

    	.page_functions {
    		width: auto !important;
    	}  

        .progress_alert {
            padding: 0.25em 0.5em;
            margin-bottom: 1em; 
            line-height: 32px; 
            font-size: 12pt; 
            font-weight: bold;
        }       
        
        .required {
            color: #990000;
            font-weight: bold;
        }

        .placeholder
        {
            color: #aaaaaa !important;
            font-weight: normal !important;
        }

        /* Status Progress Styles */
        .status_progress {
            position: relative;
            margin: 1.5em 0 1em 0;
            border: 1px solid #efefef;
            padding: 1em;
        }

        .status_title {
            position: absolute;
            top: -10px;
            color: #d9d9d9;
            padding: 0 10px;
            background-color: #ffffff;
            font-style: italic;
            letter-spacing: 2px;
            font-weight: bold;
        }

        .status_step {
            position: relative;
            display: inline-block;
            text-align: left;
            color: #cccccc;
            width: 21%;
            padding-left: 34px;
        }

        .status_step.done {
            color: #333366;
        }

        .status_step.current {
            color: #1c43a6;
            font-weight: bold;
        }

        .status_step.alert {
            color: #E87A00;
            font-weight: bold;
        }

        .status_step.deleted {
            color: #990000;
            font-weight: bold;
        }

        .status_step .slug {
            font-size: 14pt;
            letter-spacing: 1px;
        }

        .status_step .name {
            font-size: 10pt;
        }

        .status_step .check {
            position: absolute;          
            left: 10px;
            top: 8px;
        }

        /* Information Line */
        .info_line {
            min-height: 50px;
            margin-bottom: 1em;
            clear: both;
            page-break-inside: avoid;
        }   

        .info_line.border {
            border-bottom: 1px solid #d9e1e0;
        }

        .info_line .item {
            display: inline-block; 
            position: relative;           
        }

        .info_line .item .title {
            font-size: 10pt;
            margin-bottom: 0.5em;
            color: #666666;
        }

        .info_line .item .value {
            font-size: 14pt;
            height: 1.15em;
        }

        .info_line .item .value.constrain {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .info_line .item .value.long_text {
            height: auto;
            margin-bottom: 1em;
        }

        /* Assessment Table */
        .odd {
            background-color: #efefef;
        }

        .assessment_table {
            border-collapse: collapse;
            width: 100%;
            font-size: 10pt;
        }

        .assessment_table thead {
            background-color: #005FA9;
            color: #ffffff;
        }

        .assessment_table thead th {            
            padding: 4px 2px;
            text-align: left;
        }

        .assessment_table tbody tr {
            line-height: 2em;
        }

        /* Help Dialog */
        .help_dialog {
            font-size: 10pt;
        }

        .help_dialog h1 {
            font-size: 14pt;
            color: #005fa9;
            margin: 1em 0 1em 0;
        }

        .help_dialog h2 {
            font-size: 12pt;
            color: #990000;
            margin: 1em 0 0.5em 0;
        }

        .help_dialog h3 {
            font-size: 10pt;
            color: #000000 !important;
            margin: 0.75em 0 0em 0;
        }

        .help_dialog ul, ol {
            margin-left: 28px;
        }

        /* Disallow direct printing */
        @media print {
            #content {
                display: none;
            }

            body:after {
                content: "You cannot directly print this page. Submit your form to view a printable version.";
            }

            body {
                padding-top: 3em;
                font-size: 16pt;
                text-align: center;
            }
        }  

    </style>

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

<?php $__env->startSection('jquery_init'); ?>
			
	// Success bar
	$('.success_bar').animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
	{		
		$(this).delay(6000).fadeOut(4000);	

		$(this).hover(function ()
		{
			$(this).stop(true).css('opacity', '1.0');
		},
		function ()
		{
			$(this).fadeOut(4000);
		})
	});

    // Placeholder functionality
    $('[data-placeholder]').focus(function()
    {
        var input = $(this);
        if (input.val() == input.attr('data-placeholder'))
        {
            input.val('');
            input.removeClass('placeholder');
        }
    }).blur(function()
    {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('data-placeholder'))
        {
            input.addClass('placeholder');
            input.val(input.attr('data-placeholder'));
        }
    }).blur();
    $('[data-placeholder]').parents('form').submit(function()
    {
        $(this).find('[data-placeholder]').each(function()
        {
            var input = $(this);
            if (input.val() == input.attr('data-placeholder'))
            {
                input.val('');
            }
        })
    });   

    // Table row highlighter
    function colorRows ()
    {       
        $('table').each(function ()
        {
            var i = 0;

            $('tbody tr', $(this)).each(function ()
            {
                if (i % 2 == 1)
                {
                    $(this).addClass('odd');
                }
                else
                {
                    $(this).removeClass('odd');
                }
                i = i + 1;
            });     
        });
    }   
    colorRows();
    
    // Close button
    $('.close_button')
        .button({'icons':{'primary':' ui-icon-circle-close'}})
        .css({'font-size':'9pt'})
        .click(function(event)
        {                        
            <?php if (Input::has('admin')): ?>    
                window.location = '<?php echo url('/forms/bia/admin'); ?>';
                return false;
            <?php endif; ?>

            event.preventDefault();

            var link = $(this);
            var href = link.attr('href');

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : false,
                    modal : true,
                    height : 250,
                    width : 400,                    
                    title : 'Confirmation',
                    buttons: [
                        {
                            text : "Yes",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-check'},
                            click : function()
                                    {                                                       
                                        window.location = href;             
                                    }
                        },
                        {
                            text : "No",
                            'class' : "float_right",
                            'data-autofocus' : "true",
                            icons : { primary : 'ui-icon-close'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close");                           
                                    }
                        }
                    ],
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html('<br />Are you sure you want to close this form and return to your BIA Assessor Dashboard?<div style="font-size: 9pt; margin-top: 1em;" class="small gray note">Your changes are automatically saved.  You can return to this form at any time.</div>');
                            
                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');   

                            $('[data-autofocus="true"]').focus();
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            record.css({'background-color':original_background_color});

                            $(dialog_object).remove();
                        }                
                });
        });

    // Help button
    $('.help_button')
        .button({'icons':{'primary':'ui-icon-help'}})
        .css({'font-size':'9pt', 'margin-right':'10px'})
        .click(function(event)
        {
            event.preventDefault();

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : true,
                    height : 725,
                    minHeight : 400,
                    width : 615,
                    minWidth : 330,
                    modal : false,
                    title : 'Assessment Reconciliation Report Form Help',                    
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html("<div class='ajax_loader' style='width:16px; height:11px; margin:4em auto; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat;'></div>");

                            var jqxhr = $.ajax(
                                      {
                                          type : 'GET',
                                          url : '<?php echo url('forms/bia/help'); ?>',
                                          dataType : 'html'
                                      })
                                      .done(function (returned_data)
                                      {                               
                                          dialog_object.html(returned_data);
                                      })
                                      .fail(function (jqXHR, status, error)
                                      {                                                   
                                          var response = jqXHR.responseText;
                                          var errorData = $.parseJSON(response);
                                          console.log(errorData);
                                          alert ("There was an error looking up help information.\n\nThis page will be reloaded.");
                                          location.reload();
                                      })
                                      .complete(function ()
                                      {
                                           
                                      });                            
                            
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        }                
                });


        });
    
    // Submit button
    $('input[type="submit"]')
        .button()
        .click(function(event)
        {                        
            event.preventDefault();

            var button = $(this);
            var form = button.parents('form');

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : false,
                    resizable : false,
                    modal : true,
                    height : 350,
                    width : 500,                    
                    title : 'Submit Confirmation',
                    buttons: [
                        {
                            text : "Yes, I Confirm",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-check'},
                            click : function()
                                    {                                                       
                                        form.submit();             
                                    }
                        },
                        {
                            text : "No",
                            'class' : "float_right",
                            'data-autofocus' : "true",
                            icons : { primary : 'ui-icon-close'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close");                           
                                    }
                        }
                    ],
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html('<br />By submitting this form, you verify that all assessments have been completed using the standard protocol outlined in the Oregon Wrestling Weight Monitoring Program guidelines.<br /><br />You also assert that the results of these assessments for each wrestler have been entered into the NWCA OPC powered by TrackWreslting within 48 hours of assessment.<br /><br />Please confirm these statements?');
                            
                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');   

                            $('[data-autofocus="true"]').focus();
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            record.css({'background-color':original_background_color});

                            $(dialog_object).remove();
                        }                
                });
        }); 

    <?php if (count($info['assessments']) == 0): ?>

        $('input[type="submit"]')
            .button("disable");

    <?php endif; ?> 

    // Edit assessor information button
    $('.edit_assessor_info')
        .button({'icons':{'primary':' ui-icon-pencil'}})
        .css({'font-size' : '9pt',
              'margin' : '0.5em 0 1em 0'})
        .click(function(event)
        {
            var button = $(this);

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    modal : false,
                    draggable : true,
                    resizable : false,
                    title : 'Edit Information',
                    height : 475,
                    width : 625, 
                    buttons: [
                        {
                            text : "Save",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-disk'},
                            click : function()
                                  {                                                       
                                      var dialog_object = $(this);
                                      
                                      var form = $('form', dialog_object);
                                      
                                      $(form).submit();        
                                   }
                        },                                             
                        {
                            text : "Cancel",
                            'class' : "float_right",                            
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close"); 
                                        $(this).remove();                                       
                                    }
                        }
                    ],                                 
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html("<div class='ajax_loader' style='width:16px; height:11px; margin:4em auto; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat;'></div>");

                            var jqxhr = $.ajax(
                                      {
                                          type : 'GET',
                                          url : '<?php echo url('forms/bia'); ?>/<?php echo $info['form']->id; ?>/edit-assessor',
                                          dataType : 'html'
                                      })
                                      .done(function (returned_data)
                                      {                               
                                          dialog_object.html(returned_data);                                          
                                      })
                                      .fail(function (jqXHR, status, error)
                                      {                                                   
                                          var response = jqXHR.responseText;
                                          var errorData = $.parseJSON(response);
                                          console.log(errorData);
                                          alert ("There was an error loading the required data.\n\nThis page will be reloaded.");
                                          location.reload();
                                      })
                                      .complete(function ()
                                      { 
                                          // Integer only fields
                                          $('input[data-numbers-only="integer"]', dialog_object).bind('input', function()
                                          {
                                              $(this).val($(this).val().replace(/[^0-9]/gi, ''));
                                          });

                                          // Float only fields
                                          $('input[data-numbers-only="float"]', dialog_object).bind('input', function()
                                          {
                                              $(this).val($(this).val().replace(/[^0-9|\.]/gi, ''));
                                          });

                                          // Limits
                                          $('select[name="type"]', dialog_object).change(function ()
                                          { 
                                              var selected = $('option:selected', $(this)).val();
                                              var limit;

                                              if (selected == 'home')
                                              {
                                                  limit = "4.50";
                                              }
                                              else
                                              {
                                                  limit = "5.50";
                                              }

                                              $('[name="limit"]').text(limit);

                                              updateCostAmount();
                                          });

                                          // Update total amount
                                          function updateTotalAmount()
                                          {
                                              var assesses = parseInt($('input[name="assesses"]', dialog_object).val());

                                              if (isNaN(assesses))
                                              {
                                                  assesses = 0;
                                              }

                                              var cost = parseFloat($('input[name="cost"]', dialog_object).val());

                                              if (isNaN(cost))
                                              {
                                                  cost = 0;
                                              }

                                              var mileage = parseFloat($('input[name="mileage"]', dialog_object).val());

                                              if (isNaN(mileage))
                                              {
                                                  mileage = 0;
                                              }

                                              var total = (assesses * cost) + mileage;

                                              $('input[name="total"]').val(total.toFixed(2));
                                          }

                                          // Update total assessments
                                          function updateTotalAssess()
                                          {
                                              var passed = parseInt($('input[name="passed"]', dialog_object).val());
                                              if (isNaN(passed))
                                              {
                                                  passed = 0;
                                              }

                                              var failed = parseInt($('input[name="failed"]', dialog_object).val());
                                              if (isNaN(failed))
                                              {
                                                  failed = 0;
                                              }

                                              var assesses = passed + failed;

                                              $('input[name="assesses"]', dialog_object).val(assesses);

                                              updateTotalAmount();
                                          }

                                          $('input[name="passed"], input[name="failed"]', dialog_object).bind('input', function ()
                                          {
                                              updateTotalAssess();
                                          });

                                          function updateCostAmount()
                                          {
                                              var cost_field = $('input[name="cost"]', dialog_object);

                                              var limit = parseFloat($('[name="limit"]').text());                                              

                                              if (isNaN(limit))
                                              {
                                                  alert("An error was encountered, the limit could not be determined.");
                                              }

                                              var cost = parseFloat(cost_field.val());

                                              if (!isNaN(cost))
                                              {
                                                  if (cost > limit)
                                                  {
                                                      cost = limit;                                                      
                                                      
                                                      cost_field.val(cost.toFixed(2));
                                                  }
                                              }

                                              updateTotalAmount();
                                          }

                                          // Limit cost to predefined limit
                                          $('input[name="cost"]', dialog_object).bind('input', function ()
                                          {
                                              updateCostAmount();                                              
                                          });

                                          $('input[name="mileage"]', dialog_object).bind('input', function ()
                                          {
                                              updateTotalAmount();                                            
                                          });
                                      }); 

                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');                               
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        }                
                });
        }); 

    // Add assessment
    $('.add_assessment')
        .button({'icons':{'primary':' ui-icon-plusthick'}})
        .css({'font-size' : '9pt',
              'margin' : '0.5em 0 1em 0'})
        .click(function(event)
        {
            var button = $(this);

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    modal : false,
                    draggable : true,
                    resizable : false,
                    title : 'Add New Assessment Record',
                    height : 550,
                    width : 625, 
                    buttons: [
                        {
                            text : "Add",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-check'},
                            click : function()
                                  {                                                       
                                      var dialog_object = $(this);
                                      
                                      var form = $('form', dialog_object);
                                      
                                      $(form).submit();                  
                                   }
                        },                                             
                        {
                            text : "Cancel",
                            'class' : "float_right",                            
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close"); 
                                        $(this).remove();                                       
                                    }
                        }
                    ],                                 
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html("<div class='ajax_loader' style='width:16px; height:11px; margin:4em auto; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat;'></div>");

                            var jqxhr = $.ajax(
                                      {
                                          type : 'GET',
                                          url : '<?php echo url('forms/bia'); ?>/<?php echo $info['form']->id; ?>/add-assessment',
                                          dataType : 'html'
                                      })
                                      .done(function (returned_data)
                                      {                               
                                          dialog_object.html(returned_data);                                          
                                      })
                                      .fail(function (jqXHR, status, error)
                                      {                                                   
                                          var response = jqXHR.responseText;
                                          var errorData = $.parseJSON(response);
                                          console.log(errorData);
                                          alert ("There was an error loading the required data.\n\nThis page will be reloaded.");
                                          location.reload();
                                      })
                                      .complete(function ()
                                      { 
                                          // Integer only fields
                                          $('input[data-numbers-only="integer"]', dialog_object).bind('input', function()
                                          {
                                              $(this).val($(this).val().replace(/[^0-9]/gi, ''));
                                          });

                                          // Float only fields
                                          $('input[data-numbers-only="float"]', dialog_object).bind('input', function()
                                          {
                                              $(this).val($(this).val().replace(/[^0-9|\.]/gi, ''));
                                          });

                                          // Limits
                                          $('select[name="type"]', dialog_object).change(function ()
                                          { 
                                              var selected = $('option:selected', $(this)).val();
                                              var limit;

                                              if (selected == 'home')
                                              {
                                                  limit = "4.50";
                                              }
                                              else
                                              {
                                                  limit = "5.50";
                                              }

                                              $('[name="limit"]').text(limit);

                                              updateCostAmount();
                                          });

                                          // Update total amount
                                          function updateTotalAmount()
                                          {
                                              var assesses = parseInt($('input[name="assesses"]', dialog_object).val());

                                              if (isNaN(assesses))
                                              {
                                                  assesses = 0;
                                              }

                                              var cost = parseFloat($('input[name="cost"]', dialog_object).val());

                                              if (isNaN(cost))
                                              {
                                                  cost = 0;
                                              }

                                              var mileage = parseFloat($('input[name="mileage"]', dialog_object).val());

                                              if (isNaN(mileage))
                                              {
                                                  mileage = 0;
                                              }

                                              var total = (assesses * cost) + mileage;

                                              $('input[name="total"]').val(total.toFixed(2));
                                          }

                                          // Update total assessments
                                          function updateTotalAssess()
                                          {
                                              var passed = parseInt($('input[name="passed"]', dialog_object).val());
                                              if (isNaN(passed))
                                              {
                                                  passed = 0;
                                              }

                                              var failed = parseInt($('input[name="failed"]', dialog_object).val());
                                              if (isNaN(failed))
                                              {
                                                  failed = 0;
                                              }

                                              var assesses = passed + failed;

                                              $('input[name="assesses"]', dialog_object).val(assesses);

                                              updateTotalAmount();
                                          }

                                          $('input[name="passed"], input[name="failed"]', dialog_object).bind('input', function ()
                                          {
                                              updateTotalAssess();
                                          });

                                          function updateCostAmount()
                                          {
                                              var cost_field = $('input[name="cost"]', dialog_object);

                                              var limit = parseFloat($('[name="limit"]').text());                                              

                                              if (isNaN(limit))
                                              {
                                                  alert("An error was encountered, the limit could not be determined.");
                                              }

                                              var cost = parseFloat(cost_field.val());

                                              if (!isNaN(cost))
                                              {
                                                  if (cost > limit)
                                                  {
                                                      cost = limit;                                                      
                                                      
                                                      cost_field.val(cost.toFixed(2));
                                                  }
                                              }

                                              updateTotalAmount();
                                          }

                                          // Limit cost to predefined limit
                                          $('input[name="cost"]', dialog_object).bind('input', function ()
                                          {
                                              updateCostAmount();                                              
                                          });

                                          $('input[name="mileage"]', dialog_object).bind('input', function ()
                                          {
                                              updateTotalAmount();                                            
                                          });
                                      }); 

                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');                               
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        }                
                });

        }); 
    
    // Delete assessment button
    $('.delete_assessment_record')    
        .button({'text' : false,
                 'icons' : { 'primary' : 'ui-icon-trash'}})
        .css({'width' : '16px',
              'height' : '16px'})
        .click(function()
        {
            var button = $(this);

            var record = button.parents('tr');
            
            var original_background_color = record.css('background-color');            
            
            var index = button.attr('data-index');            

            record.css({'background-color':'yellow'});

            console.log(index);
                        
            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : false,
                    modal : true,
                    height : 200,
                    width : 400,                    
                    title : 'Confirm Assessment Record Deletion',
                    buttons: [
                        {
                            text : "Delete",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-check'},
                            click : function()
                                    {                                                       
                                        var data = { index : index };

                                        // Submit the change
                                        var jqxhr = $.ajax(
                                            {
                                                type : 'POST',
                                                url : '<?php echo url('forms/bia'); ?>/<?php echo $info['form']->id; ?>/delete-assessment',
                                                data : data,
                                                dataType : 'html'
                                            })
                                            .done(function (data)
                                            {                               
                                                console.log('Deletion was successful.');
                                                
                                                // Reload of refresh is specified                                                
                                                location.reload();                                                
                                            })
                                            .fail(function (jqXHR, status, error)
                                            {                                                   
                                                var response = jqXHR.responseText;
                                                var errorData = $.parseJSON(response);
                                                console.log(errorData);
                                                alert ("There was an error deleting that assessment record.\n\nThis page will be reloaded.");
                                                location.reload();
                                            });              
                                    }
                        },
                        {
                            text : "Cancel",
                            'class' : "float_right",
                            'data-autofocus' : "true",
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close");                           
                                    }
                        }
                    ],
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html('<br />Are you sure you want to delete this assessment record?');
                            
                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');   

                            $('[data-autofocus="true"]').focus();
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            record.css({'background-color':original_background_color});

                            $(dialog_object).remove();
                        }                
                });
        });
    
    
    
<?php $__env->stopSection(); ?>

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

    <a href="#" class="help_button">Help</a>

    <a href="<?php echo url('/account#tabs-bia'); ?>" class="close_button">Close</a>
    
<?php $__env->stopSection(); ?>


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

 	<?php /*  Success Bar  */ ?>
 	<?php if (Session::has('success')): ?>
		<div class="success_bar">
			<div class="message">				
				<?php echo Session::get('success'); ?>
			</div>			
		</div>
	<?php endif; ?> 

    <?php /*  Errors  */ ?>
     <?php if (Session::has('errors')): ?>                
        <div class="error ui-state-error" style="font-weight: bold; padding: 1em;">
            <span class="ui-icon ui-icon-alert box_icon"></span>
            <?php foreach ($errors->all() as $error): ?>
                <?php echo $error; ?>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>   

    <?php /*  Main Form  */ ?>
    <?php echo Form::open(array('url' => url('/forms/bia/' . $info['form']->id . '/submit'),
                        'method' => 'post')); ?>

        <h1>Reconciliation Report #<?php echo $info['form']->id; ?></h1>        

        <?php /*  Form Status  */ ?>
        <div class="ui-corner-all status_progress">
            
            <div class="status_title">Form Status</div>

            <?php foreach ($info['statuses'] as $status): ?>

                <div class="status_step <?php echo $status['class']; ?>">
                    <div class="check">
                        <?php if (Helpers::strEqual($status['class'], 'done')): ?>
                            <img src="<?php echo asset('/images/icons/check_16px.png'); ?>" alt="" title="" />
                        <?php elseif (Helpers::strEqual($status['class'], 'current')): ?>
                            <img src="<?php echo asset('/images/icons/incomplete_16px.png'); ?>" alt="" title="" />
                        <?php elseif (Helpers::strEqual($status['class'], 'alert')): ?>
                            <img src="<?php echo asset('/images/icons/alert_16px.png'); ?>" alt="" title="" />
                        <?php elseif (Helpers::strEqual($status['class'], 'deleted')): ?>
                            <img src="<?php echo asset('/images/icons/no_form_data_16px.png'); ?>" alt="" title="" />
                        <?php endif; ?>
                    </div>
                    <div class="slug"><?php echo $status['slug']; ?></div>
                    <div class="name"><?php echo $status['name']; ?></div>
                </div>

            <?php endforeach; ?>
        
        </div>

        <?php if (Helpers::strEqual($info['form']->status, 'WORK')): ?>
            <div class="ui-state-highlight progress_alert ui-corner-all">
                <img src="<?php echo asset('/images/icons/construction_32px.png'); ?>" alt="" title="" style="float: left; width: 32px; display: inline-block; margin-right: 10px;" />
                This reconciliation form has not been submitted.
                <br class="clear" />
            </div>
        <?php endif; ?>

        <?php /*  Form Timestamps  */ ?>
        <div class="info_line">

            <div class="item" style="width: 200px;">
                <div class="title">
                    Created
                </div>
                <div class="value">
                    <?php echo date('n/j/y g:i a', strtotime($info['form']->created_at)); ?>
                </div>
            </div>

            <div class="item" style="width: 200px;">
                <div class="title">
                    Updated
                </div>
                <div class="value">
                    <?php echo date('n/j/y g:i a', strtotime($info['form']->updated_at)); ?>
                </div>
            </div>

            <?php if (Helpers::strEqual($info['form']->status, array('PEND', 'INSF', 'RECD', 'DONE'))): ?>
                <div class="item" style="width: 200px;">
                    <div class="title">
                        Submitted
                    </div>
                    <div class="value">
                        <?php echo date('n/j/y g:i a', strtotime($info['form']->submitted_at)); ?>
                    </div>
                </div>

                <?php if (Helpers::strEqual($info['form']->status, array('RECD', 'DONE'))): ?>

                    <div class="item" style="width: 200px;">
                        <div class="title">
                            Received
                        </div>
                        <div class="value">
                            <?php echo date('n/j/y g:i a', strtotime($info['form']->received_at)); ?>
                        </div>
                    </div>

                    <?php if (Helpers::strEqual($info['form']->status, array('DONE'))): ?>

                        <div class="item" style="width: 200px;">
                            <div class="title">
                                Paid
                            </div>
                            <div class="value">
                                <?php echo date('n/j/y g:i a', strtotime($info['form']->paid_at)); ?>
                            </div>
                        </div>

                    <?php endif; ?>

                <?php endif; ?>

            <?php elseif (!is_null($info['form']->deleted_at)): ?>

                <div class="item" style="width: 200px;">
                    <div class="title">
                        Deleted
                    </div>
                    <div class="value">
                        <?php echo date('n/j/y g:i a', strtotime($info['form']->deleted_at)); ?>
                    </div>
                </div>

            <?php endif; ?>

        </div>


        <?php /*  Assessor Information  */ ?>
        <h2>Assessor Information</h2>

        <div class="edit_assessor_info">Edit Information</div>

        <div class="info_line">

            <div class="item" style="width: 300px;">
                <div class="title">
                    Name
                </div>
                <div class="value">
                    <?php echo $info['assessor']->user->getDisplayFullName(); ?>
                </div>
            </div>

            <div class="item" style="width: 250px;">
                <div class="title">
                    Phone Number
                </div>
                <div class="value">
                    <?php echo Helpers::displayCombinedPhone($info['assessor']->phone); ?>
                </div>
            </div>

            <div class="item" style="width: 400px;">
                <div class="title">
                    E-Mail Address
                </div>
                <div class="value">
                    <?php echo $info['assessor']->user->email; ?>
                </div>
            </div>            

        </div>

        <div class="info_line">

            <div class="item" style="width: 500px;">
                <div class="title">
                    Address
                </div>
                <div class="value">
                    <?php echo $info['assessor']->address->line_1; ?><?php if (!Helpers::strIsEmpty($info['assessor']->address->line_2)): ?>, <?php echo $info['assessor']->address->line_2; ?><?php endif; ?>
                </div>
            </div>

            <div class="item" style="width: 200px;">
                <div class="title">
                    City
                </div>
                <div class="value">
                    <?php echo $info['assessor']->address->city; ?>
                </div>
            </div>

            <div class="item" style="width: 100px;">
                <div class="title">
                    State
                </div>
                <div class="value">
                    <?php echo $info['assessor']->address->state; ?>
                </div>
            </div>

            <div class="item" style="width: 100px;">
                <div class="title">
                    Zip
                </div>
                <div class="value">
                    <?php echo $info['assessor']->address->zip; ?>
                </div>
            </div>

        </div>


        <?php /*  Assessments Information  */ ?>        
        <div class="ui-corner-all" style="float: right; margin-top: 1em; padding: 0.5em 1em 0.5em 5em; background-color: #D0E8D2; border: 1px solid #d9e1e0; font-weight: bold;">
            Grand Total: $<?php echo number_format($info['form']->total_amount, 2); ?>
        </div>


        <h2>Assessments</h2>

        <div class="add_assessment">Add Assessment</div>

        <table class="assessment_table">
            <thead>
                <tr>
                    <th>School / Coop Name</th>
                    <th>Passed Hydration</th>
                    <th>Failed Hydration</th>
                    <th>Total Assessments</th>
                    <th>Cost</th>
                    <th>Mileage</th>
                    <th>Total</th>
                    <th></th>
                </tr>
            </thead>

            <tbody>
                <?php if (count($info['assessments']) == 0): ?>
                    <tr>
                        <td colspan="8">This reconciliation form has no assessments on record.<br />Click <b>Add Assessment</b> to create a new record.  You cannot submit the form until at least one assessment record is entered.</td>
                    </tr>
                <?php else: ?>
                    <?php foreach ($info['assessments'] as $i => $assess): ?>
                        <tr>
                            <td><?php echo $assess->ap_name; ?></td>
                            <td><?php echo $assess->passed; ?></td>
                            <td><?php echo $assess->failed; ?></td>
                            <td><?php echo $assess->assesses; ?></td>
                            <td>$<?php echo number_format($assess->cost, 2); ?></td>
                            <td>$<?php echo number_format($assess->mileage, 2); ?></td>
                            <td>$<?php echo number_format($assess->total, 2); ?></td>
                            <td><div class="delete_assessment_record" data-index="<?php echo $i; ?>"></div></td>
                        </tr>
                    <?php endforeach; ?>
                <?php endif; ?>
            </tbody>

        </table>        

        <div class="horizontal_divider" style="width: 100%;"></div>

        <br />
    
        <div style="float: left; padding-right: 30px;">        
            <?php echo Form::submit('Submit'); ?>
        </div>

        <div style="float: right; padding-left: 30px;">
            <a href="#" class="help_button">Help</a>
        </div>

        <div style="font-size: 9pt; line-height: 9pt; margin-top: 0.5em;">
            Changes are automatically saved to this form.  When you are ready, click the <b>Submit</b> button.  Once submitted, you will not be able to edit the form.  After submitting this form, a printable version will be available for you to print off and include in your packet mailed to the OSAA.
        </div>

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

    <br class="clear" />
<?php $__env->stopSection(); ?>
