_x('Spese', 'spesa'),
'singular_name' => _x('Spesa', 'spesa'),
'add_new' => _x('Nuova Spesa', 'spesa'),
'add_new_item' => _x('Nuova Spesa', 'spesa'),
'edit_item' => _x('Modifica Spesa', 'spesa'),
'new_item' => _x('Nuova Spesa', 'spesa'),
'view_item' => _x('Visualizza Spesa', 'spesa'),
'search_items' => _x('Cerca Spesa', 'spesa'),
'not_found' => _x('Nessun elemento trovato', 'spesa'),
'not_found_in_trash' => _x('Nessun elemento trovato', 'spesa'),
'parent_item_colon' => _x('Parent Spesa:', 'spesa'),
'menu_name' => _x('Amm. Aperta', 'spesa')
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'In particolare, al fine di ottemperare all’obbligo normativo, per ogni spesa documentata è richiesta la pubblicazione di informazioni relative a:
ragione sociale e dati fiscali dell’impresa beneficiaria;
importo di spesa;
la norma o il titolo a base dell’attribuzione;
l’ufficio e il funzionario o responsabile del procedimento amministrativo;
metodo e modalità per la scelta del beneficiario;
link utili a: progetto selezionato, curriculum del soggetto incaricato, contratto e capitolato della prestazione, fornitura o servizio',
'supports' => array(
'title',
'custom-fields'
),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => plugin_dir_url(__FILE__) . 'openshareicon-16x16.png',
'show_in_nav_menus' => false,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => false,
'query_var' => false,
'can_export' => true,
'rewrite' => false,
'capability_type' => 'post'
);
register_post_type('spesa', $args);
}
/* =========== TITOLO HCK =========== */
function change_default_title($title)
{
$screen = get_current_screen();
if ('spesa' == $screen->post_type) {
$title = 'Inserire Titolo Spesa/Progetto';
}
return $title;
}
add_filter('enter_title_here', 'change_default_title');
/* =========== SHORTCODE ============ */
function ammap_func($atts)
{
include(plugin_dir_path(__FILE__) . 'tablegen.php');
}
add_shortcode('ammap', 'ammap_func');
/* =========== META BOX ============ */
include(plugin_dir_path(__FILE__) . 'meta-box-class/my-meta-box-class.php');
/*
* configure your meta box
*/
$config = array(
'id' => 'ammap_meta_box', // meta box id, unique per meta box
'title' => 'Dettagli Spesa', // meta box title
'pages' => array(
'spesa'
), // post types, accept custom post types as well, default is array('post'); optional
'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional
'priority' => 'high', // order of meta box: high (default), low; optional
'fields' => array(), // list of meta fields (can be added by field arrays) or using the class's functions
'local_images' => false, // Use local or hosted images (meta box images for add/remove)
'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
/*
* Initiate your meta box
*/
$my_meta = new AT_Meta_Box($config);
/*
* Campi personalizzati del Plugin - Usa API terze parti
*/
$prefix = "ammap_";
//text field
$my_meta->addText($prefix . 'beneficiario', array(
'name' => 'Beneficiario'
));
$my_meta->addText($prefix . 'importo', array(
'name' => 'Importo. Es. 2.000'
));
$my_meta->addText($prefix . 'fiscale', array(
'name' => 'Dati Fiscali'
));
$my_meta->addText($prefix . 'norma', array(
'name' => 'Norma'
));
$my_meta->addText($prefix . 'responsabile', array(
'name' => 'Responsabile'
));
$my_meta->addText($prefix . 'determina', array(
'name' => 'Determina'
));
$my_meta->addSelect($prefix . 'assegnazione', array(
'Chiamata Diretta' => 'Chiamata Diretta',
'Bando Pubblico' => 'Bando Pubblico'
), array(
'name' => 'Modalità Assegnazione',
'std' => array(
'Selezionare...'
)
));
$my_meta->addDate($prefix . 'data', array(
'name' => 'Data'
));
$my_meta->addWysiwyg($prefix . 'wysiwyg', array(
'name' => ' Caricamento Allegati'
));
/*
* Don't Forget to Close up the meta box deceleration
*/
//Finish Meta Box Deceleration
$my_meta->Finish();
/* =========== Visualizzazione Singola */
add_action('template_redirect', 'ft_job_cpt_template');
function ft_job_cpt_template()
{
global $wp, $wp_query;
if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] == 'spesa') {
if (have_posts()) {
add_filter('the_content', 'ft_job_cpt_template_filter');
} else {
$wp_query->is_404 = true;
}
}
}
function ft_job_cpt_template_filter($content)
{
global $wp_query;
$jobID = $wp_query->post->ID;
echo 'Importo: € ' . get_post_meta(get_the_ID(), 'ammap_importo', true) . '
';
echo 'Beneficiario: ' . get_post_meta(get_the_ID(), 'ammap_beneficiario', true) . '
';
echo 'Dati Fiscali: ' . get_post_meta(get_the_ID(), 'ammap_fiscale', true) . '
';
echo 'Norma: ' . get_post_meta(get_the_ID(), 'ammap_norma', true) . '
';
echo 'Modalità: ' . get_post_meta(get_the_ID(), 'ammap_assegnazione', true) . '
';
echo 'Responsabile: ' . get_post_meta(get_the_ID(), 'ammap_responsabile', true) . '
';
echo 'Determina: ' . get_post_meta(get_the_ID(), 'ammap_determina', true) . '
';
echo 'Data: ' . get_post_meta(get_the_ID(), 'ammap_data', true) . '
';
echo 'Documenti Allegati:
';
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'application/pdf,application/msword,application/zip,application/vnd.ms-excel',
'numberposts' => -1,
'post_status' => null,
'post_parent' => get_the_ID(),
'orderby' => 'menu_order',
'order' => 'desc'
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$class = "post-attachment mime-" . sanitize_title($attachment->post_mime_type);
echo '