ok

Mini Shell

Direktori : /home/ngwcolle/public_html/mis/admin/
Upload File :
Current File : //home/ngwcolle/public_html/mis/admin/update_letter.php

<?php
include('includes/checklogin.php');
// error_reporting(E_ALL);
check_login();
$aid = intval($_GET['pid']);
$count = $dbh->prepare("select * from  tblissueregister where isyearclose=0");
//$count=$dbo->prepare("delete from pdo_admin where status='F'");
$count->execute();
$no = $count->rowCount();
// echo " No of records = ".$no;
$skillset = array();
$memono = array();
if(isset($_POST['submit']))
{
  // $letterto = $dbh->quote($_POST['letterto']);
  $letterto = $_POST['letterto'];
  $subject = htmlspecialchars($_POST['subject']);
  $reference = $_POST['reference'];
  $contents = $_POST['contents'];
  $txtmemo1 = $_POST['txtmemo1'];
  $txtmemo2 = $_POST['txtmemo2'];
  $txtmemo3 = $_POST['txtmemo3'];
  $txtmemo4 = $_POST['txtmemo4'];
  $txtmemo5 = $_POST['txtmemo5']; 
  $encl = $_POST['encl'];
  $sql="UPDATE tblletter set letterto=:letterto,subject=:subject,reference=:reference,content=:content,memo_1=:memo1,memo2=:memo2,
  memo3=:memo3,memo4=:memo4,memo5=:memo5,enclosure=:enclosure where id=:aid";
  $query = $dbh->prepare($sql);
  $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->bindParam(':aid',$aid);
  $query->execute();
  if($query->execute()){
   $msg="Letter details updated successfully";
 }else{
   $msg="Failed Please try again later";
 }
 
}
// if (isset($_POST['submittttttttttttttt'])) {
  // $txtletter = $_POST['txtletter'];
  // $date = $_POST['date'];
 
  
 
  // $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)";
 
  
  
// }
?>
<!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">Update 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">Update 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
                  } ?>
                  <?php
                  $aid = intval($_GET['pid']);
                  $sql = "SELECT * from tblletter where id=:aid";
                  $query = $dbh->prepare($sql);
                  $query->bindParam(':aid', $aid, PDO::PARAM_STR);
                  $query->execute();
                  $results = $query->fetchAll(PDO::FETCH_OBJ);
                  $cnt = 1;
                  if ($query->rowCount() > 0) {
                    foreach ($results as $result) {
                  ?>
                      <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 htmlentities($result->letterno); ?>" readonly> /
                        <input type="date" name="date" class="form-control col-sm-3" style="display:inline" required value="<?php echo htmlentities($result->issuedate); ?>">
                        <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><?php echo $result->letterto; ?></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><?php echo htmlentities($result->subject); ?></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"><?php echo htmlentities($result->reference); ?></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><?php echo htmlentities($result->content); ?></textarea>
                              <!-- <input type="text"  name="animalname" id="animalname" placeholder="Animal Name" required> -->
                            </div>
                          </div>
                          <?php
                          $sql1 = "SELECT despatchno from tblissueregister where documentno=:aid and type='Letter Memo'                          ";
                          $query1 = $dbh->prepare($sql1);
                          $query1->bindParam(':aid', $aid, PDO::PARAM_STR);
                          $query1->execute();
                          // $results1=array();
                          // $results1 = $query1->fetchAll(PDO::FETCH_ASSOC);
                          // $memo1no = $results1[0];
                          // $dno=array();
                          //   if ($query1->rowCount() > 0) {
                          $resultarray = array();

                          while ($row = $query1->fetch(PDO::FETCH_ASSOC)) {
                            $resultarray[] = $row;
                          }


                          // echo $resultarray[1]['despatchno'];
                          // echo $resultarray[2]['despatchno'];
                          // echo $resultarray[3]['despatchno'];
                          // echo $resultarray[4]['despatchno'];
                          // echo $resultarray[0?]['despatchno'];
                          // print_r($resultarray);
                          ?>

                          <div class="form-group col-md-12">
                            <div class="form-check">
                              <input class="form-check-input" disabled 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" value="<?php echo $resultarray[0]['despatchno']; ?>">
                            </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"><?php echo htmlentities($result->memo_1); ?></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" disabled type="checkbox" id="check2" name="option1" value="something">
                              <label class="form-check-label">Memo2 <span class="text-danger p-0" id="memo2"></span></label>
                              <input type="hidden" id="hdnmemo2" name="hdnmemo2" value="<?php echo $resultarray[1]['despatchno']; ?>">
                            </div>

                            <div class="col-sm-12 pl-0 pr-0">
                              <textarea name="txtmemo2" id="txtmemo2" cols="30" rows="2" class="form-control"><?php echo htmlentities($result->memo2); ?></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" disabled type="checkbox" id="check3" name="option1" value="something">
                              <label class="form-check-label">Memo3 <span class="text-danger p-0" id="memo3"></span></label>
                              <input type="hidden" name="hdnmemo3" id="hdnmemo3" value="<?php echo $resultarray[2]['despatchno']; ?>">
                            </div>

                            <!-- <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"><?php echo htmlentities($result->memo3); ?></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" disabled type="checkbox" id="check4" name="option1" value="something">
                              <label class="form-check-label">Memo4 <span class="text-danger p-0" id="memo4"></span></label>
                              <input type="hidden" name="hdnmemo4" id="hdnmemo4" value="<?php echo $resultarray[3]['despatchno']; ?>">
                            </div>

                            <!-- <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"><?php echo htmlentities($result->memo4); ?></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" disabled type="checkbox" id="check5" name="option1" value="something">
                              <label class="form-check-label">Memo5 <span class="text-danger p-0" id="memo5"></span></label>
                              <input type="hidden" name="hdnmemo5" id="hdnmemo5" value="<?php echo $resultarray[4]['despatchno']; ?>">
                            </div>

                            <!-- <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"><?php echo htmlentities($result->memo5); ?></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" value="<?php echo htmlentities($result->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">Update</button>

                          <button type="reset" class="btn-inverse btn">Reset</button>
                      </form>
                  <?php
                    }
                  } ?>
                </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>

Zerion Mini Shell 1.0