ok
Direktori : /home2/selectio/public_html/obnovit-tracking/ |
Current File : /home2/selectio/public_html/obnovit-tracking/salary-add.php |
<?php include "header.php"; if(isset($_POST['add_incentive'])){ try{ $date = date('Y-m-d h:i:s', time()); $employee_salary = $_POST['employee_salary']; $salary_amount = $_POST['salary_amount']; $remaining_amount = $employee_salary-$salary_amount; if(isset($_POST['salary_month']) && $_POST['employee_id']){ $statement1 = $pdo->prepare("SELECT * FROM `tbl_salary` WHERE salary_month=? and user_id=?"); $statement1->execute(array($_POST['salary_month'],$_POST['employee_id'])); $results1 = $statement1->fetchAll(PDO::FETCH_ASSOC); if($results1){ $warning = 'This User Salary is Already Existed'; }else{ $statement = $pdo->prepare("INSERT INTO `tbl_salary` (`user_id`, `salary_amount`, `salary_month`, `payment_type`, `salary_date`, `salary_notes`,`employee_salary`,`remaining_amount`) VALUES (?,?,?,?,?,?,?,?)"); $result=$statement->execute(array($_POST['employee_id'],$_POST['salary_amount'],$_POST['salary_month'],$_POST['payment_type'],$_POST['salary_date'],$_POST['salary_notes'],$_POST['employee_salary'],$remaining_amount)); if($result){ $ids = $pdo->lastInsertId(); $statement = $pdo->prepare("INSERT INTO `tbl_salary_employee` (`employee_id`, `salary_amount`, `salary_month`, `paid_payment_type`, `paid_date`,`salary_id`) VALUES (?,?,?,?,?,?)"); $result=$statement->execute(array($_POST['employee_id'],$_POST['salary_amount'],$_POST['salary_month'],$_POST['payment_type'],$_POST['salary_date'],$ids)); $message = 'Salary is Added Successfully!'; unset($_POST); }else{ $warning="Something went wrong try again..."; } } } }catch(Exception $e){ $error=$e; } } ?> ?> <div class="content-wrapper" style="background:white;"> <div class="col-lg-12 alerts"> <div id="custom-alerts" style="display:none;"> <div class="alert alert-dismissable"> <div class="custom-msg"></div> </div> </div> <?php if ($error) { ?> <div class="alert alert-danger alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4><i class="icon fa fa-ban"></i> Error</h4> <?= $error; ?> </div> <?php $error=0;} if ($warning) { ?> <div class="alert alert-warning alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4><i class="icon fa fa-warning"></i> warning</h4> <?= $warning; ?> </div> <?php $warning=0;} if ($message) { ?> <div class="alert alert-success alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4> <i class="icon fa fa-check"></i> Success</h4> <?= $message; ?> </div> <?php $message=0; } ?> </div> <div class="clearfix"></div> <section class="content"> <div class="row"> <div class="col-xs-12"> <div> <div class="box-header"> <h3 class="box-title"><b>Create New Salary: </b></h3> </div> <div class="box-body"> <div class="col-lg-12"> <form action="" class="validation" enctype="multipart/form-data" method="post" accept-charset="utf-8"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label class="required" for="expense">Employee Name</label> <select name="employee_id" class="form-control select2" style="width:100%" id="employee_id" required> <option value="0">Select a Employee Name</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_user` where status=1"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { echo "<option value=".$result['id'].">".$result['uname']."</option>"; }?> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="expense">Employee Total Salary Amount</label> <select name="employee_salary" class="form-control" style="width:100%" id="employee_salary" required="required"> </select> <!--<input type="text" name="employee_salary" value="" placeholder="Enter the Employee Salary Amount" class="form-control tip" id="employee_salary" />--> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="expense">Employee Salary Month</label> <select name="salary_month" class="form-control select2" style="width:100%" id="salary_month" required="required"> <option value="0">Selcet Salary Month</option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="Jully">Jully</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="expense">Employee Salary Amount</label> <input type="number" name="salary_amount" value="" placeholder="Enter the Salary Amount" class="form-control tip" id="salary_amount" /> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="expense">Payment Type</label> <select name="payment_type" class="form-control select2" style="width:100%" id="payment_type" required="required"> <option value="0">Selcet Payment Type</option> <option value="Cash">Cash</option> <option value="UPI">UPI</option> <option value="Account Transfer">Account Transfer</option> <option value="Card">Card</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="expense">Salary Date</label> <input type="date" name="salary_date" value="" class="form-control tip" id="salary_date" required="required" /> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="optional" for="expense">Salary Notes</label> <textarea name="salary_notes" rows="2" class="form-control tip" id="salary_notes"></textarea> </div> </div> </div> <div class="form-group" style="text-align:center;"> <input type="submit" name="add_incentive" value="Add Salary" class="btn btn-success" /> </form> </div> </div> <div class="form-group" style="text-align:center;"> <a href="salary-add.php"><button class="btn btn-primary" ><i class="fa fa-refresh"></i> Reset Form</button></a> <a href="salary-list.php"><button class="btn btn-warning" ><i class="fa fa-chevron-left"></i> Back to List</button></a> </div> <div class="clearfix"></div> </div> </div> </div> </div> </section> <?php include "footer.php"; ?> <script> $('#add_new_employee').on('click', function() { html = '<div class="col-md-4"><div class="form-group"><label class="required" for="expense">Employee Name</label><select name="employee_id[]" class="form-control select2" style="width:100%" id="employee_id" required><option value="0">Select a Employee Name</option><?php $statement = $pdo->prepare("SELECT * FROM `tbl_user` where status=1"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC);foreach ($location_result as $result) { echo "<option value=".$result['id'].">".$result['name']."</option>"; }?></select></div></div><div class="col-md-4"><div class="form-group"><label class="required" for="expense">Incentive Amount</label><input type="number" name="incentive_amount[]" value="" placeholder="Enter the Incentive Amount" class="form-control tip" id="incentive_amount" /></div></div><div class="col-md-4"><div class="form-group"><label class="required" for="expense">Incentive Date</label><input type="date" name="incentive_date[]" value="" class="form-control tip" id="incentive_date" required="required" /></div></div>'; $('#employee_section').append(html); }); </script> <script> $(document).ready(function(){ get_plot_name(); $("#property").change(function () { get_plot_name(); }); function get_plot_name(){ $('#plot').empty(); var property=$('#property').val(); $.ajax({ url: 'api/get-all-plots-api.php', type: 'post', dataType: 'json', data: {type:'get_plot_name',property:property}, success: function (response) { console.log(response); if(response['error']==false){ var m=''; for(var n=0;n<response['data'].length;n++){ m+='<option value='+response['data'][n]['id']+'>'+response['data'][n]['plot_name']+'</option>'; } $('#plot').append(m); } } }); } }); </script> <script> $(document).ready(function(){ get_employee_salary(); $("#employee_id").change(function () { get_employee_salary(); }); function get_employee_salary(){ $('#employee_salary').empty(); var employee_id=$('#employee_id').val(); $.ajax({ url: 'api/get-all-plots-api.php', type: 'post', dataType: 'json', data: {type:'get_employee_salary',employee_id:employee_id}, success: function (response) { console.log(response); if(response['error']==false){ var m=''; for(var n=0;n<response['data'].length;n++){ m+='<option value='+response['data'][n]['id']+'>'+response['data'][n]['plot_name']+'</option>'; } $('#plot').append(m); } } }); } }); </script> <script> $(document).ready(function(){ get_employee_salary(); $("#employee_id").change(function () { get_employee_salary(); console.log('It is Working Get Employee Salary'); }); function get_employee_salary(){ $('#employee_salary').empty(); var employee_id=$('#employee_id').val(); $.ajax({ url: 'api/custom-api.php', type: 'post', dataType: 'json', data: {type:'get_employee_salary',employee_id:employee_id}, success: function (response) { console.log(response); if(response['error']==false){ var m=''; for(var n=0;n<response['data'].length;n++){ m+='<option value='+response['data'][n]['salary']+'>'+response['data'][n]['salary']+'</option>'; } $('#employee_salary').append(m); } } }); } }); </script>