Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: advanced tab with Number tools extension code integrated #613

Merged
merged 47 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
51e597d
New: advanced tab with Number tools integrated
alexmigf Sep 19, 2023
d432215
Generate minified JS and CSS files
alexmigf Sep 19, 2023
9cd5f14
Update advanced-status.php
alexmigf Sep 20, 2023
34f6193
Update advanced-status.php
alexmigf Sep 20, 2023
70197f2
Update class-wcpdf-settings-debug.php
alexmigf Sep 20, 2023
2ea7c9e
Update class-wcpdf-settings-debug.php
alexmigf Sep 20, 2023
5cd4240
Tweaks
alexmigf Sep 20, 2023
93386d7
Generate minified JS and CSS files
alexmigf Sep 20, 2023
45b148b
Implements numbers list table
alexmigf Sep 22, 2023
7e0ccae
Generate minified JS and CSS files
alexmigf Sep 22, 2023
3201cd8
Tweaks
alexmigf Sep 22, 2023
2bc13c0
Generate minified JS and CSS files
alexmigf Sep 22, 2023
1d68355
Update class-wcpdf-settings-debug.php
alexmigf Sep 22, 2023
cf00ec6
Merge branch '606-improve-debug-tab-include-number-tools' of github.c…
alexmigf Sep 22, 2023
3eca441
Update class-wcpdf-settings-debug.php
alexmigf Sep 22, 2023
118db9a
Update class-wcpdf-settings-debug.php
alexmigf Sep 22, 2023
f02aeab
Update class-wcpdf-settings-debug.php
alexmigf Sep 22, 2023
5873f40
WPCS
alexmigf Sep 22, 2023
8ed67d0
Implements danger zone tools
alexmigf Sep 22, 2023
b66127b
Generate minified JS and CSS files
alexmigf Sep 22, 2023
f72ea12
Update woocommerce-pdf-invoices-packingslips.php
alexmigf Sep 22, 2023
eb5e15b
Merge branch 'main' into 606-improve-debug-tab-include-number-tools
alexmigf Sep 22, 2023
9a1c403
Update woocommerce-pdf-invoices-packingslips.php
alexmigf Sep 22, 2023
c51ceed
Update woocommerce-pdf-invoices-packingslips.php
alexmigf Sep 22, 2023
08a1648
Update woocommerce-pdf-invoices-packingslips.php
alexmigf Sep 22, 2023
0afddcf
Update class-wcpdf-install.php
alexmigf Sep 22, 2023
a6bcebf
Update woocommerce-pdf-invoices-packingslips.php
alexmigf Sep 22, 2023
615cd7b
Update woocommerce-pdf-invoices-packingslips.php
alexmigf Sep 22, 2023
36cd2ba
Improvements
alexmigf Sep 22, 2023
f13fb3f
Update class-wcpdf-number-store-list-table.php
alexmigf Sep 22, 2023
e9464c7
Update class-wcpdf-number-store-list-table.php
alexmigf Sep 22, 2023
342c55d
Update class-wcpdf-settings-debug.php
alexmigf Sep 22, 2023
3f0ad8d
Update class-wcpdf-settings-debug.php
alexmigf Sep 22, 2023
a3437de
Update class-wcpdf-number-store-list-table.php
alexmigf Sep 22, 2023
cd2abdf
Tweaks on PR comments
alexmigf Sep 27, 2023
91ace9e
Update class-wcpdf-settings-debug.php
alexmigf Sep 27, 2023
a9a3a6c
Rename views
alexmigf Sep 27, 2023
c3ac87a
Move advanced tools & numbers HTML to new view files
alexmigf Sep 27, 2023
5cd02ff
Merge branch 'main' into 606-improve-debug-tab-include-number-tools
alexmigf Oct 3, 2023
579815d
Adds notice to Danger Zone tools when enabled
alexmigf Oct 6, 2023
de95e8f
Generate minified JS and CSS files
alexmigf Oct 6, 2023
97b5094
Update class-wcpdf-assets.php
alexmigf Oct 9, 2023
b590dcd
Improves number listings to support documents that share the Invoice …
alexmigf Oct 10, 2023
39c016d
Generate minified JS and CSS files
alexmigf Oct 10, 2023
c9a8ea2
Update class-wcpdf-number-store-list-table.php
alexmigf Oct 10, 2023
5518ef2
Merge branch 'main' into 606-improve-debug-tab-include-number-tools
alexmigf Nov 1, 2023
e9d0ff8
Update advanced-numbers.php
alexmigf Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion assets/css/debug-tools.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ form#wpo-wcpdf-settings {
margin-left: 0 !important;
}
#debug-tools {
width: 50%;
width: 100%;
margin-top: 2em;
}

