• Resolved roes99

    (@roes99)


    Hi WPERP Support,
    I am creating tasks and allocating them, however when the task email notification is sent to the recipient, it does not contain the actual “task Description” and there is no available ‘template tag’ for this.
    The only available template tags are: {employee_name}, {task_title}, {due_date}, {created_by}.
    How can I create the tag: {task_description} so that I can have the task description included in the email notification? Please help 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Mehedi Hasan

    (@thebengalboy)

    Hello @roes99,

    Here is the file location you need to work on: modules/crm/includes/emails/class-email-new-task-assigned.php

    You can add the message description on the line number: 66.

    Reference: https://d.pr/i/RknlLQ

    Thanks

    Hi Mehedi,
    Thanks, that worked for the message description however now the {due_date} and {created_by} are no longer appearing in the email notification correctly – the due date is appearing instead of the created by…. see example below:

    Hello Patrick Roesch,
    A new task VRQ Website has been assigned to you by 04-01-2019
    Due Date:
    Get Business Directory up and enough content to make site live…

    Regards
    Manager Name
    Company

    The code looks like this now:
    $this->replace = [
    ’employee_name’ => $employee->get_full_name(),
    ‘task_title’ => $extra->task_title,
    ‘message’ => $activity->message,
    ‘due_date’ => erp_format_date( $activity->start_date ),
    ‘created_by’ => $current_user->display_name,
    ];

    Plugin Support Mehedi Hasan

    (@thebengalboy)

    Hello @roes99,

    Replace the class-email-new-task-assigned.php file with this code:

    <?php
    namespace WeDevs\ERP\CRM\Emails;
    
    use WeDevs\ERP\Email;
    use WeDevs\ERP\Framework\Traits\Hooker;
    
    /**
     * New Task Assigned
     */
    class New_Task_Assigned extends Email {
    
        use Hooker;
    
        function __construct() {
            $this->id          = 'new-task-assigned';
            $this->title       = __( 'New Task Assigned', 'erp' );
            $this->description = __( 'New task assigned notification to employee.', 'erp' );
    
            $this->subject     = __( 'New task has been assigned to you', 'erp');
            $this->heading     = __( 'New Task Assigned', 'erp');
    
            $this->find = [
                'employee_name' => '{employee_name}',
                'task_title'    => '{task_title}',
                'message'       => '{message}',
                'due_date'      => '{due_date}',
                'created_by'    => '{created_by}',
            ];
    
            $this->action( 'erp_admin_field_' . $this->id . '_help_texts', 'replace_keys' );
    
            parent::__construct();
        }
    
        function get_args() {
            return [
                'email_heading' => $this->heading,
                'email_body'    => wpautop( $this->get_option( 'body' ) ),
            ];
        }
    
        public function trigger( $data ) {
            global $current_user;
    
            $activity = \WeDevs\ERP\CRM\Models\Activity::where( [
                'id'   => intval( $data['activity_id'] ),
                'type' => 'tasks',
            ] )->first();
    
            if ( ! $activity ) {
                return;
            }
    
            $extra = json_decode( base64_decode( $activity->extra ) );
    
            $this->heading = $this->get_option( 'heading', $this->heading );
            $this->subject = $this->get_option( 'subject', $this->subject );
    
            foreach ($data['user_ids'] as $id) {
                $employee = new \WeDevs\ERP\HRM\Employee( intval( $id ) );
    
                $this->replace = [
                    'employee_name' => $employee->get_full_name(),
                    'task_title'    => $extra->task_title,
                    'message'       => $activity->message,
                    'due_date'      => erp_format_date( $activity->start ),
                    'created_by'    => $current_user->display_name,
                ];
    
                if ( $employee ) {
                    $this->send( $employee->user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
                }
            }
        }
    
    }

    Also, replace the /includes/class-install.php with this code:

    <?php
    /**
     * Installation related functions and actions.
     *
     * @author Tareq Hasan
     * @package ERP
     */
    
    // don't call the file directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    /**
     * Installer Class
     *
     * @package ERP
     */
    class WeDevs_ERP_Installer {
    
        use \WeDevs\ERP\Framework\Traits\Hooker;
    
        /**
         * Binding all events
         *
         * @since 1.0
         *
         * @return void
         */
        function __construct() {
            $this->set_default_modules();
    
            register_activation_hook( WPERP_FILE, array( $this, 'activate' ) );
            register_deactivation_hook( WPERP_FILE, array( $this, 'deactivate' ) );
    
            $this->action( 'admin_menu', 'welcome_screen_menu' );
            $this->action( 'admin_head', 'welcome_screen_menu_remove' );
        }
    
        /**
         * Placeholder for activation function
         * Nothing being called here yet.
         *
         * @since 1.0
         * @since save plugin install date
         * @since save plugin install date
         * @return void
         */
        public function activate() {
            $current_erp_version = get_option( 'wp_erp_version', null );
            $current_db_version  = get_option( 'wp_erp_db_version', null );
    
            $this->create_tables();
            $this->populate_data();
    
            if ( is_null( $current_erp_version ) ) {
                $this->set_role();
            }
    
            $this->create_roles(); // @TODO: Needs to change later :)
            $this->create_cron_jobs();
            $this->setup_default_emails();
    
            // does it needs any update?
            $updater = new \WeDevs\ERP\Updates();
            $updater->perform_updates();
    
            if ( is_null( $current_erp_version ) && is_null( $current_db_version ) && apply_filters( 'erp_enable_setup_wizard', true ) ) {
                set_transient( '_erp_activation_redirect', 1, 30 );
            }
    
            // update to latest version
            $latest_version = erp_get_version();
            update_option( 'wp_erp_version', $latest_version );
            update_option( 'wp_erp_db_version', $latest_version );
    
            //save install date
            if ( false == get_option( 'wp_erp_install_date' ) ) {
                update_option( 'wp_erp_install_date', current_time( 'timestamp' ) );
            }
        }
    
        /**
         * Include required files to prevent fatal errors
         *
         * @return void
         */
        function includes() {
            include_once WPERP_MODULES . '/hrm/includes/functions-capabilities.php';
            include_once WPERP_MODULES . '/crm/includes/functions-capabilities.php';
            include_once WPERP_MODULES . '/accounting/includes/function-capabilities.php';
        }
    
        /**
         * Set default mail subject, heading and body
         *
         * @since 1.0
         *
         * @return void
         */
        function setup_default_emails() {
    
            //Employee welcome
            $welcome = [
                'subject' => 'Welcome {full_name} to {company_name}',
                'heading' => 'Welcome Onboard {first_name}!',
                'body'    => 'Dear {full_name},
    
    Welcome aboard as a <strong>{job_title}</strong> in our <strong>{dept_title}</strong> team at <strong>{company_name}</strong>! I am pleased to have you working with us. You were selected for employment due to the attributes that you displayed that appear to match the qualities I look for in an employee.
    
    I’m looking forward to seeing you grow and develop into an outstanding employee that exhibits a high level of care, concern, and compassion for others. I hope that you will find your work to be rewarding, challenging, and meaningful.
    
    Your <strong>{type}</strong> employment will start from <strong>{joined_date}</strong> and you will be reporting to <strong>{reporting_to}</strong>.
    
    Please take your time and review our yearly goals so that you can know what is expected and make a positive contribution. Again, I look forward to seeing you grow as a professional while enhancing the lives of the clients entrusted in your care.
    
    Sincerely,
    Manager Name
    CEO, Company Name
    
    {login_info}'
            ];
    
            update_option( 'erp_email_settings_employee-welcome', $welcome );
    
            //New Leave Request
            $new_leave_request = [
                'subject' => 'New leave request received from {employee_name}',
                'heading' => 'New Leave Request',
                'body'    => 'Hello,
    
    A new leave request has been received from {employee_url}.
    
    <strong>Leave type:</strong> {leave_type}
    <strong>Date:</strong> {date_from} to {date_to}
    <strong>Days:</strong> {no_days}
    <strong>Reason:</strong> {reason}
    
    Please approve/reject this leave application by going following:
    
    {requests_url}
    
    Thanks.'
            ];
    
            update_option( 'erp_email_settings_new-leave-request', $new_leave_request );
    
            //Approved Leave Request
            $approved_request = [
                'subject' => 'Your leave request has been approved',
                'heading' => 'Leave Request Approved',
                'body'    => 'Hello {employee_name},
    
    Your <strong>{leave_type}</strong> type leave request for <strong>{no_days} days</strong> from {date_from} to {date_to} has been approved.
    
    Regards
    Manager Name
    Company'
            ];
    
            update_option( 'erp_email_settings_approved-leave-request', $approved_request );
    
            //Rejected Leave Request
            $reject_request = [
                'subject' => 'Your leave request has been rejected',
                'heading' => 'Leave Request Rejected',
                'body'    => 'Hello {employee_name},
    
    Your <strong>{leave_type}</strong> type leave request for <strong>{no_days} days</strong> from {date_from} to {date_to} has been rejected.
    
    The reason of rejection is: {reject_reason}
    
    Regards
    Manager Name
    Company'
            ];
    
            update_option( 'erp_email_settings_rejected-leave-request', $reject_request );
    
            // New Task Assigned
            $new_task_assigned = [
                'subject' => 'New task has been assigned to you',
                'heading' => 'New Task Assigned',
                'body'    => 'Hello {employee_name},
    
    A new task <strong>{task_title}</strong> has been assigned to you by {created_by}.
    Due Date: {due_date}
    
    {message}
    
    Regards
    Manager Name
    Company'
            ];
    
            update_option( 'erp_email_settings_new-task-assigned', $new_task_assigned );
        }
    
        /**
         * Create cron jobs
         *
         * @return void
         */
        public function create_cron_jobs() {
            wp_schedule_event( time(), 'per_minute', 'erp_per_minute_scheduled_events' );
            wp_schedule_event( time(), 'daily', 'erp_daily_scheduled_events' );
            wp_schedule_event( time(), 'weekly', 'erp_weekly_scheduled_events' );
        }
    
        /**
         * Placeholder for deactivation function
         *
         * Nothing being called here yet.
         */
        public function deactivate() {
            wp_clear_scheduled_hook( 'erp_per_minute_scheduled_events' );
            wp_clear_scheduled_hook( 'erp_daily_scheduled_events' );
            wp_clear_scheduled_hook( 'erp_weekly_scheduled_events' );
    
            remove_role('erp_crm_manager');
            remove_role('erp_crm_agent');
        }
    
        /**
         * Welcome screen menu page cb
         *
         * @since 1.0
         *
         * @return void
         */
        public function welcome_screen_menu() {
            add_dashboard_page( __( 'Welcome to WP ERP', 'erp' ), 'WP ERP', 'manage_options', 'erp-welcome', array( $this, 'welcome_screen_content' ) );
        }
    
        /**
         * Welcome screen menu remove
         *
         * @since 1.0
         *
         * @return void
         */
        public function welcome_screen_menu_remove() {
            remove_submenu_page( 'index.php', 'erp-welcome' );
        }
    
        /**
         * Render welcome screen content
         *
         * @since 1.0
         *
         * @return void
         */
        public function welcome_screen_content() {
            include WPERP_VIEWS . '/welcome-screen.php';
        }
    
        /**
         * Create necessary table for ERP & HRM
         *
         * @since 1.0
         *
         * @return  void
         */
        public function create_tables() {
            global $wpdb;
    
            $collate = '';
    
            if ( $wpdb->has_cap( 'collation' ) ) {
                if ( ! empty($wpdb->charset ) ) {
                    $collate .= "DEFAULT CHARACTER SET $wpdb->charset";
                }
    
                if ( ! empty($wpdb->collate ) ) {
                    $collate .= " COLLATE $wpdb->collate";
                }
            }
    
            $table_schema = [
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_company_locations</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>company_id</code> int(11) unsigned DEFAULT NULL,
                    <code>name</code> varchar(255) DEFAULT NULL,
                    <code>address_1</code> varchar(255) DEFAULT NULL,
                    <code>address_2</code> varchar(255) DEFAULT NULL,
                    <code>city</code> varchar(100) DEFAULT NULL,
                    <code>state</code> varchar(100) DEFAULT NULL,
                    <code>zip</code> int(6) DEFAULT NULL,
                    <code>country</code> varchar(5) DEFAULT NULL,
                    <code>fax</code> varchar(20) DEFAULT NULL,
                    <code>phone</code> varchar(20) DEFAULT NULL,
                    <code>created_at</code> datetime NOT NULL,
                    <code>updated_at</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>company_id</code> (<code>company_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_depts</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>title</code> varchar(200) NOT NULL DEFAULT '',
                    <code>description</code> text,
                    <code>lead</code> int(11) unsigned DEFAULT '0',
                    <code>parent</code> int(11) unsigned DEFAULT '0',
                    <code>status</code> tinyint(1) unsigned DEFAULT '1',
                    <code>created_at</code> datetime NOT NULL,
                    <code>updated_at</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_designations</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>title</code> varchar(200) NOT NULL DEFAULT '',
                    <code>description</code> text,
                    <code>status</code> tinyint(1) DEFAULT '1',
                    <code>created_at</code> datetime NOT NULL,
                    <code>updated_at</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_employees</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> bigint(20) unsigned NOT NULL DEFAULT '0',
                    <code>employee_id</code> varchar(20) DEFAULT NULL,
                    <code>designation</code> int(11) unsigned NOT NULL DEFAULT '0',
                    <code>department</code> int(11) unsigned NOT NULL DEFAULT '0',
                    <code>location</code> int(10) unsigned NOT NULL DEFAULT '0',
                    <code>hiring_source</code> varchar(20) NOT NULL,
                    <code>hiring_date</code> date NOT NULL,
                    <code>termination_date</code> date NOT NULL,
                    <code>date_of_birth</code> date NOT NULL,
                    <code>reporting_to</code> bigint(20) unsigned NOT NULL DEFAULT '0',
                    <code>pay_rate</code> int(11) unsigned NOT NULL DEFAULT '0',
                    <code>pay_type</code> varchar(20) NOT NULL DEFAULT '',
                    <code>type</code> varchar(20) NOT NULL,
                    <code>status</code> varchar(10) NOT NULL DEFAULT '',
                    <code>deleted_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>user_id</code> (<code>user_id</code>),
                    KEY <code>employee_id</code> (<code>employee_id</code>),
                    KEY <code>designation</code> (<code>designation</code>),
                    KEY <code>department</code> (<code>department</code>),
                    KEY <code>status</code> (<code>status</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_employee_history</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> bigint(20) unsigned NOT NULL DEFAULT '0',
                    <code>module</code> varchar(20) DEFAULT NULL,
                    <code>category</code> varchar(20) DEFAULT NULL,
                    <code>type</code> varchar(20) DEFAULT NULL,
                    <code>comment</code> text,
                    <code>data</code> longtext,
                    <code>date</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>user_id</code> (<code>user_id</code>),
                    KEY <code>module</code> (<code>module</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_employee_notes</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> bigint(20) unsigned NOT NULL DEFAULT '0',
                    <code>comment</code> text NOT NULL,
                    <code>comment_by</code> bigint(20) unsigned NOT NULL,
                    <code>created_at</code> datetime NOT NULL,
                    <code>updated_at</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_leave_policies</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>name</code> varchar(20) DEFAULT NULL,
                    <code>value</code> mediumint(5) DEFAULT NULL,
                    <code>color</code> varchar(7) DEFAULT NULL,
                    <code>department</code> int(11) NOT NULL,
                    <code>designation</code> int(11) NOT NULL,
                    <code>gender</code> varchar(50) NOT NULL,
                    <code>marital</code> varchar(50) NOT NULL,
                    <code>description</code> LONGTEXT NOT NULL,
                    <code>location</code> INT(3) NOT NULL,
                    <code>effective_date</code> TIMESTAMP NOT NULL,
                    <code>activate</code> INT(2) NOT NULL,
                    <code>execute_day</code> INT(11) NOT NULL,
                    <code>created_at</code> datetime NOT NULL,
                    <code>updated_at</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_holiday</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>title</code> varchar(200) NOT NULL,
                    <code>start</code> timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                    <code>end</code> timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
                    <code>description</code> text NOT NULL,
                    <code>range_status</code> varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL,
                    <code>created_at</code> datetime NOT NULL,
                    <code>updated_at</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_leave_entitlements</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> bigint(20) unsigned NOT NULL,
                    <code>policy_id</code> int(11) unsigned DEFAULT NULL,
                    <code>days</code> mediumint(4) DEFAULT NULL,
                    <code>from_date</code> datetime NOT NULL,
                    <code>to_date</code> datetime NOT NULL,
                    <code>comments</code> text,
                    <code>status</code> tinyint(2) unsigned NOT NULL,
                    <code>created_by</code> bigint(20) unsigned DEFAULT NULL,
                    <code>created_on</code> datetime NOT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>user_id</code> (<code>user_id</code>),
                    KEY <code>policy_id</code> (<code>policy_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_leaves</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>request_id</code> bigint(20) unsigned NOT NULL,
                    <code>date</code> date NOT NULL,
                    <code>length_hours</code> decimal(6,2) unsigned NOT NULL,
                    <code>length_days</code> decimal(6,2) NOT NULL,
                    <code>start_time</code> time NOT NULL,
                    <code>end_time</code> time NOT NULL,
                    <code>duration_type</code> tinyint(4) unsigned NOT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>request_id</code> (<code>request_id</code>),
                    KEY <code>date</code> (<code>date</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_leave_requests</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> bigint(20) unsigned NOT NULL,
                    <code>policy_id</code> int(11) unsigned NOT NULL,
                    <code>days</code> tinyint(3) unsigned DEFAULT NULL,
                    <code>start_date</code> datetime NOT NULL,
                    <code>end_date</code> datetime NOT NULL,
                    <code>comments</code> text,
                    <code>reason</code> text NOT NULL,
                    <code>status</code> tinyint(2) unsigned DEFAULT NULL,
                    <code>created_by</code> bigint(20) unsigned DEFAULT NULL,
                    <code>updated_by</code> bigint(20) unsigned DEFAULT NULL,
                    <code>created_on</code> datetime NOT NULL,
                    <code>updated_on</code> datetime DEFAULT NULL,
                    <code>last_date</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>user_id</code> (<code>user_id</code>),
                    KEY <code>policy_id</code> (<code>policy_id</code>),
                    KEY <code>status</code> (<code>status</code>),
                    KEY <code>created_by</code> (<code>created_by</code>),
                    KEY <code>updated_by</code> (<code>updated_by</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_work_exp</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>employee_id</code> int(11) DEFAULT NULL,
                    <code>company_name</code> varchar(100) DEFAULT NULL,
                    <code>job_title</code> varchar(100) DEFAULT NULL,
                    <code>from</code> date DEFAULT NULL,
                    <code>to</code> date DEFAULT NULL,
                    <code>description</code> text,
                    <code>created_at</code> datetime DEFAULT NULL,
                    <code>updated_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>employee_id</code> (<code>employee_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_education</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>employee_id</code> int(11) unsigned DEFAULT NULL,
                    <code>school</code> varchar(100) DEFAULT NULL,
                    <code>degree</code> varchar(100) DEFAULT NULL,
                    <code>field</code> varchar(100) DEFAULT NULL,
                    <code>finished</code> int(4) unsigned DEFAULT NULL,
                    <code>notes</code> text,
                    <code>interest</code> text,
                    <code>created_at</code> datetime DEFAULT NULL,
                    <code>updated_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>employee_id</code> (<code>employee_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_dependents</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>employee_id</code> int(11) DEFAULT NULL,
                    <code>name</code> varchar(100) DEFAULT NULL,
                    <code>relation</code> varchar(100) DEFAULT NULL,
                    <code>dob</code> date DEFAULT NULL,
                    <code>created_at</code> datetime DEFAULT NULL,
                    <code>updated_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>employee_id</code> (<code>employee_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_employee_performance</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>employee_id</code> int(11) unsigned DEFAULT NULL,
                    <code>reporting_to</code> int(11) unsigned DEFAULT NULL,
                    <code>job_knowledge</code> varchar(100) DEFAULT NULL,
                    <code>work_quality</code> varchar(100) DEFAULT NULL,
                    <code>attendance</code> varchar(100) DEFAULT NULL,
                    <code>communication</code> varchar(100) DEFAULT NULL,
                    <code>dependablity</code> varchar(100) DEFAULT NULL,
                    <code>reviewer</code> int(11) unsigned DEFAULT NULL,
                    <code>comments</code> text,
                    <code>completion_date</code> datetime DEFAULT NULL,
                    <code>goal_description</code> text,
                    <code>employee_assessment</code> text,
                    <code>supervisor</code> int(11) unsigned DEFAULT NULL,
                    <code>supervisor_assessment</code> text,
                    <code>type</code> text,
                    <code>performance_date</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>employee_id</code> (<code>employee_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_hr_announcement</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> bigint(20) unsigned NOT NULL,
                    <code>post_id</code> bigint(11) NOT NULL,
                    <code>status</code> varchar(30) NOT NULL,
                    <code>email_status</code> varchar(30) NOT NULL,
                    PRIMARY KEY (id),
                    KEY <code>user_id</code> (<code>user_id</code>),
                    KEY <code>post_id</code> (<code>post_id</code>),
                    KEY <code>status</code> (<code>status</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_peoples</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> bigint(20) unsigned DEFAULT '0',
                    <code>first_name</code> varchar(60) DEFAULT NULL,
                    <code>last_name</code> varchar(60) DEFAULT NULL,
                    <code>company</code> varchar(60) DEFAULT NULL,
                    <code>email</code> varchar(100) DEFAULT NULL,
                    <code>phone</code> varchar(20) DEFAULT NULL,
                    <code>mobile</code> varchar(20) DEFAULT NULL,
                    <code>other</code> varchar(50) DEFAULT NULL,
                    <code>website</code> varchar(100) DEFAULT NULL,
                    <code>fax</code> varchar(20) DEFAULT NULL,
                    <code>notes</code> text,
                    <code>street_1</code> varchar(255) DEFAULT NULL,
                    <code>street_2</code> varchar(255) DEFAULT NULL,
                    <code>city</code> varchar(80) DEFAULT NULL,
                    <code>state</code> varchar(50) DEFAULT NULL,
                    <code>postal_code</code> varchar(10) DEFAULT NULL,
                    <code>country</code> varchar(20) DEFAULT NULL,
                    <code>currency</code> varchar(5) DEFAULT NULL,
                    <code>life_stage</code> VARCHAR(100) DEFAULT NULL,
                    <code>contact_owner</code> bigint(20) DEFAULT NULL,
                    <code>hash</code> VARCHAR(40) NULL DEFAULT NULL,
                    <code>created_by</code> BIGINT(20) DEFAULT NULL,
                    <code>created</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>user_id</code> (<code>user_id</code>),
                    KEY <code>first_name</code> (<code>first_name</code>),
                    KEY <code>last_name</code> (<code>last_name</code>),
                    KEY <code>email</code> (<code>email</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_peoplemeta</code> (
                    <code>meta_id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>erp_people_id</code> bigint(20) DEFAULT NULL,
                    <code>meta_key</code> varchar(255) DEFAULT NULL,
                    <code>meta_value</code> longtext,
                    PRIMARY KEY (<code>meta_id</code>),
                    KEY <code>erp_people_id</code> (<code>erp_people_id</code>),
                    KEY <code>meta_key</code> (<code>meta_key</code>(191))
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_people_types</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>name</code> varchar(20) DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    UNIQUE KEY <code>name</code> (<code>name</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_people_type_relations</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>people_id</code> bigint(20) unsigned DEFAULT NULL,
                    <code>people_types_id</code> int(11) unsigned DEFAULT NULL,
                    <code>deleted_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>people_id</code> (<code>people_id</code>),
                    KEY <code>people_types_id</code> (<code>people_types_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_audit_log</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>component</code> varchar(50) NOT NULL DEFAULT '',
                    <code>sub_component</code> varchar(50) NOT NULL DEFAULT '',
                    <code>data_id</code> bigint(20) DEFAULT NULL,
                    <code>old_value</code> longtext,
                    <code>new_value</code> longtext,
                    <code>message</code> longtext,
                    <code>changetype</code> varchar(10) DEFAULT NULL,
                    <code>created_by</code> bigint(20) unsigned DEFAULT NULL,
                    <code>created_at</code> datetime DEFAULT NULL,
                    <code>updated_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>component</code> (<code>component</code>),
                    KEY <code>sub_component</code> (<code>sub_component</code>),
                    KEY <code>changetype</code> (<code>changetype</code>),
                    KEY <code>created_by</code> (<code>created_by</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_crm_customer_companies</code> (
                    <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                    <code>customer_id</code> bigint(20) DEFAULT NULL,
                    <code>company_id</code> bigint(50) DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>customer_id</code> (<code>customer_id</code>),
                    KEY <code>company_id</code> (<code>company_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_crm_customer_activities</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> int(11) DEFAULT NULL,
                    <code>type</code> varchar(255) DEFAULT NULL,
                    <code>message</code> longtext,
                    <code>email_subject</code> text,
                    <code>log_type</code> varchar(255) DEFAULT NULL,
                    <code>start_date</code> datetime DEFAULT NULL,
                    <code>end_date</code> datetime DEFAULT NULL,
                    <code>created_by</code> int(11) DEFAULT NULL,
                    <code>extra</code> longtext,
                    <code>sent_notification</code> tinyint(4) DEFAULT '0',
                    <code>created_at</code> datetime DEFAULT NULL,
                    <code>updated_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>user_id</code> (<code>user_id</code>),
                    KEY <code>type</code> (<code>type</code>),
                    KEY <code>log_type</code> (<code>log_type</code>),
                    KEY <code>created_by</code> (<code>created_by</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_crm_activities_task</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>activity_id</code> int(11) DEFAULT NULL,
                    <code>user_id</code> int(11) DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    KEY <code>activity_id</code> (<code>activity_id</code>),
                    KEY <code>user_id</code> (<code>user_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_crm_contact_group</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>name</code> varchar(255) DEFAULT NULL,
                    <code>description</code> text,
                    <code>private</code> TINYINT(1) DEFAULT NULL,
                    <code>created_at</code> datetime DEFAULT NULL,
                    <code>updated_at</code> datetime DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_crm_contact_subscriber</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>user_id</code> int(11) DEFAULT NULL,
                    <code>group_id</code> int(11) DEFAULT NULL,
                    <code>status</code> varchar(25) DEFAULT NULL,
                    <code>subscribe_at</code> datetime DEFAULT NULL,
                    <code>unsubscribe_at</code> datetime DEFAULT NULL,
                    <code>hash</code> VARCHAR(40) NULL DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>),
                    UNIQUE KEY <code>user_group</code> (<code>user_id</code>,<code>group_id</code>),
                    KEY <code>status</code> (<code>status</code>),
                    KEY <code>hash</code> (<code>hash</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_crm_save_search</code> (
                  <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                  <code>user_id</code> int(11) DEFAULT NULL,
                  <code>type</code> VARCHAR(255) DEFAULT NULL,
                  <code>global</code> tinyint(4) DEFAULT '0',
                  <code>search_name</code> text,
                  <code>search_val</code> text,
                  <code>created_at</code> datetime DEFAULT NULL,
                  <code>updated_at</code> datetime DEFAULT NULL,
                  PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_crm_save_email_replies</code> (
                  <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                  <code>name</code> text,
                  <code>subject</code> text,
                  <code>template</code> longtext,
                  PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_chart_classes</code> (
                    <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                    <code>name</code> varchar(100) DEFAULT NULL,
                    PRIMARY KEY (<code>id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_chart_types</code> (
                  <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                  <code>name</code> varchar(60) NOT NULL DEFAULT '',
                  <code>class_id</code> tinyint(3) NOT NULL,
                  PRIMARY KEY (<code>id</code>),
                  KEY <code>class_id</code> (<code>class_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_journals</code> (
                  <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                  <code>ledger_id</code> int(11) unsigned NOT NULL,
                  <code>transaction_id</code> bigint(20) unsigned NOT NULL,
                  <code>type</code> varchar(20) DEFAULT NULL,
                  <code>debit</code> DECIMAL(13,4) unsigned DEFAULT NULL,
                  <code>credit</code> DECIMAL(13,4) unsigned DEFAULT NULL,
                  PRIMARY KEY (<code>id</code>),
                  KEY <code>ledger_id</code> (<code>ledger_id</code>),
                  KEY <code>transaction_id</code> (<code>transaction_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_ledger</code> (
                  <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                  <code>code</code> varchar(10) DEFAULT NULL,
                  <code>name</code> varchar(100) DEFAULT NULL,
                  <code>description</code> text,
                  <code>parent</code> int(11) unsigned NOT NULL DEFAULT '0',
                  <code>type_id</code> int(3) unsigned NOT NULL DEFAULT '0',
                  <code>currency</code> varchar(10) DEFAULT '',
                  <code>tax</code> bigint(20) DEFAULT NULL,
                  <code>cash_account</code> tinyint(2) unsigned NOT NULL DEFAULT '0',
                  <code>reconcile</code> tinyint(2) unsigned NOT NULL DEFAULT '0',
                  <code>system</code> tinyint(2) unsigned NOT NULL DEFAULT '0',
                  <code>active</code> tinyint(2) unsigned NOT NULL DEFAULT '1',
                  <code>created_by</code> bigint(20) DEFAULT 0,
                  PRIMARY KEY (<code>id</code>),
                  KEY <code>code</code> (<code>code</code>),
                  KEY <code>type_id</code> (<code>type_id</code>),
                  KEY <code>parent</code> (<code>parent</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_banks</code> (
                  <code>id</code> int(11) unsigned NOT NULL AUTO_INCREMENT,
                  <code>ledger_id</code> int(10) unsigned DEFAULT NULL,
                  <code>account_number</code> varchar(20) DEFAULT NULL,
                  <code>bank_name</code> varchar(30) DEFAULT NULL,
                  PRIMARY KEY (<code>id</code>),
                  KEY <code>ledger_id</code> (<code>ledger_id</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_transactions</code> (
                  <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                  <code>type</code> varchar(10) DEFAULT NULL,
                  <code>form_type</code> varchar(20) DEFAULT NULL,
                  <code>status</code> varchar(20) DEFAULT NULL,
                  <code>user_id</code> bigint(20) unsigned DEFAULT NULL,
                  <code>billing_address</code> tinytext,
                  <code>ref</code> varchar(50) DEFAULT NULL,
                  <code>summary</code> text,
                  <code>issue_date</code> date DEFAULT NULL,
                  <code>due_date</code> date DEFAULT NULL,
                  <code>currency</code> varchar(10) DEFAULT NULL,
                  <code>conversion_rate</code> decimal(2,2) unsigned DEFAULT NULL,
                  <code>sub_total</code> DECIMAL(13,4) DEFAULT '0.00',
                  <code>total</code> DECIMAL(13,4) DEFAULT '0.00',
                  <code>due</code> DECIMAL(13,4) unsigned DEFAULT '0.00',
                  <code>trans_total</code> DECIMAL(13,4) DEFAULT '0.00',
                  <code>invoice_number</code> INT(10) UNSIGNED NULL DEFAULT '0',
                  <code>invoice_format</code> VARCHAR(20) NOT NULL,
                  <code>files</code> varchar(255) DEFAULT NULL,
                  <code>parent</code> bigint(20) unsigned NOT NULL DEFAULT '0',
                  <code>created_by</code> int(11) unsigned DEFAULT NULL,
                  <code>created_at</code> datetime DEFAULT NULL,
                  PRIMARY KEY (<code>id</code>),
                  KEY <code>user_id</code> (<code>user_id</code>),
                  KEY <code>type</code> (<code>type</code>),
                  KEY <code>status</code> (<code>status</code>),
                  KEY <code>issue_date</code> (<code>issue_date</code>)
                ) $collate;",
    
                "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_transaction_items</code> (
                  <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                  <code>transaction_id</code> bigint(20) unsigned DEFAULT NULL,
                  <code>journal_id</code> bigint(20) unsigned DEFAULT NULL,
                  <code>product_id</code> int(10) unsigned DEFAULT NULL,
                  <code>description</code> text,
                  <code>qty</code> DECIMAL(10,2) unsigned NOT NULL DEFAULT '1',
                  <code>unit_price</code> DECIMAL(13,4) unsigned NOT NULL DEFAULT '0.00',
                  <code>discount</code> tinyint(3) unsigned NOT NULL DEFAULT '0',
                  <code>tax</code> tinyint(3) unsigned NOT NULL DEFAULT '0',
                  <code>tax_rate</code> DECIMAL(13,4) NOT NULL,
                  <code>tax_journal</code> BIGINT(20) NOT NULL,
                  <code>line_total</code> DECIMAL(13,4) unsigned NOT NULL DEFAULT '0.00',
                  <code>order</code> tinyint(3) unsigned NOT NULL DEFAULT '0',
                  PRIMARY KEY (<code>id</code>),
                  KEY <code>transaction_id</code> (<code>transaction_id</code>),
                  KEY <code>journal_id</code> (<code>journal_id</code>),
                  KEY <code>product_id</code> (<code>product_id</code>)
                ) $collate;",
    
              "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_payments</code> (
                <code>id</code> bigint(20) NOT NULL AUTO_INCREMENT,
                <code>transaction_id</code> int(11) NOT NULL,
                <code>parent</code> int(11) NOT NULL,
                <code>child</code> int(11) NOT NULL,
                PRIMARY KEY (<code>id</code>)
              ) $collate;",
    
              "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_tax</code> (
                <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                <code>name</code> varchar(255) DEFAULT NULL,
                <code>tax_number</code> varchar(255) DEFAULT NULL,
                <code>is_compound</code> varchar(5) DEFAULT NULL,
                <code>created_by</code> bigint(20) unsigned NOT NULL,
                 PRIMARY KEY (<code>id</code>)
              ) $collate;",
    
              "CREATE TABLE IF NOT EXISTS <code>{$wpdb->prefix}erp_ac_tax_items</code> (
                <code>id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                <code>tax_id</code> bigint(20) NOT NULL,
                <code>component_name</code> varchar(255) DEFAULT NULL,
                <code>agency_name</code> varchar(255) DEFAULT NULL,
                <code>tax_rate</code> float NOT NULL,
                PRIMARY KEY (<code>id</code>)
              ) $collate;",
    
            ];
    
            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
            foreach ( $table_schema as $table ) {
                dbDelta( $table );
            }
    
        }
    
        /**
         * Populate tables with initial data
         *
         * @return void
         */
        public function populate_data() {
            global $wpdb;
    
            // check if people_types exists
            if ( ! $wpdb->get_var( "SELECT id FROM <code>{$wpdb->prefix}erp_people_types</code> LIMIT 0, 1" ) ) {
                $sql = "INSERT INTO <code>{$wpdb->prefix}erp_people_types</code> (<code>id</code>, <code>name</code>)
                        VALUES (1,'contact'), (2,'company'), (3,'customer'), (4,'vendor');";
    
                $wpdb->query( $sql );
            }
    
            //Accounting
    
            // check if classes exists
            if ( ! $wpdb->get_var( "SELECT id FROM <code>{$wpdb->prefix}erp_ac_chart_classes</code> LIMIT 0, 1" ) ) {
                $sql = "INSERT INTO <code>{$wpdb->prefix}erp_ac_chart_classes</code> (<code>id</code>, <code>name</code>)
                        VALUES (1,'Assets'), (2,'Liabilities'), (3,'Expenses'), (4,'Income'), (5,'Equity');";
    
                $wpdb->query( $sql );
            }
    
            // check if chart types exists
            if ( ! $wpdb->get_var( "SELECT id FROM <code>{$wpdb->prefix}erp_ac_chart_types</code> LIMIT 0, 1" ) ) {
                $sql = "INSERT INTO <code>{$wpdb->prefix}erp_ac_chart_types</code> (<code>id</code>, <code>name</code>, <code>class_id</code>)
                        VALUES (1,'Current Asset',1), (2,'Fixed Asset',1), (3,'Inventory',1),
                            (4,'Non-current Asset',1), (5,'Prepayment',1), (6,'Bank & Cash',1), (7,'Current Liability',2),
                            (8,'Liability',2), (9,'Non-current Liability',2), (10,'Depreciation',3),
                            (11,'Direct Costs',3), (12,'Expense',3), (13,'Revenue',4), (14,'Sales',4),
                            (15,'Other Income',4), (16,'Equity',5);";
    
                $wpdb->query( $sql );
            }
    
            // check if ledger exists
            if ( ! $wpdb->get_var( "SELECT id FROM <code>{$wpdb->prefix}erp_ac_ledger</code> LIMIT 0, 1" ) ) {
    
                $sql = "INSERT INTO <code>{$wpdb->prefix}erp_ac_ledger</code> (<code>id</code>, <code>code</code>, <code>name</code>, <code>description</code>, <code>parent</code>, <code>type_id</code>, <code>currency</code>, <code>tax</code>, <code>cash_account</code>, <code>reconcile</code>, <code>system</code>, <code>active</code>)
                            VALUES
                            (1,'120','Accounts Receivable',NULL,0,1,'',NULL,0,0,1,1),
                            (2,'140','Inventory',NULL,0,3,'',NULL,0,0,1,1),
                            (3,'150','Office Equipment',NULL,0,2,'',NULL,0,0,1,1),
                            (4,'151','Less Accumulated Depreciation on Office Equipment',NULL,0,2,'',NULL,0,0,1,1),
                            (5,'160','Computer Equipment',NULL,0,2,'',NULL,0,0,1,1),
                            (6,'161','Less Accumulated Depreciation on Computer Equipment',NULL,0,2,'',NULL,0,0,1,1),
                            (7,'090','Petty Cash',NULL,0,6,'',NULL,1,1,0,1),
                            (8,'200','Accounts Payable',NULL,0,7,'',NULL,0,0,1,1),
                            (9,'205','Accruals',NULL,0,7,'',NULL,0,0,0,1),
                            (10,'210','Unpaid Expense Claims',NULL,0,7,'',NULL,0,0,1,1),
                            (11,'215','Wages Payable',NULL,0,7,'',NULL,0,0,1,1),
                            (12,'216','Wages Payable - Payroll',NULL,0,7,'',NULL,0,0,0,1),
                            (13,'220','Sales Tax',NULL,0,7,'',NULL,0,0,1,1),
                            (14,'230','Employee Tax Payable',NULL,0,7,'',NULL,0,0,0,1),
                            (15,'235','Employee Benefits Payable',NULL,0,7,'',NULL,0,0,0,1),
                            (16,'236','Employee Deductions payable',NULL,0,7,'',NULL,0,0,0,1),
                            (17,'240','Income Tax Payable',NULL,0,7,'',NULL,0,0,0,1),
                            (18,'250','Suspense',NULL,0,7,'',NULL,0,0,0,1),
                            (19,'255','Historical Adjustments',NULL,0,7,'',NULL,0,0,1,1),
                            (20,'260','Rounding',NULL,0,7,'',NULL,0,0,1,1),
                            (21,'835','Revenue Received in Advance',NULL,0,7,'',NULL,0,0,0,1),
                            (22,'855','Clearing Account',NULL,0,7,'',NULL,0,0,0,1),
                            (23,'290','Loan',NULL,0,9,'',NULL,0,0,0,1),
                            (24,'500','Costs of Goods Sold',NULL,0,11,'',NULL,0,0,1,1),
                            (25,'600','Advertising',NULL,0,12,'',NULL,0,0,0,1),
                            (26,'605','Bank Service Charges',NULL,0,12,'',NULL,0,0,0,1),
                            (27,'610','Janitorial Expenses',NULL,0,12,'',NULL,0,0,0,1),
                            (28,'615','Consulting & Accounting',NULL,0,12,'',NULL,0,0,0,1),
                            (29,'620','Entertainment',NULL,0,12,'',NULL,0,0,0,1),
                            (30,'624','Postage & Delivary',NULL,0,12,'',NULL,0,0,0,1),
                            (31,'628','General Expenses',NULL,0,12,'',NULL,0,0,0,1),
                            (32,'632','Insurance',NULL,0,12,'',NULL,0,0,0,1),
                            (33,'636','Legal Expenses',NULL,0,12,'',NULL,0,0,0,1),
                            (34,'640','Utilities',NULL,0,12,'',NULL,0,0,1,1),
                            (35,'644','Automobile Expenses',NULL,0,12,'',NULL,0,0,0,1),
                            (36,'648','Office Expenses',NULL,0,12,'',NULL,0,0,1,1),
                            (37,'652','Printing & Stationary',NULL,0,12,'',NULL,0,0,0,1),
                            (38,'656','Rent',NULL,0,12,'',NULL,0,0,1,1),
                            (39,'660','Repairs & Maintenance',NULL,0,12,'',NULL,0,0,0,1),
                            (40,'664','Wages & Salaries',NULL,0,12,'',NULL,0,0,0,1),
                            (41,'668','Payroll Tax Expense',NULL,0,12,'',NULL,0,0,0,1),
                            (42,'672','Dues & Subscriptions',NULL,0,12,'',NULL,0,0,0,1),
                            (43,'676','Telephone & Internet',NULL,0,12,'',NULL,0,0,0,1),
                            (44,'680','Travel',NULL,0,12,'',NULL,0,0,0,1),
                            (45,'684','Bad Debts',NULL,0,12,'',NULL,0,0,0,1),
                            (46,'700','Depreciation',NULL,0,10,'',NULL,0,0,1,1),
                            (47,'710','Income Tax Expense',NULL,0,12,'',NULL,0,0,0,1),
                            (48,'715','Employee Benefits Expense',NULL,0,12,'',NULL,0,0,0,1),
                            (49,'800','Interest Expense',NULL,0,12,'',NULL,0,0,0,1),
                            (50,'810','Bank Revaluations',NULL,0,12,'',NULL,0,0,1,1),
                            (51,'815','Unrealized Currency Gains',NULL,0,12,'',NULL,0,0,1,1),
                            (52,'820','Realized Currency Gains',NULL,0,12,'',NULL,0,0,1,1),
                            (53,'825','Sales Discount',NULL,0,12,'',NULL,0,0,1,1),
                            (54,'400','Sales',NULL,0,13,'',NULL,0,0,0,1),
                            (55,'460','Interest Income',NULL,0,13,'',NULL,0,0,0,1),
                            (56,'470','Other Revenue',NULL,0,13,'',NULL,0,0,0,1),
                            (57,'475','Purchase Discount',NULL,0,13,'',NULL,0,0,1,1),
                            (58,'300','Owners Contribution',NULL,0,16,'',NULL,0,0,0,1),
                            (59,'310','Owners Draw',NULL,0,16,'',NULL,0,0,0,1),
                            (60,'320','Retained Earnings',NULL,0,16,'',NULL,0,0,1,1),
                            (61,'330','Common Stock',NULL,0,16,'',NULL,0,0,0,1),
                            (62,'092','Savings Account',NULL,0,6,'',NULL,1,1,0,1);";
    
                $wpdb->query( $sql );
            }
    
            // check if banks exists
            if ( ! $wpdb->get_var( "SELECT id FROM <code>{$wpdb->prefix}erp_ac_banks</code> LIMIT 0, 1" ) ) {
                $sql = "INSERT INTO <code>{$wpdb->prefix}erp_ac_banks</code> (<code>id</code>, <code>ledger_id</code>, <code>account_number</code>, <code>bank_name</code>)
                        VALUES  (1,7,'',''), (2,62,'012345689','ABC Bank');";
    
                $wpdb->query( $sql );
            }
    
            // Subscription pages
            $subscription_settings = get_option( 'erp_settings_erp-crm_subscription', [] );
    
            if ( empty( $subscription_settings ) ) {
                // insert default erp subscription form settings
                $args = [
                    'post_title' => __( 'ERP Subscription', 'erp' ),
                    'post_content' => '',
                    'post_status' => 'publish',
                    'post_type' => 'page',
                    'comment_status' => 'closed',
                    'ping_status' => 'closed',
                ];
    
                $page_id = wp_insert_post( $args );
    
                $settings = [
                    'is_enabled'            => 'yes',
                    'email_subject'         => sprintf( __( 'Confirm your subscription to %s', 'erp' ), get_bloginfo( 'name' ) ),
                    'email_content'         => sprintf(
                        __( "Hello!\n\nThanks so much for signing up for our newsletter.\nWe need you to activate your subscription to the list(s): [contact_groups_to_confirm] by clicking the link below: \n\n[activation_link]Click here to confirm your subscription.[/activation_link]\n\nThank you,\n\n%s", 'erp' ),
                        get_bloginfo( 'name' )
                    ),
                    'page_id'               => $page_id,
                    'confirm_page_title'    => __( 'You are now subscribed!', 'erp' ),
                    'confirm_page_content'  => __( "We've added you to our email list. You'll hear from us shortly.", 'erp' ),
                    'unsubs_page_title'     => __( 'You are now unsubscribed', 'erp' ),
                    'unsubs_page_content'   => __( 'You are successfully unsubscribed from list(s):', 'erp' ),
                ];
    
                update_option( 'erp_settings_erp-crm_subscription', $settings );
            }
        }
    
        /**
         * Set default module for initial erp setup
         *
         * @since 1.0
         *
         * @return void
         */
        public function set_default_modules() {
    
            if ( get_option( 'wp_erp_version' ) ) {
                return ;
            }
    
            $default = [
                'hrm' => [
                    'title'       => __( 'HR Management', 'erp' ),
                    'slug'        => 'erp-hrm',
                    'description' => __( 'Human Resource Mnanagement', 'erp' ),
                    'callback'    => '\WeDevs\ERP\HRM\Human_Resource',
                    'modules'     => apply_filters( 'erp_hr_modules', [ ] )
                ],
    
                'crm' => [
                    'title'       => __( 'CR Management', 'erp' ),
                    'slug'        => 'erp-crm',
                    'description' => __( 'Client Resource Management', 'erp' ),
                    'callback'    => '\WeDevs\ERP\CRM\Customer_Relationship',
                    'modules'     => apply_filters( 'erp_crm_modules', [ ] )
                ],
    
                'accounting' => [
                    'title'       => __( 'Accountig Management', 'erp' ),
                    'slug'        => 'erp-accounting',
                    'description' => __( 'Accountig Management', 'erp' ),
                    'callback'    => '\WeDevs\ERP\Accounting\Accountig',
                    'modules'     => apply_filters( 'erp_accounting_modules', [ ] )
                ]
            ];
    
            update_option( 'erp_modules', $default );
        }
    
        /**
         * Create user roles and capabilities
         *
         * @since 1.0
         *
         * @return void
         */
        public function create_roles() {
            $this->includes();
    
            $roles_hr = erp_hr_get_roles();
    
            if ( $roles_hr ) {
                foreach ($roles_hr as $key => $role) {
                    add_role( $key, $role['name'], $role['capabilities'] );
                }
            }
    
            $roles_crm = erp_crm_get_roles();
    
            if ( $roles_crm ) {
                foreach ($roles_crm as $key => $role) {
                    add_role( $key, $role['name'], $role['capabilities'] );
                }
            }
    
            $roles_ac = erp_ac_get_roles();
    
            if ( $roles_ac ) {
                foreach ($roles_ac as $key => $role) {
                    add_role( $key, $role['name'], $role['capabilities'] );
                }
            }
        }
    
        /**
         * Set erp_hr_manager role for admin user
         *
         * @since 1.0
         *
         * @return void
         */
        public function set_role() {
            $this->includes();
    
            $admins = get_users( array( 'role' => 'administrator' ) );
    
            if ( $admins ) {
                foreach ($admins as $user) {
                    $user->add_role( erp_hr_get_manager_role() );
                    $user->add_role( erp_crm_get_manager_role() );
                    $user->add_role( erp_ac_get_manager_role() );
                }
            }
        }
    }
    
    new WeDevs_ERP_Installer();
    

    This should work 🙂

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘task template tags for email notifications’ is closed to new replies.