BBnepal-Accounts/account/application/views/accounts/importgroups.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

111 lines
4.9 KiB
PHP

<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?> </h5>
</div>
<div class="card-body">
<form method=POST action="" enctype="multipart/form-data" name="tbl_vouchers">
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group"> <label for="import_type">Voucher List</label>
<select class="form-control" id="import_type" value="" name="import_type">
<option value="Groups">Groups</option>
<option value="Categories">Categories</option>
<option value="Accounts">Accounts</option>
<option value="Vouchers">Vouchers</option>
<option value="VoucherDetails">Voucher Details</option>
<option value="All">All</option>
</select>
</div>
</div>
<div class="col">
<div class="form-group"> <label for="voucher_list">Voucher List</label>
<input type="file" class="form-control" id="voucher_list" value="" name="voucher_list">
</div>
</div>
<!--COL END-->
</div>
</div>
<button class="btn btn-primary" type="submit" name="submit">Save</button>
</form>
<?php if(isset($importedData)) { ?>
<?php $importedGroups=array(); ?>
<table class="table table-striped table-responsive dataTable">
<thead>
<?php $h = $importedData[0];
unset($importedData[0]); ?>
<tr>
<?php $i=0; foreach ($h as $c) : ?>
<th><?php echo $c." ($i)"; $i++; ?>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($importedData as $r) : ?>
<?php $importedGroups=addGroup($r,$importedGroups); ?>
<tr>
<?php foreach ($r as $c) : ?>
<td><?php echo $c; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
$this->db->query("truncate table tbl_acgroups");
foreach($importedGroups as $importedGroup):
$this->db->insert("tbl_acgroups",$importedGroup);
endforeach;
?>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
function addGroup($importedLine, $importedGroups)
{
/*
[0] => acgroup_id
[1] => acgroup_code
[2] => acgroup_name
[3] => created_on
[4] => created_by
[5] => remarks
[6] => status
[7] => display_order
*/
$dbGroup=new stdClass;
$dbGroup->acgroup_id=$importedLine[1];
$dbGroup->acgroup_code=$importedLine[3];
$dbGroup->acgroup_name=$importedLine[4];
$dbGroup->created_on=dbDate($importedLine[5]);
$dbGroup->created_by=$importedLine[6];
$dbGroup->remarks=$importedLine[7];
$dbGroup->status=$importedLine[8];
if(!in_array($dbGroup,$importedGroups)) $importedGroups[]=$dbGroup;
return $importedGroups;
}
?>