コード例 #1
0
ファイル: default.php プロジェクト: politik86/test2
    $package_id = $camp->otid;
    $order_details = $this->getOrderDetails($camp->id, $package_id);
    ?>
          
            <div class="uk-button-dropdown">
              <button class="uk-button uk-button-small dropdown-toggle" data-toggle="dropdown">
                <?php 
    echo JText::_("VIEWADACTION");
    ?>
                <span class="uk-icon-caret-down"></span>
              </button>
              <ul class="dropdown-menu">
                
              <?php 
    $hide_after = 0;
    $helpvar2 = new adagencyModeladagencyCampaigns();
    $rows = $helpvar2->getlistPackages();
    foreach ($rows as $key => $element) {
        if ($element->tid == $package_id) {
            $hide_after = $element->hide_after;
            break;
        }
    }
    if ($expired == 0) {
        ?>
                <li><?php 
        echo '<a href="' . $link . '">' . JText::_("AD_EDIT") . '</a>';
        ?>
</li>
                <?php 
        $offset = JFactory::getApplication()->getCfg('offset');
コード例 #2
0
ファイル: view.html.php プロジェクト: politik86/test2
 function editForm($tpl = null)
 {
     $database = JFactory::getDBO();
     $helper = new adagencyModeladagencyCampaigns();
     $helperview = new adagencyViewadagencyCampaigns();
     $data = JRequest::get('request');
     $camp = $this->get('Campaign');
     $isNew = $camp->id < 1;
     $text = $isNew ? JText::_('ADG_NEW') : JText::_('ADG_EDIT');
     $pid_pst = JRequest::getInt('pid');
     $task = $isNew ? "new" : "edit";
     $configs = $this->_models['adagencyconfig']->getConfigs();
     $advertiser = $this->get('CurrentAdvertiser');
     $JApp = JFactory::getApplication();
     $offset = JFactory::getApplication()->getCfg('offset');
     $jnow = JFactory::getDate('now', $offset);
     $itemid = $this->getModel("adagencyConfig")->getItemid('adagencycampaigns');
     if (isset($advertiser->aid) && $advertiser->aid > 0) {
         $count_total_banners = $helper->getCountBannersPerAdv($advertiser->aid);
     } else {
         $count_total_banners = 0;
     }
     $configs->params = @unserialize($configs->params);
     $configs->payment = @unserialize($configs->payment);
     $advertiser_id = (int) $advertiser->aid;
     $permission = $helper->getPermForAdv($camp->id, $advertiser_id);
     if ($permission == false) {
         global $mainframe;
         $mainframe->redirect("index.php?option=com_adagency");
     }
     $currencydef = trim($configs->currencydef, " ");
     if ($isNew) {
         $rows = $helper->getlistPackages();
         foreach ($rows as $element) {
             if ($element->cost != '0.00') {
                 $currency_price = 0;
                 if (isset($configs->params["currency_price"])) {
                     $currency_price = $configs->params["currency_price"];
                 }
                 if ($currency_price == 0) {
                     $element->description .= ' - ' . JText::_('ADAG_C_' . trim($currencydef)) . $element->cost;
                 } else {
                     $element->description .= ' - ' . $element->cost . JText::_('ADAG_C_' . trim($currencydef));
                 }
             } else {
                 $element->description .= ' - ' . JText::_('VIEWPACKAGEFREE');
             }
         }
     } else {
         $rows = $helper->getAllPacks();
     }
     if (!is_array($rows)) {
         $rows = array();
     }
     $javascript = ' onchange="submitbutton(\'refresh\')" ';
     $packagess[] = JHTML::_('select.option', "0", JText::_('ADAG_SEL_PACK'), 'tid', 'description');
     $packagess = array_merge($packagess, $rows);
     if (isset($data['otid'])) {
         $pid_pst = $data['otid'];
     } elseif (JRequest::getInt('ren_id', '0', 'get') != 0) {
         $pid_pst = JRequest::getInt('ren_id', '0', 'get');
     }
     $remove_action = JRequest::getVar("remove_action", "");
     if ($remove_action == "") {
         $lists['package'] = JHTML::_('select.genericlist', $packagess, 'otid', 'class="inputbox" size="1"' . $javascript, 'tid', 'description', $pid_pst);
     } else {
         foreach ($packagess as $key => $element) {
             if ($element->tid == $pid_pst) {
                 $lists['package'] = $element->description;
                 break;
             }
         }
     }
     for ($i = 0, $n = count($rows); $i < $n; $i++) {
         $row =& $rows[$i];
         if ($row->tid == $camp->otid) {
             $package_row = $row;
         }
     }
     $get_jreq_id = JRequest::getInt('id');
     if ($advertiser_id > 0) {
         $camp->aid = $advertiser_id;
     }
     $creat = false;
     if (!$camp->aid) {
         if (isset($get_jreq_id) && $get_jreq_id != 0) {
             $camp = $this->get('Campaign');
             $camp->aid = $advertiser_id;
         } else {
             $camp->aid = 0;
             $camp->start_date = $jnow->toSql(true);
             //$camp->start_date = date( 'Y-m-d H:i:s', time() );
         }
         $creat = true;
     } else {
         $advertiser_id = $camp->aid;
     }
     $javascript = 'onchange="submitbutton(\'edit\');"';
     $advertisers[] = JHTML::_('select.option', "0", JText::_('select advertiser'), 'aid', 'company');
     $advertisersloaded = $helper->getcmplistAdvertisers();
     if (!is_array($advertisersloaded)) {
         $advertisersloaded = array();
     }
     $advertisers = array_merge($advertisers, $advertisersloaded);
     $lists['advertiser_id'] = JHTML::_('select.genericlist', $advertisers, 'aid', 'class="inputbox" size="1"' . $javascript, 'aid', 'company', $advertiser_id);
     $lists['approved'] = JHTML::_('select.booleanlist', 'approved', '', $camp->approved);
     if (!isset($package_row)) {
         @($package_row->type = '');
         $types2 = NULL;
     } else {
         $package_row->allzones = $this->_models['adagencycampaigns']->getZonesForPack($package_row->tid);
         if (is_array($package_row->allzones)) {
             $types = array();
             foreach ($package_row->allzones as $element) {
                 $b_with_size = false;
                 $element->adparams = @unserialize($element->adparams);
                 $types = array("'a'", "'b'");
                 if (isset($element->adparams) && is_array($element->adparams)) {
                     foreach ($element->adparams as $key => $value) {
                         if ($key == 'affiliate') {
                             $types[] = "'Advanced'";
                             $b_with_size = true;
                         }
                         if ($key == 'textad') {
                             $types[] = "'TextLink'";
                         }
                         if ($key == 'standard') {
                             $types[] = "'Standard'";
                             $b_with_size = true;
                         }
                         if ($key == 'flash') {
                             $types[] = "'Flash'";
                             $b_with_size = true;
                         }
                         if ($key == 'popup') {
                             $types[] = "'Popup'";
                         }
                         if ($key == 'transition') {
                             $types[] = "'Transition'";
                         }
                         if ($key == 'floating') {
                             $types[] = "'Floating'";
                         }
                     }
                     $types[] = "'Jomsocial'";
                     if ($b_with_size == true) {
                         if (isset($element->adparams['width']) && $element->adparams['width'] != '') {
                             $with_size = " AND b.width ='" . $element->adparams['width'] . "' AND b.height='" . $element->adparams['height'] . "'";
                         } else {
                             $with_size = NULL;
                         }
                     } else {
                         $with_size = NULL;
                     }
                     $types2[] = "(b.media_type IN (" . implode(',', $types) . ")" . $with_size . ")";
                 }
             }
             if (isset($types2) && count($types2) > 0) {
                 $types2 = " AND (" . implode(" OR ", $types2) . ")";
             } else {
                 $types2 = "";
             }
         }
     }
     if ($package_row->type == "cpm") {
         $package_row->details = $package_row->quantity . "&nbsp;" . JText::_("AD_CAMP_IMP");
     }
     if ($package_row->type == "pc") {
         $package_row->details = $package_row->quantity . "&nbsp;" . JText::_("AD_CAMP_CLK");
     }
     if ($package_row->type == "fr" || $package_row->type == "in") {
         $tmp_validity = explode("|", $package_row->validity, 2);
         $package_row->details = $tmp_validity[0] . " " . JText::_("ADAG_" . strtoupper($tmp_validity[1] . "s"));
         //$now_datetime = date("Y-m-d H:i:s");
         $now_datetime = $jnow->toSql(true);
         if ($now_datetime > $camp->start_date) {
             //CONTINUE
         } else {
             $now_datetime = $camp->start_date;
         }
         if ($now_datetime > $camp->validity) {
             $camp->expired = true;
         } else {
             $camp->expired = false;
             //get time difference as days, hours, mins
             $camp->time_left = $helperview->time_difference($now_datetime, $camp->validity);
         }
     }
     if ($creat) {
         if (isset($package_row->tid)) {
             $sql = "SELECT b.id, b.title, b.media_type, b.parameters, b.width, b.height , b.approved, '0' as relative_weighting FROM #__ad_agency_banners AS b WHERE b.approved <>'N' AND b.advertiser_id=" . intval($camp->aid) . " " . $types2;
             $database->setQuery($sql);
             $ban_row = $database->loadObjectList();
         } else {
             $ban_row = NULL;
         }
     } else {
         if (isset($package_row->tid)) {
             $sql = "SELECT id, title, media_type, parameters, width, height , approved, '0' AS relative_weighting\n                        FROM #__ad_agency_banners AS b WHERE b.advertiser_id=" . intval($camp->aid) . " " . $types2;
             $database->setQuery($sql);
             $ban_row = $database->loadObjectList();
         } else {
             $ban_row = NULL;
         }
     }
     if (isset($ban_row) && isset($package_row->allzones)) {
         $ban_row = $this->_models['adagencycampaigns']->updateMediaType($ban_row);
         $ban_row = $this->_models['adagencycampaigns']->updateZoneList($ban_row, $package_row->allzones, $camp->id);
     }
     for ($i = 0, $n = count($ban_row); $i < $n; $i++) {
         $ban_row[$i]->parameters = unserialize($ban_row[$i]->parameters);
         if ($ban_row[$i]->media_type == "Popup" && $ban_row[$i]->parameters['popup_type'] == "webpage") {
             $ban_row[$i]->display = "no";
         } elseif ($ban_row[$i]->media_type == "Transition" || $ban_row[$i]->media_type == "Floating" || $ban_row[$i]->media_type == "Advanced" || $ban_row[$i]->media_type == "Popup" && $ban_row[$i]->parameters['popup_type'] == "HTML") {
             if (@preg_match("/ad_url/", $ban_row[$i]->parameters['ad_code'])) {
                 $ban_row[$i]->display = "yes";
             } else {
                 $ban_row[$i]->display = "no";
             }
         } else {
             $ban_row[$i]->display = "yes";
         }
         //unset($ban_row[$i]->parameters);
     }
     if (!$creat) {
         //SHOW STATS REPORT
         $camp->id = (int) $camp->id;
         $stats = array();
         $sql = "select * from #__ad_agency_statistics where `impressions` like '%\"advertiser_id\":" . intval($camp->aid) . ",%' OR `impressions` like '%\"advertiser_id\":\"" . intval($camp->aid) . "\",%' OR `click` like '%\"advertiser_id\":" . intval($camp->aid) . ",%' OR `click` like '%\"advertiser_id\":\"" . intval($camp->aid) . "\",%' OR `impressions` like '%\"campaign_id\":" . intval($camp->id) . ",%' OR `impressions` like '%\"campaign_id\":\"" . intval($camp->id) . "\",%' OR `click` like '%\"campaign_id\":" . intval($camp->id) . ",%' OR `click` like '%\"campaign_id\":\"" . intval($camp->id) . "\",%'";
         $database->setQuery($sql);
         $database->query();
         $result = $database->loadAssocList();
         if (isset($result) && count($result) > 0) {
             $nr_imp = 0;
             $nr_click = 0;
             foreach ($result as $key => $value) {
                 $impressions = @json_decode($value["impressions"], true);
                 $click = @json_decode($value["click"], true);
                 if (isset($impressions) && count($impressions) > 0) {
                     foreach ($impressions as $key_imp => $value_imp) {
                         if (@$value_imp["advertiser_id"] == intval($camp->aid) && $value_imp["campaign_id"] == intval($camp->id)) {
                             $nr_imp += $value_imp["how_many"];
                         }
                     }
                 }
                 if (isset($click) && count($click) > 0) {
                     foreach ($click as $key_click => $value_click) {
                         if (@$value_click["advertiser_id"] == intval($camp->aid) && $value_click["campaign_id"] == intval($camp->id)) {
                             $nr_click += $value_click["how_many"];
                         }
                     }
                 }
             }
             $stats["impressions"] = $nr_imp;
             $stats["click"] = $nr_click;
             $nr = 0;
             if (intval($nr_imp) > 0) {
                 $nr = $nr_click / ($nr_imp / 100);
             }
             $stats["click_rate"] = number_format($nr, 2, '.', ' ');
         }
         //SHOW CAMPAIGN DURATION
         $now_datetime = $jnow->toSql(true);
         if ($camp->validity == "0000-00-00 00:00:00" || $now_datetime < $camp->validity || $camp->default == "Y") {
             //CONTINUE
         } else {
             $now_datetime = $camp->validity;
         }
         //get time difference as days, hours, mins
         $duration_stats = $helperview->time_difference($camp->start_date, $now_datetime);
         if (!is_array($duration_stats)) {
             $duration_stats = array();
         }
         if (!is_array($stats)) {
             $stats = array();
         }
         if (isset($duration_stats)) {
             $stats = array_merge($stats, $duration_stats);
         }
     }
     if (!isset($stats)) {
         $stats = '';
     }
     $pstatus = $this->_models['adagencycampaigns']->getApprSts($advertiser_id);
     $itemid_cpn = $this->getModel("adagencyConfig")->getItemid('adagencycpanel');
     $this->assign("itemid_cpn", $itemid_cpn);
     if (isset($camp->params)) {
         $camp->params = @unserialize($camp->params);
     }
     $camps_ads = $this->get('listCampsAds');
     $this->assign("itemid", $itemid);
     $this->assign("pstatus", $pstatus);
     $this->assign("camp", $camp);
     $this->assign("stats", $stats);
     $this->assign("package_row", $package_row);
     $this->assign("configs", $configs);
     $this->assign("lists", $lists);
     $this->assign("task", $task);
     $this->assign("text", $text);
     $this->assign("ban_row", $ban_row);
     $this->assign("count_total_banners", $count_total_banners);
     $this->assign("camps_ads", $camps_ads);
     parent::display($tpl);
 }