0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: pi_add_budget_form.php
<?php $MAIN_HEADING="Add Voucher" ; $SUB_HEADING="" ; require_once "pi_add_budget_form_cntrl.php"; include( "include/pi_header.php"); require_once "../lib/config.php"; ?> <?php include( "include/alert_message.php"); ?> <?php $json=json_encode($project_details) ?> <script> var array_code = '<?php echo $json; ?>'; var proJson = JSON.parse(array_code); </script> <?php if(!empty($last_project_details) && isset($last_project_details->id)) { ?> <div class="nav navbar-right panel_toolbox hide"> <a href="pi_edit_budget_form.php?id=<?php echo $last_project_details->id?>" class="btn btn-success btn-xs ">Edit Lastly Added Form</a> </div> <?php } ?> <form action="pi_add_budget_form_cntrl.php" method="post" class="form-horizontal form-label-left" name="form1" id="form1" data-parsley-validate=""> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Project Code </label> <div class="col-md-6 col-sm-6 col-xs-12"> <select required="" data-parsley-minSelect="1" data-parsley-validate-if-empty="true" class="form-control col-md-7 col-xs-12 select2_single" name="project_id" id="project_id"> <?php if(!empty($project_details)) foreach ($project_details as $j=> $value) { ?> <option value="<?php echo $j; ?>"> <?php echo $value[ 'project_code']; ?> </option> <?php } ?> </select> </div> <div class="col-md-3 col-sm-3 col-xs-12" style="margin-bottom: -400px;background-color: #eee;" id="title"> <?php if(!empty($project_details)){ reset($project_details); $first_key=key($project_details); $var=$project_details[$first_key]; echo "<b>".$var[ 'project_code']. "</b><br>".$var[ 'project_title']; } ?> </div> </div> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Supplier Name </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input type="text" class="form-control col-md-7 col-xs-12" required="required" name="name" value="<?php if (isset($name) && $name!=" ") { echo $name; } ?>" /> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'name'])) { echo $error[ 'name']; }?> </li> </ul> </div> </div> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Current Date </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input readonly value="<?php echo date(DATE_FORMAT)?>" type="text" class="date-picker form-control col-md-7 col-xs-12" required="required" name="date_current" value="<?php if (isset($date_current) && $date_current!=" ") { echo $date_current; } ?>" /> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'date_current'])) { echo $error[ 'date_current']; }?> </li> </ul> </div> </div> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Debit Head </label> <div class="col-md-6 col-sm-6 col-xs-12"> <select class="form-control col-md-7 col-xs-12" required="" name="debit_head" id="debit_head"> <option value="">Please select</option> <?php if(!empty($debit_head_details)) foreach ($debit_head_details as $value) { ?> <option master_debit_id="<?php echo $value['master_debit']; ?>" value="<?php echo $value['id']; ?>"> <?php echo $value[ 'name']; ?> </option> <?php } ?> </select> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'debit_head'])) { echo $error[ 'debit_head']; }?> </li> </ul> </div> </div> <?php // echo "<pre>"; // print_r($debit_head_details); // echo "</pre>"; ?> <input readonly type="hidden" id="debit_master" class=" form-control col-md-7 col-xs-12 hide " required="required" name="debit_master" value="" /> <!-- <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Installement </label> <div class="col-md-6 col-sm-6 col-xs-12"> <select class="form-control col-md-7 col-xs-12" required="" name="installment_id" id="installment_id"> <option value="">Please select</option> <?php if(!empty($installment_details)) foreach ($installment_details as $value) { ?> <option value="<?php echo $value['id']; ?>"> <?php echo $value[ 'name']; ?> </option> <?php } ?> </select> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'installment_id'])) { echo $error[ 'installment_id']; }?> </li> </ul> </div> </div> --> <div class="form-group invoice"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Invoice Date </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input readonly type="text" class="form-control col-md-7 col-xs-12 date" name="invoice_date" id="invoice_date" value="<?php if (isset($invoice_date) && $invoice_date!=" ") { echo $invoice_date; } ?>" /> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'invoice_date'])) { echo $error[ 'invoice_date']; }?> </li> </ul> </div> </div> <div class="form-group invoice"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Invoice Number </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input type="text" class="form-control col-md-7 col-xs-12" name="invoice_number" id="invoice_number" value="<?php if (isset($invoice_number) && $invoice_number!=" ") { echo $invoice_number; } ?>" /> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'invoice_number'])) { echo $error[ 'invoice_number']; }?> </li> </ul> </div> </div> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Amount </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input type="text" class="form-control col-md-7 col-xs-12 number" required name="amount" id="amount" value="<?php if (isset($amount) && $amount!=" ") { echo $amount; } ?>" /> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'amount'])) { echo $error[ 'amount']; }?> </li> </ul> </div> </div> <div class="ln_solid"></div> <div class="form-group"> <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-4"> <button class="btn btn-success" type="submit" name="save" id="save" value="SAVE"><i class="fa fa-save"></i> Save</button> </div> </div> </form> </div> </div> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="x_panel"> <div class="x_title"> <h2>Pending List</h2> <ul class="nav navbar-right panel_toolbox"> <button class="btn btn-success" id="verify" onclick="verifyPendingBudgetForms()"> <i class="fa fa-check-circle" ></i> Verify</button> <i class="fa fa-spin fa-refresh" style="display:none" id="verify-spin"></i> </ul> <div class="clearfix"></div> <span id="verify-error" style="color:red;margin-top:10px;display:none" class="pull-right ">Please select the checkbox to verify the files</span> </div> <div class="x_content"> <div class=""> <table class="table table-striped table-bordered jambo_table bulk_action " id="table"> <thead> <tr> <th> <input type="checkbox" id="check-all" class="flat"> </th> <th>Supplier Name</th> <th>Invoice No</th> <th>Invoice Date</th> <th>Amount</th> <th>Project Code</th> <th>Debit Head</th> <th>Remarks</th> <th>Date</th> <th>Status</th> <th>Action</th> </tr> </thead> <tbody> <?php $i=0; if(!empty($pending_projets)){ foreach ($pending_projets as $value) { ?> <tr id="<?php echo $value["id"] ?>"> <td class="a-center "> <input type="checkbox" class="flat" name="table_records" value="<?php echo $value["id"] ?>"> </td> <td><?php echo $value["sup_name"] ?></td> <td><?php echo $value["invoice_number"] ?></td> <td><?php echo $value["invoice_date"] ?></td> <td><?php echo $value["amount"] ?></td> <td><?php echo $value["project_code"] ?></td> <td><?php echo $value["debit_head"] ?></td> <td><?php echo $value["remarks"] ?></td> <td><?php echo $value["created_on"] ?></td> <?php switch($value["status"]){ case "pending" : $color= "info"; break; case "accepted" : $color= "success"; $show_actions= false; break; case "declined" : $color= "danger"; $show_actions= false ; break; case "verified" : $color= "warning"; $show_actions= false ; break; default : $color= "info"; break; } $status_str = '<label class="label label-'.$color.'" >'.ucwords($value['status']).'</label>'; ?> <td><?php echo $status_str ?></td> <td><a href="<?php echo $server_ip ?>user/pi_edit_budget_form.php?id=<?php echo $value['id']?>" class="btn btn-xs btn-success" >Edit</a> <a onclick="return confirm('Delete this voucher?')" href="<?php echo $server_ip ?>user/pi_delete_voucher.php?id=<?php echo $value['id']?>" class="btn btn-xs btn-danger" >Delete</a> </td> </tr> <?php } }else{ echo '<tr class="odd"><td valign="top" colspan="11" class="dataTables_empty">No unverified vouchers found</td></tr>'; } ?> </tbody> <tbody> </tbody> </table> </div> </div> </div> </div> <?php include "include/footer.php"; ?> <script> $(document).ready(function() { $("#debit_head").change(function(argument) { var val = $(this).find("option:selected").attr("master_debit_id"); if (val == null && val.length < 1) return; $("#debit_master").val(val) if (val == 1) { $(".invoice").hide(); } else { $(".invoice").show() } }); $(".date").daterangepicker({ singleDatePicker: true, calender_style: "picker_4", locale: { format: 'DD/M/YYYY', separator: ' - ', customRangeLabel: 'Custom', }, startDate: '<?php echo date("m-d-Y") ?> ', }, function(start, end, label) { console.log($(this)) $(".date").val(moment($(".date").val()).format(COMMON_DATE_FORMAT)); }); $(".select2_single").select2({ placeholder: "Select a project code", allowClear: true, noResults: "No project code found. Add project first", }).on('change', function(e) { getDebitHeadAjax(this.value); }) }); function getDebitHeadAjax(val) { showProjectTitile(val); $.ajax({ type: 'POST', url: BASE_URL + "pi_ajax.php", data: { f: "get_debit_head", project_id: val }, dataType: 'json', error: function() { }, success: function(data) { console.log(data); $("#debit_head").find('option').not(':first').remove(); $.each(data.budget_head, function(index, value) { $("#debit_head").append( $('<option></option>').val(value.id).html(value.name).attr("master_debit_id", value.master_debit) ); }); $("#installment_id").find('option').not(':first').remove(); $.each(data.installment, function(index, value) { $("#installment_id").append( $('<option></option>').val(value.id).html(value.name) ); }); }, }); } $(function() { $('#form1').parsley({ excluded: "input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden" }).on('field:validated', function(fieldInstance) { console.log(fieldInstance.$element); if (!fieldInstance.$element.is(":visible") ) { fieldInstance._ui.$errorsWrapper.css('display', 'none'); fieldInstance.validationResult = true; return true; } }) .on('form:submit', function() { return true; // Don't submit form for this demo }); }); function showProjectTitile(val) { $("#title").html(""); if (proJson[val] !== undefined) { var txt = "<b>" + proJson[val].project_code + "</b><br>" + proJson[val].project_title; $("#title").html(txt); } } function isAnyItemChecked(){ // verify-error var length = $("table#table tbody input.flat:checked").length ; var flag = true; if(length==0) {$("#verify-error").show(); flag = false} else {$("#verify-error").hide()} return flag; } function verifyPendingBudgetForms() { if(!isAnyItemChecked()){ return; } var checked = $.map($('table#table tbody input.flat:checked'), function(n, i){ return n.value; }).join(','); var checkedArray = checked.split(","); $("#verify-spin").show(); $.ajax({ type: 'POST', url: BASE_URL + "pi_ajax.php", data: { f: "verifyPendingBudgetForms", budget_id: checked }, dataType: 'json', error: function() { $("#verify-spin").show(); alert("Something went wrong"); }, success: function(data) { $("#verify-spin").hide(); //console.log(data); if(data.status !==undefined && data.status){ $.each(checkedArray,function(a,b){ console.log(a,b); $("table#table tbody tr#"+b).remove(); }) }else{ alert("Something went wrong"); } }, }); } </script>