'; $o .= '

Sorry, you are not allowed to access this page!

'; $o .= ''; wp_die( $o, 403 ); } global $wpdb; $table_name = $wpdb->prefix . 'zacctmgr_acm_commissions_mapping'; $manager_commission_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND customer_id IS NULL ORDER BY timestamp DESC LIMIT 1;" ); $manager_order_level_commission_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND order_level=1 AND customer_account_level=0 AND customer_id IS NULL ORDER BY timestamp DESC LIMIT 1;" ); $manager_customer_level_commission_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND customer_id IS NULL AND customer_account_level=1 ORDER BY timestamp DESC LIMIT 1;" ); $manager_no_commission_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND customer_id IS NULL AND customer_account_level=0 AND no_commission=1 ORDER BY timestamp DESC LIMIT 1;" ); if ( count( $manager_commission_rate ) != 0 ) { $current_commission_rate = $manager_commission_rate[0]; if ( count( $manager_order_level_commission_rate ) != 0 ) { if ( count( $manager_customer_level_commission_rate ) != 0 ) { if ( $manager_order_level_commission_rate[0]->timestamp > $manager_customer_level_commission_rate[0]->timestamp ) { if ( count( $manager_no_commission_rate ) != 0 ) { if ( $manager_order_level_commission_rate[0]->timestamp > $manager_no_commission_rate[0]->timestamp ) { $commission_rate = $manager_order_level_commission_rate[0]; } else { $commission_rate = $manager_no_commission_rate[0]; } } else { $commission_rate = $manager_order_level_commission_rate[0]; } } else { if ( count( $manager_no_commission_rate ) != 0 ) { if ( $manager_customer_level_commission_rate[0]->timestamp > $manager_no_commission_rate[0]->timestamp ) { $commission_rate = $manager_customer_level_commission_rate[0]; } else { $commission_rate = $manager_no_commission_rate[0]; } } else { $commission_rate = $manager_customer_level_commission_rate[0]; } } } else { if ( count( $manager_no_commission_rate ) != 0 ) { if ( $manager_order_level_commission_rate[0]->timestamp > $manager_no_commission_rate[0]->timestamp ) { $commission_rate = $manager_order_level_commission_rate[0]; } else { $commission_rate = $manager_no_commission_rate[0]; } } else { $commission_rate = $manager_order_level_commission_rate[0]; } } } else { $commission_rate = new StdClass (); $commission_rate->no_commission = 0; $commission_rate->order_level = 1; $commission_rate->customer_account_level = 0; $commission_rate->new_order_commission_percentage_type = 0; $commission_rate->new_order_commission_fixed_type = 1; $commission_rate->new_order_commission_value = 0; $commission_rate->new_order_commission_limit = 1; $commission_rate->new_order_exclude_coupon_amount = 0; $commission_rate->new_order_exclude_taxes_amount = 0; $commission_rate->new_order_exclude_shipping_costs = 0; $commission_rate->new_order_exclude_shipping_tax_amount = 0; $commission_rate->existing_order_commission_percentage_type = 0; $commission_rate->existing_order_commission_fixed_type = 1; $commission_rate->existing_order_commission_value = 0; $commission_rate->existing_order_exclude_coupon_amount = 0; $commission_rate->existing_order_exclude_taxes_amount = 0; $commission_rate->existing_order_exclude_shipping_costs = 0; $commission_rate->existing_order_exclude_shipping_tax_amount = 0; } } else { $commission_rate = new StdClass (); $commission_rate->no_commission = 0; $commission_rate->order_level = 1; $commission_rate->customer_account_level = 0; $commission_rate->new_order_commission_percentage_type = 0; $commission_rate->new_order_commission_fixed_type = 1; $commission_rate->new_order_commission_value = 0; $commission_rate->new_order_commission_limit = 1; $commission_rate->new_order_exclude_coupon_amount = 0; $commission_rate->new_order_exclude_taxes_amount = 0; $commission_rate->new_order_exclude_shipping_costs = 0; $commission_rate->new_order_exclude_shipping_tax_amount = 0; $commission_rate->existing_order_commission_percentage_type = 0; $commission_rate->existing_order_commission_fixed_type = 1; $commission_rate->existing_order_commission_value = 0; $commission_rate->existing_order_exclude_coupon_amount = 0; $commission_rate->existing_order_exclude_taxes_amount = 0; $commission_rate->existing_order_exclude_shipping_costs = 0; $commission_rate->existing_order_exclude_shipping_tax_amount = 0; $current_commission_rate = $commission_rate; } $new_exclude = []; if ( $commission_rate->new_order_commission_percentage_type == 1 ) { if ( $commission_rate->new_order_exclude_coupon_amount == 1 ) { array_push( $new_exclude, 'coupon' ); } if ( $commission_rate->new_order_exclude_taxes_amount == 1 ) { array_push( $new_exclude, 'tax' ); } if ( $commission_rate->new_order_exclude_shipping_costs == 1 ) { array_push( $new_exclude, 'shipping' ); } if ( $commission_rate->new_order_exclude_shipping_tax_amount == 1 ) { array_push( $new_exclude, 'shipping_tax' ); } } $existing_exclude = []; if ( $commission_rate->existing_order_commission_percentage_type == 1 ) { if ( $commission_rate->existing_order_exclude_coupon_amount == 1 ) { array_push( $existing_exclude, 'coupon' ); } if ( $commission_rate->existing_order_exclude_taxes_amount == 1 ) { array_push( $existing_exclude, 'tax' ); } if ( $commission_rate->existing_order_exclude_shipping_costs == 1 ) { array_push( $existing_exclude, 'shipping' ); } if ( $commission_rate->existing_order_exclude_shipping_tax_amount == 1 ) { array_push( $existing_exclude, 'shipping_tax' ); } } if ( $commission_rate->order_level == 1 ) { $commission_type = 'order_level'; } elseif ( $commission_rate->customer_account_level == 1 ) { $commission_type = 'customer_account_level'; } else { $commission_type = 'no_commission'; } if ( $current_commission_rate->order_level == 1 ) { $current_commission_type = 'order_level'; } elseif ( $current_commission_rate->customer_account_level == 1 ) { $current_commission_type = 'customer_account_level'; } else { $current_commission_type = 'no_commission'; } $new_fixed_type = $commission_rate->new_order_commission_fixed_type; $existing_fixed_type = $commission_rate->existing_order_commission_fixed_type; $new_percentage_type = $commission_rate->new_order_commission_percentage_type; $existing_percentage_type = $commission_rate->existing_order_commission_percentage_type; $order_count = $commission_rate->new_order_commission_limit; $new_value = $commission_rate->new_order_commission_value; $existing_value = $commission_rate->existing_order_commission_value; /* order_level, customer_account_level, no_commission */ $zacctmgr_commission_type = $data->zacctmgr_commission_type ? $data->zacctmgr_commission_type : 'order_level'; $value1 = ''; $value2 = ''; $type1 = ''; $type1 .= ''; $type2 = ''; $type2 .= ''; $order1 = ''; /* Apply 1 */ $apply1 = ''; $style_fixed = 'style="display: block;"'; $style_percentage = 'style="display: none;"'; if ( $new_percentage_type == 1 ) { $style_fixed = 'style="display: none;"'; $style_percentage = 'style="display: block;"'; } $zacctmgr_commission_new_exclude_options = $new_exclude; $apply1 .= '
'; $apply1 .= '

