我想将数据导出到excel表格中的多个表格中,这些表格是根据我对这三个表格的要求编写的,并保存在模型中的单个函数中。并且我在控制器中调用此函数,我只对一个表执行了此方法,但对多个表却没有完成
This is MODAL
function update_wallet_pbo(){
$query1 = $this->db->query(" SELECT * FROM privilege_customer WHERE accountStatus = 'A' ");
$sno = 1;
if($query1->num_rows() > 0){
foreach($query1->result() as $row1){
$acc = $row1->accountNum;
$PBONum = $row1->PBONum;
echo 'S no. - '.$sno.' PBO No. = '.$PBONum.' Acc No. = '.$acc.'<br/>';
$total_balance = 0 ;
$query3 = $this->db->query(" SELECT * FROM `pbo_purchase_wallet` WHERE PBONum = '$PBONum' ORDER by date ASC ");
if($query3->num_rows() > 0){
foreach($query3->result() as $row3){
if($row3->type == 'Credited'){
$total_balance = round( floatval($total_balance) , 2 ) + round( floatval($row3->transactionAmount) , 2 );
echo 'ID = '.$row3->id.' PS no. = '.$row3->PSNum.' Credit = '.$row3->transactionAmount.' Debit = 0 Balance Amount = '.$row3->totalAmount.' Actual Balance Amount = '.$total_balance.'<br/>';
}
else if($row3->type == 'Debited'){
$total_balance = round( floatval($total_balance) , 2 ) - round( floatval($row3->transactionAmount) , 2 );
echo 'ID = '.$row3->id.' PS no. = '.$row3->PSNum.' Credit = 0 Debit = '.$row3->transactionAmount.' Balance Amount = '.$row3->totalAmount.' Actual Balance Amount = '.$total_balance.'<br/>';
}
/*$data = array( 'totalAmount' => $total_balance);
$this->db->update('stockist_sales_wallet_additions', $data);*/
}
}
$query4 = $this->db->query(" SELECT * FROM `pbo_wallet` WHERE PBONum = '$PBONum' ");
if($query4->num_rows() > 0){
foreach($query4->result() as $row4){
$purchase_wallet = round( floatval($row4->purchaseWallet) , 2 );
if($purchase_wallet <= $total_balance+1 && $purchase_wallet >= $total_balance-1){
echo '<b style="color:blue;">---------------------------Correct-----------------------</b><br/>';
echo 'Purchase Wallet = '.$purchase_wallet.' Total Balance = '.$total_balance.'<br/>';
echo '<b style="color:blue;">---------------------------Correct-----------------------</b><br/>';
}
else{
echo '<b style="color:red;">---------------------------Wrong-----------------------</b><br/>';
echo 'Purchase Wallet = '.$purchase_wallet.' Total Balance = '.$total_balance.'<br/>';
echo '<b style="color:red;">---------------------------Wrong-----------------------</b>';
}
}
}
$sno++;
echo '<br/><br/><br/>';
if($sno == 10){
return 1;
}
}
}
}
这是我的控制人
function update_wallet_pbo(){
$this->load->model("AdminModel");
$this->load->library("excel");
$object = new PHPExcel();
$object->setActiveSheetIndex(0);
$table_columns = array("Name", "Address", );
$column = 0;
foreach($table_columns as $field)
{
$object->getActiveSheet()->setCellValueByColumnAndRow($column, 1, $field);
$column++;
}
$employee_data = $this->AdminModel->update_wallet_pbo();
$excel_row = 2;
foreach($employee_data as $row)
{
$object->getActiveSheet()->setCellValueByColumnAndRow(0, $excel_row, 'dsf');
$object->getActiveSheet()->setCellValueByColumnAndRow(1, $excel_row, 'sadf');
$excel_row++;
}
$object_writer = PHPExcel_IOFactory::createWriter($object, 'Excel5');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Employee Data.xls"');
$object_writer->save('php://output');