<?php /* 
Plugin Name: Zero BS CRM
Plugin URI: http://zerobscrm.com
Description: Zero BS CRM is the simplest CRM for WordPress. Self host your own Customer Relationship Manager using WP.
Version: 2.0.3
Author: <a href="https://zerobscrm.com">Zero BS CRM</a>
*/





if ( ! defined( 'ABSPATH' ) ) exit;


if (version_compare(phpversion(), '5.4', '<')) {
    
        echo '<div style="font-family: \'Open Sans\',sans-serif;">Zero BS CRM Requires PHP Version 5.4 or above, please ask web hosting provider to update your PHP!</div>';
	exit();	

}








            register_deactivation_hook(__FILE__,'zeroBSCRM_uninstall');

        register_activation_hook(__FILE__,'zeroBSCRM_wizard');

        register_activation_hook(__FILE__,'zeroBSCRM_database_check');
    
    	add_action('init', 			'zeroBSCRM_init');

		add_action('admin_init', 			'zeroBSCRM_admin_init');

	    add_action('admin_menu', 	'zeroBSCRM_admin_menu'); 









	#} Initial Vars
	global 	$zeroBSCRM_db_version,$zeroBSCRM_version;
			$zeroBSCRM_db_version 			= "1.2";
			$zeroBSCRM_version 				= "2.0.3";
			$zeroBSCRM_helpEmail			= 'hello@zerobscrm.com';

	#} Urls
	global 	$zeroBSCRM_urls;
			$zeroBSCRM_urls['home'] 				= 'http://zerobscrm.com';
			$zeroBSCRM_urls['support']				= 'mailto:'.$zeroBSCRM_helpEmail;
			$zeroBSCRM_urls['feedback']				= 'mailto:feedback@zbscrm.com';
			$zeroBSCRM_urls['docs'] 				= 'http://docs.zerobscrm.com/documentation/';
			$zeroBSCRM_urls['productsdatatools'] 	= 'http://zerobscrm.com/data-tools/'; 
			$zeroBSCRM_urls['smm']					= 'http://demo.zbscrm.com/_o/smm.php';
			$zeroBSCRM_urls['extimgrepo']			= 'http://demo.zbscrm.com/_i/';
			$zeroBSCRM_urls['rateuswporg']			= 'https://wordpress.org/support/view/plugin-reviews/zero-bs-crm?filter=5#postform';
			$zeroBSCRM_urls['extdlrepo']			= 'http://demo.zbscrm.com/_ext/';

						$zeroBSCRM_urls['products'] 			= 'http://zerobscrm.com/extensions/'; 
			$zeroBSCRM_urls['extcsvimporterpro']	= 'https://zerobscrm.com/product/csv-importer-pro/';
			$zeroBSCRM_urls['limitedlaunch']		= 'https://zerobscrm.com/zero-bs-crm-version-2-0-is-here/';

	#} Page slugs
	global	$zeroBSCRM_slugs;
			$zeroBSCRM_slugs['dash'] 			= "zerobscrm-dash";
			$zeroBSCRM_slugs['home'] 			= "zerobscrm-plugin";
			$zeroBSCRM_slugs['app'] 			= "zerobscrm-app";
			$zeroBSCRM_slugs['settings'] 		= "zerobscrm-plugin-settings";
			$zeroBSCRM_slugs['whlang']			= "zerobscrm-whlang";
			$zeroBSCRM_slugs['customfields']	= "zerobscrm-customfields";
			$zeroBSCRM_slugs['logout']			= "zerobscrm-logout";
			$zeroBSCRM_slugs['sync']			= "zerobscrm-sync";
			$zeroBSCRM_slugs['datatools']		= "zerobscrm-datatools";
			$zeroBSCRM_slugs['welcome']			= "zerobscrm-welcome";
			$zeroBSCRM_slugs['feedback']		= "zerobscrm-feedback";
			$zeroBSCRM_slugs['extensions']		= "zerobscrm-extensions";
			$zeroBSCRM_slugs['bulktools']		= "zerobscrm-bulktools";
			$zeroBSCRM_slugs['import']			= "zerobscrm-import";
			$zeroBSCRM_slugs['export']			= "zerobscrm-export";
			$zeroBSCRM_slugs['systemstatus']	= "zerobscrm-systemstatus";
			
	

	#} Lang integration
			global $whLangsupport;
		   $whLangsupport['zerobscrm'] = 'zeroBSCRM_Settings'; 
	#} Currencies & countries
	global 	$zeroBSCRM__currencylist;

	#} Integrations - External Sources
		global 	$zbscrmApprovedExternalSources;
			$zbscrmApprovedExternalSources = array(
												'woo' => array('WooCommerce','ico'=>'fa-shopping-cart'), 				'pay' => array('PayPal','ico'=>'fa-paypal'),
				'env' => array('Envato','ico'=>'fa-envira'), 				'csv' => array('CSV Import','ico'=>'file-text'),
				'form' => array('Form Capture', 'ico' => 'fa-wpforms'),
				'jvz' => array('JV Zoo','ico'=>'fa-paypal'),
				'gra' => array('Gravity Forms', 'ico' => 'fa-wpforms'),
				'api' => array('API', 'ico' => 'fa-random')
			);

	#}  Integrations
		global 	$zeroBSCRM_extensionsInstalledList; $zeroBSCRM_extensionsInstalledList = array();

	#} A list of applicable Mimetypes for file uploads
	global 	$zeroBSCRM_Mimes; $zeroBSCRM_Mimes = array();



	#} Define Paths
	define( 'ZEROBSCRM_PATH', plugin_dir_path(__FILE__) );
	define( 'ZEROBSCRM_URL', plugin_dir_url(__FILE__) );
		define( 'ZEROBSCRM_WILDPATH', plugin_dir_path(__FILE__).'wild/' ); 	define( 'ZEROBSCRM_WILDURL', plugin_dir_url(__FILE__).'wild/' ); 
		define ('ZBS_MENU_FULL', 1);
	define ('ZBS_MENU_SLIM', 2);
	define ('ZBS_MENU_CRMONLY', 3);

		define('ZBS_ROOTFILE',__FILE__);








	#} Required includes
	
   		if(!defined('ZBSCRM_INC_GENFUNC')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.GeneralFuncs.php');
	if(!defined('ZBSCRM_INC_CONFINIT')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Config.Init.php');
	if(!class_exists('WHWPConfigLib')) require_once(ZEROBSCRM_PATH . 'includes/wh.config.lib.php');
	if(!defined('ZBSCRM_INC_DAL')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.DAL.php');
	if(!defined('ZBSCRM_INC_DATAVAL')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.DataValidation.php');
	if(!defined('ZBSCRM_INC_DB')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Database.php');
	if(!defined('ZBSCRM_INC_ADMSTY')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.AdminStyling.php');
	if(!defined('ZBSCRM_INC_ADMPGS')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.AdminPages.php');
	if(!defined('ZBSCRM_INC_MIGRATIONS')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Migrations.php');
	if(!defined('ZBSCRMEXTLISTINC')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Core.Extensions.php');
	if(!defined('ZBSCRM_INC_FIELDS')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Fields.php');
	if(!defined('ZBSCRM_INC_PERMS')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Permissions.php');
	if(!defined('ZBSCRM_INC_CPT')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.CPTs.php');
	if(!defined('ZBSCRM_INC_INVENTORY')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Inventory.php');
	if(!defined('ZBSCRM_INC_REWRITERULES')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.ReWriteRules.php');
	if(!defined('ZBSCRM_INC_TEMPLATING')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Templating.php');
	if(!function_exists('_whLangLibSupport')) require_once(ZEROBSCRM_PATH . 'includes/wh.langsupport.lib.php');
	if(!defined('ZBSCRM_INC_IA')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.InternalAutomator.php');
	if(!defined('ZBSCRM_INC_CRON')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.CRON.php');
	if(!defined('ZBSCRM_INC_CUSTOMER_SEARCH')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.CustomerSearch.php');


		if(!class_exists('zeroBS__Metabox')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.Customers.php');
	if(!class_exists('zeroBS__MetaboxQuote')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.Quotes.php');
	if(!class_exists('zeroBS__MetaboxInvoice')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.Invoices.php');
	if(!class_exists('zeroBS__ExternalSourceMetabox')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.ExternalSources.php');
	if(!class_exists('zeroBS__Metabox_Companies')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.Companies.php');
	if(!defined('ZBSCRM_INC_TRANSMB')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.Transactions.php');
	if(!defined('ZBSCRM_INC_LOGSMB')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.Logs.php');
	if(!defined('ZBSCRM_INC_FORMSMB')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.MetaBoxes.Forms.php');
			
		if(!defined('ZBSCRM_INC_AJAX')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.AJAX.php');
	if(!defined('ZBSCRM_INC_WYSIWYG')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.WYSIWYGButtons.php');
	if(!defined('ZBSCRM_INC_CUSTFILT')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.CustomerFilters.php');
	if(!defined('ZBSCRM_INC_WELCOMEWIZ')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.WelcomeWizard.php');
	if(!defined('ZBSCRM_INC_IARECIPES')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.InternalAutomatorRecipes.php');
	if(!defined('ZBSCRM_INC_FILEUPL')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.FileUploads.php');
	if(!defined('ZBSCRM_INC_FORMS')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Forms.php');
	if(!defined('ZBSCRM_INC_INVBUILDER')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.InvoiceBuilder.php');
	if(!defined('ZBSCRM_INC_EXPORT')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Export.php');
	if(!defined('ZBSCRM_INC_SYSCHECK')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.SystemChecks.php');
	if(!defined('ZBSCRM_INC_INTEGRATE')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.IntegrationFuncs.php');
	if(!defined('ZBSCRM_INC_TRANSINSP')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.TransactionInspector.php');
	
		if(!class_exists('zeroBSCRM_Customer_List')) require_once(ZEROBSCRM_PATH  . 'includes/ZeroBSCRM.List.Customers.php');
	if(!class_exists('zeroBSCRM_Company_List')) require_once(ZEROBSCRM_PATH  . 'includes/ZeroBSCRM.List.Companies.php');
	if(!class_exists('zeroBSCRM_CustomerNoQJ_List')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.List.CustomesWithoutQJ.php');
	if(!class_exists('zeroBSCRM_Quote_List')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.List.Quotes.php');
	if(!class_exists('zeroBSCRM_Invoice_List')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.List.Invoices.php');
	if(!class_exists('zeroBSCRM_Transaction_List')) require_once(ZEROBSCRM_PATH  . 'includes/ZeroBSCRM.List.Transactions.php');









	#} Initialise Config Model
		global $zeroBSCRM_Settings, $zeroBSCRM_Conf_Setup;
	if (!isset($zeroBSCRM_Settings)) $zeroBSCRM_Settings = new WHWPConfigLib($zeroBSCRM_Conf_Setup);

	#} Unpack Custom Fields + Apply sorts
	zeroBSCRM_unpackCustomFields();
	zeroBSCRM_unpackCustomisationsToFields(); 
	if (1 == 1){ 		zeroBSCRM_applyFieldSorts();
	}

	










      function zeroBSCRM_PostInitIncludes(){

	   	
				
   		   				if (!zeroBSCRM_isExtensionInstalled('csvimporter') && zeroBSCRM_isExtensionInstalled('csvimporterlite') && !defined('ZBSCRM_INC_CSVIMPORTERLITE')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.CSVImporter.php');

				if(zeroBSCRM_isExtensionInstalled('portal') && !defined('ZBSCRM_INC_PORTAL')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.Portal.php');

				if(zeroBSCRM_isExtensionInstalled('api') && !defined('ZBSCRM_INC_API')) require_once(ZEROBSCRM_PATH . 'includes/ZeroBSCRM.API.php');

	}












add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'zeroBSCRM_add_action_links' );

function zeroBSCRM_add_action_links ( $links ) {
 $mylinks = array(
 	 '<a href="https://zerobscrm.com/extensions/">Extensions</a>',
 );
return array_merge( $links, $mylinks );
}







#} Uninstall
function zeroBSCRM_uninstall(){

		$feedbackAlready = get_option('zbsfeedback');

	if (!defined('ZBSDEACTIVATINGINPROG') && $feedbackAlready == false){

								define('ZBSDEACTIVATINGINPROG',true);


				global $zeroBSCRM_Settings;	

				if (function_exists('file_get_contents')){

			try {

				$beforeYouGo = file_get_contents(ZEROBSCRM_PATH.'html/before-you-go/index.html');

				if (!empty($beforeYouGo)){

										$beforeYouGo = str_replace('###ADMINURL###',admin_url('plugins.php'),$beforeYouGo);
					$beforeYouGo = str_replace('###ADMINASSETSURL###',ZEROBSCRM_URL.'html/before-you-go/assets/',$beforeYouGo);	
					$beforeYouGo = str_replace('###AJAXURL###',admin_url('admin-ajax.php'),$beforeYouGo);	


										deactivate_plugins( plugin_basename( __FILE__ ) );

										echo $beforeYouGo; exit();

				}


			} catch (Exception $e){

				
			}

		}	

	}

}







function zeroBSCRM_admin_init(){
		wp_register_style('zerobscrmadmcss', 	plugins_url('/css/ZeroBSCRM.admin.global.min.css',__FILE__),'', 1.17 );
	wp_register_style('zerobsjsmodal', 	plugins_url('/css/jquery.modal.min.css',__FILE__),'', 1.17 );
	wp_register_script('zerobsjsmodal' ,plugins_url('/js/lib/jquery.modal.min.js',__FILE__), array('jquery'));
		wp_register_style('wh-fa-v4-4-0-corecss', plugins_url('/css/font-awesome.min.css',__FILE__) );

		wp_register_style('zerobscrmswa', plugins_url('/css/sweetalert.min.css',__FILE__) );
}


function zeroBSCRM_global_admin_styles(){
		wp_enqueue_style( 'zerobscrmadmcss' );
	wp_enqueue_style( 'zerobsjsmodal' );
	wp_enqueue_script('zerobsjsmodal');
	wp_enqueue_style(	'wh-fa-v4-4-0-corecss'	);
	wp_enqueue_style(	'zerobscrmswa'		);
}


function zeroBSCRM_add_admin_styles( $hook ) {

    global $post;

    if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
        if (is_object($post))
        if ( 'zerobs_customer' === $post->post_type || 'zerobs_quote' === $post->post_type || 'zerobs_company' === $post->post_type || 'zerobs_invoice' === $post->post_type || 'zerobs_transaction' === $post->post_type || 'zerobs_form' === $post->post_type ) {     
            zeroBSCRM_global_admin_styles();
        }
    }
}
add_action( 'admin_enqueue_scripts', 'zeroBSCRM_add_admin_styles', 10, 1 );

function zeroBSCRM_add_public_scripts( $hook ) {

    global $post;

            if( is_single() && get_query_var('post_type') && 'zerobs_quote' == get_query_var('post_type') ){

    			wp_enqueue_style('zerobscrmpubquocss', plugins_url('/css/ZeroBSCRM.public.quotes.min.css',__FILE__) );

    }
    
}
add_action( 'wp_enqueue_scripts', 'zeroBSCRM_add_public_scripts', 10, 1 );












#} Initialisation - enqueueing scripts/styles
function zeroBSCRM_init(){
  
	global $zeroBSCRM_slugs, $zeroBSCRM_Settings; 
	#} Add roles 
	zeroBSCRM_addUserRoles();

	#} Retrieve settings
	$settings = $zeroBSCRM_Settings->getAll();

		$useQuoteBuilder = zeroBSCRM_getSetting('usequotebuilder');
	if($useQuoteBuilder == "1" && !class_exists('zeroBSCRM_QuoteTemplate_List')) require_once(ZEROBSCRM_PATH  . 'includes/ZeroBSCRM.QuoteTemplate.list.php');

        zeroBSCRM_migrations_run($settings['migrations']);

		if (isset($_GET['zbscjson']) && is_user_logged_in() && zeroBSCRM_permsCustomers()){ exit(zeroBSCRM_cjson()); }

		if (isset($_GET['zbs_invid']) && wp_verify_nonce($_GET['_wpnonce'], 'zbsinvpreview') && is_user_logged_in() && zeroBSCRM_permsInvoices()){ exit(zeroBSCRM_invoice_generateInvoiceHTML((int)$_GET['zbs_invid'],false)); }	

	#} Catch Dashboard + redir (if override mode)
		if (isset($settings['wptakeovermode']) && $settings['wptakeovermode'] == 1) zeroBSCRM_catchDashboard();

		zeroBSCRM_extensions_init_install();

	#} setup post types
	zeroBSCRM_setupPostTypes();

		zeroBSCRM_installDefaultContent();
			
	#} Admin & Public req
	wp_enqueue_script("jquery");

		global $whLangsupport; $whLangsupport['zerobscrm'] = 'zeroBSCRM_Settings';

		zeroBSCRM_PostInitIncludes();

		do_action('zerobscrm_post_init');
	
	#} Public only	
	if (!is_admin()){

				if (isset($settings['killfrontend']) && $settings['killfrontend'] == 1){

						

									if (!zeroBSCRM_isLoginPage() && !zeroBSCRM_isWelcomeWizPage()){

				 zeroBSCRM_stopFrontEnd();

			}
		}

				wp_enqueue_script('zerobscrmglob', plugins_url('/js/ZeroBSCRM.public.global.min.js',__FILE__), array( 'jquery' ));

						

	} else {


			
					


				wp_enqueue_script('zerobscrmadmjs', plugins_url('/js/ZeroBSCRM.admin.global.min.js',__FILE__), array( 'jquery' ));

						wp_enqueue_script('zerobscrmtajs-0-11-1', plugins_url('/js/lib/typeahead.bundle.min.js',__FILE__), array( 'jquery' ));
	
								
				wp_enqueue_script('zerobscrmswa', plugins_url('/js/lib/sweetalert.min.js',__FILE__), array( 'jquery' ));
		
				if (isset($_GET['page']) && $_GET['page'] == 'zerobscrm-plugin-settings'){

			zeroBSCRM_load_libs_js_momentdatepicker();

		}


						

				$postTypeStr = ''; if (isset($_GET['post'])) $postTypeStr = get_post_type((int)$_GET['post']);
		
				if (
				(isset($_GET['page']) && $_GET['page'] == 'manage-customers') ||
				(isset($_GET['page']) && $_GET['page'] == 'manage-customers-noqj') ||
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_customer') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_customer')
				) {

					wp_enqueue_style('zerobscrm-customeredit', 	plugins_url('/css/ZeroBSCRM.admin.customeredit.min.css',__FILE__) );

		}

				if (
				(isset($_GET['page']) && $_GET['page'] == 'manage-invoices') ||
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_invoice') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_invoice')
				) {

															wp_enqueue_script('zerobscrmbsjs', plugins_url('/js/lib/bootstrap.min.js',__FILE__), array( 'jquery' ));

					
					wp_enqueue_style('zerobscrm-invoicebuilder', 	plugins_url('/css/ZeroBSCRM.admin.invoicebuilder.min.css',__FILE__) );
					wp_enqueue_script('zerobscrm-invoicebuilderjs', plugins_url('/js/ZeroBSCRM.admin.invoicebuilder.min.js',__FILE__), array( 'jquery' ));

		}

				if (
				(isset($_GET['page']) && $_GET['page'] == 'manage-quotes') ||
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_quote') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_quote')
				) {

					wp_enqueue_style('zerobscrm-quotebuilder', 	plugins_url('/css/ZeroBSCRM.admin.quotebuilder.min.css',__FILE__) );
					wp_enqueue_script('zerobscrm-quotebuilderjs', plugins_url('/js/ZeroBSCRM.admin.quotebuilder.min.js',__FILE__), array( 'jquery' ));

		}

				if (
								(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_form') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_form')
				) {

					wp_enqueue_style('zerobscrmformcss', 	plugins_url('/css/ZeroBSCRM.admin.frontendforms.min.css',__FILE__),'', 1.17 );

		}

				if (
								(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_transaction') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_transaction')
				) {

					wp_enqueue_style('zerobscrmtranscss', 	plugins_url('/css/ZeroBSCRM.admin.transactionedit.min.css',__FILE__),'', 1.17 );

		}

				if (isset($_GET['page']) && $_GET['page'] == 'zerobscrm-plugin-settings') {


			

						if (isset($_GET['tab']) && $_GET['tab'] == 'fieldsorts'){

								wp_enqueue_script('zerobscrmadmjqui', plugins_url('/js/lib/jquery-ui.min.js',__FILE__), array( 'jquery' ));

								wp_enqueue_style('zerobscrmsortscss', 	plugins_url('/css/ZeroBSCRM.admin.sortables.min.css',__FILE__));

			}

		}





						

				if (
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_customer') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_customer')
				) {
						add_filter('post_updated_messages', 'zeroBSCRM_improvedPostMsgsCustomers');

				}
		if (
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_company') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_company')
				) {
						add_filter('post_updated_messages', 'zeroBSCRM_improvedPostMsgsCompanies');

				}
		if (
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_invoice') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_invoice')
				) {
						add_filter('post_updated_messages', 'zeroBSCRM_improvedPostMsgsInvoices');

				}
		if (
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_quote') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_quote')
				) {
						add_filter('post_updated_messages', 'zeroBSCRM_improvedPostMsgsQuotes');

				}
		if (
				(isset($_GET['post_type']) && $_GET['post_type'] == 'zerobs_transaction') || 
				(!empty($postTypeStr) && $postTypeStr == 'zerobs_transaction')
				) {
						add_filter('post_updated_messages', 'zeroBSCRM_improvedPostMsgsTransactions');

				}
	

	}
	
		
		zeroBSCRM_addThemeThumbnails();

}








function zeroBSCRM__adminHeaderExpose(){

	if (zeroBSCRM_is_edit_page()){

				$outArr = zeroBS_getForms(false,1000);

				echo '<script type="text/javascript" id="wpzbscrmformsettings">var wpzbscrmroot = "'.ZEROBSCRM_URL.'";var zbsCRMFormList = '.json_encode($outArr).';</script>';

				echo '<script type="text/javascript">var zbscrmjs_globSecToken = \''.wp_create_nonce( "zbscrmjs-glob-ajax-nonce" ).'\';</script>';
	}

		echo '<script type="text/javascript" id="wpzbscrmglobal">var zbsCRMTimeZoneOffset = '.zeroBSCRM_getTimezoneOffset().';</script>';

		global $zeroBSCRM_Settings;

    $zbsMenuMode = $zeroBSCRM_Settings->get('menulayout');
    if($zbsMenuMode == 2){?>
    	<style>
    		#adminmenu .toplevel_page_sales-dash{ display:none; }
    	</style>
    <?php }


}
add_action('admin_head', 'zeroBSCRM__adminHeaderExpose'); 




#} Public Headers
function zeroBSCRM_publicHeaderExpose(){

	global $zeroBSCRM_Settings;	
		$settings = $zeroBSCRM_Settings->getAll();

	if (zeroBSCRM_isLoginPage()){ 

		if (isset($settings['loginlogourl']) && !empty($settings['loginlogourl'])){
	

						?><style type="text/css">
				.login h1 a {
					background-image: none,url(<?php echo $settings['loginlogourl']; ?>) !important;
				}
				.login #nav, .login #backtoblog {
					/*display:none;*/
				}
			</style><?php

		}

	}

}
add_action('login_head','zeroBSCRM_publicHeaderExpose');



function zeroBSCRM_exposePID(){

	global $post;

	if (isset($post) && isset($post->ID)) echo '<script type="text/javascript">var zbscrmJSFormspid = '.$post->ID.';</script>';

}








#} Load languages
function zeroBSCRM_load_textdomain() {
	load_plugin_textdomain( 'zerobscrm', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', 'zeroBSCRM_load_textdomain' );






#} Add le admin menu
function zeroBSCRM_admin_menu() {

	global $zeroBSCRM_slugs, $zeroBSCRM_Settings; 
		$settings = $zeroBSCRM_Settings->getAll();

		$b2bMode = zeroBSCRM_getSetting('companylevelcustomers');

        $zbsMenuMode = $zeroBSCRM_Settings->get('menulayout');
    if (!isset($zbsMenuMode) || !in_array($zbsMenuMode,array(1,2,3))) $zbsMenuMode = 2; 

    	do_action('zerobs_importers');  
		$adminMenuTitle = 'Zero BS CRM';  	if ($zbsMenuMode == ZBS_MENU_SLIM) $adminMenuTitle = 'ZBS CRM Admin';

	$adminPageHome = add_menu_page( 'Zero BS CRM Plugin', $adminMenuTitle, 'manage_options', $zeroBSCRM_slugs['home'], 'zeroBSCRM_pages_home'); 	add_action( "admin_print_styles-{$adminPageHome}", 'zeroBSCRM_global_admin_styles' );

			    $adminMenuWelcome = add_submenu_page( $zeroBSCRM_slugs['home'], 'Welcome to ZBS', 'Welcome to ZBS', 'manage_options', $zeroBSCRM_slugs['home'], 'zeroBSCRM_pages_home' );
    add_action( "admin_print_styles-{$adminMenuWelcome}", 'zeroBSCRM_global_admin_styles' );

              
        $adminMenuStatus = add_submenu_page( $zeroBSCRM_slugs['home'], 'System Status', 'System Status', 'manage_options', $zeroBSCRM_slugs['systemstatus'], 'zeroBSCRM_pages_systemstatus' );
	add_action( "admin_print_styles-{$adminMenuStatus}", 'zeroBSCRM_global_admin_styles' );   
    
        $adminMenuFeedback = add_submenu_page( $zeroBSCRM_slugs['home'], 'Feedback', 'Feedback', 'manage_options', $zeroBSCRM_slugs['feedback'], 'zeroBSCRM_pages_feedback' );
	add_action( "admin_print_styles-{$adminMenuFeedback}", 'zeroBSCRM_global_admin_styles' ); 
 

        $adminMenuSettings = add_submenu_page( $zeroBSCRM_slugs['home'], 'Settings', 'Settings', 'manage_options', $zeroBSCRM_slugs['settings'], 'zeroBSCRM_pages_settings' );
	add_action( "admin_print_styles-{$adminMenuSettings}", 'zeroBSCRM_global_admin_styles' );  
    
        $adminMenuExtend = add_submenu_page( $zeroBSCRM_slugs['home'], 'Extensions', '<span style="color: #FCB214 !important;">Extensions</span>', 'manage_options', $zeroBSCRM_slugs['extensions'], 'zeroBSCRM_pages_extensions' );
	add_action( "admin_print_styles-{$adminMenuExtend}", 'zeroBSCRM_global_admin_styles' ); 


	        		    		$adminMenuTrash = add_submenu_page( 'admin.php?page=zerobscrm-plugin-settings', __w('Trash Msg','zerobscrm'), __w('Trash Msg','zerobscrm'), 'admin_zerobs_customers', 'zbs-deletion', 'zeroBSCRM_pages_postdelete', 1);
		add_action( "admin_print_styles-{$adminMenuTrash}", 'zeroBSCRM_global_admin_styles' ); 


        	$adminMenuData = add_menu_page( 'Data Tools', 'Data Tools', 'manage_options', $zeroBSCRM_slugs['datatools'], 'zeroBSCRM_pages_datatools', 'dashicons-admin-tools',90); 	add_action( "admin_print_styles-{$adminMenuData}", 'zeroBSCRM_global_admin_styles' ); 


	$adminMenuBulk = add_submenu_page( $zeroBSCRM_slugs['datatools'], 'Bulk Tools', 'Bulk Tools', 'manage_options', $zeroBSCRM_slugs['bulktools'], 'zeroBSCRM_pages_bulktools' );
	add_action( "admin_print_styles-{$adminMenuBulk}", 'zeroBSCRM_global_admin_styles' ); 


	 	
	  	

    	
        do_action('zerobs_extrasubmenu');                           	

    
				$takeoverModeAll = $zeroBSCRM_Settings->get('wptakeovermodeforall');
		$takeoverModeZBS = $zeroBSCRM_Settings->get('wptakeovermode');  
		$takeoverMode = false; if ($takeoverModeAll || (zeroBSCRM_permsIsZBSUser() && $takeoverModeZBS)) $takeoverMode = true;

	    if ($zbsMenuMode == ZBS_MENU_CRMONLY){
    	$takeoverModeAll = true;
    	$takeoverModeZBS = true;
    	$takeoverMode  = true;
    }

	if ($takeoverMode){
					remove_menu_page( 'index.php' );                  		remove_menu_page( 'edit-tags.php?taxonomy=category' );                   		

		if ($takeoverModeAll){

		    remove_menu_page( 'edit-tags.php?taxonomy=category' ); 		    remove_menu_page( 'index.php' );                  		    remove_menu_page( 'edit.php' );                   		    remove_menu_page( 'upload.php' );                 		    remove_menu_page( 'edit.php?post_type=page' );    		    remove_menu_page( 'edit-comments.php' );          		    remove_menu_page( 'themes.php' );                 		    remove_menu_page( 'plugins.php' );                		    remove_menu_page( 'users.php' );                  		    remove_menu_page( 'tools.php' );                  		    remove_menu_page( 'options-general.php' );        
		}

						remove_menu_page('profile.php');

			    	    	    		$adminMenuLogout = add_menu_page( 'Log Out', 'Log Out', 'read', $zeroBSCRM_slugs['logout'], 'zeroBSCRM_pages_logout', 'dashicons-unlock',100);
		add_action( "admin_print_styles-{$adminMenuLogout}", 'zeroBSCRM_global_admin_styles' ); 



	}
   


		$allCustomersPage = remove_submenu_page( 'edit.php?post_type=zerobs_customer', 'edit.php?post_type=zerobs_customer' );

		if (zeroBSCRM_permsCustomers()){

	    	    $adminMenuCompany = add_submenu_page( 'edit.php?post_type=zerobs_customer', __w('Manage '.zeroBSCRM_getContactOrCustomer().'s','zerobscrm'), __w('Manage '.zeroBSCRM_getContactOrCustomer().'s','zerobscrm'), 'admin_zerobs_customers', 'manage-customers', 'zeroBSCRM_render_customerslist_page', 1);
		add_action( "admin_print_styles-{$adminMenuCompany}", 'zeroBSCRM_global_admin_styles' ); 

	   
	    	    	    if (isset($settings['showneedsquote']) && $settings['showneedsquote'] == 1){
	    	$adminNeedsAQ = add_submenu_page( 'edit.php?post_type=zerobs_customer', __w('Needs a Quote','zerobscrm'), __w('Needs a Quote','zerobscrm'), 'manage_options', 'manage-customers-noqj', 'zeroBSCRM_render_customersNoQJlist_page' );
			add_action( "admin_print_styles-{$adminNeedsAQ}", 'zeroBSCRM_global_admin_styles' ); 

	    }
	    
			    if ($b2bMode){
	    	$adminB2B = add_submenu_page( 'edit.php?post_type=zerobs_company', __w('Manage '.zeroBSCRM_getCompanyOrOrgPlural(),'zerobscrm'), __w('Manage '.zeroBSCRM_getCompanyOrOrgPlural(),'zerobscrm'), 'admin_zerobs_customers', 'manage-companies', 'zeroBSCRM_render_companyslist_page', 1);
	    	add_action( "admin_print_styles-{$adminB2B}", 'zeroBSCRM_global_admin_styles' ); 
	    }

				$zbscsearch = add_submenu_page('edit.php?post_type=zerobs_customer', __w('Search','zerobscrm'), __w('Search','zerobscrm'), 'admin_zerobs_customers', 'customer-searching', 'zeroBSCRM_customersearch', 2 );
		add_action( 'admin_print_styles-' . $zbscsearch, 'zbscrm_customer_search_custom_css' );

	    	    	    
	    		    	global $submenu;

	    		    	if (isset($submenu['edit.php?post_type=zerobs_customer'])){

	    			    		$menuItems = array();
	    		foreach ($submenu['edit.php?post_type=zerobs_customer'] as $ind => $menuItem){

	    			if ($menuItem[2] == 'post-new.php?post_type=zerobs_customer') $menuItems['addnew'] = $menuItem;
	    			if ($menuItem[2] == 'edit-tags.php?taxonomy=zerobscrm_customertag&amp;post_type=zerobs_customer') $menuItems['tags'] = $menuItem;
	    			if ($menuItem[2] == 'manage-customers') $menuItems['manage'] = $menuItem;
	    			if ($menuItem[2] == 'manage-customers-noqj') $menuItems['noqj'] = $menuItem;
	    			if ($menuItem[2] == 'customer-searching') $menuItems['custsearch'] = $menuItem;


	    		}

	    			    		$finalArr = array();
	    		if (isset($menuItems['manage'])) $finalArr[] = $menuItems['manage'];
	    		if (isset($menuItems['custsearch'])) $finalArr[] = $menuItems['custsearch'];
	    		if (isset($menuItems['noqj'])) $finalArr[] = $menuItems['noqj'];
	    		if (zeroBSCRM_permsCustomersTags()){ if (isset($menuItems['tags'])) $finalArr[] = $menuItems['tags']; }
	    		if (isset($menuItems['addnew'])) $finalArr[] = $menuItems['addnew'];

	    		
			    $submenu['edit.php?post_type=zerobs_customer'] = $finalArr;

			}

	    		    	if ($b2bMode) if (isset($submenu['edit.php?post_type=zerobs_company'])){

	    			    		$menuItems = array();
	    		foreach ($submenu['edit.php?post_type=zerobs_company'] as $ind => $menuItem){

	    			if ($menuItem[2] == 'post-new.php?post_type=zerobs_company') $menuItems['addnew'] = $menuItem;
	    			if ($menuItem[2] == 'edit-tags.php?taxonomy=zerobscrm_companytag&amp;post_type=zerobs_company') $menuItems['tags'] = $menuItem;
	    			if ($menuItem[2] == 'manage-companies') $menuItems['manage'] = $menuItem;


	    		}

	    			    		$finalArr = array();
	    		if (isset($menuItems['manage'])) $finalArr[] = $menuItems['manage'];
	    		if (zeroBSCRM_permsCustomersTags()){ if (isset($menuItems['tags'])) $finalArr[] = $menuItems['tags']; }
	    		if (isset($menuItems['addnew'])) $finalArr[] = $menuItems['addnew'];

			    $submenu['edit.php?post_type=zerobs_company'] = $finalArr;

			}

	}



    	$allQuotesPage = remove_submenu_page( 'edit.php?post_type=zerobs_quote', 'edit.php?post_type=zerobs_quote' );

		if (zeroBSCRM_permsQuotes()){

	    	    $adminManageQ = add_submenu_page( 'edit.php?post_type=zerobs_quote', __w('Manage Quotes','zerobscrm'), __w('Manage Quotes','zerobscrm'), 'admin_zerobs_quotes', 'manage-quotes', 'zeroBSCRM_render_quoteslist_page' );
	    
	    add_action( "admin_print_styles-{$adminManageQ}", 'zeroBSCRM_global_admin_styles' ); 

	    	    	    
	    		    	global $submenu;

	    	

	    	if (isset($submenu['edit.php?post_type=zerobs_quote'])){
		    	
		    				    $arr = array();
			    if (isset($submenu['edit.php?post_type=zerobs_quote'][11])) $arr[] = $submenu['edit.php?post_type=zerobs_quote'][11]; 			    if (isset($submenu['edit.php?post_type=zerobs_quote'][10])) $arr[] = $submenu['edit.php?post_type=zerobs_quote'][10]; 			    			    $submenu['edit.php?post_type=zerobs_quote'] = $arr;		


												$useQuoteBuilder = zeroBSCRM_getSetting('usequotebuilder');

				if ($useQuoteBuilder == "1"){

				    				    $adminMenuQuoteTemplates = add_submenu_page( 'edit.php?post_type=zerobs_quote', __w('Quote Templates','zerobscrm'), __w('Quote Templates','zerobscrm'), 'admin_zerobs_quotes', 'manage-quote-templates', 'zeroBSCRM_render_quotetemplateslist_page', 1);
					add_action( "admin_print_styles-{$adminMenuQuoteTemplates}", 'zeroBSCRM_global_admin_styles' );

				}

			} 
	}


    	$allInvoicesPage = remove_submenu_page( 'edit.php?post_type=zerobs_invoice', 'edit.php?post_type=zerobs_invoice' );

		if (zeroBSCRM_permsInvoices()){

	    	    $adminManageI = add_submenu_page( 'edit.php?post_type=zerobs_invoice', __w('Manage Invoices','zerobscrm'), __w('Manage Invoices','zerobscrm'), 'admin_zerobs_invoices', 'manage-invoices', 'zeroBSCRM_render_invoiceslist_page' );
		add_action( "admin_print_styles-{$adminManageI}", 'zeroBSCRM_global_admin_styles' );

	    
	    	    	    
	    		    	global $submenu;

	    		    	if (isset($submenu['edit.php?post_type=zerobs_invoice'])){

		    				    $arr = array();
			    if (isset($submenu['edit.php?post_type=zerobs_invoice'][11])) $arr[] = $submenu['edit.php?post_type=zerobs_invoice'][11]; 			    if (isset($submenu['edit.php?post_type=zerobs_invoice'][10])) $arr[] = $submenu['edit.php?post_type=zerobs_invoice'][10]; 			    			    $submenu['edit.php?post_type=zerobs_invoice'] = $arr;

			}

	}


    	$allTransactionsPage = remove_submenu_page( 'edit.php?post_type=zerobs_transaction', 'edit.php?post_type=zerobs_transaction' );

		if (zeroBSCRM_permsTransactions()){

	    	    $adminManageT = add_submenu_page( 'edit.php?post_type=zerobs_transaction', __w('Manage Transactions','zerobscrm'), __w('Manage Transactions','zerobscrm'), 'admin_zerobs_transactions', 'manage-transactions', 'zeroBSCRM_render_transactionslist_page' );
	    add_action( "admin_print_styles-{$adminManageT}", 'zeroBSCRM_global_admin_styles' );
	    	    	    
	    		    	global $submenu;

	    		    	if (isset($submenu['edit.php?post_type=zerobs_transaction'])){

		    				    $arr = array();
			    			    			    $zbsFirstMenuItem = false;$zbsSecondMenuItem = false;$zbsThirdMenuItem = false;
			    foreach ($submenu['edit.php?post_type=zerobs_transaction'] as $key => $menu){

			    	switch ($menu[0]){

			    		case 'Manage Transactions':
			    			$zbsFirstMenuItem = $menu;
			    			break;
			    		case 'Transaction Tags':
			    			$zbsSecondMenuItem = $menu;
			    			break;
			    		case 'Add New':
			    			$zbsThirdMenuItem = $menu;
			    			break;

			    	}
			    }
			    $arr = array($zbsFirstMenuItem,$zbsSecondMenuItem,$zbsThirdMenuItem);

			    			    $submenu['edit.php?post_type=zerobs_transaction'] = $arr;

			}

	}

    if ($zbsMenuMode == ZBS_MENU_SLIM){
    	    	remove_menu_page('edit.php?post_type=zerobs_customer');        	remove_menu_page('edit.php?post_type=zerobs_transaction'); 	    	remove_menu_page('edit.php?post_type=zerobs_quote');     	remove_menu_page('edit.php?post_type=zerobs_invoice');     	$removedFormsMenu = remove_menu_page('edit.php?post_type=zerobs_form');     	remove_menu_page('edit.php?post_type=zerobs_company'); 
    	    	remove_menu_page('zerobscrm-sync');     	$removedDataTools = remove_menu_page('zerobscrm-datatools');  
    	


    		    		global $submenu;
    		if (isset($removedDataTools) && isset($submenu['zerobscrm-plugin'])){

    			    			unset($removedDataTools[4],$removedDataTools[5],$removedDataTools[6]);


    			    			$menuArr = $submenu['zerobscrm-plugin'];

    			    			$replacementMenu = array();
    			foreach ($menuArr as $menuItem){

    				    				if ($menuItem[2] == 'zerobscrm-systemstatus') $replacementMenu[] = $removedDataTools;

    				    				$replacementMenu[] = $menuItem;
    			}

    			    			$submenu['zerobscrm-plugin'] = $replacementMenu;

    		}
	    	

    	    	remove_menu_page('edit.php?post_type=zerobs_mailcampaign');     	remove_menu_page('sales-dash'); 

    			$adminUserD = add_menu_page( 'Zero BS CRM User Dash', 'Zero BS CRM', 'zbs_dash', $zeroBSCRM_slugs['dash'], 'zeroBSCRM_pages_dash','dashicons-groups',2);
		add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );

	    	    if ($b2bMode){
	    	$adminUserD = add_submenu_page( $zeroBSCRM_slugs['dash'], __w(''.zeroBSCRM_getCompanyOrOrgPlural(),'zerobscrm'), __w(''.zeroBSCRM_getCompanyOrOrgPlural(),'zerobscrm'), 'admin_zerobs_customers', 'manage-companies-crm', 'zeroBSCRM_render_companyslist_page');
	    	add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );

	    }
	    $adminUserD = add_submenu_page( $zeroBSCRM_slugs['dash'], __w(''.zeroBSCRM_getContactOrCustomer().'s','zerobscrm'), __w(''.zeroBSCRM_getContactOrCustomer().'s','zerobscrm'), 'admin_zerobs_customers', 'manage-customers-crm', 'zeroBSCRM_render_customerslist_page', 1);
	    add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );


		$ZBSuseQuotes = zeroBSCRM_getSetting('feat_quotes');
		if($ZBSuseQuotes == "1"){
		    $adminUserD = add_submenu_page( $zeroBSCRM_slugs['dash'], __w('Quotes','zerobscrm'), __w('Quotes','zerobscrm'), 'admin_zerobs_quotes', 'manage-quotes-crm', 'zeroBSCRM_render_quoteslist_page' );
		    add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );
		}

		$ZBSuseInvoices = zeroBSCRM_getSetting('feat_invs');
		if($ZBSuseInvoices == "1"){
		    $adminUserD = add_submenu_page( $zeroBSCRM_slugs['dash'], __w('Invoices','zerobscrm'), __w('Invoices','zerobscrm'), 'admin_zerobs_invoices', 'manage-invoices-crm', 'zeroBSCRM_render_invoiceslist_page' );
			add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );
		}

			    $adminUserD = add_submenu_page( $zeroBSCRM_slugs['dash'], __w('Transactions','zerobscrm'), __w('Transactions','zerobscrm'), 'admin_zerobs_transactions', 'manage-transactions-crm', 'zeroBSCRM_render_transactionslist_page' );
	    add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );
		

	    
	    		    	global $submenu;


	    		    	if (zeroBSCRM_isExtensionInstalled('forms') && isset($submenu[$zeroBSCRM_slugs['dash']])){

	    			    			    			    		$submenu[$zeroBSCRM_slugs['dash']][] = array(__w('Forms','zerobscrm'),'edit_pages','edit.php?post_type=zerobs_form',__w('Forms','zerobscrm'));

	    	}

    }

    if ($zbsMenuMode == ZBS_MENU_FULL){
    	
    			$adminUserD = add_menu_page( 'Zero BS CRM User Dash', 'Zero BS CRM', 'zbs_dash', $zeroBSCRM_slugs['dash'], 'zeroBSCRM_pages_dash','dashicons-groups',2);
	    add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );

    }

    if ($zbsMenuMode == ZBS_MENU_CRMONLY){
    	
    			$adminUserD = add_menu_page( 'Zero BS CRM User Dash', 'Zero BS CRM', 'zbs_dash', $zeroBSCRM_slugs['dash'], 'zeroBSCRM_pages_dash','dashicons-groups',2);
    	add_action( "admin_print_styles-{$adminUserD}", 'zeroBSCRM_global_admin_styles' );
    }

	

	#} Add daterangepicker to "add quote" and "add invoice" pages:
    add_action( 'load-post.php', 'zeroBSCRM_load_libs_js_momentdatepicker' );
        add_action( 'load-post-new.php', 'zeroBSCRM_load_libs_js_momentdatepicker' );
        add_action( 'load-post-new.php', 'zeroBSCRM_load_libs_js_momentdatepicker' );

		
		


}










	
		function zeroBSCRM_load_libs_js_momentdatepicker(){
	    add_action( 'admin_enqueue_scripts', 'zeroBSCRM_enqueue_libs_js_momentdatepicker' );
	}
	function zeroBSCRM_enqueue_libs_js_momentdatepicker(){

				wp_enqueue_script('wh-moment-v2-1-3-js',		plugins_url('/js/lib/moment.min.js',__FILE__),array('jquery'));
		wp_enqueue_script('wh-daterangepicker-v2-1-21-js',		plugins_url('/js/lib/daterangepicker.min.js',__FILE__),array('jquery'));
		
	}


		function zeroBSCRM_load_libs_js_customerfilters(){
	    add_action( 'admin_enqueue_scripts', 'zeroBSCRM_enqueue_libs_js_customerfilters' );
	}
	function zeroBSCRM_enqueue_libs_js_customerfilters(){

				wp_enqueue_script('zbs-js-customerfilters-v1',		plugins_url('/js/ZeroBSCRM.admin.customerfilters.min.js',__FILE__),array('jquery'));
	}

		function zeroBSCRM_enqueue_media_manager(){
		wp_enqueue_media();
		wp_enqueue_script( 'custom-header' );
	}
	add_action('admin_enqueue_scripts', 'zeroBSCRM_enqueue_media_manager');








		define('ZBSCRMCORELOADED',true); ?>