Order Total

'; $apply1 .= '
'; foreach ( ZACCTMGR_EXCLUDE_OPTIONS as $key => $label ) { $extra = in_array( $key, $zacctmgr_commission_new_exclude_options ) ? 'checked="checked"' : ''; $apply1 .= '
'; $apply1 .= ''; $apply1 .= ''; $apply1 .= '
'; } $apply1 .= '
'; $apply1 .= '
'; $apply1 .= '
'; $apply1 .= '

Fixed Value Amount

'; $apply1 .= '
'; /* Apply 1 End */ /* Apply 2 */ $apply2 = ''; $style_fixed = 'style="display: block;"'; $style_percentage = 'style="display: none;"'; if ( $existing_percentage_type == 1 ) { $style_fixed = 'style="display: none;"'; $style_percentage = 'style="display: block;"'; } $zacctmgr_commission_existing_exclude_options = $existing_exclude; $apply2 .= '
'; $apply2 .= '

Order Total

'; $apply2 .= '
'; foreach ( ZACCTMGR_EXCLUDE_OPTIONS as $key => $label ) { $extra = in_array( $key, $zacctmgr_commission_existing_exclude_options ) ? 'checked="checked"' : ''; $apply2 .= '
'; $apply2 .= ''; $apply2 .= ''; $apply2 .= '
'; } $apply2 .= '
'; $apply2 .= '
'; $apply2 .= '
'; $apply2 .= '

Fixed Value Amount

