Location: PHPKode > projects > MembersGear > membersgear/admin/admin_product_payment_option_m.php
<?php
require_once "../config/config.php";
require_once INCLUDE_DIR."/product_class.php";
require_once INCLUDE_DIR."/cannedemail_class.php"; 
require_once INCLUDE_DIR."/users_class.php";
if($_SERVER['REQUEST_METHOD']=="GET")
    $_SESSION[SESSION_PREFIX.'page_referrer']=$_SERVER['HTTP_REFERER'];
    $users = new users_class();
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can view products and thankyou page tracking')==false)
{
        Redirect('admin_nopermission.php',true);  
} 
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can manage products and thankyou page tracking')==false)
{
        Redirect('admin_nopermission.php',true);     
} 
$product=new  product_class();

//$_SESSION[SESSION_PREFIX.'chkrecurring']=1;
//$_SESSION[SESSION_PREFIX.'paygear_productpaymentoptionid']=283;
//$_SESSION[SESSION_PREFIX.'productname']="Affiliate commision";
//$_SESSION[SESSION_PREFIX.'productprice']=100.0000;
//$_SESSION[SESSION_PREFIX.'paygear_productid']=255; 

    //  $lapaygearprodpayoptioncommisiondatainfo=$PaygearWebserviceClient->GetProductPaymentOptionCommissions((int)$lipaygear_productpaymentoptionid);
if(isset($_GET['productid']))
{
  $productid=trim($_GET['productid']);  
   if(isset($_SERVER['HTTP_REFERER']))
   {
            if(strpos($_SERVER['HTTP_REFERER'],'?')>0)
            {
                    $lsprevpageqs=substr($_SERVER['HTTP_REFERER'],strpos($_SERVER['HTTP_REFERER'],'?'));
                                     
                                     
            }  
            else
            {
                                    $lsprevpageqs='';
            } 
                         
   }
   else
   {
        $lsprevpageqs='';  
   } 
}

else
{
    if(isset($_SESSION[SESSION_PREFIX.'chkrecurring']) and isset($_SESSION[SESSION_PREFIX.'paygear_productpaymentoptionid']) and
       isset($_SESSION[SESSION_PREFIX.'paygear_productid']))
    {
        if(trim($_SESSION[SESSION_PREFIX.'paygear_productpaymentoptionid'])!='' &&
           trim($_SESSION[SESSION_PREFIX.'paygear_productid']))
         {
             $lipaygear_productpaymentoptionid= trim($_SESSION[SESSION_PREFIX.'paygear_productpaymentoptionid']);
             
             //echo "Hi". $lipaygear_productpaymentoptionid;
             $liisrecurring=trim($_SESSION[SESSION_PREFIX.'chkrecurring']);
             $lsproductname=trim($_SESSION[SESSION_PREFIX.'productname']);
             $lsproductprice=trim($_SESSION[SESSION_PREFIX.'productprice']); 
             $lsproductid=trim($_SESSION[SESSION_PREFIX.'paygear_productid']);
         }
    }
    else
    {
           $lsmessage="You do not have a permission to directly access this page.";
           $message->SetMessage($lsmessage);
           Redirect('./admin_product_v.php');
        
    }
    
}

