array( 'outline' => array( 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, 'color' => array('argb' => '#000000'), ), ), ); $styleArray1 = array( 'borders' => array( 'outline' => array( 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK, 'color' => array('argb' => '#000000'), ), ), ); $styleArray2 = [ 'font' => [ 'bold' => true, ], 'alignment' => [ 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT, ], 'borders' => [ 'top' => [ 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, ], ], 'fill' => [ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startColor' => [ 'argb' => 'FFA0A0A0', ], 'endColor' => [ 'argb' => 'FFFFFFFF', ], ], ]; if(isset($_POST["export"])) { $file = new Spreadsheet(); $txtfile="SBI TO SBI BEN (BELOW 20K).txt"; $txt1 = fopen($txtfile, "w") or die("Unable to open file!"); $txtfile="SBI TO SBI PAY (BELOW 20K).txt"; $txt2 = fopen($txtfile, "w") or die("Unable to open file!"); $txtfile="SBI TO SBI BEN (ABOVE 20K).txt"; $txt3 = fopen($txtfile, "w") or die("Unable to open file!"); $txtfile="SBI TO SBI PAY (ABOVE 20K).txt"; $txt4 = fopen($txtfile, "w") or die("Unable to open file!"); $txtfile="SBI TO OTHERS BEN (BELOW 20K).txt"; $txt5 = fopen($txtfile, "w") or die("Unable to open file!"); $txtfile="SBI TO OTHERS PAY (BELOW 20K).txt"; $txt6 = fopen($txtfile, "w") or die("Unable to open file!"); $txtfile="SBI TO OTHERS BEN (ABOVE 20K).txt"; $txt7 = fopen($txtfile, "w") or die("Unable to open file!"); $txtfile="SBI TO OTHERS PAY (ABOVE 20K).txt"; $txt8 = fopen($txtfile, "w") or die("Unable to open file!"); $mxdt=$_POST["date1"];; $pmxdt=$_POST["date1"];; $pmxdt=$_POST["date1"];; $freff=$_POST["beff"]; $tamt1=0; $tamt2=0; $tamt3=0; $tamt4=0; $query="select ifnull(sum(AMOUNT),0) AMOUNT FROM ( select eb_no ,concat(worker_name,' ',last_name) name,per_bank_name , per_bank_ac_no ,per_bank_ifsc , CAST(AMOUNT AS UNSIGNED) AMOUNT from tbl_pay_period tpp,tbl_pay_employee_payroll tpep ,worker_master wm where tpp.status=3 and is_active=1 and tpp.id=tpep.PAYPERIOD_ID and COMPONENT_ID=21 and tpep.EMPLOYEEID=wm.eb_id and AMOUNT<>0.00 and tpp.id=1998 order by eb_no ) g where AMOUNT>20000 and substr(per_bank_ifsc,1,4)='SBIN'"; $result = $connect->query($query); while($row = $result->fetch_assoc()) { $tamt2=$row["AMOUNT"]; } $query="select ifnull(sum(AMOUNT),0) AMOUNT FROM ( select eb_no ,concat(worker_name,' ',last_name) name,per_bank_name , per_bank_ac_no ,per_bank_ifsc , CAST(AMOUNT AS UNSIGNED) AMOUNT from tbl_pay_period tpp,tbl_pay_employee_payroll tpep ,worker_master wm where tpp.status=3 and is_active=1 and tpp.id=tpep.PAYPERIOD_ID and COMPONENT_ID=21 and tpep.EMPLOYEEID=wm.eb_id and AMOUNT<>0.00 and tpp.id=1998 order by eb_no ) g where AMOUNT<=20000 and substr(per_bank_ifsc,1,4)='SBIN'"; $result = $connect->query($query); while($row = $result->fetch_assoc()) { $tamt1=$row["AMOUNT"]; } $query="select ifnull(sum(AMOUNT),0) AMOUNT FROM ( select eb_no ,concat(worker_name,' ',last_name) name,per_bank_name , per_bank_ac_no ,per_bank_ifsc , CAST(AMOUNT AS UNSIGNED) AMOUNT from tbl_pay_period tpp,tbl_pay_employee_payroll tpep ,worker_master wm where tpp.status=3 and is_active=1 and tpp.id=tpep.PAYPERIOD_ID and COMPONENT_ID=21 and tpep.EMPLOYEEID=wm.eb_id and AMOUNT<>0.00 and tpp.id=1998 order by eb_no ) g where AMOUNT>20000 and substr(per_bank_ifsc,1,4)<>'SBIN'"; $result = $connect->query($query); while($row = $result->fetch_assoc()) { $tamt4=$row["AMOUNT"]; } $query="select ifnull(sum(AMOUNT),0) AMOUNT FROM ( select eb_no ,concat(worker_name,' ',last_name) name,per_bank_name , per_bank_ac_no ,per_bank_ifsc , CAST(AMOUNT AS UNSIGNED) AMOUNT from tbl_pay_period tpp,tbl_pay_employee_payroll tpep ,worker_master wm where tpp.status=3 and is_active=1 and tpp.id=tpep.PAYPERIOD_ID and COMPONENT_ID=21 and tpep.EMPLOYEEID=wm.eb_id and AMOUNT<>0.00 and tpp.id=1998 order by eb_no ) g where AMOUNT<=20000 and substr(per_bank_ifsc,1,4)<>'SBIN'"; $result = $connect->query($query); while($row = $result->fetch_assoc()) { $tamt3=$row["AMOUNT"]; } //2023-01-31 $query="select to_date, eb_no ,concat(worker_name,' ',last_name) name,per_bank_name , per_bank_ac_no ,per_bank_ifsc , CAST(AMOUNT AS UNSIGNED) AMOUNT from tbl_pay_period tpp,tbl_pay_employee_payroll tpep ,worker_master wm where tpp.status=3 and is_active=1 and tpp.id=tpep.PAYPERIOD_ID and COMPONENT_ID=21 and tpep.EMPLOYEEID=wm.eb_id and AMOUNT<>0.00 and tpp.id=".$freff." order by eb_no"; $cmpn="The Empire Jute Co Ltd"; $result = $connect->query($query); while($row = $result->fetch_assoc()) { $period=$row["to_date"]; $period=substr($row["to_date"],8,2).'/'.substr($row["to_date"],5,2).'/'.substr($row["to_date"],0,4); } $result = $connect->query($query); $active_sheet = $file->getActiveSheet(); //Employee Code Employee Name Bank Name Account No IFSC Code Net Pay $file->setActiveSheetIndex(0) ->setCellValue('A2', 'Bank Statement For Dated '.$pmxdt); $file->setActiveSheetIndex(0) ->setCellValue('A1', $cmpn); $file->setActiveSheetIndex(0) ->setCellValue('j1', $query); $file->getActiveSheet()->setTitle('SBI-20000'); $file->createSheet(); // Add some data $file->setActiveSheetIndex(1) ->setCellValue('A2', 'Bank Statement For Dated '.$pmxdt); $file->setActiveSheetIndex(1) ->setCellValue('A1', $cmpn); // Rename worksheet $file->getActiveSheet()->setTitle('SBI>20000'); $file->createSheet(); // Add some data $file->setActiveSheetIndex(2) ->setCellValue('A2', 'Bank Statement For Dated '.$pmxdt); $file->setActiveSheetIndex(2) ->setCellValue('A1', $cmpn); // Rename worksheet $file->getActiveSheet()->setTitle('NON SBI-20000'); $file->createSheet(); $file->setActiveSheetIndex(3) ->setCellValue('A2', 'Bank Statement For Dated '.$pmxdt); $file->setActiveSheetIndex(3) ->setCellValue('A1', $cmpn); // Rename worksheet $file->getActiveSheet()->setTitle('NON SBI>20000'); $file->createSheet(); $file->setActiveSheetIndex(4) ->setCellValue('A2', 'Bank Statement For Dated '.$pmxdt); $file->setActiveSheetIndex(4) ->setCellValue('A1', $cmpn); // Rename worksheet $file->getActiveSheet()->setTitle('All Employee'); $active_sheet->getStyle('A1')->getFont()->setSize(18); $active_sheet->setCellValue('A1', $cmpn); $n=0; $count=3; while($n<=4){ $file->setActiveSheetIndex($n) ->setCellValue('A3', 'Employee Code'); $file->setActiveSheetIndex($n) ->setCellValue('B3', 'Employee Name'); $file->setActiveSheetIndex($n) ->setCellValue('C3', 'Bank Name'); $file->setActiveSheetIndex($n) ->setCellValue('D3', 'Account No'); $file->setActiveSheetIndex($n) ->setCellValue('E3', 'IFSC Code'); $file->setActiveSheetIndex($n) ->setCellValue('F3', 'Net Pay'); $cl='A'.$count.":f".$count; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray2); $file->setActiveSheetIndex($n)->getColumnDimension('B')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('C')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('D')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('E')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('F')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('G')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('H')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('I')->setAutoSize(TRUE); $file->setActiveSheetIndex($n)->getColumnDimension('A')->setWidth(20); $cl='A'.$count.":f".$count; // $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray); $cll='d'.$count; $n++; } $ben="37090427545#01899#".$mxdt."#".$tamt1."##Staff Salary ".$period." (1)"."#Staff Salary ".$period." (1)"."\r\n"; fwrite($txt2, $ben); $ben="37090427545#01899#".$mxdt."#".$tamt2."##Staff Salary ".$period." (2)"."#Staff Salary ".$period." (2)"."\r\n"; fwrite($txt4, $ben); $ben="37090427545#01899#".$mxdt."#".$tamt3."##Staff Salary ".$period." (3)"."#Staff Salary ".$period." (3)"."\r\n"; fwrite($txt6, $ben); $ben="37090427545#01899#".$mxdt."#".$tamt4."##Staff Salary ".$period." (4)"."#Staff Salary ".$period." (4)"."\r\n"; fwrite($txt8, $ben); $cn0=3; $cn1=3; $cn2=3; $cn3=3; $cn4=3; $count=4; while($row = $result->fetch_assoc()) { $mm=0; $dbr=$row["per_bank_ifsc"]; $dp=substr($dbr,0,4); switch($dp) { case 'SBIN': $mm=1; break; } $np=$row["AMOUNT"]; $amt=strval($np); $t1=265999; //; $n=1; if ( ($mm==1) and ($np<=20000)) { $n=0; $cn0++; $cnx=$cn0; $ifc=substr($row["per_bank_ifsc"],6,5); $eb=$row["name"]."#".$row["per_bank_ac_no"]."#".$ifc."\r\n"; $pa=$row["per_bank_ac_no"]."#".$ifc."#".$mxdt."##".$np."#"."STAFF SALARY ".$period."(1)"."#"."STAFF SALARY ".$period."(1)"."\r\n"; fwrite($txt1, $eb); fwrite($txt2, $pa); } if ( ($mm==1) and ($np>20000)) { $n=1; $cn1++; $cnx=$cn1; $ifc=substr($row["per_bank_ifsc"],6,5); $eb=$row["name"]."#".$row["per_bank_ac_no"]."#".$ifc."\r\n"; $pa=$row["per_bank_ac_no"]."#".$ifc."#".$mxdt."##".$np."#"."STAFF SALARY ".$period."(1)"."#"."STAFF SALARY ".$period."(2)"."\r\n"; fwrite($txt3, $eb); fwrite($txt4, $pa); } if ( ($mm==0) and ($np<=20000)) { $n=2; $cn2++; $cnx=$cn2; $ifc=substr($row["per_bank_ifsc"],6,5); $eb=$row["name"]."#".$row["per_bank_ac_no"]."#".$ifc."\r\n"; $pa=$row["per_bank_ac_no"]."#".$ifc."#".$mxdt."##".$np."#"."STAFF SALARY ".$period."(1)"."#"."STAFF SALARY ".$period."(3)"."\r\n"; fwrite($txt5, $eb); fwrite($txt6, $pa); } if ( ($mm==0) and ($np>20000)) { $n=3; $cn3++; $cnx=$cn3; $ifc=substr($row["per_bank_ifsc"],6,5); $eb=$row["name"]."#".$row["per_bank_ac_no"]."#".$ifc."\r\n"; $pa=$row["per_bank_ac_no"]."#".$ifc."#".$mxdt."##".$np."#"."STAFF SALARY ".$period."(4)"."#"."STAFF SALARY ".$period."(4)"."\r\n"; fwrite($txt7, $eb); fwrite($txt8, $pa); } $cl='A'.$count; $file->setActiveSheetIndex($n) ->setCellValue('a' . $cnx, $row["eb_no"]); $file->setActiveSheetIndex($n) ->setCellValue('b' . $cnx, $row["name"]); $file->setActiveSheetIndex($n) ->setCellValue('c' . $cnx, $row["per_bank_name"]); $file->setActiveSheetIndex($n) ->setCellValue('d' . $cnx, $row["per_bank_ac_no"]); $file->setActiveSheetIndex($n) ->setCellValue('e' . $cnx, $row["per_bank_ifsc"]); $file->setActiveSheetIndex($n) ->setCellValue('f' . $cnx, $row["AMOUNT"]); $cll='d'.$cnx; $file->setActiveSheetIndex($n)->getCell($cll) ->setValueExplicit( $row["per_bank_ac_no"], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING ); $cl='A'.$cnx.":f".$cnx; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray); $eb=$row["eb_no"]."#".$row["name"]."\r\n"; $pa=$row["per_bank_ac_no"]."#".$row["AMOUNT"]."\r\n"; $n=4; $cl='A'.$count; $file->setActiveSheetIndex($n) ->setCellValue('a' . $count, $row["eb_no"]); $file->setActiveSheetIndex($n) ->setCellValue('b' . $count, $row["name"]); $file->setActiveSheetIndex($n) ->setCellValue('c' . $count, $row["per_bank_name"]); $file->setActiveSheetIndex($n) ->setCellValue('d' . $count, $row["per_bank_ac_no"]); $file->setActiveSheetIndex($n) ->setCellValue('e' . $count, $row["per_bank_ifsc"]); $file->setActiveSheetIndex($n) ->setCellValue('f' . $count, $row["AMOUNT"]); $cll='d'.$count; $file->setActiveSheetIndex($n)->getCell($cll) ->setValueExplicit( $row["per_bank_ac_no"], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING ); $cl='A'.$count.":f".$count; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray); $count++; } $cn0++; $first_i = 4; $last_i = $cn0 - 1; $sumrange = 'f' . $first_i . ':f' . $last_i; $n=0; $file->setActiveSheetIndex(0) ->setCellValue('F' . $cn0, '=SUM(' . $sumrange . ')'); $cl='A'.$cn0.":f".$cn0; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray2); $cn1++; $first_i = 4; $last_i = $cn1 - 1; $sumrange = 'f' . $first_i . ':f' . $last_i; $n=1; $file->setActiveSheetIndex(1) ->setCellValue('F' . $cn1, '=SUM(' . $sumrange . ')'); $cl='A'.$cn1.":f".$cn1; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray2); $cn2++; $first_i = 4; $last_i = $cn2 - 1; $sumrange = 'f' . $first_i . ':f' . $last_i; $n=2; $file->setActiveSheetIndex(2) ->setCellValue('F' . $cn2, '=SUM(' . $sumrange . ')'); $cl='A'.$cn2.":f".$cn2; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray2); $cn3++; $first_i = 4; $last_i = $cn3 - 1; $sumrange = 'f' . $first_i . ':f' . $last_i; $n=3; $file->setActiveSheetIndex(3) ->setCellValue('F' . $cn3, '=SUM(' . $sumrange . ')'); $cl='A'.$cn3.":f".$cn3; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray2); $cn=$count; $first_i = 4; $last_i = $cn - 1; $sumrange = 'f' . $first_i . ':f' . $last_i; $n=4; $file->setActiveSheetIndex(4) ->setCellValue('F' . $cn, '=SUM(' . $sumrange . ')'); $cl='A'.$cn.":f".$cn; $file->setActiveSheetIndex($n)->getStyle($cl)->applyFromArray($styleArray2); $active_sheet->setCellValue('A2', 'Bank Statement For Dated '.$pmxdt); $file->getActiveSheet()->getColumnDimension('D')->setWidth(30); $file->getActiveSheet()->getStyle('d1:d100')->getAlignment()->setWrapText(true); $file->getActiveSheet()->getColumnDimension('B')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('C')->setAutoSize(TRUE); // $file->getActiveSheet()->getColumnDimension('D')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('E')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('F')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('G')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('H')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('I')->setAutoSize(TRUE); // $file->getActiveSheet()->getColumnDimension('j')->setAutoSize(TRUE); $filetype="Xlsx"; $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($file, $filetype); $file_name = 'Bank Statement_'.$mxdt.'.' . strtolower($filetype); $writer->save($file_name); fclose($txt1); $file_url=$txtfile; header('Content-Type: application/x-www-form-urlencoded'); header('Content-Transfer-Encoding: Binary'); header("Content-disposition: attachment; filename=\"".$file_name."\""); readfile($file_name); unlink($file_name); exit; /* fclose($txt); $file_url=$txtfile; header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: utf-8"); header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\""); readfile($file_url); */ //excel close } if(isset($_POST["upload"])) { $disp=1; /* $txtfile="SBI TO SBI BEN (BELOW 20K).txt"; $file_url=$txtfile; header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: utf-8"); header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\""); readfile($file_url); */ $txt1="SBI TO SBI BEN (BELOW 20K).txt"; $txt2="SBI TO SBI PAY (BELOW 20K).txt"; $txt3="SBI TO SBI BEN (ABOVE 20K).txt"; $txt4="SBI TO SBI PAY (ABOVE 20K).txt"; $txt5="SBI TO OTHERS BEN (BELOW 20K).txt"; $txt6="SBI TO OTHERS PAY (BELOW 20K).txt"; $txt7="SBI TO OTHERS BEN (ABOVE 20K).txt"; $txt8="SBI TO OTHERS PAY (ABOVE 20K).txt"; $files = array($txt1,$txt2,txt3,$txt4,$txt5,$txt6,$txt7,$txt8); $zipname = 'bankfile.zip'; $zip = new ZipArchive; $zip->open($zipname, ZipArchive::CREATE); foreach ($files as $file) { $zip->addFile($file); } $zip->close(); header('Content-Type: application/zip'); header('Content-disposition: attachment; filename='.$zipname); header('Content-Length: ' . filesize($zipname)); readfile($zipname); } ?>