ok

Mini Shell

Direktori : /proc/self/root/proc/thread-self/root/home/ngwcolle/public_html/mis/admin/
Upload File :
Current File : //proc/self/root/proc/thread-self/root/home/ngwcolle/public_html/mis/admin/expense_income.php

<?php
include('includes/checklogin.php');
check_login();
error_reporting(1);
if ($_POST['id']) {
  $id = $_POST['id'];
  $response = array();
  $select = $dbh->prepare("select * from tblaccount where id = :ppid");
  $select->bindParam(':ppid', $id);
  $select->execute();
  $row = $select->fetch(PDO::FETCH_ASSOC);
  if ($select->rowCount() > 0) {
    $response = $row;
  } else {
    $response = null;
  }
  // header('Content-Type: application/json');
  echo json_encode($response);

  exit;
}
$aid = intval($_GET['pid']);
if (isset($_POST['submit'])) {
  $txdate = $_POST['tdate'];
  $txamount = $_POST['fullamt'];
  $diffamt = $_POST['diffamt'];

  // $txtype = "Dr";
  $accounthead = $_POST['acchead'];
  $paidto = $_POST['details'];
  $remark = $_POST['reference'];
  // $aimage = $_FILES["animalimage"]["name"];
  // move_uploaded_file($_FILES["animalimage"]["tmp_name"], "images/" . $_FILES["animalimage"]["name"]);
  $sql = "UPDATE tbltrans set txdate=:aname,txamount=:cage,paidto=:adetails,remark=:aimage where id=:id";
  $query = $dbh->prepare($sql);
  $query->bindParam(':aname', $txdate, PDO::PARAM_STR);
  $query->bindParam(':cage', $txamount, PDO::PARAM_STR);
  // $query->bindParam(':feed', $txtype, PDO::PARAM_STR);
  // $query->bindParam(':breed', $accounthead, PDO::PARAM_STR);
  $query->bindParam(':adetails', $paidto, PDO::PARAM_STR);
  $query->bindParam(':aimage', $remark, PDO::PARAM_STR);
  $query->bindParam(':id', $aid);
  // $lastInsertId = $dbh->lastInsertId();
  if ($query->execute()) {
    // $count = $dbh->prepare("select * from  tbltrans ");
    // //$count=$dbo->prepare("delete from pdo_admin where status='F'");
    // $count->execute();
    // $no = "NGWC" . str_pad($count->rowCount(), 5, 0, STR_PAD_LEFT);
    // $msg = "Animal Created Successfully";
    // $sql2 = "UPDATE  tbltrans set txid = '$no' where id='$lastInsertId'";
    // $dbh->exec($sql2);
    $sql1 = "UPDATE  tblaccount set amtbalance = amtbalance+'$diffamt' where id='$accounthead'";
    $dbh->exec($sql1);
    echo '<script>alert("Collection Updated Successfully.")</script>';
    echo "<script>window.location.href ='manage_income.php'</script>";
    // exit();
  } 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 - Update Expense</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">
  <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">Expense Transaction</h1>
            <ol class="breadcrumb">
              <li class="breadcrumb-item"><a href="dashboard.php">Home</a></li>
              <li class="breadcrumb-item active" aria-current="page">Updte Expense 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">Updte Expense</h6>

                </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 tbltrans 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">
                        <div class="row ">
                          <div class="form-group col-md-8 pl-md-0">
                            <label class="col-sm-12 pl-0 pr-0">Paid From Head of Account</label>
                            <div class="col-sm-12 pl-0 pr-0">

                              <select name="acchead" id="acchead" class="form-control bg-light">
                                <option value="">--Select Account Head--</option>
                                <?php

                                $smt = $dbh->prepare("select * from tblaccount where status='1'");
                                $smt->execute();
                                $data = $smt->fetchAll(PDO::FETCH_OBJ);
                                foreach ($data as $row) {
                                ?>
                                  <option value="<?php echo $row->id; ?>" <?php if ($row->id == $result->accounthead) echo 'selected="selected"'; ?>><?php echo strtoupper($row->accounthead); ?></option>
                                <?php } ?>
                              </select>

                              <!-- <input type="text" class="form-control" name="animalname" id="animalname" placeholder="Animal Name" required> -->
                            </div>
                          </div>
                          <div class="form-group col-md-4 pl-md-0">
                            <label class="col-sm-12 pl-0 pr-0">Balance Fund</label>
                            <div class="col-sm-12 pl-0 pr-0">

                              <input type="text" name="balance" id="balance" placeholder="Balance Fund" class="form-control text-danger" readonly>
                            </div>
                          </div>

                        </div>

                        <div class="row">
                          <div class="form-group col-md-6 pl-md-0">
                            <label class="col-sm-12 pl-0 pr-0">Transaction Date</label>
                            <div class="col-sm-12 pl-0 pr-0">
                              <input type="date" class="form-control" value="<?php echo htmlentities($result->txdate); ?>" name="tdate" id="cage" placeholder="Date" required>
                            </div>
                          </div>
                          <div class="form-group col-md-6 pl-md-0">
                            <label class="col-sm-12 pl-0 pr-0 text-danger">Amount Paid(In Rs.) Wrongly</label>
                            <div class="col-sm-12 pl-0 pr-0">
                              <input type="text" readonly class="form-control bg-danger text-white font-bold" name="amtpaid1" id="amtpaid1" value="<?php echo htmlentities($result->txamount); ?>" placeholder="Amount Paid in Rs." required>
                            </div>
                          </div>


                          <!-- <div class="form-group col-md-6 pl-md-0">
                        <label class="col-sm-12 pl-0 pr-0">Breed</label>
                        <div class="col-sm-12 pl-0 pr-0">
                          <input type="text" class="form-control" name="breed" id="breed" placeholder=" Breed" required>
                        </div>
                      </div> -->
                        </div>
                        <div class="row">
                          <div class="form-group col-md-6 pl-md-0">
                            <label class="col-sm-12 pl-0 pr-0">Amount Paid(In Rs.) Actual</label>
                            <div class="col-sm-12 pl-0 pr-0">
                              <input type="text" class="form-control" name="fullamt" id="amtpaid" placeholder="Amount in Rs." required>
                            </div>
                          </div>
                          <div class="form-group col-md-6 pl-md-0">
                            <label class="col-sm-12 pl-0 pr-0 text-info">Amount Difference</label>
                            <div class="col-sm-12 pl-0 pr-0">
                              <input type="text" class="form-control 0 text-danger font-bold" name="diffamt" id="diffamt" placeholder="Amount Paid in Rs." required>
                            </div>
                          </div>
                        </div>
                        <div class="row">
                          <div class="form-group col-md-6 pl-md-0">
                            <label class="col-sm-12 pl-0 pr-0">Expense Details</label>
                            <div class="col-sm-12 pl-0 pr-0">
                              <textarea class="form-control" rows="5" cols="50" name="details" id="details" placeholder="Expense Details" required><?php echo htmlentities($result->paidto); ?></textarea>
                            </div>
                          </div>
                          <div class="form-group col-md-6 pl-md-0 ">
                            <label class="col-sm-12 pl-0 pr-0 ">Cheque/DD/UPI/TV/UTR No with Date</label>
                            <div class="col-sm-12 pl-0 pr-0">
                              <textarea class="form-control" rows="5" cols="50" name="reference" id="details" placeholder="Transaction Reference Details" required><?php echo htmlentities($result->remark); ?></textarea>
                            </div>
                          </div>
                        </div>
                        <button type="submit" name="submit" id="btnSubmit" class="btn-primary btn">Create</button>

                        <button type="reset" class="btn-inverse btn">Reset</button>
                      </form>
                </div>
              </div>
          <?php }
                  } ?>
            </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() {
      // get balance of HOA 
      var selectedCountry = $('#acchead').val();
      $.ajax({
        method: "POST",
        url: "expense_update.php",
        // data: sub_id,
        // data:'subid='+sub_id,
        data: {
          id: selectedCountry
        },
        dataType: "json",
        cache: false,
        success: function(response) {

          if (response) {
            $("#balance").val(response['amtbalance']);

          }

          console.log(response);

        }
      });

      //get balance of HIA
      $("#btnSubmit").click(function() {

        var balance = $('#balance').val();
        var diffamt = $('#diffamt').val();
        if (parseInt(balance) <= 0) {
          alert("Not sufficient fund in this head");
          return false;

        }
        if (parseInt(diffamt) = 0) {
          alert("Enter correct amount");
          return false;

        }
      });

      $('#pin,#amtpaid,#distance,#whno,#stmobile,#gcontact,#aadhar').keypress(function(e) {

        // var charCode = (e.which) ? e.which : event.keyCode    

        // if (String.fromCharCode(charCode).match(/[^0-9]/g))    

        //     return false;         
        var caret = e.target.selectionStart;
        var nowStr = $(this).val().substr(0, caret) + String.fromCharCode(e.which) + $(this).val().substr(caret);
        if (!$.isNumeric(nowStr)) e.preventDefault();

      });
      $("#amtpaid").change(function() {
        var actualamt = $('#amtpaid1').val();
        var prevamt = $(this).val();
        //  var admyear = $('#admyear').children("option:selected").val();
        // alert("You have selected the country - " + admyear);
        if (!$('#amtpaid').val()) {
          alert('Select Account Head!');
          $('#diffamt').val('0');
          return false;
        }
        var difference = parseInt(prevamt) - parseInt(actualamt);
        $('#diffamt').val(difference);
        alert(actualamt);
        // ajax call



        // ajax return
      });
    });
  </script>
</body>

</html>

Zerion Mini Shell 1.0