return; } $output = $ctlView->renderRows($products, $cv_config['tpl']); $pagination = ''; if ($cv_config['paginate'] && !$cv_config['randomize'] && $cv_config['display'] > 0) { //pagination require_once MODX_BASE_PATH . "assets/snippets/catalogView/classes/pagination.class.php"; $p = new pagination(); $p->nextT = $langTxt['next']; //' <a href="[+link+]">'.$langTxt['next'].'</a> '; $p->prevT = $langTxt['prev']; //' <a href="[+link+]">'.$langTxt['prev'].'</a> '; $p->numberT = ' <a href="[+link+]" class="' . $cv_config['pageClass'] . '">[+num+]</a> '; $p->currentT = ' <b class="' . $cv_config['currentPageClass'] . '">[+num+]</b> '; $p->prevI = ''; $p->Items($total); $p->limit($ctlView->config['display']); $p->target($cv_config['thisPageUrl'] . $pagesQueryString); $p->currentPage($qs_page); $p->parameterName($cv_config['id_prefix'] . 'page'); $p->changeClass($cv_config['pageParentClass']); $pagination .= $p->getOutput(); $totalPages = ceil($total / $qs_display); $ctlView->setMODxPlaceholders(array("pages" => $pagination, "totalPages" => $totalPages)); } $ctlView->setMODxPlaceholders(array("sortBy" => $qs_sortBy, "sortDir" => $qs_sortDir, "qs_start" => $qs_start, "total" => $total, "currentPage" => $qs_page, "display" => $qs_display, "sortDirOther" => $sortDirOther, "filter" => $qs_filter, "pagesQueryString" => $pagesQueryString, "thisPageUrl" => $cv_config['thisPageUrl'])); if ($cv_config['toPlaceholder']) { $ctlView->setMODxPlaceholders(array($cv_config['toPlaceholder'] => $output)); $output = ''; } }
function Iscritti() { require 'pagination.class.php'; global $_POST; global $wpdb; $table_email = $wpdb->prefix . "nl_email"; //cancellazione provamoce if ($_POST['delete'] && $_POST['id_email']) { $delete = $wpdb->query("delete from {$table_email} where id_email = '{$_POST['id_email']}'"); echo '<div id="message" class="updated fade"><p><strong>' . __("Email deleted succesfully!", "sendit") . '</strong></p></div>'; //print_r($_POST); } //modifica provamoce if ($_POST['update']) { //$code = md5(uniqid(rand(), true)); $update = $wpdb->query("update {$table_email} set email = '{$_POST['email']}', magic_string='{$_POST['code']}', accepted = '{$_POST['status']}' where id_email = '{$_POST['id_email']}'"); echo '<div id="message" class="updated fade"><p><strong>' . sprintf(__('email %s edited succesfully', 'sendit'), $_POST[email]) . '</p></div>'; //print_r($_POST); } //aggiunta indirizzo o indirizzi email dalla textarea if ($_POST['emails_add'] != "") { //ver 1.1 multiaddress support $email_add = explode("\n", $_POST['emails_add']); foreach ($email_add as $key => $value) { //echo $value."<br />"; //validation fix 1.5.6 (also there!) {2,4} if (!ereg("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})\$", trim($value))) { echo '<div id="message" class="error"><p><strong>indirizzo email ' . $value . ' non valido!</strong></p></div>'; } else { $user_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_email} where email ='{$value}' and id_lista = '{$_GET['lista']}' order by email;"); if ($user_count > 0) { echo "<div class=\"error\"><p><strong>" . sprintf(__('email %s already present', 'sendit'), $value) . "</strong></p></div>"; } else { //genero stringa univoca x conferme e cancellazioni sicure $code = md5(uniqid(rand(), true)); $wpdb->query("INSERT INTO {$table_email} (email,id_lista, magic_string, accepted) VALUES ('{$value}', '{$_POST['id_lista']}', '{$code}', 'y')"); echo '<div class="updated fade"><p><strong>' . sprintf(__('email %s added succesfully!', 'sendit'), $value) . '</strong></p></div>'; } } } //fine ciclo for } $email_items = $wpdb->get_var("SELECT count(*) FROM {$table_email} where id_lista= '{$_GET['lista']}'"); // number of total rows in the database if ($email_items > 0) { $p = new pagination(); $p->items($email_items); $p->limit(20); // Limit entries per page $p->target("admin.php?page=lista-iscritti&lista=" . $_GET['lista']); $p->currentPage($_GET[$p->paging]); // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { //echo "No Record Found"; } $emails = $wpdb->get_results("SELECT id_email, id_lista, email, subscriber_info, magic_string, accepted FROM {$table_email} where id_lista= '{$_GET['lista']}' order by email {$limit}"); //email confermat $emails_confirmed = $wpdb->get_results("SELECT id_email, id_lista, email, subscriber_info, magic_string, accepted FROM {$table_email} where id_lista= '{$_GET['lista']}' and accepted='y'"); echo "<div class=\"wrap\"><h2>" . __('Subscribers', 'sendit') . "</h2>"; //estraggo le liste $table_liste = $wpdb->prefix . "nl_liste"; $liste = $wpdb->get_results("SELECT id_lista, nomelista FROM {$table_liste} "); // print_r($_POST); echo "<div class=\"table\">\n\t\t\t<table class=\"widefat fixed\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>" . __('id', 'sendit') . "</th>\n\t\t\t\t\t\t<th class=" . $css_list . ">" . __('mailing list', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('actions', 'sendit') . "</th>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</thead><tbody>"; foreach ($liste as $lista) { if ($_GET['lista'] == $lista->id_lista) { $selected = " class=\"updated fade\""; } else { $selected = ""; } echo "<tr >\n \t\t<td>" . $lista->id_lista . "</td>\n \t\t<td " . $selected . "><a class=\"\" href=\"admin.php?page=lista-iscritti&lista=" . $lista->id_lista . "\">" . $lista->nomelista . "</a></td>\n \t\t<td></td><tr>"; } echo "</tbody></table>\n </div><br clear=\"all\\ />"; /*miglioro facendo comparire la form x aggiungere solo se selezionata una lista*/ if ($_GET['lista']) { echo "<h3>" . __('Manual Subscribe mailing list ', 'sendit') . " " . $_POST['lista'] . "</h3>\n\n <label for=\"email_add\">" . __('email address (one or more: default separator= line break)', 'sendit') . "<br />\n <div id=\"dashboard-widgets\" class=\"metabox-holder\">\n <div class='postbox-container' style='width:49%;'>\n\t\t\t\t<div id=\"normal-sortables\" class=\"meta-box-sortables\">\n\t\t\t\t<div id=\"dashboard_right_now\" class=\"postbox \" >\n\t\t\t\t\t<div class=\"handlediv\" title=\"Fare clic per cambiare.\"><br /></div>\n\t\t\t\t<h3 class='hndle'><span>" . __('Subscription', 'sendit') . "</span></h3>\n\t\t\t\t<div class=\"inside\">\n\t\t\t\t <p>" . __('Copy here one or more email address', 'sendit') . "</p>\n\n\t\t\t\t\t <form id=\"add\" name=\"add\" method=\"post\" action=\"admin.php?page=lista-iscritti&lista=" . $_GET[lista] . "\">\n\n \n <textarea id=\"emails_add\" type=\"text\" value=\"\" name=\"emails_add\" rows=\"10\" cols=\"50\"/></textarea></label>\n <input type=\"hidden\" name=\"id_lista\" value=\"" . $_GET[lista] . "\" /> \n\n <input class=\"button\" type=\"submit\" value=\"" . __('Add', 'sendit') . "\"/>\n </p>\n </form>\n </div>\n </div>\n </div>\n </div>\n </div>\n <br clear=\"all\" />"; //posiziono la paginazione echo "<h3>" . __('Subscribers', 'sendit') . " n." . $email_items . " (" . __('Subscriptions confirmed', 'sendit') . ": " . count($emails_confirmed) . ")</h3>"; if ($p) { echo $p->show(); } echo "\n <br clear=\"all\" />\n\t\t\t<table class=\"widefat post fixed\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>"; if (get_option('sendit_gravatar') == 'yes') { echo "<th style=\"width:30px !important;\"></th>"; } echo "<th>" . __('email', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('status', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('Additional info', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('actions', 'sendit') . "</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n \t\n "; foreach ($emails as $email) { //coloro le input per distinguere tra chi ha confermato e chi no if ($email->accepted == "y") { $style = "style=\"background:#E4FFCF; border:1px solid #B6FF7F;\""; } elseif ($email->accepted == "n") { $style = "style=\"background:#fffbcc; border:1px solid #e6db55;\""; } else { $style = "style=\"background:#fd919b; border:1px solid #EF4A5C;\""; } //fare funzione per ricaare i valori ovunque $subscriber_info = json_decode($email->subscriber_info); $subscriber_options = explode("&", $subscriber_info->options); $options = ''; foreach ($subscriber_options as $option) { $option = explode("=", $option); //stampo solo i campi unserializzati senza email_add e lista if ($option[0] != 'email_add' and $option[0] != 'lista') { $options .= $option[0]; $options .= ':'; $options .= urldecode($option[1]); $options .= '<br />'; } } echo "<tr>\t\n \t\t<form action=\"#email_" . $email->id_email . "\" method=\"post\">"; if (get_option('sendit_gravatar') == 'yes') { echo "<td class=\"grav\" style=\"width:30px !important;\">" . get_avatar($email->email, '24') . "</td>"; } echo "<td id=\"email_" . $email->id_email . "\">\n \n <!--input type=\"checkbox\" name=\"email_handler[]\" value=\"" . $email->id_email . "\">-->\n <input type=\"hidden\" name=\"id_email\" value=\"" . $email->id_email . "\">\n <input type=\"hidden\" name=\"lista\" value=\"" . $_POST['lista'] . "\">\n <input type='hidden' name='code' value='" . $email->magic_string . "' />\n <input type='text' name='email' value='" . $email->email . "' />\n </td>\n <td " . $style . " >\n <select name=\"status\">\n \n <option value=\"y\""; if ($email->accepted == "y") { echo " selected=\"selected\""; } echo ">" . __('Confirmed', 'sendit') . "</option>\n <option value=\"n\""; if ($email->accepted == "n") { echo " selected=\"selected\""; } echo ">" . __('Not confirmed', 'sendit') . "</option>\n <option value=\"d\""; if ($email->accepted == "d") { echo " selected=\"selected\""; } echo ">" . __('Cancelled', 'sendit') . "</option>\n \n </select>\n </td>\n <td>" . $options . "</td>\n\n <td>\n\t <input type=\"submit\" class=\"button\" name=\"update\" value=\"" . __('Update', 'sendit') . "\">\n\t <input type=\"submit\" class=\"button\" name=\"delete\" value=\"" . __('Delete', 'sendit') . "\">\n\t\t\t\t\t\t</td>\n </form>\n </tr> "; } echo "\t\t<tfoot>\n\t\t\t\t\t<tr>"; if (get_option('sendit_gravatar') == 'yes') { echo "<th style=\"width:30px !important;\"></th>"; } echo "<th>" . __('email', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('status', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('Additional info', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('actions', 'sendit') . "</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</tfoot>\n</table><br clear=\"all\" />"; //ripeto la paginazione if ($p) { echo $p->show(); } } echo "</div>"; }
$filtrar_por = false; } if ($ordenar_por) { $ordenar_query = "&ordenar_por=" . $ordenar_por; } if ($filtrar_por) { $filtrar_query = "&filtrar_por=" . $filtrar_por; } $p = new pagination(); $p->items($items); $p->limit(30); // Limit entries per page $p->currentPage($_GET[$p->paging]); // Gets and validates the current page // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->target("tools.php?page=" . plugin_basename(dirname(__FILE__)) . "/modulo-vendas.php" . $ordenar_query . $filtrar_query); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } $p->calculate(); //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; if ($ordenar_por) { $obter_vendas = "SELECT * from {$table_name} order by {$ordenar_por} asc {$limit}"; } else { $obter_vendas = "SELECT * from {$table_name} order by id asc {$limit}";
/** * Abandon Cart Settings Page */ function woocommerce_ac_page() { if (is_user_logged_in()) { global $wpdb; // Check the user capabilities if (!current_user_can('manage_woocommerce')) { wp_die(__('You do not have sufficient permissions to access this page.', 'woocommerce-ac')); } ?> <div class="wrap"> <div class="icon32" style="background-image: url('<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/abandoned_cart_small.png') !important;"> <br /> </div> <h2><?php _e('WooCommerce - Abandon Cart', 'woocommerce-ac'); ?> </h2> <?php if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = ""; } if (isset($_GET['mode'])) { $mode = $_GET['mode']; } else { $mode = ""; } $this->display_tabs(); if ($action == 'emailsettings') { // Save the field values if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { $ac_settings = new stdClass(); if (isset($_POST['enable_cart_notifications'])) { $ac_settings->enable_cart_notification = $_POST['enable_cart_notifications']; } $ac_settings->cart_time = $_POST['cart_abandonment_time']; $ac_settings->delete_order_days = $_POST['delete_abandoned_orders_days']; if (isset($_POST['email_admin_on_conversion'])) { $ac_settings->email_admin = $_POST['email_admin_on_conversion']; } if (isset($_POST['track_coupons'])) { $ac_settings->track_coupons = $_POST['track_coupons']; } //$ac_settings->conver_email = $_POST['conversion_emails_sendto']; //$ac_settings->conver_link = $_POST['stop_on_conversion_link']; //$ac_settings->conver_order = $_POST['stop_on_conversion_order']; $woo_ac_settings[] = $ac_settings; $woocommerce_ac_settings = json_encode($woo_ac_settings); update_option('woocommerce_ac_settings', $woocommerce_ac_settings); //exit; } ?> <?php if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { ?> <div id="message" class="updated fade"><p><strong><?php _e('Your settings have been saved.', 'woocommerce-ac'); ?> </strong></p></div> <?php } ?> <?php //$enable_email_sett = array(); $enable_email_sett = json_decode(get_option('woocommerce_ac_settings')); ?> <p><?php _e('Change settings for sending email notifications to Customers, to Admin, Tracking Coupons etc.', 'woocommerce-ac'); ?> </p> <div id="content"> <form method="post" action="" id="ac_settings"> <input type="hidden" name="ac_settings_frm" value="save"> <div id="poststuff"> <div class="postbox"> <h3 class="hndle"><?php _e('Settings', 'woocommerce-ac'); ?> </h3> <div> <table class="form-table"> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Enable abandoned cart notifications', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $noti = ""; if (isset($enable_email_sett[0]->enable_cart_notification) && $enable_email_sett[0]->enable_cart_notification == 'on') { $noti = "checked"; } print '<input type="checkbox" name="enable_cart_notifications" id="enable_cart_notifications" ' . $noti . '>'; ?> <img class="help_tip" width="16" height="16" data-tip="<?php _e('Yes, enable the abandoned cart notifications', 'woocommerce-ac'); ?> " src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Yes, enable the abandoned cart notifications', 'woocommerce-ac'); ?> </span> --> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Cart abandoned cut-off time', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $cart_time = ""; if (isset($enable_email_sett[0]->cart_time) && ($enable_email_sett[0]->cart_time != '' || $enable_email_sett[0]->cart_time != 'null')) { $cart_time = $enable_email_sett[0]->cart_time; } print '<input type="text" name="cart_abandonment_time" id="cart_abandonment_time" size="5" value="' . $cart_time . '"> minutes '; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Consider cart abandoned after X minutes of item being added to cart & order not placed', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Consider cart abandoned after X minutes of item being added to cart & order not placed', 'woocommerce-ac'); ?> </span> --> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Automatically Delete Abandoned Orders after', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $delete_order_days = ""; if (isset($enable_email_sett[0]->delete_order_days) && ($enable_email_sett[0]->delete_order_days != '' || $enable_email_sett[0]->delete_order_days != 'null')) { $delete_order_days = $enable_email_sett[0]->delete_order_days; } print '<input type="text" name="delete_abandoned_orders_days" id="delete_abandoned_orders_days" size="5" value="' . $delete_order_days . '"> days '; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Automatically delete abandoned cart orders after X days', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Automatically delete abandoned cart orders after X days', 'woocommerce-ac'); ?> </span> --> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Email admin on order recovery', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $email_admin = ""; if (isset($enable_email_sett[0]->email_admin) && $enable_email_sett[0]->email_admin == 'on') { $email_admin = "checked"; } print '<input type="checkbox" name="email_admin_on_conversion" ' . $email_admin . '> '; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Sends email to Admin if an Abandoned Cart Order is recoverd', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!--<span id="email_on_conversion">--> <?php /* $conversation_email = ""; if ( $enable_email_sett[0]->conver_email != '' || $enable_email_sett[0]->conver_email != 'null') { $conversation_email = $enable_email_sett[0]->conver_email; } print'<input type="text" name="conversion_emails_sendto" id="conversion_emails_sendto" size="30" value="'.$conversation_email.'"></span> <br />'; */ ?> <!-- <span class="description"><?php //_e( 'Email me when an abandoned cart is saved & results in an order', 'woocommerce-ac' ); ?> </span> --> </td> </tr> <!-- <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Stop sending emails', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $stop_conversation_email = ""; if ($enable_email_sett[0]->conver_link == 'on') { $stop_conversation_email = "checked"; } print '<input type="checkbox" name="stop_on_conversion_link" id="stop_on_conversion_link"' . $stop_conversation_email . '> '; ?> <img class="help_tip" data-tip='<?php _e('Sends email to Admin if an Abandoned Cart Order is recoverd', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <span><?php _e('Stop sending when the shopper clicks the \\"Complete Order\\" link in the email', 'woocommerce-ac'); ?> </span> <br /> <?php $stop_conversation_onorder = ""; if ($enable_email_sett[0]->conver_order == 'on') { $stop_conversation_onorder = "checked"; } print '<input type="checkbox" name="stop_on_conversion_order" id="stop_on_conversion_order" ' . $stop_conversation_onorder . '> '; ?> <span><?php _e('Stop sending when the shopper completes their order', 'woocommerce-ac'); ?> </span> <span class="description"><?php //echo _e( 'Email me when an abandoned cart is saved & results in an order', 'woocommerce-ac' ); ?> </span> </td> </tr> --> <!--<tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Email Frequency:', 'woocommerce-ac'); ?> </b></label> </th> <td> <select name="woocommerce_ac_email_frequency"> <?php foreach ($intervals_arr as $seconds => $value) { printf("<option %s value='%s'>%s</option>\n", selected($seconds, get_option('woocommerce_ac_email_frequency'), false), esc_attr($seconds), $value); } ?> </select> <br /> <span class="description"><?php echo __('Set email frequency (since cart was abandoned).', 'woocommerce-ac'); ?> </span> </td> </tr>--> <tr> <th> <label for="woocommerce_ac_track_coupons"><b><?php _e('Track Coupons', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $coupon_track = ""; if (isset($enable_email_sett[0]->track_coupons) && $enable_email_sett[0]->track_coupons == 'on') { $coupon_track = "checked"; } print '<input type="checkbox" name="track_coupons" id="track_coupons" ' . $coupon_track . '>'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Tracks all coupons that were applied to abandoned carts', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Tracks all coupons that were applied to abandoned carts', 'woocommerce-ac'); ?> </span> --> </td> </tr> </table> </div> </div> </div> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes', 'woocommerce-ac'); ?> " /> </p> </form> </div> <?php } elseif ($action == 'listcart' || $action == '') { ?> <p> <?php _e('The list below shows all Abandoned Carts which have remained in cart for a time higher than the "Cart abandoned cut-off time" setting.', 'woocommerce-ac'); ?> </p> <?php //echo plugins_url(); include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT wpac . * , wpu.user_login, wpu.user_email \n\t\t\t\t\t FROM `" . $wpdb->prefix . "ac_abandoned_cart_history` AS wpac \n\t\t\t\t\t LEFT JOIN " . $wpdb->prefix . "users AS wpu ON wpac.user_id = wpu.id\n\t\t\t\t\t WHERE recovered_cart='0' AND unsubscribe_link='0' "); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=listcart"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php $order = ""; if (isset($_GET['order'])) { $order = $_GET['order']; } if ($order == "") { $order = "desc"; $order_next = "asc"; } elseif ($order == "asc") { $order_next = "desc"; } elseif ($order == "desc") { $order_next = "asc"; } $order_by = ""; if (isset($_GET['orderby'])) { $order_by = $_GET['orderby']; } if ($order_by == "") { $order_by = "abandoned_cart_time"; } /* Now we use the LIMIT clause to grab a range of rows */ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email \n\t\t\t\t\t FROM `" . $wpdb->prefix . "ac_abandoned_cart_history` AS wpac \n\t\t\t\t\t LEFT JOIN " . $wpdb->prefix . "users AS wpu ON wpac.user_id = wpu.id\n\t\t\t\t\t WHERE recovered_cart='0' AND unsubscribe_link='0' \n\t\t\t\t\t ORDER BY `{$order_by}` {$order} \n\t\t\t\t\t {$limit}"; //echo $query; $results = $wpdb->get_results($query); /* echo "<pre>"; print_r($results); echo "</pre>"; */ //exit; /* From here you can do whatever you want with the data from the $result link. */ $ac_cutoff_time = json_decode(get_option('woocommerce_ac_settings')); if (isset($ac_cutoff_time[0]->track_coupons)) { $display_tracked_coupons = $ac_cutoff_time[0]->track_coupons; } else { $display_tracked_coupons = ""; } ?> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data'> <tr> <th> <?php _e('Customer', 'woocommerce-ac'); ?> </th> <th> <?php _e('Order Total', 'woocommerce-ac'); ?> </th> <th> <?php _e('Quantity', 'woocommerce-ac'); ?> </th> <th scope="col" id="date_ac" class="manage-column column-date_ac sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=listcart&orderby=abandoned_cart_time&order=<?php echo $order_next; ?> "> <span> <?php _e('Date', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <?php if ($display_tracked_coupons == 'on') { ?> <th> <?php _e('Coupon Code Used', 'woocommerce-ac'); ?> </th> <th> <?php _e('Coupon Status', 'woocommerce-ac'); ?> </th> <?php } ?> <th scope="col" id="status_ac" class="manage-column column-status_ac sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=listcart&orderby=cart_ignored&order=<?php echo $order_next; ?> "> <span> <?php _e('Status', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Actions', 'woocommerce-ac'); ?> </th> </tr> <?php foreach ($results as $key => $value) { if ($value->user_type == "GUEST") { $query_guest = "SELECT * from `" . $wpdb->prefix . "ac_guest_abandoned_cart_history`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $value->user_id . "'"; $results_guest = $wpdb->get_results($query_guest); /* echo "<pre>"; print_r($results_guest); echo "</pre>";*/ } $abandoned_order_id = $value->id; $user_id = $value->user_id; $user_login = $value->user_login; if ($value->user_type == "GUEST") { if (isset($results_guest[0]->email_id)) { $user_email = $results_guest[0]->email_id; } if (isset($results_guest[0]->billing_first_name)) { $user_first_name = $results_guest[0]->billing_first_name; } else { $user_first_name = ""; } if (isset($results_guest[0]->billing_last_name)) { $user_last_name = $results_guest[0]->billing_last_name; } else { $user_last_name = ""; } // echo $user_first_name . " " . $user_last_name; } else { $user_email = $value->user_email; $user_first_name_temp = get_user_meta($value->user_id, 'first_name'); if (isset($user_first_name_temp[0])) { $user_first_name = $user_first_name_temp[0]; } else { $user_first_name = ""; } $user_last_name_temp = get_user_meta($value->user_id, 'last_name'); if (isset($user_last_name_temp[0])) { $user_last_name = $user_last_name_temp[0]; } else { $user_last_name = ""; } // echo $user_first_name . " " . $user_last_name; } $cart_info = json_decode($value->abandoned_cart_info); $order_date = ""; $cart_update_time = $value->abandoned_cart_time; if ($cart_update_time != "" && $cart_update_time != 0) { $order_date = date('d M, Y h:i A', $cart_update_time); } $ac_cutoff_time = json_decode(get_option('woocommerce_ac_settings')); $cut_off_time = $ac_cutoff_time[0]->cart_time * 60; $current_time = current_time('timestamp'); $compare_time = $current_time - $cart_update_time; if (isset($ac_cutoff_time[0]->track_coupons)) { $display_tracked_coupons = $ac_cutoff_time[0]->track_coupons; } /*echo $display_tracked_coupons."</br>"; echo $cut_off_time." <pre>"; print_r($ac_cutoff_time); echo "</pre>"; exit;*/ $cart_details = $cart_info->cart; $line_total = 0; if (count($cart_details) > 0) { foreach ($cart_details as $k => $v) { $line_total = $line_total + $v->line_total; } } $quantity_total = 0; if (count($cart_details) > 0) { foreach ($cart_details as $k => $v) { $quantity_total = $quantity_total + $v->quantity; } } if ($quantity_total == 1) { $item_disp = "item"; } else { $item_disp = "items"; } $coupon_details = get_user_meta($value->user_id, '_woocommerce_ac_coupon', true); if ($value->cart_ignored == 0 && $value->recovered_cart == 0) { $ac_status = "Abandoned"; } elseif ($value->cart_ignored == 1 && $value->recovered_cart == 0) { $ac_status = "Abandoned but new </br>cart created after this"; } else { $ac_status = ""; } ?> <?php if ($compare_time > $cut_off_time && $ac_status != "") { if ($quantity_total > 0) { ?> <tr id="row_<?php echo $abandoned_order_id; ?> "> <td><strong><a href="admin.php?page=woocommerce_ac_page&action=orderdetails&id=<?php echo $value->id; ?> "><?php echo "Abandoned Order #" . $abandoned_order_id; ?> </a></strong><?php echo "</br>Name: " . $user_first_name . " " . $user_last_name . "<br><a href='mailto:{$user_email}'>" . $user_email . "</a>"; ?> </td> <td><?php echo get_woocommerce_currency_symbol() . " " . $line_total; ?> </td> <td><a href="admin.php?page=woocommerce_ac_page&action=orderdetails&id=<?php echo $value->id; ?> "><?php echo $quantity_total . " " . $item_disp; ?> </a></td> <td><?php echo $order_date; ?> </td> <?php if ($display_tracked_coupons == 'on') { ?> <td><?php if ($coupon_details != '') { foreach ($coupon_details as $key => $value) { echo $coupon_details[$key]['coupon_code'] . "</br>"; } } ?> </td> <td><?php if ($coupon_details != '') { foreach ($coupon_details as $key => $value) { echo $coupon_details[$key]['coupon_message'] . "</br>"; } } ?> </td> <?php } ?> <td><?php echo $ac_status; ?> <td id="<?php echo $abandoned_order_id; ?> "> <?php echo "<a href='#' id='{$abandoned_order_id}-{$user_id}' class='remove_cart'> <img src='" . plugins_url() . "/woocommerce-abandon-cart-pro/images/delete.png' alt='Remove Cart Data' title='Remove Cart Data'></a>"; ?> <br><?php //echo "<a href='#' id='$abandoned_order_id-$user_id' class='contact_customer'> Contact Customer </a>"; ?> </td> </tr> <?php } } } echo "</table>"; } elseif ($action == 'emailtemplates' && ($mode != 'edittemplate' && $mode != 'addnewtemplate' && $mode != 'copytemplate')) { ?> <p> <?php _e('Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-ac'); ?> </p> <?php // Save the field values if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { if (isset($_POST['coupon_ids'][0])) { $coupon_code_id = $_POST['coupon_ids'][0]; } else { $coupon_code_id = ""; } $active_post = empty($_POST['is_active']) ? '0' : '1'; if ($active_post == 1) { $check_query = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates` \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE is_active='1' AND frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; $check_results = $wpdb->get_results($check_query); if (count($check_results) == 0) { $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates` \n\t\t\t\t\t\t\t\t\t\t(from_email, subject, body, is_active, frequency, day_or_hour, coupon_code, template_name, from_name, reply_email)\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $_POST['woocommerce_ac_email_from'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_subject'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_body'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $active_post . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['email_frequency'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['day_or_hour'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $coupon_code_id . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_reply'] . "' )"; //echo $query; $wpdb->query($query); } else { $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tis_active='0'\n\t\t\t\t\t\t\t\t\t\tWHERE frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; //echo $query_update; $wpdb->query($query_update); $query_insert_new = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates` \n\t\t\t\t\t\t\t\t\t\t(from_email, subject, body, is_active, frequency, day_or_hour, coupon_code, template_name, from_name, reply_email)\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $_POST['woocommerce_ac_email_from'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_subject'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_body'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $active_post . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['email_frequency'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['day_or_hour'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $coupon_code_id . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_reply'] . "' )"; //echo $query; $wpdb->query($query_insert_new); } } else { $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t(from_email, subject, body, is_active, frequency, day_or_hour, coupon_code, template_name, from_name, reply_email)\n\t\t\t\t\t\t\t\t\tVALUES ('" . $_POST[woocommerce_ac_email_from] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_email_subject] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_email_body] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $active_post . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[email_frequency] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[day_or_hour] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_template_name] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_from_name] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_email_reply] . "' )"; //echo $query; $wpdb->query($query); } } if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'update') { /* echo "<pre>"; print_r($_POST); echo "</pre>"; */ if (isset($_POST['coupon_ids'])) { $coupon_code_id = $_POST['coupon_ids'][0]; if ($coupon_code_id == "" && $_POST['existing_coupon_id'] != "") { $coupon_code_id = $_POST['existing_coupon_id']; } } else { if (isset($_POST['coupon_ids'][0])) { $coupon_code_id = $_POST['coupon_ids'][0]; } else { $coupon_code_id = ""; } } $active = empty($_POST['is_active']) ? '0' : '1'; if ($active == 1) { $check_query = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\tWHERE is_active='1' AND frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; $check_results = $wpdb->get_results($check_query); if (count($check_results) == 0) { $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tfrom_email='" . $_POST['woocommerce_ac_email_from'] . "',\n\t\t\t\t\t\t\t\t\t\tsubject='" . $_POST['woocommerce_ac_email_subject'] . "',\n\t\t\t\t\t\t\t\t\t\tbody='" . $_POST['woocommerce_ac_email_body'] . "',\n\t\t\t\t\t\t\t\t\t\tis_active='" . $active . "', frequency='" . $_POST['email_frequency'] . "',\n\t\t\t\t\t\t\t\t\t\tday_or_hour='" . $_POST['day_or_hour'] . "',\n\t\t\t\t\t\t\t\t\t\tcoupon_code='" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\t\ttemplate_name='" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\tfrom_name='" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\treply_email='" . $_POST['woocommerce_ac_email_reply'] . "'\n\t\t\t\t\t\t\t\t\t\tWHERE id='" . $_POST['id'] . "' "; //echo $query_update; $wpdb->query($query_update); } else { $query_update_new = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tis_active='0'\n\t\t\t\t\t\t\t\t\t\tWHERE frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; //echo $query_update; $wpdb->query($query_update_new); $query_update_latest = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tfrom_email='" . $_POST['woocommerce_ac_email_from'] . "',\n\t\t\t\t\t\t\t\t\t\tsubject='" . $_POST['woocommerce_ac_email_subject'] . "',\n\t\t\t\t\t\t\t\t\t\tbody='" . $_POST['woocommerce_ac_email_body'] . "',\n\t\t\t\t\t\t\t\t\t\tis_active='" . $active . "', frequency='" . $_POST['email_frequency'] . "',\n\t\t\t\t\t\t\t\t\t\tday_or_hour='" . $_POST['day_or_hour'] . "',\n\t\t\t\t\t\t\t\t\t\tcoupon_code='" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\t\ttemplate_name='" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\tfrom_name='" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\treply_email='" . $_POST['woocommerce_ac_email_reply'] . "'\n\t\t\t\t\t\t\t\t\t\tWHERE id='" . $_POST['id'] . "' "; //echo $query_update; $wpdb->query($query_update_latest); } } else { $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\tfrom_email='" . $_POST[woocommerce_ac_email_from] . "',\n\t\t\t\t\t\t\t\t\tsubject='" . $_POST[woocommerce_ac_email_subject] . "',\n\t\t\t\t\t\t\t\t\tbody='" . $_POST[woocommerce_ac_email_body] . "',\n\t\t\t\t\t\t\t\t\tis_active='" . $active . "', frequency='" . $_POST[email_frequency] . "',\n\t\t\t\t\t\t\t\t\tday_or_hour='" . $_POST[day_or_hour] . "',\n\t\t\t\t\t\t\t\t\tcoupon_code='" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\ttemplate_name='" . $_POST[woocommerce_ac_template_name] . "',\n\t\t\t\t\t\t\t\t\tfrom_name='" . $_POST[woocommerce_ac_from_name] . "',\n\t\t\t\t\t\t\t\t\treply_email='" . $_POST[woocommerce_ac_email_reply] . "'\n\t\t\t\t\t\t\t\t\tWHERE id='" . $_POST[id] . "' "; //echo $query_update; $wpdb->query($query_update); } } if ($action == 'emailtemplates' && $mode == 'removetemplate') { $id_remove = $_GET['id']; $query_remove = "DELETE FROM `" . $wpdb->prefix . "ac_email_templates` WHERE id='" . $id_remove . "' "; //echo $query_remove; $wpdb->query($query_remove); } if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { ?> <div id="message" class="updated fade"><p><strong><?php _e('The Email Template has been successfully added.', 'woocommerce-ac'); ?> </strong></p></div> <?php } if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'update') { ?> <div id="message" class="updated fade"><p><strong><?php _e('The Email Template has been successfully updated.', 'woocommerce-ac'); ?> </strong></p></div> <?php } ?> <div class="tablenav"> <p style="float:left;"> <input type="button" value="+ Add New Template" id="add_new_template" onclick="location.href='admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate';" style="font-weight: bold; color: green; font-size: 18px; cursor: pointer;"> <!--<a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate">Add New Template</a>--> </p> <?php include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT wpet . * \n\t\t\t\t\t\t\t\t\t\tFROM `" . $wpdb->prefix . "ac_email_templates` AS wpet \n\t\t\t\t\t\t\t\t\t\t"); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=emailtemplates"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php $order = ""; if (isset($_GET['order'])) { $order = $_GET['order']; } if ($order == "") { $order = "desc"; $order_next = "asc"; } elseif ($order == "asc") { $order_next = "desc"; } elseif ($order == "desc") { $order_next = "asc"; } $order_by_2 = ""; $order_by = ""; if (isset($_GET['orderby'])) { $order_by = $_GET['orderby']; } if ($order_by == "" || $order_by == "frequencyday_or_hour") { $order_by = "day_or_hour"; $order_by_2 = ",frequency {$order_next}"; } $query = "SELECT wpet . * \n\t\t\t\t\t\t FROM `" . $wpdb->prefix . "ac_email_templates` AS wpet \n\t\t\t\t\t\t ORDER BY {$order_by} {$order}\n\t\t\t\t\t\t {$order_by_2} \n\t\t\t\t\t\t {$limit}"; $results = $wpdb->get_results($query); /* From here you can do whatever you want with the data from the $result link. */ ?> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='email_templates'> <tr> <th> <?php _e('Sr', 'woocommerce-ac'); ?> </th> <th scope="col" id="temp_name" class="manage-column column-temp_name sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&orderby=template_name&order=<?php echo $order_next; ?> "> <span> <?php _e('Template Name', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th scope="col" id="sent" class="manage-column column-sent sorted <?php echo $order_next; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&orderby=frequencyday_or_hour&order=<?php echo $order_next; ?> "> <span> <?php _e('Sent', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Active ?', 'woocommerce-ac'); ?> </th> <th> <?php _e('Emails Sent', 'woocommerce-ac'); ?> </th> <th> <?php _e('Actions', 'woocommerce-ac'); ?> </th> </tr> <?php if (isset($_GET['pageno'])) { $add_var = ($_GET['pageno'] - 1) * $limit; } else { $add_var = ""; } $i = 1 + $add_var; foreach ($results as $key => $value) { $id = $value->id; $query_no_emails = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history\n\t\t\t\t\t\t\t\t\t \t \t\t\tWHERE template_id='" . $id . "' "; $number_emails = $wpdb->get_results($query_no_emails); $from = $value->from_email; $subject = $value->subject; $body = $value->body; $is_active = $value->is_active; if ($is_active == '1') { $active = "Yes"; } else { $active = "No"; } $frequency = $value->frequency; $day_or_hour = $value->day_or_hour; ?> <tr id="row_<?php echo $id; ?> "> <td><?php echo $i; ?> </td> <td><?php echo $value->template_name; ?> </td> <td><?php echo $frequency . " " . $day_or_hour . " After Abandonment"; ?> </td> <td><?php echo $active; ?> </td> <td><?php echo count($number_emails); ?> </td> <td> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=copytemplate&id=<?php echo $id; ?> "> <img src="<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/copy.png" alt="Copy as a new template" title="Copy as a new template" width="20" height="20"> </a> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=edittemplate&id=<?php echo $id; ?> "> <img src="<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/edit.png" alt="Edit Template" title="Edit Template" width="20" height="20"> </a> <a href="#" onclick="delete_email_template( <?php echo $id; ?> )" > <img src="<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/delete.png" alt="Delete Template" title="Delete Template" width="20" height="20"> </a> </td> </tr> <?php $i++; } echo "</table>"; //echo "</p>"; } elseif ($action == 'stats' || $action == '') { ?> <p> <script language='javascript'> jQuery(document).ready(function() { jQuery('#duration_select').change(function() { var group_name = jQuery('#duration_select').val(); var today = new Date(); var start_date = ""; var end_date = ""; if ( group_name == "yesterday") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); } else if ( group_name == "today") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_seven") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_fifteen") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 15); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_thirty") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 30); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_ninety") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 90); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_year_days") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 365); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear(); var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear(); jQuery('#start_date').val(start_date_value); jQuery('#end_date').val(end_date_value); //location.href= 'admin.php?page=woocommerce_ac_page&action=stats&durationselect='+group_name; }); }); </script> <?php if (isset($_POST['duration_select'])) { $duration_range = $_POST['duration_select']; } else { $duration_range = ""; } if ($duration_range == "") { if (isset($_GET['duration_select'])) { $duration_range = $_GET['duration_select']; } } if ($duration_range == "") { $duration_range = "last_seven"; } else { $duration_range = ""; } //global $this->duration_range_select,$this->start_end_dates; ?> <p> The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.</p> <div id="recovered_stats_date" class="postbox" style="display:block"> <div class="inside"> <form method="post" action="admin.php?page=woocommerce_ac_page&action=stats" id="ac_stats"> <select id="duration_select" name="duration_select" > <?php foreach ($this->duration_range_select as $key => $value) { $sel = ""; if ($key == $duration_range) { $sel = " selected "; } echo "<option value='{$key}' {$sel}> {$value} </option>"; } $date_sett = $this->start_end_dates[$duration_range]; ?> </select> <script type="text/javascript"> jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] ); jQuery("#start_date").datepicker({dateFormat: formats[1]}); }); jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery("#end_date").datepicker({dateFormat: formats[1]}); }); </script> <?php if (isset($_POST['start_date'])) { $start_date_range = $_POST['start_date']; } else { $start_date_range = ""; } if ($start_date_range == "") { $start_date_range = $date_sett['start_date']; } if (isset($_POST['end_date'])) { $end_date_range = $_POST['end_date']; } else { $end_date_range = ""; } if ($end_date_range == "") { $end_date_range = $date_sett['end_date']; } ?> <label class="start_label" for="start_day"> <?php _e('Start Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="start_date" name="start_date" readonly="readonly" value="<?php echo $start_date_range; ?> "/> <label class="end_label" for="end_day"> <?php _e('End Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="end_date" name="end_date" readonly="readonly" value="<?php echo $end_date_range; ?> "/> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Go', 'woocommerce-ac'); ?> " /> </form> </div> </div> <?php global $wpdb; $start_date = strtotime($start_date_range . " 00:01:01"); $end_date = strtotime($end_date_range . " 23:59:59"); include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history\n\t\t\t\t\t\t\t\t WHERE abandoned_cart_time >= " . $start_date . "\n\t\t\t\t\t\t\t\t AND abandoned_cart_time <= " . $end_date . "\n\t\t\t\t\t\t\t\t AND recovered_cart > '0' \n\t\t\t\t\t\t\t\t "); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=stats&duration_select={$duration_range}"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php $order = ""; if (isset($_GET['order'])) { $order = $_GET['order']; } if ($order == "") { $order = "desc"; $order_next = "asc"; } elseif ($order == "asc") { $order_next = "desc"; } elseif ($order == "desc") { $order_next = "asc"; } $order_by = ""; if (isset($_GET['orderby'])) { $order_by = $_GET['orderby']; } if ($order_by == "") { $order_by = "recovered_cart"; } $query_ac = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history \n\t\t\t\t\t\t\t\t\t WHERE abandoned_cart_time >= " . $start_date . "\n\t\t\t\t\t\t\t\t\t AND abandoned_cart_time <= " . $end_date . "\n\t\t\t\t\t\t\t\t\t AND recovered_cart > 0 \n\t\t\t\t\t\t\t\t\t ORDER BY {$order_by} {$order} {$limit}"; /* echo "<br>".date("d M Y H:i:s", $start_date); echo "<br>".date("d M Y H:i:s", $end_date); echo $query_ac; */ $ac_results = $wpdb->get_results($query_ac); $query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history\n\t\t\t\t\t\t\t\t\t\t WHERE abandoned_cart_time >= " . $start_date . "\n\t\t\t\t\t\t\t\t\t \t AND abandoned_cart_time <= " . $end_date; $ac_carts_results = $wpdb->get_results($query_ac_carts); $recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0; foreach ($ac_carts_results as $key => $value) { $count_carts += 1; $cart_detail = json_decode($value->abandoned_cart_info); $product_details = $cart_detail->cart; $line_total = 0; foreach ($product_details as $k => $v) { $line_total = $line_total + $v->line_total; } $total_value += $line_total; } $table_data = ""; foreach ($ac_results as $key => $value) { if ($value->recovered_cart != 0) { $recovered_id = $value->recovered_cart; $rec_order = get_post_meta($recovered_id); /* echo "<pre>"; //print_r($rec_order); print_r(unserialize($rec_order['_order_items'][0])); echo "</pre>"; */ $woo_order = new WC_Order($recovered_id); $recovered_date = strtotime($woo_order->order_date); $recovered_date_new = date('d M, Y h:i A', $recovered_date); $recovered_item += 1; /* $order_items = unserialize($rec_order['_order_items'][0]); foreach ( $order_items as $order_key => $order_value) { $order_total += $order_items[$order_key]['line_total']; } */ $recovered_total += $rec_order['_order_total'][0]; $abandoned_date = date('d M, Y h:i A', $value->abandoned_cart_time); $abandoned_order_id = $value->id; $is_email_sent_for_this_order = $this->check_email_sent_for_order($abandoned_order_id) ? 'Yes' : 'No'; $table_data .= "<tr>\n\t\t\t\t\t\t\t\t\t\t\t <td>Name: " . $rec_order['_billing_first_name'][0] . " " . $rec_order['_billing_last_name'][0] . "</br><a href='mailto:'" . $rec_order['_billing_email'][0] . "'>" . $rec_order['_billing_email'][0] . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>" . $abandoned_date . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>{$is_email_sent_for_this_order}</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>" . $recovered_date_new . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>" . get_woocommerce_currency_symbol() . " " . $rec_order['_order_total'][0] . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td> <a href=\"post.php?post=" . $recovered_id . "&action=edit\">View Details</td>"; } } ?> <div id="recovered_stats" class="postbox" style="display:block"> <div class="inside" > <p style="font-size: 15px"> During the selected range <strong><?php echo $count_carts; ?> </strong> carts totaling <strong><?php echo get_woocommerce_currency_symbol() . " " . $total_value; ?> </strong> were abandoned. We were able to recover <strong><?php echo $recovered_item; ?> </strong> of them, which led to an extra <strong><?php echo get_woocommerce_currency_symbol() . " " . $recovered_total; ?> </strong> in sales</p> </div> </div> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data'> <tr> <th> <?php _e('Customer', 'woocommerce-ac'); ?> </th> <th scope="col" id="created_date" class="manage-column column-created_date sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=stats&orderby=abandoned_cart_time&order=<?php echo $order_next; ?> &durationselect=<?php echo $duration_range; ?> "> <span> <?php _e('Created On', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Email Sent', 'woocommerce-ac'); ?> </th> <th scope="col" id="rec_order" class="manage-column column-rec_order sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=stats&orderby=recovered_cart&order=<?php echo $order_next; ?> &durationselect=<?php echo $duration_range; ?> "> <span> <?php _e('Recovered Date', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Order Total', 'woocommerce-ac'); ?> </th> <th></th> </tr> <?php echo $table_data; print '</table>'; } elseif ($action == 'emailstats') { ?> <p> <script language='javascript'> jQuery(document).ready(function() { jQuery('#duration_select_email').change(function() { var group_name = jQuery('#duration_select_email').val(); var today = new Date(); var start_date = ""; var end_date = ""; if ( group_name == "yesterday") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); } else if ( group_name == "today") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_seven") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_fifteen") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 15); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_thirty") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 30); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_ninety") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 90); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_year_days") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 365); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear(); var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear(); jQuery('#start_date_email').val(start_date_value); jQuery('#end_date_email').val(end_date_value); //location.href= 'admin.php?page=woocommerce_ac_page&action=emailstats&durationselect='+group_name; }); }); </script> <?php if (isset($_POST['duration_select_email'])) { $duration_range = $_POST['duration_select_email']; } else { $duration_range = ""; } if ($duration_range == "") { if (isset($_GET['duration_select_email'])) { $duration_range = $_GET['duration_select_email']; } } if ($duration_range == "") { $duration_range = "last_seven"; } //global $this->duration_range_select,$this->start_end_dates; ?> <p> <?php _e('The Report below shows emails sent, emails opened and other related stats for the selected date range', 'woocommerce-ac'); ?> </p> <div id="email_stats" class="postbox" style="display:block"> <div class="inside"> <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailstats" id="ac_email_stats"> <select id="duration_select_email" name="duration_select_email" > <?php foreach ($this->duration_range_select as $key => $value) { $sel = ""; if ($key == $duration_range) { $sel = " selected "; } echo "<option value='{$key}' {$sel}> {$value} </option>"; } $date_sett = $this->start_end_dates[$duration_range]; ?> </select> <script type="text/javascript"> jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] ); jQuery("#start_date_email").datepicker({ dateFormat: formats[1]}); }); jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery("#end_date_email").datepicker({ dateFormat: formats[1]}); }); </script> <?php if (isset($_POST['start_date_email'])) { $start_date_range = $_POST['start_date_email']; } else { $start_date_range = ""; } if ($start_date_range == "") { $start_date_range = $date_sett['start_date']; } if (isset($_POST['end_date_email'])) { $end_date_range = $_POST['end_date_email']; } else { $end_date_range = ""; } if ($end_date_range == "") { $end_date_range = $date_sett['end_date']; } ?> <label class="start_label" for="start_day"> <?php _e('Start Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="start_date_email" name="start_date_email" readonly="readonly" value="<?php echo $start_date_range; ?> "/> <label class="end_label" for="end_day"> <?php _e('End Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="end_date_email" name="end_date_email" readonly="readonly" value="<?php echo $end_date_range; ?> "/> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Go', 'woocommerce-ac'); ?> " /> </form> </div> </div> <?php global $wpdb, $woocommerce; $start_date = strtotime($start_date_range . " 00:01:01"); $start_date_db = date('Y-m-d H:i:s', $start_date); $end_date = strtotime($end_date_range . " 23:59:59"); $end_date_db = date('Y-m-d H:i:s', $end_date); include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ac_sent_history\n\t\t\t\t\t\t\t\t\t \t WHERE sent_time >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t \t AND sent_time <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t"); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=emailstats&duration_select_email={$duration_range}"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php /* Now we use the LIMIT clause to grab a range of rows */ $query_ac_sent = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history\n\t\t\t\t\t\t\t\t\t \t WHERE sent_time >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t \t AND sent_time <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t\t\t ORDER BY `id` DESC\n\t\t\t\t\t\t\t\t\t\t {$limit}"; //echo $query; $ac_results_sent = $wpdb->get_results($query_ac_sent); $query_ac_clicked = "SELECT DISTINCT email_sent_id FROM " . $wpdb->prefix . "ac_link_clicked_email\n\t\t\t\t\t\t\t\t\t\t\t WHERE time_clicked >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t\t\t AND time_clicked <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t\t\t\t ORDER BY id DESC "; $ac_results_clicked = $wpdb->get_results($query_ac_clicked, ARRAY_A); $query_ac_opened = "SELECT DISTINCT email_sent_id FROM " . $wpdb->prefix . "ac_opened_emails\n\t\t\t\t\t\t\t\t\t\t \tWHERE time_opened >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t\t \tAND time_opened <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t\t\t\tORDER BY id DESC "; $ac_results_opened = $wpdb->get_results($query_ac_opened, ARRAY_A); ?> <div id="email_sent_stats" class="postbox" style="display:block"> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data_sent' style="font-size : 15px"> <tr> <td> <p style="font-size : 15px"> <?php _e('Emails Sent :', 'woocommerce-ac'); ?> <?php echo $count; ?> </p> </td> <td> <p style="font-size : 15px"> <?php _e('Emails Opened :', 'woocommerce-ac'); ?> <?php echo count($ac_results_opened); ?> </p> </td> <td> <p style="font-size : 15px"> <?php _e('Links Clicked :', 'woocommerce-ac'); ?> <?php echo count($ac_results_clicked); ?> </p> </td> </tr> </table> </div> <div id="email_sent_stats_table" class="postbox" style="display:block"> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data_sent'> <tr> <th> <?php _e('Sent Time', 'woocommerce-ac'); ?> </th> <th> <?php _e('Email Address', 'woocommerce-ac'); ?> </th> <th> <?php _e('Date/Time Opened', 'woocommerce-ac'); ?> </th> <th> <?php _e('Link Clicked', 'woocommerce-ac'); ?> </th> <th> <?php _e('Email Template', 'woocommerce-ac'); ?> </th> <th> <?php _e('View Order', 'woocommerce-ac'); ?> </th> </tr> <?php foreach ($ac_results_sent as $key => $value) { $sent_tmstmp = strtotime($value->sent_time); $sent_date = date('d M Y h:i A', $sent_tmstmp); $query_template_name = "SELECT template_name FROM " . $wpdb->prefix . "ac_email_templates\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id='" . $value->template_id . "' "; $ac_results_template_name = $wpdb->get_results($query_template_name); $link_clicked = ""; if (isset($ac_results_template_name[0]->template_name)) { $ac_email_template_name = $ac_results_template_name[0]->template_name; } else { $ac_email_template_name = ""; } foreach ($ac_results_clicked as $clicked_key => $clicked_value) { if ($clicked_value['email_sent_id'] == $value->id) { $query_links = "SELECT * FROM " . $wpdb->prefix . "ac_link_clicked_email\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE email_sent_id='" . $value->id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `id` DESC\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1"; $results_links = $wpdb->get_results($query_links); /* echo "<pre>"; print_r($results_links); echo "</pre>"; */ $checkout_page_id = get_option('woocommerce_checkout_page_id'); $checkout_page = get_post($checkout_page_id); $checkout_page_link = $checkout_page->guid; //echo "checkout ".$checkout_page_link."</br>"; $cart_page_id = get_option('woocommerce_cart_page_id'); $cart_page = get_post($cart_page_id); $cart_page_link = $cart_page->guid; if ($results_links[0]->link_clicked == $checkout_page_link) { $link_clicked = "Checkout Page"; } elseif ($results_links[0]->link_clicked == $cart_page_link) { $link_clicked = "Cart Page"; } } } $email_opened = ""; foreach ($ac_results_opened as $opened_key => $opened_value) { if ($opened_value['email_sent_id'] == $value->id) { $query_opens = "SELECT * FROM " . $wpdb->prefix . "ac_opened_emails\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE email_sent_id='" . $value->id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `id` DESC\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1"; $results_opens = $wpdb->get_results($query_opens); /* echo "<pre>"; print_r($results_opens); echo "</pre>"; */ $opened_tmstmp = strtotime($results_opens[0]->time_opened); $email_opened = date('d M Y h:i A', $opened_tmstmp); } } $view_order_query = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history\n\t\t\t\t\t\t\t\t\t\t\t\t WHERE id='" . $value->abandoned_order_id . "'"; $view_order_results = $wpdb->get_results($view_order_query); if ($view_order_results[0]->recovered_cart == 0) { $view_link = "admin.php?page=woocommerce_ac_page&action=orderdetails&id=" . $value->abandoned_order_id; $view_name = "Abandoned Order"; } else { $view_link = "post.php?post=" . $view_order_results[0]->recovered_cart . "&action=edit"; $view_name = "Recovered Order"; } ?> <tr> <td> <p> <?php echo $sent_date; ?> </p> </td> <td> <p> <?php echo $value->sent_email_id; ?> </p> </td> <td> <p> <?php echo $email_opened; ?> </p> </td> <td> <p> <?php echo $link_clicked; ?> </p> </td> <td> <p> <?php echo $ac_email_template_name; ?> </p> </td> <td> <p> <a href="<?php echo $view_link; ?> "> <?php echo $view_name; ?> </a> </p> </td> </tr> <?php } print '</table> </div>'; } elseif ($action == 'orderdetails') { $ac_order_id = $_GET['id']; ?> <p> </p> <div id="ac_order_details" class="postbox" style="display:block"> <h3> <p> <?php _e("Abandoned Order #{$ac_order_id} Details", "woocommerce-ac"); ?> </p> </h3> <div class="inside"> <table cellpadding="0" cellspacing="0" class="wp-list-table widefat fixed posts"> <tr> <th> <?php _e('Item', 'woocommerce-ac'); ?> </th> <th> <?php _e('Id', 'woocommerce-ac'); ?> </th> <th> <?php _e('Name', 'woocommerce-ac'); ?> </th> <th> <?php _e('Quantity', 'woocommerce-ac'); ?> </th> <th> <?php _e('Line Subtotal', 'woocommerce-ac'); ?> </th> <th> <?php _e('Line Total', 'woocommerce-ac'); ?> </th> </tr> <?php $query = "SELECT * \n\t\t\t\t\t \t\t\t\tFROM `" . $wpdb->prefix . "ac_abandoned_cart_history` \n\t\t\t\t\t \t\t\t\tWHERE id = '" . $_GET['id'] . "' "; //echo $query; $results = $wpdb->get_results($query); /* echo "<pre>"; print_r($results); echo "</pre>"; */ //exit; if ($results[0]->user_type == "GUEST") { $query_guest = "SELECT * FROM `" . $wpdb->prefix . "ac_guest_abandoned_cart_history`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $results[0]->user_id . "'"; $results_guest = $wpdb->get_results($query_guest); $user_email = $results_guest[0]->email_id; $user_first_name = $results_guest[0]->billing_first_name; $user_last_name = $results_guest[0]->billing_last_name; $user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_postcode = $user_billing_state = $user_billing_country = $user_billing_phone = ""; $user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_postcode = $user_shipping_state = $user_shipping_country = ""; } else { $user_id = $results[0]->user_id; if (isset($results[0]->user_login)) { $user_login = $results[0]->user_login; } $user_email = get_user_meta($results[0]->user_id, 'billing_email', true); $user_first_name_temp = get_user_meta($results[0]->user_id, 'first_name'); if (isset($user_first_name_temp[0])) { $user_first_name = $user_first_name_temp[0]; } else { $user_first_name = ""; } $user_last_name_temp = get_user_meta($results[0]->user_id, 'last_name'); if (isset($user_last_name_temp[0])) { $user_last_name = $user_last_name_temp[0]; } else { $user_last_name = ""; } $user_billing_first_name = get_user_meta($results[0]->user_id, 'billing_first_name'); $user_billing_last_name = get_user_meta($results[0]->user_id, 'billing_last_name'); $user_billing_company_temp = get_user_meta($results[0]->user_id, 'billing_company'); if (isset($user_billing_company_temp[0])) { $user_billing_company = $user_billing_company_temp[0]; } else { $user_billing_company = ""; } $user_billing_address_1_temp = get_user_meta($results[0]->user_id, 'billing_address_1'); if (isset($user_billing_address_1_temp[0])) { $user_billing_address_1 = $user_billing_address_1_temp[0]; } else { $user_billing_address_1 = ""; } $user_billing_address_2_temp = get_user_meta($results[0]->user_id, 'billing_address_2'); if (isset($user_billing_address_2_temp[0])) { $user_billing_address_2 = $user_billing_address_2_temp[0]; } else { $user_billing_address_2 = ""; } $user_billing_city_temp = get_user_meta($results[0]->user_id, 'billing_city'); if (isset($user_billing_city_temp[0])) { $user_billing_city = $user_billing_city_temp[0]; } else { $user_billing_city = ""; } $user_billing_postcode_temp = get_user_meta($results[0]->user_id, 'billing_postcode'); if (isset($user_billing_postcode_temp[0])) { $user_billing_postcode = $user_billing_postcode_temp[0]; } else { $user_billing_postcode = ""; } $user_billing_state_temp = get_user_meta($results[0]->user_id, 'billing_state'); if (isset($user_billing_state_temp[0])) { $user_billing_state = $user_billing_state_temp[0]; } else { $user_billing_state = ""; } $user_billing_country_temp = get_user_meta($results[0]->user_id, 'billing_country'); if (isset($user_billing_country_temp[0])) { $user_billing_country = $user_billing_country_temp[0]; } else { $user_billing_country = ""; } $user_billing_phone_temp = get_user_meta($results[0]->user_id, 'billing_phone'); if (isset($user_billing_phone_temp[0])) { $user_billing_phone = $user_billing_phone_temp[0]; } else { $user_billing_phone = ""; } $user_shipping_first_name = get_user_meta($results[0]->user_id, 'shipping_first_name'); $user_shipping_last_name = get_user_meta($results[0]->user_id, 'shipping_last_name'); $user_shipping_company_temp = get_user_meta($results[0]->user_id, 'shipping_company'); if (isset($user_shipping_company_temp[0])) { $user_shipping_company = $user_shipping_company_temp[0]; } else { $user_shipping_company = ""; } $user_shipping_address_1_temp = get_user_meta($results[0]->user_id, 'shipping_address_1'); if (isset($user_shipping_address_1_temp[0])) { $user_shipping_address_1 = $user_shipping_address_1_temp[0]; } else { $user_shipping_address_1 = ""; } $user_shipping_address_2_temp = get_user_meta($results[0]->user_id, 'shipping_address_2'); if (isset($user_shipping_address_2_temp[0])) { $user_shipping_address_2 = $user_shipping_address_2_temp[0]; } else { $user_shipping_address_2 = ""; } $user_shipping_city_temp = get_user_meta($results[0]->user_id, 'shipping_city'); if (isset($user_shipping_city_temp[0])) { $user_shipping_city = $user_shipping_city_temp[0]; } else { $user_shipping_city = ""; } $user_shipping_postcode_temp = get_user_meta($results[0]->user_id, 'shipping_postcode'); if (isset($user_shipping_postcode_temp[0])) { $user_shipping_postcode = $user_shipping_postcode_temp[0]; } else { $user_shipping_postcode = ""; } $user_shipping_state_temp = get_user_meta($results[0]->user_id, 'shipping_state'); if (isset($user_shipping_state_temp[0])) { $user_shipping_state = $user_shipping_state_temp[0]; } else { $user_shipping_state = ""; } $user_shipping_country_temp = get_user_meta($results[0]->user_id, 'shipping_country'); if (isset($user_shipping_country_temp[0])) { $user_shipping_country = $user_shipping_country_temp[0]; } else { $user_shipping_country = ""; } } //echo $user_id."</br>"; $cart_info = json_decode($results[0]->abandoned_cart_info); $cart_details = $cart_info->cart; foreach ($cart_details as $k => $v) { $quantity_total = $v->quantity; $product_id = $v->product_id; //echo $product_id."</br>"; $prod_name = get_post($product_id); $product_name = $prod_name->post_title; // $prod_details = new WC_PRODUCT ( $product_id); $item_total = $v->line_total / $quantity_total; $product = get_product($product_id); $prod_image = $product->get_image(); ?> <tr> <td> <?php echo $prod_image; ?> </td> <td> <?php echo $product->id; ?> </td> <td> <?php echo $product_name; ?> </td> <td> <?php echo $quantity_total; ?> </td> <td> <?php echo get_woocommerce_currency_symbol() . " " . $item_total; ?> </td> <td> <?php echo get_woocommerce_currency_symbol() . " " . $v->line_total; ?> </td> </tr> <?php } ?> </table> </div> </div> <div id="ac_order_customer_details" class="postbox" style="display:block"> <h3> <p> <?php _e('Customer Details', 'woocommerce-ac'); ?> </p> </h3> <div class="inside" style="height: 300px;" > <div id="order_data" class="panel"> <div style="width:500px;float:left"> <h3> <p> <?php _e('Billing Details', 'woocommerce-ac'); ?> </p> </h3> <p> <strong> <?php _e('Name:', 'woocommerce-ac'); ?> </strong> <?php echo $user_first_name . " " . $user_last_name; ?> </p> <p> <strong> <?php _e('Address:', 'woocommerce-ac'); ?> </strong> <?php echo $user_billing_company . "</br>" . $user_billing_address_1 . "</br>" . $user_billing_address_2 . "</br>" . $user_billing_city . "</br>" . $user_billing_postcode . "</br>" . $user_billing_state . "</br>" . $user_billing_country . "</br>"; ?> </p> <p> <strong> <?php _e('Email:', 'woocommerce-ac'); ?> </strong> <a href='mailto:$user_email'><?php echo $user_email; ?> </a> </p> <p> <strong> <?php _e('Phone:', 'woocommerce-ac'); ?> </strong> <?php echo $user_billing_phone; ?> </p> </div> <div style="width:500px;float:right"> <h3> <p> <?php _e('Shipping Details', 'woocommerce-ac'); ?> </p> </h3> <!-- <p> <strong>Name:</strong> <?php echo $user_first_name[0] . " " . $user_last_name[0]; ?> </p> --> <p> <strong> <?php _e('Address:', 'woocommerce-ac'); ?> </strong> <?php if ($user_shipping_company == '' && $user_shipping_address_1 == '' && $user_shipping_address_2 == '' && $user_shipping_city == '' && $user_shipping_postcode == '' && $user_shipping_state == '' && $user_shipping_country == '') { echo "Shipping Address same as Billing Address"; } else { ?> <?php echo $user_shipping_company . "</br>" . $user_shipping_address_1 . "</br>" . $user_shipping_address_2 . "</br>" . $user_shipping_city . "</br>" . $user_shipping_postcode . "</br>" . $user_shipping_state . "</br>" . $user_shipping_country . "</br>"; ?> </p> <?php } ?> <!-- <p> <strong>Email:</strong> <a href='mailto:$user_email'><?php echo $user_email; ?> </a> </p> <p> <strong>Phone:</strong> <?php echo $user_shipping_phone[0]; ?> </p>--> </div> </div> </div> </div> <?php } if (isset($_GET['action'])) { $action = $_GET['action']; } if (isset($_GET['mode'])) { $mode = $_GET['mode']; } if ($action == 'emailtemplates' && ($mode == 'addnewtemplate' || $mode == 'edittemplate' || $mode == 'copytemplate')) { if ($mode == 'edittemplate') { $edit_id = $_GET['id']; $query = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates` AS wpet WHERE id='" . $edit_id . "'"; //echo $query; $results = $wpdb->get_results($query); } if ($mode == 'copytemplate') { $copy_id = $_GET['id']; $query_copy = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates` AS wpet WHERE id='" . $copy_id . "'"; //echo $query; $results_copy = $wpdb->get_results($query_copy); } $active_post = empty($_POST['is_active']) ? '0' : '1'; /*if ( (isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save') || (isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update') ) { ?> <div id="message" class="updated fade"><p><strong><?php _e( 'Your settings have been saved.', 'woocommerce-ac' ); ?></strong></p></div> <?php } */ ?> <div id="content"> <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings"> <input type="hidden" name="mode" value="<?php echo $mode; ?> " /> <input type="hidden" name="id" value="<?php echo $_GET['id']; ?> " /> <?php $button_mode = "save"; $display_message = "Add Email Template"; if ($mode == 'edittemplate') { $button_mode = "update"; $display_message = "Edit Email Template"; } print '<input type="hidden" name="ac_settings_frm" value="' . $button_mode . '">'; ?> <div id="poststuff"> <div class="postbox"> <h3 class="hndle"><?php _e($display_message, 'woocommerce-ac'); ?> </h3> <div> <table class="form-table" id="addedit_template"> <tr> <th> <label for="woocommerce_ac_template_name"><b><?php _e('Template Name:', 'woocommerce-ac '); ?> </b></label> </th> <td> <?php $template_name = ""; if ($mode == 'edittemplate') { $template_name = $results[0]->template_name; } if ($mode == 'copytemplate') { $template_name = "Copy of " . $results_copy[0]->template_name; } print '<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="' . $template_name . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter a template name for reference', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> </tr> <tr> <th> <label for="woocommerce_ac_from_name"><b><?php _e('Send From This Name:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $from_name = "Admin"; if ($mode == 'edittemplate') { $from_name = $results[0]->from_name; } if ($mode == 'copytemplate') { $from_name = $results_copy[0]->from_name; } print '<input type="text" name="woocommerce_ac_from_name" id="woocommerce_ac_from_name" class="regular-text" value="' . $from_name . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the name that should appear in the email sent', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_from"><b><?php _e('Send From This Email Address:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $from_edit = get_option('admin_email'); if ($mode == 'edittemplate') { $from_edit = $results[0]->from_email; } if ($mode == 'copytemplate') { $from_edit = $results_copy[0]->from_email; } print '<input type="text" name="woocommerce_ac_email_from" id="woocommerce_ac_email_from" class="regular-text" value="' . $from_edit . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Which email address should be shown in the "From Email" field for this email?', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_reply"><b><?php _e('Send Reply Emails to:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $reply_edit = get_option('admin_email'); if ($mode == 'edittemplate') { $reply_edit = $results[0]->reply_email; } if ($mode == 'copytemplate') { $reply_edit = $results_copy[0]->reply_email; } print '<input type="text" name="woocommerce_ac_email_reply" id="woocommerce_ac_email_reply" class="regular-text" value="' . $reply_edit . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_subject"><b><?php _e('Subject:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $subject_edit = ""; if ($mode == 'edittemplate') { $subject_edit = $results[0]->subject; } if ($mode == 'copytemplate') { $subject_edit = $results_copy[0]->subject; } print '<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="' . $subject_edit . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the subject that should appear in the email sent', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_body"><b><?php _e('Email Body:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $initial_data = ""; //stripslashes(get_option( 'woocommerce_ac_email_body' )); if ($mode == 'edittemplate') { $initial_data = $results[0]->body; } if ($mode == 'copytemplate') { $initial_data = $results_copy[0]->body; } /* $settings = array( 'quicktags' => array('buttons' => 'em,strong,link',), 'text_area_name'=>'woocommerce_ac_email_body',//name you want for the textarea 'quicktags' => true, 'class' => 'tinymce', 'tinymce' => true ); //echo "<textarea id='editortest'> </textarea>"; $id = 'woocommerce_ac_email_body';//has to be lower case wp_editor(stripslashes($initial_data),$id,$settings); */ echo "<textarea id='woocommerce_ac_email_body' name='woocommerce_ac_email_body' rows='15'' cols='80'>" . $initial_data . "</textarea>"; ?> <!--<textarea name="woocommerce_ac_email_body" cols="45" rows="3" class="regular-text"><?php echo stripslashes(get_option('woocommerce_ac_email_body')); ?> </textarea><br />--> <span class="description"><?php echo __('Message to be sent in the reminder email.', 'woocommerce-ac'); ?> </span> </td> </tr> <tr> <th> <label for="is_active"><b><?php _e('Active:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $is_active_edit = ""; if ($mode == 'edittemplate') { $active_edit = $results[0]->is_active; if ($active_edit == '1') { $is_active_edit = "checked"; } else { $is_active_edit = ""; } } if ($mode == 'copytemplate') { $active_edit = $results_copy[0]->is_active; if ($active_edit == '1') { $is_active_edit = "checked"; } else { $is_active_edit = ""; } } print '<input type="checkbox" name="is_active" id="is_active" ' . $is_active_edit . '> </input>'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Yes, This email should be sent to shoppers with abandoned carts', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Send this email:', 'woocommerce-ac'); ?> </b></label> </th> <td> <select name="email_frequency" id="email_frequency"> <?php $frequency_edit = ""; if ($mode == 'edittemplate') { $frequency_edit = $results[0]->frequency; } if ($mode == 'copytemplate') { $frequency_edit = $results_copy[0]->frequency; } for ($i = 1; $i < 60; $i++) { printf("<option %s value='%s'>%s</option>\n", selected($i, $frequency_edit, false), esc_attr($i), $i); } ?> </select> <select name="day_or_hour" id="day_or_hour"> <?php $days_or_hours_edit = ""; if ($mode == 'edittemplate') { $days_or_hours_edit = $results[0]->day_or_hour; } if ($mode == 'copytemplate') { $days_or_hours_edit = $results_copy[0]->day_or_hour; } $days_or_hours = array('Minutes' => 'Minute(s)', 'Days' => 'Day(s)', 'Hours' => 'Hour(s)'); foreach ($days_or_hours as $k => $v) { printf("<option %s value='%s'>%s</option>\n", selected($k, $days_or_hours_edit, false), esc_attr($k), $v); } ?> <!--<select name="day_or_hour" id="day_or_hour"> <option value="Days" <?php echo $day_serl; ?> > Days </option> <option value="Hours" <?php echo $hours_serl; ?> > Hours </option>--> </select> <span class="description"><?php echo __('after cart is abandoned.', 'woocommerce-ac'); ?> </span> </td> </tr> <?php $entered_coupon = ""; if ($mode == 'edittemplate') { $entered_coupon = $results[0]->coupon_code; } if ($mode == 'copytemplate') { $entered_coupon = $results_copy[0]->coupon_code; } ?> <input type="hidden" name="existing_coupon_id" value="<?php echo $entered_coupon; ?> " /> <tr> <th> <label for="woocommerce_ac_coupon_auto_complete"><b><?php _e('Enter a coupon code to add into email:', 'woocommerce-ac'); ?> </b></label> </th> <td> <!-- code started for woocommerce auto-complete coupons field --> <div id="coupon_options" class="panel woocommerce_options_panel"> <div class="options_group"> <p class="form-field" style="padding-left:0px;"> <select id="coupon_ids" name="coupon_ids[]" class="ajax_chosen_select_coupons" multiple="multiple" data-placeholder="<?php _e('Search for a coupon…', 'woocommerce'); ?> "> <?php if ($mode == 'edittemplate') { $coupon_code_id = $results[0]->coupon_code; } if ($mode == 'copytemplate') { $coupon_code_id = $results_copy[0]->coupon_code; } if ($coupon_code_id > 0) { $title = get_the_title($coupon_code_id); $sku = get_post_meta($coupon_code_id, '_sku', true); if (isset($sku) && $sku) { $sku = ' (SKU: ' . $sku . ')'; } echo '<option value="' . $product_id . '" selected="selected">' . $title . $sku . '</option>'; } ?> </select> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Search & select one coupon code that customers should use to get a discount.', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /> </p> </div></div> <!-- code ended for woocommerce auto-complete coupons field --> <!--<input type="text" id="enter_coupon" name="enter_coupon" class="regular-text" value="<?php echo $entered_coupon; ?> "/>--> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_preview"><b><?php _e('Send a test email to:', 'woocommerce-ac'); ?> </b></label> </th> <td> <input type="text" id="send_test_email" name="send_test_email" class="regular-text" > <input type="button" value="Send a test email" id="preview_email" onclick="javascript:void(0);"> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the email id to which the test email needs to be sent.', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /> <div id="preview_email_sent_msg" style="display:none;"></div> </p> </td> </tr> </table> </div> </div> </div> <p class="submit"> <?php $button_value = "Save Changes"; if ($mode == 'edittemplate') { $button_value = "Update Changes"; } ?> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e($button_value, 'woocommerce-ac'); ?> " /> </p> </form> </div> <?php } } }
/** * Create WP ULike bbPress Logs page with separate pagination * * @author Alimir * @since 2.2 * @return String */ function wp_ulike_bbpress_likes_logs() { global $wpdb; $alternate = true; $items = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "ulike_forums"); if ($items > 0) { $p = new pagination(); $p->items($items); $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page $p->target("admin.php?page=wp-ulike-bbpress-logs"); $p->calculate(); // Calculates what to show $p->parameterName('page_number'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['page_number'])) { $p->page = 1; } else { $p->page = $_GET['page_number']; } //Query for limit page_number $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; $get_ulike_logs = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ulike_forums ORDER BY id DESC " . $limit . ""); ?> <div class="wrap"> <h2><?php _e('WP ULike Logs', 'alimir'); ?> </h2> <h3><?php _e('Topics Likes Logs', 'alimir'); ?> </h3> <div class="tablenav"> <div class='tablenav-pages'> <span class="displaying-num"><?php echo $items . ' ' . __('Logs', 'alimir'); ?> </span> <?php echo $p->show(); // Echo out the list of paging. ?> </div> </div> <table class="widefat"> <thead> <tr> <th width="2%"><?php _e('ID', 'alimir'); ?> </th> <th width="10%"><?php _e('Username', 'alimir'); ?> </th> <th><?php _e('Status', 'alimir'); ?> </th> <th width="6%"><?php _e('Topic ID', 'alimir'); ?> </th> <th><?php _e('Topic Title', 'alimir'); ?> </th> <th width="20%"><?php _e('Date / Time', 'alimir'); ?> </th> <th><?php _e('IP', 'alimir'); ?> </th> <th><?php _e('Actions', 'alimir'); ?> </th> </tr> </thead> <tbody class="wp_ulike_logs"> <?php foreach ($get_ulike_logs as $get_ulike_log) { ?> <tr <?php if ($alternate == true) { echo 'class="alternate"'; } ?> > <td> <?php echo $get_ulike_log->id; ?> </td> <td> <?php $user_info = get_userdata($get_ulike_log->user_id); if ($user_info) { echo get_avatar($user_info->user_email, 16, '', 'avatar') . '<em> @' . $user_info->user_login . '</em>'; } else { echo '<em> #' . __('Guest User', 'alimir') . '</em>'; } ?> </td> <td> <?php $get_the_status = $get_ulike_log->status; if ($get_the_status == 'like') { echo '<img src="' . plugin_dir_url(__FILE__) . '/classes/img/like.png" alt="like" width="24"/>'; } else { echo '<img src="' . plugin_dir_url(__FILE__) . '/classes/img/unlike.png" alt="unlike" width="24"/>'; } ?> </td> <td> <?php echo $get_ulike_log->topic_id; ?> </td> <td> <?php echo '<a href="' . get_permalink($get_ulike_log->topic_id) . '" title="' . get_the_title($get_ulike_log->topic_id) . '">' . get_the_title($get_ulike_log->topic_id) . '</a>'; ?> </td> <td> <?php echo wp_ulike_date_i18n($get_ulike_log->date_time); ?> </td> <td> <?php echo $get_ulike_log->ip; ?> </td> <td> <button class="wp_ulike_delete button" type="button" data-id="<?php echo $get_ulike_log->id; ?> " data-table="ulike_forums"><i class="dashicons dashicons-trash"></i></button> </td> <?php $alternate = !$alternate; } ?> </tr> </tbody> </table> <div class="tablenav"> <div class='tablenav-pages'> <span class="displaying-num"><?php echo $items . ' ' . __('Logs', 'alimir'); ?> </span> <?php echo $p->show(); // Echo out the list of paging. ?> </div> </div> </div> <?php } else { echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)', 'alimir') . "</p></div>"; } }
function show_easy_gallery($atts, $content = null) { $order = 'desc'; $pagesql = ''; $limit = ''; $count = 8; $page = true; $page_st = true; $theme = 'fancybox'; $view = 'album'; $album = ''; global $wpdb; //echo "select * from easy_photos order by $order limit $limit offset $offset"; if (isset($atts['order'])) { $order = $atts['order']; } if (isset($atts['theme'])) { $theme = trim($atts['theme']); if ($theme != 'fancybox' && $theme != 'swipebox') { $theme = 'fancybox'; } } if (isset($atts['view'])) { $view = trim($atts['view']); if ($view != 'album' && $view != 'image') { $view = 'album'; } } if (isset($atts['album'])) { $album = trim($atts['album']); } if (isset($atts['limit'])) { $count = trim($atts['limit']); if ($count < 1) { $count = 2; } } $order = strtolower($order); if ($order != 'asc' && $order != 'desc') { $order = 'desc'; } if (isset($atts['pagination'])) { $page_st = trim($atts['pagination']); if ($page_st != 'true' && $page_st != 'false') { $page_st = 'true'; } } if ($page_st == 'true') { $page = true; $sql = " SELECT DISTINCT(a.album_id) FROM easy_album a,easy_photos b WHERE a.album_id=b.album_id AND a.disabled=0 AND b.disabled=0"; if ($album != '') { $sql = $sql . " and a.album_id = {$album}"; } if ($view == 'image') { $sql = "select * from easy_photos where album_id not in(select album_id from easy_album b where b.disabled=1) and disabled=0"; if ($album != '') { $sql = $sql . " and album_id = {$album}"; } } $rows = $wpdb->get_results($sql); $items = count($rows); if ($items > 0) { $p = new pagination(); $p->items($items); $p->limit($count); // Limit entries per page if ($album != '') { $p->target(get_permalink() . '?album=' . $album); } else { $p->target(get_permalink()); } //$p->urlFriendly(); if (isset($p->paging)) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->nextLabel(''); //removing next text $p->prevLabel(''); //removing previous text $p->nextIcon('►'); //Changing the next icon $p->prevIcon('◄'); //Changing the previous icon $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { echo "No Images"; } } else { $page = false; } ?> <div class="easy-gallery-base"> <div class="easy-gallery-content"> <?php $sql = ""; $tmp_sql = " SELECT DISTINCT(a.album_id) FROM easy_album a,easy_photos b WHERE a.album_id=b.album_id AND a.disabled=0 AND b.disabled=0 "; if ($album != '') { $tmp_sql = $tmp_sql . " and a.album_id = {$album}"; } $tmp_sql = $tmp_sql . " order by album_id {$order} {$limit}"; $rows_tmp = $wpdb->get_results($tmp_sql); $data = array(); foreach ($rows_tmp as $obj_temp) { array_push($data, $obj_temp->album_id); } $album_list = implode(',', $data); if ($view == 'image') { $sql = "select * from easy_photos where album_id not in(select album_id from easy_album b where b.disabled=1) and disabled=0 "; if ($album != '') { $sql = $sql . " and album_id = {$album}"; } $sql = $sql . " order by id {$order} {$limit}"; } else { $sql = "select a.*,b.album_cover,b.name from easy_photos a,easy_album b where a.album_id = b.album_id and b.disabled=0 and a.disabled=0 and b.album_id in({$album_list}) order by b.album_id {$order}"; } $rows = $wpdb->get_results($sql); $aid = ""; $i = 1; $img_count = count($rows); if ($view == 'album') { foreach ($rows as $obj) { if ($obj->album_id != $aid && $aid != "") { echo '</div>'; $i = 1; } if ($i == 1) { ?> <div class="album_thumb has-album-name"> <?php } if ($i == 1) { ?> <a href="<?php echo $obj->image_path; ?> " class="<?php echo $theme; ?> " rel="<?php echo $obj->album_id; ?> " title="<?php echo $obj->description; ?> "> <img title="<?php echo $obj->name; ?> " src="<?php echo $obj->album_cover; ?> " /> </a> <div class="album-name"><?php if (strlen($obj->name) > 30) { echo substr($obj->name, 0, 30) . '..'; } else { echo $obj->name; } ?> </div> <?php } else { ?> <a href="<?php echo $obj->image_path; ?> " class="<?php echo $theme; ?> " rel="<?php echo $obj->album_id; ?> " title="<?php echo $obj->description; ?> "> </a> <?php } $i++; if ($img_count == 1) { $i = 1; ?> </div> <?php } //else if($obj->album_id!=$aid && $aid!="" and ) //{ //echo $obj->album_id; // $i=1; ?> <?php //} $aid = $obj->album_id; ?> <?php } if ($img_count > 0) { echo '</div>'; } } else { if ($view == 'image') { foreach ($rows as $obj) { ?> <div class="album_thumb"> <p><a class="fancybox" data-fancybox-group="thumb" href="<?php echo $obj->image_path; ?> "> <img src="<?php echo $obj->thumb_path; ?> " /></a> </p> </div> <?php } } } ?> <br style="clear:both;" /> </div> <div> <?php if ($page && $items > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php }
} catch (PDOException $e) { $log->logError($e . " - " . basename(__FILE__)); } echo "<div class=\"page-header\"><h1>" . _("Access Logs") . "</h1></div>"; echo "<h6>" . _("Options") . " : <a href=\"{$website}/" . ADMIN_DIRECTORY . "/settings#/misc\">" . _("Access Settings") . "</a></h6><br/>"; echo "<ul class=\"breadcrumb\">\n\t\t<li><a href=\"{$website}/" . ADMIN_DIRECTORY . "/settings\">" . _("Home") . "</a> <span class=\"divider\">/</span></li>\n\t\t<li class=\"active\">" . _("Access Logs") . "</li>\n\t\t</ul>"; if (!empty($number)) { /* initializing the ip2country class for converting ip address to country. */ $ip2country = new ip2country($db); $p = new pagination(); $p->items($number); $p->limit($max_show); $p->currentPage($page); $p->parameterName("p"); $p->urlFriendly(); $p->target("{$website}/" . ADMIN_DIRECTORY . "/access/%"); $from2 = $page * $max_show; if ($from2 > $number) { $diff = $number % $max_show; $from2 = $number; $from1 = $from2 - $diff; } else { $from1 = $from2 - $max_show; } echo "<table class=\"table table-condensed\">"; echo "<thead><tr>\n\t\t\t<th>" . _("ID") . "</th>\n\t\t\t<th>" . _("IP Address") . "</th>\n\t\t\t<th>" . _("Username") . "</th>\n\t\t\t<th>" . _("Country") . "</th>\n\t\t\t<th>" . _("Access") . "</th>\n\t\t\t</tr></thead>"; /* loading all the tags data in arrays. */
$output_list = ''; $status_list = $upconf['action'] == 'archorders' ? '4,5' : '1,2,3,6'; $total = $modx->db->getValue($modx->db->select("COUNT(*)", $mod_table, "userid = '{$userId}' AND status in({$status_list})")); //pagination $pages = ''; $qs_page = !empty($_GET[$upconf['id_prefix'] . 'page']) && is_numeric($_GET[$upconf['id_prefix'] . 'page']) ? $modx->db->escape($_GET[$upconf['id_prefix'] . 'page']) : 1; $qs_start = !empty($_GET[$upconf['id_prefix'] . 'start']) && !is_array($_GET[$upconf['id_prefix'] . 'start']) ? $_GET[$upconf['id_prefix'] . 'start'] : $qs_page * $upconf['display'] - $upconf['display']; $p = new pagination(); $p->nextT = ' <a href="[+link+]">' . $langTxt['next'] . '</a> '; $p->prevT = ' <a href="[+link+]">' . $langTxt['prev'] . '</a> '; $p->numberT = ' <a href="[+link+]">[+num+]</a> '; $p->currentT = ' <b>[+num+]</b> '; //' <a class="current" href="[+link+]">[+num+]</a> '; $p->prevI = ''; $p->Items($total); $p->limit($upconf['display']); $p->target($upconf['thisPage'] . $upconf['qs'] . $upconf['id_prefix'] . "act=purchase&" . $upconf['id_prefix'] . "sub=" . $upconf['action']); $p->currentPage($qs_page); $p->parameterName($upconf['id_prefix'] . 'page'); $pages .= $p->getOutput(); $totalPages = ceil($orders_total_count / $upconf['display']); //orders $output_list = $shk_uprofile->getOrderList($userId, $list_chunk, $qs_start, $status_list); $shk_uprofile->phx->placeholders = array(); $shk_uprofile->setPlaceholders(array('notempty' => $total > 0 ? 'true' : '', 'title' => $title, 'list' => $output_list, 'pages' => $pages, 'totalPages' => $totalPages)); $output .= $shk_uprofile->phx->Parse($chunk[0] . '[+list+]' . $chunk[2]); $output = $shk_uprofile->cleanPHx($output); } break; } return $output;
do_action('wp_client_redirect', get_admin_url() . 'admin.php?page=wpclients' . $target_order . '&msg=d'); exit; } if (!class_exists('pagination')) { include_once 'pagination.php'; } //$items = count_users(); //$items = ( isset( $items['avail_roles']['wpc_client'] ) ) ? $items['avail_roles']['wpc_client'] : 0; $sql = "SELECT count( a.ID ) FROM {$wpdb->users} a, {$wpdb->usermeta} b\r\n WHERE\r\n a.ID = b.user_id\r\n AND b.meta_key = '{$wpdb->prefix}capabilities'\r\n AND b.meta_value LIKE '%s:10:\"wpc_client\";%'\r\n AND a.ID NOT IN (SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'to_approve')\r\n {$search}\r\n {$sql_order}\r\n "; $items = $wpdb->get_var($sql); $p = new pagination(); $p->items($items); $p->limit(25); $p->target("admin.php?page=wpclients" . $target_order); $p->calculate(); $p->parameterName('p'); $p->adjacents(2); if (!isset($_GET['p'])) { $p->page = 1; } else { $p->page = $_GET['p']; } $limit = " LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; $sql = "SELECT a.ID FROM {$wpdb->users} a, {$wpdb->usermeta} b\r\n WHERE\r\n a.ID = b.user_id\r\n AND b.meta_key = '{$wpdb->prefix}capabilities'\r\n AND b.meta_value LIKE '%s:10:\"wpc_client\";%'\r\n AND a.ID NOT IN (SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'to_approve')\r\n {$search}\r\n {$sql_order}\r\n {$limit}\r\n "; $clients = $wpdb->get_results($sql, 'ARRAY_A'); $code = md5('wpc_client_' . get_current_user_id() . '_send_mess'); ?> <div style="" class='wrap'> <?php
function list_voucher_display_settings() { global $wpdb; $sql = 'SELECT COUNT(*) FROM wp_voucher_post'; $items = $wpdb->get_var($sql); // $items = mysql_num_rows(mysql_query("SELECT * FROM wp_voucher_post")); // number of total rows in the database if ($items > 0) { $p = new pagination(); $p->items($items); $p->limit(500); // Limit entries per page $p->target("admin.php?page=list_voucher_settings"); $p->currentPage($_GET[$p->paging]); // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { echo "No Record Found"; } echo '<div class="wrap"> <h2>List of Records</h2> <div class="tablenav"> <div class="tablenav-pages">'; echo $p->show(); echo '</div> </div> <table class="widefat"> <thead> <tr> <th><strong>ID</strong></th> <th><strong>Người nhận</strong></th> <th><strong>Email</strong></th> <th><strong>Điện thoại</strong></th> <th><strong>Tên voucher</strong></th> <th><strong>Số lượng</strong></th> </tr> </thead> <tbody>'; $sql = "SELECT * FROM wp_voucher_post, wp_posts where wp_voucher_post.post_id = wp_posts.id ORDER BY wp_voucher_post.id DESC {$limit}"; $result = $wpdb->get_results($sql) or die('Error, query failed'); foreach ($result as $value) { echo '<tr> <td>' . $value->post_id . '</td> <td>' . $value->fullname . '</td> <td>' . $value->email . '</td> <td>' . $value->phone . '</td> <td>' . $value->post_title . '</td> <td>' . $value->total . '</td> </tr>'; } echo '</tbody> </table> </div>'; }
function sc_render_manager_page() { require_once plugin_dir_path(__FILE__) . 'includes/Services/Soundcloud.php'; require_once plugin_dir_path(__FILE__) . 'includes/class/pagination.class.php'; $options = get_option('sc_options'); $client = new Services_Soundcloud($options['client_id'], $options['client_secret'], $options['callback_url']); // Error message if app settings are not filled in. if ($options['client_id'] == "Your client ID goes here" || $options['client_secret'] == "Your client secret goes here" || $options['callback_url'] == "Your callback url goes here") { echo '<div class="error fade"><p>Warning: One or more of the required fields have not been set. Please insure that your cliend ID, client secret, and callback url are defined <a href="' . admin_url('options-general.php?page=soundcloud/soundcloud.php') . '">HERE</a>.</br>Soundcloud functionality will not be available until these fields are set.</p></div></br>'; } // SoundCloud login/logout if (isset($_GET['code']) || get_option('soundcloud_access_token')) { echo '<a href="' . admin_url('admin.php?page=soundcloud-disconnect') . '" class="soundcloud-icon"><img src="' . plugins_url() . '/soundcloud/includes/images/btn-disconnect-l.png" alt="Disconnect"/></a>'; try { $client = new Services_Soundcloud($options['client_id'], $options['client_secret'], $options['callback_url']); if (isset($_GET['code'])) { $accessToken = $client->accessToken($_GET['code']); update_option('soundcloud_access_token', $accessToken['access_token']); update_option('soundcloud_refresh_token', $accessToken['refresh_token']); update_option('soundcloud_token_expiration', time() + $accessToken['expires_in']); } else { if (get_option('soundcloud_access_token')) { // refresh token code deprecated due to non-expiring tokens /*if (time() > get_option('soundcloud_token_expiration')) { $client->setAccessToken(get_option('soundcloud_access_token')); // refresh access token $accessToken = $client->accessTokenRefresh(get_option('soundcloud_refresh_token')); //$client->setAccessToken($accessToken['access_token']); update_option('soundcloud_access_token', $accessToken['access_token']); update_option('soundcloud_refresh_token', $accessToken['refresh_token']); update_option('soundcloud_token_expiration', time() + $accessToken['expires_in']); } else {*/ $client->setAccessToken(get_option('soundcloud_access_token')); //} } } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } } else { echo '<a href="' . $client->getAuthorizeUrl(array('scope' => 'non-expiring')) . '" class="soundcloud-icon"><img src="' . plugins_url() . '/soundcloud/includes/images/btn-connect-sc-l.png" alt="Connect with Soundcloud"/></a>'; } // tab switching if (isset($_GET['tab'])) { sc_admin_tabs($_GET['tab']); $tab = $_GET['tab']; } else { sc_admin_tabs('user'); $tab = 'user'; } if (get_option('soundcloud_access_token')) { try { $me = json_decode($client->get('me'), true); } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } echo '<h3>Logged in as: ' . $me['username'] . '</h3>'; } else { echo '<h3>Not logged in.</h3>'; } switch ($tab) { case 'user': try { $me = json_decode($client->get('me'), true); ?> <form action="" method="post"> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="username">Username:</label></th> <td><input type="text" name="username" value="<?php echo $me['username']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="permalink">Permalink:</label></th> <td><input type="text" name="permalink" value="<?php echo $me['permalink']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="description">Description:</label></th> <td><input type="text" name="description" value="<?php echo $me['description']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="website">Website:</label></th> <td><input type="text" name="website" value="<?php echo $me['website']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="website_title">Website Name:</label></th> <td><input type="text" name="website_title" value="<?php echo $me['website_title']; ?> " size="30" class="regular-text code"></td> </tr> </table> <p class="submit"><input type="submit" value="Update Account" class="button-primary"></p> </form> <?php if (isset($_POST['username']) || isset($_POST['permalink']) || isset($_POST['description']) || isset($_POST['website']) || isset($_POST['website_title'])) { $response = json_decode($client->put('me', array('user[username]' => $_POST['username'], 'user[permalink]' => $_POST['permalink'], 'user[description]' => $_POST['description'], 'user[website]' => strlen($_POST['website']) ? $_POST['website'] : null, 'user[website_title]' => strlen($_POST['website_title']) ? $_POST['website_title'] : null))); } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } break; case 'upload': ?> <form action="" enctype="multipart/form-data" method="post" id ="add_track"> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="track_title">Track title:</label></th> <td><input type="text" name="track_title" size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="track_file">Please specify a track:</label></th> <td><input type="file" name="track_file" id="track_file" size="40" accept="audio/*" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="track_art">Please specify track artwork:</label></th> <td><input type="file" name="track_art" id="track_art" size="40" accept="image/*" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="tag">Track tags:</label></th> <td><input type="text" name="tag" id="tag" size="30"><input type="button" id="add_tag" name="add_tag" class="button" value="Add Tag" /> <br><ul id="tags"></ul></td> </tr> <tr valign="top"> <th scope="row"><label for="sharing">Track privacy:</label></th> <td><select name="sharing"> <option value="public">Public</option> <option value="private">Private</option> </select></td> </tr> </table> <p class="submit"><input type="submit" value="Upload" class="button-primary"></p> </form> <?php try { $tmp_file = '/tmp/' . stripslashes($_FILES['track_file']['name']); $tmp_art_file = '/tmp/' . stripslashes($_FILES['track_art']['name']); if (move_uploaded_file($_FILES['track_file']['tmp_name'], $tmp_file) && move_uploaded_file($_FILES['track_art']['tmp_name'], $tmp_art_file)) { // upload audio file $track = json_decode($client->post('tracks', array('track[title]' => $_POST['track_title'], 'track[asset_data]' => '@' . $tmp_file, 'track[artwork_data]' => '@' . $tmp_art_file, 'track[tags]' => strlen($_POST['tags']) ? $_POST['tags'] : null, 'track[sharing]' => $_POST['sharing']))); unlink(realpath($tmp_file)); unlink(realpath($tmp_art_file)); } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } break; case 'tracks': try { echo '</br>'; $page_size = 5; // Pagination code $p = new pagination(); $p->items($me['track_count']); $p->limit($page_size); // Limit entries per page $p->target("admin.php?page=soundcloud-manager&tab=tracks"); $p->currentPage($_GET[$p->paging]); // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } if ($p->page == 1) { // get first page of tracks $tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size))); } else { // get additional pages of tracks $tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size, 'offset' => $page_size * $page))); } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php echo $p->show(); ?> </div> </div> <?php foreach ($tracks as $track) { $client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1)); $embed_info = json_decode($client->get('oembed', array('url' => $track->permalink_url))); // render the html for the player widget echo $embed_info->html . '</br></br>'; } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } break; } }
$items = $wpdb->get_results($sql); $items_count = $wpdb->get_results($sql_count); $p->items($items_count[0]->count); $p->limit($page_count); // Limit entries per page if (isset($_GET['s'])) { $p->target("admin.php?page=order_details&" . $query_string); } else { $p->target("admin.php?page=order_details&" . $query_string); } if (isset($_GET['order_page'])) { $cp = $_GET['order_page']; } else { $cp = 1; } $p->parameterName('order_page'); $p->currentPage($cp); // Gets and validates the current page $p->calculate(); // Calculates what to show $p->adjacents(1); //No. of page away from the current page if ($items_count > 0) { $prod_name_id_array = array(); foreach ($products as $product) { $project = new ID_Project($product->id); $post_id = $project->get_project_postid(); $prod_name_id_array[] = array('id' => $product->id, 'product_name' => get_the_title($post_id)); } } ?>