-
Notifications
You must be signed in to change notification settings - Fork 0
/
document-creator.php
245 lines (209 loc) · 8.5 KB
/
document-creator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
/*
Plugin Name: Document Creator
Plugin URI: -
Description: Make Document From Template
Version: 1.1.0
Author: Dharmawan Sukma Hardi
Author URI: -
License: GPLv2 or laterss
Text Domain:
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
function docrt_plugin_url() {
return untrailingslashit( plugins_url( '/', __FILE__ ) );
}
function docrt_plugin_path() {
return untrailingslashit( plugin_dir_path( __FILE__ ) );
}
function docrt_plugin_basename() {
return plugin_basename(__FILE__);
}
/*****************************************************************************************
* Define
*****************************************************************************************/
function docrt_get_list_ttd() {
$docrt_pej = get_option('docrt_pej');
$pejabat = array();
foreach ($docrt_pej as $key => $value) {
$pejabat[] = $value['kode'];
}
return $pejabat;
}
function docrt_get_type_surat_allowed() {
$docrt_surat_checkbox = get_option('docrt_surat_checkbox');
$surat = array();
if ($docrt_surat_checkbox) {
foreach ($docrt_surat_checkbox as $key => $value) {
if ($value == 1) {
$surat[] = $key;
}
}
}
return $surat;
}
// data dasar
function docrt_dd($jenis = false){
$dd = get_option('docrt_data_dasar');
if($jenis) return $dd[$jenis];
return $dd;
}
// no surat here
function docrt_no_surat($type,$meta,$postID) {
$no = '35.73'.'.'.docrt_dd('kkec').'.'.docrt_dd('kkel');
// Surat Utama 16
$data['sku'] = '563/'.$meta['docrt_sku_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skdu'] = '563/'.$meta['docrt_skdu_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skd'] = '563/'.$meta['docrt_skd_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skik'] = '435/'.$meta['docrt_skik_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skck'] = '331/'.$meta['docrt_skck_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skp'] = '475/'.$meta['docrt_skp_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skp_m'] = '475/'.$meta['docrt_skp_m_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['sktm'] = '581/'.$meta['docrt_sktm_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skbpm'] = '474/'.$meta['docrt_skbpm_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['skel'] = '474.1/'.$meta['docrt_skel_id'][0].'/'.$no.'/'.'V/'.get_the_date('Y',$postID) ;
$data['skem'] = '474.3/'.$meta['docrt_skem_id'][0].'/'.$no.'/'.'V/'.get_the_date('Y',$postID) ;
$data['kk'] = $meta['docrt_kk_id'][0].'/'.get_the_date('Y',$postID) ;
$data['kk_p'] = $meta['docrt_kk_p_id'][0].'/'.get_the_date('Y',$postID) ;
$data['kk_t'] = $meta['docrt_kk_t_id'][0].'/'.get_the_date('Y',$postID) ;
$data['ktp'] = $meta['docrt_ktp_id'][0].'/'.get_the_date('Y',$postID) ;
$data['sk'] = '474/'.$meta['docrt_sk_id'][0].'/'.$no.'/'.get_the_date('Y',$postID) ;
$data['lg'] = $meta['docrt_lg_id'][0].'/'.get_the_date('Y',$postID) ;
$data['r_u'] = $meta['docrt_r_u_id'][0].'/'.get_the_date('Y',$postID) ;
$data['r_ho'] = $meta['docrt_r_ho_id'][0].'/'.get_the_date('Y',$postID) ;
$data['r_imb'] = $meta['docrt_r_imb_id'][0].'/'.get_the_date('Y',$postID) ;
// option: bukan merupakan surat utama
$data['skai'] = '331/'.$meta['docrt_skp_id'][0].'/'.$no.'/'.'V/'.get_the_date('Y',$postID) ;
$data['skkel'] = '???/'.$meta['docrt_skel_id'][0].'/'.$no.'/'.'V/'.get_the_date('Y',$postID) ;
$data['skkem'] = '???/'.$meta['docrt_skem_id'][0].'/'.$no.'/'.'V/'.get_the_date('Y',$postID) ;
return $data[$type];
}
// List yang menandatangani
function docrt_who_give_ttd($jenis_ttd) {
$pejabat = get_option('docrt_pej');
$data_dasar = get_option('docrt_data_dasar');
//unset($pejabat['count']);
$status = false;
foreach ($pejabat as $k => $v) {
// Kondisi kusus
$lurah = strtoupper('Lurah '.$data_dasar['kel']);
switch ($v['kode']) {
case 'lurah':
$option_jabatan = $lurah;
$option_kasi = '';
break;
case 'seklur':
$option_jabatan = $lurah.'<br /><span style="font-size:11px;">'.$v['jabatan'].'</span>';
$option_kasi = '';
break;
default:
$option_jabatan = 'an: '.$lurah.'<br /><span style="font-size:11px;">'.$v['jabatan'].'</span>';
$option_kasi = '<span style="font-size:11px;">Penata</span><br/>';
break;
}
if ($v['kode'] == $jenis_ttd) {
$ttd['jabatan'] = $option_jabatan;
$ttd['nama'] = $v['nama'];
$ttd['kasi'] = $option_kasi;
$ttd['nip'] = 'NIP. '.$v['nip'];
$status = true;
}
// lurah selalu ikut
if ($v['kode'] == 'lurah') {
$ttd['lurah'] = $v;
}
}
if (!$status) {
$ttd['jabatan'] = 'error';
$ttd['nama'] = 'error';
$ttd['kasi'] = 'error';
$ttd['nip'] = 'error';
}
return $ttd;
}
function docrt_include_admin() {
if (is_admin()) {
include_once __DIR__ . '/includes/admin/types-table-filter.php';
include_once __DIR__ . '/includes/admin/settings.php';
}
}
add_action('init', 'docrt_include_admin');
function docrt_load_scripts_admin() {
global $pagenow;
wp_enqueue_style( 'style-default', docrt_plugin_url() . '/assets/css/style_admin.css' );
wp_enqueue_style( 'jqui-css', docrt_plugin_url() . '/assets/css/jquery-ui.css' );
wp_enqueue_script( 'jqui-js', docrt_plugin_url() . '/assets/js/jquery-ui.js', array('jquery'), '' );
if (in_array($pagenow, array('post-new.php', 'post.php'))) {
wp_enqueue_media();
wp_enqueue_script( 'form-js', docrt_plugin_url() . '/assets/js/docrt-form.js' , array('jquery'), '' );
}
if (in_array($pagenow, array('edit.php'))) {
wp_enqueue_media();
wp_enqueue_script( 'edit-js', docrt_plugin_url() . '/assets/js/docrt-edit.js' , array('jquery'), '' );
}
}
add_action('admin_enqueue_scripts', 'docrt_load_scripts_admin');
function docrt_load_scripts(){
wp_enqueue_media();
wp_enqueue_style( 'style-default', docrt_plugin_url() . '/assets/css/style.css' );
//wp_localize_script( 'main-js', 'ajax_params', array( 'ajax_url' => docrt_plugin_url().'/ajax'.'/'));
// send ajax url
wp_localize_script('main-js', 'ajax_params', array(
'empty_img_url' => docrt_plugin_url() . '/assets/img/rectangle.png',
'ajax_url' => docrt_plugin_url() . '/ajax' . '/'
));
}
add_action( 'wp_enqueue_scripts', 'docrt_load_scripts' );
/*****************************************************************************************
* Set Option on install Plugin
* docrt-document
*****************************************************************************************/
function docrt_tax_list() {
$terms_surat = get_terms( array(
'taxonomy' => 'surat',
'hide_empty' => false,
) );
$all_terms_empty = false;
if (!$terms_surat) $all_terms_empty = true;
foreach ($terms_surat as $key => $v) {
$terms_surat_array[$v->slug] = $v->name;
}
$terms = docrt_get_terms_active();
foreach ($terms as $key => $value) {
if ( !array_key_exists($key, $terms_surat_array) || $all_terms_empty) {
wp_insert_term( $value, 'surat', $args = array('slug' => $key) );
}
}
}
function docrt_get_terms_active() {
$terms = array(
'sku' => 'surat keterangan usaha',
'skdu' => 'surat keterangan domisili usaha ',
'skd' => 'surat keterangan domisili',
'skik' => 'surat keterangan ijin keramaian',
'skck' => 'surat keterangan catatan kepolisian',
'sktm' => 'surat keterangan tidak mampu',
'skbpm' => 'surat keterangan balum pernah menikah',
'skel' => 'surat kelahiran',
'skem' => 'surat kematian',
'skp' => 'surat keterangan pindah',
'skp_m' => 'surat keterangan pindah masuk',
'sk' => 'surat keterangan',
'ktp' => 'kartu tanda penduduk',
// KK
'kk' => 'kartu keluarga',
'kk_p' => 'KK perubahan',
'kk_t' => 'KK tambah anggota keluarga',
// Rekomendasi
'r_u' => 'recom umum',
'r_ho' => 'recom HO',
'r_imb' => 'recom IMB',
// Legalisir
'lg' => 'legalisir',
);
return $terms;
}
include_once __DIR__ . '/includes/types.php';
include_once __DIR__ . '/includes/types-perangkat.php';