ok
Direktori : /home/ngwcolle/public_html/mis/admin/ |
Current File : //home/ngwcolle/public_html/mis/admin/create_letter.php |
<?php include('includes/checklogin.php'); // error_reporting(E_ALL); check_login(); $query=$dbh->prepare("SELECT * FROM tblsetting WHERE id='1'"); // $query->bindParam(':param', $param); $query->execute(); $resultsetting = $query -> fetch(); $count = $dbh->prepare("select * from tblissueregister where isyearclose=0"); //$count=$dbo->prepare("delete from pdo_admin where status='F'"); $count->execute(); $no = $count->rowCount()+ $resultsetting[1];; // echo " No of records = ".$no; $skillset = array(); $memono = array(); if (isset($_POST['submit'])) { $txtletter = $_POST['txtletter']; $date = $_POST['date']; $letterto = $_POST['letterto']; $subject = $_POST['subject']; $reference = $_POST['reference']; $contents = $_POST['contents']; $txtmemo1 = $_POST['txtmemo1']; $txtmemo2 = $_POST['txtmemo2']; $txtmemo3 = $_POST['txtmemo3']; $txtmemo4 = $_POST['txtmemo4']; $txtmemo5 = $_POST['txtmemo5']; $hdnmemo1=$_POST['hdnmemo1'];$hdnmemo2=$_POST['hdnmemo2'];$hdnmemo3=$_POST['hdnmemo3']; $hdnmemo4=$_POST['hdnmemo4'];$hdnmemo5=$_POST['hdnmemo5']; $encl = $_POST['encl']; array_push($skillset, $txtmemo1, $txtmemo2, $txtmemo3, $txtmemo4, $txtmemo5); array_push($memono, $hdnmemo1, $hdnmemo2, $hdnmemo3, $hdnmemo4, $hdnmemo5); // print_r($memono); // echo "<br>"; $countmemo = count(array_filter($skillset)); // echo $countmemo; // move_uploaded_file($_FILES["animalimage"]["tmp_name"], "images/" . $_FILES["animalimage"]["name"]); $sql = "INSERT INTO tblletter(letterno,issuedate,letterto,subject,reference,content,memo_1,memo2,memo3,memo4,memo5,enclosure) VALUES(:letterno,:issuedate,:letterto,:subject,:reference,:content,:memo1,:memo2,:memo3,:memo4,:memo5,:enclosure)"; // // $sql = "INSERT INTO tblletter(letterno,issuedate,letterto,subject,reference,content,memo_1,memo2,memo3) // // VALUES(:letterno,:issuedate,:letterto,:subject,:reference,:content,:memo1,:memo2,:memo3)"; $query = $dbh->prepare($sql); $query->bindParam(':letterno', $txtletter, PDO::PARAM_STR); $query->bindParam(':issuedate', $date); $query->bindParam(':letterto', $letterto, PDO::PARAM_STR); $query->bindParam(':subject', $subject, PDO::PARAM_STR); $query->bindParam(':reference', $reference, PDO::PARAM_STR); $query->bindParam(':content', $contents, PDO::PARAM_STR); $query->bindParam(':memo1', $txtmemo1); $query->bindParam(':memo2', $txtmemo2, PDO::PARAM_STR); $query->bindParam(':memo3', $txtmemo3, PDO::PARAM_STR); $query->bindParam(':memo4', $txtmemo4, PDO::PARAM_STR); $query->bindParam(':memo5', $txtmemo5, PDO::PARAM_STR); $query->bindParam(':enclosure', $encl, PDO::PARAM_STR); $query->execute(); $lastInsertId = $dbh->lastInsertId(); if ($lastInsertId) { $type = "letter"; $sql1 = "INSERT INTO tblissueregister(despatchno,date,letterto,subject,type,documentno) VALUES(:despatchno,:date,:letterto,:subject,:type,:documentno)"; $query = $dbh->prepare($sql1); $query->bindParam(':despatchno', $txtletter, PDO::PARAM_STR); $query->bindParam(':date', $date); $query->bindParam(':letterto', $letterto, PDO::PARAM_STR); $query->bindParam(':subject', $subject, PDO::PARAM_STR); $query->bindParam(':type', $type, PDO::PARAM_STR); $query->bindParam(':documentno', $lastInsertId, PDO::PARAM_STR); // // $query->bindParam(':memo1', $txtmemo1); // // $query->bindParam(':memo2', $txtmemo2, PDO::PARAM_STR); // // $query->bindParam(':memo3', $txtmemo3, PDO::PARAM_STR); // // $query->bindParam(':memo4', $txtmemo4, PDO::PARAM_STR); // // $query->bindParam(':memo5', $txtmemo5, PDO::PARAM_STR); // // $query->bindParam(':enclosure', $encl, PDO::PARAM_STR); $query->execute(); if ($countmemo > 0) { for ($i = 0; $i<$countmemo; $i++) { // echo "Memo no to be insert" . $i; // echo $skillset[$i]; // echo "<br>"; // echo $memono[$i]; $sql1 = "INSERT INTO tblissueregister(despatchno,date,letterto,subject,type,documentno) VALUES('$memono[$i]','$date','$skillset[$i]','$subject','Memo','$lastInsertId')"; $dbh->exec($sql1); } } $msg = "Letter Created Successfully"; echo '<script>alert("Letter Addedd Successfully.")</script>'; echo "<script>window.location.href ='manage_letter.php'</script>"; } else { $error = "Something went wrong. Please try again"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <link href="img/logo/logo.png" rel="icon"> <title>Admin - Create Letter</title> <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"> <link href="css/ruang-admin.min.css" rel="stylesheet"> <script src="vendor/ckeditor/ckeditor.js"></script> <style> .errorWrap { padding: 10px; margin: 0 0 20px 0; background: #fff; border-left: 4px solid #dd3d36; -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); } .succWrap { padding: 10px; margin: 0 0 20px 0; background: #fff; border-left: 4px solid #5cb85c; -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); } </style> </head> <body id="page-top"> <div id="wrapper"> <!-- Sidebar --> <?php include('includes/sidebar.php'); ?> <!-- Sidebar --> <div id="content-wrapper" class="d-flex flex-column"> <div id="content"> <!-- TopBar --> <?php include('includes/header.php'); ?> <!-- Topbar --> <!-- Container Fluid--> <div class="container-fluid" id="container-wrapper"> <div class="d-sm-flex align-items-center justify-content-between mb-4"> <h1 class="h3 mb-0 text-gray-800">Letter</h1> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="dashboard.php">Home</a></li> <li class="breadcrumb-item active" aria-current="page">Add Letter Detail</li> </ol> </div> <div class="row"> <div class="col-lg-12"> <!-- Form Basic --> <div class="card mb-4"> <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> <h6 class="m-0 font-weight-bold text-primary">Write New Letter</h6> <a href="manage_letter.php" class="btn btn-info">Back to Letter</a> </div> <div class="card-body"> <?php if ($error) { ?> <div class="errorWrap"> <strong>ERROR</strong>:<?php echo htmlentities($error); ?> </div> <?php } else if ($msg) { ?> <div class="succWrap"> <strong>SUCCESS</strong>:<?php echo htmlentities($msg); ?> </div> <?php } ?> <form class="form-sample" method="post" enctype="multipart/form-data"> <span class="text-danger p-0 mt-0" id="letterno">Letter No/Date</span> <input type="text" id="txtletter" name="txtletter" class="form-control col-sm-3" style="display:inline" value="<?php echo $no + 1; ?>" readonly> / <input type="date" name="date" class="form-control col-sm-3" style="display:inline" required> <div class="row py-3"> <div class="form-group col-md-6"> <label class="col-sm-12 pl-0 pr-0">Letter write to whom</label> <div class="col-sm-12 pl-0 pr-0"> <textarea name="letterto" id="" cols="30" rows="3" class="form-control" required></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-6"> <label class="col-sm-12 pl-0 pr-0">Subject of the Letter</label> <div class="col-sm-12 pl-0 pr-0"> <textarea name="subject" id="" cols="30" rows="3" class="form-control" required></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12"> <label class="col-sm-12 pl-0 pr-0">Letter under reference</label> <div class="col-sm-12 pl-0 pr-0"> <textarea name="reference" id="" cols="30" rows="2" class="form-control"></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12"> <label class="col-sm-12 pl-0 pr-0">Letter Contents</label> <div class="col-sm-12 pl-0 pr-0"> <textarea name="contents" id="editor" cols="30" rows="15" class="form-control" required></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12"> <div class="form-check"> <input class="form-check-input" type="checkbox" id="check1" name="option1" value="something"> <label class="form-check-label">Memo1 Letter No:<span class="text-danger p-0" id="memo1"></span></label> <input type="hidden" id="hdnmemo1" name="hdnmemo1"> </div> <!-- <span class="text-danger p-0">Letter No/Date</span> --> <!-- <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault"> --> <div class="col-sm-12 pl-0 pr-0"> <textarea name="txtmemo1" id="txtmemo1" cols="30" rows="2" class="form-control"></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12"> <div class="form-check"> <input class="form-check-input" type="checkbox" id="check2" name="option1" value="something"> <label class="form-check-label">Memo2 <span class="text-danger p-0" id="memo2"></span></label> </div> <input type="hidden" id="hdnmemo2" name="hdnmemo2"> <div class="col-sm-12 pl-0 pr-0"> <textarea name="txtmemo2" id="txtmemo2" cols="30" rows="2" class="form-control" required></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12"> <div class="form-check"> <input class="form-check-input" type="checkbox" id="check3" name="option1" value="something"> <label class="form-check-label">Memo3 <span class="text-danger p-0" id="memo3"></span></label> </div> <input type="hidden" name="hdnmemo3" id="hdnmemo3"> <!-- <span class="text-danger p-0">Letter No/Date</span>Memo-3 <span class="text-danger p-0">Letter No/Date</span></label> --> <div class="col-sm-12 pl-0 pr-0"> <textarea name="txtmemo3" id="txtmemo3" cols="30" rows="2" class="form-control" required></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12"> <div class="form-check"> <input class="form-check-input" type="checkbox" id="check4" name="option1" value="something"> <label class="form-check-label">Memo4 <span class="text-danger p-0" id="memo4"></span></label> </div> <input type="hidden" name="hdnmemo4" id="hdnmemo4"> <!-- <label class="col-sm-12 pl-0 pr-0">Memo-4 <span class="text-danger p-0">Letter No/Date</span></label> --> <div class="col-sm-12 pl-0 pr-0"> <textarea name="txtmemo4" id="txtmemo4" cols="30" rows="2" class="form-control" required></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12"> <div class="form-check"> <input class="form-check-input" type="checkbox" id="check5" name="option1" value="something"> <label class="form-check-label">Memo5 <span class="text-danger p-0" id="memo5"></span></label> </div> <input type="hidden" name="hdnmemo5" id="hdnmemo5"> <!-- <label class="col-sm-12 pl-0 pr-0">Memo-5 <span class="text-danger p-0">Letter No/Date</span></label> --> <div class="col-sm-12 pl-0 pr-0"> <textarea name="txtmemo5" id="txtmemo5" cols="30" rows="2" class="form-control" required></textarea> <!-- <input type="text" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-12 pl-md-0"> <label class="col-sm-12 pl-2 pr-0">Enclosure(If Any)</label> <div class="col-sm-12 pl-2 pr-0"> <input type="text" class="form-control" name="encl" id="encl" placeholder="Attachment/Enclosure"> </div> </div> </div> <div class="row pl-2"> <!-- <div class="form-group col-md-6 pl-md-0"> <label class="col-sm-12 pl-0 pr-0">Animal Details</label> <div class="col-sm-12 pl-0 pr-0"> <textarea class="form-control" rows="5" cols="50" name="details" id="details" placeholder="Animal Details" required></textarea> </div> </div> --> <!-- <div class="form-group col-md-4 "> <label class="col-sm-12 pl-0 pr-0 ">Attach Animal Image</label> <div class="col-sm-12 pl-0 pr-0"> <input type="file" name="animalimage" id="animalimage" required> </div> </div> </div> --> <button type="submit" name="submit" class="btn-primary btn">Create</button> <button type="reset" class="btn-inverse btn">Reset</button> </form> </div> </div> </div> </div> <!--Row--> <!-- Modal Logout --> <?php include('includes/modal.php'); ?> </div> <!---Container Fluid--> </div> <!-- Footer --> <?php include('includes/footer.php'); ?> <!-- Footer --> </div> </div> <!-- Scroll to top --> <a class="scroll-to-top rounded" href="#page-top"> <i class="fas fa-angle-up"></i> </a> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="vendor/jquery-easing/jquery.easing.min.js"></script> <script src="js/ruang-admin.min.js"></script> <script> $(document).ready(function() { $("#txtmemo1").prop('disabled', true); $("#txtmemo2").prop('disabled', true); $("#txtmemo3").prop('disabled', true); $("#txtmemo4").prop('disabled', true); $("#txtmemo5").prop('disabled', true); $("#check1").click(function() { if ($(this).prop("checked")) { var letterno = $("#txtletter").val(); $('#txtmemo1').removeAttr('disabled'); $("#memo1").html(parseInt(letterno) + 1); $("#hdnmemo1").val(parseInt(letterno) + 1); } else { $("#memo1").html(""); $("#txtmemo1").prop('disabled', true); $("#txtmemo1").val(""); $("#hdnmemo1").val(""); } }); $("#check2").click(function() { if ($(this).prop("checked")) { var letterno = $("#memo1").text(); if (!letterno) { alert("Fille Memo-1 First"); return false; } else { var letterno1 = parseInt(letterno) + 1; $('#txtmemo2').removeAttr('disabled'); $("#memo2").html(letterno1); $("#hdnmemo2").val(letterno1); } } else { $("#memo2").html(""); $("#txtmemo2").prop('disabled', true); $("#txtmemo2").val(""); $("#hdnmemo2").val(""); } }); $("#check3").click(function() { if ($(this).prop("checked")) { var letterno = $("#memo2").text(); if (!letterno) { alert("Fille Memo-2 First"); return false; } else { var letterno2 = parseInt(letterno) + 1; $('#txtmemo3').removeAttr('disabled'); $("#memo3").html(letterno2); $("#hdnmemo3").val(letterno2); } } else { $("#memo3").html(""); $("#txtmemo3").prop('disabled', true); $("#txtmemo3").val(""); $("#hdnmemo3").val(""); } }); $("#check4").click(function() { if ($(this).prop("checked")) { var letterno = $("#memo3").text(); if (!letterno) { alert("Fille Memo-3 First"); return false; } else { var letterno2 = parseInt(letterno) + 1; $('#txtmemo4').removeAttr('disabled'); $("#memo4").html(letterno2); $("#hdnmemo4").val(letterno2); } } else { $("#memo4").html(""); $("#txtmemo4").prop('disabled', true); $("#txtmemo4").val(""); $("#hdnmemo4").val(""); } }); $("#check5").click(function() { if ($(this).prop("checked")) { var letterno = $("#memo4").text(); if (!letterno) { alert("Fille Memo-4 First"); return false; } else { var letterno2 = parseInt(letterno) + 1; $('#txtmemo5').removeAttr('disabled'); $("#memo5").html(letterno2); $("#hdnmemo5").val(letterno2); } } else { $("#memo5").html(""); $("#txtmemo5").prop('disabled', true); $("#txtmemo5").val(""); $("#hdnmemo5").val(""); } }); }); </script> <script> CKEDITOR.replace('editor'); </script> </body> </html>