Beispiel #1
0
 public function __construct($affiliateId)
 {
     parent::__construct();
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $affiliate = $service->findAffiliateById($affiliateId);
     if (!$affiliate) {
         $this->setVisible(false);
         return;
     }
     $billingService = BOL_BillingService::getInstance();
     $this->assign('currency', $billingService->getActiveCurrency());
     $clicksCount = $service->countClicksForAffiliate($affiliateId);
     $this->assign('clicksCount', $clicksCount);
     $signupCount = $service->countRegistrationsForAffiliate($affiliateId);
     $this->assign('signupCount', $signupCount);
     $salesCount = $service->countSalesForAffiliate($affiliateId);
     $this->assign('salesCount', $salesCount);
     $clicksSum = $service->getClicksSumForAffiliate($affiliateId);
     $this->assign('clicksSum', $clicksSum);
     $signupSum = $service->getRegistrationsSumForAffiliate($affiliateId);
     $this->assign('signupSum', $signupSum);
     $salesSum = $service->getSalesSumForAffiliate($affiliateId);
     $this->assign('salesSum', $salesSum);
     $earnings = $clicksSum + $signupSum + $salesSum;
     $this->assign('earnings', $earnings);
     $payouts = $service->getPayoutSum($affiliateId);
     $this->assign('payouts', $payouts);
     $balance = $earnings - $payouts;
     $this->assign('balance', $balance);
     $this->assign('affiliate', $affiliate);
 }
Beispiel #2
0
 public function __construct($affiliateId, $adminMode = false)
 {
     parent::__construct();
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $affiliate = $service->findAffiliateById($affiliateId);
     if (!$affiliate) {
         $this->setVisible(false);
         return;
     }
     $this->assign('affiliate', $affiliate);
     $this->assign('adminMode', $adminMode);
     $this->assign('creditsEnabled', OW::getPluginManager()->isPluginActive('usercredits'));
     if ($adminMode) {
         $this->assign('assoc', $service->getAffiliateAssocUser($affiliateId));
         $script = '$("#assign-assoc").click(function(){
             assignUserFloatBox = OW.ajaxFloatBox(
                 "OCSAFFILIATES_CMP_AssignUser",
                 { affiliateId: ' . $affiliateId . ' },
                 { width: 500, title: ' . json_encode(OW::getLanguage()->text('ocsaffiliates', 'assign')) . ' }
             );
         });
         ';
         OW::getDocument()->addOnloadScript($script);
     }
 }
Beispiel #3
0
 public function onUserUnregister(OW_Event $event)
 {
     $params = $event->getParams();
     $userId = $params['userId'];
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $service->deleteAffiliateUserByUserId($userId);
 }
Beispiel #4
0
 public function __construct($affiliateId)
 {
     parent::__construct();
     $form = new OCSAFFILIATES_CLASS_RegisterPayoutForm('register_payout', $affiliateId);
     $form->getElement('affiliateId')->setValue($affiliateId);
     $assoc = OCSAFFILIATES_BOL_Service::getInstance()->getAffiliateAssocUser($affiliateId);
     $this->assign('assocUser', $assoc);
     $creditsOption = OW::getPluginManager()->isPluginActive('usercredits') && $assoc;
     $this->assign('creditsOption', $creditsOption);
     $this->addForm($form);
 }
Beispiel #5
0
 public function __construct($affiliateId, $adminMode = false)
 {
     parent::__construct();
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $affiliate = $service->findAffiliateById($affiliateId);
     if (!$affiliate) {
         $this->setVisible(false);
         return;
     }
     $this->assign('payoutList', $service->getPayoutListForAffiliate($affiliateId));
     $billingService = BOL_BillingService::getInstance();
     $this->assign('currency', $billingService->getActiveCurrency());
     $this->assign('adminMode', $adminMode);
 }
Beispiel #6
0
 public function __construct($affiliateId, $mode = 'owner')
 {
     parent::__construct();
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $this->assign('mode', $mode);
     $form = new OCSAFFILIATES_CLASS_EditForm('affiliate-edit', $mode);
     $this->addForm($form);
     $affiliate = $service->findAffiliateById($affiliateId);
     $form->getElement('affiliateId')->setValue($affiliateId);
     $form->getElement('name')->setValue($affiliate->name);
     $form->getElement('email')->setValue($affiliate->email);
     $form->getElement('payment')->setValue($affiliate->paymentDetails);
     if ($mode == 'admin') {
         $form->getElement('emailVerified')->setValue($affiliate->emailVerified);
         $form->getElement('status')->setValue($affiliate->status);
     }
 }
Beispiel #7
0
 public function delete()
 {
     if (!OW::getRequest()->isAjax()) {
         exit(json_encode(array('result' => false)));
     }
     if (!OW::getUser()->isAdmin()) {
         exit(json_encode(array('result' => false)));
     }
     if (empty($_POST['affiliateId'])) {
         exit(json_encode(array('result' => false)));
     }
     $affiliateId = (int) $_POST['affiliateId'];
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     if (!($affiliate = $service->findAffiliateById($affiliateId))) {
         exit(json_encode(array('result' => false)));
     }
     $service->deleteAffiliate($affiliateId);
     OW::getFeedback()->info(OW::getLanguage()->text('ocsaffiliates', 'affiliate_removed'));
     exit(json_encode(array('result' => true)));
 }
Beispiel #8
0
 /**
  * Returns an instance of class
  *
  * @return OCSAFFILIATES_BOL_Service
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Beispiel #9
0
 public function expireResetPasswords()
 {
     $this->service->deleteExpiredResetPasswordCodes();
 }
Beispiel #10
0
 public function banners()
 {
     $this->addComponent('menu', $this->getMenu('banners'));
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     OW::getDocument()->setHeading($lang->text('ocsaffiliates', 'admin_page_heading'));
     if (isset($_POST['action']) && $_POST['action'] == 'add_banner') {
         if (empty($_FILES['banner_file']) || !$service->validateBannerFileType($_FILES['banner_file'])) {
             OW::getFeedback()->error($lang->text('ocsaffiliates', 'banner_file_incorrect'));
         }
         $added = $service->addAffiliateBanner(0, $_FILES['banner_file']);
         if ($added) {
             OW::getFeedback()->info($lang->text('ocsaffiliates', 'banner_added'));
         } else {
             OW::getFeedback()->error($lang->text('ocsaffiliates', 'banner_add_error'));
         }
         $this->redirect();
     }
     $this->assign('bannerList', $service->getBannerListForAffiliate(0));
     $script = '$(".action_delete_banner").click(function(){
             var bannerId = $(this).attr("bid");
             if ( confirm(' . json_encode($lang->text('ocsaffiliates', 'banner_delete_confirm')) . ') )
         {
             $.ajax({
                 url: ' . json_encode(OW::getRouter()->urlForRoute('ocsaffiliates.action_delete_banner')) . ',
                 type: "POST",
                 data: { bannerId: bannerId },
                 dataType: "json",
                 success: function(data)
                 {
                     if ( data.result == true )
                     {
                         document.location.reload();
                     }
                     else if ( data.error != undefined )
                     {
                         OW.warning(data.error);
                     }
                 }
             });
         }
     });
     ';
     OW::getDocument()->addOnloadScript($script);
 }
Beispiel #11
0
 public function logout()
 {
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $homeUrl = OW::getRouter()->urlForRoute('ocsaffiliates.home');
     if (!$service->isAuthenticated()) {
         $this->redirect($homeUrl);
     }
     $service->logoutAffiliate();
     $this->redirect($homeUrl);
 }