ok
Direktori : /home2/selectio/www/salemgovtitialumni.in/dashboard/admin/ |
Current File : /home2/selectio/www/salemgovtitialumni.in/dashboard/admin/trainee-add.php |
<?php require_once('header.php'); ?> <?php if(isset($_GET['code'])){ $get_code = $_GET['code']; if($get_code==1){ $title_name = "Achievements"; }else if($get_code==2){ $title_name = "Annual Statements"; }else if($get_code==3){ $title_name = "Trainee Corner"; }else if($get_code==4){ $title_name = "Work details"; }else if($get_code==5){ $title_name = "Auditor report"; }else{ $title_name = ""; } }else{ $get_code = 0; } if(isset($_POST['form1'])) { $valid = 1; $path = $_FILES['photo']['name']; $path_tmp = $_FILES['photo']['tmp_name']; if($path == '') { $valid = 0; $error_message .= "You must have to select a photo<br>"; } else { $ext = pathinfo( $path, PATHINFO_EXTENSION ); $file_name = basename( $path, '.' . $ext ); } if($valid == 1) { // getting auto increment id for photo renaming $statement = $pdo->prepare("SHOW TABLE STATUS LIKE 'tbl_photo'"); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { $ai_id=$row[10]; } // uploading the photo into the main location and giving it a final name $final_name = 'service-'.$ai_id.'.'.$ext; move_uploaded_file( $path_tmp, '../assets/uploads/report/'.$final_name ); $image_path ='assets/uploads/report/'.$final_name; if( $row['type'] ==1){ $type="Achivement"; }else if($row['type'] ==2){ $type="Annual Statement"; }else if($row['type'] ==3){ $type="Trainee"; }else if($row['type'] ==4){ $type="work Details"; }else if($row['type'] ==5){ $type="Auditor Report"; } // saving into the database $statement = $pdo->prepare("INSERT INTO tbl_trainee (acheiver_name,acheiver_file,type) VALUES (?,?,?)"); $statement->execute(array($_POST['report'],$image_path,$get_code)); $success_message = $title_name.' is added successfully.'; } } ?> <section class="content-header"> <div class="content-header-left"> <h1>Add <?= $title_name ?></h1> </div> <div class="content-header-right"> <a href="alumini-reports-lists.php?code=<?= $get_code ?>" class="btn btn-primary btn-sm">View All</a> </div> </section> <section class="content"> <div class="row"> <div class="col-md-12"> <?php if($error_message): ?> <div class="callout callout-danger"> <p> <?php echo $error_message; ?> </p> </div> <?php endif; ?> <?php if($success_message): ?> <div class="callout callout-success"> <p><?php echo $success_message; ?></p> </div> <?php endif; ?> <form class="form-horizontal" action="" method="post" enctype="multipart/form-data"> <div class="box box-info"> <div class="box-body"> <div id="html"> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label"></label> <div class="col-sm-6"> <button type="submit" class="btn btn-success pull-left" name="form1">Submit</button> </div> </div> </div> </div> </div> </form> </div> </div> </section> <?php require_once('footer.php'); ?> <script> $(document).ready(function(){ typeReport(); }); function typeReport(){ $("#html").empty(); var type = $("#type").val(); // alert(type); var htmls = ''; if(type==1){ var htmls = '<div class="form-group"><label for="" class="col-sm-2 control-label"> name <span>*</span></label><div class="col-sm-6"><input type="text" autocomplete="off" class="form-control" name="report" value=""></div></div><div class="form-group"><label for="" class="col-sm-2 control-label">File <span>*</span></label><div class="col-sm-9" style="padding-top:5px"><input type="file" name="photo">(Only pdf, jpg, jpeg, gif and png are allowed)</div></div>'; }else if(type == 2){ var htmls = '<div class="form-group"><label for="" class="col-sm-2 control-label"> name <span>*</span></label><div class="col-sm-6"><input type="text" autocomplete="off" class="form-control" name="report" value=""></div></div><div class="form-group"><label for="" class="col-sm-2 control-label">File <span>*</span></label><div class="col-sm-9" style="padding-top:5px"><input type="file" name="photo">(Only pdf, jpg, jpeg, gif and png are allowed)</div></div>'; }else if(type == 3){ var htmls = '<div class="form-group"><label for="" class="col-sm-2 control-label"> Name <span>*</span></label><div class="col-sm-6"><input type="text" autocomplete="off" class="form-control" name="report" value=""></div></div><div class="form-group"><label for="" class="col-sm-2 control-label">File <span>*</span></label><div class="col-sm-9" style="padding-top:5px"><input type="file" name="photo">(Only pdf, jpg, jpeg, gif and png are allowed)</div></div>'; }else if(type == 4){ var htmls = '<div class="form-group"><label for="" class="col-sm-2 control-label"> name <span>*</span></label><div class="col-sm-6"><input type="text" autocomplete="off" class="form-control" name="report" value=""></div></div><div class="form-group"><label for="" class="col-sm-2 control-label">File <span>*</span></label><div class="col-sm-9" style="padding-top:5px"><input type="file" name="photo">(Only pdf, jpg, jpeg, gif and png are allowed)</div></div>'; }else{ var htmls = '<div class="form-group"><label for="" class="col-sm-2 control-label"> name <span>*</span></label><div class="col-sm-6"><input type="text" autocomplete="off" class="form-control" name="report" value=""></div></div><div class="form-group"><label for="" class="col-sm-2 control-label">File <span>*</span></label><div class="col-sm-9" style="padding-top:5px"><input type="file" name="photo">(Only pdf, jpg, jpeg, gif and png are allowed)</div></div>'; } if(type==0){ var htmls = ''; } $("#html").html(htmls); } </script>