Plugin Directory

Changeset 3331282


Ignore:
Timestamp:
07/21/2025 09:15:07 AM (7 months ago)
Author:
prosolution
Message:

Changelog

1.9.8

  • UPDATE:
    • fix bug in sync module, now we are able to sync more that 500 jobs
Location:
prosolution-wp-client/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • prosolution-wp-client/trunk/README.txt

    r3186315 r3331282  
    66Tested up to: 6.5
    77Requires PHP: 7.0
    8 Stable tag: 1.9.7
     8Stable tag: 1.9.8
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    646416. Backend Setting - Tools
    6565
     66== Changelog ==
     67= 1.9.8 =
     68* UPDATE:
     69  - fix bug in sync module, now we are able to sync more that 500 jobs
    6670
    6771== Changelog ==
  • prosolution-wp-client/trunk/admin/class-prosolwpclient-admin.php

    r3186315 r3331282  
    304304            $table_name = isset( $_POST['table'] ) ? filter_var( $_POST['table'], FILTER_SANITIZE_STRING ) : '';
    305305            $synctype = isset($_POST['synctype']) ? filter_var( $_POST['synctype'], FILTER_SANITIZE_STRING ) : ''; 
     306            $batch = isset( $_POST['batch'] ) ? filter_var( $_POST['batch'], FILTER_SANITIZE_STRING ) : 0;
    306307
    307308            $issite = CBXProSolWpClient_Helper::proSol_getSitecookie();
     
    314315            if ( $sync_enabled ) {
    315316
    316                 $response_data = CBXProSolWpClient_TableHelper::proSol_apiActivity( $table_name, $synctype );
    317                  
     317                $response_data = CBXProSolWpClient_TableHelper::proSol_apiActivity( $table_name, $synctype, $batch);
     318                if($table_name == "jobs"){
     319                    $jobrecordcount = CBXProSolWpClient_TableHelper::proSol_apiActivity( $table_name, $synctype, $batch, 'count');
     320                }
    318321                if ( is_object( $response_data ) ) {
    319322                    CBXProSolWpClient_TableHelper::proSol_allTablesInsertion( $table_name, $response_data);
     
    321324                    $output['message']  = esc_html__( 'Existing data truncated and new data synced successfully.', 'prosolwpclient' );
    322325                    $output['synctime'] = current_time( 'mysql' );
     326                    if($table_name == "jobs"){
     327                        $output['jobrecordcount'] = $jobrecordcount;
     328                    }
    323329                } else {
    324330                    $output['error']   = 1;
  • prosolution-wp-client/trunk/admin/js/prosolwpclient-admin.js

    r2714610 r3331282  
    2828            document.cookie = "selsite="+selectval;
    2929        });
     30
     31        function ajaxSyncCall(thisel, tablename_arg, syntype_arg, batch_arg){
     32            var sync_time_id = $('#synctime-' + tablename_arg);
     33            var btnelement = $('[data-tablename="' + tablename_arg + '"]');
     34            return $.ajax({
     35                type: "post",
     36                dataType: "json",
     37                url: prosolwpclient.ajaxurl,
     38                data: {
     39                    action: "proSol_ajaxTablesync",
     40                    table: tablename_arg,
     41                    batch : batch_arg,
     42                    security: prosolwpclient.nonce,
     43                    synctype: syntype_arg
     44                },
     45                success: function (data, textStatus, XMLHttpRequest) {
     46                    thisel.attr("disabled", false); 
     47                    if (parseInt(data.error) == 1) {
     48                        alert(data.message);
     49                        sync_time_id.removeClass('synctime-common-busy');
     50                        sync_time_id.html(prosolwpclient.sync_failed);
     51                    }
     52                    else {
     53                        if(tablename_arg != "jobs" || (tablename_arg == "jobs" && data.jobrecordcount != 501)){
     54                           
     55                            $(".syncjobsch").removeAttr("disabled");
     56                            sync_time_id.removeClass('synctime-common-busy');
     57                            sync_time_id.html(data.synctime);
     58                        }
     59                    }
     60                }
     61            });
     62        }
     63
     64        $('#prosolsyncall').on('click', async function (e) {
     65            e.preventDefault();
     66
     67            const prosoltables = $(".prosolsingletable");
     68            for(var idxtab of prosoltables){
     69
     70                var $this = $(idxtab);
     71                var tablename = $this.data('tablename');
     72                var syntype = $this.data('synctype');
     73
     74                $this.attr("disabled", true);
     75                var sync_time_id = $('#synctime-' + tablename);
     76                sync_time_id.html('');
     77                sync_time_id.addClass('synctime-common-busy');
     78
     79                if(tablename == "jobs"){
     80                    var startrow = 0;
     81                    var totaljobrecord = 0;
     82                    var flagstart = 1;
     83                    while(flagstart == 1 || (totaljobrecord == 501)){
     84                        var res = await ajaxSyncCall($this, tablename, syntype, startrow);
     85                        var totaljobrecord = res.jobrecordcount;
     86                        var startrow = startrow + 501;
     87                        var flagstart = 0;
     88                    }
     89                }else{
     90                    var res = await ajaxSyncCall($this, tablename, syntype, 0);
     91                }
     92            }
     93            window.location.reload();
     94        });
    3095       
    3196        //click on sync button if api key exists and send ajax request for sync
    32         $('.prosolsyncsingle').on('click', function (e) {
     97        $('.prosolsyncsingle').on('click', async function (e) {
    3398            e.preventDefault();
    3499
     
    40105            $this.attr("disabled", true);
    41106            var sync_time_id = $('#synctime-' + tablename);
    42             //var sync_time_val_backup = sync_time_id.text();
     107            var sync_time_val_backup = sync_time_id.text();
    43108            sync_time_id.html('');
    44109            sync_time_id.addClass('synctime-common-busy');
    45110
    46             $.ajax({
    47                 type: "post",
    48                 dataType: "json",
    49                 url: prosolwpclient.ajaxurl,
    50                 data: {
    51                     action: "proSol_ajaxTablesync",
    52                     table: tablename,
    53                     security: prosolwpclient.nonce,
    54                     synctype: syntype
    55                 },
    56                 success: function (data, textStatus, XMLHttpRequest) {
    57                     $this.attr("disabled", false); 
    58                     if (parseInt(data.error) == 1) {
    59                         alert(data.message);
    60                         sync_time_id.removeClass('synctime-common-busy');
    61                         sync_time_id.html(prosolwpclient.sync_failed);
    62                     }
    63                     else {
    64                         $(".syncjobsch").removeAttr("disabled");
    65                         sync_time_id.removeClass('synctime-common-busy');
    66                         sync_time_id.html(data.synctime);
    67                         window.location.reload();
    68                         if (redirect == 1) {
    69                             window.location = $this.attr('href');
    70                         }
    71                     }
     111            if(tablename == "jobs"){
     112                var startrow = 0;
     113                var totaljobrecord = 0;
     114                var flagstart = 1;
     115                while(flagstart == 1 || (totaljobrecord == 501)){
     116                    var res = await ajaxSyncCall($this, tablename, syntype, startrow);
     117                    var totaljobrecord = res.jobrecordcount;
     118                    var startrow = startrow + 501;
     119                    var flagstart = 0;
    72120                }
    73             });
     121            }else{
     122                var res = await ajaxSyncCall($this, tablename, syntype, 0);
     123            }
     124           
     125            window.location.reload();
     126            if (redirect == 1) {
     127                window.location = $this.attr('href');
     128            }
    74129        });
    75130
  • prosolution-wp-client/trunk/admin/templates/admin-overview.php

    r3012337 r3331282  
    7878                                            //' . add_query_arg($sync_url_params, $overview_page_url) . '
    7979                                            $sync_js_class = ($show_sync) ? 'prosolsyncsingle' : 'prosolsyncsingle_d';
    80                                             $sync_html = '<a href="' . admin_url('admin.php?page=prosolutionoverview&table_view=1&table=' . $table_key) . '" data-redirect="0" class="button ' . $sync_js_class . '" data-tablename="' . $table_key . '" data-synctype="all">'
     80                                            $sync_html = '<a href="' . admin_url('admin.php?page=prosolutionoverview&table_view=1&table=' . $table_key) . '" data-redirect="0" class="button prosolsingletable ' . $sync_js_class . '" data-tablename="' . $table_key . '" data-synctype="all">'
    8181                                                         . esc_attr__('Sync', 'prosolwpclient') . '</a>';
    8282                                            // project 1440             
     
    9696                                                    $sync_time=CBXProSolWpClient_Helper::proSol_dateReadableFormat($qjobstamp[0]['add_date']);
    9797                                                }
    98                                                 $sync_html = '<a href="' . admin_url('admin.php?page=prosolutionoverview&table_view=1&table=' . $table_key) . '" data-redirect="0" class="button ' . $sync_js_class . '" data-tablename="' . $table_key . '" data-synctype="all">'
     98                                                $sync_html = '<a href="' . admin_url('admin.php?page=prosolutionoverview&table_view=1&table=' . $table_key) . '" data-redirect="0" class="button prosolsingletable ' . $sync_js_class . '" data-tablename="' . $table_key . '" data-synctype="all">'
    9999                                                         . esc_attr__('SynchAll', 'prosolwpclient') . '</a>';
    100100                                                $sync_html .= '<a href="' . admin_url('admin.php?page=prosolutionoverview&table_view=1&table=' . $table_key) . '" data-redirect="0" class="button  ' . $sync_js_class . ' syncjobsch" data-tablename="' . $table_key . '" data-synctype="changes"' . $disabled . ' >'
  • prosolution-wp-client/trunk/includes/class-prosolwpclient-table-helper.php

    r3182060 r3331282  
    7474         * @return mixed
    7575         */
    76         public static function proSol_apiActivity( $table_name = '', $synctype = 'all' ) {
     76        public static function proSol_apiActivity( $table_name = '', $synctype = 'all', $batch_start = 0, $returntype = 'data' ) {
    7777            $frontend_settingPage = get_option( 'prosolwpclient_frontend' );
    7878            $response_data = new stdClass();
     
    132132                    $api_body  = array( "param" => json_encode( $safe_data ));
    133133
    134                     $response    = wp_remote_post( $api_config['api_url'] .''. $api_location .'joblist?limitrows=500', array(
     134                    $response    = wp_remote_post( $api_config['api_url'] .''. $api_location .'joblist?limitrows=500&startrow='. $batch_start, array(
    135135                        'headers'        => $header_info,
    136136                        'body'           => $api_body
    137                     ) ); 
     137                    ) );
    138138                } else if($table_name != '' && $table_name != 'jobs'){ // default table beside jobs
    139139                    $response = wp_remote_get( $api_config['api_url'] . 'system/list/' . $table_name, array( 'headers' => $header_info ) );
     
    145145                    // project 1440, insert /jobdetail into table Jobs in here
    146146                    if($table_name == 'jobs'){
    147                         $response_stamp = json_decode( $response['body'] )->JOBUNTIL;
    148                         $jobid_arr = $response_data->jobid;
    149                        
    150                         // clearing table jobs move here
    151                         global $wpdb;global $prosol_prefix;
    152                         $ps_table_jobs = $prosol_prefix . 'jobs';
    153                         $jobid_list = implode(",", $jobid_arr);
    154                        
    155                         if($synctype == 'all'){
    156                             $wpdb->query( "DELETE FROM $ps_table_jobs WHERE site_id= $siteidfordb " );
    157                         }else{                         
    158                             $wpdb->query( "DELETE FROM $ps_table_jobs WHERE site_id= $siteidfordb AND jobid in ($jobid_list) " );   
    159                         }
    160                         //var_dump($response);
    161                         $chkerror=0;
    162                         $img_dir_path = dirname(plugin_dir_path(__FILE__)) . '/jobimages'.'/';
    163                         if(is_dir($img_dir_path) === true){
    164                             $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($img_dir_path), RecursiveIteratorIterator::CHILD_FIRST);
    165                             foreach ($files as $file){
    166                                 if (in_array($file->getBasename(), array('.', '..')) !== true){
    167                                     if ($file->isDir() === true){
    168                                         rmdir($file->getPathName());
    169                                     } else if (($file->isFile() === true) || ($file->isLink() === true)){
    170                                         unlink($file->getPathname());
     147                        if($returntype == 'count'){
     148                            $response_data = json_decode( $response['body'] )->recordcount;
     149                        }else{
     150                            $response_stamp = json_decode( $response['body'] )->JOBUNTIL;
     151                            // $jobid_arr = $jobidlist_arr;
     152                            $jobid_arr = $response_data->jobid;
     153                           
     154                            // clearing table jobs move here
     155                            global $wpdb;global $prosol_prefix;
     156                            $ps_table_jobs = $prosol_prefix . 'jobs';
     157                            $jobid_list = implode(",", $jobid_arr);
     158                           
     159                            if($batch_start == 0){
     160                                if($synctype == 'all'){
     161                                    $wpdb->query( "DELETE FROM $ps_table_jobs WHERE site_id= $siteidfordb " );
     162                                }else{                         
     163                                    $wpdb->query( "DELETE FROM $ps_table_jobs WHERE site_id= $siteidfordb AND jobid in ($jobid_list) " );   
     164                                }
     165                            }
     166                           
     167                            //var_dump($response);
     168                            $chkerror=0;
     169                            $img_dir_path = dirname(plugin_dir_path(__FILE__)) . '/jobimages'.'/';
     170                            if(is_dir($img_dir_path) === true){
     171                                $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($img_dir_path), RecursiveIteratorIterator::CHILD_FIRST);
     172                                foreach ($files as $file){
     173                                    if (in_array($file->getBasename(), array('.', '..')) !== true){
     174                                        if ($file->isDir() === true){
     175                                            rmdir($file->getPathName());
     176                                        } else if (($file->isFile() === true) || ($file->isLink() === true)){
     177                                            unlink($file->getPathname());
     178                                        }
    171179                                    }
    172180                                }
     181                                rmdir($img_dir_path);
    173182                            }
    174                             rmdir($img_dir_path);
    175                         }
    176                         foreach ( $jobid_arr as $index => $jobid ) {
    177                             $response = wp_remote_get( $api_config['api_url'] . $api_location . 'jobdetail/' . $jobid, array( 'headers' => $header_info, 'timeout' => 300 ) );
     183                            foreach ( $jobid_arr as $index => $jobid ) {
     184                                $response = wp_remote_get( $api_config['api_url'] . $api_location . 'jobdetail/' . $jobid, array( 'headers' => $header_info, 'timeout' => 300 ) );
     185                               
     186                                if ( ! is_wp_error( $response ) ) {
     187                                    $response_data = json_decode( $response['body'] )->data;
     188                                    // for table jobs call proSol_allTablesInsertion here, not like other table, different flow
     189                                    self::proSol_allTablesInsertion('jobs', $response_data, $synctype, $siteidfordb, $response_stamp );
     190                                } else {
     191                                    $response_data = sprintf( __( 'Api response failed. Message: %s', 'prosolwpclient' ), $response->get_error_message() );
     192                                    $chkerror=1;
     193                                    break;
     194                                }
     195                            }
    178196                           
    179                             if ( ! is_wp_error( $response ) ) {
    180                                 $response_data = json_decode( $response['body'] )->data;
    181                                 // for table jobs call proSol_allTablesInsertion here, not like other table, different flow
    182                                 self::proSol_allTablesInsertion('jobs', $response_data, $synctype, $siteidfordb, $response_stamp );
    183                             } else {
    184                                 $response_data = sprintf( __( 'Api response failed. Message: %s', 'prosolwpclient' ), $response->get_error_message() );
    185                                 $chkerror=1;
    186                                 break;
    187                             }
     197                            if($chkerror != 1){
     198                                if(!is_null($response_data)){ 
     199                                    self::proSol_jobstampInsertion($siteidfordb,$response_stamp);
     200                                    // add wp scheduler 
     201                                    self::prosol_dailytask($siteidfordb);
     202                                   
     203                                }
     204                            }
    188205                        }
    189206                       
    190                         if($chkerror != 1){
    191                             if(!is_null($response_data)){ 
    192                                 self::proSol_jobstampInsertion($siteidfordb,$response_stamp);
    193                                 // add wp scheduler 
    194                                 self::prosol_dailytask($siteidfordb);
    195                                
    196                             }
    197                         }
    198207                    }
    199208
     
    268277
    269278                if($is_api_setup){
    270                     $response    = wp_remote_post( $api_config['api_url'] .''. $api_location .'joblist?limitrows=500', array(
    271                         'headers'        => $header_info,
    272                         'body'           => $api_body
    273                     ) );
     279                    $startrow = 0;
     280                    $totaljobrecord = 0;
     281                    $flagstart = 1;
     282                    $jobidlist_arr = [];
     283                    while($flagstart == 1 || ($totaljobrecord == 500+1)){
     284                        $response    = wp_remote_post( $api_config['api_url'] .''. $api_location .'joblist?limitrows=500&startrow='. $startrow, array(
     285                            'headers'        => $header_info,
     286                            'body'           => $api_body
     287                        ) );
     288                        $response_data = json_decode( $response['body'] )->data;
     289                        $jobid_arr = $response_data->jobid;
     290                        $totaljobrecord = json_decode( $response['body'] )->recordcount;
     291                        $jobidlist_arr = array_merge($jobidlist_arr, $jobid_arr);
     292                        $startrow += 501;
     293                        $flagstart = 0;
     294                    }
     295                   
    274296                   
    275297                    if ( ! is_wp_error( $response ) ) {
    276298                        $response_data = json_decode( $response['body'] )->data;
    277299                        $response_stamp = json_decode( $response['body'] )->JOBUNTIL;
    278                         $jobid_arr = $response_data->jobid;
     300                        $jobid_arr = $jobidlist_arr;
    279301                       
    280302                        // clearing table jobs move here
  • prosolution-wp-client/trunk/prosolwpclient.php

    r3186315 r3331282  
    1717     * Plugin URI:        https://prosolution.com/produkte-und-services/workexpert.html
    1818     * Description:       WordPress client for ProSolution
    19      * Version:           1.9.7
     19     * Version:           1.9.8
    2020     * Author:            ProSolution
    2121     * Author URI:        https://www.prosolution.com
     
    4242
    4343    defined('PROSOLWPCLIENT_PLUGIN_NAME') or define('PROSOLWPCLIENT_PLUGIN_NAME', 'prosolwpclient');
    44     defined('PROSOLWPCLIENT_PLUGIN_VERSION') or define('PROSOLWPCLIENT_PLUGIN_VERSION', '1.9.7');
     44    defined('PROSOLWPCLIENT_PLUGIN_VERSION') or define('PROSOLWPCLIENT_PLUGIN_VERSION', '1.9.8');
    4545    defined('PROSOLWPCLIENT_BASE_NAME') or define('PROSOLWPCLIENT_BASE_NAME', plugin_basename(__FILE__));
    4646    defined('PROSOLWPCLIENT_ROOT_PATH') or define('PROSOLWPCLIENT_ROOT_PATH', plugin_dir_path(__FILE__));
  • prosolution-wp-client/trunk/public/class-prosolwpclient-public.php

    r3182060 r3331282  
    9696            if(version_compare($curr_version, $enc_version, '>')){
    9797                $vector_dir = __DIR__ . '/../vector.txt';
    98                 if(file_exists($vector_dir)){error_log('a');
     98                if(file_exists($vector_dir)){
    9999                   
    100100
  • prosolution-wp-client/trunk/public/prosolwpclient.php

    r3059488 r3331282  
    214214        $all_table_arr=array_keys(CBXProSolWpClient_Helper::proSol_allTablesArr());
    215215        foreach($all_table_arr as $tablename ){
     216           
    216217            $prosol_table = $wpdb->prefix.$tablename;
    217218            $oldprkey=$tablename.'id';
Note: See TracChangeset for help on using the changeset viewer.