Plugin Directory

Changeset 2473672


Ignore:
Timestamp:
02/12/2021 11:23:40 AM (5 years ago)
Author:
opurockey
Message:

Release version 1.7.5

Location:
erp
Files:
2354 added
9 edited

Legend:

Unmodified
Added
Removed
  • erp/trunk/modules/crm/includes/class-ajax.php

    r2441411 r2473672  
    301301        $data = array_merge( $posted['contact']['main'], $posted['contact']['meta'], $posted['contact']['social'] );
    302302
     303        $data['first_name'] = stripslashes( $data['first_name'] );
     304        $data['last_name']  = stripslashes( $data['last_name'] );
     305
    303306        if ( ! $data['id'] && ! current_user_can( 'erp_crm_add_contact' ) ) {
    304307            $this->send_error( __( 'You don\'t have any permission to add new contact', 'erp' ) );
  • erp/trunk/modules/crm/includes/functions-capabilities.php

    r2417217 r2473672  
    259259
    260260            if ( ! user_can( $user_id, $crm_manager_role ) && user_can( $user_id, $crm_agent_role ) ) {
    261                 $contact_user_id = \WeDevs\ERP\Framework\Models\People::select( 'user_id' )->where( 'id', $contact_id )->first();
     261                $contact_user_id = \WeDevs\ERP\Framework\Models\People::select( 'user_id', 'contact_owner' )->where( 'id', $contact_id )->first();
    262262
    263263                if ( isset( $contact_user_id->user_id ) && $contact_user_id->user_id ) {
    264264                    $assign_id = get_user_meta( $contact_user_id->user_id, 'contact_owner', true );
    265265                } else {
    266                     $assign_id = erp_people_get_meta( $contact_id, 'contact_owner', true );
     266                    $assign_id = (int) $contact_user_id->contact_owner;
    267267                }
    268268
    269                 if ( $assign_id != $user_id ) {
    270                     $caps = ['do_not_allow'];
     269                if ( $assign_id !== $user_id ) {
     270                    $caps = [ 'do_not_allow' ];
    271271                } else {
    272272                    if ( $data_hard ) {
    273                         $caps = ['do_not_allow'];
     273                        $caps = [ 'do_not_allow' ];
    274274                    }
    275275                }
    276276            } elseif ( ! user_can( $user_id, $crm_manager_role ) ) {
    277                 $caps = ['do_not_allow'];
     277                $caps = [ 'do_not_allow' ];
    278278            }
    279279
    280         break;
     280            break;
    281281    }
    282282
  • erp/trunk/modules/crm/includes/functions-customer.php

    r2417217 r2473672  
    32563256            $created       = 0;
    32573257            $users         = [];
    3258             $user_ids      = isset( $_REQUEST['users'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['users'] ) ) : [];
     3258            $user_ids      = isset( $_REQUEST['users'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['users'] ) ) : [];
    32593259            $life_stage    = isset( $_POST['life_stage'] ) ? sanitize_text_field( wp_unslash( $_POST['life_stage'] ) ) : [];
    32603260            $contact_owner = isset( $_POST['contact_owner'] ) ? sanitize_text_field( wp_unslash( $_POST['contact_owner'] ) ) : [];
  • erp/trunk/modules/hrm/includes/class-employee.php

    r2448466 r2473672  
    252252        }
    253253
     254        if ( isset( $user_email ) && ! empty( $user_email ) ) {
     255            if ( erp_is_employee_exist( $user_email, $user_id ) ) {
     256                return new WP_Error( 'employee-email-exist', sprintf( __( 'Employee with the employee email %s already exist. Please use different one.', 'erp' ), $user_email ) );
     257            }
     258        }
     259
    254260        $data = apply_filters( 'pre_erp_hr_employee_args', $data );
    255261
  • erp/trunk/modules/hrm/includes/class-form-handler.php

    r2417217 r2473672  
    12241224        }
    12251225
    1226         if ( isset( $_POST['action'] ) && $_POST['action'] === 'erp-hr-fyears-setting' ) {
    1227             if ( isset( $_POST['_wpnonce'] ) && ! wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'erp-settings-nonce' ) ) {
    1228                 die( 'Nonce failed.' );
    1229             }
    1230 
    1231             $fnames = isset( $_POST['fyear-name'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['fyear-name'] ) ) : [];
    1232             $starts = isset( $_POST['fyear-start'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['fyear-start'] ) ) : [];
    1233             $ends   = isset( $_POST['fyear-end'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['fyear-end'] ) ) : [];
    1234 
    1235             $current_user_id = get_current_user_id();
    1236             $url             = admin_url( 'admin.php?page=erp-settings&tab=erp-hr&section=financial' );
    1237 
    1238             $errors = new ERP_Errors( 'leave_financial_years_create' );
    1239 
    1240             foreach ( $fnames as $key => $fname ) {
    1241                 if ( strpos( $key, 'id-' ) !== false ) {
    1242                     // we have existing record
    1243                     $f_id = explode( 'id-', $key )[1]; // id-3 => 3
    1244 
    1245                     $policy_exist = Leave_Policy::where( 'f_year', $f_id )->first();
    1246 
    1247                     if ( $policy_exist ) {
    1248                         $errors->add( esc_html__(
    1249                             sprintf( 'Existing leave year associated with policy won\'t be updated. e.g. %s', $fname ), 'erp' ) );
    1250 
    1251                         // we shouldn't update if there's an associated policy
    1252                         // so, let's move on to next loop
    1253                         continue;
    1254                     }
    1255 
    1256                     // otherwise, update an existing one
    1257                     Financial_Year::find( $f_id )->update( [
    1258                         'fy_name'     => $fname,
    1259                         'start_date'  => erp_mysqldate_to_phptimestamp( $starts[ $key ] ),
    1260                         'end_date'    => erp_mysqldate_to_phptimestamp( $ends[ $key ] ),
    1261                         'description' => esc_html__( 'Year for leave', 'erp' ),
    1262                         'updated_by'  => $current_user_id,
    1263                     ] );
    1264 
     1226        if ( ! isset( $_POST['action'] ) || $_POST['action'] !== 'erp-hr-fyears-setting' ) {
     1227            return;
     1228        }
     1229
     1230        if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'erp-settings-nonce' ) ) {
     1231            die( esc_html__( 'Nonce failed.', 'erp' ) );
     1232        }
     1233
     1234        $fnames = isset( $_POST['fyear-name'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['fyear-name'] ) ) : [];
     1235        $starts = isset( $_POST['fyear-start'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['fyear-start'] ) ) : [];
     1236        $ends   = isset( $_POST['fyear-end'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['fyear-end'] ) ) : [];
     1237
     1238        $current_user_id = get_current_user_id();
     1239        $url             = admin_url( 'admin.php?page=erp-settings&tab=erp-hr&section=financial' );
     1240
     1241        $errors = new ERP_Errors( 'leave_financial_years_create' );
     1242
     1243        foreach ( $fnames as $key => $fname ) {
     1244            if ( strpos( $key, 'id-' ) !== false ) {
     1245                // we have existing record
     1246                $f_id = explode( 'id-', $key )[1]; // id-3 => 3
     1247
     1248                $policy_exist = Leave_Policy::where( 'f_year', $f_id )->first();
     1249
     1250                if ( $policy_exist ) {
     1251                    $errors->add( esc_html__(
     1252                        sprintf( 'Existing leave year associated with policy won\'t be updated. e.g. %s', $fname ), 'erp' ) );
     1253
     1254                    // we shouldn't update if there's an associated policy
     1255                    // so, let's move on to next loop
    12651256                    continue;
    12661257                }
    12671258
    1268                 // or create a new one
    1269                 Financial_Year::create( [
     1259                // otherwise, update an existing one
     1260                Financial_Year::find( $f_id )->update( [
    12701261                    'fy_name'     => $fname,
    12711262                    'start_date'  => erp_mysqldate_to_phptimestamp( $starts[ $key ] ),
    12721263                    'end_date'    => erp_mysqldate_to_phptimestamp( $ends[ $key ] ),
    12731264                    'description' => esc_html__( 'Year for leave', 'erp' ),
    1274                     'created_by'  => $current_user_id,
     1265                    'updated_by'  => $current_user_id,
    12751266                ] );
    1276             }
    1277 
    1278             if ( $errors->has_error() ) {
    1279                 $errors->save();
    1280                 $url = add_query_arg( [ 'error' => 'leave_financial_years_create' ], $url );
    1281             }
    1282 
    1283             wp_safe_redirect( $url );
    1284             exit();
    1285         }
     1267
     1268                continue;
     1269            }
     1270
     1271            // or create a new one
     1272            Financial_Year::create( [
     1273                'fy_name'     => $fname,
     1274                'start_date'  => erp_mysqldate_to_phptimestamp( $starts[ $key ] ),
     1275                'end_date'    => erp_mysqldate_to_phptimestamp( $ends[ $key ] ),
     1276                'description' => esc_html__( 'Year for leave', 'erp' ),
     1277                'created_by'  => $current_user_id,
     1278            ] );
     1279        }
     1280
     1281        if ( $errors->has_error() ) {
     1282            $errors->save();
     1283            $url = add_query_arg( [ 'error' => 'leave_financial_years_create' ], $url );
     1284        }
     1285
     1286        wp_safe_redirect( $url );
     1287        exit();
    12861288    }
    12871289}
  • erp/trunk/modules/hrm/includes/functions-designation.php

    r2417217 r2473672  
    6767    $args = wp_parse_args( $args, $defaults );
    6868
    69     $cache_key    = 'erp-designations';
     69    //$cache_key    = 'erp-designations';
     70    $cache_key    = 'erp-designations-'  . md5( serialize( $args ) );
    7071    $designations = wp_cache_get( $cache_key, 'erp' );
    7172
  • erp/trunk/modules/hrm/includes/functions-employee.php

    r2441411 r2473672  
    10171017    global $wpdb;
    10181018    $user_email = sanitize_email( $email );
    1019     $sql        = "select user.ID from {$wpdb->prefix}erp_hr_employees as employee inner join {$wpdb->prefix}users as user on user.ID=employee.user_id where user.user_email='{$user_email}' AND user.ID !='{$user_id}'";
    1020 
    1021     return $wpdb->get_col( $sql );
     1019    return $wpdb->get_col( $wpdb->prepare( "select ID from {$wpdb->prefix}users where user_email=%s AND ID !=%s", $user_email, $user_id ) );
    10221020}
    10231021
  • erp/trunk/readme.txt

    r2448466 r2473672  
    44Tags: business manager, erp, accounting, crm, hr, project manager, small business, SME, contact, contacts, Customer Relationship Management, employee, leave management, hr, human resource management, job, jobs, job listing, lead management, opportunity, schedule, task, lead, holiday, company
    55Requires at least: 4.4
    6 Tested up to: 5.6
     6Tested up to: 5.6.1
    77Requires PHP: 5.6
    8 Stable tag: 1.7.4
     8Stable tag: 1.7.5
    99License: GPLv2
    1010License: GPLv2 or later
     
    280280
    281281== Changelog ==
     282
     283= v1.7.5 -> February 12, 2021 =
     284--------------------------
     285- [fix] Fixed nonce verification issue while leave year is being saved
     286- [fix] Issue with importing WP user to CRM contact fixed
     287- [fix] CRM agent was not able edit their own contact- this has been fixed
     288- [fix] Fixed extra slash issue if CRM first name last name has apostrophe
     289- [fix] Fixed the Admin access loosing issue when adding an Employee with the Admin email address
     290- [fix] Fixed accounting transaction summary piechart was not showing the percentage value
     291- [fix] Fixed static cache key issue at designation list page
     292- [update] Updated already existing employee check functionality
    282293
    283294= v1.7.4 -> December 31, 2020 =
  • erp/trunk/wp-erp.php

    r2448466 r2473672  
    66 * Author: weDevs
    77 * Author URI: https://wedevs.com
    8  * Version: 1.7.4
     8 * Version: 1.7.5
    99 * License: GPL2
    1010 * Text Domain: erp
     
    5353     * @var string
    5454     */
    55     public $version = '1.7.4';
     55    public $version = '1.7.5';
    5656
    5757    /**
Note: See TracChangeset for help on using the changeset viewer.