Plugin Directory

Changeset 2568441


Ignore:
Timestamp:
07/20/2021 05:48:45 PM (5 years ago)
Author:
serviceonline
Message:

update before 1.0.2

Location:
service
Files:
80 added
7 edited

Legend:

Unmodified
Added
Removed
  • service/trunk/includes/api.php

    r2565526 r2568441  
    3939add_action('rest_api_init', function (){
    4040
     41    register_rest_route('service', 'statistics', array(
     42        'methods' => 'GET',
     43        'permission_callback' => function(){
     44            return current_user_can('service_user');
     45        },
     46        'callback' => function($request_data){
     47
     48            global $wpdb;
     49            foreach ($wpdb->get_results("SELECT sum(cost_total-cost_spare), DATE_FORMAT(`date_issue`, '%Y-%m') as period FROM $wpdb->service_orders WHERE `date_issue` >= DATE_FORMAT(CURRENT_DATE - INTERVAL 10 YEAR, '%Y-%m-01') GROUP BY period", ARRAY_A) as $row) {
     50                $month[] = [$row['period'], (int)$row['sum(cost_total-cost_spare)']];
     51            }
     52            foreach ($wpdb->get_results("SELECT DATE_FORMAT(date_issue, '%d') as date, sum(cost_total-cost_spare) FROM $wpdb->service_orders WHERE MONTH(`date_issue`) = MONTH(NOW()) AND YEAR(`date_issue`) = YEAR(NOW()) GROUP BY 1 ASC", ARRAY_A) as $row) {
     53                $day[] = [$row['date'], (int)$row['sum(cost_total-cost_spare)']];
     54            }
     55            $res = $wpdb->get_row("SELECT (SELECT sum(cost_total-cost_spare) FROM $wpdb->service_orders WHERE (MONTH(`date_issue`) = MONTH(NOW()) AND (YEAR(`date_issue`) = YEAR(NOW())) )  ) / (EXTRACT(DAY FROM CURDATE()))", ARRAY_N);
     56            wp_send_json( [ 'day' => $day, 'month' => $month, 'forecast' => round($res[0]) ] );
     57
     58        }
     59    ));
     60
    4161    register_rest_route('service', 'orders', array(
    4262        'methods' => 'GET',
     
    5373            global $wpdb;
    5474            $data = $wpdb->get_results( "SELECT id, id_label, date, model, serial, malfunction, client, number, work, cost_spare, cost_total, status, manager_notes FROM `$wpdb->service_orders` $where $order $limit", ARRAY_A );
    55             $resTotalLength = $wpdb->get_var("SELECT COUNT(`id`) FROM `$wpdb->service_orders`");
     75            $resTotalLength = $wpdb->get_var("SELECT COUNT(`id`) FROM `$wpdb->service_orders` $where");
    5676            wp_send_json([
    5777                "draw"            => intval( $parameters['draw'] ) ,
  • service/trunk/includes/function.php

    r2565526 r2568441  
    6767});
    6868
    69 
    7069//settings page
    7170add_action('wp_ajax_save_settings', function (){
  • service/trunk/pages/orders.php

    r2565526 r2568441  
    8888
    8989
    90 
    91 
    9290    <br>
    9391    <table id="table_repair" class="display" style="width:100%">
    94         <thead>
    95         <tr>
    96             <th>
    97             </th>
    98             <th>№</th>
    99             <th><?php _e('Date', 'service');?></th>
    100             <th><?php _e('Model', 'service');?></th>
    101             <th><?php _e('Malfunction', 'service');?></th>
    102             <th><?php _e('Client', 'service');?></th>
    103             <th><?php _e('Work', 'service');?></th>
    104             <th><?php _e('Cost spare', 'service');?></th>
    105             <th><?php _e('Total cost', 'service');?></th>
    106             <th><?php _e('Status', 'service');?></th>
    107             <th><?php _e('Notes', 'service');?></th>
    108         </tr>
    109         </thead>
    110 
    11192    </table>
    11293    <br>
    113 
    11494    <button id="delete" class="button" style="display:none;"><?php _e('Delete', 'service');?></button>
    11595    </div>
     
    275255                },
    276256
    277 
    278257                createdRow: function(row, data, index){
    279258
     
    292271                    },
    293272
    294                     {data: 'id_label'},
    295 
    296                     {data: 'date'},
    297 
    298                     {data: 'model',
     273                    {data: 'id_label', title: '№'},
     274
     275                    {data: 'date', title: '<?php _e('Date', 'service');?>'},
     276
     277                    {data: 'model', title: '<?php _e('Model', 'service');?>',
    299278                        render : function (data, type, row) {
    300279                            return '<b>' + data + '</b><br><span class="serial">' + row.serial + '</span>'
     
    302281                    },
    303282
    304                     {data: 'malfunction'},
    305 
    306                     {data: 'client',
     283                    {data: 'malfunction', title: '<?php _e('Malfunction', 'service');?>'},
     284
     285                    {data: 'client', title: '<?php _e('Client', 'service');?>',
    307286                        render : function (data, type, row) {
    308287                            return '<b>' + data + '</b><br><span class="number">' + row.number + '</span>'
     
    310289                    },
    311290
    312                     {data: 'work',
     291                    {data: 'work', title: '<?php _e('Work', 'service');?>',
    313292                        render : function (data, type, row) {
    314293                            return '<input type="text" class="work" value = "'+data+'" >'
     
    316295                    },
    317296
    318                     {data: 'cost_spare',
     297                    {data: 'cost_spare', title: '<?php _e('Cost spare', 'service');?>',
    319298                        render : function (data) {
    320299                            return '<input type="text" class="cost_spare" value = "'+data+'" size=5>'
     
    322301                    },
    323302
    324                     {data: 'cost_total',
     303                    {data: 'cost_total', title: '<?php _e('Total cost', 'service');?>',
    325304                        render : function (data) {
    326305                            return '<input type="text" class="cost_total" value = "'+data+'" size=5>'
     
    328307                    },
    329308
    330                     {data: 'status',
     309                    {data: 'status', title: '<?php _e('Status', 'service');?>',
    331310                        render : function (data, type, row) {
    332311                            let select = '<select id="'+row.id+'"><option>'+orderStatus[data]+'</option>';
     
    340319                    },
    341320
    342                     {data: 'manager_notes',
     321                    {data: 'manager_notes', title: '<?php _e('Notes', 'service');?>',
    343322                        render : function (data, type, row) {
    344323                            return '<input type="text" class="manager_notes" value = "'+data+'" >'
  • service/trunk/readme.txt

    r2565526 r2568441  
    33Tags: crm, service
    44Requires at least: 4.7
    5 Tested up to: 5.7.2
    6 Stable tag: 1.0.1
     5Tested up to: 5.8
     6Stable tag: 1.0.2
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    1313
    1414== Changelog ==
     15
     16= 1.0.2 =
     17*Release Date - 20 Jul 2021*
     18
     19* Added statistics function
    1520
    1621= 1.0.1 =
  • service/trunk/service.php

    r2565526 r2568441  
    55 * Plugin URI:        https://wordpress.org/plugins/service/
    66 * Description:       The CRM for service center
    7  * Version:           1.0.1
     7 * Version:           1.0.2
    88 * Requires at least: 5.7.2
    99 * Requires PHP:      7.4
     
    4545        esc_html__('Orders', 'service'),
    4646        'service_user',
    47         'orders',
     47        'service-orders',
    4848        function() {include 'pages/orders.php';});
    4949    remove_submenu_page('service.php','service.php');
     
    6363        esc_html__('Settings', 'service'),
    6464        esc_html__('Settings', 'service'),
    65         'manage_options',
    66         'settings',
     65        'service_user',
     66        'service-settings',
    6767        function() {include 'pages/settings.php';});
    6868    add_action( 'load-' . $page, function (){
     
    7070    } );
    7171});
     72
     73add_action('admin_menu', function (){
     74    $page = add_submenu_page('service.php',
     75        esc_html__('Statistics', 'service'),
     76        esc_html__('Statistics', 'service'),
     77        'service_user',
     78        'service-statistics',
     79        function() {include 'pages/statistics.php';});
     80    add_action( 'load-' . $page, function (){
     81        wp_enqueue_script( 'google_charts', plugins_url('/js/google.charts.js', __FILE__) );
     82    } );
     83});
     84
     85
     86
    7287
    7388register_activation_hook(__FILE__, function () {
  • service/trunk/uninstall.php

    r2565526 r2568441  
    11<?php
    22
    3 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
    4     die();
     3if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) die();
    54
    65global $wpdb;
     
    98delete_option('service_print_receipt');
    109delete_option('service_print_warranty');
     10delete_option('service_sms_api_key');
    1111delete_option( 'service_imei_api_key');
     12delete_option( 'service_imei_api_key_status');
Note: See TracChangeset for help on using the changeset viewer.