//$_action='edit';
switch($_action)
{
    case 'insert': 
          $liVendorID=decrypt(PAYGEAR_USERID); 
          $lsValues = array(); 
          $lsValues[]=trim($lsproductid);
          $lsValues[]=trim($lipaygear_productpaymentoptionid);
          $lsValues[]=trim($_POST['ddlCommissionType']);
          $lsValues[]=trim($_POST['txtLevel1']);
          $lsValues[]=trim($_POST['txtLevel2']);
          if($liisrecurring==1)
          {
               $lsValues[]=trim($_POST['txtLevel1_2']); 
               $lsValues[]=trim($_POST['txtLevel2_2']); 
          }
          else
          {
              $lsValues[]=0; 
              $lsValues[]=0;
              
          }
          $lsValues[]=$liVendorID;
          $lsValues[]=$_SERVER['REMOTE_ADDR']; 
          $resultpaygeraaddproductcommision=$PaygearWebserviceClient->AddProductPaymentOptionCommissions((int)$lsValues[0],(int)$lsValues[1],(int)$lsValues[2],(double)$lsValues[3],
                                                                                                        (double)$lsValues[4],(double)$lsValues[5],(double)$lsValues[6],(int)$lsValues[7],$lsValues[8]);
                                                                                                        
           if($resultpaygeraaddproductcommision!='' &&  $resultpaygeraaddproductcommision!=null && $resultpaygeraaddproductcommision!=false)
           {
              $paygearlink=true;
           }
           else
           {
              $paygearlink=false;
           }   
           unset($_SESSION[SESSION_PREFIX.'chkrecurring']);
           unset($_SESSION[SESSION_PREFIX.'paygear_productpaymentoptionid']);
           unset($_SESSION[SESSION_PREFIX.'productname']);
           unset($_SESSION[SESSION_PREFIX.'productprice']);
           unset($_SESSION[SESSION_PREFIX.'paygear_productid']);
           $lsmessage=($paygearlink==false)?'Product is Inserted but not Link with paygear':'Product is Successfully Inserted';     
           $message->SetMessage($lsmessage);
           Redirect('./admin_product_v.php');
           
      break;
    
    case 'update':
           
           $liVendorID=decrypt(PAYGEAR_USERID); 
           $liisrecurring=trim($_POST['hdnissubscription']);
          $lsValues = array(); 
          $lsValues[]=trim($_POST['hdnpaygearproductid']);
          $lsValues[]=trim($_POST['hdnpaygearproducpaymentoptiontid']);
          $lsValues[]=trim($_POST['ddlCommissionType']);
          $lsValues[]=trim($_POST['txtLevel1']);
          $lsValues[]=trim($_POST['txtLevel2']);
          if($liisrecurring==1)
          {
               $lsValues[]=trim($_POST['txtLevel1_2']); 
               $lsValues[]=trim($_POST['txtLevel2_2']); 
          }
          else
          {
              $lsValues[]=0; 
              $lsValues[]=0;
              
          }
          $lsValues[]=$liVendorID;
          $lsValues[]=$_SERVER['REMOTE_ADDR']; 
          $resultpaygeraaddproductcommision=$PaygearWebserviceClient->AddProductPaymentOptionCommissions((int)$lsValues[0],(int)$lsValues[1],(int)$lsValues[2],(double)$lsValues[3],
                                                                                                        (double)$lsValues[4],(double)$lsValues[5],(double)$lsValues[6],(int)$lsValues[7],$lsValues[8]);
                                                                                                        
           if($resultpaygeraaddproductcommision!='' &&  $resultpaygeraaddproductcommision!=null && $resultpaygeraaddproductcommision!=false)
           {
              $paygearlink=true;
           }
           else
           {
              $paygearlink=false;
           }   
    
           $lsmessage=($paygearlink==false)?'Product is updated successfully but not Link with paygear':'Product is updated successfully';     
           $message->SetMessage($lsmessage);
             if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
             {
                Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);  
             }
             else
             {         
                Redirect('./admin_product_v.php');
             }       
       
      break;
    case 'delete': 
      break;
    case 'edit':
                if($productid>0)
                {
                    $lsValues = array();
                    $lsValues[]=$productid;   
                    $query="select p.*,p.id as 'Updateproductid',po.* from ".TABLE_PREFIX ."products p left join ".TABLE_PREFIX ."productpaymentoptions po on p.id=po.productid where p.id=?";
                    $laproductdatadb=$product->View($query,$lsValues,null);
                    
                    
                    
                    if(is_array($laproductdatadb) and sizeof($laproductdatadb)>0)
                    {
                      $lsproductname=$laproductdatadb[0]['name'];
                      $liisrecurring=$laproductdatadb[0]['issubscription'];
                      $lipaygear_productpaymentoptionid=$laproductdatadb[0]['paygear_productpaymentoptionid']; 
                       $lapaygearprodpayoptioncommisiondatainfo=$PaygearWebserviceClient->GetProductPaymentOptionCommissions((int)$lipaygear_productpaymentoptionid);
                        if(is_array($lapaygearprodpayoptioncommisiondatainfo))
                        {
                            if(sizeof($lapaygearprodpayoptioncommisiondatainfo))
                            {
                                    $lapaygearprodpayoptioncommisiondatainfo=$product->GetPaygearProductPaymentCommisioninfo($lapaygearprodpayoptioncommisiondatainfo);
                                    $laproductdata [] =  array();     
                                    $laproductdata[0]= $lapaygearprodpayoptioncommisiondatainfo;
                                    $laproductdata[0]['name']= $laproductdatadb[0]['name'];   
                                    $laproductdata[0]['paygear_productid']= $laproductdatadb[0]['paygear_productid']; 
                                    $laproductdata[0]['paygear_productpaymentoptionid']=$laproductdatadb[0]['paygear_productpaymentoptionid'];
                                    $laproductdata[0]['price']= $laproductdatadb[0]['price'];
                                    $laproductdata[0]['issubscription']=$laproductdatadb[0]['issubscription']; 
                                 //   print_r($laproductdata); 
                                    $smarty->assign('productcommisiondata',$laproductdata);    
                                    $smarty->assign('IsEdit','yes');   
                            }
                        }
                    }
               
                }

      default:
            
     
          $result=$PaygearWebserviceClient->ViewMasterValue('CommissionType');
          if(is_array($result))
          {
                 if(sizeof($result)>0)
                 {  
                     $smarty->assign('lacommisiontype',$result);
                 }
          }    
         //$post=array();
//         $post['txtcommlevel1']='0.00';
//         $post['txtcommlevel2']='0.00';  
//         $post['txtreqcommlevel1']=0.00;   
//         $post['txtreqcommlevel2']=0.00;    
          
         $smarty->assign('lsproductname',$lsproductname);
         $smarty->assign('lsrecurring',$liisrecurring);
         $smarty->assign('hdnProductPrice',$lsproductprice);
         $smarty->assign('hdncommissionid',0);
         $smarty->assign('lsprevpageqs',$lsprevpageqs);
         $smarty->display('admin_product_payment_option_m.tpl');     
   
}   
    
?>
Return current item: MembersGear