<?php

$accounts = get_account_list_for_array();
?>


<ol class="breadcrumb">
  <li><a href="<?php 
echo site_url('');
?>
"><?php 
lang('Dashboard');
?>
</a></li>
  <li class="active"><?php 
lang('Plugins');
?>
</li>
</ol>

<?php 
$this->db->where('option_group', 'plugins');
$plugins = $this->db->get('options')->result_array();
?>


<div class="row">
<div class="col-md-8">

<div class="row">
	<?php 
function get_location_list($data = '')
{
    $ci =& get_instance();
    $accounts = get_account_list_for_array();
    $projects = get_p_project_cards();
    $ci->db->where('status', 1);
    $locations = $ci->db->get('p_p_locations')->result_array();
    ?>
    <table cellpadding="0" cellspacing="0" border="0" class="table table-hover table-bordered table-condensed dataTable_noExcel_noLength_noInformation">
    	<thead>
        	<tr>
            	<th width="1"></th>
                <th><?php 
    lang('Name');
    ?>
</th>
                <th><?php 
    lang('Custom Code');
    ?>
</th>
                <th><?php 
    lang('City');
    ?>
</th>
                <th><?php 
    lang('County');
    ?>
</th>
                <th><?php 
    lang('Account Card');
    ?>
</th>
                <th><?php 
    lang('Project Card');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
    <?php 
    foreach ($locations as $location) {
        ?>
    	<tr>
        	<td width="1">
            	<a href="javascript:;" class="btn btn-xs btn-default btnSelected_project" 
            		data-location_id='<?php 
        echo $location['id'];
        ?>
' 
                	data-location_name='<?php 
        echo $location['name'];
        ?>
'
                    data-location_project_id='<?php 
        echo $location['project_id'];
        ?>
'
                    >
				<?php 
        lang('Choose');
        ?>
</a>
            </td>
            <td><?php 
        echo $location['name'];
        ?>
</td>
            <td><?php 
        echo $location['custom_code'];
        ?>
</td>
            <td><?php 
        echo $location['city'];
        ?>
</td>
            <td><?php 
        echo $location['county'];
        ?>
</td>
            <td><?php 
        echo @$accounts[$location['account_id']]['name'];
        ?>
</td>
            <td><?php 
        echo @$projects[$location['project_id']]['name'];
        ?>
</td>
        </tr>
    <?php 
    }
    ?>
    	</tbody>
    </table>
    
    <script>
        $('.btnSelected_project').click(function() {
			<?php 
    if (isset($data['location_id'])) {
        ?>
$('#<?php 
        echo $data['location_id'];
        ?>
').val($(this).attr('data-location_id'));<?php 
    }
    ?>
			<?php 
    if (isset($data['location_name'])) {
        ?>
$('#<?php 
        echo $data['location_name'];
        ?>
').val($(this).attr('data-location_name'));<?php 
    }
    ?>
			<?php 
    if (isset($data['RUN'])) {
        ?>
				<?php 
        echo $data['RUN'];
        echo '(';
        ?>
$(this).attr("data-location_project_id")<?php 
        echo ');';
    }
    ?>
			$('.close').click();
		});
	</script>
    <?php 
}