Example #1
0
    /**
     * @param desingAdd object provide ad data information
     * @return
     * */
    function sendForApproval($desingAdd)
    {
        $return['sa_sentApproveMail'] = '';
        if (empty($desingAdd)) {
            return $return;
        }
        $db = JFactory::getDBO();
        // 1. check whether any order  is confirmed
        $query = 'SELECT p.`id` FROM `#__ad_payment_info` as p
				WHERE p.ad_id=' . $desingAdd->ad_id . ' AND p.`status`=\'C\' ORDER BY `id` DESC';
        $db->setQuery($query);
        $ConfirmOrders = $db->loadResult();
        if (empty($ConfirmOrders)) {
            // no order is confirm then allow to edit ad
            return $return;
        }
        // get old ad details
        $query = 'SELECT a.`ad_id`,a.`ad_image`,a.`ad_title`,a.`ad_body`,a.`ad_url2` FROM `#__ad_data` as a
				WHERE a.ad_id=' . $desingAdd->ad_id . '  AND a.ad_approved=1';
        $db->setQuery($query);
        $oldAd = $db->loadObject();
        // ANY ONE IS CHANGED
        if (!empty($oldAd) && ($oldAd->ad_image != $desingAdd->ad_image || $oldAd->ad_title != $desingAdd->ad_title || $oldAd->ad_body != $desingAdd->ad_body || $oldAd->ad_url2 != $desingAdd->ad_url2)) {
            $createAdHelper = new createAdHelper();
            $createAdHelper->adminAdApprovalEmail($desingAdd->ad_id);
            $return['ad_approved'] = 0;
            $return['sa_sentApproveMail'] = 1;
            return $return;
        }
        return $return;
    }
Example #2
0
 function getUserCampaign()
 {
     $input = JFactory::getApplication()->input;
     $userid = $input->get('userid');
     $createAdHelper = new createAdHelper();
     $campaigns = $createAdHelper->getUserCampaign($userid);
     echo json_encode($campaigns);
     jexit();
 }
Example #3
0
 function activateAd()
 {
     $session = JFactory::getSession();
     $db = JFactory::getDBO();
     $ad_id = $session->get('ad_id');
     $obj = new stdclass();
     $obj->ad_id = $ad_id;
     $obj->ad_published = 1;
     if (!$db->updateObject('#__ad_data', $obj, 'ad_id')) {
         echo $this->_db->stderr();
         return 0;
     }
     // vm: send admin approve mail for new ad
     require JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_socialads" . DS . "config" . DS . "config.php";
     if ($socialads_config['approval'] == 1) {
         $createAdHelper = new createAdHelper();
         $createAdHelper->adminAdApprovalEmail($ad_id);
     }
     // vm:end
     return true;
 }
Example #4
0
 function autoSave()
 {
     $mainframe = JFactory::getApplication();
     $input = JFactory::getApplication()->input;
     $session = JFactory::getSession();
     $post = $input->post;
     $model = $this->getModel('buildad');
     $stepId = $input->get('stepId', '', 'STRING');
     $retdata = array();
     $retdata['stepId'] = $stepId;
     $retdata['payAndReviewHtml'] = '';
     $retdata['adPreviewHtml'] = '';
     $retdata['camp_id'] = '';
     $retdata['sa_sentApproveMail'] = '';
     $socialadshelper = new socialadshelper();
     $Itemid = $socialadshelper->getSocialadsItemid('managead');
     $retdata['Itemid'] = $Itemid;
     // Save step-1 : design ad data
     if ($stepId == 'ad-design') {
         $user = JFactory::getUser();
         $adminApproval = 0;
         if (isset($user->groups['8']) || isset($user->groups['7']) || isset($user->groups['Super Users']) || isset($user->groups['Administrator']) || $user->usertype == "Super Users" || isset($user->groups['Super Users']) || isset($user->groups['Administrator']) || $user->usertype == "Super Administrator" || $user->usertype == "Administrator") {
             $adminApproval = 1;
         }
         $model = $this->getModel('buildad');
         $response = $model->saveDesignAd($post, $adminApproval);
         // vm:start
         if ($response && $response['sa_sentApproveMail']) {
             $retdata['sa_sentApproveMail'] = $response['sa_sentApproveMail'];
         } else {
             if ($response === false) {
                 return false;
             }
         }
         // vm:end
     }
     // Save step-2 : targeting ad data
     if ($stepId == 'ad-targeting') {
         $model = $this->getModel('buildad');
         $response = $model->saveTargetingData($post);
         if ($response === false) {
             return false;
         }
     }
     // Save ad pricing data
     if ($stepId == 'ad-pricing') {
         $response = $model->savePricingData($post);
         if (isset($response['camp_id'])) {
             $retdata['camp_id'] = $response['camp_id'];
         }
         if ($response === false) {
             return false;
         }
     }
     // VM:
     // if billing tab is hide
     $sa_hide_billTab = $input->get('sa_hide_billTab', 0);
     // if 0 means billing details are not saved
     if (!empty($sa_hide_billTab) && $stepId == 'ad-pricing' || $stepId == 'ad-billing') {
         $user = JFactory::getUser();
         $ad_id = $session->get('ad_id');
         $createAdHelper = new createAdHelper();
         $order_id = $createAdHelper->getLatestPendigOrder($ad_id, $user->id);
         $billdata = $post->get('bill', array(), "ARRAY");
         // save billing detail
         if (!empty($billdata)) {
             $model->billingaddr($user->id, $billdata);
         }
         $showBillLink = $sa_hide_billTab;
         $billpath = $socialadshelper->getViewpath('buildad', 'default_adsummary');
         ob_start();
         include $billpath;
         $html = ob_get_contents();
         ob_end_clean();
         $retdata['payAndReviewHtml'] = $html;
     }
     // VM: end
     // Start :-> Amol
     //If campaign is selected then get ad preview html
     if ($stepId == 'ad-pricing') {
         $ad_id = $session->get('ad_id');
         $AdPreviewData = $model->getAdPreviewData($ad_id);
         $path = $socialadshelper->getViewpath('buildad', 'default_showadscamp');
         ob_start();
         include $path;
         $html = ob_get_contents();
         ob_end_clean();
         $retdata['adPreviewHtml'] = $html;
     }
     // end :-> Amol
     echo json_encode($retdata);
     jexit();
 }