#debug-tools .wrapper {
Expand Down Expand Up @@ -34,6 +35,19 @@ form#wpo-wcpdf-settings {
max-width: 25rem;
}

#debug-tools #danger_zone {
margin-top: 20px;
background-color: #fcf9e8;
}

#debug-tools #danger_zone .notice {
margin: 0;
}

#debug-tools .add-info {
margin-left: 6px;
}

#document_custom_redirect_page,
#document_custom_redirect_page + .description {
display: none;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/debug-tools.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions assets/css/settings-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ table.wcpdf_documents_settings_list td.title {
color: #222;
}

.wcpdf_advanced_numbers_choose_table {
margin-top: 20px;
}

.wcpdf_document_settings_document_output_formats {
margin-bottom: 30px;
}
Expand Down Expand Up @@ -263,7 +267,7 @@ body.woocommerce_page_wpo_wcpdf_options_page {
margin: 15px 0 0;
}

.nav-tab-wrapper a.nav-tab {
.nav-tab-wrapper:not( .wcpdf_debug_settings_sections > .nav-tab-wrapper) a.nav-tab {
background: transparent;
border: none;
border-bottom: 3px solid transparent;
Expand All @@ -272,7 +276,7 @@ body.woocommerce_page_wpo_wcpdf_options_page {
font-size: 15px;
}

.nav-tab-wrapper a.nav-tab.nav-tab-active {
.nav-tab-wrapper:not( .wcpdf_debug_settings_sections > .nav-tab-wrapper) a.nav-tab.nav-tab-active {
border-bottom: 3px solid #51266b;
}

Expand Down Expand Up @@ -435,6 +439,10 @@ body.woocommerce_page_wpo_wcpdf_options_page {
font-size: 12px;
}

#wpo-wcpdf-settings .system-status-table {
margin-top: 2em;
}

#wpo-wcpdf-preview-wrapper[data-preview-states="1"] .sidebar {
flex: 0 0 100%;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/css/settings-styles.min.css

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions assets/js/debug-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,97 @@ jQuery( function( $ ) {
}
} ).trigger( 'change' );

// number search
$( document.body ).on( 'click', '#wpo-wcpdf-settings a.number-search-button', function( e ) {
e.preventDefault();

let search_val = $( this ).closest( 'div' ).find( ':input[name="number_search_input"]' ).val();
window.location.href = window.location.href + '&s=' + search_val;
} );

// datepicker
$( '#renumber-date-from, #renumber-date-to, #delete-date-from, #delete-date-to' ).datepicker( { dateFormat: 'yy-mm-dd' } );

// danger zone tools
$( '#wpo-wcpdf-settings .number-tools-btn' ).click( function( event ) {
event.preventDefault();

let documentType = '';
let dateFrom = '';
let dateTo = '';
let deleteOrRenumber = '';
let pageCount = 1;
let documentCount = 0;

if ( 'renumber-documents-btn' === this.id ) {
documentType = $( '#renumber-document-type' ).val();
dateFrom = $( '#renumber-date-from' ).val();
dateTo = $( '#renumber-date-to' ).val();
deleteOrRenumber = 'renumber';

} else if ( 'delete-documents-btn' === this.id ) {
documentType = $( '#delete-document-type' ).val();
dateFrom = $( '#delete-date-from' ).val();
dateTo = $( '#delete-date-to' ).val();
deleteOrRenumber = 'delete';
}

if ( '' === documentType || 'undefined' === documentType ) {
alert( wpo_wcpdf_debug.select_document_type );
return;
}

if ( 'renumber' === deleteOrRenumber ) {
$( '.renumber-spinner' ).css( 'visibility', 'visible' );
} else if ( 'delete' === deleteOrRenumber ) {
$( '.delete-spinner' ).css( 'visibility', 'visible' );
}

$( '#renumber-documents-btn, #delete-documents-btn' ).attr( 'disabled', true );
$( '#renumber-document-type, #renumber-date-from, #renumber-date-to, #delete-document-type, #delete-date-from, #delete-date-to' ).prop( 'disabled', true );

// first call
renumberOrDeleteDocuments( documentType, dateFrom, dateTo, pageCount, documentCount, deleteOrRenumber );
} );

function renumberOrDeleteDocuments( documentType, dateFrom, dateTo, pageCount, documentCount, deleteOrRenumber ) {
let data = {
'action': 'wpo_wcpdf_danger_zone_tools',
'delete_or_renumber': deleteOrRenumber,
'document_type': documentType,
'date_from': dateFrom,
'date_to': dateTo,
'page_count': pageCount,
'document_count': documentCount,
'nonce': wpo_wcpdf_debug.nonce,
};

$.ajax( {
type: 'POST',
url: wpo_wcpdf_debug.ajaxurl,
data: data,
dataType: 'json',
success: function( response ) {
if ( false === response.data.finished ) {
// update page count and document count
pageCount = response.data.pageCount;
documentCount = response.data.documentCount;

// recall function
renumberOrDeleteDocuments( documentType, dateFrom, dateTo, pageCount, documentCount, deleteOrRenumber );

} else {
$( '.renumber-spinner, .delete-spinner' ).css( 'visibility', 'hidden' );
$( '#renumber-documents-btn, #delete-documents-btn' ).removeAttr( 'disabled' );
$( '#renumber-document-type, #renumber-date-from, #renumber-date-to, #delete-document-type, #delete-date-from, #delete-date-to' ).prop( 'disabled', false );
let message = response.data.message;
alert( documentCount + message );
}
},
error: function( xhr, ajaxOptions, thrownError ) {
alert( xhr.status + ':'+ thrownError );
}
} );
}

} );
2 changes: 1 addition & 1 deletion assets/js/debug-script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions includes/class-wcpdf-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,19 @@ public function backend_scripts_styles ( $hook ) {
wp_enqueue_script(
'wpo-wcpdf-debug',
WPO_WCPDF()->plugin_url() . '/assets/js/debug-script'.$suffix.'.js',
[ 'jquery', 'jquery-blockui' ],
array( 'jquery', 'jquery-blockui', 'jquery-ui-datepicker' ),
WPO_WCPDF_VERSION
);
wp_localize_script(
'wpo-wcpdf-debug',
'wpo_wcpdf_debug',
[
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpo_wcpdf_debug_nonce' ),
'download_label' => __( 'Download', 'woocommerce-pdf-invoices-packing-slips' ),
'confirm_reset' => __( 'Are you sure you want to reset this settings? This cannot be undone.', 'woocommerce-pdf-invoices-packing-slips' ),
]
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpo_wcpdf_debug_nonce' ),
'download_label' => __( 'Download', 'woocommerce-pdf-invoices-packing-slips' ),
'confirm_reset' => __( 'Are you sure you want to reset this settings? This cannot be undone.', 'woocommerce-pdf-invoices-packing-slips' ),
'select_document_type' => __( 'Please select a document type', 'woocommerce-pdf-invoices-packing-slips' ),
)
);

}
Expand Down
11 changes: 11 additions & 0 deletions includes/class-wcpdf-documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ public function get_document( $document_type, $order ) {

return false;
}

