function altadupdate() { $input = JFactory::getApplication()->input; $model = $this->getModel('managead'); $ad_id = $input->get('adid', 0, 'INT'); if ($model->altUpdate()) { $sacontroller = new socialadsController(); $sacontroller->execute('delimages'); $msg = JText::_('UPDATE'); } else { $msg = JText::_('ERROR'); } $itemid = socialadshelper::getSocialadsItemid('managead'); $link = JRoute::_("index.php?option=com_socialads&view=managead&Itemid={$itemid}", false); $this->setRedirect($link, $msg); }
function __construct() { parent::__construct(); // Register Extra tasks $this->registerTask('add', 'edit'); }
function saveUnlimitedAd() { $model = $this->getModel('buildad'); $status = $model->storeUnlimiteAd(); if ($status) { $sacontroller = new socialadsController(); $sacontroller->execute('delimages'); $msg = JText::_('DETAILS_SAVE'); $socialadshelper = new socialadshelper(); $itemid = $socialadshelper->getSocialadsItemid('managead'); $link = JRoute::_("index.php?option=com_socialads&view=managead&layout=list&Itemid={$itemid}", false); $this->setRedirect($link, $msg); } else { $msg = JText::_('ERROR_SAVE'); } }
function makepayment() { $input = JFactory::getApplication()->input; //$post=$input->post; //$input->get //$data = JRequest::get( 'post' ); $cop = $input->get('cop', '', 'STRING') ? $input->get('cop', '', 'STRING') : ''; $arb_flag = $input->get('arb_flag') ? $input->get('arb_flag') : 0; require JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_socialads" . DS . "config" . DS . "config.php"; $model = $this->getModel('showad'); $buildadsession = JFactory::getSession(); $data = JRequest::get('post'); if (!empty($arb_flag) and $arb_flag == 1) { $buildadsession->set('arb_flag', 1); } $amount = $buildadsession->get('totalamount'); $amt = $amount; //interchange amt and cop_amt $cop_dis_opn_hide = $input->get('cop_dis_opn_hide', '', 'INT'); JRequest::setVar('coupon_code', $cop); $model = $this->getModel('showad'); $adcop = ''; if ($cop_dis_opn_hide == 0) { $adcop = $model->getcoupon(); if ($adcop) { if ($adcop[0]->val_type == 1) { //discount rate $val = $adcop[0]->value / 100 * $buildadsession->get('totalamount'); } else { $val = $adcop[0]->value; } } else { $val = 0; } $amt = round($buildadsession->get('totalamount') - $val, 2); // if ($adcop) { if ($adcop[0]->val_type == 1) { //discount rate $valchrg = $adcop[0]->value / 100 * $buildadsession->get('sa_ad_totalamount'); } else { $valchrg = $adcop[0]->value; } } else { $valchrg = 0; } $amtchrg = round($buildadsession->get('sa_ad_totalamount') - $valchrg, 2); // } if ($amt <= 0) { $amt = 0; } $temp = $buildadsession->get('totalamount'); $buildadsession->set('totalamount', $amt); $buildadsession->set('orgi_totalamount', $temp); if (!$buildadsession->get('ad_id')) { $adid = $model->store(); } else { $adid = $buildadsession->get('ad_id'); } if ($adid) { $sacontroller = new socialadsController(); $sacontroller->execute('delimages'); $msg = JText::_('DETAILS_SAVE'); if ($socialads_config['approval'] == 1) { $msg .= '<br>' . JText::_('AD_REVIEW'); } $user = JFactory::getUser(); $option = $buildadsession->get('ad_gateway'); JPluginHelper::importPlugin('socialads', $option); $dispatcher = JDispatcher::getInstance(); $ad_chargeoption = $buildadsession->get('ad_chargeoption'); if ($ad_chargeoption >= 2) { $credits = $buildadsession->get('ad_totaldays', ''); } else { $credits = $buildadsession->get('ad_totaldisplay'); } $buildadsession->set('credits', $credits); $buildadsession->set('cop', $cop); $paymentdata = new stdClass(); if ($amt <= 0 && $adcop) { $db = JFactory::getDBO(); //TODO ad payment for date type ads //added for date type ads $query = "SELECT ad_payment_type FROM #__ad_data WHERE ad_id =" . $adid; $db->setQuery($query); $ad_payment_type = $db->loadResult(); if ($ad_payment_type != 2) { $query = "UPDATE #__ad_data SET ad_credits = ad_credits + {$credits}, ad_credits_balance = {$credits} WHERE ad_id=" . $adid; $db->setQuery($query); $db->execute(); } else { if ($ad_payment_type >= 2) { socialadshelper::adddays($adid, $credits); } } $paymentdata->id = ''; $paymentdata->ad_id = $adid; $paymentdata->cdate = date('Y-m-d H:i:s'); $paymentdata->processor = $buildadsession->get('ad_gateway'); if ($ad_chargeoption >= 2) { $credits = $buildadsession->get('ad_totaldays', ''); } $paymentdata->ad_credits_qty = $credits; $paymentdata->ad_amount = $buildadsession->get('totalamount'); $paymentdata->ad_original_amt = $buildadsession->get('orgi_totalamount'); $paymentdata->status = 'C'; $paymentdata->ad_coupon = $cop; $paymentdata->payee_id = $user->id; $paymentdata->ip_address = $_SERVER["REMOTE_ADDR"]; if (!$db->insertObject('#__ad_payment_info', $paymentdata, 'id')) { echo $db->stderr(); return false; } echo "<div class='coupon_discount_all'> </div>"; jexit(); } else { if ($buildadsession->get('ad_chargeoption') > 2 and $buildadsession->get('arb_flag') != 1) { $credits = $buildadsession->get('ad_chargeoption') * $credits; } else { if ($buildadsession->get('ad_chargeoption') > 2 and $buildadsession->get('arb_flag') == 1) { $credits = $buildadsession->get('ad_chargeoption'); $paymentdata->extras = 'occurrences=' . $credits; } } $payment_type = $recurring_startdate = ""; if ($arb_flag == 1 and $ad_chargeoption > 2) { $payment_type = "recurring"; $recurring_startdate = $startDate = $buildadsession->get('datefrom', ''); } $success_msg = ''; $totalamt = $buildadsession->get('totalamount'); if ($option == 'jomsocialpoints' or $option == 'alphauserpoints') { $plugin = JPluginHelper::getPlugin('payment', $buildadsession->get('ad_gateway')); $pluginParams = json_decode($plugin->params); if (isset($pluginParams->conversion)) { $totalamt = $buildadsession->get('totalamount') / $pluginParams->conversion; } $success_msg = JText::sprintf('TOTAL_POINTS_DEDUCTED_MESSAGE', $buildadsession->get('totalamount')); } $paymentdata->extras = 'occurrences=' . $credits; $orderdata = array('payment_type' => $payment_type, 'order_id' => '', 'pg_plugin' => $option, 'user' => $user, 'adid' => $adid, 'amount' => $totalamt, 'original_amount' => $buildadsession->get('orgi_totalamount'), 'coupon' => $cop, 'credits' => $credits, 'recurring_startdate' => $recurring_startdate, 'recurring_payment_interval_length' => $buildadsession->get('ad_chargeoption', ''), 'recurring_payment_interval_totaloccurances' => $buildadsession->get('ad_totaldays', ''), 'success_message' => $success_msg); //Here orderid is id in payment_info table $orderid = $model->createorder($orderdata); if (!$orderid) { echo $msg = JText::_('ERROR_SAVE'); exit; } $orderdata['order_id'] = $orderid; $html = $this->getHTML($orderdata); if (!empty($html)) { echo $html; } jexit(); } } else { $msg = JText::_('ERROR_SAVE'); } }
function __construct() { parent::__construct(); }
function sa_applycoupon() { $user = JFactory::getUser(); $socialadsController = new socialadsController(); $input = JFactory::getApplication()->input; //$post=$input->post; //$input->get $c_code = $input->get('coupon_code', '', 'STRING'); $data = $socialadsController->getcoupon($c_code); $count = ''; $model = $this->getModel('showad'); $count = $model->getcoupon(); if ($count) { $c[] = array("value" => $count[0]->value, "val_type" => $count[0]->val_type); echo json_encode($c); } else { echo 0; } jexit(); }