<!-- Dashboard cities start -->
<div id="dashboard-cities">
	<div class="row">
		<div class="col s12">
			<div class="widget-holder hoverable fadeIn" id="dashboard-cities-overview">
				<div class="widget-heading">
					<h2 class="widget-heading-thick"><?php echo Lang::get('core.menu_cities'); ?></h2>
					<a href="<?php echo URL::route('getAddCity'); ?>" class="btn-floating waves-effect waves-light btn-primary new-blog-post" id="add-city-button"><i class="material-icons">add</i></a>

					<div class="row filter-row">
						<div class="col s12">
							<select id="country">
								<option value="null" <?php echo ($country==null)?'selected':''; ?>><?php echo ucfirst(Lang::get('core.all_countries')); ?></option>
								<?php foreach($countries as $cntry): ?>
									<option value="<?php echo $cntry->id; ?>" <?php echo ($country==$cntry->id)?'selected':''; ?>><?php echo Lang::get('databaseAssets.'. $cntry->identifier); ?></option>
								<?php endforeach; ?>
							</select>

							<select id="status">
								<option value="null"  <?php echo ($status=="null")?'selected':''; ?> ><?php echo ucfirst(Lang::get('core.all_statuses')); ?></option>
								<option value="1" <?php echo ($status=="1")?'selected':''; ?>><?php echo ucfirst(Lang::get('core.active')); ?></option>
								<option value="0" <?php echo ($status=="0")?'selected':''; ?>><?php echo ucfirst(Lang::get('core.inactive')); ?></option>
							</select>
							<a id="filter" class="waves-effect waves-light btn btn-primary"><?php echo Lang::get('core.filter'); ?></a>

							<div class="input-field right">
								<i class="material-icons prefix">search</i>
								<input id="icon_prefix" type="text" onkeyup="filterTable()">
								<label for="icon_prefix"><?php echo ucfirst(Lang::get('core.search')); ?></label>
							</div>
						</div>
					</div>
				</div>
				<div class="widget-content">
					<div class="table-wrapper">
						<table class="bordered responsive-table" >
							<thead>
							<tr>
								<th class="text-capitalize"><?php echo Lang::get('companiesList.header_city'); ?></th>
								<th class="text-capitalize"><?php echo Lang::get('core.country'); ?></th>
								<th class="text-capitalize"><?php echo Lang::get('core.status'); ?></th>
								<th class="text-capitalize"><?php echo Lang::get('core.admins'); ?></th>
								<th class="text-capitalize"><?php echo Lang::get('core.actions'); ?></th>

							</tr>
							</thead>

							<tbody  id="searchable">
							<?php foreach($cities as $city): ?>
							<tr>
								<td><?php echo $city['city']->name; ?></td>
								<td><?php echo Lang::get('databaseAssets.'. $city['city']->country_identifier); ?></td>
								<td>
									<?php if($city['city']->city_is_active == 1): ?>
										<?php echo ucfirst(Lang::get('core.active')); ?>

									<?php else: ?>
										<?php echo ucfirst( Lang::get('core.inactive')); ?>

									<?php endif; ?>
								</td>

								<td>
									<select adminindex="<?php echo $city['city']->id; ?>">

										<?php foreach($city['users'] as $user): ?>
											<option value="<?php echo $user->id; ?>"><?php echo $user->first_name .' '. $user->last_name; ?> </option>
										<?php endforeach; ?>

									</select>

								</td>
								<td>
									<a class="icon-btn icon-btn-list admin-login-btn tooltipped" data-tooltip="<?php echo Lang::get('usersList.button_login_as', array('name' => '')); ?>"><i data-logindex="<?php echo $city['city']->id; ?>" class="material-icons">input</i></a>

									<a href="<?php echo URL::route('getEditCity', array('id'=>$city['city']->id)); ?>" class="icon-btn icon-btn-edit"><i class="material-icons">mode_edit</i></a>
									<a href="#" class="icon-btn icon-btn-delete"><i class="material-icons">delete</i></a>
								</td>
							</tr>

							<?php endforeach; ?>

							</tbody>
						</table>

					</div>
				</div>
			</div>


		</div>
	</div>
</div>
<!-- Dashboard cities end -->
<?php if($cities != null): ?>
<?php foreach($cities as $city): ?>
<div class="modal fade" id="deleteCityModal<?php echo $city['city']->id; ?>"  tabindex="-1" role="dialog" aria-labelledby="cityDeleteModalLabel">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close modalDelegateCloseButton" data-dismiss="modal" aria-label="<?php echo Lang::get('core.close'); ?>"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title"><?php echo Lang::get('city.link_delete_city'); ?></h4>
			</div>
			<div class="modal-body">
				 <p><?php echo Lang::get('city.confirm_city_delete'); ?>   </p>

						<a href="<?php echo URL::route('deleteCity', array('id' => $city['city']->id)); ?>" class="btn btn-danger mt10 w120"><i class="fa fa-times"></i> <?php echo Lang::get('city.link_delete_city'); ?></a>


			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default modalDelegateCloseButton" data-dismiss="modal"><?php echo Lang::get('core.close'); ?></button>
			</div>
		</div>
	</div>
</div>
<?php endforeach; ?>
<?php endif; ?>

