<?php
	include("../includes/dbconfig.php");
	$pagetitle = "New Job Classfication";
	require('../includes/applicationtop.php');
	require('../includes/applicationmenu.php');
    $error = '';
    if ($_SERVER["REQUEST_METHOD"] == "POST"  ) {
        if(!empty($_POST["amount"]) and !empty($_POST["name"]) and !empty($_POST["category"]) ){
            $cat = $_POST["category"];
            $name = $_POST["name"];
            $amount = $_POST["amount"];

            DB::startTransaction();
					DB::query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");
					DB::insert
					('repair_jobnames', 
						array
						(
							'job_type' => $cat, 
							'job_name' => $name, 
							'job_amount' => $amount
						)
					);
					
					DB::commit();
                    ?>
						<script>
							location.href="repairname.php";
						</script>
<?php
					
        }else  { $error =  'All fields are required';}


    }
?>
			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
				<!-- Content Header (Page header) -->
				<section class="content-header">
					<h1><?= $pagetitle  ?></h1>
					<ol class="breadcrumb">
					</ol>
				</section>

				<!-- Main content -->
				<section class="content">
					<!-- Default card -->
					<div class="card card-primary">
					 
						<div class="card-header with-border text-center">
							<h3 class="card-title"><?= $pagetitle  ?></h3>
						</div>
						<div class="card-body">
							<div id="servererrormessage">
							</div>
							<div class="card-body table-responsive no-padding">
								 
								
								<div class="col-md-12" style="margin-top: 25px"></div>

                                <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
								 
							<div class="row">
								<div class="col-sm-12">
                                   <?php if(!empty($error)){ ?>
                                   <h6 class='alert alert-warning' align='center'>  <?= $error; ?> </h6>
                                   <?php } ?>
								   
									<div class="form-group  ">
									<label for="employee_role">Category</label>
									<select  class="form-control" name="category" id="employee_role" data-placeholder="Choose One">
											<option value="0">Choose One</option>
											<?php
												$employee_roledata = DB::query("SELECT * FROM repair_jobtypes");
												
												foreach($employee_roledata as $useemployee_role)
												{
											?>
											<option  value="<?php echo $useemployee_role['rptid']; ?>"><?php echo $useemployee_role['rpt_name']; ?></option>
											<?php
												}
											?>
											</select>
										 </div><!-- form-group -->
										 
									<div class="form-group">
										<label for="firstname"> Name</label>
										<input type="text" name="name" id="name" maxlength="40" class="form-control" value="<?php echo isset($_POST['name']) ? $_POST['name'] : "" ?>" >
									</div><!-- form-group -->
									
									<div class="form-group">
										<label for="lastname">Amount charged</label>
										<input type="text" name="amount" id="amount" maxlength="40" class="form-control" value="<?php echo isset($_POST['amount']) ? $_POST['amount'] : "" ?>" >
									</div><!-- form-group -->
									
									 
                                    <div class="btn-list">
								<div class="text-right">
									<a href="systemusers.php" class="btn btn-danger"><i class="glyphicon glyphicon-remove"></i> Cancel</a>
									
									<button type="submit" name="savedatabtn" id="savedatabtn" class="btn btn-success"><i class="glyphicon glyphicon-floppy-disk"></i> Save</button>
								</div>
							</div>
									
									 
									
																		
								</div>
							
								 
									</div><!-- form-group -->
									</div>
								</div>
							</div>
						</div><!-- /.card-body -->
						
						<div class="card-footer">
							
							
						</div><!-- /.card-footer-->
							</form>
										
							 
							</div>
						</div><!-- /.card-body -->
						<div class="card-footer">
							
						</div><!-- /.card-footer-->
				 
				 
					</div><!-- /.card -->
				</section><!-- /.content -->
			</div><!-- /.content-wrapper -->

			 
		</div><!-- ./wrapper -->
		
		<div class="modal" id="waitdialogmodal"  data-backdrop="static">
            <div class="modal-dialog modal-sm">
              <div class="modal-content">
                  <div class="modal-body">
					<div class="text-center">
						<img src="<?php echo $base_url . $ajax_loading_image; ?>" />
					</div>
				  </div>
              </div>
            </div>
        </div>
		
		<div class="modal" id="mediummodal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-body">					
						<div class="row" id="mediummodaldetails">
					
						</div>
					</div>
				</div>
			</div>
		</div>
<?php include ('../includes/general_footer.php')?>
		<script src="../plugins/bert/storepos.js" type="text/javascript"></script>
		<script src="../plugins/bert/category.js" type="text/javascript"></script>
	</body>
</html>