bbone/application/modules/Asset/views/asset_list.php
2023-06-24 16:02:54 +05:30

240 lines
11 KiB
PHP

<form id="otp-form">
<input type="hidden" id="csrf" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
</form>
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<h2>Assets Details </h2>
<ul class="nav navbar-right panel_toolbox">
<?php if(user()->action_permit != 'view' ) { ?>
<a href="<?php echo base_url();?>Asset/addAsset" class="btn btn-sm btn-primary">Add Asset</a>
<?php } ?>
<button class="btn btn-sm btn-secondary" onclick="deleteRow();" hidden>Remove</button>
<button class="btn btn-sm btn-info" onclick="viewQr();" hidden>View QR</button>
<!-- <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li> -->
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="row">
<div class="col-sm-12">
<div class="card-box table-responsive">
<form class="" method="post" action="<?php echo base_url()?>Asset/filterAssets">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" >
<input type="hidden" name="category" value="<?php echo $tableData[0]->category; ?>" >
<fieldset>
<div class="col-md-5 col-sm-5 " for="first-name"> </div>
<div class="col-md-3 col-sm-3 " for="first-name"><h2> &nbsp; &nbsp;Filter with purchase date : </h2> </div>
<div class="col-md-3 col-sm-3 ">
<div class="control-group ">
<div class="controls">
<div class="input-prepend input-group">
<input type="text" style="width: 200px" name="reservation" id="reservation" class="form-control" value="" />
</div>
</div>
</div>
</div>
<div class="col-md-1 col-sm-1 ">
<button class="btn btn-sm btn-info" type="submit" style="height:37px;">Submit</button>
</div>
</fieldset>
</form>
<table id="datatable-buttons" class="table table-striped table-bordered bulk_action" width="100%">
<thead style="white-space: nowrap;">
<tr class="headings">
<th><input type="checkbox" id="check_all" ></th>
<th class="column-title">Asset Name </th>
<th class="column-title">Purchase Date </th>
<th class="column-title">Purchase Cost </th>
<th class="column-title">Current Value </th>
<!-- <th class="column-title">Manufacturer </th>
<th class="column-title">Tag </th>
<th class="column-title">Serial </th>
<th class="column-title">Model </th>
<th class="column-title">Category </th>
<th class="column-title">Status </th> -->
<!-- <th class="column-title">Notes </th>
<th class="column-title">Warranty </th>
<th class="column-title">Order No </th>
<th class="column-title">Purchase Date </th>
<th class="column-title">Supplier </th>
<th class="column-title">Cost </th>
<th class="column-title">Location </th> -->
<th class="column-title" style="min-width:120px;">Action </th>
</tr>
</thead>
<tbody>
<?php foreach ($tableData as $key => $value) { ?>
<tr class="even pointer">
<td><input type="checkbox" id="check-all" value="<?php echo $value->id; ?>" ></td>
<td class=" "> <?php echo $value->name; ?> </td>
<td class=" "> <?php echo my_date_show($value->purchase_date); ?> </td>
<td class=" " style=" text-align: right;"> <?php echo $value->cost; ?> </td>
<td class=" " style=" text-align: right;"> <?php echo $value->current_cost; ?></td>
<!-- <td class=" "> <?php echo $value->name; ?> </td> -->
<!-- <td class=" "><?php echo $value->manufacturer_name; ?> </td>
<td class=" "><?php echo $value->tag; ?></td>
<td class=" "><?php echo $value->serial; ?></td>
<td class=" "><?php echo $value->model; ?></td>
<td class=" "><?php echo $value->category_name; ?></td>
<td class=" "><?php echo $value->status_display_name; ?></td> -->
<!--<td class=" "><?php echo $value->notes; ?> </td>
<td class=" "><?php echo $value->warranty; ?> </td>
<td class=" "><?php echo $value->order_no; ?></td>
<td class=" "><?php echo $value->purchase_date; ?></td>
<td class=" "><?php echo $value->supplier_name; ?></td>
<td class=" "><?php echo $value->cost; ?></td>
<td class=" "><?php echo $value->location_name; ?></td> -->
<td style=" text-align: center; font-size: 16px;">
<?php if(user()->action_permit != 'view' ) { ?>
<a href="<?php echo base_url()?>Asset/editAsset/<?php echo md5($value->id);?>" ><i class="fa fa-pencil" title="Edit"></i></a>
&nbsp;
<a href="<?php echo base_url()?>Asset/addAsset/<?php echo md5($value->id);?>" ><i class="fa fa-copy" title="Copy"></i></a>
&nbsp;
<a><i class="fa fa-trash deleteAsset" data-toggle="modal" data-target=".bs-example-modal-sm" id="<?php echo md5($value->id);?>" ></i></a>
<!-- <a href="<?php echo base_url()?>Asset/deleteAsset/<?php echo md5($value->id);?>" ><i class="fa fa-trash" title="Delete"></i></a> -->
&nbsp;
<?php } ?>
<a href="<?php echo base_url()?>Asset/view_asset_details/<?php echo md5($value->id);?>" > <i class="fa fa-eye" title="View"></i></a>
&nbsp;
<!-- <a href="<?php echo base_url()?>Asset/view_qr_code/<?php echo md5($value->id);?>" > <i class="fa fa-qrcode"></i></a> -->
<a href="#" class="qr_view" id="<?php echo $value->id; ?>"> <i class="fa fa-qrcode" title="QR code"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<br/>
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div style="display:none" id="sub-value">
</div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
<script>
$("input[type='checkbox']").change(function(){
if($('input[type="checkbox"]:not(:checked)').length == $('input[type="checkbox"]').length){
console.log('all checked');
$('.btn-secondary').attr("hidden",true);
$('.btn-info').attr("hidden",true);
}
});
$('input:checkbox').click(function() {
$('.btn-secondary').removeAttr('hidden');
$('.btn-info').removeAttr('hidden');
});
$('.deleteAsset').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Asset/deleteAsset";
$.ajax({
url: "<?php echo base_url()?>Asset/getDeleteConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.delete_url').attr('action',url);
}
});
});
function deleteRow() {
var csrf_data = $("#otp-form").serialize();
delete_id = [];
document.querySelectorAll('#datatable-buttons #check-all:checked').forEach(e => {
delete_id.push(e.value)
e.parentNode.parentNode.remove();
console.log("tes----"+e.parentNode.parentNode);
});
console.log(delete_id);
$.ajax({
type: "post",
url: "<?php echo base_url()?>Asset/deleteMultipleAsset",
data: {data:delete_id,'<?php echo $this->security->get_csrf_token_name(); ?>': $('#csrf').val()},
json: true,
success: function(response) {
response = jQuery.parseJSON(response);
$('input[name=csrf_test_name]').val(response.csrf_hash);
console.log('success');
},
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
});
}
function viewQr() {
var csrf_data = $("#otp-form").serialize();
view_qr_id = [];
document.querySelectorAll('#datatable-buttons #check-all:checked').forEach(e => {
view_qr_id.push(e.value)
});
console.log(view_qr_id);
$.ajax({
type: "post",
url: "<?php echo base_url()?>Asset/view_qrcode",
data: {data:view_qr_id,'<?php echo $this->security->get_csrf_token_name(); ?>': $('#csrf').val()},
json: true,
success: function(response) {
response = jQuery.parseJSON(response);
$('input[name=csrf_test_name]').val(response.csrf_hash);
console.log('success');
$('.bs-example-modal-lg').html(response.htmlPage);
$('.bs-example-modal-lg').modal("show");
},
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
});
};
$(document).on('click','.qr_view',function(){
var csrf_data = $("#otp-form").serialize();
view_qr_id = [];
var id = $(this).attr("id");
view_qr_id.push(id)
$.ajax({
type: "post",
url: "<?php echo base_url()?>Asset/view_qrcode",
data: {data:view_qr_id,'<?php echo $this->security->get_csrf_token_name(); ?>': $('#csrf').val()},
json: true,
success: function(response) {
response = jQuery.parseJSON(response);
$('input[name=csrf_test_name]').val(response.csrf_hash);
console.log('success');
$('.bs-example-modal-lg').html(response.htmlPage);
$('.bs-example-modal-lg').modal("show");
},
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
});
});
$("#check_all").click(function(){
$('input:checkbox').not(this).prop('checked', this.checked);
});
</script>