Location: PHPKode > projects > MembersGear > membersgear/includes/getdata_admin_user_subscription.php
<?php
require_once("../config/config.php");
require_once INCLUDE_DIR."/product_class.php";  


/**
 *  Example 1
 *  This class shows how to read something from the client
 *  and write something on the brower.
 *  
 *  @author Cesar D. Rodas
 *  @package PHP-Ajax-Examples
 */



if(isset($_POST)){
        /*
         *  The variables that was read in the method
         *  "input" is referenced here as local variable
         *  for made easy in the code time.
         */
       $pProductId = $_POST['productid'];
       $pUserId = $_POST['userid'];
     
           $prodcalssObj=new product_class();
           $lsIsLifeTimeCheckQuery         ="select IsLifeTime,price from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
           $result                        =$prodcalssObj->View($lsIsLifeTimeCheckQuery);
           $isLifeTimeVal                 =$result[0]['islifetime'];
           $lsprice                       =$result[0]['price'];  
             
         $prodid=$prodcalssObj->isValidProduct($pProductId);                                            
          
/*          if($prodid!="" and isset($prodid) and $prodid!=NULL)
          { 
                          if($isLifeTimeVal!=1)
                          {
                                            
                                            $lsdurationCheckQuery       ="select duration_type from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                            $result                     =$prodcalssObj->view($lsdurationCheckQuery);
                                            $lsDurationType             =$result[0]['duration_type'];
                                            
                                            if(isset($lsDurationType) and $lsDurationType=="Months")
                                             {
                                                     $igetMonthQuery         ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                                     $resultMonthQuery       = $prodcalssObj->view($igetMonthQuery); 
                                                     $lsDurationValue        =$resultMonthQuery[0]['duration'];       
                                                 
                                                     if($lsDurationValue>0)
                                                      {
                                                          $liFromDate                     = strtotime(date("Y/m/dH:i:s"));
                                                          $liUptoDate                     = strtotime(date("Y/m/dH:i:s")." +$lsDurationValue month");
                                                      }
                                                  
                                             }
                                             
                                            else if(isset($lsDurationType) and $lsDurationType=="Days")
                                             {
                                                     $igetDayQuery           ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                                     $resultDayQuery         = $prodcalssObj->view($igetDayQuery); 
                                                     $lsDurationValue        =$resultDayQuery[0]['duration'];       
                                                 
                                                     if($lsDurationValue>0)
                                                      {
                                                          $liFromDate                     = strtotime(date("Y/m/dH:i:s"));
                                                          $liUptoDate                     = strtotime(date("Y/m/dH:i:s")." +$lsDurationValue day");   
                                                      }
                                                  
                                             }
                                              else if(isset($lsDurationType) and $lsDurationType=="Years")
                                             {
                                                     $igetYearQuery           ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                                     $resultYearQuery         = $prodcalssObj->view($igetYearQuery); 
                                                     $lsDurationValue         =$resultYearQuery[0]['duration'];       
                                                 
                                                     if($lsDurationValue>0)
                                                      {
                                                          $liFromDate                     = strtotime(date("Y/m/dH:i:s"));
                                                          $liUptoDate                     = strtotime(date("Y/m/dH:i:s")." +$lsDurationValue year");
                                                      }
                                                  
                                             }
                                            else if(isset($lsDurationType) and $lsDurationType=="Exact date (mm-dd-yyyy)")
                                             {
                                            
                                                 $liFromDate             = strtotime(date("Y/m/dH:i:s")); 
                                                 $igetexactdate          ="select duration_exactdate from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                                 $resultexactdateQuery   = $prodcalssObj->view($igetexactdate); 
                                                 $lsDurationValue        =$resultexactdateQuery[0]['duration_exactdate'];
                                                 $liUptoDate             =$lsDurationValue;  
                                             
                                             }
                                              
                          }
                        else
                         {
                              $liFromDate                     = "-";
                              $liUptoDate                     = "-"; 
                             
                         }
          }   */
          
          /* updated by nikunj for renewal group */
           $renewal_Prod_id=NULL;
           $getSatusRenewal_Or_New_Subscription=$prodcalssObj->getRenwalProductRecord($prodid,$pUserId);
             
           if($getSatusRenewal_Or_New_Subscription!=NULL and  $getSatusRenewal_Or_New_Subscription!="")
            {
               $prodidRenwal=$prodcalssObj->getRenwalProductGroup($getSatusRenewal_Or_New_Subscription);
               if($prodidRenwal==NULL or $prodidRenwal=="")
                  $prodidRenwal=$pProductId;
                  
               $is_valid_Product=$prodcalssObj->isValidProduct($prodidRenwal); 
               
               $renewal_Prod_id=$is_valid_Product;
        
            }
         
              
           
                   
           
          /************************************************************************************************************/
          if($prodid!="" and isset($prodid) and $prodid!=NULL)
           { 
                          
           
                if($renewal_Prod_id!=NULL and $renewal_Prod_id!="")
                 {
                     
                          $lsIsLifeTimeCheckQueryRnewalGroup         ="select IsLifeTime from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
                          $result                         =$prodcalssObj->View($lsIsLifeTimeCheckQueryRnewalGroup);
                          $isLifeTimeVal                  =$result[0]['islifetime'];
                       if($isLifeTimeVal!=1)
                        {
                            
                                    $lsdurationCheckQuery       ="select duration_type from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
                                    $result                     =$prodcalssObj->View($lsdurationCheckQuery);
                                    $lsDurationType             =$result[0]['duration_type'];
                                    
                                    if(isset($lsDurationType) and $lsDurationType=="Months")
                                     {
                                             $igetMonthQuery         ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
                                             $resultMonthQuery       = $prodcalssObj->View($igetMonthQuery); 
                                             $lsDurationValue        =$resultMonthQuery[0]['duration'];       
                                         
                                             if($lsDurationValue>0)
                                              {
                                                  $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                                  $liUptoDate                     = strtotime(date("m/d/YH:i:s")." +$lsDurationValue month");
                                              }
                                          
                                     }
                                     
                                    else if(isset($lsDurationType) and $lsDurationType=="Days")
                                     {
                                             $igetDayQuery           ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
                                             $resultDayQuery         =$prodcalssObj->View($igetDayQuery); 
                                             $lsDurationValue        =$resultDayQuery[0]['duration'];       
                                         
                                             if($lsDurationValue>0)
                                              {
                                                  $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                                  $liUptoDate                     = strtotime(date("m/d/YH:i:s")." +$lsDurationValue day");   
                                              }
                                          
                                     }
                                      else if(isset($lsDurationType) and $lsDurationType=="Years")
                                     {
                                             $igetYearQuery           ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
                                             $resultYearQuery         =$prodcalssObj->View($igetYearQuery); 
                                             $lsDurationValue         =$resultYearQuery[0]['duration'];       
                                         
                                             if($lsDurationValue>0)
                                              {
                                                  $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                                  $liUptoDate                     = strtotime(date("m/d/YH:i:s")." +$lsDurationValue year");
                                              }
                                          
                                     }
                                    else if(isset($lsDurationType) and $lsDurationType=="Exact date (mm-dd-yyyy)")
                                     {
                                    
                                         $liFromDate             = strtotime(date("m/d/YH:i:s")); 
                                         $igetexactdate          ="select duration_exactdate from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
                                         $resultexactdateQuery   =$prodcalssObj->View($igetexactdate); 
                                         $lsDurationValue        =$resultexactdateQuery[0]['duration_exactdate'];
                                         $liUptoDate             =$lsDurationValue;  
                                     
                                     }
                                    
                                }
                                else
                                 {
                                      $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                      $liUptoDate                     = strtotime(date("m/d/YH:i:s")); 
                                     
                                 }
                             
                             
                                 /* get max record id for this product user*/
                                 
                                // $maxProdIdQuery ="SELECT  max(id) as `maxid` FROM ".TABLE_PREFIX."product_users WHERE userid=$pUserId and productid=$pProductId ";
//                                 $res=$prodcalssObj->View($maxProdIdQuery);
//                                 $maxId=$res[0]['maxid'];
                                 
                             
                                /************************************************/
                                 
                              //   $updateQueryTempProdUser           ="update ".TABLE_PREFIX."product_users set fromdate=$liFromDate,uptodate=$liUptoDate,productmembershipstatusid=$masterValuesId,paygear_etransactionid='$payGear_eTranId', paygear_paymentgetway='$payGear_payment_gateway', paygear_paymentgetwayresponse='$paygear_paymentgetwayresponse',paygear_epaymentstatus=$payGearE_Payment_Status,paygear_vendorpaymentstatus=$paygearVendorStat,paygear_paymentmethod='$payGearPayMethod',paygear_orderid=$payGear_orderid,paygear_paidon=$paygear_paidon,islifetime=$isLifeTimeVal where userid=$pUserId and productid=$pProductId and id=$maxId";
//                                 $result                            =$prodcalssObj->View($updateQueryTempProdUser);
                                 /* $myFile = "error.txt";
                                 $fh = fopen($myFile, 'w') or die("can't open file");
                                 fwrite($fh, $updateQueryTempProdUser);
                                 fwrite($fh, "\nRenewal\n$isLifeTimeVal"); 
                                 fclose($fh);    */
                 }
                else
                 {   
                     
                          if($isLifeTimeVal!=1)
                        {
                            
                                    $lsdurationCheckQuery       ="select duration_type from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                    $result                     =$prodcalssObj->View($lsdurationCheckQuery);
                                    $lsDurationType             =$result[0]['duration_type'];
                                    
                                    if(isset($lsDurationType) and $lsDurationType=="Months")
                                     {
                                             $igetMonthQuery         ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                             $resultMonthQuery       = $prodcalssObj->View($igetMonthQuery); 
                                             $lsDurationValue        =$resultMonthQuery[0]['duration'];       
                                         
                                             if($lsDurationValue>0)
                                              {
                                                  $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                                  $liUptoDate                     = strtotime(date("m/d/YH:i:s")." +$lsDurationValue month");
                                              }
                                          
                                     }
                                     
                                    else if(isset($lsDurationType) and $lsDurationType=="Days")
                                     {
                                             $igetDayQuery           ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                             $resultDayQuery         = $prodcalssObj->View($igetDayQuery); 
                                             $lsDurationValue        =$resultDayQuery[0]['duration'];       
                                         
                                             if($lsDurationValue>0)
                                              {
                                                  $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                                  $liUptoDate                     = strtotime(date("m/d/YH:i:s")." +$lsDurationValue day");   
                                              }
                                          
                                     }
                                      else if(isset($lsDurationType) and $lsDurationType=="Years")
                                     {
                                             $igetYearQuery           ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                             $resultYearQuery         = $prodcalssObj->View($igetYearQuery); 
                                             $lsDurationValue         =$resultYearQuery[0]['duration'];       
                                         
                                             if($lsDurationValue>0)
                                              {
                                                  $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                                  $liUptoDate                     = strtotime(date("m/d/YH:i:s")." +$lsDurationValue year");
                                              }
                                          
                                     }
                                    else if(isset($lsDurationType) and $lsDurationType=="Exact date (mm-dd-yyyy)")
                                     {
                                    
                                         $liFromDate             = strtotime(date("m/d/YH:i:s")); 
                                         $igetexactdate          ="select duration_exactdate from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
                                         $resultexactdateQuery   = $prodcalssObj->View($igetexactdate); 
                                         $lsDurationValue        =$resultexactdateQuery[0]['duration_exactdate'];
                                         $liUptoDate             =$lsDurationValue;  
                                     
                                     }
                                    
                                }
                                else
                                 {
                                      $liFromDate                     = strtotime(date("m/d/YH:i:s"));
                                      $liUptoDate                     = strtotime(date("m/d/YH:i:s")); 
                                     
                                 }
                             
                             /* get max record id for this product user*/
                                 
                                // $maxProdIdQuery ="SELECT  max(id) as `maxid` FROM ".TABLE_PREFIX."product_users WHERE userid=$pUserId and productid=$pProductId";
//                                 $res=$prodcalssObj->View($maxProdIdQuery);
//                                 $maxId=$res[0]['maxid'];
//                                 
                                 
                    
                                /************************************************/
                              //   $updateQueryTempProdUser           ="update ".TABLE_PREFIX."product_users set fromdate=$liFromDate,uptodate=$liUptoDate,productmembershipstatusid=$masterValuesId,paygear_etransactionid='$payGear_eTranId', paygear_paymentgetway='$payGear_payment_gateway', paygear_paymentgetwayresponse='$paygear_paymentgetwayresponse',paygear_epaymentstatus=$payGearE_Payment_Status,paygear_vendorpaymentstatus=$paygearVendorStat,paygear_paymentmethod='$payGearPayMethod',paygear_orderid=$payGear_orderid,paygear_paidon=$paygear_paidon where userid=$pUserId and productid=$pProductId and id=$maxId";
//                                 $result                            =$this->Update($updateQueryTempProdUser);
                                /*  $myFile = "error.txt";
                                 $fh = fopen($myFile, 'w') or die("can't open file");
                                 fwrite($fh, $updateQueryTempProdUser);
                                 fclose($fh);          */
                 
                    
                 }  
           }
          $lsprice="$".number_format($lsprice,2,'.','');  
          if($isLifeTimeVal!=1)
          {
             
            $str=$liFromDate;
            $upd= $liUptoDate;
          
            echo 'no'.'[||]'.$lsprice.'[||]'.date("Y-m-d H:i:s",$liFromDate).'[||]'.$str.'[||]'.date("Y-m-d H:i:s",$liUptoDate).'[||]'.$upd;  
           
          }
          else
          {
             $str="<input type=\"hidden\" name=\"hdnislifetime\" id=\"hdnislifetime\" value=".$isLifeTimeVal.">"; 
             echo 'yes'.'[||]'.$lsprice.'[||]'.$str;
       
          }
          
     exit;
    
}
?>
Return current item: MembersGear