anchor.diff:      <% mods = Rails.configuration.modules %>
       
       <ul class="nav nav-tabs" role="tablist">
  -      
         <% if mods.include? :marketing %>
           <li role="presentation" class="<%= "active" if ["campaigns", "", nil].include? params[:q] %>"><a href="<%= admin_system_affiliate_path(@affiliate, q: "campaigns")%>" role="tab">Marketing Campaigns</a></li>
  -        <li role="presentation" class="<%= "active" if params[:q] == "commissions" %>"><a href="<%= admin_system_affiliate_path(@affiliate, q: "commissions")%>" role="tab">Commissions</a></li>
  +        <% if mods.include? :store %>
  +          <li role="presentation" class="<%= "active" if params[:q] == "orders" %>"><a href="<%= admin_system_affiliate_path(@affiliate, q: "orders")%>" role="tab">Orders</a></li>
  +        <% end %>
           <li role="presentation" class="<%= "active" if params[:q] == "payments" %>"><a href="<%= admin_system_affiliate_path(@affiliate, q: "payments")%>" role="tab">Payments</a></li>
         <% end %>
  -      
  -      <% if mods.include? :store %>
  -        <li role="presentation" class="<%= "active" if params[:q] == "orders" %>"><a href="<%= admin_system_affiliate_path(@affiliate, q: "orders")%>" role="tab">Orders</a></li>
  -      <% end %>
       </ul>
   		
       
  
positive.code:     
        <%
          campaigns = AffiliateCampaign.where(affiliate_id: @affiliate.id)
          orders = Order.where(affiliate_campaign_id: campaigns).where.not(status: "in cart").order(submitted: :desc).paginate(page: params[:page], per_page: 10) 
        %>
    
        <%= will_paginate orders %>
        <table class="table table-striped table-condensed">
        	<tr>
        		<th>Order #</th>
            <th>Sales Channel</th>
        		<th>Date</th>
        		<th>Customer</th>
        		<th>Location</th>
        		<th>Amount</th>
        		<th>Status</th>
        	</tr>
        	<% orders.each do |order| %>
        	<tr>
        		<td><%= link_to order.id, admin_store_order_path(order) %></td>
            <td><%= order.sales_channel %></td>
        		<td><%= systime order.submitted if order.submitted%></td>
        		<td><%= order.shipping_name || order.billing_name %></td>
        		<td><%= order.shipping_city %>, <%= order.shipping_state %></td>
        		<td><%= number_to_currency(order.total) %></td>
        		<td><%= order_status(order) %></td>
        	</tr>
        	<% end %>
        </table>
  
      <% elsif params[:q] == "commissions" %>
      
        <% payments = Payment.where(payable_type: "affiliate", payable_id: @affiliate.id).where("amount > 0.0").order(created_at: :desc).paginate(page: params[:page], per_page: 10) %>
  
        <%= will_paginate payments %>
        <table class="table table-striped table-condensed">
          <tr>
            <th>ID</th>
            <th>Date</th>
            <th>Item</th>
            <th>Amount</th>
          </tr>
          <% payments.order('created_at DESC').each do |pmt| %>
          <tr>
            <td><%= pmt.id %></td>
            <td><%= systime pmt.created_at %></td>
            <td>
              <% if pmt.payable_type == "order" %>
                  <%= link_to "Order ##{pmt.payable_id}", admin_store_order_path(pmt.payable_id) %>
              <% elsif pmt.payable_type == "user_package" %>
                  <%= link_to "Package: " + UserPackage.find(pmt.payable_id).package.name, admin_billing_user_package_path(pmt.payable_id) %>
              <% elsif pmt.payable_type == "pbx_cdr" %>
                  <%= link_to "Phone Call", admin_pbx_cdr_path(0, uuid: pmt.payable_id) %>
              <% end %>
            </td>
            <td><%= number_to_currency(pmt.amount, negative_format: "(%u%n)") %></td>
          </tr>
          <% end %>
        </table>
  
      <% elsif params[:q] == "payments" %>
      
  
negative.code:     		<table class="table table-striped table-condensed">
      			<tr>
      				<th>Campaign</th>
      				<th class="text-center">Signup</th>
      				<th class="text-center">Sale</th>
      				<th class="text-center">Raw clicks</th>
      				<th class="text-center">Uniq. clicks</th>
      				<th class="text-center">Signups</th>
      				<th class="text-center">Orders</th>
              <th class="text-center">Conv. A</th>
              <th class="text-center">Conv. B</th>
              <th>Earn</th>
      			</tr>
      			<% campaigns.each do |campaign| 
              earning =  Order.where(affiliate_campaign_id: campaign.id)
                              .where.not(status: ["in cart", "cancelled"])
                              .sum(:total) * campaign.sale_commission / 100.0 %>
      			<tr>
      				<td><%= link_to campaign.name, edit_admin_marketing_affiliate_campaign_path(campaign) %></td>
      				<td class="text-center"><%= number_to_currency campaign.signup_commission %></td>
      				<td class="text-center"><%= campaign.sale_commission %>%</td>
      				<td class="text-center"><%= number_with_delimiter(campaign.raw_clicks) %></td>
      				<td class="text-center"><%= number_with_delimiter(campaign.unique_clicks) %></td>
      				<td class="text-center"><%= number_with_delimiter(campaign.signups) %></td>
      				<td class="text-center"><%= number_with_delimiter(campaign.orders) %></td>
              <td class="text-center"><%= (100.0 * campaign.signups / campaign.unique_clicks).round(1) %>%</td>
              <td class="text-center"><%= (100.0 * campaign.orders / campaign.unique_clicks).round(1) %>%</td>
              <td><%= number_to_currency(earning) %></td>
      			</tr>
      			<% end %>
      		</table>
  