Changeset 3331282
- Timestamp:
- 07/21/2025 09:15:07 AM (7 months ago)
- Location:
- prosolution-wp-client/trunk
- Files:
-
- 8 edited
-
README.txt (modified) (2 diffs)
-
admin/class-prosolwpclient-admin.php (modified) (3 diffs)
-
admin/js/prosolwpclient-admin.js (modified) (2 diffs)
-
admin/templates/admin-overview.php (modified) (2 diffs)
-
includes/class-prosolwpclient-table-helper.php (modified) (4 diffs)
-
prosolwpclient.php (modified) (2 diffs)
-
public/class-prosolwpclient-public.php (modified) (1 diff)
-
public/prosolwpclient.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
prosolution-wp-client/trunk/README.txt
r3186315 r3331282 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.0 8 Stable tag: 1.9. 78 Stable tag: 1.9.8 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 64 64 16. Backend Setting - Tools 65 65 66 == Changelog == 67 = 1.9.8 = 68 * UPDATE: 69 - fix bug in sync module, now we are able to sync more that 500 jobs 66 70 67 71 == Changelog == -
prosolution-wp-client/trunk/admin/class-prosolwpclient-admin.php
r3186315 r3331282 304 304 $table_name = isset( $_POST['table'] ) ? filter_var( $_POST['table'], FILTER_SANITIZE_STRING ) : ''; 305 305 $synctype = isset($_POST['synctype']) ? filter_var( $_POST['synctype'], FILTER_SANITIZE_STRING ) : ''; 306 $batch = isset( $_POST['batch'] ) ? filter_var( $_POST['batch'], FILTER_SANITIZE_STRING ) : 0; 306 307 307 308 $issite = CBXProSolWpClient_Helper::proSol_getSitecookie(); … … 314 315 if ( $sync_enabled ) { 315 316 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 } 318 321 if ( is_object( $response_data ) ) { 319 322 CBXProSolWpClient_TableHelper::proSol_allTablesInsertion( $table_name, $response_data); … … 321 324 $output['message'] = esc_html__( 'Existing data truncated and new data synced successfully.', 'prosolwpclient' ); 322 325 $output['synctime'] = current_time( 'mysql' ); 326 if($table_name == "jobs"){ 327 $output['jobrecordcount'] = $jobrecordcount; 328 } 323 329 } else { 324 330 $output['error'] = 1; -
prosolution-wp-client/trunk/admin/js/prosolwpclient-admin.js
r2714610 r3331282 28 28 document.cookie = "selsite="+selectval; 29 29 }); 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 }); 30 95 31 96 //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) { 33 98 e.preventDefault(); 34 99 … … 40 105 $this.attr("disabled", true); 41 106 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(); 43 108 sync_time_id.html(''); 44 109 sync_time_id.addClass('synctime-common-busy'); 45 110 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; 72 120 } 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 } 74 129 }); 75 130 -
prosolution-wp-client/trunk/admin/templates/admin-overview.php
r3012337 r3331282 78 78 //' . add_query_arg($sync_url_params, $overview_page_url) . ' 79 79 $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">' 81 81 . esc_attr__('Sync', 'prosolwpclient') . '</a>'; 82 82 // project 1440 … … 96 96 $sync_time=CBXProSolWpClient_Helper::proSol_dateReadableFormat($qjobstamp[0]['add_date']); 97 97 } 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">' 99 99 . esc_attr__('SynchAll', 'prosolwpclient') . '</a>'; 100 100 $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 74 74 * @return mixed 75 75 */ 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' ) { 77 77 $frontend_settingPage = get_option( 'prosolwpclient_frontend' ); 78 78 $response_data = new stdClass(); … … 132 132 $api_body = array( "param" => json_encode( $safe_data )); 133 133 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( 135 135 'headers' => $header_info, 136 136 'body' => $api_body 137 ) ); 137 ) ); 138 138 } else if($table_name != '' && $table_name != 'jobs'){ // default table beside jobs 139 139 $response = wp_remote_get( $api_config['api_url'] . 'system/list/' . $table_name, array( 'headers' => $header_info ) ); … … 145 145 // project 1440, insert /jobdetail into table Jobs in here 146 146 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 } 171 179 } 172 180 } 181 rmdir($img_dir_path); 173 182 } 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 } 178 196 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 } 188 205 } 189 206 190 if($chkerror != 1){191 if(!is_null($response_data)){192 self::proSol_jobstampInsertion($siteidfordb,$response_stamp);193 // add wp scheduler194 self::prosol_dailytask($siteidfordb);195 196 }197 }198 207 } 199 208 … … 268 277 269 278 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 274 296 275 297 if ( ! is_wp_error( $response ) ) { 276 298 $response_data = json_decode( $response['body'] )->data; 277 299 $response_stamp = json_decode( $response['body'] )->JOBUNTIL; 278 $jobid_arr = $ response_data->jobid;300 $jobid_arr = $jobidlist_arr; 279 301 280 302 // clearing table jobs move here -
prosolution-wp-client/trunk/prosolwpclient.php
r3186315 r3331282 17 17 * Plugin URI: https://prosolution.com/produkte-und-services/workexpert.html 18 18 * Description: WordPress client for ProSolution 19 * Version: 1.9. 719 * Version: 1.9.8 20 20 * Author: ProSolution 21 21 * Author URI: https://www.prosolution.com … … 42 42 43 43 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'); 45 45 defined('PROSOLWPCLIENT_BASE_NAME') or define('PROSOLWPCLIENT_BASE_NAME', plugin_basename(__FILE__)); 46 46 defined('PROSOLWPCLIENT_ROOT_PATH') or define('PROSOLWPCLIENT_ROOT_PATH', plugin_dir_path(__FILE__)); -
prosolution-wp-client/trunk/public/class-prosolwpclient-public.php
r3182060 r3331282 96 96 if(version_compare($curr_version, $enc_version, '>')){ 97 97 $vector_dir = __DIR__ . '/../vector.txt'; 98 if(file_exists($vector_dir)){ error_log('a');98 if(file_exists($vector_dir)){ 99 99 100 100 -
prosolution-wp-client/trunk/public/prosolwpclient.php
r3059488 r3331282 214 214 $all_table_arr=array_keys(CBXProSolWpClient_Helper::proSol_allTablesArr()); 215 215 foreach($all_table_arr as $tablename ){ 216 216 217 $prosol_table = $wpdb->prefix.$tablename; 217 218 $oldprkey=$tablename.'id';
Note: See TracChangeset
for help on using the changeset viewer.