Location: PHPKode > projects > MembersGear > membersgear/admin/admin_country_state_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 view countries/states')==false)
  {
        Redirect('admin_nopermission.php',true);  
      
  } 
 //for display the header.php
          echo($smarty->fetch('admin_header.php'));
          echo "<div id=\"content\" class=\"setdiv\"> "; 
           if(isset($_GET['sortby']) and isset($_GET['sortdir']) and isset($_GET['begin']) and isset($_GET['rows']))
           {
                $_SESSION['gsStateQueryStr'] = 'sortby='.$_GET['sortby'].'&sortdir='.$_GET['sortdir'].'&begin='.$_GET['begin'].'&rows='.$_GET['rows'];
           }
           
           if(!isset($_GET['id']) or $_GET['id'] == '' or !(is_numeric($_GET['id'])))
           {
               Redirect('admin_country_v.php'); 
           }
           
            if($message->IsMessageExists())
           {    
                $lsmsg=$message->GetMessage();
                echo "<div class=\"succmsg\" style=\"width:400px\">$lsmsg</div>";
           }
           
           if(!isset($_GET['sortby'])) $_GET['sortby']='name';
           if(!isset($_GET['sortdir'])) $_GET['sortdir']='ASC';
           
           
            if(isset($_GET['letter']) and $_GET['letter'] != 'all')
            {
                $lsSearchLetter = $_GET['letter'];
            }
            else
            {
                $lsSearchLetter = '';   
            }
                
           $sql = 'SELECT p.id,p.name,case when p.type=1 then \'Country\' else \'State\' end as `LocationType`,
               case when p.parentid=0 then \'-\' else l.name end as `ParentLocation`,
               case when p.status=1 then \'Active\' else \'InActive\' end as `Status`,
               \'View State\' as `Manage`
               FROM '.TABLE_PREFIX.'location p 
               left join '.TABLE_PREFIX.'location l on l.id=p.parentid
               where p.type=2 and p.parentid='.$_GET['id'].' and p.name like \''.$lsSearchLetter.'%\'';

            
            echo "<div id=\"full-contentdiv\">";
            echo "<div class=\"righttop\">";
            echo "<h2 align=\"center\">";
            echo "Country State List";
            echo "</h2>";
            echo "</div>";
            echo "<div class=\"whole-page clear\">";
            $name = mysql_fetch_array(mysql_query($sql));                        
            echo "<div style=\"width:100%;color:#093854;font-weight:bold;clear:both;overflow:hidden;\">";
            echo"<div style=\"float: left; width: 50%;\"><span style=\"margin-left:4px;\"><a href=\"admin_country_v.php\">Back To Countries List</a></span></div>";
            //echo"<div style=\"float:left;text-align:center;width:82%;\"><span style=\"text-align:center;margin-left:-150px;font-size:15px;font-weight:bold;\">$name[3]'s States</span></div>";
            echo "</div>";
            
            /****************************************************************************
            * Updated By Jayesh : for display character based paging
            *****************************************************************************/
            echo "<div style=\"width:56%;text-align:center;margin:2px;padding-left:60px\">";
            echo PrintABCDPaging();
            echo "</div>";
             
            /*
            echo "<form id=\"frmSearch\" name=\"frmSearch\" action=\"\" method=\"GET\">";
            echo "<div style=\"float:right\">";
            echo "<input type=\"text\" id=\"q\" name=\"q\" value=\"".$_GET['q']."\" class=\"txtcss\" style=\"width:180px;\" maxlength=\"100\">&nbsp;&nbsp;";
            echo "<input type=\"hidden\" id=\"id\" name=\"id\" value=\"".$_GET['id']."\">";
            echo "<input type=\"submit\" value=\"Search\" id=\"submit\" name=\"submit\" class=\"btncss\">";
            echo "</div>";
            echo "</form>";
             */
            
            
           // echo "<div style=\"margin-left:4px;width:200px;font-weight:bold;\"></div>";
                
          //echo $res;
               /* $sql = 'SELECT p.id,p.name,case when p.type=1 then \'Country\' else \'State\' end as `LocationType`,
               case when p.parentid=0 then \'-\' else l.name end as `ParentLocation`,
               case when p.status=1 then \'Active\' else \'InActive\' end as `Status`,
               \'View State\' as `Manage`
               FROM '.TABLE_PREFIX.'location p 
               left join '.TABLE_PREFIX.'location l on l.id=p.parentid
               where p.type=2 and p.parentid='.$_GET['id'];*/
           /*
           if(isset($_GET) and $_GET['submit'] == 'Search')
           {
               $sql .= " and p.name like '".$_GET['q']."%';";
           }*/
           
                # execute the sql query
                $db->execute($sql);
                
                # 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("name", "Name");
                
                # creates a new phpSortColumn object for Tile
                $col_1 = new phpSortColumn("LocationType", "Type");

                # creates a new phpSortColumn object for Field Type
                $col_2 = new phpSortColumn("ParentLocation", "Parent Location");

                $col_3 = new phpSortColumn("Status","Status");
                
                //$col_4 = new phpSortColumn("Manage", "","",'link','admin_country_state_v.php?','images/phpgrid/a_view.gif','','_self');
                
                # add the columns to an array 
                $columns = array(0=>$col_0, 1=>$col_1, 2=>$col_2, 3=>$col_3);

                # 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_country_state_m.php?action=edit";

                # 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
                $quest="&";
                if(isset($_GET) && !empty($_GET))
                 {
                     foreach($_GET as $keyname => $value) {
                          $quest.=$keyname."=".$value."&";
                        }     
                 
                 }
                $sortable->deleteLink = "admin_country_state_m.php?action=delete$quest";

                # define the link for add new entries
                $sortable->addLink = "admin_country_state_m.php?parentid=".$_GET['id'];

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

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

                # define the message to be diplayed if there are no results found
                $sortable->emptyMsg = "No State 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 "<input type=\"hidden\" id=\"hdnParentID\" name=\"hdnParentID\" value=\"".$_GET['id']."\">";
              echo "</div>";
              echo "</div>";
              echo "</div>";
                
              //For display footer.php
              echo($smarty->fetch('admin_footer.php'));   
 
?>
Return current item: MembersGear