siddharth_application/application/views/cashbooklisting.php
2021-04-23 12:07:34 +05:30

279 lines
9.1 KiB
PHP

<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
<div class="content-wrapper">
<section class="content" id="loadingcontent">
<div>
<CENTER><h3>Siddharth Industries - Cashbook Listing</h3></CENTER>
</div>
<div class="box">
<div class="box-header">
<!-- <CENTER><h1 class="box-title">Siddharth Industries Cashbook Listing</h1></CENTER> -->
</div>
<form role="form" id="cashbookform" action="<?php echo base_url()?>" method="post" enctype="multipart/form-data">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-md-12">
<legend>Cash book / Account details</legend>
<div class="col-md-12">
<div class="col-md-3"><span>Account Type :</span>&nbsp;&nbsp;<span style="color:#ff6347;">*</span><br>
<input type="radio" name="accounttype" id="accounttype" value="RECEIPT" checked> RECEIPT<br>
<input type="radio" name="accounttype" id="accounttype" value="PAYMENT"> PAYMENT<br>
</div><p style="color:red"></p>
<div class="col-md-3 pad"><span>Account Code :</span>&nbsp;&nbsp;<span style="color:#ff6347;">*</span>
<input type="text" name="accountcode" id="accountcode" onchange="validateACCODE();" class="form-control" requried placeholder="Account Code" title="Account Code is requried">
</div><p style="color:red"></p>
<div class="col-md-3 pad"><span>Account Name :</span>&nbsp;&nbsp;<sapn style="color:#ff6347;">*</span>
<input type="text" name="accountname" id="accountname" class="form-control" placeholder="Account Name" title="Account Name is requried" class="tooltip" onfocus="theFocus(this);" onblur="theBlur(this);">
</div><p style="color:red"></p>
<div class="col-md-3 pad"><span>Description :</span>
<input type="email" name="description" id="description" class="form-control" placeholder="Account Description">
</div>
<input type="hidden" id="accountstate" name="accountstate" class="form-control" value="Yes" >
</div><br>
<div class="row" style="align:right;">
<div class="col-md-offset-10 col-md-1 ">
<input type="button" value="Add" id="Add" class="btn btn-primary"> </div>
<div class=" col-md-1">
<input type="button" value="Save" onclick="saveAll();" class="btn btn-primary"> </div>
</div>
</div>
</div>
<legend>Cash book / Account Tables</legend>
<div class="row">
<div class="col-xs-12">
<table id="cashbooktable" class="table table-hover table-bordered" style="background-color:#fff;font-size:12px;" >
<thead style="background-color:#ddf">
<tr>
<th>AccountCodeType</th>
<th>AccountCode</th>
<th>AccountName</th>
<th>Description</th>
<th>Status</th>
</tr>
</thead>
<tbody id="databaseAppend">
<?php
if(!empty($cashbook))
{
foreach($cashbook as $cb){
?>
<tr>
<td><?php echo $cb->type ?></td>
<td><?php echo $cb->code ?></td>
<td contenteditable='true'><?php echo $cb->name ?></a></td>
<td contenteditable='true'><?php echo $cb->description?></a>
<td contenteditable='true'><?php if($cb->status == 1 )
{
echo 'Yes';
//echo strtoupper('Yes');
}
else
{
echo 'No';
//echo strtoupper('No');
}
?></td></tr>
<?php
}
}
?> </tbody>
</table>
</div>
</div>
</div>
</div>
</form>
</div>
</section>
</div>
<script type="text/html" id="addList">
<tr id="<%=index%>">
<td align="left"><%=AccountCodeType%></td>
<td align="left"><%=AccountCode%></td>
<td align="left" contenteditable="true"><%=AccountName%></td>
<td align="left" contenteditable="true"><%=Description%></td>
<td align="left" contenteditable="true"><%=Status%></td>
</tr>
</script>
<script>
var index = '1';
var localcodes =[];
$('#Add').click(function(){
var res = validateACCODE();
// alert('res'+res);
if(res != 1)
{
//alert('inside if');
var temp = index;
var Acctype = $("#accounttype:checked").val() ;
var Acccode = $('#accountcode').val();
var Accname = $('#accountname').val();
var Accdesc = $('#description').val();
var Status = $('#accountstate').val();
var localflag = 0;
//if(Acctype != '' || Accname != '' || Acccode != '' )https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjnwuzq4MXXAhVIQI8KHcWmBUoQFggqMAA&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F9127847%2Fdocument-getelementbyid-focus-returning-undefined&usg=AOvVaw20BMY_C7k6ShhmOz0Vmzs8
if(Accname != '' || Acccode != '')
{
//var radioValue = $("input[name='accounttype']:checked").val();
if (Acccode == ''){
$('#accountcode').focus();
alert('Account code is requried');
//$("#accountcode").attr('title', 'account code is requried');
return false;
}
else if (Accname == ''){
$('#accountname').focus();
alert('Account Name is requried');
return false;
}//valid if closed
else{
$.each(localcodes,function(i,j){
if(j == Acccode)
{
alert('Account Code Already Taken');
document.getElementById("accountcode").focus();
localflag = 1;
return false;
}
});
if( localflag == 0){
var template = jQuery("#addList").html();
index = parseInt(index)+1;
//$('table tr.odd').remove();//class="dataTables_empty"
//$('.odd').remove();//
localcodes.push(Acccode);
$('#databaseAppend').append(_.template(template,{index:temp,AccountCodeType:Acctype,AccountCode:Acccode,AccountName:Accname,Description:Accdesc,Status:Status}));
clear();
}
}//nearest else closed
}// nearest if closed
//$('input[name="accounttype"]').attr('checked', false);
}
});//add click function closed
</script>
<script type="text/javascript">
$(function () {
$('#cashbooktable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": true
});
});
function saveAll()
{
$('#loadingcontent').loader('show');
var tablevalue = $('#cashbooktable').tableToJSON(); // Convert the table into a javascript object
var value = JSON.stringify(tablevalue);
$.ajax({
data:{id:value},
type:"POST",
url:"<?php echo base_url() ?>cashbook/cashbookdtl",
success:function(data){
$('#loadingcontent').loader('hide');
alert(data);
window.location.href="addNewIncomeExpenseLoad";
}//success function closed
});//ajax function closed
}
</script>
<script>
function validateACCODE()
{
var accode = [];
var flag=0;
accode = <?php echo json_encode($cashbook);?>;
var current = $('#accountcode').val();
$.each(accode,function(i,j){
//alert(i+'-'+j.code);
if(j.code == current)
{
alert('Account Code already Taken!');
document.getElementById("accountcode").focus();
// $("#Add").attr("disabled", "disabled");
flag++;
//return false;
}
else
{
//$("#Add").removeAttr("disabled");
}
});
//alert(flag);
return flag;
}
function clear()
{
$('#accountcode').val('');
$('#accountname').val('');
$('#description').val('');
}
</script>