Esempio n. 1
0
 function store()
 {
     $data = JRequest::get('post');
     $id = $data['id'];
     $status = $data['status'];
     //require_once(JPATH_SITE.DS."components".DS."com_socialads".DS."helper.php");  // require when we call from backend
     $socialadshelper = new socialadshelper();
     if ($status == 'RF') {
         $query = "UPDATE #__ad_payment_info SET status ='RF' WHERE id =" . $id;
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             return 2;
         }
         $socialadshelper->new_pay_mail($id);
         return 3;
     } elseif ($status == 'E') {
         $query = "UPDATE #__ad_payment_info SET status ='E' WHERE id =" . $id;
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             return 2;
         }
         $socialadshelper->new_pay_mail($id);
         return 3;
     } elseif ($status == 'C') {
         $query = "SELECT * FROM #__ad_payment_info WHERE id =" . $id;
         $this->_db->setQuery($query);
         $result = $this->_db->loadObject();
         $query = "UPDATE #__ad_payment_info SET status ='C' WHERE id =" . $id;
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             return 2;
         }
         //entry for transaction table
         $query = "SELECT ad_id FROM #__ad_payment_info WHERE id = " . $id;
         $this->_db->setQuery($query);
         $ad = $this->_db->loadresult();
         JLoader::import('payment', JPATH_SITE . DS . 'components' . DS . 'com_socialads' . DS . 'models');
         $socialadsModelpayment = new socialadsModelpayment();
         if (empty($ad)) {
             // add wallet
             $comment = 'ADS_PAYMENT';
             $transc = $socialadsModelpayment->add_transc($result->ad_original_amt, $id, $comment);
             $sendmail = $socialadsModelpayment->SendOrderMAil($id, $data['search_gateway'], $payPerAd = 0);
         } else {
             // pay per ad
             $sendmail = $socialadsModelpayment->SendOrderMAil($id, $data['search_gateway'], $payPerAd = 1);
         }
         require_once JPATH_SITE . '/components/com_socialads/helper.php';
         $adid = $result->ad_id;
         $qryad = "SELECT ad_payment_type FROM #__ad_data WHERE ad_id =" . $adid;
         $this->_db->setQuery($qryad);
         $ad_payment_type = $this->_db->loadResult();
         if ($ad_payment_type != 2) {
             $query = "UPDATE #__ad_data SET ad_credits = ad_credits + {$result->ad_credits_qty}, ad_credits_balance = ad_credits_balance + {$result->ad_credits_qty} WHERE ad_id=" . $result->ad_id;
             $this->_db->setQuery($query);
             $this->_db->execute();
         }
         //added by sagar for date type ads
         if (empty($subscriptiondata[0]->subscription_id) and $ad_payment_type == 2) {
             socialadshelper::adddays($adid, $result->ad_credits_qty);
         }
         //added by sagar for date type ads
     } else {
         $query = "UPDATE #__ad_payment_info SET status ='P' WHERE id =" . $id;
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             return 2;
         }
     }
     return 1;
 }