131 lines
5.8 KiB
PHP
131 lines
5.8 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">Choose Ledger</label>
|
||
|
<?php
|
||
|
$this->myaccounts->showAccountsCombo($fieldName="account_id", $displayName="account_name", $fieldID="account_id", $condition = "", $default = "", $CSSclass = "")
|
||
|
?>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col">
|
||
|
<div class="form-group"> <label for="dr_balance">Opening Balance (Dr)</label>
|
||
|
<input type="text" class="form-control" id="dr_balance" value="" name="dr_balance">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col">
|
||
|
<div class="form-group"> <label for="cr_balance">Opening Balance (Cr)</label>
|
||
|
<input type="text" class="form-control" id="cr_balance" value="" name="cr_balance">
|
||
|
</div>
|
||
|
</div>
|
||
|
<!--COL END-->
|
||
|
</div>
|
||
|
</div>
|
||
|
<button class="btn btn-primary" type="submit" name="submit">Save</button>
|
||
|
</form>
|
||
|
<?php if(isset($importedData)) { ?>
|
||
|
<?php $importedAccounts=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 $importedAccounts=addAccounts($r,$importedAccounts); ?>
|
||
|
<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_accounts");
|
||
|
foreach($importedAccounts as $importedAccount):
|
||
|
$this->db->insert("tbl_accounts",$importedAccount);
|
||
|
endforeach;
|
||
|
|
||
|
|
||
|
?>
|
||
|
|
||
|
|
||
|
<?php } ?>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<?php
|
||
|
|
||
|
function addAccounts($importedLine, $importedAccounts)
|
||
|
{
|
||
|
/*
|
||
|
[0] => account_id
|
||
|
[1] => accategory_id
|
||
|
[2] => account_code
|
||
|
[3] => account_name
|
||
|
[4] => account_type
|
||
|
[5] => account_plcategory
|
||
|
[6] => account_currency
|
||
|
[7] => account_partyname
|
||
|
[8] => account_partyaddress
|
||
|
[9] => account_partypan
|
||
|
[10] => account_partycontact
|
||
|
[11] => account_partyemail
|
||
|
[12] => account_partycontactperson
|
||
|
[13] => account_partycontactpersoncontact
|
||
|
[14] => created_on
|
||
|
[15] => created_by
|
||
|
[16] => remarks
|
||
|
[17] => status
|
||
|
*/
|
||
|
$dbAccount=new stdClass;
|
||
|
$dbAccount->account_id=$importedLine[1];
|
||
|
$dbAccount->accategory_id=$importedLine[2];
|
||
|
$dbAccount->account_code=$importedLine[3];
|
||
|
$dbAccount->account_name=$importedLine[4];
|
||
|
$dbAccount->account_type=$importedLine[5];
|
||
|
$dbAccount->account_plcategory=$importedLine[6];
|
||
|
$dbAccount->account_currency=$importedLine[7];
|
||
|
$dbAccount->account_partyname=$importedLine[14];
|
||
|
$dbAccount->account_partyaddress=$importedLine[15];
|
||
|
$dbAccount->account_partycontact=$importedLine[16];
|
||
|
$dbAccount->account_partyemail='N/A';
|
||
|
$dbAccount->account_partycontactperson=$importedLine[17];
|
||
|
$dbAccount->account_partycontactpersoncontact='';
|
||
|
$dbAccount->created_on=dbDate($importedLine[9]);
|
||
|
$dbAccount->created_by=$importedLine[8];
|
||
|
$dbAccount->remarks=$importedLine[12];
|
||
|
$dbAccount->status=$importedLine[13];
|
||
|
|
||
|
if(!in_array($dbAccount,$importedAccounts)) $importedAccounts[]=$dbAccount;
|
||
|
return $importedAccounts;
|
||
|
|
||
|
}
|
||
|
?>
|