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

141 lines
6.3 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 $importedVoucherDetails=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
$importedVoucherDetails=addVoucherDetails($r,$importedVoucherDetails);
//pre($r);die;
?>
<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_voucherdetails");
foreach($importedVoucherDetails as $importedVoucherDetail):
$this->db->insert("tbl_voucherdetails",$importedVoucherDetail);
endforeach;
echo "Vouche Details Imported Successfully!!\n";
?>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
function addVoucherDetails($importedLine, $importedVoucherDetails)
{
//pre($importedLine);//die;
/*
[0] => voucherdetail_id
[1] => voucher_id
[2] => entry_no
[3] => transaction_date
[4] =>
[5] => narration
[6] => dr
[7] => cr
[8] => cheque
[9] => cheque_details
[10] => currency
[11] => exrate
[12] => fcdr
[13] => fccr
[14] => branch_id
[15] => fiscalyear_id
[16] => created_on
[17] => created_by
[18] => remarks
[19] => status
*/
if(sizeof($importedLine)>0):
$dbVoucherDetail=new stdClass;
$dbVoucherDetail->voucherdetail_id=$importedLine[1];
$dbVoucherDetail->voucher_id=$importedLine[2];
$dbVoucherDetail->entry_no=$importedLine[3];
$dbVoucherDetail->transaction_date=dbDate($importedLine[4]);
$dbVoucherDetail->account_id=$importedLine[5];
$dbVoucherDetail->narration=$importedLine[6];
$dbVoucherDetail->dr=$importedLine[7];
$dbVoucherDetail->cr=$importedLine[8];//$_SESSION['FiscalYearID'];
$dbVoucherDetail->cheque=$importedLine[9];//$_SESSION['BranchID'];
$dbVoucherDetail->cheque_details=$importedLine[10];
$dbVoucherDetail->currency=$importedLine[11];
$dbVoucherDetail->exrate=$importedLine[12];
$dbVoucherDetail->fcdr=$importedLine[13];
$dbVoucherDetail->fccr=$importedLine[14];
$dbVoucherDetail->branch_id=$_SESSION['BranchID'];//$importedLine[47];
$dbVoucherDetail->fiscalyear_id=$_SESSION['FiscalYearID'];//$importedLine[47];
$dbVoucherDetail->created_on=dbDate($importedLine[15]);
$dbVoucherDetail->created_by=$importedLine[16];
$dbVoucherDetail->remarks=$importedLine[19];
$dbVoucherDetail->status=$importedLine[20];
if(!in_array($dbVoucherDetail,$importedVoucherDetails)) $importedVoucherDetails[]=$dbVoucherDetail;
return $importedVoucherDetails;
endif;
return "";
}
?>