コード例 #1
0
 function ajax__aff_getdashstats()
 {
     global $user;
     $user = wp_get_current_user();
     $user_ID = $user->ID;
     $headings = aff_get_option('affiliateheadings', array(__('Unique Clicks', 'affiliate'), __('Sign ups', 'affiliate'), __('Paid members', 'affiliate')));
     $results = $this->db->get_results($this->db->prepare("SELECT * FROM {$this->affiliatedata} WHERE user_id = %d ORDER BY period DESC LIMIT 0, 18", $user_ID));
     $startat = strtotime(date("Y-m-15"));
     $clicks = array();
     $signups = array();
     $payments = array();
     $ticks = array();
     if (!empty($results)) {
         $recent = array_shift($results);
     } else {
         $recent = array();
     }
     for ($n = 0; $n < 10; $n++) {
         $place = 10 - $n;
         $rdate = strtotime("-{$n} month", $startat);
         $period = date('Ym', $rdate);
         $ticks[] = array((int) $place, date_i18n('M y', $rdate));
         if (!empty($recent) && $recent->period == $period) {
             // We are on the current period
             $clicks[] = array((int) $place, (int) $recent->uniques);
             $signups[] = array((int) $place, (int) $recent->signups);
             $payments[] = array((int) $place, (int) $recent->completes);
             if (!empty($results)) {
                 $recent = array_shift($results);
             } else {
                 $recent = array();
             }
         } else {
             // A zero blank row
             $clicks[] = array((int) $place, (int) 0);
             $signups[] = array((int) $place, (int) 0);
             $payments[] = array((int) $place, (int) 0);
         }
     }
     $return = array();
     $return['chart'][] = array("label" => stripslashes($headings[0]), "data" => $clicks);
     $return['chart'][] = array("label" => stripslashes($headings[1]), "data" => $signups);
     $return['chart'][] = array("label" => stripslashes($headings[2]), "data" => $payments);
     $return['ticks'] = $ticks;
     $this->return_json($return);
     exit;
 }
コード例 #2
0
ファイル: marketpress.php プロジェクト: hscale/webento
function AM_Show_Affiliate_Settings($settings)
{
    if (isset($_POST['gateway_settings'])) {
        // Do processing here
        if (!empty($_POST['affiliate_mp_percentage']) && $_POST['affiliate_mp_percentage'] > 0) {
            aff_update_option('affiliate_mp_percentage', $_POST['affiliate_mp_percentage']);
        } else {
            aff_delete_option('affiliate_mp_percentage');
        }
    }
    ?>
		<div id="mp_gateways" class="postbox">
            <h3 class='hndle'><span><?php 
    _e('Affiliate Settings', 'mp');
    ?>
</span></h3>
            <div class="inside">
			  <span class="description"><?php 
    _e('You can set the global commision amount paid to affiliates for referred purchases below. Set it to 0 for no payments.', 'affiliate');
    ?>
</span>
              <table class="form-table">
                <tr>
        				<th scope="row"><?php 
    _e('Set percentage to be paid to affiliates', 'affiliate');
    ?>
</th>
        				<td>
							<?php 
    $percentage = aff_get_option('affiliate_mp_percentage', 0);
    ?>
							<input type='text' name='affiliate_mp_percentage' value='<?php 
    echo number_format($percentage, 2);
    ?>
' style='width:5em;'/>&nbsp;<?php 
    _e('%', 'affiliate');
    ?>
                			<?php 
    ?>
        				</td>
                </tr>
              </table>
            </div>
          </div>
	<?php 
}
コード例 #3
0
ファイル: affiliatepublic.php プロジェクト: hscale/webento
 function __construct()
 {
     global $wpdb;
     // Grab our own local reference to the database class
     $this->db =& $wpdb;
     $this->detect_location(1);
     foreach ($this->tables as $table) {
         if (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('affiliate/affiliate.php') && (defined('AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED') && AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED == 'yes')) {
             // we're activated site wide
             $this->{$table} = $this->db->base_prefix . $table;
         } else {
             if (defined('AFFILIATE_USE_BASE_PREFIX_IF_EXISTS') && AFFILIATE_USE_BASE_PREFIX_IF_EXISTS == 'yes' && !empty($this->db->base_prefix)) {
                 $this->{$table} = $this->db->base_prefix . $table;
             } else {
                 // we're only activated on a blog level so put the admin menu in the main area
                 $this->{$table} = $this->db->prefix . $table;
             }
         }
     }
     $installed = aff_get_option('Aff_Installed', false);
     if ($installed === false || $installed != $this->build) {
         $this->install();
         aff_update_option('Aff_Installed', $this->build);
     }
     register_activation_hook(__FILE__, array(&$this, 'install'));
     add_action('init', array(&$this, 'handle_affiliate_link'));
     // Global generic functions
     add_action('affiliate_click', array(&$this, 'record_click'), 10, 1);
     add_action('affiliate_signup', array(&$this, 'record_signup'), 10);
     add_action('affiliate_purchase', array(&$this, 'record_complete'), 10, 5);
     add_action('affiliate_credit', array(&$this, 'record_credit'), 10, 2);
     add_action('affiliate_debit', array(&$this, 'record_debit'), 10, 2);
     add_action('affiliate_referrer', array(&$this, 'record_referrer'), 10, 2);
     // Include affiliate plugins
     load_affiliate_addons();
 }
