Exemplo n.º 1
0
 function onGridUserAfterSave(Am_Event_Grid $event)
 {
     $vars = $event->getArg(0);
     if (!empty($vars['_newsletter_hidden'])) {
         $vals = @$vars['_newsletter'];
         $this->getDi()->newsletterUserSubscriptionTable->adminSetIds($event->getGrid()->getRecord()->pk(), (array) $vals);
     }
 }
Exemplo n.º 2
0
 function onGridProductValuesToForm(Am_Event_Grid $event)
 {
     $args = $event->getArgs();
     $product = $args[1];
     $args[0]['_thanks_redirect_url'] = $product->data()->get('thanks_redirect_url');
 }
Exemplo n.º 3
0
 function onGridProductInitGrid(Am_Event_Grid $event)
 {
     $grid = $event->getGrid();
     $grid->addField(new Am_Grid_Field('subscription_limit', ___('Limit'), false))->setRenderFunction(array($this, 'renderLimit'));
 }
Exemplo n.º 4
0
    public function onGridUserInitForm(Am_Event_Grid $event)
    {
        $fieldSet = $event->getGrid()->getForm()->addAdvFieldset('affiliate')->setLabel(___('Affiliate Program'));
        $user = $event->getGrid()->getRecord();
        $user_id = $user->pk();
        $affGroup = $fieldSet->addGroup()->setLabel(___('Referred Affiliate'));
        $affEl = $affGroup->addText('_aff', array('placeholder' => ___('Type Username or E-Mail')))->setId('aff-refered-affiliate');
        $fieldSet->addScript()->setScript(<<<CUT
    \$("input#aff-refered-affiliate").autocomplete({
        minLength: 2,
        source: window.rootUrl + "/aff/admin/autocomplete/?exclude={$user_id}"
    });
CUT
);
        if (!empty($user->aff_id)) {
            try {
                $aff = $this->getDi()->userTable->load($user->aff_id);
                $affEl->setValue($aff->login);
                $affEl->setAttribute('style', 'display:none');
                $url = new Am_View_Helper_UserUrl();
                $is_expired = false;
                if ($commissionDays = $this->getDi()->config->get('aff.commission_days')) {
                    $signupDays = $this->getDi()->time - strtotime($user->aff_added ? $user->aff_added : $user->added);
                    $signupDays = intval($signupDays / (3600 * 24));
                    // to days
                    if ($commissionDays < $signupDays) {
                        $is_expired = true;
                    }
                }
                $affHtml = sprintf('<div><a class="link" href="%s">%s %s (%s)</a> [<a href="javascript:;" title="%s" class="local" id="aff-unassign-affiliate">x</a>]%s</div>', Am_Controller::escape($url->userUrl($user->aff_id)), $aff->name_f, $aff->name_l, $aff->email, ___('Unassign Affiliate'), $is_expired ? sprintf('<div class="red">%s</div>', ___('affiliate <-> user relation is expired (%saccording your settings%s <strong>User-Affiliate Relation Lifetime</strong> is %d day(s)), no commissions will be added for new payments', '<a href="' . REL_ROOT_URL . '/admin-setup/aff">', '</a>', $commissionDays)) : '');
                $affGroup->addStatic()->setContent($affHtml);
                $affGroup->addScript()->setScript(<<<CUT
\$('#aff-unassign-affiliate').click(function(){
    \$(this).closest('div').remove();
    \$('#aff-refered-affiliate').val('');
    \$('#aff-refered-affiliate').show();
})
CUT
);
            } catch (Am_Exception $e) {
                // ignore if affiliate was deleted
            }
        }
        if ($user->isLoaded() && ($source = $user->data()->get('aff-source'))) {
            preg_match('/^([a-z]*)(-(.*))?$/i', $source, $match);
            $res = '';
            switch ($match[1]) {
                case 'ip':
                    $res = ___('Assigned by IP <strong>%s</strong> at %s', $match[3], amDatetime($user->aff_added));
                    break;
                case 'cookie':
                    $res = ___('Assigned by COOKIE at %s', amDatetime($user->aff_added));
                    break;
                case 'admin':
                    $admin = $this->getDi()->adminTable->load($match[3], false);
                    $res = ___('Assigned by Administrator <strong>%s</strong> at %s', $admin ? sprintf('%s (%s %s)', $admin->login, $admin->name_f, $admin->name_l) : '#' . $match[3], amDatetime($user->aff_added));
                    break;
                case 'coupon':
                    $res = ___('Assigned by Coupon %s at %s', '<a href="' . REL_ROOT_URL . '/admin-coupons?_coupon_filter=' . urlencode($match[3]) . '">' . $match[3] . '</a>', amDatetime($user->aff_added));
                    break;
                case 'invoice':
                    $invoice = $this->getDi()->invoiceTable->load($match[3], false);
                    $res = ___('Assigned by Invoice %s at %s', $invoice ? '<a href="' . REL_ROOT_URL . '/admin-user-payments/index/user_id/' . $invoice->user_id . '#invoice-' . $invoice->pk() . '">' . $invoice->pk() . '/' . $invoice->public_id . '</a>' : '<strong>#' . $match[3] . '</strong>', amDatetime($user->aff_added));
                    break;
                default:
                    $res = $source;
            }
            $fieldSet->addHtml()->setLabel(___('Affiliate Source'))->setHtml('<div>' . $res . '</div>');
        }
        $fieldSet->addElement('advradio', 'is_affiliate')->setLabel(___("Is Affiliate?\n" . 'customer / affiliate status'))->loadOptions(array('0' => ___('No'), '1' => ___('Both Affiliate and member'), '2' => ___('Only Affiliate %s(rarely used)%s', '<em>', '</em>')))->setValue($this->getConfig('signup_type') == 1 ? 1 : 0);
        if ($cr = $this->getConfig('custom_redirect')) {
            $fieldSet->addElement('advradio', 'aff_custom_redirect')->setLabel(___('Allow Affiliate to redirect Referrers to any url'))->loadOptions(array('0' => $cr == self::AFF_CUSTOM_REDIRECT_ALLOW_SOME_DENY_OTHERS ? ___('No') : ___('Yes'), '1' => $cr == self::AFF_CUSTOM_REDIRECT_DENY_SOME_ALLOW_OTHERS ? ___('No') : ___('Yes')));
        }
        $this->addPayoutInputs($fieldSet);
    }
