0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: pi_edit_budget_form.php
<?php $MAIN_HEADING = "Edit Voucher"; $SUB_HEADING =""; require_once "pi_edit_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> <form action="pi_edit_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">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> <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) && !empty($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> <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">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> <input type="hidden" name="id" value="<?php if(isset($id) ) echo $id; ?>"> <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">Submit</button> <button class="btn btn-default" type="reset" name="reset" id="save">Reset</button> </div> </div> </form> <?php include "include/footer.php"; ?> <script> var init = true; $(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) { $(".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); }); var pc_id= "<?php echo $budgetFrom->project_id?>"; var proj_id = parseInt(pc_id); // $(".select2_single").select2('id', [proj_id,proJson[proj_id]['project_code']], true); $(".select2_single").val(proj_id).trigger("change"); }); 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 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) ); }); if(init){ var __bh_id = parseInt("<?php echo $budgetFrom->debit_head; ?>"); $("#debit_head").val(__bh_id).change(); } init = false; }, }); } $(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 }); }); </script>