public function get_document_titles() {
$documents = $this->get_documents();
$document_titles = array();

foreach ( $documents as $document ) {
$document_titles[ $document->get_type() ] = $document->get_title();
}

return $document_titles;
}

}

Expand Down
4 changes: 2 additions & 2 deletions includes/class-wcpdf-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public function do_install() {
update_option( $version_setting, WPO_WCPDF_VERSION );
}

// deactivate ubl addon
add_action( 'admin_init', array( WPO_WCPDF(), 'deactivate_ubl_addon') );
// deactivate legacy addons
add_action( 'admin_init', array( WPO_WCPDF(), 'deactivate_legacy_addons') );
}


Expand Down
2 changes: 1 addition & 1 deletion includes/class-wcpdf-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct() {
add_filter( 'wpo_wcpdf_pdf_filters', array( $this, 'pdf_currency_filters' ) );
add_filter( 'wpo_wcpdf_html_filters', array( $this, 'html_currency_filters' ) );

// scheduled attachments cleanup (following settings on Status tab)
// scheduled attachments cleanup (following settings on Advanced tab)
add_action( 'wp_scheduled_delete', array( $this, 'schedule_temporary_files_cleanup' ) );

// remove private data
Expand Down
6 changes: 3 additions & 3 deletions includes/class-wcpdf-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function check_auto_increment_increment() {
$row = $wpdb->get_row( "SHOW VARIABLES LIKE 'auto_increment_increment'" );
if ( ! empty( $row ) && ! empty( $row->Value ) && $row->Value != 1 ) {
/* translators: database row value */
$error = wp_kses_post( sprintf( __( "<strong>Warning!</strong> Your database has an AUTO_INCREMENT step size of %d, your invoice numbers may not be sequential. Enable the 'Calculate document numbers (slow)' setting in the Status tab to use an alternate method." , 'woocommerce-pdf-invoices-packing-slips' ), intval( $row->Value ) ) );
$error = wp_kses_post( sprintf( __( "<strong>Warning!</strong> Your database has an AUTO_INCREMENT step size of %d, your invoice numbers may not be sequential. Enable the 'Calculate document numbers (slow)' setting in the Advanced tab to use an alternate method." , 'woocommerce-pdf-invoices-packing-slips' ), intval( $row->Value ) ) );
printf( '<div class="error"><p>%s</p></div>', $error );
}
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public function settings_page() {

// add status and upgrade tabs last in row
$settings_tabs['debug'] = array(
'title' => __( 'Status', 'woocommerce-pdf-invoices-packing-slips' ),
'title' => __( 'Advanced', 'woocommerce-pdf-invoices-packing-slips' ),
'preview_states' => 1,
);

Expand All @@ -204,7 +204,7 @@ public function settings_page() {
$active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field( $_GET[ 'tab' ] ) : $default_tab;
$active_section = isset( $_GET[ 'section' ] ) ? sanitize_text_field( $_GET[ 'section' ] ) : '';

include( 'views/wcpdf-settings-page.php' );
include( 'views/settings-page.php' );
}

public function maybe_disable_preview_on_settings_tabs( $settings_tabs ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ public function get_thumbnail ( $product ) {
* which turns the function 'imagecreatefromwebp()' inexistent,
* leading to display an error in DOMPDF.
*
* Check 'System configuration' in the Status tab for 'webp' support.
* Check 'System configuration' in the Advanced tab for 'webp' support.
*/
if ( 'webp' === wp_check_filetype( $thumbnail_path )['ext'] && ! function_exists( 'imagecreatefromwebp' ) ) {
$thumbnail = '';
Expand Down
2 changes: 1 addition & 1 deletion includes/settings/class-wcpdf-settings-callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public function media_upload( $args ) {
if ( 'webp' === wp_check_filetype( $attachment_src )['ext'] && ! function_exists( 'imagecreatefromwebp' ) ) {
printf(
'<div class="notice notice-warning inline" style="display:inline-block; width:auto;"><p>%s</p></div>',
wp_kses_post( 'File type <strong>webp</strong> is not supported by your server! Please check your <strong>System Configurations</strong> under the <strong>Status</strong> tab.', 'woocommerce-pdf-invoices-packing-slips' )
wp_kses_post( 'File type <strong>webp</strong> is not supported by your server! Please check your <strong>System Configurations</strong> under the <strong>Advanced</strong> tab.', 'woocommerce-pdf-invoices-packing-slips' )
);
}

Expand Down
Loading