Location: PHPKode > projects > MembersGear > membersgear/admin/admin_fields_v.php
<?php       
  require_once "../config/config.php";
  require_once "../includes/fields_class.php";
  require_once INCLUDE_DIR."/users_class.php";  
  $users=new users_class();
   
  if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
      unset($_SESSION[SESSION_PREFIX.'page_referrer']);
      
  if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can view  fields')==false)
  {
        Redirect('admin_nopermission.php',true);  
  }    
  /**************************** Set Field order *****************************/
             if ($_SERVER['REQUEST_METHOD'] == 'POST')
            {
                $loFieldClass = new fields_class();
                
                $lsFormSortValues = $_POST['phpgridtextbox'];
                $lsFormSortValuesID = $_POST['phpgridid'];
                
                $loFieldClass->setFieldOrder($lsFormSortValues,$lsFormSortValuesID);
                
                $message->SetMessage('Field order updated successfully.');
                 
            }
 /*************************************************************/
 //for display the header.php            
          echo($smarty->fetch('admin_header.php'));
           
           echo "<div id=\"content\" class=\"setdiv\"> ";
            
          /* 
           echo "<pre>";
           echo "      textbox=<br>";
           print_r($_POST['phpgridtextbox']);
           echo "       id=<br>";
           print_r($_POST['phpgridid']);
           echo "</pre>";
              */
            #
            
            
            if($message->IsMessageExists())
            {    
                $lsmsg=$message->GetMessage();
                echo "<div class=\"succmsg\" style=\"width:200px\">$lsmsg</div>";
            }
            
            
            echo "<div id=\"full-contentdiv\">";
            echo "<div class=\"righttop\">";
            echo "<h2 align=\"center\">";
            echo "Additional Fields";
            echo "</h2>";
            echo "</div>";
            echo "<div class=\"whole-page clear\">";
            echo "<form name=\"form1\" action=\"\" method=\"POST\">";
            /****************************************************************************
            * 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 p.`id`, concat(p.`name`,\'<input type="hidden" name="phpgridid[]" value="\',p.`id`,\'" id="phpgridid[]" />\') as `name`,
                          p.`label`, p.`description`, p.`displaytype`, p.`datatype`, p.`property`,
                          p.`defaultvalue`, p.`signupformvisibility`, p.`profileformvisibility`,
                          p.`validationfurnction`, p.`createdon`, p.`createdby`, p.`createdipaddress`,
                          p.`modifiedon`, p.`modifiedby`, p.`modifiedipaddress`, p.`sortorder`
                        FROM '.TABLE_PREFIX.'singupformfields p order by name asc;';
                 */
                 
                  $sql = 'SELECT p.`id`, concat(p.`name`,\'<input type="hidden" name="phpgridid[]" value="\',p.`id`,\'" id="phpgridid[]" />\') as `name`,
                          p.`label`, p.`description`, p.`displaytype`, p.`datatype`, p.`property`,
                          p.`defaultvalue`,case when p.`signupformvisibility`=1 then "Display and allow editing" else "Don\'t display" end as `Visibility`, p.`profileformvisibility`,
                          p.`validationfurnction`, p.`createdon`, p.`createdby`, p.`createdipaddress`,
                          p.`modifiedon`, p.`modifiedby`, p.`modifiedipaddress`, p.`sortorder`
                        FROM '.TABLE_PREFIX.'singupformfields p where p.name like \''.$lsSearchLetter.'%\' order by name asc;';
                 
                # 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("label", "Title");

                # creates a new phpSortColumn object for Field Type
                //$col_2 = new phpSortColumn("datatype", "Field Type");

                # creates a new phpSortColumn object for Desplay Type   
                $col_3 = new phpSortColumn("displaytype", "Display Type");

                # creates a new phpSortColumn object for validation function   
                $col_4 = new phpSortColumn("validationfurnction", "Validation function");
                
                $col_5=new phpSortColumn("Visibility","Visibility");
                
                $col_6 = new phpSortColumn("sortorder", "Order","",'HTML_INPUT_TEXT'); 

                # add the columns to an array 
                $columns = array(0=>$col_0, 1=>$col_1,  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->encryptlink = false;
                
                # define the link for edit of entries
                $sortable->editLink = "admin_fields_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_fields_m.php?action=delete$quest";

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

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

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

                # define the message to be diplayed if there are no results found
                $sortable->emptyMsg = "No Field 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();
              if($lbsortbuttonvisible==true)
              {
                  echo "<div style=\"text-align:right;padding:2px\">";
                  echo '<input style="margin-left:755px;margin-top:5px;" type="submit" value="Update Order" name="btnUpdateOrder" id="btnUpdateOrder" class="btncss" />';  
                  echo "</div>";
              }
              echo "</form>";  
              echo "</div>";
              echo "</div>";
              echo "</div>";
                
              //For display footer.php
              echo($smarty->fetch('admin_footer.php'));
              
              
              
              echo "
              
                    <script>
                    
                        function IsNumericPhpGridTextbox()
                        {
                            var result=true;
                            var phpgridtextboxes = document.getElementsByName('phpgridtextbox[]');
  
                            for(i=0;i<phpgridtextboxes.length;i++)
                            {
                              if(rtrim(ltrim(phpgridtextboxes[i].value))=='')
                               {
                                    alert('Please enter valid Order.');
                                    phpgridtextboxes[i].focus();
                                    result = false;
                                    break;
                               }     
                               if(isNaN(phpgridtextboxes[i].value))
                               {
                                    alert('Please enter valid Order.');
                                    phpgridtextboxes[i].focus();
                                    result = false;
                                    break;
                               }     
                            }
                            
                            return result;
                        }
                        
                        var frmvalidator  = new Validator('form1');  
                        frmvalidator.setAddnlValidationFunction('IsNumericPhpGridTextbox');
                        
                    </script>
              
              ";   
 
?>
Return current item: MembersGear