first commit
This commit is contained in:
+140
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
include('../koneksi.php');
|
||||
|
||||
|
||||
|
||||
//echo "Hari ini adalah ". hari_ini();
|
||||
|
||||
$riwayat_kegiatan_id=$_POST['riwayat_kegiatan_id'];
|
||||
$satuan_kerja_id=$_POST['satuan_kerja_id'];
|
||||
|
||||
$ket=pg_query("SELECT a1.id,a1.nama,a2.id,a2.tgl_nd,a2.no_nd,k.thn,k.nama_pelatihan,
|
||||
k.tanggal_mulai,k.tanggal_selesai,k.waktu_mulai,k.waktu_selesai,k.tempat,
|
||||
a2.permintaan_nd,a2.tgl_paling_lambat_nd,k.id
|
||||
FROM satuan_kerja a1
|
||||
INNER JOIN riwayat_quota a2 ON (a2.satuan_kerja_id=a1.id)
|
||||
INNER JOIN riwayat_kegiatan k ON (a2.riwayat_kegiatan_id=k.id)
|
||||
WHERE a2.riwayat_kegiatan_id='$riwayat_kegiatan_id'
|
||||
AND a1.id='$satuan_kerja_id'
|
||||
");
|
||||
|
||||
while($rket=pg_fetch_array($ket)) {
|
||||
$id=$rket[14];
|
||||
$satker_nd_1=str_replace("&","dan",$rket[1]);
|
||||
$tgl_nd_1=$rket[3];
|
||||
$no_nd_1=$rket[4];
|
||||
$thn_nd_1=$rket[5];
|
||||
$nama_pelatihan_nd_1=str_replace("&","dan",$rket[6]);
|
||||
$tanggal_mulai=$rket[7];
|
||||
$tanggal_selesai=$rket[8];
|
||||
$waktu_mulai=$rket[9];
|
||||
$waktu_selesai=$rket[10];
|
||||
$tempat_nd_1=str_replace("&","dan",$rket[11]);
|
||||
$permintaan_nd_1d=str_replace("&","dan",$rket[12]);
|
||||
$tgl_paling_lambat_nd_1 =$rket[13];
|
||||
}
|
||||
|
||||
$kpl=pg_query("SELECT p.nama,p.nipb,k.pangkat
|
||||
FROM data_kepala k
|
||||
INNER JOIN data_pegawai p ON (p.id=k.data_pegawai_id) WHERE k.aktif='t'");
|
||||
while($rkpl=pg_fetch_array($kpl)) {
|
||||
$nm_kepala=$rkpl[0];
|
||||
$pangkat=$rkpl[2];
|
||||
$nip=$rkpl[1];
|
||||
}
|
||||
$thn=date('Y');
|
||||
$array_hari = array(1=>"Senin","Selasa","Rabu","Kamis","Jumat", "Sabtu","Minggu");
|
||||
$hari1 = $array_hari[date("N",strtotime($tanggal_mulai))];
|
||||
$hari2 = $array_hari[date("N",strtotime($tanggal_selesai))];
|
||||
|
||||
$bulan = array(
|
||||
'01' => 'Januari',
|
||||
'02' => 'Februari',
|
||||
'03' => 'Maret',
|
||||
'04' => 'April',
|
||||
'05' => 'Mei',
|
||||
'06' => 'Juni',
|
||||
'07' => 'Juli',
|
||||
'08' => 'Agustus',
|
||||
'09' => 'September',
|
||||
'10' => 'Oktober',
|
||||
'11' => 'November',
|
||||
'12' => 'Desember',
|
||||
);
|
||||
$bulan[date('m')];
|
||||
|
||||
|
||||
$template_file_name = 'nd_permohonan_peserta.docx';
|
||||
|
||||
$rand_no = rand(111111, 999999);
|
||||
$fileName = "NOTA_DINAS_PERMOHONAN_PESERTA_".$satker_nd_1.'_'.$no_nd_1.".docx";
|
||||
|
||||
$folder = $id;
|
||||
$full_path = $folder . '/' . $fileName;
|
||||
|
||||
try
|
||||
{
|
||||
if (!file_exists($folder))
|
||||
{
|
||||
mkdir($folder);
|
||||
}
|
||||
|
||||
//Copy the Template file to the Result Directory
|
||||
copy($template_file_name, $full_path);
|
||||
|
||||
// add calss Zip Archive
|
||||
$zip_val = new ZipArchive;
|
||||
|
||||
//Docx file is nothing but a zip file. Open this Zip File
|
||||
if($zip_val->open($full_path) == true)
|
||||
{
|
||||
// In the Open XML Wordprocessing format content is stored.
|
||||
// In the document.xml file located in the word directory.
|
||||
|
||||
$key_file_name = 'word/document.xml';
|
||||
$message = $zip_val->getFromName($key_file_name);
|
||||
|
||||
$timestamp = date('d-M-Y H:i:s');
|
||||
|
||||
// this data Replace the placeholders with actual values
|
||||
$message = str_replace("satker_nd_1", $satker_nd_1, $message);
|
||||
$message = str_replace("tgl_nd_1", date('d',strtotime($tgl_nd_1)).' '.($bulan[date('m',strtotime($tgl_nd_1))]).' '.date('Y',strtotime($tgl_nd_1)), $message);
|
||||
$message = str_replace("no_nd_1", $no_nd_1, $message);
|
||||
$message = str_replace("thn_nd_1", $thn_nd_1, $message);
|
||||
$message = str_replace("nama_pelatihan_nd_1", $nama_pelatihan_nd_1, $message);
|
||||
|
||||
if ($tanggal_mulai==$tanggal_selesai) {
|
||||
$message = str_replace("hari_nd_1", $hari1, $message);
|
||||
$message = str_replace("tanggal_nd1", date('d',strtotime($tanggal_mulai)).' '.($bulan[date('m',strtotime($tanggal_mulai))]).' '.date('Y',strtotime($tanggal_mulai)), $message);
|
||||
} else {
|
||||
$message = str_replace("hari_nd_1", $hari1.' s/d '.$hari2, $message);
|
||||
$message = str_replace("tanggal_nd1", date('d',strtotime($tanggal_mulai)).' '.($bulan[date('m',strtotime($tanggal_mulai))]).' '.date('Y',strtotime($tanggal_mulai)).' s/d '.date('d',strtotime($tanggal_selesai)).' '.($bulan[date('m',strtotime($tanggal_selesai))]).' '.date('Y',strtotime($tanggal_selesai)), $message);
|
||||
}
|
||||
if (date('H:i',strtotime($waktu_selesai))=='00:00') {
|
||||
$message = str_replace("waktu_nd_1", date('H:i',strtotime($waktu_mulai)).' s/d Selesai', $message);
|
||||
} else {
|
||||
$message = str_replace("waktu_nd_1", date('H:i',strtotime($waktu_mulai)).' s/d '.date('H:i',strtotime($waktu_selesai)), $message);
|
||||
}
|
||||
$message = str_replace("tempat_nd_1", $tempat_nd_1, $message);
|
||||
$message = str_replace("permintaan", $permintaan_nd_1d, $message);
|
||||
$message = str_replace("tglplnd", date('d',strtotime($tgl_paling_lambat_nd_1)).' '.($bulan[date('m',strtotime($tgl_paling_lambat_nd_1))]).' '.date('Y',strtotime($tgl_paling_lambat_nd_1)), $message);
|
||||
$message = str_replace("kabid_nd_1", $nm_kepala, $message);
|
||||
$message = str_replace("pangkat_nd_1", $pangkat, $message);
|
||||
$message = str_replace("nip_nd_1", $nip, $message);
|
||||
|
||||
$zip_val->addFromString($key_file_name, $message);
|
||||
$zip_val->close();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception $exc)
|
||||
{
|
||||
$error_message = "Error creating the Word Document";
|
||||
var_dump($exc);
|
||||
}
|
||||
|
||||
echo $fileName;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user