<style>
	th, td { text-align: center; }
</style>
<h1 class="page-title"> Company Settings</h1>
<!-- CONTENT -->
<div class="row">
	<div class="col-md-12">
		<!-- BEGIN PROFILE SIDEBAR -->
		<div class="profile-sidebar">
			<!-- PORTLET MAIN -->
			<div class="portlet light profile-sidebar-portlet ">
				<!-- SIDEBAR USERPIC -->
				<form enctype="multipart/form-data" class="cmxform form-horizontal adminex-form" id="editPicForm" method="post" action="/company/edit/updatepic">
					<div class="profile-userpic ">
						<div class="fileinput fileinput-new row" data-provides="fileinput">
							<div class="col-md-12">
								<div class="fileinput-new img-responsive">
									<center>				
										<img id="uploadPreview" src="<?php echo showCompanyImage($_SESSION['user_id'], "user_id"); ?>" alt="" style="margin-left: 30px;" /> 
										<span class="btn btn-file" style="position:static;">
										<a class="fileinput-new" style="top: 0 !important;right : 0 !important;margin: 0 !important;color: #fff !important;opacity: .6 !important;border: none !important;padding: 3px 9px !important;font-size: 12px !important;background: #000 !important;position: absolute !important;filter: alpha(opacity=60) !important;"> edit </a>
										<input type="file" name="image" id="image" onchange="PreviewImage();"> 
										</span>
									</center>
								</div>
							</div>
						</div>
					</div>
				</form>
				<!-- END SIDEBAR USERPIC -->
				<!-- SIDEBAR USER TITLE -->
				<div class="profile-usertitle">
					<div class="profile-usertitle-name"> <?php echo getCompanyData($_SESSION["user_id"], "user_id", "name"); ?> </div>
				</div>
				<!-- END SIDEBAR USER TITLE -->
				<!-- SIDEBAR MENU -->
				<div class="profile-usermenu">
					<ul class="nav">
						<li>
							<a href="/profile/edit">
							<i class="icon-settings"></i> Personal Settings </a>
						</li>
						<li class="active">
							<?php if(getCompany($_SESSION['user_id']) == 0 || (getCompany($_SESSION['user_id']) <> 0 && getCompanyPosition($_SESSION['user_id']) == 1)){?>
							<a href="/company/edit">
							<i class="icon-info"></i> Company Settings </a>
							<?php }elseif(getCompany($_SESSION['user_id']) <> 0 && (getCompanyPosition($_SESSION['user_id']) == 2 || getCompanyPosition($_SESSION['user_id']) == 3)){?>
							<a href="/company">
							<i class="icon-info"></i> Company Information </a>
							<?php } ?>	
						</li>
					</ul>
				</div>
				<!-- END MENU -->
			</div>
			<!-- END PORTLET MAIN -->
		</div>
		<!-- END BEGIN PROFILE SIDEBAR -->
		<!-- BEGIN PROFILE CONTENT -->
		<div class="profile-content">
			<div class="row">
				<div class="col-md-12">
					<div class="portlet light ">
						<div class="portlet-title tabbable-line">
							<ul class="nav nav-tabs">
								<li>
									<a href="/company/edit">Company Information</a>
								</li>
								<?php if($_SESSION['group_id'] == 2){ ?>
								<li>
									<a href="/company/branch">Branch Information</a>
								</li>
								<?php } ?>
								<li>
									<?php if($_SESSION['group_id'] == 2){ ?>
									<a href="/company/warehouse">Delivery Information</a>
									<?php }else{ ?>
									<a href="/company/warehouse">Warehouse Information</a>
									<?php } ?>
								</li>
								<li class="active">
									<a href="/company/staff">Staff Information</a>
								</li>
							</ul>
						</div>
						<div class="portlet-body">
							<div class="tab-content">
								<!-- CHANGE AVATAR TAB -->
								<div class="tab-pane active">
									<?php 
										if(getCompany($_SESSION['user_id']) == 0){
											?>
									<center style="margin-top:70px">
									Please complete your <strong><a href="/company/edit">Company Information</a></strong> to proceed.
									<?php
										}else{
										?>
									<div id='suksesupdate' class="alert alert-success alert-block fade in" style='display:none;'>
										<h4>
											<i class="icon-ok-sign"></i>
											Success!
										</h4>
										<p>Yehaa.. Your staff added to your company. Redirecting in few seconds..</p>
									</div>
									<div id='gagalupdate' class="alert alert-danger alert-block fade in" style='display:none;'>
										<h4>
											<i class="icon-ok-sign"></i>
											Whoops!
										</h4>
										<p>Add staff been declined. There is an error occured. Please refresh the page and retry.</p>
									</div>
									<div class="table-toolbar">
										<div class="row">
											<div class="col-md-6">
											</div>
											<div class="col-md-6">
												<div class="btn-group pull-right">
													<div class="btn-group">
														<a class="btn green btn-circle" href="#form_add" data-toggle="modal"> Add New <i class="fa fa-plus"></i>
														</a>
													</div>
												</div>
											</div>
										</div>
									</div>
									<table class="table table-striped table-hover table-bordered" id="staff">
										<thead>
											<tr role="row" class="heading">
												<th>
													<center>Name</center>
												</th>
												<th>
													<center>Position</center>
												</th>
												<?php if($_SESSION['group_id'] == 2){ ?>
												<th>
													<center>Branch</center>
												</th>
												<?php } ?>
												<th>
													<center>Action</center>
												</th>
											</tr>
										</thead>
									</table>
									<?php
										}
										?>
								</div>
								<!-- END CHANGE AVATAR TAB -->
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- END PROFILE CONTENT -->
	</div>
