
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
include '../includes/settings/constant.php';
//include '../includes/settings/db.php';
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
if (!empty($_SESSION['adminId']) && !empty($_SESSION['admin_role_id'])) {
if($_SESSION['admin_role_id']==1){
//header("Location: index.php");
}elseif($_SESSION['admin_role_id']==2){
header("Location: ../dashboard/index.php");
}
}else{
header("Location: ../index.php");
exit();
}
$function = new FUNCTIONS();
if(isset($_POST['btnAddCrlrmin']) && !empty($_POST)){
// Include the database configuration file
//include_once 'dbConfig.php';
//print_r($_FILES); exit;
$title = !empty($_POST['title'])?trim($_POST['title']):"";
// File upload configuration
$targetDir = "../uploads/circularsminutes/";
$allowTypes = array('jpg','png','jpeg','gif');
$statusMsg = $errorMsg = $insertValuesSQL = $errorUpload = $errorUploadType = '';
if(!empty(array_filter($_FILES['files']['name']))){
$sno=1;
foreach($_FILES['files']['name'] as $key=>$val){
// File upload path
$uniqname = uniqid('crlrmin-',false);
$fileName = basename($_FILES['files']['name'][$key]); //exit;
$targetFilePath = $targetDir . $fileName; //exit;
// Check whether file type is valid
$filename2 = pathinfo($targetFilePath);
//$filename2['filename']."-".$uniqname; exit;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
$newfileName = $filename2['filename']."-".$uniqname.".".$fileType;
$targetFilePath2 = $targetDir . $newfileName;
if(in_array($fileType, $allowTypes)){
// Upload file to server
if(move_uploaded_file($_FILES["files"]["tmp_name"][$key], $targetFilePath2)){
// Image db insert sql
$insertValuesSQL .= "('".$title."','".$newfileName."', '".$sno."', NOW()),";
}else{
$errorUpload .= $_FILES['files']['name'][$key].', ';
}
}else{
$errorUploadType .= $_FILES['files']['name'][$key].', ';
}
$sno++;
}
if(!empty($insertValuesSQL)){
$insertValuesSQL = trim($insertValuesSQL,',');
// Insert image file name into database
$pdodb = PDODB::getInstance();
$sql = "INSERT INTO tb_circulars_minutes_new (title, file_name, sort_by, uploaded_on) VALUES $insertValuesSQL";
//exit;
$result = $pdodb->query($sql);
//$insert = $pdodb->query("INSERT INTO images (file_name, uploaded_on) VALUES $insertValuesSQL");
//exit;
if($result){
$errorUpload = !empty($errorUpload)?'Upload Error: '.$errorUpload:'';
$errorUploadType = !empty($errorUploadType)?'File Type Error: '.$errorUploadType:'';
$errorMsg = !empty($errorUpload)?'<br/>'.$errorUpload.'<br/>'.$errorUploadType:'<br/>'.$errorUploadType;
$statusMsg = "Files are uploaded successfully.".$errorMsg;
}else{
$statusMsg = "Sorry, there was an error uploading your file.";
}
}
}else{
$statusMsg = 'Please select a file to upload.';
}
// Display status message
//echo $statusMsg;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INSPINIA | Basic Form</title>
<?php include_once '../layout/style.php'; ?>
</head>
<body>
<div id="wrapper">
<?php $currentPage = 'circularsminutes-create'; include_once '../layout/side-bar.php'; ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once '../layout/header.php'; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-10">
<h2>Add Circulars & Minutes Form</h2>
</div>
<div class="col-lg-2">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title back-change">
<!-- <h5>Image cropper <small>http://fengyuanchen.github.io/cropper/</small></h5> -->
<p style="color:red; text-align: center;"><?=(!empty($statusMsg))?$statusMsg:'';?>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">Config option 1</a>
</li>
<li><a href="#">Config option 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="row">
<form method="POST" action="" enctype="multipart/form-data" id="addGallery">
<div class="col-sm-6 b-r">
<div class="form-group"><label>Title</label> <input type="text" placeholder="Enter Title" name="title" id="title" class="form-control">
</div>
<div class="form-group"><label>Select Images</label>
<input type="file" class="btn btn-primary" name="files[]" multiple>
</div>
<div>
<button class="btn btn-sm btn-primary pull-right m-t-n-xs" name="btnAddCrlrmin" id="btnAddCrlrmin" type="submit"><strong>Submit</strong></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once '../layout/script.php'; ?>
<script>
function tossterMsgAlert(msg='Welcome',title='') {
toastr.options = {
closeButton: true,
//debug: false,
newestOnTop: false,
//progressBar: false,
positionClass: 'toast-top-center',
preventDuplicates: true,
//onclick: null,
//showDuration: 300,
//hideDuration: 1000,
timeOut: 2000,
//extendedTimeOut: 1000,
//showEasing: 'swing',
//hideEasing: 'linear',
//showMethod: 'fadeIn',
hideMethod: 'fadeOut'
};
toastr.warning(title,msg);
}
</script>
<script type="text/javascript">
$("#addGallery").validate({
rules: {
title: {
required: true
},
file: {
required: true
}
},
messages: {
title: {
required: "Please Enter News Title"
},
file: {
required: "Please Upload Photo"
}
},
submitHandler: function(form) {
form.submit();
}
});
</script>
</body>
</html>


PK 99