<?php include 'header.php'; ?>

<?php include 'sidebar.php'; ?>


<div id="page-wrapper">

    <div class="container-fluid">

		<br/>

         <div class="row">

             <div class="col-lg-12">
				<div class="panel panel-default dash">
					<div class="panel panel-primary">
						<div class="panel-heading">
							<h2 class="sub-header">
								<i class="fa fa-money-bill-alt" aria-hidden="true"></i> <?php echo lang('COLLEGE_FEES');?>
							</h2>
						</div>
						<!-- /.panel-heading -->
						<div class="panel-body">
							<div class="table-responsive">
							
								<div class="col-md-12">

									<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" class="form-horizontal" name="newservice">
										<fieldset>
											<?php $csrf->echoInputField(); ?>


											<!-- Text input -->
											<div class="form-group">
												<label class="col-md-2 control-label" for="collegeID"><?php echo lang('COLLEGE_NAME');?></label>
												<div class='col-md-6'>
													<select class="form-control input-md" name="collegeID">
													  <option value="<?php
														global $conection;
														$sql = mysqli_query($conection,"select collegeName from colleges");
														$row = mysqli_fetch_assoc($sql);
														echo $row['collegeName'];
													?>">
														<?php echo listCollegeLists(); ?>
													</select>
												</div>
											</div>

											<!-- Text input -->
											<div class="form-group">
												<label class="col-md-2 control-label" for="courseID"><?php echo lang('COURSE_NAME');?></label>
												<div class='col-md-6'>
													<select class="form-control input-md" name="courseID">
													  <option value="<?php
														global $conection;
														$sql = mysqli_query($conection,"select courseName from courses");
														$row = mysqli_fetch_assoc($sql);
														echo $row['courseName'];
													?>">
														<?php echo listSubjectLists(); ?>
													</select>
												</div>
											</div>



											<!-- Text input-->
											<div class="form-group">
												<label class="col-md-2 control-label" for="noofseats"><?php echo lang('NO_OF_SEAT');?></label>
												<div class="col-md-6">
													<input id="noofseats" name="noofseats" type="text" class="form-control input-md" required>
												</div>
											</div>

											<!-- Text input-->
											<div class="form-group">
												<label class="col-md-2 control-label" for="coursefees"><?php echo lang('COURSE_FEES');?></label>
												<div class="col-md-6">
													<input id="coursefees" name="coursefees" type="text" class="form-control input-md" required>
												</div>
											</div>


											<!-- Button -->
											<div class="form-group">
												<label class="col-md-10 control-label" for="singlebutton"></label>
												<div class="col-md-2">
													<input type="submit" name="newservice" class="btn save btn-primary" value="<?php echo lang('SAVE');?>" />
												</div>
											</div>

										</fieldset>
									</form>



									<?php

										// Se o usuário clicou no botão cadastrar efetua as ações
										if (!empty($_POST['newservice']))
										 {
											global $conection;

											$collegeID = mysqli_real_escape_string($conection, $_POST['collegeID']);
											$courseID = mysqli_real_escape_string($conection, $_POST['courseID']);
											$noofseats = mysqli_real_escape_string($conection, $_POST['noofseats']);
											$coursefees = mysqli_real_escape_string($conection, $_POST['coursefees']);

										 
													// Insere os dados no banco
	$sql = mysqli_query($conection,"INSERT INTO finalcollegetable VALUES ('', '".$collegeID."', '".$courseID."', '".$noofseats."', '".$coursefees."')");

					
													// Se os dados forem inseridos com sucesso			
													if (!$sql) {
													echo ("Can't insert into database: " . mysqli_error());
													return false;
													} else {
													echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('ADDED')."', 'success');</script>";
															echo '<meta http-equiv="refresh" content="1; collegefees.php">'; 
															die();
													}		
													return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
	
										?>

								</div>    
							</div>
						</div>
					</div>
				</div>
			</div>
        </div>
        <!-- /.row -->

        <div class="copyright">
            <p>© Copyright 2019  &nbsp;&nbsp;|&nbsp;&nbsp; All Rights Reserved Powered by 
            <a href="http://www.bluelinecomputers.com/" target="_blank">Blueline Computers</a></p>
        </div>
    
    </div>
    <!-- /.container-fluid -->

</div>
<!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<?php include 'footer.php'; ?>