File: /home/cafsindia/cloud_cafsinfotech_in/application/views/pf_challan_setting/form.php
<?php
$prime_pf_challan_setting_id = $previous_result[0]->prime_pf_challan_setting_id;
if(!$prime_pf_challan_setting_id){
$prime_pf_challan_setting_id = "-1";
}
echo form_open('pf_challan_setting/save/' .$prime_pf_challan_setting_id ,array('id'=>'pf_challan_setting_form','class'=>'form-inline'));
?>
<fieldset>
<div class="form-group">
<?php
echo form_label("Order No", 'order_no', array('class' => 'required'));
echo form_input( array('name'=>'order_no', 'id'=>'order_no','class' => 'form-control input-sm', 'value'=>$previous_result[0]->order_no));
?>
</div>
<div class="form-group">
<?php
echo form_label("Column Name", 'column_name', array('class' => 'required'));
echo form_input( array('name'=>'column_name','class' => 'form-control input-sm', 'id'=>'column_name', 'value'=>$previous_result[0]->column_name));
?>
</div>
<div class="form-group">
<?php
echo form_label("Transaction Type", 'transaction_type', array('class' => 'required'));
$transaction_type = array('' => '---Select Transaction Type ---', 'cw_employees' =>'Masters', 'cw_transactions' =>'Transaction');
echo form_dropdown(array(
'name' => 'transaction_type',
'id' => 'transaction_type',
'class' => 'form-control input-sm'), $transaction_type, $previous_result[0]->transaction_type);
?>
</div>
<div class="form-group">
<?php
echo form_label("Matching Field", 'previous_column', array('class' => 'required'));
echo form_dropdown(array(
'name' => 'matching_field',
'id' => 'matching_field',
'class' => 'form-control input-sm select2'), $columns, $previous_result[0]->matching_field);
?>
</div>
</fieldset>
<?php echo form_close(); ?>
<script type="text/javascript">
$(document).ready(function(){
var prime_id = "#<?php echo $prime_id;?>";
var form_id = "#<?php echo $form_id;?>";
var date_exist = "<?php echo $date_exist;?>";
var transaction_type = "<?php echo $previous_result[0]->transaction_type;?>";
get_matching_list(transaction_type);
//get_columns();
if(date_exist === "1"){
$(function () {
$(".datepicker").datetimepicker({
format: 'MM-YYYY',
//debug: true
});
});
}
var drop_exist = "<?php echo $drop_exist;?>";
$(function(){
$('.select2').select2({
placeholder: '---- Select ----',
dropdownParent: $('.modal-dialog')
});
$('.select2-tags').select2({
tags: true,
tokenSeparators: [',']
});
});
//Back space Not Allowed
$('#order_no').on('keypress', function(e) {
if (e.which == 32)
return false;
});
$('input').keypress(function(e){
e = e || event;
var s = String.fromCharCode(e.charCode);
if(s.match(/[A-Z]/)){
toastr.clear();
toastr.error('Capital letters disabled');
return false;
}
});
$('textarea').on('keyup keypress', function(e) {
if(e.keyCode === 13) {
e.stopPropagation();
}else
if(e.shiftKey){
e.stopPropagation();
}
});
$(".number").bind('keyup', function(e) {
this.value = this.value.replace(/[^0-9]/g,'');
});
$(".decimal_no").bind('keyup', function(e) {
this.value = this.value.replace(/[^0-9_.]/g,'');
});
$('.alpha').bind('keypress', function (event) {
var regex = new RegExp("^[a-z0-9\-_.@\/\\s]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
});
$.validator.setDefaults({ignore:[]});
$.validator.addMethod("alphanumeric", function(value, element) {
return this.optional(element) || /^[a-z0-9\-\s]+$/i.test(value);
}, "Allow only letters, numbers, or dashes.");
$('#pf_challan_setting_form').submit(function(event){ event.preventDefault(); }).validate({
rules:{
order_no : "required",
column_name : "required",
transaction_type : "required",
matching_field : "required"
},
submitHandler: function (form){
$("#submit").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
$('#submit').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function (response){
$('#submit').attr('disabled',false);
$("#submit").html("Submit");
if(response.success){
table_support.handle_submit('<?php echo site_url($controller_name); ?>', response);
table_support.refresh();
$('.row_btn').show();
dialog_support.hide();
}else{
toastr.error(response.message);
}
},
dataType: 'json'
});
}
});
/* LOAD SCRIPT AND CONDITION LOAD */
<?php
echo "$document_load_script";
foreach($condition_list as $list){
echo $list;
}
?>
/* LOAD SCRIPT AND CONDITION LOAD */
//GET Matching Field
$("#transaction_type").change(function(){
var transaction_type = $("#transaction_type").val();
get_matching_list(transaction_type);
});
});
function get_matching_list(transaction_type){
var matching_field = "<?php echo $previous_result[0]->matching_field;?>";
if(transaction_type){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name."/get_matching_list"); ?>',
data: {transaction_type:transaction_type},
success: function(data){
$('#matching_field').html(data);
if(matching_field){
$('#matching_field').val(matching_field);
}
},
});
}
}
</script>
<style>
.textcolor{
color: blue;
}
</style>