<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 $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; } ?>