'; $apply2 .= '
'; /* Apply 2 End */ // if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'zacctmgr_edit_commission' ) ) { // echo '

Account Manager commission updated.
← Back to Commission

'; // } echo '
'; echo '

Edit Commission

'; echo '
'; echo '

Account Manager Commission Edit

'; global $wpdb; $table_name = $wpdb->prefix . 'zacctmgr_acm_commissions_mapping'; $report = zacctmgr_get_manager_report( $manager_id ); $new_type = $new_fixed_type == 1 ? 'fixed' : 'percentage'; $existing_type = $existing_fixed_type == 1 ? 'fixed' : 'percentage'; $commissionData = zacctmgr_get_total_commission_by_manager( $manager_data ); $current_commission_calculation_type = $current_commission_type; $current_new_order_limit = $commission_rate->new_order_commission_limit; $current_new_order_type = $commission_rate->new_order_commission_fixed_type == 1 ? 'fixed' : 'percentage'; $current_existing_order_type = $commission_rate->existing_order_commission_fixed_type == 1 ? 'fixed' : 'percentage'; $current_new_value = $commission_rate->new_order_commission_value; $current_existing_value = $commission_rate->existing_order_commission_value; $current_new_exclude = $new_exclude; $current_existing_exclude = $existing_exclude; $audit_info = ''; $audit_info .= ''; $audit_info .= ''; $audit_info .= ''; $audit_info .= ''; $audit_info .= ''; foreach ( $current_new_exclude as $item ) { $audit_info .= ''; } foreach ( $current_existing_exclude as $item ) { $audit_info .= ''; } $order_level_commission = zacctmgr_get_latest_order_level( $manager_id ); $accounts_number = zacctmgr_get_account_type_number( $manager_id ); ?>

first_name . ' ' . $manager_data->last_name; ?>

Accounts
Order Level

Accounts
Customer Account Level

new_order_commission_percentage_type == 1 ) { $o = ''; if ( $order_level_commission->new_order_exclude_coupon_amount == 1 ) { $o .= 'Exclude Coupon Amount
'; } if ( $order_level_commission->new_order_exclude_taxes_amount == 1 ) { $o .= 'Exclude Taxes Amount
'; } if ( $order_level_commission->new_order_exclude_shipping_costs == 1 ) { $o .= 'Exclude Shipping Costs Amount
'; } if ( $order_level_commission->new_order_exclude_shipping_tax_amount == 1 ) { $o .= 'Exclude Shipping Tax Amount
'; } if ( $o == '' ) { $o = 'Percentage Value Amount'; } } else { if ( $order_level_commission->new_order_commission_fixed_type == 1 ) { $o = 'Fixed Value Amount'; } } ?>
existing_order_commission_percentage_type == 1 ) { $o = ''; if ( $order_level_commission->existing_order_exclude_coupon_amount == 1 ) { $o .= 'Exclude Coupon Amount
'; } if ( $order_level_commission->existing_order_exclude_taxes_amount == 1 ) { $o .= 'Exclude Taxes Amount
'; } if ( $order_level_commission->existing_order_exclude_shipping_costs == 1 ) { $o .= 'Exclude Shipping Costs Amount
'; } if ( $order_level_commission->existing_order_exclude_shipping_tax_amount == 1 ) { $o .= 'Exclude Shipping Tax Amount
'; } if ( $o == '' ) { $o = 'Percentage Value Amount'; } } else { if ( $order_level_commission->existing_order_commission_fixed_type == 1 ) { $o = 'Fixed Value Amount'; } } ?>
Order Level Rates Apply to Value Calculated by
New Orders new_order_commission_limit; ?> new_order_commission_value . ( $order_level_commission->new_order_commission_percentage_type == 1 ? '%' : '' ); ?>
Existing Orders existing_order_commission_value . ( $order_level_commission->new_order_commission_percentage_type == 1 ? '%' : '' ); ?>
Total Commission New
Total Commission Existing
Total Commission

Oops, No Data for Time Period Selected

Try another data range

'; echo ''; echo ''; echo $audit_info; echo wp_nonce_field( 'zacctmgr_edit_commission' ); echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Commission Calculations
'; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Commission RatesApply toValueTypeCalculate By
New Orders' . $order1 . '' . $value1 . '' . $type1 . '' . $apply1 . '
Existing Orders' . $value2 . '' . $type2 . '' . $apply2 . '
'; echo '
'; echo '

'; echo ''; echo '

'; echo ''; echo '
'; ?>

Audit Log

print_overview(); ?>