113 lines
5.1 KiB
PHP
113 lines
5.1 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 $importedCategories=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 $importedCategories=addCategory($r,$importedCategories); ?>
|
|
|
|
<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_accategories");
|
|
foreach($importedCategories as $importedCategory):
|
|
$this->db->insert("tbl_accategories",$importedCategory);
|
|
endforeach;
|
|
|
|
|
|
?>
|
|
|
|
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
|
|
function addCategory($importedLine,$importedCategories)
|
|
{
|
|
/*
|
|
[0] => accategory_id
|
|
[1] => acgroup_id
|
|
[2] => accategory_code
|
|
[3] => accategory_name
|
|
[4] => created_on
|
|
[5] => created_by
|
|
[6] => remarks
|
|
[7] => status
|
|
*/
|
|
$dbCategory=new stdClass;
|
|
$dbCategory->accategory_id=$importedLine[1];
|
|
$dbCategory->acgroup_id=$importedLine[2];
|
|
$dbCategory->accategory_code=$importedLine[3];
|
|
$dbCategory->accategory_name=$importedLine[4];
|
|
$dbCategory->created_on=dbDate($importedLine[6]);
|
|
$dbCategory->created_by=$importedLine[7];
|
|
$dbCategory->remarks=$importedLine[8];
|
|
$dbCategory->status=$importedLine[9];
|
|
if(!in_array($dbCategory,$importedCategories)) $importedCategories[]=$dbCategory;
|
|
return $importedCategories;
|
|
|
|
}
|
|
|
|
?>
|