</div>
<?php 
	if(getCompany($_SESSION['user_id']) <> 0){
		?>
<div class="modal fade" id="form_add" role="basic" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
				<h4 class="modal-title">Add Staff</h4>
			</div>
			<form class="cmxform form-horizontal adminex-form" id="addstaff" method="get" action="">
				<div class="modal-body">
					<div class="form-group">
						<label class="control-label col-md-4">Staff Name</label>
						<div class="col-md-8">
							<div class="input-group select2-bootstrap-prepend">
								<select id="user_id" name="user_id" class="form-control select2-allow-clear">
									<option></option>
									<?php echo getAllFriendNoCompany($_SESSION['user_id']); ?>
								</select>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-4">Position <a class=" tooltips" data-placement="right" data-original-title="The access right that are granted for a user in IZYIM."><i class="fa fa-question-circle"></i></a></label>
						<div class="col-md-8">
							<div class="input-group select2-bootstrap-prepend">
								<select id="position" name="position" class="form-control select2-allow-clear">
									<option></option>
									<option value="1">Admin</option>
									<?php if($_SESSION['group_id'] == 2){ ?>								
									<option value="2">Admin Branch</option>
									<?php } ?>
									<option value="3">Staff</option>
								</select>
								<span class="help-block" style="display:none;" id="helpbar"></span>
							</div>
						</div>
					</div>
					<?php if($_SESSION['group_id'] == 2){ ?>			
					<div class="form-group">
						<label class="control-label col-md-4">Branch</label>
						<div class="col-md-8">
							<div class="input-group select2-bootstrap-prepend">
								<select id="branch" name="branch" class="form-control select2-allow-clear">
									<option></option>
									<?php echo getAllBranch(getCompany($_SESSION['user_id']));?>
								</select>
							</div>
						</div>
					</div>
					<?php }else{ ?>
					<input name="branch" id="branch" value="<?php echo getBranch($_SESSION['user_id']); ?>" hidden type="hidden" style="display:none;" />
					<?php } ?>
				</div>
				<div class="modal-footer">
					<button class="btn btn-primary" type="submit" id='submitpin'>Add Staff</button>
					<button class="btn btn-default" type="button" id='waitingpin' disabled style="display:none;">Please Wait...</button>
				</div>
			</form>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal-dialog -->
</div>
<div class="modal fade" id="form_edit" tabindex="-1" role="basic" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
				<h4 class="modal-title">Edit Staff</h4>
			</div>
			<form class="cmxform form-horizontal adminex-form" id="editstaff" method="get" action="">
				<div class="modal-body" id="getCode"> 
				</div>
				<div class="modal-footer">
					<button class="btn btn-primary" type="submit" id='submitpin'>Edit Staff</button>
					<button class="btn btn-default" type="button" id='waitingpin' disabled style="display:none;">Please Wait...</button>
				</div>
			</form>
		</div>
	</div>
</div>
<?php } ?>