Exemplo n.º 5
0
 function onGridProductInitForm(Am_Event_Grid $event)
 {
     $fs = $event->getGrid()->getForm()->getAdditionalFieldSet();
     $fs->addInteger('subusers_count')->setLabel(___("SubUsers Count\n" . "(keep zero for non-reseller products)"));
     $fs->addSelect('subusers_product_id')->setLabel(___("SubUsers Product\n" . "(keep empty for non-reseller products)"))->loadOptions(array('' => '-- ' . ___('Please select') . ' --') + $this->getDi()->productTable->getOptions());
 }
Exemplo n.º 6
0
 function onGridProductInitForm(Am_Event_Grid $event)
 {
     $fs = $event->getGrid()->getForm()->getAdditionalFieldSet();
     $fs->addInteger('subusers_count')->setLabel(___("SubUsers Count\n" . "(keep zero for non-reseller products)"));
     $options = array('' => '-- ' . ___('Please select') . ' --');
     foreach ($this->getDi()->db->selectCol("SELECT product_id AS ARRAY_KEY, title FROM ?_product") as $k => $v) {
         $options[$k] = $v;
     }
     $fs->addSelect('subusers_product_id')->setLabel(___("SubUsers Product\n" . "(keep empty for non-reseller products)"))->loadOptions($options);
 }
Exemplo n.º 7
0
Arquivo: Tax.php Projeto: grlf/eyedock
 function onGridUserInitForm(Am_Event_Grid $event)
 {
     $form = $event->getGrid()->getForm();
     $user = $event->getGrid()->getRecord();
     $address_fieldset = $form->getElementById('address_info');
     $tax_id_el = new HTML_QuickForm2_Element_InputText('tax_id');
     $tax_id_el->setLabel(___('Tax Id'));
     $form->insertBefore($tax_id_el, $address_fieldset);
 }