<?php

require_once 'classes/AffiliatePlugin.php';

/**
* @package Plugins
*/
class PluginJrox extends AffiliatePlugin
{
    function getVariables()
    {
        /* Specification
              itemkey     - used to identify variable in your other functions
              type        - text,textarea,yesno,password,hidden ( type hidden are variables used by CE and are required )
              description - description of the variable, displayed in ClientExec
        */
    
        $variables = array (
                   /*T*/"Plugin Name"/*/T*/ => array (
                                        "type"=>"hidden",
                                        "description"=>"Used By CE to show plugin - must match how you call the action function names",
                                        "value"=>/*T*/"JROX Affiliate Manager"/*/T*/
                                       ),
                   /*T*/'Enabled'/*/T*/       => array(
                                        "type"          => "yesno",
                                        "description"   => /*T*/"When enabled, JROX will be notified of new sales."/*/T*/,
                                        "value"         => "0",
                                    ),
                   /*T*/"Description"/*/T*/ => array (
                                        "type"=>"hidden",
                                        "description"=>/*T*/"Description viewable by admin in server settings"/*/T*/,
                                        "value"=>/*T*/"Plugin for JROX to notify when new orders are accepted."/*/T*/
                                       ),
                   /*T*/"Image URL"/*/T*/ => array (
                                        "type"=>"text",
                                        "description"=>/*T*/"The full URL to JROX's sale.php.  Example: http://mydomain.com/jrox/sale.php"/*/T*/,
                                        "value"=>"http://mydomain.com/jrox/sale.php"
                                       ),
                   /*T*/"Include Tax"/*/T*/ => array (
                                        "type"=>"yesno",
                                        "description"=>/*T*/"Whether tax should be included in the affiliate amount."/*/T*/,
                                        "value"=>"0"
                                       ),
        );
        return $variables;
    }
    
    function getImage($args)
    {
        require_once 'modules/billing/models/Invoice.php';
        $invoice = new Invoice($this->user, $args['invoiceNumber']);
        if ($args['Include Tax'] == 0 && $invoice->getTax() > 0) {
            $args['invoiceAmount'] = $invoice->getPriceExludingTax();
        }
        $this->logger->log(5, 'Generating JROX hidden sale image (Amount: $'.$args['invoiceAmount'].' Invoice #: '.$args['invoiceNumber'].')');
        return '<img border="0" src="'.$args['Image URL'].'?amount='.$args['invoiceAmount'].'&trans_id='.$args['invoiceNumber'].'" width="1" height="1">';
    }
}
?>