コード例 #4
0
ファイル: supporter.php プロジェクト: vilmark/vilmark_main
function affiliate_supporter_settings()
{
    global $psts;
    if (function_exists('get_site_option')) {
        $getoption = 'get_site_option';
    } else {
        $getoption = 'get_option';
    }
    $psts_tabs = 3.5 >= $psts->version ? true : false;
    ?>
	<?php 
    if (!$psts_tabs) {
        ?>
		<div class="postbox">
		<h3 class="hndle" style="cursor:auto;"><span><?php 
        _e('Affiliate Settings', 'affiliate');
        ?>
</span></h3>
	<?php 
    } else {
        $tab = ProSites_Helper_Tabs_Settings::get_active_tab();
        ProSites_Helper_Settings::settings_header($tab);
    }
    ?>
        <div class="inside">
			<?php 
    $prosites_currency = $psts->get_setting('currency');
    $affiliate_currency = aff_get_option('affiliate-currency-paypal-masspay', 'USD');
    //echo "prosites_currency[". $prosites_currency ."] affiliate_currency[". $affiliate_currency ."]<br />";
    if ($prosites_currency != $affiliate_currency) {
        ?>
<p class="error"><?php 
        echo sprintf(__('Currency mismatch. Your Pro Sites currency is set to <strong>%s</strong> but Affiliate currency is set to <strong>%s</strong>. Please ensure both are set correctly.'), $prosites_currency, $affiliate_currency);
        ?>
</p><?php 
    }
    ?>

          <table class="form-table">
            <tr valign="top">
            <th scope="row"><?php 
    _e('1 Month payment', 'affiliate');
    ?>
</th>
            <td>
				<select name="supporter_1_whole_payment">
				<?php 
    $supporter_1_whole_payment = $getoption("supporter_1_whole_payment");
    $counter = 0;
    for ($counter = 0; $counter <= 300; $counter += 1) {
        echo '<option value="' . $counter . '"' . ($counter == $supporter_1_whole_payment ? ' selected' : '') . '>' . $counter . '</option>' . "\n";
    }
    ?>
		        </select>
		        .
				<select name="supporter_1_partial_payment">
				<?php 
    $supporter_1_partial_payment = $getoption("supporter_1_partial_payment");
    $counter = 0;
    echo '<option value="00"' . ('00' == $supporter_1_partial_payment ? ' selected' : '') . '>00</option>' . "\n";
    for ($counter = 1; $counter <= 99; $counter += 1) {
        if ($counter < 10) {
            $number = '0' . $counter;
        } else {
            $number = $counter;
        }
        echo '<option value="' . $number . '"' . ($number == $supporter_1_partial_payment ? ' selected' : '') . '>' . $number . '</option>' . "\n";
    }
    ?>
		        </select>
				&nbsp;
				<?php 
    $supporter_1_payment_type = $getoption("supporter_1_payment_type", 'actual');
    ?>
				<select name="supporter_1_payment_type">
					<option value='actual' <?php 
    selected($supporter_1_payment_type, 'actual');
    ?>
><?php 
    echo esc_html($affiliate_currency);
    ?>
</option>
					<option value='percentage' <?php 
    selected($supporter_1_payment_type, 'percentage');
    ?>
><?php 
    _e('%', 'membership');
    ?>
</option>
				</select>
		        <br /><?php 
    _e('Affiliate payment for one month.');
    ?>
            </td>
            </tr>

			<tr valign="top">
            <th scope="row"><?php 
    _e('3 Month payment', 'affiliate');
    ?>
</th>
            <td>
				<select name="supporter_3_whole_payment">
				<?php 
    $supporter_3_whole_payment = $getoption("supporter_3_whole_payment");
    $counter = 0;
    for ($counter = 0; $counter <= 300; $counter += 1) {
        echo '<option value="' . $counter . '"' . ($counter == $supporter_3_whole_payment ? ' selected' : '') . '>' . $counter . '</option>' . "\n";
    }
    ?>
		        </select>
		        .
				<select name="supporter_3_partial_payment">
				<?php 
    $supporter_3_partial_payment = $getoption("supporter_3_partial_payment");
    $counter = 0;
    echo '<option value="00"' . ('00' == $supporter_3_partial_payment ? ' selected' : '') . '>00</option>' . "\n";
    for ($counter = 1; $counter <= 99; $counter += 1) {
        if ($counter < 10) {
            $number = '0' . $counter;
        } else {
            $number = $counter;
        }
        echo '<option value="' . $number . '"' . ($number == $supporter_3_partial_payment ? ' selected' : '') . '>' . $number . '</option>' . "\n";
    }
    ?>
		        </select>
				&nbsp;
				<?php 
    $supporter_3_payment_type = $getoption("supporter_3_payment_type", 'actual');
    ?>
				<select name="supporter_3_payment_type">
					<option value='actual' <?php 
    selected($supporter_3_payment_type, 'actual');
    ?>
><?php 
    echo esc_html($affiliate_currency);
    ?>
</option>
					<option value='percentage' <?php 
    selected($supporter_3_payment_type, 'percentage');
    ?>
><?php 
    _e('%', 'membership');
    ?>
</option>
				</select>
		        <br /><?php 
    _e('Affiliate payment for three months.');
    ?>
            </td>
            </tr>

			<tr valign="top">
            <th scope="row"><?php 
    _e('12 Month payment', 'affiliate');
    ?>
</th>
            <td>
				<select name="supporter_12_whole_payment">
				<?php 
    $supporter_12_whole_payment = $getoption("supporter_12_whole_payment");
    $counter = 0;
    for ($counter = 0; $counter <= 300; $counter += 1) {
        echo '<option value="' . $counter . '"' . ($counter == $supporter_12_whole_payment ? ' selected' : '') . '>' . $counter . '</option>' . "\n";
    }
    ?>
		        </select>
		        .
				<select name="supporter_12_partial_payment">
				<?php 
    $supporter_12_partial_payment = $getoption("supporter_12_partial_payment");
    $counter = 0;
    echo '<option value="00"' . ('00' == $supporter_12_partial_payment ? ' selected' : '') . '>00</option>' . "\n";
    for ($counter = 1; $counter <= 99; $counter += 1) {
        if ($counter < 10) {
            $number = '0' . $counter;
        } else {
            $number = $counter;
        }
        echo '<option value="' . $number . '"' . ($number == $supporter_12_partial_payment ? ' selected' : '') . '>' . $number . '</option>' . "\n";
    }
    ?>
		        </select>
				&nbsp;
				<?php 
    $supporter_12_payment_type = $getoption("supporter_12_payment_type", 'actual');
    ?>
				<select name="supporter_12_payment_type">
					<option value='actual' <?php 
    selected($supporter_12_payment_type, 'actual');
    ?>
><?php 
    echo esc_html($affiliate_currency);
    ?>
</option>
					<option value='percentage' <?php 
    selected($supporter_12_payment_type, 'percentage');
    ?>
><?php 
    _e('%', 'membership');
    ?>
</option>
				</select>
	            <?php 
    if ($psts_tabs) {
        echo '<input type="hidden" name="active_tab" value="affiliate" />';
    }
    ?>
		        <br /><?php 
    _e('Affiliate payment for twelve months.');
    ?>
            </td>
            </tr>

          </table>
        </div>
	<?php 
    if (!$psts_tabs) {
        ?>
		</div>
	<?php 
    }
}
コード例 #5
0
ファイル: membership2.php プロジェクト: vilmark/vilmark_main
    /**
     * Display additional fields in the Membership payment options screen.
     *
     * This function is called on the admin screen where Membership payment
     * settings are configured.
     * We can directly output HTML code that is appended to the default form.
     *
     * Note that the payment form has no submit button! All settings must be
     * saved directly via Ajax directly when they are changed.
     *
     * @since  1.0.0
     * @param  MS_View $view The view object that called this function.
     * @param  MS_Model_Membership $membership The membership that is modified.
     */
    public function form($view, $membership)
    {
        $membership_currency = $this->api->settings->currency;
        $affiliate_currency = aff_get_option('affiliate-currency-paypal-masspay', 'USD');
        if ($membership->is_free) {
            $label = __('Reward on subscription', 'affiliate');
        } else {
            $label = __('Reward on first payment', 'affiliate');
        }
        $fields = array();
        $fields['value'] = array('type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'id' => 'aff_reward_value', 'before' => $label, 'value' => $this->get_value($membership), 'class' => 'ms-text-smallish', 'config' => array('step' => '0.01', 'min' => '0'), 'ajax_data' => array('action' => self::AJAX_ACTION, 'membership_id' => $membership->id));
        $fields['type'] = array('type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'id' => 'aff_reward_type', 'value' => $this->get_type($membership), 'field_options' => array('inv' => __('Percent (payment)', 'affiliate') . '*', 'mem' => __('Percent (price)', 'affiliate') . '**', 'abs' => $affiliate_currency), 'ajax_data' => array('action' => self::AJAX_ACTION, 'membership_id' => $membership->id));
        ?>
		<div class="aff-payment-options">
			<?php 
        MS_Helper_Html::html_separator();
        ?>
			<div class="aff-title">
				<strong><?php 
        _e('Affiliate settings', 'affiliate');
        ?>
</strong>
			</div>
			<div class="aff-inside">
				<?php 
        foreach ($fields as $field) {
            MS_Helper_Html::html_element($field);
        }
        ?>
				<p>
				* <?php 
        _e('Reward is based on the actually paid amount which includes any discounts (but no taxes).', 'affiliate');
        ?>
<br />
				** <?php 
        _e('Reward is based on the current membership price setting.', 'affiliate');
        ?>
				</p>
				<p>
				<?php 
        printf(__('Tipp: There is no currency conversion done. All rewards are paid in %s, regardless of the currency used by Membership2 or the invoice.', 'affiliate'), '<strong>' . $affiliate_currency . '</strong>');
        ?>
				</p>
			</div>
		</div>
		<?php 
    }
コード例 #6
0
    function output_banners()
    {
        $user = wp_get_current_user();
        $user_ID = $user->ID;
        if (empty($user_ID)) {
            return '';
        }
        $reference = get_user_meta($user_ID, 'affiliate_reference', true);
        if (function_exists('is_multisite') && is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('affiliate/affiliate.php')) {
            $site = aff_get_option('site_name');
            $url = get_blog_option(1, 'home');
        } else {
            $site = aff_get_option('blogname');
            $url = aff_get_option('home');
        }
        ob_start();
        $banners = aff_get_option('affiliatebannerlinks');
        foreach ((array) $banners as $banner) {
            ?>
			<img src='<?php 
            echo $banner;
            ?>
' />
			<br/><br/>
			<textarea cols='80' rows='5'><?php 
            echo sprintf("<a href='%s?ref=%s'>\n", $url, $reference);
            echo "<img src='" . $banner . "' alt='" . htmlentities(stripslashes($site), ENT_QUOTES, 'UTF-8') . "' title='Check out " . htmlentities(stripslashes($site), ENT_QUOTES, 'UTF-8') . "' />\n";
            echo "</a>";
            ?>
</textarea>
			<br/><br/>
			<?php 
        }
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
コード例 #7
0
    function output_banners()
    {
        $user = wp_get_current_user();
        $user_ID = $user->ID;
        if (empty($user_ID)) {
            return '';
        }
        $reference = get_user_meta($user_ID, 'affiliate_reference', true);
        if (function_exists('is_multisite') && is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('affiliate/affiliate.php')) {
            $site = aff_get_option('site_name');
            $url = get_blog_option(1, 'home');
        } else {
            $site = aff_get_option('blogname');
            $url = aff_get_option('home');
        }
        if (function_exists('is_multisite') && is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('affiliate/affiliate.php')) {
            $site = aff_get_option('site_name');
            // switch to use new option
            $siteurl = get_blog_option(1, 'home');
            $affiliatelinkurl = aff_get_option('affiliatelinkurl', $siteurl);
        } else {
            $site = aff_get_option('blogname');
            // switch to use new option
            $siteurl = aff_get_option('home');
            $affiliatelinkurl = aff_get_option('affiliatelinkurl', $siteurl);
        }
        ob_start();
        $banners = aff_get_option('affiliatebannerlinks');
        foreach ((array) $banners as $banner) {
            // Split the string in case there is a | in there
            $advbanner = explode("|", $banner);
            if (count($advbanner) == 1) {
                $advbanner[] = $affiliatelinkurl;
            }
            // Trim the array so that it removes none text characters
            array_map('trim', $advbanner);
            ?>
			<img src='<?php 
            echo $advbanner[0];
            ?>
' />
			<br/><br/>
			<textarea cols='80' rows='5'><?php 
            echo sprintf("<a href='%s?ref=%s'>\n", $advbanner[1], $reference);
            echo "<img src='" . $advbanner[0] . "' alt='" . htmlentities(stripslashes($site), ENT_QUOTES, 'UTF-8') . "' title='Check out " . htmlentities(stripslashes($site), ENT_QUOTES, 'UTF-8') . "' />\n";
            echo "</a>";
            ?>
</textarea>
			<br/><br/>
			<?php 
        }
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
コード例 #8
0
function show_affiliate_admin_metabox_settings_paypal_masspay_currency()
{
    global $affiliate_currencies, $affiliate_currencies_paypal_masspay;
    sort($affiliate_currencies_paypal_masspay);
    ?>
	<div class="postbox">
		<h3 class='hndle'><span><?php 
    _e('Currency used for PayPal Masspay', 'affiliate');
    ?>
</span></h3>
		<div class="inside">
			<span class="description"><?php 
    echo sprintf(__('This setting defines the 3-character currency used for the %s.', 'affiliate'), '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_batch-payment-format-outside" target="_blank">' . __('PayPal masspay file', 'affiliate') . '</a>');
    ?>
</span>



			<table class="form-table">
			<tr valign="top">
				<th scope="row"><?php 
    _e('Currency', 'mp');
    ?>
</th>
				<td>
					<select id="affiliate-currency-paypal-masspay" name="affiliate-currency-paypal-masspay">
					<?php 
    foreach ($affiliate_currencies_paypal_masspay as $key) {
        if (isset($affiliate_currencies[$key])) {
            ?>
<option value="<?php 
            echo $key;
            ?>
"<?php 
            selected(aff_get_option('affiliate-currency-paypal-masspay', 'USD'), $key);
            ?>
><?php 
            echo esc_attr($key) . ' - ' . esc_attr($affiliate_currencies[$key][0]);
            ?>
</option><?php 
        }
    }
    ?>
					</select>
				</td>
			</tr>
			</table>
		</div>
	</div>
	<?php 
}
コード例 #9
0
ファイル: membership.php プロジェクト: vilmark/vilmark_main
function affiliate_membership_subscription_settings($sub_id)
{
    global $M_options;
    ?>
	<h3><?php 
    _e('Affiliate settings', 'affiliate');
    ?>
</h3>
	<div class='sub-details'>

	<?php 
    $membership_currency = $M_options['paymentcurrency'];
    $affiliate_currency = aff_get_option('affiliate-currency-paypal-masspay', 'USD');
    if ($membership_currency != $affiliate_currency) {
        ?>
<p class="error"><?php 
        echo sprintf(__('Currency mismatch. Your Membership currency is set to <strong>%s</strong> but Affiliate currency is set to <strong>%s</strong>. Please ensure both are set correctly.'), $membership_currency, $affiliate_currency);
        ?>
</p><?php 
    }
    ?>
	<label for='aff_pay'><?php 
    _e('Affiliate payment credited for a signup on this subscription', 'management');
    ?>
</label>
	<select name="membership_whole_payment">
	<?php 
    $membership_whole_payment = get_option("membership_whole_payment_" . $sub_id);
    $counter = 0;
    for ($counter = 0; $counter <= MEMBERSHIP_MAX_CHARGE; $counter += 1) {
        echo '<option value="' . $counter . '"' . ($counter == $membership_whole_payment ? ' selected' : '') . '>' . $counter . '</option>' . "\n";
    }
    ?>
    </select>
    .
	<select name="membership_partial_payment">
	<?php 
    $membership_partial_payment = get_option("membership_partial_payment_" . $sub_id);
    $counter = 0;
    echo '<option value="00"' . ('00' == $membership_partial_payment ? ' selected' : '') . '>00</option>' . "\n";
    for ($counter = 1; $counter <= 99; $counter += 1) {
        if ($counter < 10) {
            $number = '0' . $counter;
        } else {
            $number = $counter;
        }
        echo '<option value="' . $number . '"' . ($number == $membership_partial_payment ? ' selected' : '') . '>' . $number . '</option>' . "\n";
    }
    ?>
    </select>
	&nbsp;
	<?php 
    $membership_payment_type = get_option("membership_payment_type_" . $sub_id, 'actual');
    ?>
	<select name="membership_payment_type">
		<option value='actual' <?php 
    selected($membership_payment_type, 'actual');
    ?>
><?php 
    echo esc_html($affiliate_currency);
    ?>
</option>
		<option value='percentage' <?php 
    selected($membership_payment_type, 'percentage');
    ?>
><?php 
    _e('%', 'membership');
    ?>
</option>
	</select>
	</div>
	<?php 
}
コード例 #10
0
ファイル: affiliateadmin.php プロジェクト: hscale/webento
    function handle_affiliates_panel()
    {
        global $page;
        wp_reset_vars(array('page'));
        $page = addslashes($_GET['page']);
        echo "<div class='wrap nosubsub'>";
        echo "<h2>" . __('Affiliate System Administration', 'affiliate') . "</h2>";
        $this->show_affiliates_panel_menu();
        if (!empty($page) && $page != 'affiliatesadmin') {
            switch ($page) {
                case 'affiliatesadminsettings':
                    $this->handle_affiliate_settings_panel();
                    break;
                case 'affiliatesadminmanage':
                    $this->handle_affiliate_users_panel();
                    break;
                case 'affiliatesadminaddons':
                    $this->handle_addons_panel();
                    break;
                default:
                    break;
            }
        } else {
            if (isset($_GET['action'])) {
                switch (addslashes($_GET['action'])) {
                    case 'allaffiliates':
                        // Bulk operations
                        if (isset($_POST['allaction_markaspaid'])) {
                            check_admin_referer('allaffiliateactions');
                            if (!empty($_POST['allpayments'])) {
                                foreach ($_POST['allpayments'] as $affiliate) {
                                    $affdetails = explode('-', $affiliate);
                                    if (count($affdetails) == 2) {
                                        $affected = $this->db->query("UPDATE " . $this->affiliatedata . " SET payments = payments + (credits - debits), lastupdated = '" . current_time('mysql', true) . "' WHERE user_id = " . $affdetails[0] . " AND period = '" . $affdetails[1] . "'");
                                    }
                                }
                                echo '<div id="message" class="updated fade"><p>' . __('Payments has been assigned correctly.', 'affiliate') . '</p></div>';
                            }
                            // Mark as paid
                        }
                        break;
                    case 'makepayment':
                        // Mark a payment
                        $affiliate = addslashes($_GET['id']);
                        if (isset($affiliate)) {
                            $affdetails = explode('-', $affiliate);
                            if (count($affdetails) == 2) {
                                $affected = $this->db->query("UPDATE " . $this->affiliatedata . " SET payments = payments + (credits - debits), lastupdated = '" . current_time('mysql', true) . "' WHERE user_id = " . $affdetails[0] . " AND period = '" . $affdetails[1] . "'");
                                if ($affected) {
                                    echo '<div id="message" class="updated fade"><p>' . __('Payment has been assigned correctly.', 'affiliate') . '</p></div>';
                                }
                            }
                        }
                        break;
                }
            }
            $headings = aff_get_option('affiliateheadings', array(__('Unique Clicks', 'affiliate'), __('Sign ups', 'affiliate'), __('Paid members', 'affiliate')));
            $headings = array_merge($headings, array(__('Debits', 'affiliate'), __('Credits', 'affiliate'), __('Payments', 'affiliate')));
            $newcolumns = apply_filters('affiliate_column_names', $headings);
            if (count($newcolumns) == 6) {
                // We must have 6 columns
                $columns = $newcolumns;
            }
            if (isset($_REQUEST['reportperiod'])) {
                $reportperiod = addslashes($_REQUEST['reportperiod']);
            } else {
                $reportperiod = date('Ym');
            }
            $results = $this->db->get_results($this->db->prepare("SELECT * FROM {$this->affiliatedata} WHERE period = %s ORDER BY credits DESC", $reportperiod));
            echo '<form id="form-affiliate-list" action="?page=' . $page . '&amp;action=allaffiliates" method="post">';
            echo '<input type="hidden" name="action" value="allaffiliates" />';
            echo '<input type="hidden" name="page" value="' . $page . '" />';
            echo '<div class="tablenav">';
            echo '<div class="alignleft">';
            echo __('Show report for', 'affiliate') . '&nbsp;';
            echo '<select name="reportperiod" id="reportperiod">';
            $startat = strtotime(date("Y-m-15"));
            for ($n = 0; $n <= 24; $n++) {
                $rdate = strtotime("-{$n} month", $startat);
                $period = date('Ym', $rdate);
                echo '<option value="' . $period . '"';
                if ($reportperiod == $period) {
                    echo ' selected="selected"';
                }
                echo '>' . date('M Y', $rdate) . '</option>';
            }
            echo '</select>&nbsp;';
            echo '<input type="submit" value="' . __('Refresh', 'affiliate') . '" name="allaction_refresh" class="button-secondary" />';
            echo '<br class="clear" />';
            echo '</div>';
            echo '<div class="alignright">';
            echo '<input type="submit" value="' . __('Export Payments', 'affiliate') . '" name="allaction_exportpayments" class="button-secondary delete" />&nbsp;&nbsp;';
            echo '<input type="submit" value="' . __('Mark as Paid', 'affiliate') . '" name="allaction_markaspaid" class="button-secondary" />';
            wp_nonce_field('allaffiliateactions');
            echo '<br class="clear" />';
            echo '</div>';
            echo '</div>';
            echo '<table cellpadding="3" cellspacing="3" class="widefat" style="width: 100%;">';
            echo '<thead>';
            echo '<tr>';
            echo '<th scope="col" class="check-column"></th>';
            echo '<th scope="col">';
            echo __('Username', 'affiliate');
            echo '</th>';
            foreach ($columns as $column) {
                echo '<th scope="col" class="num">';
                echo $column;
                echo '</th>';
            }
            echo '</tr>';
            echo '</thead>';
            echo '<tbody id="the-list">';
            if ($results) {
                foreach ($results as $result) {
                    echo "<tr class=''>";
                    // Check boxes
                    echo '<th scope="row" class="check-column">';
                    echo '<input type="checkbox" id="payment-' . $result->user_id . "-" . $result->period . '" name="allpayments[]" value="' . $result->user_id . "-" . $result->period . '" />';
                    echo '</th>';
                    echo '<td valign="top">';
                    $user = get_userdata($result->user_id);
                    echo $user->user_login;
                    echo " ( " . get_user_meta($result->user_id, 'affiliate_paypal', true) . " )";
                    // Get the affiliate website listing
                    $referrer = get_user_meta($result->user_id, 'affiliate_referrer', true);
                    if (!empty($referrer)) {
                        echo " " . __('linked to ', 'affiliate') . "<a href='http://{$referrer}'>" . $referrer . "</a>";
                    }
                    // Quick links
                    $actions = array();
                    $actions[] = "<a href='?page={$page}&amp;action=makepayment&amp;id=" . $result->user_id . "-" . $result->period . "&amp;reportperiod=" . $reportperiod . "' class='edit'>" . __('Mark as Paid', 'affiliate') . "</a>";
                    $actions[] = "<a href='?page=affiliatesadminmanage&amp;subpage=users&amp;id=" . $result->user_id . "' class='edit'>" . __('Manage Affiliate', 'affiliate') . "</a>";
                    echo '<div class="row-actions">';
                    echo implode(' | ', $actions);
                    echo '</div>';
                    echo '</td>';
                    echo '<td valign="top" class="num">';
                    echo $result->uniques;
                    echo '</td>';
                    echo '<td valign="top" class="num">';
                    echo $result->signups;
                    echo '</td>';
                    echo '<td valign="top" class="num">';
                    echo $result->completes;
                    echo '</td>';
                    echo '<td valign="top" class="num">';
                    echo number_format($result->debits, 2);
                    echo '</td>';
                    echo '<td valign="top" class="num">';
                    echo number_format($result->credits, 2);
                    echo '</td>';
                    echo '<td valign="top" class="num">';
                    echo number_format($result->payments, 2);
                    echo '</td>';
                    echo '</tr>';
                }
            } else {
                echo "<tr class=''>";
                echo '<td colspan="8" valign="top">';
                echo __('There are no results for the selected month.', 'affiliate');
                echo '</td>';
                echo '</tr>';
            }
            echo '</tbody>';
            echo '<tfoot>';
            echo '<tr>';
            echo '<th scope="col" class="check-column"></th>';
            echo '<th scope="col">';
            echo __('Username', 'affiliate');
            echo '</th>';
            reset($columns);
            foreach ($columns as $column) {
                echo '<th scope="col" class="num">';
                echo $column;
                echo '</th>';
            }
            echo '</tr>';
            echo '</tfoot>';
            echo '</table>';
            echo '</form>';
            ?>
			</div>
			<?php 
        }
    }
コード例 #11
0
 function show_users_period_summary_table($user_id)
 {
     $headings = aff_get_option('affiliateheadings', array(__('Unique Clicks', 'affiliate'), __('Sign ups', 'affiliate'), __('Paid members', 'affiliate')));
     $headings = array_merge($headings, array(__('Credits', 'affiliate'), __('Debits', 'affiliate'), __('Payments', 'affiliate'), __('Balance', 'affiliate')));
     $newcolumns = apply_filters('affiliate_summary_columns', $headings);
     if (count($newcolumns) == 7) {
         // We must have 6 columns
         $columns = $newcolumns;
     }
     $results = $this->db->get_results($this->db->prepare("SELECT * FROM {$this->affiliatedata} WHERE user_id = %d ORDER BY period DESC", $user_id));
     // The table
     echo '<table width="100%" cellpadding="3" cellspacing="3" class="widefat" style="width: 100%;">';
     echo '<thead>';
     echo '<tr>';
     echo '<th scope="col">';
     echo __('Period', 'affiliate');
     echo '</th>';
     foreach ($columns as $column) {
         echo '<th scope="col" class="num">';
         echo stripslashes($column);
         echo '</th>';
     }
     echo '</tr>';
     echo '</thead>';
     echo '<tbody id="the-list">';
     $totalclicks = 0.0;
     $totalsignups = 0.0;
     $totalcompletes = 0.0;
     $totaldebits = 0.0;
     $totalcredits = 0.0;
     $totalpayments = 0.0;
     $totalbalances = 0.0;
     if (!empty($results)) {
         $recent = array_shift($results);
     } else {
         $recent = array();
     }
     $startat = strtotime(date("Y-m-15"));
     //echo "startat[". $startat ."]<br />";
     //global $wp_locale;
     //echo "wp_locale<pre>"; print_r($wp_locale); echo "</pre>";
     for ($n = 0; $n < 18; $n++) {
         $rdate = strtotime("-{$n} month", $startat);
         $period = date('Ym', $rdate);
         $place = 10 - $n;
         echo "<tr class='periods' id='period-{$place}'>";
         echo '<td valign="top">';
         //echo "recent<pre>"; print_r($recent); echo "</pre>";
         if (!empty($recent->uniques) || !empty($recent->signups) || !empty($recent->completes) || !empty($recent->debits) || !empty($recent->credits) || !empty($recent->payments)) {
             /*
             if(is_network_admin()) {
             	echo '<a href="' . network_admin_url('user-edit.php?user_id='. $user_id .'&period='. $period .'#affiliate-details') .'">'. date("M", $rdate) . '<br/>' . date("Y", $rdate) .'</a>';
             } else {
             	echo '<a href="'. admin_url('user-edit.php?user_id='. $user_id .'&period='. $period .'#affiliate-details') .'">'. date("M", $rdate) . '<br/>' . date("Y", $rdate) .'</a>';
             }
             */
             $period_url = esc_url(add_query_arg('subpage', 'details'));
             $period_url = esc_url(add_query_arg('period', $period, $period_url));
             echo '<a title="' . __('View Affiliate detail transactions for this period', 'affiliate') . '" href="' . $period_url . '">' . date_i18n("M", $rdate, true) . '<br/>' . date_i18n("Y", $rdate) . '</a>';
         } else {
             echo date_i18n("M", $rdate, true) . '<br/>' . date_i18n("Y", $rdate);
         }
         echo '</td>';
         if (!empty($recent) && $recent->period == $period) {
             // We are on the current period
             echo '<td valign="top" class="num">';
             echo $recent->uniques;
             $totalclicks += $recent->uniques;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo $recent->signups;
             $totalsignups += $recent->signups;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo $recent->completes;
             $totalcompletes += $recent->completes;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo number_format($recent->credits, 2);
             $totalcredits += (double) $recent->credits;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo number_format($recent->debits * -1, 2);
             $totaldebits += (double) $recent->debits;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo number_format($recent->payments * -1, 2);
             $totalpayments += (double) $recent->payments;
             echo '</td>';
             echo '<td valign="top" class="num">';
             $balanace = $recent->credits - $recent->debits - $recent->payments;
             $totalbalances += $balanace;
             echo number_format($balanace, 2);
             echo '</td>';
             if (!empty($results)) {
                 $recent = array_shift($results);
             } else {
                 $recent = array();
             }
         } else {
             // A zero blank row
             echo '<td valign="top" class="num">';
             echo 0;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo 0;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo 0;
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo "0.00";
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo number_format(0, 2);
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo number_format(0, 2);
             echo '</td>';
             echo '<td valign="top" class="num">';
             echo number_format(0, 2);
             echo '</td>';
         }
         echo '</tr>';
     }
     echo '</tbody>';
     echo '<tfoot>';
     echo '<tr>';
     echo '<th scope="col">';
     echo '</th>';
     echo '<th scope="col" class="num">';
     echo $totalclicks;
     echo '</th>';
     echo '<th scope="col" class="num">';
     echo $totalsignups;
     echo '</th>';
     echo '<th scope="col" class="num">';
     echo $totalcompletes;
     echo '</th>';
     echo '<th scope="col" class="num">';
     echo number_format($totalcredits, 2);
     echo '</th>';
     echo '<th scope="col" class="num">';
     echo number_format($totaldebits * -1, 2);
     echo '</th>';
     echo '<th scope="col" class="num">';
     echo number_format($totalpayments * -1, 2);
     echo '</th>';
     echo '<th scope="col" class="num">';
     echo number_format($totalbalances, 2);
     echo '</th>';
     echo '</tr>';
     echo '</tfoot>';
     echo '</table>';
 }
コード例 #12
0
 function get_columns()
 {
     $columns = array();
     //$columns['cb']			= '<input type="checkbox" />';
     $columns['username'] = __('Username', 'affiliate');
     $columns['name'] = __('Name', 'affiliate');
     if (is_multisite() && is_network_admin()) {
         $columns['blog'] = __('Blog', 'affiliate');
     }
     if (aff_get_option('affiliateenableapproval', 'no') == 'yes') {
         $columns['approval'] = __('Approved', 'affiliate');
     }
     $columns['paypal'] = __('PayPal account', 'affiliate');
     $columns['reference'] = __('Reference', 'affiliate');
     $columns['linked'] = __('URL', 'affiliate');
     return $columns;
 }
コード例 #13
0
 function install()
 {
     return;
     // The install is done via the admin class on plugin activation. WTF is this doing here?
     // This shouldn't really need to be called as the admin area will set up the tables - but just in case
     if ($this->db->get_var("SHOW TABLES LIKE '" . $this->affiliatedata . "' ") != $this->affiliatedata) {
         $charset_collate = '';
         if (!empty($this->db->charset)) {
             $charset_collate = "DEFAULT CHARACTER SET " . $this->db->charset;
         }
         if (!empty($this->db->collate)) {
             $charset_collate .= " COLLATE " . $this->db->collate;
         }
         $sql = "CREATE TABLE `" . $this->affiliatedata . "` (\n\t\t\t  \t`user_id` bigint(20) default NULL,\n\t\t\t  \t`period` varchar(6) default NULL,\n\t\t\t  \t`uniques` bigint(20) default '0',\n\t\t\t  \t`signups` bigint(20) default '0',\n\t\t\t  \t`completes` bigint(20) default '0',\n\t\t\t  \t`debits` decimal(10,2) default '0.00',\n\t\t\t  \t`credits` decimal(10,2) default '0.00',\n\t\t\t  \t`payments` decimal(10,2) default '0.00',\n\t\t\t  \t`lastupdated` datetime default '0000-00-00 00:00:00',\n\t\t\t  \tUNIQUE KEY `user_period` (`user_id`,`period`)\n\t\t\t\t) {$charset_collate};";
         $this->db->query($sql);
         $sql = "CREATE TABLE `" . $this->affiliatereferrers . "` (\n\t\t\t  \t`user_id` bigint(20) default NULL,\n\t\t\t  \t`period` varchar(6) default NULL,\n\t\t\t  \t`url` varchar(250) default NULL,\n\t\t\t  \t`referred` bigint(20) default '0',\n\t\t\t  \tUNIQUE KEY `user_id` (`user_id`,`period`,`url`)\n\t\t\t\t) {$charset_collate};";
         $this->db->query($sql);
     }
     if ($this->db->get_var("SHOW TABLES LIKE '" . $this->affiliaterecords . "' ") != $this->affiliaterecords) {
         $sql = "CREATE TABLE `" . $this->affiliaterecords . "` (\n\t\t\t  \t`user_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t  `period` varchar(6) DEFAULT NULL,\n\t\t\t\t  `affiliatearea` varchar(50) DEFAULT NULL,\n\t\t\t\t  `area_id` bigint(20) DEFAULT NULL,\n\t\t\t\t  `affiliatenote` text,\n\t\t\t\t  `amount` decimal(10,2) DEFAULT NULL,\n\t\t\t\t  KEY `user_id` (`user_id`),\n\t\t\t\t  KEY `period` (`period`)\n\t\t\t\t) {$charset_collate};";
         $this->db->query($sql);
     }
     if (affiliate_is_plugin_active_for_network() && (defined('AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED') && AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED == 'yes')) {
         // We need to check for a transfer across from old options to new ones
         $option = aff_get_option('affiliateheadings', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliateheadings');
             aff_update_option('affiliateheadings', $option);
         }
         $option = aff_get_option('affiliatesettingstext', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliatesettingstext');
             aff_update_option('affiliatesettingstext', $option);
         }
         $option = aff_get_option('affiliateadvancedsettingstext', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliateadvancedsettingstext');
             aff_update_option('affiliateadvancedsettingstext', $option);
         }
         $option = aff_get_option('affiliateenablebanners', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliateenablebanners');
             aff_update_option('affiliateenablebanners', $option);
         }
         $option = aff_get_option('affiliatelinkurl', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliatelinkurl');
             aff_update_option('affiliatelinkurl', $option);
         }
         $option = aff_get_option('affiliatebannerlinks', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliatebannerlinks');
             aff_update_option('affiliatebannerlinks', $option);
         }
         $option = aff_get_option('affiliate_activated_addons', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliate_activated_addons');
             aff_update_option('affiliate_activated_addons', $option);
         }
     }
 }
コード例 #14
0
ファイル: functions.php プロジェクト: vilmark/vilmark_main
function load_affiliate_addons()
{
    $plugins = aff_get_option('affiliate_activated_addons', array());
    if (is_dir(affiliate_dir('affiliateincludes/addons'))) {
        if ($dh = opendir(affiliate_dir('affiliateincludes/addons'))) {
            $aff_plugins = array();
            while (($plugin = readdir($dh)) !== false) {
                // Not sure why this file is present. But ignore it.
                if ($plugin == "prosites.php") {
                    continue;
                }
                if (substr($plugin, -4) == '.php') {
                    $aff_plugins[] = $plugin;
                }
            }
            closedir($dh);
            sort($aff_plugins);
            $aff_plugins = apply_filters('affiliate_available_addons', $aff_plugins);
            foreach ($aff_plugins as $aff_plugin) {
                if (in_array($aff_plugin, (array) $plugins)) {
                    include_once affiliate_dir('affiliateincludes/addons/' . $aff_plugin);
                }
            }
        }
    }
}