public function admin_scripts($hook) { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_media(); wp_enqueue_style('erp-tiptip'); wp_enqueue_script('erp-tiptip'); wp_enqueue_script('wp-erp-crm', WPERP_CRM_ASSETS . "/js/crm{$suffix}.js", array('wp-erp-script', 'erp-admin-timepicker'), date('Ymd'), true); $localize_script = apply_filters('erp_crm_localize_script', array('nonce' => wp_create_nonce('wp-erp-crm-nonce'), 'popup' => array('customer_title' => __('Add New Customer', 'wp-erp'), 'customer_update_title' => __('Edit Customer', 'wp-erp'), 'customer_social_title' => __('Customer Social Profile', 'wp-erp'), 'customer_assing_group' => __('Add to Contact groups', 'wp-erp')), 'add_submit' => __('Add New', 'wp-erp'), 'update_submit' => __('Update', 'wp-erp'), 'save_submit' => __('Save', 'wp-erp'), 'customer_upload_photo' => __('Upload Photo', 'wp-erp'), 'customer_set_photo' => __('Set Photo', 'wp-erp'), 'confirm' => __('Are you sure?', 'wp-erp'), 'delConfirmCustomer' => __('Are you sure to delete this customer?', 'wp-erp'), 'delConfirm' => __('Are you sure to delete this?', 'wp-erp'), 'checkedConfirm' => __('Alteast one item must be checked', 'wp-erp'), 'contact_filter' => erp_crm_get_serach_key())); // if it's an customer page if ('crm_page_erp-sales-customers' == $hook || 'crm_page_erp-sales-companies' == $hook) { wp_enqueue_style('erp-admin-timepicker'); wp_enqueue_script('erp-admin-timepicker'); wp_enqueue_script('erp-vuejs'); wp_enqueue_script('erp-trix-editor'); wp_enqueue_style('erp-trix-editor'); wp_enqueue_script('underscore'); wp_enqueue_style('wp-erp-nprogress', WPERP_CRM_ASSETS . '/css/nprogress.css'); wp_enqueue_script('wp-erp-nprogress', WPERP_CRM_ASSETS . "/js/nprogress{$suffix}.js", array('jquery'), date('Ymd'), true); wp_enqueue_script('wp-erp-crm-vue-customer', WPERP_CRM_ASSETS . "/js/crm-app{$suffix}.js", array('wp-erp-nprogress', 'wp-erp-script', 'erp-vuejs', 'underscore', 'erp-select2', 'erp-tiptip'), date('Ymd'), true); wp_enqueue_script('wp-erp-crm-vue-save-search', WPERP_CRM_ASSETS . "/js/save-search{$suffix}.js", array('wp-erp-script', 'erp-vuejs', 'underscore', 'erp-select2', 'erp-tiptip'), date('Ymd'), true); wp_enqueue_script('post'); $customer = new Contact(); $country = \WeDevs\ERP\Countries::instance(); wp_localize_script('wp-erp-crm-vue-customer', 'wpCRMvue', ['ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('wp-erp-crm-customer-feed'), 'current_user_id' => get_current_user_id(), 'confirm' => __('Are you sure?', 'wp-erp'), 'date_format' => get_option('date_format')]); wp_localize_script('wp-erp-crm-vue-save-search', 'wpCRMSaveSearch', ['ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('wp-erp-crm-save-search'), 'searchFields' => erp_crm_get_serach_key()]); $localize_script['customer_empty'] = $customer->to_array(); $localize_script['wpErpCountries'] = $country->load_country_states(); } wp_localize_script('wp-erp-crm', 'wpErpCrm', $localize_script); }
/** * Get customer details * * @since 1.0 * * @return array */ public function customer_get() { $this->verify_nonce('wp-erp-crm-nonce'); $customer_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $customer = new Contact($customer_id); if (!$customer_id || !$customer) { $this->send_error(__('Cotact does not exists.', 'wp-erp')); } $this->send_success($customer->to_array()); }