Plugin Directory

Changeset 2481749


Ignore:
Timestamp:
02/25/2021 07:12:52 PM (5 years ago)
Author:
Evarisk
Message:

Version 7.6.6

  • Add : Ajout d'un champ description pour un GP ou une UT.
Location:
digirisk/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • digirisk/trunk/digirisk.config.json

    r2476472 r2481749  
    22    "name": "Digirisk",
    33    "slug": "digirisk",
    4     "version": "7.6.5",
     4    "version": "7.6.6",
    55    "description": "L'application Digirisk",
    66    "insert_scripts_pages_js": [
  • digirisk/trunk/digirisk.php

    r2476475 r2481749  
    44 * Plugin URI:  http://www.evarisk.com/document-unique-logiciel
    55 * Description: Avec le plugin Digirisk vous pourrez réaliser, de façon simple et intuitive, le ou les documents uniques de vos entreprises et gérer toutes les données liées à la sécurité de votre personnel.
    6  * Version:     7.6.5
     6 * Version:     7.6.6
    77 * Author:      Evarisk
    88 * Author URI:  http://www.evarisk.com
  • digirisk/trunk/modules/informations/view/main.view.php

    r2476365 r2481749  
    1818
    1919<?php if ( ( $type != 'digi-group' ) && ( $type != 'digi-workunit' ) ) : ?>
    20     <h3><?php esc_html_e( 'Document unique', 'digirisk' ); ?></h3>
     20    <h3><?php esc_html_e( 'Document unique', 'digirisk' ); ?></h3>
    2121
    22     <div class="wpeo-gridlayout grid-3">
    23         <p>
    24             <span><?php esc_html_e( 'Date dernière impression:', 'digirisk' ); ?></span>
    25             <span><strong><?php echo ( ! empty( $current_duer ) ) ? $current_duer->data['date']['rendered']['date'] : __( 'N/A', 'digirisk' ); ?></strong></span>
    26         </p>
    27         <p><?php printf( __( 'Mise à jour obligatoire tous les <strong>%d</strong> jours', 'digirisk' ), $general_options['required_duer_day'] ); ?></p>
    28         <p><?php printf( __( 'Nombre de jours restant avant la prochaine mise à jour obligatoire: <strong>%s</strong> jours', 'digirisk' ), ! empty( $date_before_next_duer ) ? $date_before_next_duer : 'N/A' ); ?></p>
    29     </div>
     22    <div class="wpeo-gridlayout grid-3">
     23        <p>
     24            <span><?php esc_html_e( 'Date dernière impression:', 'digirisk' ); ?></span>
     25            <span><strong><?php echo ( ! empty( $current_duer ) ) ? $current_duer->data['date']['rendered']['date'] : __( 'N/A', 'digirisk' ); ?></strong></span>
     26        </p>
     27        <p><?php printf( __( 'Mise à jour obligatoire tous les <strong>%d</strong> jours', 'digirisk' ), $general_options['required_duer_day'] ); ?></p>
     28        <p><?php printf( __( 'Nombre de jours restant avant la prochaine mise à jour obligatoire: <strong>%s</strong> jours', 'digirisk' ), ! empty( $date_before_next_duer ) ? $date_before_next_duer : 'N/A' ); ?></p>
     29    </div>
    3030
    31     <h3><?php esc_html_e( 'Accident', 'digirisk' ); ?></h3>
     31    <h3><?php esc_html_e( 'Accident', 'digirisk' ); ?></h3>
    3232
    33     <div class="wpeo-gridlayout grid-3">
    34         <p>
    35             <span><?php esc_html_e( 'Date du dernier accident:', 'digirisk' ); ?></span>
     33    <div class="wpeo-gridlayout grid-3">
     34        <p>
     35            <span><?php esc_html_e( 'Date du dernier accident:', 'digirisk' ); ?></span>
    3636
    37             <span><strong><?php echo ( ! empty( $accident ) ) ? $accident->data['accident_date']['rendered']['date'] : __( 'N/A', 'digirisk' ); ?></strong></span>
    38         </p>
     37            <span><strong><?php echo ( ! empty( $accident ) ) ? $accident->data['accident_date']['rendered']['date'] : __( 'N/A', 'digirisk' ); ?></strong></span>
     38        </p>
    3939
    40         <p>
    41             <span><?php esc_html_e( 'Nombre de jour sans accident:', 'digirisk' ); ?></span>
     40        <p>
     41            <span><?php esc_html_e( 'Nombre de jour sans accident:', 'digirisk' ); ?></span>
    4242
    43             <span><strong><?php echo isset($days_without_accident) ? $days_without_accident : __( 'N/A', 'digirisk' ); ?></strong></span>
    44         </p>
    45         <p><?php printf( __( 'Unité de Travail concernée: <strong>%s</strong>', 'digirisk' ), ! empty( $accident ) ? $accident->data['place']->data['unique_identifier'] . ' - ' . $accident->data['place']->data['title'] : 'N/A' ); ?></p>
     43            <span><strong><?php echo isset($days_without_accident) ? $days_without_accident : __( 'N/A', 'digirisk' ); ?></strong></span>
     44        </p>
     45        <p><?php printf( __( 'Unité de Travail concernée: <strong>%s</strong>', 'digirisk' ), ! empty( $accident ) ? $accident->data['place']->data['unique_identifier'] . ' - ' . $accident->data['place']->data['title'] : 'N/A' ); ?></p>
     46    </div>
     47<?php endif; ?>
     48
     49<?php $id = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; ?>
     50
     51<?php if ( $id != 0  && ( ( $type == 'digi-group' ) || ( $type == 'digi-workunit' ) ) ) :
     52    $society = Society_Class::g()->show_by_type($id) ?>
     53
     54
     55    <?php if ( $type == 'digi-group' ) : ?>
     56        <h3><?php esc_html_e ('Description d\'un GP' , 'digirisk') ;?></h3>
     57    <?php endif; ?>
     58    <?php if ( $type == 'digi-workunit' ) : ?>
     59        <h3><?php esc_html_e ('Description d\'une UT' , 'digirisk') ;?></h3>
     60    <?php endif; ?>
     61    <div class="society-description">
     62        <textarea type="text" style="width: 90% !important;" value="<?php printf($society->data['content']);?>" name="societyDescription"><?php printf($society->data['content']);?></textarea>
     63        <input type="hidden" name="idSociety" value="<?php echo $society->data['id'] ;?>">
     64        <input type="hidden" name="action" value="save_society_description">
     65
     66        <div class="wpeo-button button-green button-square-50 action-input save active"
     67             data-parent="society-description">
     68            <i class="button-icon fas fa-save"></i>
     69        </div>
    4670    </div>
    4771<?php endif; ?>
    4872
    49 <h3><?php esc_html_e( 'Analyse par unité de travail ou GP', 'digirisk' ); ?></h3>
     73<h3><?php esc_html_e( 'Analyse par unité de travail ou GP', 'digirisk' ); ?> </h3>
    5074
    5175<div class="wpeo-gridlayout grid-3">
    52     <p>
    53         <span><?php esc_html_e( 'Date de l\'action:', 'digirisk' ); ?></span>
    54         <span><strong><?php echo ( ! empty( $historic_update ) && isset( $historic_update['date']['date'] ) ) ? $historic_update['date']['date'] : 'N/A'; ?></strong></span>
    55     </p>
    56     <p><?php printf( __( 'UT ou GP: <strong>%s</strong>', 'digirisk' ), ( ! empty( $historic_update['parent_id'] ) ) ? $historic_update['parent']->data['unique_identifier'] . ' - ' . $historic_update['parent']->data['title'] : 'N/A' ); ?></p>
    57     <p><?php printf( __( 'Description de l\'action: <strong>%s</strong>', 'digirisk' ), ! empty( $historic_update ) ? $historic_update['content'] : 'N/A' ); ?></p>
     76    <p>
     77        <span><?php esc_html_e( 'Date de l\'action:', 'digirisk' ); ?></span>
     78        <span><strong><?php echo ( ! empty( $historic_update ) && isset( $historic_update['date']['date'] ) ) ? $historic_update['date']['date'] : 'N/A'; ?></strong></span>
     79    </p>
     80    <p><?php printf( __( 'UT ou GP: <strong>%s</strong>', 'digirisk' ), ( ! empty( $historic_update['parent_id'] ) ) ? $historic_update['parent']->data['unique_identifier'] . ' - ' . $historic_update['parent']->data['title'] : 'N/A' ); ?></p>
     81    <p><?php printf( __( 'Description de l\'action: <strong>%s</strong>', 'digirisk' ), ! empty( $historic_update ) ? $historic_update['content'] : 'N/A' ); ?></p>
    5882</div>
    5983
     
    6185
    6286<div class="wpeo-gridlayout grid-3">
    63     <p>
    64         <span><?php _e( 'Nombre de personnes sur l\'établissement:', 'digirisk' ); ?></span>
    65         <span><strong><?php echo esc_html( $total_users ); ?></strong></span>
    66     </p>
    67     <p><?php printf( __( 'Nombre de personnes impliqués: <strong>%s évaluateur(s)</strong>', 'digirisk' ), $number_evaluator ); ?></p>
    68     <p><?php printf( __( 'Pourcentage: <strong>%s</strong>', 'digirisk' ), $average ); ?></p>
     87    <p>
     88        <span><?php _e( 'Nombre de personnes sur l\'établissement:', 'digirisk' ); ?></span>
     89        <span><strong><?php echo esc_html( $total_users ); ?></strong></span>
     90    </p>
     91    <p><?php printf( __( 'Nombre de personnes impliqués: <strong>%s évaluateur(s)</strong>', 'digirisk' ), $number_evaluator ); ?></p>
     92    <p><?php printf( __( 'Pourcentage: <strong>%s</strong>', 'digirisk' ), $average ); ?></p>
    6993</div>
    7094
  • digirisk/trunk/modules/society/action/class-society-action.php

    r2476365 r2481749  
    2424class Society_Action {
    2525
    26     /**
    27      * Constructeur.
    28      *
    29      * @since 6.0.0
    30      */
    31     public function __construct() {
    32         add_action( 'wp_ajax_save_society', array( $this, 'callback_save_society' ) );
    33         add_action( 'wp_ajax_delete_society', array( $this, 'callback_delete_society' ) );
    34         add_action( 'wp_ajax_search_establishment', array( $this, 'callback_search_establishment' ) );
    35         add_action( 'wp_ajax_display_edit_view', array( $this, 'callback_display_edit_view' ) );
    36     }
    37 
    38     /**
    39      * Sauvegardes les données d'une societé
    40      *
    41      * @since 6.0.0
    42      */
    43     public function callback_save_society() {
    44         check_ajax_referer( 'save_society' );
    45 
    46         $id    = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; // WPCS: input var ok.
    47         $title = ! empty( $_POST['title'] ) ? sanitize_text_field( wp_unslash( $_POST['title'] ) ) : ''; // WPCS: input var ok.
    48 
    49         if ( empty( $id ) ) {
    50             wp_send_json_error();
    51         }
    52 
    53         $society                = Society_Class::g()->show_by_type( $id );
    54         $society->data['title'] = $title;
    55 
    56         Society_Class::g()->update_by_type( $society );
    57 
    58         ob_start();
    59         DUER_Class::g()->display_page( $id, 'true' );
    60         wp_send_json_success( array(
    61             'namespace'        => 'digirisk',
    62             'module'           => 'society',
    63             'callback_success' => 'savedSocietySuccess',
    64             'society'          => $society,
    65             'template'         => ob_get_clean(),
    66         ) );
    67     }
    68 
    69     /**
    70      * Supprimes une société
    71      *
    72      * @since 6.0.0
    73      */
    74     public function callback_delete_society() {
    75         check_ajax_referer( 'delete_society' );
    76 
    77         $id = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; // WPCS: input var ok.
    78 
    79         Society_Class::g()->delete_child( $id );
    80 
    81         $society                 = Society_Class::g()->show_by_type( $id );
    82         $society->data['status'] = 'trash';
    83         Society_Class::g()->update_by_type( $society );
    84 
    85         ob_start();
    86         Digirisk::g()->display( $society->data['parent_id'] );
    87         wp_send_json_success( array(
    88             'template'         => ob_get_clean(),
    89             'namespace'        => 'digirisk',
    90             'module'           => 'society',
    91             'callback_success' => 'deletedSocietySuccess',
    92         ) );
    93     }
    94 
    95     /**
    96      * Recherches une société depuis $_GET['term'].
    97      *
    98      * @since 6.4.0
    99      */
    100     public function callback_search_establishment() {
    101         global $wpdb;
    102         $term = sanitize_text_field( $_GET['term'] );
    103 
    104         $posts_type = array(
    105             'digi-group',
    106             'digi-workunit',
    107         );
    108 
    109         $posts_founded = array();
    110         $ids_founded   = array();
    111 
    112         $results = $wpdb->query( $wpdb->prepare( 'SELECT ID FROM {$wpdb->posts} WHERE ID LIKE %s AND post_type IN(%s)', array(
    113             '%' . $term . '%',
    114             implode( $posts_type, ',' ),
    115         ) ) );
    116 
    117         if ( ! empty( $results ) ) {
    118             foreach ( $results as $post ) {
    119                 $ids_founded[] = $post->ID;
    120             }
    121         }
    122 
    123         $query = new \WP_Query( array(
    124             'post_type'   => $posts_type,
    125             's'           => $term,
    126             'post_status' => array( 'publish', 'draft' ),
    127         ) );
    128 
    129         if ( ! empty( $query->posts ) ) {
    130             foreach ( $query->posts as $post ) {
    131                 if ( ! in_array( $post->ID, $ids_founded, true ) ) {
    132                     $ids_founded[] = $post->ID;
    133                 }
    134             }
    135         }
    136 
    137         $results = $wpdb->query(
    138             $wpdb->prepare(
    139                 'SELECT PM.post_id FROM {$wpdb->postmeta} AS PM
     26    /**
     27     * Constructeur.
     28     *
     29     * @since 6.0.0
     30     */
     31    public function __construct() {
     32        add_action( 'wp_ajax_save_society', array( $this, 'callback_save_society' ) );
     33        add_action( 'wp_ajax_delete_society', array( $this, 'callback_delete_society' ) );
     34        add_action( 'wp_ajax_search_establishment', array( $this, 'callback_search_establishment' ) );
     35        add_action( 'wp_ajax_display_edit_view', array( $this, 'callback_display_edit_view' ) );
     36        add_action( 'wp_ajax_save_society_description', array( $this, 'callback_save_society_description' ) );
     37    }
     38
     39    /**
     40     * Sauvegardes les données d'une societé
     41     *
     42     * @since 6.0.0
     43     */
     44    public function callback_save_society() {
     45        check_ajax_referer( 'save_society' );
     46
     47        $id    = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; // WPCS: input var ok.
     48        $title = ! empty( $_POST['title'] ) ? sanitize_text_field( wp_unslash( $_POST['title'] ) ) : ''; // WPCS: input var ok.
     49
     50        if ( empty( $id ) ) {
     51            wp_send_json_error();
     52        }
     53
     54        $society                = Society_Class::g()->show_by_type( $id );
     55        $society->data['title'] = $title;
     56
     57        Society_Class::g()->update_by_type( $society );
     58
     59        ob_start();
     60        DUER_Class::g()->display_page( $id, 'true' );
     61        wp_send_json_success( array(
     62            'namespace'        => 'digirisk',
     63            'module'           => 'society',
     64            'callback_success' => 'savedSocietySuccess',
     65            'society'          => $society,
     66            'template'         => ob_get_clean(),
     67        ) );
     68    }
     69
     70    /**
     71     * Sauvegardes les données d'une societé
     72     *
     73     * @since 6.0.0
     74     */
     75    public function callback_save_society_description() {
     76//        check_ajax_referer( 'save_society_description' );
     77
     78        $id    = ! empty( $_POST['idSociety'] ) ? (int) $_POST['idSociety'] : 0; // WPCS: input var ok.
     79        $content = ! empty( $_POST['societyDescription'] ) ? sanitize_text_field( wp_unslash( $_POST['societyDescription'] ) ) : ''; // WPCS: input var ok.
     80
     81        if ( empty( $id ) ) {
     82            wp_send_json_error();
     83        }
     84
     85        $society                = Society_Class::g()->show_by_type( $id );
     86        $society->data['content'] = $content;
     87
     88        Society_Class::g()->update_by_type( $society );
     89
     90        ob_start();
     91        DUER_Class::g()->display_page( $id, 'true' );
     92        wp_send_json_success( array(
     93            'namespace'        => 'digirisk',
     94            'module'           => 'society',
     95            'callback_success' => 'savedSocietySuccess',
     96            'society'          => $society,
     97            'template'         => ob_get_clean(),
     98        ) );
     99    }
     100
     101    /**
     102     * Supprimes une société
     103     *
     104     * @since 6.0.0
     105     */
     106    public function callback_delete_society() {
     107        check_ajax_referer( 'delete_society' );
     108
     109        $id = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; // WPCS: input var ok.
     110
     111        Society_Class::g()->delete_child( $id );
     112
     113        $society                 = Society_Class::g()->show_by_type( $id );
     114        $society->data['status'] = 'trash';
     115        Society_Class::g()->update_by_type( $society );
     116
     117        ob_start();
     118        Digirisk::g()->display( $society->data['parent_id'] );
     119        wp_send_json_success( array(
     120            'template'         => ob_get_clean(),
     121            'namespace'        => 'digirisk',
     122            'module'           => 'society',
     123            'callback_success' => 'deletedSocietySuccess',
     124        ) );
     125    }
     126
     127    /**
     128     * Recherches une société depuis $_GET['term'].
     129     *
     130     * @since 6.4.0
     131     */
     132    public function callback_search_establishment() {
     133        global $wpdb;
     134        $term = sanitize_text_field( $_GET['term'] );
     135
     136        $posts_type = array(
     137            'digi-group',
     138            'digi-workunit',
     139        );
     140
     141        $posts_founded = array();
     142        $ids_founded   = array();
     143
     144        $results = $wpdb->query( $wpdb->prepare( 'SELECT ID FROM {$wpdb->posts} WHERE ID LIKE %s AND post_type IN(%s)', array(
     145            '%' . $term . '%',
     146            implode( $posts_type, ',' ),
     147        ) ) );
     148
     149        if ( ! empty( $results ) ) {
     150            foreach ( $results as $post ) {
     151                $ids_founded[] = $post->ID;
     152            }
     153        }
     154
     155        $query = new \WP_Query( array(
     156            'post_type'   => $posts_type,
     157            's'           => $term,
     158            'post_status' => array( 'publish', 'draft' ),
     159        ) );
     160
     161        if ( ! empty( $query->posts ) ) {
     162            foreach ( $query->posts as $post ) {
     163                if ( ! in_array( $post->ID, $ids_founded, true ) ) {
     164                    $ids_founded[] = $post->ID;
     165                }
     166            }
     167        }
     168
     169        $results = $wpdb->query(
     170            $wpdb->prepare(
     171                'SELECT PM.post_id FROM {$wpdb->postmeta} AS PM
    140172                    JOIN {$wpdb->posts} AS P ON P.ID=PM.post_id
    141173                WHERE PM.meta_key="_wpdigi_unique_identifier"
    142174                    AND PM.meta_value LIKE %s
    143175                    AND P.post_type IN(%s)', array( '%' . $term . '%', implode( $posts_type, ',' ) )
    144             )
    145         );
    146 
    147         if ( ! empty( $results ) ) {
    148             foreach ( $results as $post ) {
    149                 $ids_founded[] = $post->post_id;
    150             }
    151         }
    152 
    153         if ( ! empty( $ids_founded ) ) {
    154             foreach ( $ids_founded as $id_founded ) {
    155                 $s = Society_Class::g()->show_by_type( $id_founded );
    156 
    157                 if ( ! empty( $s ) ) {
    158                     $posts_founded[] = array(
    159                         'label' => $s->unique_identifier . ' ' . $s->title,
    160                         'value' => $s->unique_identifier . ' ' . $s->title,
    161                         'id'    => $s->id,
    162                     );
    163                 }
    164             }
    165         }
    166 
    167         if ( empty( $posts_founded ) ) {
    168             $posts_founded[] = array(
    169                 'label' => __( 'Aucun résultat', 'digirisk' ),
    170                 'value' => __( 'Aucun résultat', 'digirisk' ),
    171                 'id'    => 0,
    172             );
    173         }
    174 
    175         wp_die( wp_json_encode( $posts_founded ) );
    176     }
    177 
    178     public function callback_display_edit_view(){
    179         check_ajax_referer( 'display_edit_view' );
    180         $element          = isset( $_POST[ 'element' ] ) ? sanitize_text_field( $_POST[ 'element' ] ) : '';
    181         $society_id       = isset( $_POST[ 'society_id' ] ) ? (int) $_POST[ 'society_id' ] : 0;
    182         $legal_display_id = isset( $_POST[ 'legal_display_id' ] ) ? (int) $_POST[ 'legal_display_id' ] : 0;
    183 
    184         $society = Society_Class::g()->get_actual_society( $society_id );
    185 
    186         $legal_display = Legal_Display_Class::g()->get_legal_display( $society->data[ 'id' ] );
    187 
    188         Legal_Display_Class::g()->display_configuration_view( $society, $element );
    189     }
     176            )
     177        );
     178
     179        if ( ! empty( $results ) ) {
     180            foreach ( $results as $post ) {
     181                $ids_founded[] = $post->post_id;
     182            }
     183        }
     184
     185        if ( ! empty( $ids_founded ) ) {
     186            foreach ( $ids_founded as $id_founded ) {
     187                $s = Society_Class::g()->show_by_type( $id_founded );
     188
     189                if ( ! empty( $s ) ) {
     190                    $posts_founded[] = array(
     191                        'label' => $s->unique_identifier . ' ' . $s->title,
     192                        'value' => $s->unique_identifier . ' ' . $s->title,
     193                        'id'    => $s->id,
     194                    );
     195                }
     196            }
     197        }
     198
     199        if ( empty( $posts_founded ) ) {
     200            $posts_founded[] = array(
     201                'label' => __( 'Aucun résultat', 'digirisk' ),
     202                'value' => __( 'Aucun résultat', 'digirisk' ),
     203                'id'    => 0,
     204            );
     205        }
     206
     207        wp_die( wp_json_encode( $posts_founded ) );
     208    }
     209
     210    public function callback_display_edit_view(){
     211        check_ajax_referer( 'display_edit_view' );
     212        $element          = isset( $_POST[ 'element' ] ) ? sanitize_text_field( $_POST[ 'element' ] ) : '';
     213        $society_id       = isset( $_POST[ 'society_id' ] ) ? (int) $_POST[ 'society_id' ] : 0;
     214        $legal_display_id = isset( $_POST[ 'legal_display_id' ] ) ? (int) $_POST[ 'legal_display_id' ] : 0;
     215
     216        $society = Society_Class::g()->get_actual_society( $society_id );
     217
     218        $legal_display = Legal_Display_Class::g()->get_legal_display( $society->data[ 'id' ] );
     219
     220        Legal_Display_Class::g()->display_configuration_view( $society, $element );
     221    }
    190222
    191223}
  • digirisk/trunk/readme.txt

    r2481734 r2481749  
    44Donate link: http://www.evarisk.com/document-unique-logiciel
    55Requires at least: 4.4
    6 Tested up to: 5.6
    7 Stable tag: 7.6.5
     6Tested up to: 5.6.2
     7Stable tag: 7.6.6
    88License: AGPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7777
    7878* Veillez à bien sauvegarder vos données avant d'effectuer une mise à jour du plugin
     79
     80= Version 7.6.6 =
     81
     82- Add : Ajout d'un champ description pour un GP ou une UT.
    7983
    8084= Version 7.6.5 =
Note: See TracChangeset for help on using the changeset viewer.