PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 1.1
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v1.1
2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 2.0.22 All 55 releases
booking-manager / wpdev-crm.php

wpdev-crm.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 1.1, at wpdev-crm.php

1,717 lines 120.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Booking Manager
4 Plugin URI: http://ordersplugin.onlinebookingcalendar.com/
5 Description: Booking Manager - show all old bookings (and cutomers) from <a href="http://onlinebookingcalendar.com">Booking Calendar</a> plugin. Profesional verion can export bookings to CSV, print bookings, have advanced filter.
6 Version: 1.1
7 Author: wpdevelop
8 Author URI: http://www.wpdevelop.com
9 */
10
11 /* T O D O P L A N of W O R K :
12 *
13 * 2. Notes for customers and orders - Pro
14 * 3. Actions: delete - Pro
15 * 1. Email sending - Pro
16 * 2. Notification emails - Pro
17 *
18 */
19
20 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
21 if (!function_exists ('debuge')) { function debuge() { $numargs = func_num_args(); $var = func_get_args(); $makeexit = is_bool($var[count($var)-1])?$var[count($var)-1]:false; echo "<div style='text-align:left;background:#ffffff;border: 1px dashed #ff9933;font-size:11px;line-height:15px;font-family:'Lucida Grande',Verdana,Arial,'Bitstream Vera Sans',sans-serif;'><pre>"; print_r ( $var ); echo "</pre></div>"; if ($makeexit) { echo '<div style="font-size:18px;float:right;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</div>'; exit;} } }
22 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23 // Internal plugin action system
24 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25 if (true) {
26 global $wpdev_crm_action, $wpdev_crm_filter;
27
28 function add_crm_filter($filter_type, $filter) {
29 global $wpdev_crm_filter;
30
31 $args = array();
32 if ( is_array($filter) && 1 == count($filter) && is_object($filter[0]) ) // array(&$this)
33 $args[] =& $filter[0];
34 else
35 $args[] = $filter;
36 for ( $a = 2; $a < func_num_args(); $a++ )
37 $args[] = func_get_arg($a);
38
39 if ( is_array($wpdev_crm_filter) )
40 if ( is_array($wpdev_crm_filter[$filter_type]) )
41 $wpdev_crm_filter[$filter_type][]= $args;
42 else
43 $wpdev_crm_filter[$filter_type]= array($args);
44 else
45 $wpdev_crm_filter = array( $filter_type => array( $args ) ) ;
46 }
47
48 function remove_crm_filter($filter_type, $filter) {
49 global $wpdev_crm_filter;
50
51 if ( isset($wpdev_crm_filter[$filter_type]) ) {
52 for ($i = 0; $i < count($wpdev_crm_filter[$filter_type]); $i++) {
53 if ( $wpdev_crm_filter[$filter_type][$i][0] == $filter ) {
54 $wpdev_crm_filter[$filter_type][$i] = null;
55 return;
56 }
57 }
58 }
59 }
60
61 function apply_crm_filter($filter_type) {
62 global $wpdev_crm_filter;
63
64
65 $args = array();
66 for ( $a = 1; $a < func_num_args(); $a++ )
67 $args[] = func_get_arg($a);
68
69 $value = $args[0];
70
71 if ( is_array($wpdev_crm_filter) )
72 if ( isset($wpdev_crm_filter[$filter_type]) )
73 foreach ($wpdev_crm_filter[$filter_type] as $filter) {
74 $filter_func = array_shift($filter);
75 $parameter = $args;
76 $value = call_user_func_array($filter_func,$parameter );
77 }
78 return $value;
79 }
80
81 function make_crm_action($action_type) {
82 global $wpdev_crm_action;
83
84
85 $args = array();
86 for ( $a = 1; $a < func_num_args(); $a++ )
87 $args[] = func_get_arg($a);
88
89 //$value = $args[0];
90
91 if ( is_array($wpdev_crm_action) )
92 if ( isset($wpdev_crm_action[$action_type]) )
93 foreach ($wpdev_crm_action[$action_type] as $action) {
94 $action_func = array_shift($action);
95 $parameter = $action;
96 call_user_func_array($action_func,$args );
97 }
98 }
99
100 function add_crm_action($action_type, $action) {
101 global $wpdev_crm_action;
102
103 $args = array();
104 if ( is_array($action) && 1 == count($action) && is_object($action[0]) ) // array(&$this)
105 $args[] =& $action[0];
106 else
107 $args[] = $action;
108 for ( $a = 2; $a < func_num_args(); $a++ )
109 $args[] = func_get_arg($a);
110
111 if ( is_array($wpdev_crm_action) )
112 if ( is_array($wpdev_crm_action[$action_type]) )
113 $wpdev_crm_action[$action_type][]= $args;
114 else
115 $wpdev_crm_action[$action_type]= array($args);
116 else
117 $wpdev_crm_action = array( $action_type => array( $args ) ) ;
118 }
119
120 function remove_crm_action($action_type, $action) {
121 global $wpdev_crm_action;
122
123 if ( isset($wpdev_crm_action[$action_type]) ) {
124 for ($i = 0; $i < count($wpdev_crm_action[$action_type]); $i++) {
125 if ( $wpdev_crm_action[$action_type][$i][0] == $action ) {
126 $wpdev_crm_action[$action_type][$i] = null;
127 return;
128 }
129 }
130 }
131 }
132 }
133 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
134 // Get header info from this file, just for compatibility with WordPress 2.8 and older versions.
135 function get_file_data_crm_wpdev( $file, $default_headers, $context = '' ) {
136 // We don't need to write to the file, so just open for reading.
137 $fp = fopen( $file, 'r' );
138
139 // Pull only the first 8kiB of the file in.
140 $file_data = fread( $fp, 8192 );
141
142 // PHP will close file handle, but we are good citizens.
143 fclose( $fp );
144
145 if( $context != '' ) {
146 $extra_headers = array();//apply_filters( "extra_$context".'_headers', array() );
147
148 $extra_headers = array_flip( $extra_headers );
149 foreach( $extra_headers as $key=>$value ) {
150 $extra_headers[$key] = $key;
151 }
152 $all_headers = array_merge($extra_headers, $default_headers);
153 } else {
154 $all_headers = $default_headers;
155 }
156
157
158 foreach ( $all_headers as $field => $regex ) {
159 preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field});
160 if ( !empty( ${$field} ) )
161 ${$field} = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', ${$field}[1] ));
162 else
163 ${$field} = '';
164 }
165
166 $file_data = compact( array_keys( $all_headers ) );
167
168 return $file_data;
169 }
170 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
171 // Define all our CONSTANTS and other...
172
173 $wpdev_booking_module_for_orders = false;
174
175 function wpdev_crm_define_static() {
176
177
178 if (!function_exists ('get_option')) { die('You do not have permission to direct access to this file !!!'); }
179
180 $default_headers = array(
181 'Name' => 'Plugin Name',
182 'PluginURI' => 'Plugin URI',
183 'Version' => 'Version',
184 'Description' => 'Description',
185 'Author' => 'Author',
186 'AuthorURI' => 'Author URI',
187 'TextDomain' => 'Text Domain',
188 'DomainPath' => 'Domain Path'
189 );
190 $plugin_data = get_file_data_crm_wpdev( __FILE__, $default_headers, 'plugin' );
191
192 if (!defined('WPDEV_CRM_VERSION')) define('WPDEV_CRM_VERSION', $plugin_data['Version'] ); // 0.1
193 if (!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); // Z:\home\test.wpdevelop.com\www/wp-content
194 if (!defined('WP_CONTENT_URL')) define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // http://test.wpdevelop.com/wp-content
195 if (!defined('WP_PLUGIN_DIR')) define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins'); // Z:\home\test.wpdevelop.com\www/wp-content/plugins
196 if (!defined('WP_PLUGIN_URL')) define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); // http://test.wpdevelop.com/wp-content/plugins
197 if (!defined('WPDEV_CRM_PLUGIN_FILENAME')) define('WPDEV_CRM_PLUGIN_FILENAME', basename( __FILE__ ) ); // menu-compouser.php
198 if (!defined('WPDEV_CRM_PLUGIN_DIRNAME')) define('WPDEV_CRM_PLUGIN_DIRNAME', plugin_basename(dirname(__FILE__)) ); // menu-compouser
199 if (!defined('WPDEV_CRM_PLUGIN_DIR')) define('WPDEV_CRM_PLUGIN_DIR', WP_PLUGIN_DIR.'/'.WPDEV_CRM_PLUGIN_DIRNAME ); // Z:\home\test.wpdevelop.com\www/wp-content/plugins/menu-compouser
200 if (!defined('WPDEV_CRM_PLUGIN_URL')) define('WPDEV_CRM_PLUGIN_URL', WP_PLUGIN_URL.'/'.WPDEV_CRM_PLUGIN_DIRNAME ); // http://test.wpdevelop.com/wp-content/plugins/menu-compouser
201
202
203 // Load modules, if they exist
204 if (file_exists(WPDEV_CRM_PLUGIN_DIR. '/modules/booking-module.php')) {
205 require_once(WPDEV_CRM_PLUGIN_DIR. '/modules/booking-module.php' );
206 global $wpdev_booking_module_for_orders;
207 if ( class_exists('wpdev_booking_module_for_orders')) { $wpdev_booking_module_for_orders = new wpdev_booking_module_for_orders(); }
208 }
209
210
211 if (file_exists(WPDEV_CRM_PLUGIN_DIR. '/include/wpdev-pro.php')) { require_once(WPDEV_CRM_PLUGIN_DIR. '/include/wpdev-pro.php' ); }
212
213 if ( ! loadLocale_crm() ) { loadLocale_crm('en_US'); } //loadLocale_crm('ru_RU'); // Localization
214
215 }
216
217
218 // Load locale
219 function loadLocale_crm($locale = '') { // Load locale, if not so the load en_EN default locale from folder "languages" files like "this_file_file_name-ru_RU.po" and "this_file_file_name-ru_RU.mo"
220 if ( empty( $locale ) ) $locale = get_locale();
221 if ( !empty( $locale ) ) {
222 //Filenames like this "microstock-photo-ru_RU.po", "microstock-photo-de_DE.po" at folder "languages"
223 $mofile = WPDEV_BK_PLUGIN_DIR .'/languages/'.str_replace('.php','',WPDEV_CRM_PLUGIN_FILENAME).'-'.$locale.'.mo';
224 if (file_exists($mofile)) return load_textdomain(str_replace('.php','',WPDEV_CRM_PLUGIN_FILENAME), $mofile);
225 else return false;
226 } return
227 false;
228 }
229
230
231
232 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
233 // Getting Ajax requests
234 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
235 if ( isset( $_POST['ajax_action_crm'] ) ) {
236 define('DOING_AJAX', true);
237 require_once( dirname(__FILE__) . '/../../../wp-load.php' );
238 @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
239 wpdev_crm_define_static();
240 if ( class_exists('wpdev_crm_pro')) { $wpdev_crm_pro_in_ajax = new wpdev_crm_pro(); }
241 wpdev_crm_ajax_responder();
242 }
243
244
245
246 wpdev_crm_define_static();
247
248 if (!class_exists('wpdev_crm')) {
249 class wpdev_crm {
250 var $wpdev_crm_pro;
251 var $wpdev_booking_module_for_orders;
252 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
253 // Constructor ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
254 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
255 function wpdev_crm() {
256
257
258
259 if ( class_exists('wpdev_crm_pro')) { $this->wpdev_crm_pro = new wpdev_crm_pro(); }
260 else { $this->wpdev_crm_pro = false; }
261
262 // Add settings top line before all other menu items.
263 add_crm_action('wpdev_crm_settings_show_top_line', array($this, 'show_settings_menu_top_line'));
264 add_crm_action('wpdev_crm_settings_show_content', array(&$this, 'show_settings_menu_content'));
265
266 add_crm_action('wpdev_crm_orders_show_content', array(&$this, 'show_orders_content'));
267 add_crm_action('wpdev_crm_customers_show_content', array(&$this, 'show_customers_content'));
268
269
270 // Create admin menu
271 add_action('admin_menu', array(&$this, 'add_new_admin_menu'));
272
273
274 // Add settings link at the plugin page
275 add_filter('plugin_action_links', array(&$this, 'plugin_links'), 10, 2 );
276
277
278 // Install / Uninstall
279 register_activation_hook( __FILE__, array(&$this,'wpdev_crm_activate' ));
280 register_deactivation_hook( __FILE__, array(&$this,'wpdev_crm_deactivate' ));
281
282 wp_enqueue_script( 'jquery-ui-dialog' );
283 wp_enqueue_style( 'wpdev-bk-jquery-ui', WPDEV_CRM_PLUGIN_URL. '/css/jquery-ui.css', array(), 'wpdev-bk', 'screen' );
284
285 }
286
287
288 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
289 // ADMIN MENU SECTIONS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
290 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
291 function add_new_admin_menu(){
292 $users_roles = array(get_option( 'wpdev_crm_user_role_orders' ), get_option( 'wpdev_crm_user_role_customers' ), get_option( 'wpdev_crm_user_role_settings' ) );
293 //$users_roles = array('administrator','administrator','administrator');
294
295 for ($i = 0 ; $i < count($users_roles) ; $i++) {
296 if ( $users_roles[$i] == 'administrator' ) $users_roles[$i] = 10;
297 if ( $users_roles[$i] == 'editor' ) $users_roles[$i] = 7;
298 if ( $users_roles[$i] == 'author' ) $users_roles[$i] = 2;
299 if ( $users_roles[$i] == 'contributor' ) $users_roles[$i] = 1;
300 if ( $users_roles[$i] == 'subscriber') $users_roles[$i] = 0;
301 }
302
303 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
304 // M A I N B O O K I N G
305 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
306 $pagehook1 = add_menu_page( __('Orders', 'wpdev-crm'), __('Orders', 'wpdev-crm'), $users_roles[0],
307 __FILE__ . 'wpdev-crm', array(&$this, 'on_show_crm_page_orders'), WPDEV_CRM_PLUGIN_URL . '/img/crm-16x16.png' );
308 add_action("admin_print_scripts-" . $pagehook1 , array( &$this, 'on_add_admin_js_files'));
309 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
310 // A D D R E S E R V A T I O N
311 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
312 $pagehook2 = add_submenu_page(__FILE__ . 'wpdev-crm',__('Customers', 'wpdev-crm'), __('Customers', 'wpdev-crm'), $users_roles[1],
313 __FILE__ .'wpdev-crm-customers', array(&$this, 'on_show_crm_page_customers') );
314 add_action("admin_print_scripts-" . $pagehook2 , array( &$this, 'on_add_admin_js_files'));
315 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
316 // S E T T I N G S
317 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
318 $pagehook3 = add_submenu_page(__FILE__ . 'wpdev-crm',__('Settings', 'wpdev-crm'), __('Settings', 'wpdev-crm'), $users_roles[2],
319 __FILE__ .'wpdev-crm-settings', array(&$this, 'on_show_crm_page_settings') );
320 add_action("admin_print_scripts-" . $pagehook3 , array( &$this, 'on_add_admin_js_files'));
321 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
322
323 global $submenu, $menu; // Change Title of the Main menu inside of submenu
324 // this is make error in roleswhen we have first autor and then admin and admin roles
325 $submenu[plugin_basename( __FILE__ ) . 'wpdev-crm'][0][0] = __('Orders', 'wpdev-crm');
326
327 }
328 //Orders
329 function on_show_crm_page_orders(){
330 $this->on_show_page_adminmenu('wpdev-crm','/img/crm-48x48.png', __('Orders', 'wpdev-crm'),1);
331 }
332 //Customers
333 function on_show_crm_page_customers(){
334 $this->on_show_page_adminmenu('wpdev-crm-customers','/img/crm-48x48.png', __('Customers', 'wpdev-crm'),2);
335 }
336 //Settings
337 function on_show_crm_page_settings(){
338 $this->on_show_page_adminmenu('wpdev-crm-settings','/img/crm-48x48.png', __('Settings', 'wpdev-crm'),3);
339 }
340 //Show content
341 function on_show_page_adminmenu($html_id, $icon, $title, $content_type) {
342 ?>
343 <div id="<?php echo $html_id; ?>-general" class="wrap crmpage">
344 <?php
345 if ($content_type == 3 ) echo '<div class="icon32" style="margin:5px 40px 10px 10px;"><img src="'. WPDEV_CRM_PLUGIN_URL . $icon .'"><br /></div>' ;
346 else echo '<div class="icon32" style="margin:10px 25px 10px 10px;"><img src="'. WPDEV_CRM_PLUGIN_URL . $icon .'"><br /></div>' ; ?>
347
348 <h2><?php echo $title; ?></h2>
349 <?php
350 switch ($content_type) {
351 case 1: $this->content_of_crm_orders(); break;
352 case 2: $this->content_of_crm_customers(); break;
353 case 3: $this->content_of_crm_settings(); break;
354 default: break;
355 } ?>
356 </div>
357 <?php
358 }
359 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
360
361
362
363 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
364 // A D M I N C O N T E N T P A G E S
365 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
366 // CONTENT OF THE ADMIN O R D E R S PAGE /////////////////////////////////////////////////////////////////////////////////////////////
367 function content_of_crm_orders(){ ?>
368 <div style="height:1px;clear:both;border-bottom:1px solid #cccccc;"></div>
369 <div id="ajax_working"></div>
370 <div id="ajax_respond"></div>
371 <div style="display:none;" id="wpdev-crm-dialog-container"><div id="wpdev-crm-dialog" ><div id="wpdev-crm-dialog-content" >
372 <!--div id="modal_content1" style="display:none;" class="modal_content_text" >
373 <iframe src="http://wpdevelop.com/booking-calendar-professional/#content" style="border:1px solid red; width:1000px;height:500px;padding:0px;margin:0px;"></iframe>
374 </div-->
375 <div id="modal_content1" style="display:none;" class="modal_content_text" style="" >
376 <p style="line-height:35px;text-align:left;font-size:17px;padding:0px;margin: 0px;text-align:center;"><?php printf(__('This functionality available in %sCustomer &amp; Orders Support Professional%s','wpdev-crm'),'<b style="font-size:15px;"> ',' </b>'); ?>
377 <?php _e('Please, check feature list for this version','wpdev-crm'); ?> <a href="http://wpdevelop.com/booking-manager-professional/" target="_blank"><?php _e('here','wpdev-crm'); ?></a></p>
378 <p style="line-height:25px;text-align:center;padding-top:15px;"><a href="http://wpdevelop.com/booking-manager-professional/" target="_blank" class="buttonlinktext">Buy now</a></p>
379 </div>
380 </div></div></div>
381
382 <div style="height:10px;clear:both;"></div>
383 <?php if (!class_exists('wpdev_crm_pro')) { ?>
384 <div style="float:right;margin:0px 10px 0 0;"> <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Export (Pro)','wpdev-crm'); ?>" onclick="javascript:openModalWindowCRM(&quot;modal_content1&quot;);" /> </div>
385 <div style="float:right;margin:0px 10px 0 0;"> <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Print (Pro)','wpdev-crm'); ?>" onclick="javascript:openModalWindowCRM(&quot;modal_content1&quot;);" /> </div>
386 <?php } else { ?>
387 <div style="float:right;margin:0px 10px 0 0;"> <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Export All','wpdev-crm'); ?>" onclick="javascript:make_export_all_csv();" /> </div>
388 <div style="float:right;margin:0px 10px 0 0;"> <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Export','wpdev-crm'); ?>" onclick="javascript:make_export_csv();" /> </div>
389 <div style="float:right;margin:0px 10px 0 0;"> <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Print','wpdev-crm'); ?>" onclick="javascript:make_print('modal_content_print');" /> </div>
390 <?php } ?>
391 <div style="float:left;margin:0px 0px;"> <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Import new bookings','wpdev-crm'); ?>" onclick="javscript:importBookings();" /> </div>
392
393 <?php if (!class_exists('wpdev_crm_pro')) { ?>
394 <div style="float:left;margin:0px 0px;"> <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Show filters (Pro)','wpdev-crm'); ?>" onclick="javascript:openModalWindowCRM(&quot;modal_content1&quot;);" /> </div>
395 <?php } else { ?>
396 <?php make_crm_action('wpdev_crm_show_orders_filter'); ?>
397 <?php } ?>
398
399 <div style="height:10px;clear:both;"></div>
400 <?php make_crm_action('wpdev_crm_orders_show_content'); ?>
401 <div style="height:10px;clear:both;"></div>
402 <div style="float:left;margin:0px 0px;">
403 <?php
404 if (isset($_GET['show_all_records'])) {
405 if ($_GET['show_all_records']=='1') { ?>
406 <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Show orders on several pages','wpdev-crm'); ?>" onclick="javscript:showNormalRecordsAtOnePage();" /> </div>
407 <?php } else { ?>
408 <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Show records at one page','wpdev-crm'); ?>" onclick="javscript:showAllRecordsAtOnePage();" /> </div>
409 <?php }
410 } else { ?>
411 <input type="button" class="button" style="font-weight:bold;" value="<?php _e('Show records at one page','wpdev-crm'); ?>" onclick="javscript:showAllRecordsAtOnePage();" /> </div>
412 <?php } ?>
413
414 <div style="height:10px;clear:both;"></div>
415 <?php
416 }
417
418 // Show content of orders
419 function show_orders_content(){ global $wpdb;
420 global $wpdev_booking_module_for_orders;
421 // D E F I N E I N I T I A L P A R A M E T E R S //////////////////////////////////////////////////////////////
422 $start_just_page = '0';
423 if (isset($_GET['wpdev_page_num']))
424 if ( ($_GET['wpdev_page_num'] +0 ) > 0)
425 $start_just_page = $_GET['wpdev_page_num'];
426
427 $cont_on_page = get_option( 'wpdev_crm_rows_per_page_orders' );
428 if (isset($_GET['show_all_records']))
429 if ($_GET['show_all_records']=='1')
430 $cont_on_page = 'all';
431 if ($cont_on_page == 'all') {$cont_on_page = '10000'; $start_just_page = '0'; }
432
433 $start_page = ((int) $start_just_page) * ((int) $cont_on_page);
434 $sort_array_tags = array('date','id','customer','order_date','type','cost','email','internal_filter');
435
436 $table_sort_tags = array('','ordr.order_id','ordr.customer_id','ordr.order_date','ordr.type','ordr.cost','custmr.email','ordr.internal_filters');
437 $sort_tag_for_table ='';
438
439 // Set TYPE of SORTING : dates, id, customer, order_date, type, cost
440 $sorted_structure = array();
441 $sort_type = 'id'; $sort_order = 'DESC'; $ii=0;
442 if (isset($_GET['wpdev_sort_order'])) { // CHECK S O R T T A Gs
443 foreach ($sort_array_tags as $sort_tag) {
444 if ($_GET['wpdev_sort_order'] == $sort_tag) { $sort_type = $sort_tag; $sort_order = 'ASC'; $sort_tag_for_table = $table_sort_tags[$ii] ; }
445 if ($_GET['wpdev_sort_order'] == ($sort_tag . '_desc') ) { $sort_type = $sort_tag; $sort_order = 'DESC';$sort_tag_for_table = $table_sort_tags[$ii] ; }
446 $ii++;
447 }
448 }
449
450 if ($sort_tag_for_table !=='') $sort_tag_for_table .= ' ' . $sort_order . ', ';
451
452 $booking_date_view_type = get_option( 'booking_date_view_type'); // Get data from Booking Plugin according hided dates
453 if ($booking_date_view_type == 'short'){ $wide_days_class = ' hide_dates_view '; $short_days_class = ''; }
454 else { $wide_days_class = ''; $short_days_class = ' hide_dates_view '; }
455
456 $sort_url = '<a style="color:#fff;" href="admin.php?page='. WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME. 'wpdev-crm';
457 $sort_url = '<a style="color:#fff;" href="javascript:;" onclick="javascript:reloadpage_with_param(\'wpdev_sort_order\',\'';
458
459 //if (isset( $_GET['wpdev_filter_customer'] )) { $sort_url .= '&wpdev_filter_customer=' . $_GET['wpdev_filter_customer']; }
460 //$sort_url .= '&wpdev_sort_order=';
461
462
463 $arr_asc = '<img src="'.WPDEV_CRM_PLUGIN_URL.'/img/arrow-down.png" width="12" height="12" style="margin:0 0px -3px 0;">';
464 $arr_desc = '<img src="'.WPDEV_CRM_PLUGIN_URL.'/img/arrow-up.png" width="12" height="12" style="margin:0 0px -3px 0;">';
465
466 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
467 $where = '';
468
469 if (isset($_GET['wpdev_filter_customer'])) {
470 if ( $_GET['wpdev_filter_customer'] != '0') {
471 if ($where !== '') { $where .= ' AND '; }
472 $where .= ' custmr.customer_id = '. $_GET['wpdev_filter_customer'] . ' ';
473 }
474 }
475
476
477 // TODO: add here filter and set it to pro
478 $where = apply_crm_filter('wpdev_where_filter', $where);
479 /*// Pro functionality //////////////////////////////////////////////////////////////////////////////
480 if (isset($_GET['wpdev_filter_order_type'])) {
481 if ( ( $_GET['wpdev_filter_order_type'] !== '' ) && ( $_GET['wpdev_filter_order_type'] != '0' ) ) {
482 if ($where !== '') { $where .= ' AND '; }
483 $where .= ' ordr.internal_filters1 = '. $_GET['wpdev_filter_order_type'] . ' ';
484 }
485 }
486 if (isset($_GET['wpdev_filter_bk_dates_start'])) {
487 if ( ( $_GET['wpdev_filter_bk_dates_start'] !== '' ) && ( $_GET['wpdev_filter_bk_dates_start'] != '0' ) ) {
488 if ($where !== '') { $where .= ' AND '; }
489 $my_date = explode('-',$_GET['wpdev_filter_bk_dates_start']);
490 $my_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00' );
491 $where .= ' ordr.internal_filters2 > \''. $my_date . '\' ';
492 }
493 }
494 if (isset($_GET['wpdev_filter_bk_dates_fin'])) {
495 if ( ( $_GET['wpdev_filter_bk_dates_fin'] !== '' ) && ( $_GET['wpdev_filter_bk_dates_fin'] != '0' ) ) {
496 if ($where !== '') { $where .= ' AND '; }
497 $my_date = explode('-',$_GET['wpdev_filter_bk_dates_fin']);
498 $my_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '23', '59', '59' );
499 $where .= ' ordr.internal_filters3 < \''. $my_date . '\' ';
500 }
501 }
502 if (isset($_GET['wpdev_filter_cost_start'])) {
503 if ( ($_GET['wpdev_filter_cost_start'] +0) > 0 ) {
504 if ($where !== '') { $where .= ' AND '; }
505 $where .= ' ordr.cost > '. $_GET['wpdev_filter_cost_start'] . ' ';
506 }
507 }
508 if (isset($_GET['wpdev_filter_cost_fin'])) {
509 if ( ($_GET['wpdev_filter_cost_fin'] +0) > 0 ) {
510 if ($where !== '') { $where .= ' AND '; }
511 $where .= ' ordr.cost < '. $_GET['wpdev_filter_cost_fin'] . ' ';
512 }
513 }/**/
514 ///////////////////////////////////////////////////////////////////////////////////////////////////
515 //debuge($where);
516
517 if ($where !== '') $where = ' WHERE ' . $where;
518
519 //Set here order by some field
520 $sql = "SELECT count(ordr.order_id) as cnt
521 FROM ".$wpdb->prefix ."wpdev_crm_orders as ordr
522 INNER JOIN ".$wpdb->prefix ."wpdev_crm_customers as custmr
523 ON ordr.customer_id = custmr.customer_id
524 " . $where ."
525 ORDER BY ".$sort_tag_for_table." ordr.order_id DESC";
526
527 $result = $wpdb->get_results( $sql );
528 $togather_pages = ceil($result[0]->cnt / ((int) $cont_on_page));
529
530 $sql = "SELECT *
531 FROM ".$wpdb->prefix ."wpdev_crm_orders as ordr
532 INNER JOIN ".$wpdb->prefix ."wpdev_crm_customers as custmr
533 ON ordr.customer_id = custmr.customer_id " .
534 $where ."
535 ORDER BY ".$sort_tag_for_table." ordr.order_id DESC LIMIT " .$start_page . "," . $cont_on_page;
536
537 // debuge($sql);
538 $result = $wpdb->get_results( $sql );
539 // debuge($result);
540 ?>
541 <table class='booking_table' cellspacing="0" id="wpdev_order_table">
542 <tr>
543 <th style="width:28px;">
544 <?php echo $sort_url; ?><?php
545 if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']=='id') echo 'id_desc'; else echo 'id'; }
546 else echo 'id'; ?>');"><?php _e('ID', 'wpdev-crm'); ?></a><?php
547 if ( ($_GET['wpdev_sort_order']=='id') ) echo $arr_asc;
548 if ( ($_GET['wpdev_sort_order']=='id_desc') || (! isset( $_GET['wpdev_sort_order']) ) ) echo $arr_desc;
549 ?>
550 </th>
551 <th style="width:auto;"><?php _e('Info', 'wpdev-crm'); ?>
552
553 <?php if ( class_exists('wpdev_booking')) { ?>
554
555 <span style="font-size: 10px; font-weight: normal;">(<?php // printf(__('Sort results by: ','wpdev-crm'),'<strong>','</strong>'); ?>
556 <?php $current_sort_type = 'internal_filter'; $current_sort_type_title = __('Dates', 'wpdev-crm');
557 echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>');"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?>
558 <?php /* ?>, <?php $current_sort_type = 'email'; $current_sort_type_title = __('Email', 'wpdev-crm');
559 echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>');"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?>
560 <?php /**/ ?>
561 )</span>
562
563
564 <div style="float:right;">
565 <span class="showwidedates<?php echo $short_days_class; ?>" style="cursor: pointer;text-decoration: none;font-size:10px;" onclick="javascript:
566 jWPDev('.short_dates_view').addClass('hide_dates_view');
567 jWPDev('.short_dates_view').removeClass('show_dates_view');
568 jWPDev('.wide_dates_view').addClass('show_dates_view');
569 jWPDev('.wide_dates_view').removeClass('hide_dates_view');
570 jWPDev('#showwidedates').addClass('hide_dates_view');
571
572 jWPDev('.showwidedates').addClass('hide_dates_view');
573 jWPDev('.showshortdates').addClass('show_dates_view');
574 jWPDev('.showshortdates').removeClass('hide_dates_view');
575 jWPDev('.showwidedates').removeClass('show_dates_view');
576
577 "><img src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/arrow-left.png" width="16" height="16" style="margin:0 5px -4px 0;"><?php _e('Wide Days view', 'wpdev-crm'); ?><img src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/arrow-right.png" width="16" height="16" style="margin:0 0px -4px 5px;"></span>
578 <span class="showshortdates<?php echo $wide_days_class; ?>" style="cursor: pointer;text-decoration: none;font-size:10px;" onclick="javascript:
579 jWPDev('.wide_dates_view').addClass('hide_dates_view');
580 jWPDev('.wide_dates_view').removeClass('show_dates_view');
581 jWPDev('.short_dates_view').addClass('show_dates_view');
582 jWPDev('.short_dates_view').removeClass('hide_dates_view');
583
584 jWPDev('.showshortdates').addClass('hide_dates_view');
585 jWPDev('.showwidedates').addClass('show_dates_view');
586 jWPDev('.showwidedates').removeClass('hide_dates_view');
587 jWPDev('.showshortdates').removeClass('show_dates_view');
588 "><img src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/arrow-right.png" width="16" height="16" style="margin:0 5px -4px 0;"><?php _e('Short Days view', 'wpdev-crm'); ?><img src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/arrow-left.png" width="16" height="16" style="margin:0 0px -4px 5px;"></span>
589 </div>
590 <?php } ?>
591 </th>
592 <th style="width:75px;"><?php $current_sort_type = 'customer'; $current_sort_type_title = __('Customer', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>');"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
593 <th style="width:45px;"><?php $current_sort_type = 'type'; $current_sort_type_title = __('Type', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>');"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
594 <th style="width:95px;"><?php $current_sort_type = 'order_date'; $current_sort_type_title = __('Date of order', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>');"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
595 <?php if ( class_exists('wpdev_bk_premium')) {
596 ?> <th style="width:45px;border-bottom: 1px solid #aaa;"><?php $current_sort_type = 'cost'; $current_sort_type_title = __('Cost', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>');"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th><?php
597 } ?>
598 <!--th style="width:50px;"><?php _e('Actions', 'wpdev-crm'); ?></th>
599 <th style="width:50px;"><?php _e('Labels', 'wpdev-crm'); ?></th-->
600 </tr>
601 <?php
602 $result_structure = array();
603 $ns = -1;
604 $last_date = $last_show_date = '';
605
606 // Get S T R U C T U R E for O R D E R
607 foreach ($result as $res) {
608 $ns++;
609 $content = false;
610 $my_type = unserialize($res->type);
611 $order_type = 0;
612 // C O N T E N T
613 if (isset($my_type['booking'])) { // C O N T E N T
614 if ( function_exists ('get_form_content')) { // Booking
615 $content = get_form_content($res->order_info, $my_type['booking']);
616 $order_type = $my_type['booking'];
617 $result_structure[$ns]['content'] = str_replace('<br/>', '', $content['content']);
618 $result_structure[$ns]['content'] = str_replace('<br />', '', $result_structure[$ns]['content']);
619 } else {
620 $result_structure[$ns]['content'] = __( 'Booking Calendar plugin is not installed. This plugin is requred Booking Calendar for this type of records. ', 'wpdev-crm');
621 }
622 } else $result_structure[$ns]['content'] = $res->order_info; // SOME OTHER ORDERS
623
624
625 if ($content) // D A T E S
626 if (isset($content['_all_'])) {
627 if (isset($content['_all_']['booking_dates'])) {
628 $my_dates = explode(',',$content['_all_']['booking_dates']);
629 sort($my_dates);
630 $result_structure[$ns]['dates'] = $my_dates;
631 if ($wpdev_booking_module_for_orders!== false)
632 $result_structure[$ns]['short_dates'] = $wpdev_booking_module_for_orders->get_booking_short_days($my_dates);
633 }
634 if (isset($content['_all_']['email' . $my_type['booking'] ])) {
635 $result_structure[$ns]['email'] = $content['_all_']['email' . $my_type['booking'] ];
636 }
637 $result_structure[$ns]['all'] = $content['_all_']; // A l l b o o k i n g d a t a
638 }
639
640 $result_structure[$ns]['id'] = $res->order_id; // I D
641 $result_structure[$ns]['customer'] = $res->second_name . ' ' .$res->name; // C u s t o m e r
642 $result_structure[$ns]['customer_id'] = $res->customer_id ; // C u s t o m e r ID
643 $result_structure[$ns]['order_date'] = $res->order_date; // O r d e r D a t e
644 $result_structure[$ns]['type'] = $order_type; // O r d e r T y p e
645 if ( class_exists('wpdev_bk_premium')) $result_structure[$ns]['cost']= $res->cost; // O r d e r C o s t
646 }
647 //debuge($result_structure, $sort_type);
648 // S O R T process
649 foreach ($result_structure as $key=>$value) {
650 switch ($sort_type) {
651 case 'date':
652 if ( ! empty($sorted_structure[$value['dates'][0]])) $sorted_structure[$value['dates'][0] . (time() * rand()) ] = $value;
653 else $sorted_structure[$value['dates'][0]] = $value; break;
654 case 'email':
655 if ( ! empty($sorted_structure[$value['email']])) $sorted_structure[$value['email'] . (time() * rand()) ] = $value;
656 else $sorted_structure[$value['email']] = $value; break;
657 case 'customer': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break;
658 case 'order_date': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break;
659 case 'id': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break;
660 case 'type': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break;
661 case 'cost': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break;
662 // Check booking here
663 //case 'email': if ( ! empty($sorted_structure[$value['all']['email' . $value['type'] ]])) $sorted_structure[$value['all']['email' . $value['type'] ] . (time() * rand()) ] = $value; else $sorted_structure[strtolower($value['all']['email' . $value['type'] ])] = $value; break;
664 default: $sorted_structure[$value['id']] = $value; break;
665 }
666 //debuge($sorted_structure);
667 }
668 // if ($sort_order == 'DESC') krsort($sorted_structure );
669 // else ksort($sorted_structure );
670
671 $alternative_color = '';
672 $summ_togather = 0;
673
674
675 // L o o p A l l R O W S
676 foreach ($sorted_structure as $sort_element) {
677
678 if ( $alternative_color == '') {$alternative_color = ' class="alternative_color" ';} else { $alternative_color = '';} ?>
679
680 <tr>
681 <td<?php echo $alternative_color ?> style="border-right:1px solid #ccc;text-align:center;"><?php echo $sort_element['id']; ?></td>
682 <td<?php echo $alternative_color ?> style="border-right:1px solid #ccc;font-size:11px;"><?php echo $sort_element['content']; ?>
683 <?php
684 if (isset($sort_element['dates'])) $my_dates = $sort_element['dates'];
685 $outColorClass = 0;
686 ?>
687 <div style="height: 0px; clear: both;margin:3px;" class="clear topmenuitemseparatorv0"></div>
688 <div style="float:left;height:auto;line-height: 21px; "><strong><?php _e('Booking dates','wpdev-crm') ?></strong>:&nbsp;</div>
689
690 <div id="wide_dates_view<?php echo $sort_element['id'];?>" class="wide_dates_view<?php echo $wide_days_class; ?>" >
691 <?php foreach ($my_dates as $date_key => $bkdate) {
692 $date_class = ( date('m', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('d', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('Y', mysql2date('U',$bkdate)) + 0 ); ?>
693 <span class="<?php echo "adate-" . $date_class; ?>"><a href="#" class="booking_overmause<?php echo $outColorClass; ?>" ><?php
694 echo apply_filters('wpdev_bk_get_showing_date_format', mysql2date('U', $bkdate )); ?>
695 </a></span><?php
696 //make_bk_action('show_subtype_num',$bk['booking_type'], $bk['id'], $bkdate);
697 if ($date_key != (count($my_dates)-1)) echo ", ";
698 }
699 echo '</div><div id="short_dates_view'.$sort_element['id'].'" class="short_dates_view'. $short_days_class. '" >';
700
701 $short_days = $sort_element['short_dates']; //if ($wpdev_booking_module_for_orders!== false) $wpdev_booking_module_for_orders->get_booking_short_days($my_dates);
702 if ( isset($short_days))
703 // SHORT DAYS ECHO
704 foreach ($short_days[0] as $bkdate) { //echo $bkdate; continue;
705 if ((trim($bkdate) != ',') && (trim($bkdate) != '-')) { //eco date
706 $date_class = ( date('m', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('d', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('Y', mysql2date('U',$bkdate)) + 0 );
707
708 echo '<span class="adate-'.$date_class.'"><a href="#" class="booking_overmause'. $outColorClass.'"'.
709 ' >' . apply_filters('wpdev_bk_get_showing_date_format', mysql2date('U', $bkdate )) .
710 '</a></span>';
711 //echo apply_bk_filter('filter_subtype_num','',$bk['booking_type'], $bk['id'], $bkdate);
712 echo ' ';
713 } else { // echo separator
714 echo '<span class="date_tire">'.$bkdate.' </span>' ;
715 }
716 }
717 ?>
718 </div>
719 </td>
720 <td<?php echo $alternative_color ?> style="border-right:1px solid #ccc;"><?php
721 //debuge($sort_element);die;
722 echo '<a class="bktypetitle" style="line-height: 25px; background-color:#888;text-shadow:0 -1px 0 #CCCCCC;color:#fff; padding: 2px 5px; font-size: 10px; white-space: nowrap;" href="admin.php?page=' . WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME . 'wpdev-crm-customers'.'&wpdev_selected_customer='.$sort_element['customer_id'].'">';
723 echo $sort_element['customer']; $current_customer = $sort_element['customer']; ?></a></td>
724 <td<?php echo $alternative_color ?> style="border-right:1px solid #ccc;"><?php
725 if (function_exists('get_booking_title')) {
726 $title = get_booking_title( $sort_element['type'] ) ;
727 echo '<a class="bktypetitle" style="line-height: 25px; background-color:#fff; padding: 2px 5px; font-size: 10px; white-space: nowrap;" href="admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/'. WPDEV_BK_PLUGIN_FILENAME . 'wpdev-crm'.'&booking_type='.$sort_element['type'].'" >' , $title , '</a>';
728 }
729 ?></td>
730 <td<?php echo $alternative_color ?> style="border-right:1px solid #ccc;padding:0px 5px 0px 5px;"><?php
731 $order_year = ( date('Y', mysql2date('U',$sort_element['order_date'])) + 0 );
732 //debuge($sort_element['order_date']);
733 if ( $order_year != '1970') {
734 $outColorClass = 1;
735 $date_class = ( date('m', mysql2date('U',$sort_element['order_date'])) + 0 ) . '-' . ( date('d', mysql2date('U',$sort_element['order_date'])) + 0 ) . '-' . ( date('Y', mysql2date('U',$sort_element['order_date'])) + 0 ); ?>
736 <span class="<?php echo "adate-" . $date_class; ?>"><a href="#" class="booking_overmause<?php echo $outColorClass; ?>" ><?php
737 echo apply_filters('wpdev_bk_get_showing_date_format', mysql2date('U', $sort_element['order_date'] ));
738 ?></a></span>
739 <?php } ?>
740 </td>
741 <?php if ( class_exists('wpdev_bk_premium')) { ?>
742 <th<?php echo $alternative_color ?>><?php
743 $cost_currency = '';
744 $cost_currency = get_option( 'booking_paypal_curency' );
745 if ($cost_currency == 'USD' ) $cost_currency = '$';
746 elseif ($cost_currency == 'EUR' ) $cost_currency = '&euro;';
747 elseif ($cost_currency == 'GBP' ) $cost_currency = '&#163;';
748 elseif ($cost_currency == 'JPY' ) $cost_currency = '&#165;';
749
750 echo $cost_currency ,$sort_element['cost'];
751 $summ_togather += (float) $sort_element['cost'];
752 ?></th>
753 <?php } ?>
754 <!--td<?php echo $alternative_color ?>><?php _e('Actions', 'wpdev-crm'); ?></td>
755 <td<?php echo $alternative_color ?>><?php _e('Labels', 'wpdev-crm'); ?></td-->
756 </tr>
757 <?php
758 }
759
760 // T a bl e f o o t e r
761 if ( count($sorted_structure) > 0 ) {
762 ?>
763 <tr>
764 <th style="border-top:1px solid #777;" align="left" colspan="2">
765 <?php
766 $page_url = 'admin.php?page='. WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME. 'wpdev-crm';
767 if (isset( $_GET['wpdev_filter_customer'] )) { $page_url .= '&wpdev_filter_customer=' . $_GET['wpdev_filter_customer']; }
768 if (isset( $_GET['wpdev_sort_order'] )) { $page_url .= '&wpdev_sort_order=' . $_GET['wpdev_sort_order']; }
769 for ($ii = 0; $ii < $togather_pages; $ii++) {
770 if ($start_just_page == $ii) $selected_page = ' selected ';
771 else $selected_page = '';
772 ?><a class="<?php echo $selected_page; ?>"
773 href="javascript:;" onclick="javascript:reloadpage_with_param('wpdev_page_num',<?php echo $ii ?>);"
774 style="color:#fff;"><?php echo ($ii+1) ?></a> &nbsp;<?php
775 } ?>
776 </th>
777 <th style="border-top:1px solid #777;"></th>
778 <th style="border-top:1px solid #777;"></th>
779 <th style="border-top:1px solid #777;font-size: 15px;" align="right"><?php if ( class_exists('wpdev_bk_premium')) { _e('Summ','wpdev-crm'); echo ' :'; } ?></th>
780 <?php if ( class_exists('wpdev_bk_premium')) { ?>
781 <th<?php echo $alternative_color ?> style="border-top:1px solid #777;font-size: 15px;"><?php
782 $cost_currency = '';
783 $cost_currency = get_option( 'booking_paypal_curency' );
784 if ($cost_currency == 'USD' ) { $cost_currency = '$'; }
785 elseif ($cost_currency == 'EUR' ) { $cost_currency = '&euro;'; }
786 elseif ($cost_currency == 'GBP' ) $cost_currency = '&#163;';
787 elseif ($cost_currency == 'JPY' ) $cost_currency = '&#165;';
788
789 echo $cost_currency ,$summ_togather;
790 ?></th>
791 <?php }?>
792 </tr>
793 <?php } else { ?>
794 <tr><td colspan="6" style="text-align: center; " class="this_td_empty">
795 <strong><?php _e('There are no orders. ','wpdev-crm') ?></strong><br/><br/>
796 <?php printf(__('Right now current plugin is support orders from %s or newer.','wpdev-crm'), '<strong>Booking Calendar v.2.1</strong>'); ?><br/><br/>
797 <?php printf(__('You can install %s%s%s now for free. ','wpdev-crm'), '<a href="'.get_option('siteurl') . '/wp-admin/plugin-install.php?tab=search&type=tag&s=reservation-service">', '<strong>Booking Calendar Standard</strong>','</a>'); ?><br/>
798 </td></tr>
799 <?php } ?>
800 </table>
801 <?php
802
803 make_crm_action('wpdev_crm_make_generate_sorted_structure', $sorted_structure);
804 /*
805
806 $wpdev_csv = new adv_csv();
807 $csv = $wpdev_csv->adv_html_to_csv($out1);
808
809 $dir_relative = ''; //$b['host'] . dirname ( $b['path'] );
810 $dir = $_SERVER['DOCUMENT_ROOT'] .$dir_relative ; //$b['host'] . dirname ( $b['path'] );
811
812 $fp = fopen( $dir . '/' . 'file.csv' , 'w' );
813 $search = array ("'<script[^>]*?>.*?</script>'si","'<[\/\!]*?[^<>]*?>'si","'([\r\n])[\s]+'","'&(quot|#34);'i","'&(amp|#38);'i","'&(lt|#60);'i","'&(gt|#62);'i","'&(nbsp|#160);'i","'&(iexcl|#161);'i","'&(cent|#162);'i","'&(pound|#163);'i","'&(copy|#169);'i","'&#(\d+);'e");
814 $replace = array ("","","\\1","\"","&","<",">"," ",chr(161),chr(162),chr(163),chr(169),"chr(\\1)");
815 $csv = preg_replace($search, $replace, $csv);
816
817 fwrite($fp, $csv);
818 //foreach ($csv as $line) { fputcsv($fp, split(',', $line)); }
819 fclose($fp);
820 //debuge($csv);/**/
821 ?>
822
823 <script type="text/javascript">
824 <?php if ( isset($_GET['wpdev_filter_customer']) ){
825 if ( $_GET['wpdev_filter_customer'] != '0') {
826 ?>
827 //var val1 = '<img src="<?php echo WPDEV_BK_PLUGIN_URL; ?>/img/<?php echo $selected_icon; ?>"><br />';
828 //jQuery('div.wrap div.icon32').html(val1);
829 //jQuery('div.bookingpage h2').after('<?php echo $support_links; ?>');
830 jQuery('div.crmpage h2').html( jQuery('div.crmpage h2').html() + '<?php echo ' '; _e('from','wpdev-crm'); echo ' ', $current_customer ; ?>');
831 <?php } } ?>
832 </script>
833 <?php
834 }
835
836
837
838 // CONTENT OF THE ADMIN PAGE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
839 function content_of_crm_customers(){?>
840 <div style="height:1px;clear:both;border-bottom:1px solid #cccccc;"></div>
841 <div id="ajax_working"></div>
842
843 <div style="display:none;" id="wpdev-crm-dialog-container"><div id="wpdev-crm-dialog" ><div id="wpdev-crm-dialog-content" >
844 <!--div id="modal_content1" style="display:none;" class="modal_content_text" >
845 <iframe src="http://wpdevelop.com/booking-manager-professional/#content" style="border:1px solid red; width:1000px;height:500px;padding:0px;margin:0px;"></iframe>
846 </div-->
847 <div id="modal_content1" style="display:none;" class="modal_content_text" style="" >
848 <p style="line-height:25px;text-align:left;"><?php printf(__('This functionality exist at %sProfessional%s version.','wpdev-crm'),'<a href="http://wpdevelop.com/booking-manager-professional/" target="_blank">','</a>','<a href="http://wpdevelop.com/booking-manager-professional/" target="_blank">','</a>','<a href="http://wpdevelop.com/booking-manager-professional/" target="_blank">','</a>'); ?>
849 Please, check feature list for this version <a href="http://wpdevelop.com/booking-manager-professional/" target="_blank">here</a></p>
850 <p style="line-height:25px;text-align:center;padding-top:15px;"><a href="http://wpdevelop.com/booking-manager-professional/" target="_blank" class="buttonlinktext">Buy now</a></p>
851 </div>
852 </div></div></div>
853
854 <?php make_crm_action('wpdev_crm_customers_show_content');
855 }
856 // Show content of orders
857 function show_customers_content(){ global $wpdb;
858
859 // D E F I N E I N I T I A L P A R A M E T E R S //////////////////////////////////////////////////////////////
860 $start_just_page = '0';
861 if (isset($_GET['wpdev_page_num']))
862 if ( ($_GET['wpdev_page_num'] +0 ) > 0)
863 $start_just_page = $_GET['wpdev_page_num'];
864
865 $cont_on_page = get_option( 'wpdev_crm_rows_per_page_customers' );
866 $start_page = ((int) $start_just_page) * ((int) $cont_on_page);
867
868 $sort_array_tags = array( 'id','name','email','phone','adress','city','country','orders_num');
869
870 $table_sort_tags = array( 'custmr.customer_id','custmr.second_name','custmr.email','custmr.phone','custmr.adress','custmr.city','custmr.country','cnt');
871 $sort_tag_for_table ='';
872
873
874 // Set TYPE of SORTING : dates, id, customer, order_date, type, cost
875 $sorted_structure = array();
876 $sort_type = 'id'; $sort_order = 'DESC'; $ii=0;
877 if (isset($_GET['wpdev_sort_order'])) { // CHECK S O R T T A Gs
878 foreach ($sort_array_tags as $sort_tag) {
879 if ($_GET['wpdev_sort_order'] == $sort_tag) { $sort_type = $sort_tag; $sort_order = 'ASC'; $sort_tag_for_table = $table_sort_tags[$ii] ; }
880 if ($_GET['wpdev_sort_order'] == ($sort_tag . '_desc') ) { $sort_type = $sort_tag; $sort_order = 'DESC';$sort_tag_for_table = $table_sort_tags[$ii] ; }
881 $ii++;
882 }
883 }
884 if ($sort_tag_for_table !=='') $sort_tag_for_table .= ' ' . $sort_order . ', ';
885 $sort_url = '<a style="color:#fff;" href="admin.php?page='. WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME. 'wpdev-crm-customers&wpdev_sort_order=';
886 $arr_asc = '<img src="'.WPDEV_CRM_PLUGIN_URL.'/img/arrow-down.png" width="12" height="12" style="margin:0 0px -3px 0;">';
887 $arr_desc = '<img src="'.WPDEV_CRM_PLUGIN_URL.'/img/arrow-up.png" width="12" height="12" style="margin:0 0px -3px 0;">';
888
889 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
890
891 //Set here order by some field
892 $sql = "SELECT count(custmr.customer_id) as cnt
893 FROM ".$wpdb->prefix ."wpdev_crm_customers as custmr
894 ORDER BY ".$sort_tag_for_table." custmr.customer_id DESC";
895
896 $result = $wpdb->get_results( $sql );
897 $togather_pages = ceil($result[0]->cnt / ((int) $cont_on_page));
898
899
900 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
901 // S Q L
902 $sql = "SELECT custmr.*, count(ordr.order_id) as cnt
903 FROM ".$wpdb->prefix ."wpdev_crm_customers as custmr
904 INNER JOIN ".$wpdb->prefix ."wpdev_crm_orders as ordr
905 ON ordr.customer_id = custmr.customer_id
906 GROUP by customer_id
907 ORDER BY ".$sort_tag_for_table." custmr.customer_id DESC LIMIT " .$start_page . "," . $cont_on_page ;
908 $result = $wpdb->get_results( $sql );
909
910 $alternative_color = '';
911 ?>
912 <br/><br/><table class='booking_table' cellspacing="0" >
913 <tr>
914 <th style="width:28px;"> <?php echo $sort_url; ?><?php
915 if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']=='id') echo 'id_desc'; else echo 'id'; }
916 else echo 'id'; ?>"><?php _e('ID', 'wpdev-crm'); ?></a><?php
917 if ( ($_GET['wpdev_sort_order']=='id') ) echo $arr_asc;
918 if ( ($_GET['wpdev_sort_order']=='id_desc') || (! isset( $_GET['wpdev_sort_order']) ) ) echo $arr_desc;
919 ?>
920 </th>
921 <th style="width:70px;"><?php $current_sort_type = 'name'; $current_sort_type_title = __('Name', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
922 <th style="width:170px;"><?php $current_sort_type = 'email'; $current_sort_type_title = __('Email', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
923 <th style="width:90px;"><?php $current_sort_type = 'phone'; $current_sort_type_title = __('Phone', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
924 <th style="width:auto;"><?php $current_sort_type = 'adress'; $current_sort_type_title = __('Adress', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
925 <th style="width:75px;"><?php $current_sort_type = 'city'; $current_sort_type_title = __('City', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
926 <th style="width:65px;"><?php $current_sort_type = 'country'; $current_sort_type_title = __('Country', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
927 <th style="width:117px;"><?php $current_sort_type = 'orders_num'; $current_sort_type_title = __('Count of Orders', 'wpdev-crm'); echo $sort_url; if (isset($_GET['wpdev_sort_order'])) { if ($_GET['wpdev_sort_order']== $current_sort_type ) echo $current_sort_type . '_desc'; else echo $current_sort_type ; } else echo $current_sort_type . '_desc'; ?>"><?php echo $current_sort_type_title ; ?></a><?php if ($_GET['wpdev_sort_order']== $current_sort_type ){ echo $arr_asc; } if ($_GET['wpdev_sort_order']== $current_sort_type . '_desc'){ echo $arr_desc; } ?></th>
928 <!--th style="width:50px;"><?php _e('Actions', 'wpdev-crm'); ?></th-->
929 </tr>
930 <?php
931 $page_url = 'admin.php?page='. WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME. 'wpdev-crm';
932
933 for ($i = 0; $i < count($result); $i++) {
934 if ( $alternative_color == '') {$alternative_color = ' class="alternative_color" ';} else { $alternative_color = '';}
935
936 if (isset($_GET['wpdev_selected_customer']))
937 if ($_GET['wpdev_selected_customer'] == $result[$i]->customer_id ) {
938 $alternative_color = ' class="selected_row_color" ';
939 }
940
941 ?>
942 <tr>
943 <td style="text-align:center;border-right:1px solid #ccc;" <?php echo $alternative_color ?>><?php echo $result[$i]->customer_id; ?></td>
944 <td style="border-right:1px solid #ccc;" <?php echo $alternative_color ?>>
945 <a href="<?php echo $page_url . '&wpdev_filter_customer=' . $result[$i]->customer_id; ?>" style="line-height: 25px; background-color: rgb(136, 136, 136); text-shadow: 0pt -1px 0pt rgb(204, 204, 204); color: rgb(255, 255, 255); padding: 2px 5px; font-size: 10px; white-space: nowrap;" class="bktypetitle">
946 <?php echo $result[$i]->second_name . ' ' . $result[$i]->name; ?></a>
947 </td>
948 <td style="border-right:1px solid #ccc;" <?php echo $alternative_color ?>><?php echo $result[$i]->email; ?></td>
949 <td style="border-right:1px solid #ccc;" <?php echo $alternative_color ?>><?php echo $result[$i]->phone; ?></td>
950 <td style="border-right:1px solid #ccc;" <?php echo $alternative_color ?>><?php echo $result[$i]->adress; ?></td>
951 <td style="border-right:1px solid #ccc;text-align:center;" <?php echo $alternative_color ?>><?php echo $result[$i]->city; ?></td>
952 <td style="border-right:1px solid #ccc;text-align:center;" <?php echo $alternative_color ?>><?php echo $result[$i]->country; ?></td>
953 <td style="border-right:1px solid #ccc;text-align:center;" <?php echo $alternative_color ?>>
954 <a href="<?php echo $page_url . '&wpdev_filter_customer=' . $result[$i]->customer_id; ?>" style="line-height: 25px; background-color: rgb(136, 136, 136); text-shadow: 0pt -1px 0pt rgb(204, 204, 204); color: rgb(255, 255, 255); padding: 2px 5px; font-size: 10px; white-space: nowrap;" class="bktypetitle">
955 <?php echo $result[$i]->cnt; ?></a></td>
956 <?php /* ?>
957 <td style="text-align:center;" <?php echo $alternative_color ?>>
958 <?php
959 if ($bk_type==0) if (isset($type_items[ $bk['booking_type'] ]))
960 echo '<a href="admin.php?page=' . WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME . 'wpdev-crm'.'&booking_type='.$bk['booking_type'].'" class="bktypetitle" style="line-height:25px;background-color:#fff;padding:2px 5px;font-size:10px;white-space:nowrap;">' . $type_items[ $bk['booking_type'] ] . '</a>';
961
962 ?>
963 <a href="javascript:;" onclick='javascript:openModalWindowCRM(&quot;modal_content1&quot;);' >
964 <img src="<?php echo WPDEV_CRM_PLUGIN_URL . '/img/delete_type.png'; ?>" class="tipcy" title='<?php echo __('Edit reservation','wpdev-crm'); ?>'
965 /></a>
966 <?php ?>
967 <a href="javascript:;" onclick='javascript:openModalWindowCRM(&quot;modal_content1&quot;);' >
968 <img src="<?php echo WPDEV_CRM_PLUGIN_URL . '/img/notes.png'; ?>" class="tipcy" title='<?php echo __('Edit Notes','wpdev-crm'); ?>' /></a>
969 <?php
970 //echo "<input type='button' class='button' value='".__('Remark','wpdev-crm')."' onclick='javascript:openModalWindow(&quot;modal_content1&quot;);'>";
971
972 make_CRM_action('show_remark_editing_field',$bk['id'],$bk,"height:1px;padding:0px;margin:0px;border:none;");
973 ?>
974 </td>
975 <?php /**/ ?>
976 </tr>
977 <?php
978 }
979
980
981 // T a bl e f o o t e r
982 if ( count($result) > 0 ) {
983 ?>
984 <tr>
985 <th style="border-top:1px solid #777;" align="left" colspan="9">
986 <?php
987 $page_url = 'admin.php?page='. WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME. 'wpdev-crm-customers';
988 if (isset( $_GET['wpdev_sort_order'] )) { $page_url .= '&wpdev_sort_order=' . $_GET['wpdev_sort_order']; }
989 for ($ii = 0; $ii < $togather_pages; $ii++) {
990 if ($start_just_page == $ii) $selected_page = ' selected ';
991 else $selected_page = '';
992 ?><a class="<?php echo $selected_page; ?>" href="<?php echo $page_url; ?>&wpdev_page_num=<?php echo $ii ?>" style="color:#fff;"><?php echo ($ii+1) ?></a> &nbsp;<?php
993 } ?>
994 </th>
995 </tr>
996 <?php } else { ?>
997 <tr><td colspan="9" style="text-align: center; ">
998 <strong><?php _e('There are no customers. ','wpdev-crm') ?></strong><br/><br/>
999 <?php printf(__('Right now current plugin is support orders from %s or newer.','wpdev-crm'), '<strong>Booking Calendar v.2.1</strong>'); ?><br/><br/>
1000 <?php printf(__('You can install %s%s%s now for free. ','wpdev-crm'), '<a href="'.get_option('siteurl') . '/wp-admin/plugin-install.php?tab=search&type=tag&s=reservation-service">', '<strong>Booking Calendar Standard</strong>','</a>'); ?><br/>
1001 </td></tr>
1002 <?php }
1003
1004 ?> </table> <?php
1005
1006 }
1007
1008
1009
1010 // CONTENT OF THE ADMIN S E T T I N G S PAGE //////////////////////////////////////////////////////////////////////////////////////////
1011 function content_of_crm_settings(){
1012 make_crm_action('wpdev_crm_settings_show_top_line'); ?>
1013 <div style="height:1px;clear:both;border-top:1px solid #cccccc;"></div>
1014 <div id="ajax_working"></div>
1015 <?php make_crm_action('wpdev_crm_settings_show_content');
1016 }
1017
1018 // Show T O P L I N E M E N U
1019 function show_settings_menu_top_line(){
1020 $version = 'free';
1021 if (class_exists('wpdev_crm_pro')) $version = 'pro';
1022
1023 ?>
1024
1025 <div style="height:1px;clear:both;margin-top:20px;"></div>
1026 <div id="menu-wpdevplugin">
1027 <div class="nav-tabs-wrapper">
1028 <div class="nav-tabs">
1029 <?php $title = __('General', 'wpdev-crm'); $my_icon = 'General-setting-64x64.png'; $my_tab = 'main'; ?>
1030 <?php if ( ($_GET['tab'] == $my_tab) || (! isset($_GET['tab'])) ) { $slct_a = 'selected'; } else { $slct_a = ''; } ?>
1031 <?php if ($slct_a == 'selected') { $selected_title = $title; $selected_icon = $my_icon; ?><span class="nav-tab nav-tab-active"><?php } else { ?><a class="nav-tab" href="admin.php?page=<?php echo WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME ; ?>wpdev-crm-settings&tab=<?php echo $my_tab; ?>"><?php } ?><img class="menuicons" src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/<?php echo $my_icon; ?>"><?php if ($is_only_icons) echo '&nbsp;'; else echo $title; ?><?php if ($slct_a == 'selected') { ?></span><?php } else { ?></a><?php } ?>
1032 <?php /*
1033 <?php $title = __('Advanced settings', 'wpdev-crm'); $my_icon = 'General-setting-64x64.png'; $my_tab = 'pro'; ?>
1034 <?php if ($_GET['tab'] == $my_tab) { $slct_a = 'selected'; } else { $slct_a = ''; } ?>
1035 <?php if ($slct_a == 'selected') { $selected_title = $title; $selected_icon = $my_icon; ?><span class="nav-tab nav-tab-active"><?php } else { ?><a class="nav-tab" href="admin.php?page=<?php echo WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME ; ?>wpdev-crm-settings&tab=<?php echo $my_tab; ?>"><?php } ?><img class="menuicons" src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/<?php echo $my_icon; ?>"><?php if ($is_only_icons) echo '&nbsp;'; else echo $title; ?><?php if ($slct_a == 'selected') { ?></span><?php } else { ?></a><?php } ?>
1036 */ ?>
1037 <?php if ( ($version == 'free') ) { ?>
1038 <?php $title = __('Buy now', 'wpdev-crm'); $my_icon = 'shopping_trolley.png'; $my_tab = 'buy'; ?>
1039 <?php if ( ($_GET['tab'] == $my_tab) ) { $slct_a = 'selected'; } else { $slct_a = ''; } ?>
1040 <?php if ($slct_a == 'selected') { $selected_title = $title; $selected_icon = $my_icon; ?><span class="nav-tab nav-tab-active"><?php } else { ?><a class="nav-tab" href="admin.php?page=<?php echo WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME ; ?>wpdev-crm-settings&tab=<?php echo $my_tab; ?>"><?php } ?><img class="menuicons" src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/<?php echo $my_icon; ?>"><?php if ($is_only_icons) echo '&nbsp;'; else echo $title; ?><?php if ($slct_a == 'selected') { ?></span><?php } else { ?></a><?php } ?>
1041 <?php } ?>
1042 </div>
1043 </div>
1044 </div>
1045 <script type="text/javascript">
1046 var val1 = '<img src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/<?php echo $selected_icon; ?>"><br />';
1047 jQuery('div.wrap div.icon32').html(val1);
1048 jQuery('div.crmpage h2').html( '<?php echo $selected_title . ' ' . __('settings'); ?>');
1049 </script><?php
1050
1051 }
1052
1053 // Switch between tabs content at settings page
1054 function show_settings_menu_content(){
1055 ?> <div id="poststuff" class="metabox-holder"> <?php
1056 $version = 'free';
1057 if (class_exists('wpdev_crm_pro')) $version = 'pro';
1058
1059 if ( ! isset($_GET['tab']) ) $this->settings_general_content();
1060
1061
1062 switch ($_GET['tab']) {
1063 case 'main': $this->settings_general_content(); break;
1064 case 'pro': $this->settings_advanced_content(); break;
1065 case 'buy':
1066 if ( ($version == 'free') ) {
1067 ?>
1068 <div class="clear" style="height:20px;"></div>
1069 <div id="ajax_working"></div>
1070 <div id="poststuff" class="metabox-holder">
1071 <?php $this->showBuyWidow(); ?>
1072 </div>
1073 <?php } break;
1074
1075 }
1076 ?> </div> <?php
1077 }
1078
1079 // Show General content of settings
1080 function settings_general_content(){
1081 $version = 'free';
1082 if (class_exists('wpdev_crm_pro')) $version = 'pro';
1083
1084 if ( isset( $_POST['Submit_general'] ) ) {
1085
1086 $is_delete_if_deactive = $_POST['is_delete_if_deactive']; // check
1087 $wpdev_copyright = $_POST['wpdev_copyright']; // check
1088 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
1089 if (isset( $is_delete_if_deactive )) $is_delete_if_deactive = 'On';
1090 else $is_delete_if_deactive = 'Off';
1091 update_option('wpdev_crm_is_delete_if_deactive' , $is_delete_if_deactive );
1092
1093 if (isset( $wpdev_copyright )) $wpdev_copyright = 'On';
1094 else $wpdev_copyright = 'Off';
1095 update_option( 'wpdev_crm_copyright' , $wpdev_copyright );
1096 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
1097
1098 $user_role_orders = $_POST['user_role_orders'];
1099 $user_role_customers = $_POST['user_role_customers'];
1100 $user_role_settings = $_POST['user_role_settings'];
1101 if ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) {
1102 $user_role_orders = 'subscriber';
1103 $user_role_customers = 'subscriber';
1104 $user_role_settings = 'subscriber';
1105 }
1106 update_option( 'wpdev_crm_user_role_orders', $user_role_orders );
1107 update_option( 'wpdev_crm_user_role_customers', $user_role_customers );
1108 update_option( 'wpdev_crm_user_role_settings', $user_role_settings );
1109
1110
1111 update_option( 'wpdev_crm_rows_per_page_customers', $_POST['rows_per_page_customers'] );
1112 update_option( 'wpdev_crm_rows_per_page_orders', $_POST['rows_per_page_orders'] );
1113
1114 }
1115 $is_delete_if_deactive = get_option( 'wpdev_crm_is_delete_if_deactive' );
1116 $wpdev_copyright = get_option( 'wpdev_crm_copyright' );
1117
1118 $user_role_orders = get_option( 'wpdev_crm_user_role_orders' );
1119 $user_role_customers = get_option( 'wpdev_crm_user_role_customers' );
1120 $user_role_settings = get_option( 'wpdev_crm_user_role_settings' );
1121
1122 $rows_per_page_customers = get_option( 'wpdev_crm_rows_per_page_customers' );
1123 $rows_per_page_orders = get_option( 'wpdev_crm_rows_per_page_orders' );
1124
1125 ?>
1126 <div class="clear" style="height:20px;"></div>
1127
1128 <div style="width:64%; float:left;margin-right:1%;">
1129
1130 <div class='meta-box'>
1131 <div class="postbox" > <h3 class='hndle'><span><?php _e('General Settings', 'wpdev-crm'); ?></span></h3>
1132 <div class="inside">
1133
1134
1135 <form name="post_option" action="" method="post" id="post_option" >
1136 <table class="form-table"><tbody>
1137
1138
1139 <!--tr valign="top">
1140 <th scope="row"><label for="client_cal_count" ><?php _e('Some setttingsd', 'wpdev-crm'); ?>:</label><br><?php printf(__('at %sclient%s side view', 'wpdev-crm'),'<span style="color:#888;font-weight:bold;">','</span>'); ?></th>
1141 <td>
1142 <input id="client_cal_count" class="regular-text code" type="text" size="45" value="<?php echo $client_cal_count; ?>" name="client_cal_count"/>
1143 <span class="description"><?php printf(__('Type your %sdefault count of calendars%s for inserting into post/page', 'wpdev-crm'),'<b>','</b>');?></span>
1144 </td>
1145 </tr-->
1146
1147 <tr valign="top">
1148 <th scope="row"><label for="rows_per_page_orders" ><?php _e('Rows per page', 'wpdev-crm'); ?>:</label><br><?php printf(__('at %sorders%s page', 'wpdev-crm'),'<span style="color:#888;font-weight:bold;">','</span>'); ?></th>
1149 <td>
1150 <select id="rows_per_page_orders" name="rows_per_page_orders">
1151 <?php $rows_per_page = array('10','25','50','75','100','all');
1152 foreach ($rows_per_page as $row_num) { ?>
1153 <option <?php if($rows_per_page_orders == $row_num) echo "selected"; ?> value="<?php echo $row_num; ?>" ><?php if ($row_num =='all') _e('All records at one page','wpdev-crm'); else echo $row_num; ?></option>
1154 <?php } ?>
1155 </select>
1156 <span class="description"><?php _e('Select number orders per page', 'wpdev-crm');?></span>
1157 </td>
1158 </tr>
1159
1160 <tr valign="top">
1161 <th scope="row"><label for="rows_per_page_customers" ><?php _e('Rows per page', 'wpdev-crm'); ?>:</label><br><?php printf(__('at %scustomers%s page', 'wpdev-crm'),'<span style="color:#888;font-weight:bold;">','</span>'); ?></th>
1162 <td>
1163 <select id="rows_per_page_customers" name="rows_per_page_customers">
1164 <?php $rows_per_page = array('10','25','50','75','100');
1165 foreach ($rows_per_page as $row_num) { ?>
1166 <option <?php if($rows_per_page_customers == $row_num) echo "selected"; ?> value="<?php echo $row_num; ?>" ><?php echo $row_num; ?></option>
1167 <?php } ?>
1168 </select>
1169 <span class="description"><?php _e('Select number customers per page', 'wpdev-crm');?></span>
1170 </td>
1171 </tr>
1172
1173
1174 <tr valign="top">
1175 <td colspan="2"><div style="width:100%;">
1176 <span style="color:#21759B;cursor: pointer;font-weight: bold;"
1177 onclick="javascript: jQuery('#togle_settings_useraccess').slideToggle('normal');"
1178 style="text-decoration: none;font-weight: bold;font-size: 11px;">
1179 + <span style="border-bottom:1px dashed #21759B;"><?php _e('Show settings of user access level to admin menu', 'wpdev-crm'); ?></span>
1180 </span>
1181 </div>
1182
1183 <table id="togle_settings_useraccess" style="display:none;" class="hided_settings_table">
1184 <tr valign="top">
1185
1186 <th scope="row"><label for="start_day_weeek" ><?php _e('Orders', 'wpdev-crm'); ?>:</label><br><?php _e('access level', 'wpdev-crm'); ?></th>
1187 <td>
1188 <select id="user_role_orders" name="user_role_orders">
1189 <option <?php if($user_role_orders == 'subscriber') echo "selected"; ?> value="subscriber" ><?php echo translate_user_role('Subscriber'); ?></option>
1190 <option <?php if($user_role_orders == 'administrator') echo "selected"; ?> value="administrator" ><?php echo translate_user_role('Administrator'); ?></option>
1191 <option <?php if($user_role_orders == 'editor') echo "selected"; ?> value="editor" ><?php echo translate_user_role('Editor'); ?></option>
1192 <option <?php if($user_role_orders == 'author') echo "selected"; ?> value="author" ><?php echo translate_user_role('Author'); ?></option>
1193 <option <?php if($user_role_orders == 'contributor') echo "selected"; ?> value="contributor" ><?php echo translate_user_role('Contributor'); ?></option>
1194 </select>
1195 <span class="description"><?php _e('Select user access level for this administration page', 'wpdev-crm');?></span>
1196 </td>
1197 </tr>
1198
1199
1200 <tr valign="top">
1201 <th scope="row"><label for="start_day_weeek" ><?php _e('Customers', 'wpdev-crm'); ?>:</label><br><?php _e('access level', 'wpdev-crm'); ?></th>
1202 <td>
1203 <select id="user_role_customers" name="user_role_customers">
1204 <option <?php if($user_role_customers == 'subscriber') echo "selected"; ?> value="subscriber" ><?php echo translate_user_role('Subscriber'); ?></option>
1205 <option <?php if($user_role_customers == 'administrator') echo "selected"; ?> value="administrator" ><?php echo translate_user_role('Administrator'); ?></option>
1206 <option <?php if($user_role_customers == 'editor') echo "selected"; ?> value="editor" ><?php echo translate_user_role('Editor'); ?></option>
1207 <option <?php if($user_role_customers == 'author') echo "selected"; ?> value="author" ><?php echo translate_user_role('Author'); ?></option>
1208 <option <?php if($user_role_customers == 'contributor') echo "selected"; ?> value="contributor" ><?php echo translate_user_role('Contributor'); ?></option>
1209 </select>
1210 <span class="description"><?php _e('Select user access level for this administration page', 'wpdev-crm');?></span>
1211 </td>
1212 </tr>
1213
1214
1215 <tr valign="top">
1216 <th scope="row"><label for="start_day_weeek" ><?php _e('Settings', 'wpdev-crm'); ?>:</label><br><?php _e('access level', 'wpdev-crm'); ?></th>
1217 <td>
1218 <select id="user_role_settings" name="user_role_settings">
1219 <option <?php if($user_role_settings == 'subscriber') echo "selected"; ?> value="subscriber" ><?php echo translate_user_role('Subscriber'); ?></option>
1220 <option <?php if($user_role_settings == 'administrator') echo "selected"; ?> value="administrator" ><?php echo translate_user_role('Administrator'); ?></option>
1221 <option <?php if($user_role_settings == 'editor') echo "selected"; ?> value="editor" ><?php echo translate_user_role('Editor'); ?></option>
1222 <option <?php if($user_role_settings == 'author') echo "selected"; ?> value="author" ><?php echo translate_user_role('Author'); ?></option>
1223 <option <?php if($user_role_settings == 'contributor') echo "selected"; ?> value="contributor" ><?php echo translate_user_role('Contributor'); ?></option>
1224 </select>
1225 <span class="description"><?php _e('Select user access level for this administration page', 'wpdev-crm');?></span>
1226 <?php if ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) { ?> <br/><span class="description" style="font-weight: bold;">You do not allow to change this items because right now you test DEMO</span> <?php } ?>
1227 </td>
1228 </tr>
1229 </table>
1230 </td>
1231 </tr>
1232 <tr valign="top">
1233 <td colspan="2"><div style="border-bottom:1px solid #cccccc;"></div></td>
1234 </tr>
1235
1236 <tr valign="top">
1237 <th scope="row"><label for="is_delete_if_deactive" ><?php _e('Delete data', 'wpdev-crm'); ?>:</label><br><?php _e('when plugin deactivated', 'wpdev-crm'); ?></th>
1238 <td><input id="is_delete_if_deactive" type="checkbox" <?php if ($is_delete_if_deactive == 'On') echo "checked"; ?> value="<?php echo $is_delete_if_deactive; ?>" name="is_delete_if_deactive"/>
1239 <span class="description"><?php _e(' Check, if you want delete booking data during uninstalling plugin.', 'wpdev-crm');?></span>
1240 </td>
1241 </tr>
1242
1243 <tr valign="top">
1244 <th scope="row"><label for="wpdev_copyright" ><?php _e('Copyright notice', 'wpdev-crm'); ?>:</label></th>
1245 <td><input id="wpdev_copyright" type="checkbox" <?php if ($wpdev_copyright == 'On') echo "checked"; ?> value="<?php echo $wpdev_copyright; ?>" name="wpdev_copyright"/>
1246 <span class="description"><?php printf(__(' Turn On/Off copyright %s notice at footer of site view.', 'wpdev-crm'),'wpdevelop.com');?></span>
1247 </td>
1248 </tr>
1249
1250 </tbody></table>
1251
1252 <input class="button-primary" style="float:right;" type="submit" value="<?php _e('Save Changes', 'wpdev-crm'); ?>" name="Submit_general"/>
1253 <div class="clear" style="height:10px;"></div>
1254 </form>
1255
1256 <div style="clear:both;"></div>
1257 </div>
1258 </div>
1259 </div>
1260 </div>
1261
1262
1263 <div style="width:35%; float:left;">
1264
1265 <?php if( $version == 'free' ) { ?>
1266 <?php $this->showBuyWidow(); ?>
1267
1268 <?php } ?>
1269
1270 <?php if ( false ) { ?>
1271
1272 <div class='meta-box'>
1273 <div class="postbox gdrgrid" > <h3 class='hndle'><span><?php _e('Category & Page Icons Professional version'); ?></span></h3>
1274 <div class="inside">
1275 <h2 style="margin:10px;"><?php _e('Category & Page Icons Pro'); ?> </h2>
1276 <p style="margin:0px;">
1277 <?php printf(__('If you want %sdonate or have more functionality%s you can %sBuy Professional version%s, which are include posibility to set icons at the top, bottom, right or left side according to titles of pages or categories. At this version is also possible to set spaces between titles and icons.'),'<strong>','</strong>','<strong>','</strong>'); ?> <br/>
1278 </p>
1279 <p style="text-align:center;padding:10px 0px;">
1280 <a href="http://wpdevelop.com/category-page-icons-purchase" class="button-primary" target="_blank">Donate</a>
1281 <a href="http://wpdevelop.com/category-page-icons-purchase" class="button-primary" target="_blank">Buy PRO version</a>
1282 </p>
1283
1284 </div>
1285 </div>
1286 </div>
1287
1288 <div class='meta-box'>
1289 <div class="postbox gdrgrid" > <h3 class='hndle'><span><?php _e('Recomended WordPress Plugins'); ?></span></h3>
1290 <div class="inside">
1291 <h2 style="margin:10px;"><?php _e('Booking Calendar - online booking system'); ?> </h2>
1292 <img src="<?php echo WPDEV_C_PLUGIN_URL . '/img/calendar-48x48.png'; ?>" style="float:left; padding:0px 10px 10px 0px;">
1293
1294 <p style="margin:0px;">
1295 <?php printf(__('This wordpress plugin is %sadd booking service to your site%s. Your site visitors can make booking for one or several days of one or several properties (appartments, hotel rooms, cars and so on). Its can be interesting %sfor hotel reservation service, rental service or any other service%s, where is needed making reservation at specific dates.'),'<strong>','</strong>','<strong>','</strong>'); ?> <br/>
1296 </p>
1297 <p style="text-align:center;padding:10px 0px;">
1298 <a href="http://wordpress.org/extend/plugins/booking" class="button-primary" target="_blank">Download from wordpress</a>
1299 <a href="http://onlinebookingcalendar.com" class="button-primary" target="_blank">Demo site</a>
1300 </p>
1301
1302 </div>
1303 </div>
1304 </div>
1305
1306 <?php } ?>
1307
1308 <div class='meta-box'>
1309 <div class="postbox gdrgrid" > <h3 class='hndle'><span><?php _e('Information'); ?></span></h3>
1310 <div class="inside">
1311 <p class="sub"><?php _e("Info"); ?></p>
1312 <div class="table">
1313 <table><tbody>
1314 <tr class="first">
1315 <td class="first b" style="width: 133px;"><?php _e("Version"); ?></td>
1316 <td class="t"><?php _e("release date"); ?>: <?php echo date ("d.m.Y", filemtime(__FILE__)); ?></td>
1317 <td class="b options" style="color: red; font-weight: bold;"><?php echo WPDEV_CRM_VERSION; ?></td>
1318 </tr>
1319 </tbody></table>
1320 </div>
1321 <p class="sub"><?php _e("Links"); ?></p>
1322 <div class="table">
1323 <table><tbody>
1324 <tr class="first">
1325 <td class="first b">Plugin page</td>
1326 <td class="t"><?php _e("official plugin page"); ?></td>
1327 <td class="t options"><a href="http://wpdevelop.com/wp-plugins/" target="_blank"><?php _e("visit"); ?></a></td>
1328 </tr>
1329 <tr>
1330 <td class="first b">WordPress Extend</td>
1331 <td class="t"><?php _e("wordpress plugin page"); ?></td>
1332 <td class="t options"><a href="http://wordpress.org/extend/plugins" target="_blank"><?php _e("visit"); ?></a></td>
1333 </tr>
1334 </tbody></table>
1335 </div>
1336 <p class="sub"><?php _e("Author"); ?></p>
1337 <div class="table">
1338 <table><tbody>
1339 <tr class="first">
1340 <td class="first b"><span><?php _e("Premium Support"); ?></span></td>
1341 <td class="t"><?php _e("special plugin customizations"); ?></td>
1342 <td class="t options"><a href="mailto:info@wpdevelop.com" target="_blank"><?php _e("contact"); ?></a></td>
1343 </tr>
1344 </tbody></table>
1345 </div>
1346
1347 </div>
1348 </div>
1349 </div>
1350
1351 </div>
1352
1353 <?php
1354 }
1355
1356 // Show Advanced settings content
1357 function settings_advanced_content(){
1358 ?>
1359 <div class="clear" style="height:20px;"></div>
1360
1361 <div style="width:99%; ">
1362
1363 <div class='meta-box'>
1364 <div class="postbox" > <h3 class='hndle'><span><?php _e('Advanced Settings', 'wpdev-crm'); ?></span></h3>
1365 <div class="inside">
1366 <?php //$this->show_help(true); ?>
1367 <div style="clear:both;"></div>
1368 <div style="margin:0px 5px auto;text-align:center;">
1369 <!--img style="margin:0px auto;" src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/help/range_selection_settings.png" -->
1370 <img style="margin:0px 0px 20px auto;" src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/img/help/range_selection_wide.png" >
1371 </div>
1372 <div style="clear:both;"></div>
1373 </div>
1374 </div>
1375 </div>
1376 </div>
1377 <?php
1378
1379 }
1380
1381
1382 // Show window for purchase
1383 function showBuyWidow(){
1384 ?>
1385 <div class='meta-box'>
1386 <div class="postbox gdrgrid" > <h3 class='hndle'><span><?php _e('Professional version', 'wpdev-crm'); ?></span></h3>
1387 <div class="inside">
1388 <p class="sub"><?php _e("Main difference features", 'wpdev-crm'); ?></p>
1389 <div class="table">
1390 <table><tbody>
1391 <tr class="first">
1392 <td class="first b" style="width: 53px;"><b><?php _e("Features", 'wpdev-crm'); ?></b></td>
1393 <td class="t"></td>
1394 <td class="b options comparision" style="color:#11cc11;"><b><?php _e("Free", 'wpdev-crm'); ?></b></td>
1395 <td class="b options comparision" style="color:#f71;"><b><?php _e("Paid", 'wpdev-crm'); ?></b></td>
1396 </tr>
1397 <tr class="">
1398 <td class="first b" ><?php _e("Functionality", 'wpdev-crm'); ?></td>
1399 <td class="t i">(<?php _e("all existing functionality", 'wpdev-crm'); ?>)</td>
1400 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;">&bull;</td>
1401 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;">&bull;</td>
1402 </tr>
1403 <tr class="">
1404 <td class="first b" ><?php _e("Export", 'wpdev-crm'); ?></td>
1405 <td class="t i">(<?php _e("export to CSV", 'wpdev-crm'); ?>)</td>
1406 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;"></td>
1407 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;">&bull;</td>
1408 </tr>
1409 <tr class="">
1410 <td class="first b"><?php _e("Print", 'wpdev-crm'); ?></td>
1411 <td class="t i">(<?php _e("Print loyout", 'wpdev-crm'); ?>)</td>
1412 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;"></td>
1413 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;">&bull;</td>
1414 </tr>
1415 <tr class="">
1416 <td class="first b"><?php _e("Filter", 'wpdev-crm'); ?></td>
1417 <td class="t i">(<?php _e("advanced filter for orders", 'wpdev-crm'); ?>)</td>
1418 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;"></td>
1419 <td class="b options comparision" style="text-align:center;color: green; font-weight: bold;">&bull;</td>
1420 </tr>
1421 <tr>
1422 <td class="first b" ><?php _e("Cost", 'wpdev-crm'); ?></td>
1423 <td class="t"><?php ?></td>
1424 <td class="t options comparision" style="border-right:1px solid #ddd;"><?php _e("free", 'wpdev-crm'); ?></td>
1425 <td class="t options comparision"><?php //_e("start", 'wpdev-crm'); ?>$119</td>
1426 </tr>
1427 <tr class="last">
1428 <td class="first b" ><?php _e("Live demo", 'wpdev-crm'); ?></td>
1429 <td class="t" colspan="3"> <a href="http://ordersplugin.onlinebookingcalendar.com/wp-admin/" target="_blank"> Professional </a>
1430 </td>
1431 </tr>
1432 <tr class="last">
1433 <!--td class="first b"><span><?php _e("Purchase", 'wpdev-crm'); ?></span></td-->
1434 <td colspan="4" style="text-align:right;font-size: 18px;font-weight:normal;" class="t comparision"> <a class="buttonlinktext" href="http://wpdevelop.com/booking-manager-professional/" target="_blank"><?php _e("Buy now", 'wpdev-crm'); ?></a> </td>
1435 </tr>
1436
1437 </tbody></table>
1438 </div>
1439 </div>
1440 </div>
1441 </div>
1442
1443
1444 <?php
1445 }
1446
1447
1448
1449 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1450 // S U P P O R T F U N C T I O N S
1451 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1452 // Check if table exist
1453 function is_table_exists( $tablename ) {
1454 global $wpdb;
1455 if (strpos($tablename, $wpdb->prefix) ===false) $tablename = $wpdb->prefix . $tablename ;
1456 $sql_check_table = "
1457 SELECT COUNT(*) AS count
1458 FROM information_schema.tables
1459 WHERE table_schema = '". DB_NAME ."'
1460 AND table_name = '" . $tablename . "'";
1461
1462 $res = $wpdb->get_results($sql_check_table);
1463 return $res[0]->count;
1464
1465 }
1466
1467 // Check if table exist
1468 function is_field_in_table_exists( $tablename , $fieldname) {
1469 global $wpdb;
1470 if (strpos($tablename, $wpdb->prefix) ===false) $tablename = $wpdb->prefix . $tablename ;
1471 $sql_check_table = "SHOW COLUMNS FROM " . $tablename ;
1472
1473 $res = $wpdb->get_results($sql_check_table);
1474
1475 foreach ($res as $fld) {
1476 if ($fld->Field == $fieldname) return 1;
1477 }
1478
1479 return 0;
1480
1481 }
1482
1483 // Adds Settings link to plugins settings
1484 function plugin_links($links, $file) {
1485
1486 $this_plugin = plugin_basename(__FILE__);
1487
1488 if ($file == $this_plugin) {
1489 $settings_link = '<a href="admin.php?page=' . WPDEV_CRM_PLUGIN_DIRNAME . '/'. WPDEV_CRM_PLUGIN_FILENAME . 'wpdev-crm-settings">'.__("Settings", 'wpdev-crm').'</a>';
1490 $settings_link2 = '<a href="http://wpdevelop.com/booking-manager-professional/">'.__("Buy", 'wpdev-crm').' Pro</a>';
1491 array_unshift($links, $settings_link2);
1492 array_unshift($links, $settings_link);
1493 }
1494 return $links;
1495 }
1496
1497
1498 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1499 // J a v a S c r i p t
1500 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1501 // Files and CSS - print only at the admin pages of this plugin
1502 function on_add_admin_js_files(){
1503 add_action('admin_head', array(&$this, 'print_JS_CSS' ), 1);
1504 }
1505
1506 // Direct Write JS and CSS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1507 function print_JS_CSS(){
1508 ?> <!-- CRM JS & CSS files - Start --> <?php
1509 ?> <link href="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/css/admin.css" rel="stylesheet" type="text/css" /> <?php
1510 ?> <!-- CRM JS & CSS files - End --> <?php
1511 ?><script type="text/javascript">
1512 if(jWPDev == undefined)
1513 var jWPDev = jQuery.noConflict();
1514 var wpdev_crm_plugin_url = '<?php echo WPDEV_CRM_PLUGIN_URL; ?>';
1515 var wpdev_crm_plugin_filename = '<?php echo WPDEV_CRM_PLUGIN_FILENAME; ?>';
1516 </script><?php
1517 do_action('wpdev_crm_js_define_variables');
1518 ?> <script type="text/javascript" src="<?php echo WPDEV_CRM_PLUGIN_URL; ?>/js/wpdev.stnd.js"></script> <?php
1519 do_action('wpdev_crm_js_write_files');
1520
1521 }
1522
1523
1524
1525
1526
1527 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1528 /// A C T I V A T I O N A N D D E A C T I V A T I O N O F T H I S P L U G I N ///////////////////////////////////////////////////////////
1529 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1530 function setDefaultInitialValues($evry_one = 1) { global $wpdb;
1531 $names = array( 'Jacob', 'Michael', 'Daniel', 'Anthony', 'William', 'Emma', 'Sophia', 'Kamila', 'Isabella', 'Jack', 'Daniel', 'Matthew',
1532 'Olivia', 'Emily', 'Grace', 'Jessica', 'Joshua', 'Harry', 'Thomas', 'Oliver', 'Jack' );
1533 $second_names = array( 'Smith', 'Johnson', 'Widams', 'Brown', 'Jones', 'Miller', 'Davis', 'Garcia', 'Rodriguez', 'Wilyson', 'Gonzalez', 'Gomez',
1534 'Taylor', 'Bron', 'Wilson', 'Davies', 'Robinson', 'Evans', 'Walker', 'Jackson', 'Clarke' );
1535 $city = array( 'New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'San Antonio', 'San Diego', 'San Jose', 'Detroit',
1536 'San Francisco', 'Jacksonville', 'Austin',
1537 'London', 'Birmingham', 'Leeds', 'Glasgow', 'Sheffield', 'Bradford', 'Edinburgh', 'Liverpool', 'Manchester' );
1538 $adress = array( '30 Mortensen Avenue', '144 Hitchcock Rd', '222 Lincoln Ave', '200 Lincoln Ave', '65 West Alisal St',
1539 '426 Work St', '65 West Alisal Street', '159 Main St', '305 Jonoton Avenue', '423 Caiptown Rd', '34 Linoro Ave',
1540 '50 Voro Ave', '15 East St', '226 Middle St', '35 West Town Street', '59 Other St', '50 Merci Ave', '15 Dolof St',
1541 '226 Gordon St', '35 Sero Street', '59 Exit St' );
1542 $country = array( 'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'UK','UK','UK','UK','UK','UK','UK','UK','UK' );
1543 $info = array( ' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ',' ',' ',' ',' ',' ',' ',' ',' ' );
1544
1545 for ($i = 0; $i < count($names); $i++) {
1546 if ( ($i % $evry_one) !==0 ) { continue; }
1547 $bk_type = rand(1,4);
1548 $form = 'text^starttime'.$bk_type.'^0'.rand(0,9).':'.rand(10,59).'~'.
1549 'text^endtime'.$bk_type.'^'.rand(13,23).':'.rand(10,59).'~'.
1550 'text^name'.$bk_type.'^'.$names[$i].'~'.
1551 'text^secondname'.$bk_type.'^'.$second_names[$i].'~'.
1552 'text^email'.$bk_type.'^'.$second_names[$i].'.example@wpdevelop.com~'.
1553 'text^address'.$bk_type.'^'.$adress[$i].'~'.
1554 'text^city'.$bk_type.'^'.$city[$i].'~'.
1555 'text^postcode'.$bk_type.'^'.rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).'~'.
1556 'text^country'.$bk_type.'^'.$country[$i].'~'.
1557 'text^phone'.$bk_type.'^'.rand(0,9).rand(0,9).rand(0,9).'-'.rand(0,9).rand(0,9).'-'.rand(0,9).rand(0,9).'~'.
1558 'select-one^visitors'.$bk_type.'^'.rand(0,9).'~'.
1559 'checkbox^children'.$bk_type.'[]^false~'.
1560 'textarea^details'.$bk_type.'^'.$info[$i];
1561
1562 $wp_bk_querie = "INSERT INTO ".$wpdb->prefix ."booking ( form, booking_type, cost ) VALUES
1563 ( '".$form."', ".$bk_type .", ".rand(0,1000)." ) ;";
1564 $wpdb->query($wp_bk_querie);
1565
1566 $temp_id = $wpdb->insert_id;
1567 $wp_queries_sub = "INSERT INTO ".$wpdb->prefix ."bookingdates (
1568 booking_id,
1569 booking_date
1570 ) VALUES
1571 ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*$i*$evry_one+2)." day ),
1572 ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*$i*$evry_one+3)." day ),
1573 ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*$i*$evry_one+4)." day );";
1574 $wpdb->query($wp_queries_sub);
1575 }
1576 }
1577
1578
1579
1580 // Activate
1581 function wpdev_crm_activate(){
1582
1583
1584 global $wpdb;
1585 $charset_collate = '';
1586 if ( $wpdb->has_cap( 'collation' ) ) {
1587 if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1588 if ( ! empty($wpdb->collate) ) $charset_collate .= " COLLATE $wpdb->collate";
1589 }
1590
1591 $wp_queries = array();
1592 if ( ! $this->is_table_exists('wpdev_crm_orders') ) { // Cehck if tables not exist yet
1593 $wp_queries[] = "CREATE TABLE ".$wpdb->prefix ."wpdev_crm_orders (
1594 order_id bigint(20) unsigned NOT NULL auto_increment,
1595 order_info text NOT NULL default '',
1596 customer_id bigint(10) NOT NULL default 1,
1597 type text NOT NULL default '',
1598 cost FLOAT(7,2) NOT NULL DEFAULT 0.00,
1599 tags bigint(10) NOT NULL default 1,
1600 order_date datetime NOT NULL default '0000-00-00 00:00:00',
1601 remark TEXT NOT NULL DEFAULT '',
1602 internal_id bigint(10) NOT NULL default 0,
1603 internal_filters text NOT NULL default '',
1604 internal_filters1 text NOT NULL default '',
1605 internal_filters2 datetime NOT NULL default '0000-00-00 00:00:00',
1606 internal_filters3 datetime NOT NULL default '0000-00-00 00:00:00',
1607 PRIMARY KEY (order_id)
1608 ) $charset_collate;";
1609 }
1610
1611 if ( ! $this->is_table_exists('wpdev_crm_customers') ) { // Cehck if tables not exist yet
1612 $wp_queries[] = "CREATE TABLE ".$wpdb->prefix ."wpdev_crm_customers (
1613 customer_id bigint(20) unsigned NOT NULL auto_increment,
1614 name varchar(255) NOT NULL default '',
1615 second_name varchar(255) NOT NULL default '',
1616 email varchar(255) NOT NULL default '',
1617 phone varchar(255) NOT NULL default '',
1618 adress text NOT NULL default '',
1619 city varchar(255) NOT NULL default '',
1620 country varchar(255) NOT NULL default '',
1621 info text NOT NULL default '',
1622 comments text NOT NULL default '',
1623 tags bigint(10) NOT NULL default 1,
1624 customer_date datetime NOT NULL default '0000-00-00 00:00:00',
1625 remark TEXT NOT NULL DEFAULT '',
1626 PRIMARY KEY (customer_id)
1627 ) $charset_collate;";
1628 }
1629
1630 if (count($wp_queries)>0) // Execute all SQL
1631 foreach ($wp_queries as $wp_q) $wpdb->query($wp_q);
1632
1633
1634
1635
1636 if ( strpos($_SERVER['SCRIPT_FILENAME'],'ordersplugin.onlinebookingcalendar.com') !== FALSE ) {
1637 $this->setDefaultInitialValues();
1638 $this->setDefaultInitialValues(3);
1639 $this->setDefaultInitialValues(9);
1640 wpdev_import_booking_crm_ajax(true);
1641 }
1642
1643
1644 add_option( 'wpdev_crm_is_delete_if_deactive' , 'Off' );
1645
1646 add_option( 'wpdev_crm_copyright' , 'Off' );
1647
1648 add_option( 'wpdev_crm_user_role_orders', 'subscriber' );
1649 add_option( 'wpdev_crm_user_role_customers', 'subscriber' );
1650 add_option( 'wpdev_crm_user_role_settings', 'subscriber' );
1651
1652 add_option( 'wpdev_crm_rows_per_page_customers', '25' );
1653 add_option( 'wpdev_crm_rows_per_page_orders', '25' );
1654
1655 make_crm_action('wpdev_crm_activation');
1656 }
1657
1658 // Deactivate
1659 function wpdev_crm_deactivate(){
1660 $is_delete_if_deactive = get_option( 'wpdev_crm_is_delete_if_deactive' ); // check
1661
1662 if ($is_delete_if_deactive == 'On') {
1663
1664 delete_option( 'wpdev_crm_is_delete_if_deactive');
1665 delete_option( 'wpdev_crm_copyright' );
1666
1667 delete_option( 'wpdev_crm_user_role_orders' );
1668 delete_option( 'wpdev_crm_user_role_customers' );
1669 delete_option( 'wpdev_crm_user_role_settings' );
1670
1671 delete_option( 'wpdev_crm_rows_per_page_customers' );
1672 delete_option( 'wpdev_crm_rows_per_page_orders' );
1673
1674
1675 global $wpdb;
1676 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wpdev_crm_orders');
1677 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wpdev_crm_customers');
1678
1679 make_crm_action('wpdev_crm_deactivation');
1680 }
1681
1682 }
1683
1684 }
1685 }
1686
1687 $wpdev_crm = new wpdev_crm();
1688
1689
1690
1691 // Ajax response ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1692 function wpdev_crm_ajax_responder() { global $wpdb;
1693 if (!function_exists ('adebug')) { function adebug() { $var = func_get_args(); echo "<div style='text-align:left;background:#ffffff;border: 1px dashed #ff9933;font-size:11px;line-height:15px;font-family:'Lucida Grande',Verdana,Arial,'Bitstream Vera Sans',sans-serif;'><pre>"; print_r ( $var ); echo "</pre></div>"; } }
1694
1695 $action = $_POST['ajax_action_crm'];
1696
1697 switch ( $action ) :
1698
1699 case 'IMPORT_BOOKINGS':
1700 if (function_exists ('wpdev_import_booking_crm_ajax')) wpdev_import_booking_crm_ajax();
1701 die();
1702 case 'EXPORT_BOOKINGS' :
1703 if (function_exists ('wpdev_export_booking_crm_ajax')) wpdev_export_booking_crm_ajax();
1704 die();
1705 case 'EXPORT_ALL_BOOKINGS' :
1706 if (function_exists ('wpdev_export_booking_all_crm_ajax')) wpdev_export_booking_all_crm_ajax();
1707 die();
1708 default:
1709 if (function_exists ('wpdev_pro_crm_ajax')) wpdev_pro_crm_ajax();
1710 die();
1711
1712 endswitch;
1713 }
1714
1715
1716 ?>
1717