Location: PHPKode > projects > MembersGear > membersgear/admin/admin_product_v.php
<?php   
  require_once "../config/config.php"; 
  require_once INCLUDE_DIR."/users_class.php"; 
  $users=new users_class();    
  $lsmanageproduct=true;

  if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
      unset($_SESSION[SESSION_PREFIX.'page_referrer']);
      
  if(isset($_SESSION[SESSION_PREFIX.'chkrecurring']))    
    unset($_SESSION[SESSION_PREFIX.'chkrecurring']);
  if(isset($_SESSION[SESSION_PREFIX.'paygear_productpaymentoptionid']))
    unset($_SESSION[SESSION_PREFIX.'paygear_productpaymentoptionid']);
  if(isset($_SESSION[SESSION_PREFIX.'productname']))
    unset($_SESSION[SESSION_PREFIX.'productname']);
  if(isset($_SESSION[SESSION_PREFIX.'productprice']))  
    unset($_SESSION[SESSION_PREFIX.'productprice']);
  if(isset($_SESSION[SESSION_PREFIX.'paygear_productid']))  
   unset($_SESSION[SESSION_PREFIX.'paygear_productid']);    
     
  if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can view products and thankyou page tracking')==false)
  {
    Redirect('admin_nopermission.php',true);  
      
  }  
  switch($_action)
  {
      
       case 'insert':   
       
       
       case 'update':  
       
        default:       
           ////Parameterized View
         /*  $lsValues = array();
           
           $lTypes=null;
           
           $result = $loManageFields->View('SELECT * FROM '.TABLE_PREFIX.'singupformfields');
  
           $smarty->assign('data',$result);
           
           //$smarty->display('admin_fields_m.tpl');  */
          // require_once "../templates/admin_header.php";
         
         //for display the header.php
           echo($smarty->fetch('admin_header.php'));
           echo "<form name=\"frmsendmail\" action=\"admin_send_email.php?action=sendgp\" method=\"POST\">";  
           echo "<div id=\"content\" class=\"setdiv\"> ";
            echo "
                    <script language=\"JavaScript\">
                        function CheckAll(elementID)
                        {
                            var CheckSelect = document.getElementById('chkSelectAll');
                            var LabelCheckSelect = document.getElementById('lblSelect');
                            var AllCheckBox = document.getElementsByName('chkDeleteItem[]');
                            //alert(CheckSelect.checked);
                            //alert(AllCheckBox.length);
                            
                            switch(elementID)
                            {
                                case 'chkSelectAll':
                                        if(CheckSelect.checked)
                                        {
                                             //alert(AllCheckBox.length);
                                             LabelCheckSelect.innerHTML = 'Uncheck All';
                                            for(i=0;i<AllCheckBox.length;i++)
                                            {
                                                AllCheckBox[i].checked = 'true';
                                            }
                                        }
                                        else
                                        {
                                            LabelCheckSelect.innerHTML = 'Check All';
                                            for(i=0;i<AllCheckBox.length;i++)
                                            {
                                                AllCheckBox[i].checked = '';
                                            }
                                        }
                                        break;
                                case 'ckhDeleteItem':
                                        var flag = 1;
                                        for(i=0;i<AllCheckBox.length;i++)
                                        {
                                            if(!AllCheckBox[i].checked)
                                            {
                                                  flag = 0;
                                            }
                                        }
                                        
                                        if(flag == 0)
                                        {
                                             LabelCheckSelect.innerHTML = 'Check All';
                                             CheckSelect.checked = '';
                                        }
                                        else
                                        {
                                             LabelCheckSelect.innerHTML = 'Uncheck All';
                                             CheckSelect.checked = 'true';
                                        }
                            }
            
                        }
                        
                        function ValidateCheckbox(str,str1)
                        {     
                              var AllCheckBox = document.getElementsByName('chkDeleteItem[]');
                              var error=''; 
                              var flag = 0;     
                                for(i=0;i<AllCheckBox.length;i++)
                                {
                                        if(AllCheckBox[i].checked)
                                        {
                                                  flag = 1;
                                        }
                                }
                                
                                if(str == 'selected')
                                {
                                    if(str1=='btnEmailSelected')
                                    {
                                        //alert('Please select atleast one product to send an email.');
                                        if(document.getElementById('seluser1').checked)
                                        {
                                            if(flag == 0)
                                            {
                                                error+='Please select atleast one product to send an email.".'\r\n'."';   
                                            }
                                            var active=document.getElementById('chkactive').checked;
                                            var inactive=document.getElementById('chkinactive').checked;
                                            var pending=document.getElementById('chkpending').checked;
                                            var expire=document.getElementById('chkexpire').checked;
                                            if(active==false && inactive==false && pending==false  && expire==false)
                                           {
                                               error+='Please select atleast one product membership status.'; 
                                             
                                           } 
                                           if(error!='')  
                                          
                                            {   
                                                alert(error);
                                                  return false; 
                                            }
                                        } 
                                        else
                                        {  if(flag == 0)
                                            {
                                                alert('Please select atleast one product to send an email.'); 
                                                  return false;    
                                            }
                                        } 
                                       
                                        
                                    }
                                  
                                  
                                }
                                else
                                {   if(str1=='btnDeleteSelected')
                                    {
                                        return confirm('Are you sure to delete '+str+' users?');
                                    }
                                    else
                                    {
                                        return true;
                                    }
                                    //return true;
                                } 
                                
                        }
                        function Formsubmit() 
                        {   
                        
                            document.frmDeleteLog.action='admin_send_email.php'; 
                            document.frmDeleteLog.submit();
                        } 
                        setSlideDownSpeed(4);     
                    </script>
                    
                    <style type=\"text/css\" charset=\"utf-8\">
                    fieldset {
                    -moz-border-radius: 10px;

                    }
                    </style>
                
                 ";
           
           $from=$_GET['q'];
        
            if($message->IsMessageExists())
             {    
                $lsmsg=$message->GetMessage();
                if(isset($_GET['err']))
                {
                    if($_GET['err']=="true")
                     $errorHeader= "<div class=\"errormsg\" style=\"width:400px\">$lsmsg</div>";
                    else
                       $errorHeader= "<div class=\"succmsg\" style=\"width:400px\">$lsmsg</div>";
                }
               else
                 $errorHeader= "<div class=\"succmsg\" style=\"width:400px\">$lsmsg</div>"; 
                   
                   
               echo  $errorHeader;   
             }
            echo "<div id=\"full-contentdiv\">"; 
           
            echo "<div class=\"righttop\">";
            echo "<h2 align=\"center\">";
            
            if($from=='sendemailstouser')
            echo "Send Emails To Users";
            else
            echo "Manage Products";
            echo "</h2>";
            echo "<div style='text-align:right;margin-top:8px;margin-right:3px;'><input value='Import products from PayGear' type='button' class='btncss' onclick='location.href=\"admin_product_m.php?action=product_import&vendorId=".decrypt(PAYGEAR_USERID)."\"'></a></div>";
            echo "</div>";
            echo "<div class=\"whole-page clear\">";
            
            /****************************************************************************
            * Updated By Jayesh : for display character based paging
            *****************************************************************************/
            echo "<div style=\"text-align:center;margin:2px;\">";
            echo "<div style=\"margin-left:3px;margin-top:3px;text-align:left;font-weight:bold !important;float:left;width:120px;\">";
           // if($lsmanageemaillog==true)
            {
               echo "<input type=\"checkbox\" class=\"chkcss\" id=\"chkSelectAll\" name=\"chkSelectAll\" onclick=\"return CheckAll(this.id)\"> <label id=\"lblSelect\" for=\"chkSelectAll\">Check All</label>";              
            }
              echo "</div>";
           // echo "<div class='controlDiv'>";
           //echo "<div style=\"float: left;margin-left:110px\">";  
            echo "<div class=\"divABCDPaging\">";
            echo PrintABCDPaging();
            echo "</div>";
            echo "</div>";
            
             if(isset($_GET['letter']) and $_GET['letter'] != 'all')
              {
                    $lsSearchLetter = $_GET['letter'];
              }
              else
              {
                    $lsSearchLetter = '';   
              }
          //echo $res;
              //  $sql = 'SELECT * FROM '.TABLE_PREFIX.'singupformfields';
               /*
                $sql="select p.*,concat('$',FORMAT(p.price,2))as 'Fromatedprice',
                        (CASE WHEN  po.issubscription=1 THEN 'Yes' else 'No' END) as Isrecurring,
                        (CASE po.RecurringChargePeriodTypeID WHEN
                            1 THEN concat(po.RecurringChargePeriod,'','d')  WHEN
                            2 THEN  concat(po.RecurringChargePeriod,'','m')
                        ELSE '' END) as Duration,
                        (CASE WHEN islinkedwithpaygear=1 then 'Yes' else 'No' END) as `islinkedwithpaygear`
                        from ".TABLE_PREFIX."products p  join ".TABLE_PREFIX."productpaymentoptions 
                        po on p.id=po.productid where p.IsDeleted=0;";
                
                $sql="select p.*,concat('$',FORMAT(p.price,2))as 'Fromatedprice',
                        (CASE WHEN  po.issubscription=1 THEN 'Yes' else 'No' END) as Isrecurring,
                        (CASE po.RecurringChargePeriodTypeID WHEN
                            1 THEN concat(po.RecurringChargePeriod,'','d')  WHEN
                            2 THEN  concat(po.RecurringChargePeriod,'','m')
                        ELSE '' END) as Duration,
                        (CASE WHEN islinkedwithpaygear=1 then 'Yes' else 'No' END) as `islinkedwithpaygear`
                        from ".TABLE_PREFIX."products p  join ".TABLE_PREFIX."productpaymentoptions 
                        po on p.id=po.productid where p.IsDeleted=0 and name like '".$lsSearchLetter."%';";  */
                    
                $sql="select concat('<table><tr><td><input type=\"checkbox\" id=\"ckhDeleteItem\" name=\"chkDeleteItem[]\" onclick=\"return CheckAll(this.id)\" value=\"',p.id,'\" /></td></tr></table>') as `CheckToDelete`,
                       p.*,replace(FORMAT(p.price,2),',','')as 'Fromatedprice',
                                 CASE WHEN  isonetimeoffer=1 THEN  
                       concat('<table width=\"100%\"><tr><td align=\"left\">',(p.name),'<DIV><div id=\"dhtmlgoodies_control\"><a href=\"#\" style=\"font-size:0.9em\"onclick=\"slidedown_showHide(\'box',p.id,'\');return false;\"><b>(Show One Time Offer URL)</b></a></div>
                       <div class=\"dhtmlgoodies_contentBox\" id=\"box',p.id,'\"><div class=\"dhtmlgoodies_content\" id=\"subBox',p.id,'\">
                        <table style=\"width:100%\">
                            <tr>
                            <td align=\"left\"><b>One Time Offer url</b></td>
                            <td align=\"right\" style=\"text-align:right;\">    
                            <div id=\"dhtmlgoodies_control\" style=\"float:right;width:34px;\"><a href=\"#\" onclick=\"slidedown_showHide(\'box',p.id,'\');return false;\" style=\"text-decoration:none! important;\">Close</a></div> 
                            </td>
                           </tr>
                           <tr><td colspan=\"2\"><input type=\"text\" class=\"txtcss\" readonly=\"readonly\" onclick=\"this.select();\" id=\"url',p.id,'\" name=\"url',p.id,'\" size=\"112\" value=\"".WEB_URL."/user_onetimeoffer_signup.php?productid=',p.id,'\"></td></tr></table></div></div></div></td></tr></table>')  
                       else
                          concat('<table width=\"100%\"><tr><td align=\"left\">',(p.name),'</td></tr></table>')
                       end  as `name`,
                        (CASE WHEN  po.issubscription=1 THEN 'Yes' else 'No' END) as Isrecurring,
                        concat('<a href=\"admin_thankyoupage_tracking_v.php?productid=',p.id,'\"><img src=\"".ADMIN_IMAGE_DIR."/Thankpage.png\" title=\"Thankyou Page Tracking\" alt=\"Thankyou Page Tracking Code\"/></a>') as `thankyoupage`,
                         (CASE WHEN  p.islinkedwithpaygear=1 THEN 
                         concat('<a href=\"admin_product_payment_option_m.php?action=edit&productid=',p.id,'\"><img src=\"".ADMIN_IMAGE_DIR."/edit_commision.png\" title=\"Affiliate Commision\" alt=\"Affiliate Commision\"/></a>')
                         
                          else 
                          concat('<a href=\"#\"><img src=\"".ADMIN_IMAGE_DIR."/edit_commision_disable.png\" title=\"Affiliate Commision\" alt=\"Affiliate Commision\" onclick=\" return alert(\'In order to use this feature,you must have to link this product with paygear.\')\"/></a>')
                          
                           END)
                       
                        as `Affiliatecommision`,
                        (case when LENGTH(protectedurl) >= 45 then CONCAT('<a href=\"".WEB_URL."',protectedurl,'\">',SUBSTR(protectedurl,1,40),'....</a>') else  CONCAT('<a href=\"".WEB_URL."',protectedurl,'\">',protectedurl,'</a>') end) as protectedurl, 
                        concat('<table width=\"100%\"><tr><td align=\"center\">',(CASE WHEN islinkedwithpaygear=1 then 'Yes' else 'No' END),'</td></tr></table>')  as `islinkedwithpaygear`,
                        concat('<table width=\"100%\"><tr><td align=\"center\">',(CASE WHEN  isonetimeoffer=1 THEN 'Yes' else 'No' END) ,'</td></tr></table>')  as `isonetimeoffer`,
                        concat('<table width=\"100%\"><tr><td align=\"center\">',(CASE WHEN  isonetimeoffer=1 THEN 'Yes' else 'No' END) ,'</td></tr></table>')  as `isonetimeoffer1`,
                        concat('<table width=\"100%\"><tr><td align=\"left\">',(p.id),'</td></tr></table>')
                        as `proId`, 
                       
                           (CASE WHEN  p.isonetimeoffer=1  or  p.price <=0  or   po.issubscription=1 or p.islinkedwithpaygear!=1  THEN 
                            concat(' ') 
                           else                                                                                 
                            concat('<center><a href=\"admin_product_upsell_m.php?productid=',p.id,'\">Upsell<br/>Products</a></center>') 
                           END) as upsellurl
                            
                        from ".TABLE_PREFIX."products p  join ".TABLE_PREFIX."productpaymentoptions 
                        po on p.id=po.productid where p.IsDeleted=0 and name like '".$lsSearchLetter."%';";  
                
                # execute the sql query 
                $db->execute($sql);
                $totalrowcount=$db->rowCount();   

                # creates a new phpSortColumn object for ID´s 
                //$col_0 = new phpSortColumn("id", "ID");
                
                #creates a new phpSortcolunm objects for name
                $col_0=new phpSortColumn("CheckToDelete","");
               
                $col_1=new phpSortColumn("proId","Id");
               
               
                $col_2 = new phpSortColumn("name", "Name");
                
                # creates a new phpSortColumn object for Tile
                $col_3 = new phpSortColumn("Fromatedprice", "Price(\$)");

                # creates a new phpSortColumn object for Field Type
                
               // $col_2 = new phpSortColumn("Duration", "Duration"); 
                 
                $col_4 = new phpSortColumn("scop", "Scope");

                # creates a new phpSortColumn object for Desplay Type   
                $col_5 = new phpSortColumn("pricegroup", "Group");
                
                $col_6 = new phpSortColumn("sortorder", "Sort");   
                
                $col_7 = new phpSortColumn("Isrecurring", "Recurring");
                      
                $col_8 = new phpSortColumn("protectedurl", "Product Url");    
                $col_9 = new phpSortColumn("upsellurl", "<center>One Click<br/>Upsell</center>");    
                

                $col_10 = new phpSortColumn("islinkedwithpaygear", "<center>Linked With <br/>PayGear</center>");  
                
                //$col_10=new phpSortColumn("isonetimeoffer","<center>One Time<br/>Offer</center>");
                $col_11=new phpSortColumn("thankyoupage","");
                $col_12=new phpSortColumn("Affiliatecommision",""); 
                # creates a new phpSortColumn object for validation function   
               

                # 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,6=>$col_6,7=>$col_7,8=>$col_8,9=>$col_9,10=>$col_10,11=>$col_11,12=>$col_12);

                # 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->encryptlink = false;
                
                # define the link for edit of entries
                $sortable->editLink = "admin_product_m.php?action=edit";
                $sortable->encryptlink=false;
                # 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
                

                
                # define the link for add new entries
                $sortable->addLink = "admin_product_m.php";

                 # set visibility of add,edit,delete link of the grid
                if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can manage products and thankyou page tracking')==false)
                {
                     $sortable->showaddLink=false; 
                     $sortable->showeditLink=false;
                     $sortable->showdeleteLink=false;
                     $lsmanageproduct=false;
                }
                # define the hint to be displyed over the add button
                $sortable->addText = "Add New Product";

                # 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?";

                # define the prompt message to be diplayed on clicking the delete button
                $sortable->deletePromptMsg = "Are you sure you want to delete this Product?";

                # define the message to be diplayed if there are no results found
                $sortable->emptyMsg = "No Product found.";

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

                $quest="&";
                if(isset($_GET) && !empty($_GET))
                 {
                     foreach($_GET as $keyname => $value) {
                          $quest.=$keyname."=".$value."&";
                        }     
                 
                 }
                $sortable->deleteLink = "admin_product_m.php?action=delete$quest";
                #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();
             if($totalrowcount>0)
             {                      
              echo '<br><br><a name="sendemail" style="text-decoration:none;"/><input type="radio" value="1" id="seluser1" name="rdlemail" class="chkcss" checked/><label for="seluser1"><b>Send Email to users who signed up selected products</b></label><br/>';
              echo '<div style="padding-left:20px;"><fieldset style="width:350px;*width:195px;">
                    <legend style="color:#55717d;"><label><strong>Product Membership Status</strong></label></legend>';
              echo '<input type="checkbox" checked="" value="Active" id="chkactive" name="chkactive" class="chkcss"/><label  for="chkactive"><b>Active</b></label><br/>
                    <input type="checkbox" checked="" value="Inactive" id="chkinactive" name="chkinactive" class="chkcss"/><label  for="chkinactive"><b>Inactive</b></label><br/>
                    <input type="checkbox" checked="" value="Pending" id="chkpending" name="chkpending" class="chkcss"/><label  for="chkpending"><b>Pending</b></label><br/>
                    <input type="checkbox" checked="" value="Expire" id="chkexpire" name="chkexpire" class="chkcss"/><label  for="chkexpire"><b>Expire</b></label><br/>';
             
              echo '</fieldset></div>';
              echo '<input type="radio" value="2" id="seluser2" name="rdlemail" class="chkcss"/><label  for="seluser2"><b>Send Email to users who didn\'t signed up selected products</b></label><br/>';
              echo '<input style="margin:5px;" type="submit" value="Click Here To Customize Your Email Message" name="btnEmailSelected" id="btnEmailSelected" class="btncss" onclick="return ValidateCheckbox(\'selected\',this.id);"/>';
             }
              echo "</div>";
              echo "</div>";
              echo "</div>";
             if($totalrowcount<=0)
             {
                 echo "<script>";
                 echo "document.getElementById('chkSelectAll').style.display='none';";
                 echo "document.getElementById('lblSelect').style.display='none';";
                 echo "</script>";
             }  
              //For display footer.php
              echo($smarty->fetch('admin_footer.php'));
              
  }
?>
Return current item: MembersGear