PluginProbe
ANAC XML Bandi di Gara / 7.7.4
ANAC XML Bandi di Gara v7.7.4
7.8 trunk 0.1 1.0.0.1 1.0.1 1.0.2 1.0.3 1.0.4 1.1 1.1.1 1.1.2 2.0 2.0.1 2.0.2 2.0.3 2.1 2.2 2.3 2.3.1 3 3.0.1 3.1 3.1.1 3.1.2 3.1.3 All 57 releases
avcp / avcp.php

avcp.php in ANAC XML Bandi di Gara 7.7.4, at avcp.php

430 lines 17.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: ANAC XML Bandi di Gara
4 Plugin URI: https://wordpress.org/plugins/avcp
5 Description: Generatore XML per ANAC (ex AVCP) e gestione bandi di gara e contratti (Legge 190/2012 art. 1.32 & D.Lgs 33/2013)
6 Author: Marco Milesi
7 Version: 7.7.4
8 Author URI: https://www.marcomilesi.com
9 */
10
11 add_action( 'init', 'register_cpt_avcp' );
12
13 function register_cpt_avcp() {
14
15 $labels = array(
16 'name' => 'Bandi di gara',
17 'singular_name' => _x( 'Gara', 'avcp' ),
18 'add_new' => _x( 'Nuova voce', 'avcp' ),
19 'add_new_item' => _x( 'Nuova Gara', 'avcp' ),
20 'edit_item' => _x( 'Modifica Gara', 'avcp' ),
21 'new_item' => _x( 'Nuova Gara', 'avcp' ),
22 'view_item' => _x( 'Vedi Gara', 'avcp' ),
23 'search_items' => _x( 'Cerca Gara', 'avcp' ),
24 'not_found' => _x( 'Nessuna voce trovata', 'avcp' ),
25 'not_found_in_trash' => _x( 'Nessuna voce trovata', 'avcp' ),
26 'parent_item_colon' => _x( 'Parent Gara:', 'avcp' ),
27 'menu_name' => 'Bandi'
28 );
29
30 $get_avcp_abilita_ruoli = get_option('avcp_abilita_ruoli');
31 if ($get_avcp_abilita_ruoli == '1') {
32 $avcp_capability_type = 'gare_avcp';
33 $avcp_map_meta_cap_var = 'true';
34 $avcp_capabilities_array = array(
35 'publish_posts' => 'pubblicare_gara_avcp',
36 'edit_posts' => 'modificare_propri_gara_avcp',
37 'edit_others_posts' => 'modificare_altri_gara_avcp',
38 'delete_posts' => 'eliminare_propri_gara_avcp',
39 'delete_others_posts' => 'modificare_altri_gara_avcp',
40 'read_private_posts' => 'read_private_avcp',
41 'edit_post' => 'modificare_gara_avcp',
42 'delete_post' => 'eliminare_gara_avcp',
43 'read_post' => 'leggere_gara_avcp',
44 );
45 } else {
46 $avcp_capability_type = 'post';
47 $avcp_map_meta_cap_var = 'false';
48 }
49
50 $args = array(
51 'labels' => $labels,
52 'hierarchical' => false,
53 'description' => 'Gare AVCP',
54 'supports' => array( 'title', 'custom-fields', 'editor', 'revisions', 'post_tag' ),
55 'taxonomies' => array( 'ditte' ),
56 'public' => true,
57 'show_ui' => true,
58 'show_in_menu' => true,
59 'menu_position' => 37,
60 'menu_icon' => 'dashicons-portfolio',
61 'show_in_nav_menus' => false,
62 'publicly_queryable' => true,
63 'exclude_from_search' => false,
64 'has_archive' => true,
65 'query_var' => true,
66 'can_export' => true,
67 'rewrite' => true,
68 'capability_type' => $avcp_capability_type,
69 'map_meta_cap' => $avcp_map_meta_cap_var
70 );
71
72 register_post_type( 'avcp', $args );
73 }
74
75 add_action( 'init', 'register_taxonomy_ditte' );
76
77 function register_taxonomy_ditte() {
78
79 $labels = array(
80 'name' => _x( 'Ditte partecipanti', 'ditte' ),
81 'singular_name' => _x( 'Ditte', 'ditte' ),
82 'search_items' => _x( 'Cerca Ditta', 'ditte' ),
83 'popular_items' => _x( 'Ditte più usate', 'ditte' ),
84 'all_items' => _x( 'Tutte le ditte', 'ditte' ),
85 'parent_item' => _x( 'Parent Ditte', 'ditte' ),
86 'parent_item_colon' => _x( 'Parent Ditte:', 'ditte' ),
87 'edit_item' => _x( 'Edit Ditte', 'ditte' ),
88 'update_item' => _x( 'Update Ditte', 'ditte' ),
89 'add_new_item' => _x( 'Nuova Ditta', 'ditte' ),
90 'new_item_name' => _x( 'Nuova Ditte', 'ditte' ),
91 'separate_items_with_commas' => _x( 'Separate ditta with commas', 'ditte' ),
92 'add_or_remove_items' => _x( 'Add or remove ditta', 'ditte' ),
93 'choose_from_most_used' => _x( 'Choose from the most used ditta', 'ditte' ),
94 'menu_name' => _x( 'Ditte', 'ditte' ),
95 );
96
97 $args = array(
98 'labels' => $labels,
99 'public' => true,
100 'show_in_nav_menus' => false,
101 'show_ui' => true,
102 'show_tagcloud' => false,
103 'show_admin_column' => true,
104 'hierarchical' => true,
105 'rewrite' => true,
106 'query_var' => true
107 );
108
109 register_taxonomy( 'ditte', array('avcp'), $args );
110 }
111
112 add_action( 'init', 'register_taxonomy_annirif' );
113
114 function register_taxonomy_annirif() {
115
116 $labels2 = array(
117 'name' => _x( 'Anno Riferimento', 'annirif' ),
118 'singular_name' => _x( 'Anno Riferimento', 'annirif' ),
119 'search_items' => _x( 'Cerca Anno', 'annirif' ),
120 'popular_items' => _x( 'Anni più Usati', 'annirif' ),
121 'all_items' => _x( 'Tutti gli anni', 'annirif' ),
122 'parent_item' => _x( 'Parent Anni', 'annirif' ),
123 'parent_item_colon' => _x( 'Parent Anno:', 'annirif' ),
124 'edit_item' => _x( 'Modifica Anno', 'annirif' ),
125 'update_item' => _x( 'Aggiorna Anno', 'annirif' ),
126 'add_new_item' => _x( 'Nuovo Anno', 'annirif' ),
127 'new_item_name' => _x( 'Nuovo Anno', 'annirif' ),
128 'separate_items_with_commas' => _x( 'Separate anno with commas', 'annirif' ),
129 'add_or_remove_items' => _x( 'Add or remove anno', 'annirif' ),
130 'choose_from_most_used' => _x( 'Choose from the most used years', 'annirif' ),
131 'menu_name' => _x( 'Anni', 'annirif' ),
132 );
133
134 $args = array(
135 'labels' => $labels2,
136 'public' => true,
137 'show_in_nav_menus' => true,
138 'show_ui' => true,
139 'show_tagcloud' => false,
140 'show_admin_column' => true,
141 'hierarchical' => true,
142 'rewrite' => true,
143 'capabilities' => array('manage_terms' => 'utentealieno','edit_terms' => 'utentealieno','delete_terms' => 'utentealieno'),
144 'query_var' => true
145 );
146
147 register_taxonomy( 'annirif', array('avcp'), $args );
148
149 }
150
151 add_action( 'init', function() {
152 $labels = array(
153 'name' => _x( 'Uffici - Settori - Centri di costo', 'areesettori' ),
154 'singular_name' => _x( 'Settore - Centro di costo', 'areesettori' ),
155 'search_items' => _x( 'Cerca in Settori - Centri di costo', 'areesettori' ),
156 'popular_items' => _x( 'Settori - Centri di costo Più usati', 'areesettori' ),
157 'all_items' => _x( 'Tutti i Centri di costo', 'areesettori' ),
158 'parent_item' => _x( 'Parent Settore - Centro di costo', 'areesettori' ),
159 'parent_item_colon' => _x( 'Parent Settore - Centro di costo:', 'areesettori' ),
160 'edit_item' => _x( 'Modifica Settore - Centro di costo', 'areesettori' ),
161 'update_item' => _x( 'Aggiorna Settore - Centro di costo', 'areesettori' ),
162 'add_new_item' => _x( 'Aggiungi Nuovo Settore - Centro di costo', 'areesettori' ),
163 'new_item_name' => _x( 'Nuovo Settore - Centro di costo', 'areesettori' ),
164 'separate_items_with_commas' => _x( 'Separate settori - centri di costo with commas', 'areesettori' ),
165 'add_or_remove_items' => _x( 'Add or remove settori - centri di costo', 'areesettori' ),
166 'choose_from_most_used' => _x( 'Choose from the most used settori - centri di costo', 'areesettori' ),
167 'menu_name' => _x( 'Uffici & Settori', 'areesettori' ),
168 );
169
170 $args = array(
171 'labels' => $labels,
172 'public' => true,
173 'show_in_nav_menus' => false,
174 'show_ui' => true,
175 'show_tagcloud' => false,
176 'show_admin_column' => true,
177 'hierarchical' => true,
178
179 'rewrite' => true,
180 'query_var' => true
181 );
182 register_taxonomy( 'areesettori', array('incarico', 'spesa', 'avcp', 'amm-trasparente'), $args );
183 } );
184
185 add_action('save_post', 'save_at_gara_posts',10,2);
186 function save_at_gara_posts($post_id) {
187
188 if ( (get_option('avcp_autopublish') == '1') && (get_post_type($post_id ) == 'avcp') ) {
189
190 $terms = wp_get_post_terms($post_id, 'annirif');
191
192 $verificafilecreati = '';
193 if ( count($terms) > 0 ) {
194 //require_once(plugin_dir_path(__FILE__) . 'avcp_xml_generator.php');
195 foreach ( $terms as $term ) {
196 creafilexml ($term->name);
197 $verificafilecreati = $term->name . ' &bull; ' . $verificafilecreati;
198 }
199 anac_add_log('Generazione automatica: '.$verificafilecreati, 0);
200
201 }
202 }
203 }
204
205 /* =========== Cambio Titolo Custom Post =========== */
206 add_filter('enter_title_here', function($title) {
207 $screen = get_current_screen();
208 if ('avcp' == $screen->post_type) {
209 $title = 'Oggetto della Gara';
210 }
211 return $title;
212 });
213
214 /* =========== SHORTCODE ============ */
215
216 function avcp_func($atts)
217 {
218 extract(shortcode_atts(array('anno' => 'all'), $atts));
219
220 ob_start();
221 include(plugin_dir_path(__FILE__) . 'tablegen.php');
222 $atshortcode = ob_get_clean();
223 return $atshortcode;
224 }
225 add_shortcode('avcp', 'avcp_func');
226 add_shortcode('anac', 'avcp_func');
227 add_shortcode('gare', 'avcp_func');
228
229 function anac_add_log($azione, $errore) {
230 if ($errore) { $err = ' style="color:red;"'; } else { $err = ''; }
231 update_option('anac_log', get_option('anac_log') . '<br>' . current_time('d/m/Y - H:i') . ' <strong'.$err.'>'.$azione.'</strong>');
232 }
233
234 add_action( 'init', 'atg_caricamoduli' );
235 function atg_caricamoduli() {
236 require_once(plugin_dir_path(__FILE__) . 'avcp_create_taxonomy.php');
237 require_once(plugin_dir_path(__FILE__) . 'tax-meta-class/Tax-meta-class.php');
238 require_once(plugin_dir_path(__FILE__) . 'avcp_taxonomy_fields.php');
239 require_once(plugin_dir_path(__FILE__) . 'avcp_metabox_generator.php');
240 require_once(plugin_dir_path(__FILE__) . 'avcp_index_generator.php');
241 require_once(plugin_dir_path(__FILE__) . 'singlehack.php');
242 require_once(plugin_dir_path(__FILE__) . 'avcp_xml_generator.php');
243 require_once(plugin_dir_path(__FILE__) . 'opendata/loader.php');
244
245 //Funzioni
246 require_once(plugin_dir_path(__FILE__) . 'getsommeliquidate.php');
247
248 //Include sistemi di validazione
249 require_once(plugin_dir_path(__FILE__) . 'valid_page.php');
250 global $typenow;
251 if ($typenow == 'avcp') {
252 add_filter( 'manage_posts_custom_column', 'avcp_modify_post_table_row', 10, 2 );
253 add_filter( 'manage_posts_custom_column', 'avcp_modify_post_table' );
254 }
255 }
256
257
258 add_action('admin_enqueue_scripts', function( $hook ) {
259
260 global $post;
261 if ( ('post-new.php' == $hook || 'post.php' == $hook) && 'avcp' === $post->post_type ) {
262 wp_register_style( 'avcp_style', plugins_url('avcp/includes/avcp_admin.css') );
263 wp_enqueue_style( 'avcp_style');
264
265 wp_enqueue_script( 'avcp_functions', plugins_url('avcp/includes/avcp_functions.js'), array( 'jquery' ) );
266
267
268 wp_register_script('avcp_searchTaxonomyGT_at_js', plugins_url('includes/searchTaxonomyGT.js', __FILE__));
269 wp_enqueue_script('avcp_searchTaxonomyGT_at_js');
270 }
271 });
272
273 add_action('admin_notices', function() {
274 global $current_user ;
275 global $current_screen;
276 $user_id = $current_user->ID;
277
278 if (get_option('avcp_denominazione_ente') == null || get_option('avcp_codicefiscale_ente') == null) {
279 echo '<div class="error"><p><strong>ANAC XML</strong>: alcuni dati dell\'ente non sono stati specificati in <strong>WPGov.it >> XML Bandi di Gara</strong></b></a></div>';
280 }
281
282 if ( 'ditte' == $current_screen->taxonomy ) {
283 echo '<div class="updated"><p>Attenzione: ogni modifica effettuata a una ditta si applica anche alle gare già pubblicate!<br/>Nel caso di cambio partita iva o denominazione, creare una nuova ditta.</p></div>';
284 } else if ( 'areesettori' == $current_screen->taxonomy ) {
285 echo '<div class="updated"><p>Attenzione: ogni modifica effettuata a un settore-centro di costo si applica anche alle gare già pubblicate!</p></div>';
286 }
287 });
288
289 add_action( 'admin_init', 'AVCP_ADMIN_LOAD');
290 function AVCP_ADMIN_LOAD () {
291
292 require_once(plugin_dir_path(__FILE__) . 'taxfilteringbackend.php');
293
294 register_setting( 'avcp_options', 'avcp_version_number');
295 register_setting( 'avcp_options', 'avcp_denominazione_ente');
296 register_setting( 'avcp_options', 'avcp_codicefiscale_ente');
297 register_setting( 'avcp_options', 'avcp_autopublish');
298 register_setting( 'avcp_options', 'avcp_dis_archivioditte');
299 register_setting( 'avcp_options', 'avcp_dis_archivioanni');
300 register_setting( 'avcp_options', 'avcp_tab_jqueryui');
301 register_setting( 'avcp_options', 'avcp_showxml');
302 register_setting( 'avcp_options', 'avcp_showlove');
303 register_setting( 'avcp_options', 'avcp_enable_editor');
304 register_setting( 'avcp_options', 'avcp_abilita_ruoli');
305 register_setting( 'avcp_options', 'avcp_centricosto');
306 register_setting( 'avcp_options', 'avcp_export');
307 register_setting( 'avcp_options', 'avcp_dataset_capability');
308
309
310
311 require_once(plugin_dir_path(__FILE__) . 'pannelli/import.php');
312
313 //Controllo Versione e Utilità
314 $arraya_anac_v = get_plugin_data ( __FILE__ );
315 $nuova_versione_anac = $arraya_anac_v['Version'];
316
317 $versione_attuale_anac = get_option('avcp_version_number');
318 if ($versione_attuale_anac == '') {
319 update_option( 'avcp_version_number', $nuova_versione_anac );
320 crea_anni();
321 avcp_activate();
322 } else if (version_compare($versione_attuale_anac, $nuova_versione_anac, '<') == '1') {
323 crea_anni();
324 avcp_activate();
325 require_once(plugin_dir_path(__FILE__) . 'update.php');
326 update_option( 'avcp_version_number', $nuova_versione_anac );
327 anac_add_log('Aggiornato plugin ' . $nuova_versione_anac, 0);
328 }
329 delete_option('avcp_invalid');
330 }
331
332 function crea_anni() {
333
334 for( $x = 2013; $x <= 2030; $x++) {
335 $termcheck = term_exists( $x, 'annirif');
336 if ($termcheck == 0 || $termcheck == null) {
337 wp_insert_term( $x, 'annirif');
338 anac_add_log('Aggiunto anno di riferimento <strong>'.$x.'</strong>', 0);
339 }
340 }
341 }
342
343 add_action('admin_menu', function() {
344
345 if ( !wp_count_posts( 'avcp' ) || wp_count_posts( 'avcp')->publish == 0 ) {
346 add_submenu_page('edit.php?post_type=avcp', 'Importa', 'Importa', 'manage_options', 'anac_import', 'anac_import_load');
347 }
348
349 if (!get_option('avcp_dataset_capability')) {
350 $anac_menu_cap = 'manage_options';
351 } else {
352 $anac_menu_cap = get_option('avcp_dataset_capability');
353 }
354
355 add_submenu_page('edit.php?post_type=avcp', 'Validazione', 'Validazione', $anac_menu_cap, 'avcp_v_dataset', 'avcp_v_dataset_load'); //valid_page.php
356
357 add_submenu_page( 'edit.php?post_type=avcp', 'Impostazioni', 'Impostazioni', 'publish_posts', 'wpgov_avcp', function() { include(plugin_dir_path(__FILE__) . 'settings.php'); } );
358
359 });
360
361 function avcp_activate() {
362 $srcfile= ABSPATH . 'wp-content/plugins/avcp/includes/index.php.null';
363 $dstfile= avcp_get_basexmlpath() . 'index.php';
364 mkdir(dirname($dstfile), 0755, true);
365 copy($srcfile, $dstfile);
366 chmod($dstfile, 0755);
367 }
368
369 function avcp_deactivate() {
370 unlink(ABSPATH . 'avcp/index.php');
371 }
372 register_deactivation_hook( __FILE__, 'avcp_deactivate' );
373
374
375 function avcp_get_contraente($input) {
376 $tipi_contraente = array(
377 array('01','01-PROCEDURA APERTA'),
378 array('02','02-PROCEDURA RISTRETTA'),
379 array('03','03-PROCEDURA NEGOZIATA PREVIA PUBBLICAZIONE'),
380 array('04','04-PROCEDURA NEGOZIATA SENZA PREVIA PUBBLICAZIONE'),
381 array('05','05-DIALOGO COMPETITIVO'),
382 array('06','06-PROCEDURA NEGOZIATA SENZA PREVIA INDIZIONE DI GARA (SETTORI SPECIALI)'),
383 array('07','07-SISTEMA DINAMICO DI ACQUISIZIONE'),
384 array('08','08-AFFIDAMENTO IN ECONOMIA - COTTIMO FIDUCIARIO'),
385 array('14','14-PROCEDURA SELETTIVA EX ART 238 C.7, D.LGS. 163/2006'),
386 array('17','17-AFFIDAMENTO DIRETTO EX ART. 5 DELLA LEGGE 381/91'),
387 array('21','21-PROCEDURA RISTRETTA DERIVANTE DA AVVISI CON CUI SI INDICE LA GARA'),
388 array('22','22-PROCEDURA NEGOZIATA CON PREVIA INDIZIONE DI GARA (SETTORI SPECIALI)'),
389 array('23','23-AFFIDAMENTO DIRETTO'),
390 array('24','24-AFFIDAMENTO DIRETTO A SOCIETA\' IN HOUSE'),
391 array('25','25-AFFIDAMENTO DIRETTO A SOCIETA\' RAGGRUPPATE/CONSORZIATE O CONTROLLATE NELLE CONCESSIONI E NEI PARTENARIATI'),
392 array('26','26-AFFIDAMENTO DIRETTO IN ADESIONE AD ACCORDO QUADRO/CONVENZIONE'),
393 array('27','27-CONFRONTO COMPETITIVO IN ADESIONE AD ACCORDO QUADRO/CONVENZIONE'),
394 array('28','28-PROCEDURA AI SENSI DEI REGOLAMENTI DEGLI ORGANI COSTITUZIONALI'),
395 array('29','29-PROCEDURA RISTRETTA SEMPLIFICATA'),
396 array('30','30-PROCEDURA DERIVANTE DA LEGGE REGIONALE'),
397 array('31','31-AFFIDAMENTO DIRETTO PER VARIANTE SUPERIORE AL 20% DELL\'IMPORTO CONTRATTUALE'),
398 array('32','32-AFFIDAMENTO RISERVATO'),
399 array('33','33-PROCEDURA NEGOZIATA PER AFFIDAMENTI SOTTO SOGLIA'),
400 array('34','34-PROCEDURA ART.16 COMMA 2-BIS DPR 380/2001 PER OPERE URBANIZZAZIONE A SCOMPUTO PRIMARIE SOTTO SOGLIA COMUNITARIA'),
401 array('35','35-PARTERNARIATO PER L’INNOVAZIONE'),
402 array('36','36-AFFIDAMENTO DIRETTO PER LAVORI, SERVIZI O FORNITURE SUPPLEMENTARI'),
403 array('37','37-PROCEDURA COMPETITIVA CON NEGOZIAZIONE'),
404 array('38','38-PROCEDURA DISCIPLINATA DA REGOLAMENTO INTERNO PER SETTORI SPECIALI'),
405 );
406 foreach ( $tipi_contraente as $tc ) {
407 if ( substr($input, 0, 2) == $tc[0] ) {
408 return $tc[1];
409 }
410 }
411 return "Non definito";
412 }
413 function avcp_get_basexmlurl($year = 0) {
414 $base = apply_filters( 'anac_filter_basexmlurl', get_site_url() . '/avcp/' );
415 if ( $year ) {
416 return $base . $year.'.xml';
417 } else {
418 return $base;
419 }
420 }
421 function avcp_get_basexmlpath($year = 0) {
422 $base = apply_filters( 'anac_filter_basexmlpath', ABSPATH . 'avcp/' );
423 if ( $year ) {
424 return $base . $year . '.xml';
425 } else {
426 return $base;
427 }
428 }
429
430 ?>