"Senin","Selasa","Rabu","Kamis","Jumat", "Sabtu","Minggu"); $hari = $array_hari[date("N",strtotime($tgl_acara_und))]; $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 = 'undangan.docx'; $rand_no = rand(111111, 999999); $fileName = "UNDANGAN_".$nama_und.'_'.date('d',strtotime($tgl_und)).''.(date('m',strtotime($tgl_und))).''.date('Y',strtotime($tgl_und)).".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("tgl_und", date('d',strtotime($tgl_und)).' '.($bulan[date('m',strtotime($tgl_und))]).' '.date('Y',strtotime($tgl_und)), $message); $message = str_replace("no_und", $no_und, $message); $message = str_replace("thn_und", $thn_und, $message); $message = str_replace("nama_und", $nama_und, $message); $message = str_replace("satker_und", $satker_und, $message); $message = str_replace("tgl_acara_und", date('d',strtotime($tgl_acara_und)).' '.($bulan[date('m',strtotime($tgl_acara_und))]).' '.date('Y',strtotime($tgl_acara_und)), $message); if (date('H:i',strtotime($waktu_selesai))=='00:00') { $message = str_replace("waktu_acara_und", date('H:i',strtotime($waktu_mulai)).' s/d Selesai', $message); } else { $message = str_replace("waktu_acara_und", date('H:i',strtotime($waktu_mulai)).' s/d '.date('H:i',strtotime($waktu_selesai)), $message); } $message = str_replace("tempat_und", $tempat_und, $message); $message = str_replace("sebagai_und", $sebagai_und, $message); $message = str_replace("jenis_pel", $jenis_pel, $message); $message = str_replace("nama_pel", $nama_pel, $message); $message = str_replace("wadir_und", $wadir_und, $message); $message = str_replace("pangkat_und", $pangkat_und, $message); $message = str_replace("nip_und", $nip_und, $message); /* $message = str_replace("2020", $thn, $message); $message = str_replace("hd", $head, $message); $message = str_replace("isi_catatan", $isi_catatan, $message); */ //Replace the content with the new content created above. $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; ?>