Location: PHPKode > projects > MembersGear > membersgear/admin/admin_user_subscription_v.php
<?php
  require_once "../config/config.php";
  require_once INCLUDE_DIR."/users_class.php"; 
  $users = new users_class(); 
  if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can browse user profiles')==false)
  {
    Redirect('admin_nopermission.php',true);  
      
  } 
    
      $lsuserid='';
       if(isset($_GET['userid']) && $_GET['userid']!='')
       {
          $lsuserid=(int)$_GET['userid'];
        
       }
       else
       {
           Redirect('admin_users_v.php',true); 
           
       }   
    //$liUserID = $_GET['id'];     
          
          echo($smarty->fetch('admin_header.php'));
          //echo PrintABCDPaging();
          //phpinfo();
           
            echo "<div id=\"content\" class=\"setdiv\"> ";
           
            if($message->IsMessageExists())
            {    
                $lsmsg=$message->GetMessage();
                echo "<div class=\"succmsg\" style=\"width:200px\">$lsmsg</div>";
            }
            
            $userQuery = 'SELECT username FROM '.TABLE_PREFIX.'users WHERE id = '.$lsuserid;
            $username = $users->View($userQuery);
            //print_r($username);die;
           
            echo "<div id=\"full-contentdiv\">";
            echo "<div class=\"righttop\">";
            echo "<h2 align=\"center\">";
             if(is_array($username) && sizeof($username)) 
                 echo "User Payments/Subscriptions of ". $username[0]['username'];
             else
                   echo "User Payments/Subscriptions";
            echo "</h2>";
            echo "</div>";
            echo "<div class=\"whole-page clear\">";
             echo "<div style=\"width:100%;color:#093854;font-weight:bold;clear:both;overflow:hidden;\">";
            echo"<div style=\"float:left;width:17%;\"><span style=\"margin-left:4px;\"><a href=\"admin_users_v.php\">Back To Users List</a></span></div>";
            echo "</div>";
            /****************************************************************************
            * Updated By Jayesh : for display character based paging
            *****************************************************************************/
            echo "<div class='controlDiv'>";
            echo PrintABCDPaging();
            echo "</div>";
            
             if(isset($_GET['letter']) and $_GET['letter'] != 'all')
              {
                    $lsSearchLetter = $_GET['letter'];
              }
              else
              {
                    $lsSearchLetter = '';   
              }
            
          //echo $res;
                /*$sql = 'SELECT *,CASE WHEN bantype = 1 THEN \'IP Address\' WHEN bantype = 2 THEN  \'Hostname\' WHEN bantype = 3 THEN \'Range\' END AS `BanType`,CASE WHEN `isactive` = 1 THEN \'Active\' WHEN `isactive` = 0 THEN \'InActive\' END AS `Status` FROM '.TABLE_PREFIX.'banlist';
                      
                        $sql = 'SELECT pp.name as `Productname`,
                                case when ptu.islifetime = 1 then concat(from_unixtime(ptu.fromdate,"%Y/%m/%d"),\' - LIFETIME\')
                                     else concat(from_unixtime(ptu.fromdate,"%Y/%m/%d"),\' - \',from_unixtime(ptu.uptodate,"%Y/%m/%d")) end as `Period`
                                     ,ptu.paygear_paymentgetway as `PaymentGateway`
                                     ,ptu.paygear_etransactionid as `TransactionId`
                                     ,ptu.amount as `Amount`
                                     ,ppm.paygear_value as `Paid`,
                                     case when pmvp.value = \'Expire\' then concat(\'<span style="color:red;font-weight:bold">\',pmvp.value,\'</span>\')
                                          when pmvp.value = \'Active\' then concat(\'<span style="font-weight:bold">\',pmvp.value,\'</span>\')
                                          when pmvp.value = \'Pending\' or pmvp.value = \'Inactive\' then pmvp.value end as `Status`
                                     ,pu.username
                                FROM '.TABLE_PREFIX.'product_users ptu
                                    left join '.TABLE_PREFIX.'products pp on pp.id = ptu.productid
                                    left join '.TABLE_PREFIX.'paygear_mastervalues ppm on ppm.paygear_id = ptu.paygear_epaymentstatus and ppm.paygear_master = \'    ePaymentStatus\'
                                    left join '.TABLE_PREFIX.'master_values pmvp on pmvp.id = ptu.productmembershipstatusid
                                    join ".TABLE_PREFIX."users pu on pu.id = ptu.userid
                                where ifnull(name,\'\') like \''.$lsSearchLetter.'%\' and userid='.$lsuserid.' 
                                order by name;';
                                    */
                        $sql = "
                                select ptu.id as 'id',pp.name as `Productname`
                                        ,case when ptu.islifetime = 1 then concat(from_unixtime(ptu.fromdate,\"%Y/%m/%d\"),' - LIFETIME')
                                              else concat(from_unixtime(ptu.fromdate,\"%Y/%m/%d\"),' - ',from_unixtime(ptu.uptodate,\"%Y/%m/%d\")) end as `Period`
                                        ,ptu.paygear_paymentgetway as `PaymentGateway`
                                        ,ptu.paygear_etransactionid as `TransactionId`
                                        ,ptu.amount as `Amount1`
                                        ,replace(FORMAT(ptu.amount,2),',','') as 'Amount'
                                        ,ppm.paygear_value as `Paid`
                                        ,case when pmvp.value = 'Expire' then concat('<span style=\"color:red;font-weight:bold\">',pmvp.value,'d</span>')
                                              when pmvp.value = 'Active' then concat('<span style=\"font-weight:bold\">',pmvp.value,'</span>')
                                              when pmvp.value = 'Pending' or pmvp.value = 'Inactive' then pmvp.value end as `Status`
                                        ,pu.username

                                from ".TABLE_PREFIX."product_users ptu
                                        left join ".TABLE_PREFIX."products pp on pp.id = ptu.productid
                                        left join ".TABLE_PREFIX."paygear_mastervalues ppm on ppm.paygear_id = ptu.paygear_epaymentstatus and ppm.paygear_master = 'ePaymentStatus'
                                        left join ".TABLE_PREFIX."master_values pmvp on pmvp.id = ptu.productmembershipstatusid
                                        join ".TABLE_PREFIX."users pu on pu.id = ptu.userid
                                where ifnull(name,'') like '$lsSearchLetter%' and userid=$lsuserid 
                                order by name;
                        ";
                //echo $sql;
                # execute the sql query
                $db->execute($sql);


                # creates a new phpSortColumn object for ID´s 
                
                
                #creates a new phpSortcolunm objects for name
                $col_0 = new phpSortColumn("Productname", "Product");
                
                # creates a new phpSortColumn object for Tile
                $col_1 = new phpSortColumn("Period", "Period");

                # creates a new phpSortColumn object for Field Type
                $col_2 = new phpSortColumn("PaymentGateway", "Payment Gateway");
                
                $col_3 = new phpSortColumn("TransactionId", "Transaction ID");
                
                $col_4 = new phpSortColumn("Amount", "Amount(\$)");
                
                $col_5 = new phpSortColumn("Paid", "Paid");
                
                $col_6 = new phpSortColumn("Status", "Status");
              //  $col_7 = new phpSortColumn("id", "ID");    

                # add the columns to an array 
                $columns = array(0=>$col_0, 1=>$col_1, 2=>$col_2, 3=>$col_3, 4=>$col_4, 5=>$col_5, 6=>$col_6);

                # create a new phpSortable object with the abstracted db object
                # and the array of column object
                $sortable = new phpSortable($db, $columns);

                # define the table format: cellpadding, cellspacing, border
                $sortable->setTableFormat ("2", "2", "0");

                # define the table title
                $sortable->tableTitle = "";

                # Encrypt Edit and Delete Link
                $sortable->editLink = "admin_user_subscription_m.php?userid=$lsuserid&action=edit";
                $sortable->encryptlink=true;
                # open the edit page in a new window
                //$sortable->editTarget = "_blank";

                # window format for the edit page
               // $sortable->editWindowFormat = "'width=300,height=400'";

                # define the link for delete of entries
                $sortable->deleteLink = "admin_user_subscription_m.php?userid=$lsuserid&action=delete";
                
                # open the edit page in a new window
                     # define the link for add new entries
                $sortable->addLink = "admin_user_subscription_m.php?userid=$lsuserid";
                
                # set visibility of add,edit,delete link of the grid
                 if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can add users')==false)
                {
                    $sortable->showaddLink=false; 
                      $sortable->showeditLink=false;
                }

                # define the hint to be displyed over the add button
                $sortable->addText = "Add/Renew Subscription";
//$sortable->editTarget = "_blank";

                # define the key name to be attached to links
                $sortable->urlKeyName = "id";

                # define the column name of to be attached to links as key value
                $sortable->tableKeyName = "id";

                # define the prompt message to be diplayed on clicking the edit button            
                //$sortable->editPromptMsg = "Are you sure you want to edit this affiliate?";
                $sortable->deletePromptMsg = "Are you sure you want to delete this Subscription?";
                
                # define the message to be diplayed if there are no results found
                $sortable->emptyMsg = "No Product Subscription Found.";

                #define the deafult row number to be displayed
                $sortable->defaultRowsNum = "10";

                #define the path for the css file
                $sortable->cssFilePath = ADMIN_CSS_DIR."/phpSortable.css";

                #define the path for of the images directory
                $sortable->imgFilePath = ADMIN_IMAGE_DIR."/phpgrid/";

                # print the table            
                $sortable->printTable();

           /*   echo "<br/>";
           
              if(isset($_SERVER['HTTP_REFERER']))
              {
                    if(strpos($_SERVER['HTTP_REFERER'],'admin_user_subscription_m.php')>0)
                        echo "<div style=\"text-align: right; margin-right: 3px;\"><input type=\"button\" class=\"btncss\" name=\"btnBack\" value=\"Back\" onclick=\"javascript:location.href='admin_user_subscription_m.php?userid=$lsuserid';\"></div>";                       
                    else
                       echo "<div style=\"text-align: right; margin-right: 3px;\"><input type=\"button\" class=\"btncss\" name=\"btnBack\" value=\"Back\" onclick=\"javascript:window.history.go(-1);\"></div>";              
              } 
              else
              {
                    echo "<div style=\"text-align: right; margin-right: 3px;\"><input type=\"button\" class=\"btncss\" name=\"btnBack\" value=\"Back\" onclick=\"javascript:window.history.go(-1);\"></div>";                            
              } */ 
              echo "</div>";
              echo '<input style="margin:5px;" type="submit" value="View Members" name="btnViewMembers" id="btnViewMembers" class="btncss" onclick="window.location.href=\'admin_users_v.php\';return false;"/>';  
              echo "</div>";
              
              echo "</div>";
              
              //For display footer.php
              echo($smarty->fetch('admin_footer.php'));   
?>
Return current item: MembersGear