* SlipGiroAction.java
* Part of project Vega
*
* Author: Tantowi Mustofa. tantowi@spjbaut.com
*/
package com.tantowi.vega.finance;
import com.tantowi.vega.absen.*;
import com.tantowi.nebula.*;
import com.tantowi.nebula.DbConnection;
import com.tantowi.vega.VegaAction;
import static com.tantowi.vega.VegaAction.format;
import static com.tantowi.vega.finance.GiroEditAction.getBankItems;
import java.io.IOException;
import java.sql.SQLException;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import java.text.DecimalFormat;
import javax.servlet.ServletOutputStream;
/**
*
* @author dhanang
*/
public class SlipGiroAction extends VegaAction {
int fid = 0;
String fnomor = "";
LocalDate ftanggal = LocalDate.now();
String fkepada = "";
String fbank = "";
LocalDate fjthtempo = LocalDate.now();
double fjumlah = 0;
String fmtu = "";
String fket = "";
String fnorek = "";
String fcabang = "";
@Override
protected void doInit() throws ServletException, SQLException, IOException {
authorize("finance");
}
@Override
protected void doGet() throws ServletException, SQLException, IOException {
try (DbConnection db = this.getDbConnection()) {
String cnomor = (String) request.getAttribute("nomor");
if (cnomor == null || cnomor.isEmpty()) {
throw new HttpNotFoundException("");
}
if (!cnomor.equals("~")) {
db.query("SELECT
A.ID,A.NOMOR,A.TANGGAL,A.KEPADA,A.JTEMPO,A.JUMLAH,A.KETERANGAN,B.BANK,B.CABANG,B.NO
MOR_REK FROM FINANCE_GIRO_REQ AS A\n"
+ "LEFT JOIN FINANCE_BANK AS B ON A.BANK_ID=B.ID where
A.NOMOR=?");
db.setString(1, cnomor);
db.execute();
if (!db.next()) {
throw new HttpNotFoundException("Nomor Not Found :" + cnomor);
}
fid = db.getInt(1);
fnomor = db.getString(2);
ftanggal = db.getLocalDate(3);
fkepada = db.getString(4);
fjthtempo = db.getLocalDate(5);
fjumlah = db.getInt(6);
fket = db.getString(7);
fbank = db.getString(8);
fcabang = db.getString(9);
fnorek = db.getString(10);
}
byte[] pdf = doSlip();
String filename = "Slip Giro -" + ".pdf";
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=" +
filename);
response.setContentLength(pdf.length);
ServletOutputStream out = response.getOutputStream();
out.write(pdf);
}
}
pg.close();
byte[] pdf = doc.build();
doc.close();
return pdf;
}