

<!-- Dashboard companies start -->

<div id="dashboard-companies" class="fadeIn">
	<div class="row">
		<div class="col s12">

			<!-- Companies-->
			<div class="widget-holder hoverable fadeIn" id="dashboard-companies-overview">
				<div class="widget-heading">
					<h2 class="widget-heading-thick"><?php echo isset($title) ? $title : null; ?></h2>

					<?php if(Entrust::hasRole('superadmin') || Entrust::hasRole('admin')): ?>

					<a href="<?php echo URL::route('getAddCompany'); ?>" class="btn-floating waves-effect waves-light btn-primary new-blog-post" id="add-company-button"><i class="material-icons">add</i></a>
					<?php endif; ?>

					<div class="row filter-row">
						<div class="col s12">

							<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">

					<?php if(Entrust::hasRole('manager')): ?>

						<div class="table-wrapper">
							<table class="bordered responsive-table">
								<thead>
								<tr>
									<th><?php echo Lang::get('companiesList.header_name'); ?></th>
									<th><?php echo Lang::get('companiesList.header_email'); ?></th>
									<th><?php echo Lang::get('companiesList.header_phone'); ?></th>
									<th><?php echo Lang::get('companiesList.header_address'); ?></th>
									<th><?php echo Lang::get('companiesList.header_description'); ?></th>
									<th><?php echo Lang::get('communalService.header_action'); ?></th>

								</tr>
								</thead>

								<tbody id="searchable">
								<?php if(count($companies) > 0): ?>
								<?php foreach($companies as $company): ?>

									<td>
										<?php echo $company->name; ?>

									</td>
									<td>
										<?php echo $company->email; ?>

									</td>
									<td>
										<?php echo $company->phone; ?>

									</td>
									<td>
										<?php echo $company->address; ?>

									</td>
									<td>
										<?php echo $company->description; ?>

									</td>
									<td>
									<a href="<?php echo URL::route('getEditCompany', array('id' => $company->id)); ?>"  title="<?php echo Lang::get('companiesList.button_edit_company', array('name' => $company->name)); ?>" class="icon-btn icon-btn-edit"><i class="material-icons">mode_edit</i></a>
									</td>
								</tr>

									<?php endforeach; ?>
								<?php endif; ?>
								</tbody>
							</table>

						</div>

					<?php endif; ?>
					<?php if(Entrust::hasRole('superadmin') || Entrust::hasRole('admin')): ?>

					<div class="table-wrapper">
						<table class="bordered responsive-table">
							<thead>
							<tr>
								<th><?php echo Lang::get('companiesList.header_name'); ?></th>
								<th><?php echo Lang::get('companiesList.header_city'); ?></th>
								<th><?php echo Lang::get('companiesList.header_email'); ?></th>
								<th><?php echo Lang::get('companiesList.header_phone'); ?></th>
								<th><?php echo Lang::get('companiesList.header_address'); ?></th>
								<th><?php echo Lang::get('companiesList.header_description'); ?></th>
								<th><?php echo Lang::get('communalService.reports_count'); ?></th>
								<th><?php echo Lang::get('communalService.header_action'); ?></th>

							</tr>
							</thead>

							<tbody  id="searchable">
							<?php foreach($companies as $company): ?>


								<tr>

								<td>
									<?php echo $company['city_company']->name; ?>

								</td>
								<td>
									<?php echo $company['city_company']->city_name; ?>

								</td>
								<td>
									<?php echo $company['city_company']->email; ?>

								</td>
								<td>
									<?php echo $company['city_company']->phone; ?>

								</td>
								<td>
									<?php echo $company['city_company']->address; ?>

								</td>
								<td>
									<?php echo $company['city_company']->description; ?>

								</td>
								<td>
									<?php echo $company['report_count']; ?>

								</td>
									<td>
									<a href="<?php echo URL::route('getEditCompany', array('id' => $company['city_company']->id)); ?>"  title="<?php echo Lang::get('companiesList.button_edit_company', array('name' => $company['city_company']->name)); ?>" class="icon-btn icon-btn-edit"><i class="material-icons">mode_edit</i></a>
									<?php if($company['report_count']>0): ?>
											<a href="<?php echo URL::route('getCompanyReports', array('id' => $company['city_company']->id)); ?>"  data-tooltip="<?php echo Lang::get('communalService.link_view_company_reports'); ?>" class="icon-btn icon-btn-edit tooltipped"><i class="material-icons">visibility</i></a>

										<?php endif; ?>
										<a href="<?php echo URL::route('getDeleteCompany', array('id' => $company['city_company']->id)); ?>"  title="<?php echo Lang::get('companiesList.button_delete_company', array('name' => $company['city_company']->name)); ?>" class="icon-btn icon-btn-delete"><i class="material-icons">delete</i></a>
								</td>
							</tr>

								<?php endforeach; ?>
							</tbody>
						</table>

					</div>

					<?php endif; ?>
				</div>
			</div>
			<!--Companies end-->

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

<!-- Dashboard companies end -->

