function asz_ind_show_posts() { $ajax_author_name = $_POST['authorname']; $startdate = $_POST['startdate']; $enddate = $_POST['enddate']; global $wpdb; $asz_the_users = asz_get_users(); foreach ($asz_the_users as $users) { //var_dump($users); //var_dump($_POST); if ($users['user_nicename'] == $ajax_author_name) { $asz_the_posts = asz_ind_get_posts($users['ID'], $startdate, $enddate); foreach ($asz_the_posts as $the_posts) { $da_author = $the_posts->post_author; $asz_options = get_option('_user-stats--options'); (int) ($da_author_article_cost = $asz_options['asz_dollar_per_article-' . $da_author]); (int) ($da_author_thousand_cost = $asz_options['asz_dollar_per_thousand-' . $da_author]); $da_date = $the_posts->post_date; $da_date_format = get_option('date_format'); $da_date = date($da_date_format, strtotime($da_date)); $da_cat = get_the_category($the_posts->ID); $cat_string = ''; foreach ($da_cat as $dacat) { $cat_string .= " " . $dacat->name; } $asz_post_meta = get_post_meta($the_posts->ID, '_statz_count', true); if ($asz_post_meta == '') { $asz_post_meta = 0; } //$asz_dollar_per_views = $da_author_article_cost / $asz_post_meta; if ($asz_post_meta == 0 || $da_author_article_cost == 0) { $asz_dollar_per_views = 0; } else { $asz_dollar_per_views = $da_author_article_cost / $asz_post_meta; } //$asz_dollar_per_views = round($asz_dollar_per_views, 2, PHP_ROUND_HALF_UP); $asz_dollar_per_views = asz_round($asz_dollar_per_views); $asz_dollar_per_thousand_views = $da_author_thousand_cost / 1000; $asz_dollar_per_thousand_views = $asz_dollar_per_thousand_views * $asz_post_meta; //$asz_dollar_per_thousand_views = round($asz_dollar_per_thousand_views, 2, PHP_ROUND_HALF_UP); $asz_dollar_per_thousand_views = asz_round($asz_dollar_per_thousand_views); //var_dump($users); echo "<tr class='asz_ind_posts asz_ind_posts_" . $users['user_nicename'] . "' >"; if ($asz_options['author_author'] != 'author_author') { echo "<td>" . $users['user_nicename'] . "</td>"; } if ($asz_options['author_article'] != 'author_article') { echo "<td class='asz_article_column'><a href='" . $the_posts->guid . "' target='_blank'>" . $the_posts->post_title . "</a><span class='asz_edit'><a href='" . get_edit_post_link($the_posts->ID) . "' target='_blank'>edit</a></span></td>"; } if ($asz_options['author_date'] != 'author_date') { echo "<td>" . $da_date . "</td>"; } if ($asz_options['author_cat'] != 'author_cat') { echo "<td>" . $cat_string . "</td>"; } if ($asz_options['author_views'] != 'author_views') { echo "<td id='viewcount_" . $the_posts->ID . "'>" . $asz_post_meta . "<span><img title='Reset View Count' class='asz_reset' id='" . $the_posts->ID . "' src='" . USERSTATS_URLPATH . "/images/delete.png" . "' /></span></td>"; } if ($asz_options['author_dollarviews'] != 'author_dollarviews') { echo "<td>" . $asz_dollar_per_views . "</td>"; } if ($asz_options['author_dollarthousand'] != 'author_dollarthousand') { echo "<td>" . $asz_dollar_per_thousand_views . "</td>"; } echo "</tr>"; } } //end if } die; }
function asz_overview() { $asz_options = get_option('_user-stats--options'); $asz_users = asz_get_users(); foreach ($asz_users as $asz_overview) { //Remove the user if selected. $asz_noauthor = "over_noauthor_" . $asz_overview['user_nicename']; $get_check_cos_its_late = isset($asz_options[$asz_noauthor]); if (isset($noauthorcheck) != $get_check_cos_its_late) { continue; } //var_dump($asz_overview); (int) ($tempdollarperarticle = $asz_options['asz_dollar_per_article-' . $asz_overview['ID']]); (int) ($tempdollarperthousand = $asz_options['asz_dollar_per_thousand-' . $asz_overview['ID']]); $overview_post_count = count_user_posts($asz_overview['ID']); $overview_total_count = asz_get_total_counts($asz_overview['ID']); if ($overview_post_count == 0) { $overview_avg_views = 0; } else { $overview_avg_views = $overview_total_count / $overview_post_count; } //$overview_avg_views = round($overview_avg_views, 2, PHP_ROUND_HALF_UP); $overview_avg_views = asz_round($overview_avg_views); $overview_dollar_per_article = $tempdollarperarticle; if ($overview_dollar_per_article == '') { $overview_dollar_per_article = 0; } else { $overview_dollar_per_article = $overview_dollar_per_article; } $overview_total_dollar_per_article = $overview_post_count * $tempdollarperarticle; if ($overview_total_count == 0) { $overview_avg_dollar_per_view = 0; } else { $overview_avg_dollar_per_view = $overview_total_dollar_per_article / $overview_total_count; } //$overview_avg_dollar_per_view = round($overview_avg_dollar_per_view, 2, PHP_ROUND_HALF_UP); $overview_avg_dollar_per_view = asz_round($overview_avg_dollar_per_view); $overview_dollar_per_thousand = $tempdollarperthousand; if ($overview_dollar_per_thousand == '') { $overview_dollar_per_thousand = 0; } else { $overview_dollar_per_thousand = $overview_dollar_per_thousand; } $overview_total_dollar_per_thousand = $overview_total_count * $overview_dollar_per_thousand; if ($overview_total_count == 0) { $overview_avg_dollar_per_thousand = 0; } else { $overview_avg_dollar_per_thousand = $overview_total_dollar_per_thousand / $overview_total_count; } //$overview_avg_dollar_per_thousand = round($overview_total_dollar_per_thousand, 2, PHP_ROUND_HALF_UP)/1000; $overview_avg_dollar_per_thousand = asz_round($overview_total_dollar_per_thousand); echo "<tr>"; echo "<td><input type='checkbox' class='asz_overview_totals' /></td>"; echo "<td class='asz_author_name' id='" . $asz_overview['user_nicename'] . "'>" . $asz_overview['user_nicename'] . "</td>"; if (isset($asz_options['over_role']) != 'over_role') { echo "<td>" . asz_user_role($asz_overview['ID']) . "</td>"; } if (isset($asz_options['over_noarticles']) != 'over_noarticles') { echo "<td>" . $overview_post_count . "</td>"; } if (isset($asz_options['over_tviews']) != 'over_tviews') { echo "<td>" . $overview_total_count . "</td>"; } if (isset($asz_options['over_aviews']) != 'over_aviews') { echo "<td>" . $overview_avg_views . "</td>"; } if (isset($asz_options['over_dollararticles']) != 'over_dollararticles') { echo "<td>" . $overview_dollar_per_article . "</td>"; } if (isset($asz_options['over_totaldollararticles']) != 'over_totaldollararticles') { echo "<td>" . $overview_total_dollar_per_article . "</td>"; } if (isset($asz_options['over_avgdollarview']) != 'over_avgdollarview') { echo "<td>" . $overview_avg_dollar_per_view . "</td>"; } if (isset($asz_options['over_dollarthousandview']) != 'over_dollarthousandview') { echo "<td>" . $overview_dollar_per_thousand . "</td>"; } if (isset($asz_options['over_avgdollarthousandview']) != 'over_avgdollarthousandview') { echo "<td>" . $overview_avg_dollar_per_thousand . "</td>"; } echo "</tr>"; } // This will be the running total echo "<tfoot><tr id='asz_running_total'>"; echo "<td></td>"; echo "<td class='asz_author_name' id=''>TOTAL</td>"; if (isset($asz_options['over_role']) != 'over_role') { echo '<td id="asz_running_role"></td>'; } if (isset($asz_options['over_noarticles']) != 'over_noarticles') { echo '<td id="asz_running_noarticles"></td>'; } if (isset($asz_options['over_tviews']) != 'over_tviews') { echo '<td id="asz_running_totalview"></td>'; } if (isset($asz_options['over_aviews']) != 'over_aviews') { echo '<td id="asz_running_avgview"></td>'; } if (isset($asz_options['over_dollararticles']) != 'over_dollararticles') { echo '<td id="asz_running_dollarart"></td>'; } if (isset($asz_options['over_totaldollararticles']) != 'over_totaldollararticles') { echo '<td id="asz_running_totalart"></td>'; } if (isset($asz_options['over_avgdollarview']) != 'over_avgdollarview') { echo '<td id="asz_running_avgdollarview"></td>'; } if (isset($asz_options['over_dollarthousandview']) != 'over_dollarthousandview') { echo '<td id="asz_running_dollarthou"></td>'; } if (isset($asz_options['over_avgdollarthousandview']) != 'over_avgdollarthousandview') { echo '<td id="asz_running_avgdollarthou"></td>'; } echo "</tr></tfoot>"; }