Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
Donovan
Client


Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Tue Feb 03, 2009 6:44 pm Reply with quote

I am reworking a module I built awhile ago and have a bug I can't figure out.

I am moving all the admin pages inside a single index.php and building functions with each one.

Some of the pages come up fine but a handfull don't. My main admin panel looks like the following. It uses a new tab menu I found.

Code:
function milpacs($panel) {

    global $prefix, $db, $admin_file, $bgcolor2, $bgcolor3;
   tabmenu();
    include("header.php");   
    OpenTable();
    echo "<center><strong>MILPACS Administration</strong><br /><br />\n";
   echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel1');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Configuration</a>";
    echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel2');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Soldiers</a>";
    echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel3');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Ranks</a>";
   echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel4');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Medals</a>";
   echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel5');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Weapons</a>";
    echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel6');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Units</a>";
    echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel7');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Combat</a>";
   echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel8');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Drills</a>";
   echo "<a href=\"#\" class=\"tab\" onclick=\"return showPanel(this, 'panel9');\" STYLE=\"text-decoration:none\"><img src=\"modules/MILPACS/images/folder.gif\" width=\"10\" height=\"10\" border=\"0\"> Attendance</a></center>";
   
   if ($panel=="configuration"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel1\" $panstyle>";
   configuration();
   echo "</div>";
   if ($panel=="soldiers"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel2\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";   
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add New Soldier\"><input name=\"op\" type=\"hidden\" value=\"addsoldier\"></form>";
   rostermanager();
   echo "</div>";
   if ($panel=="ranks"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel3\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add New Rank\"><input name=\"op\" type=\"hidden\" value=\"addrank\"></form>";
   ranksmanager();   
   echo "</div>";
   if ($panel=="medals"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel4\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add New Medal\"><input name=\"op\" type=\"hidden\" value=\"addmedal\"></form>";
   medalsmanager();   
   echo "</div>";
   if ($panel=="Weapons"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel5\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add New Weapon\"><input name=\"op\" type=\"hidden\" value=\"addweapon\"></form>";
   weaponsmanager();   
   echo "</div>";
   if ($panel=="Units"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel6\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add Combat Unit\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add Admin Unit\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add Squad\">";
   echo "<input name=\"op\" type=\"hidden\" value=\"AddUnit\">";
   echo "<input name=\"op\" type=\"hidden\" value=\"AddAdminUnit\">";
   echo "<input name=\"op\" type=\"hidden\" value=\"AddSubUnit\"></form>";
   unitmanager();
   echo "</div>";
   if ($panel=="Combat"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel7\" $panstyle>";   
   listmatches();
   echo "<input name=\"op\" type=\"hidden\" value=\"createchallenge\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Ok\">";
   echo "</form>";
   echo "</div>";
   if ($panel=="Drills"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel8\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add New Drill\"><input name=\"op\" type=\"hidden\" value=\"AddDrillReport\"></form>";
   drillmanager();   
   echo "</div>";
   if ($panel=="Attendance"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel9\" $panstyle>";
   attendancemanager();
   echo "</div>";
   CloseTable();
   echo "<br>";   
   
   }


The form inside here are not passing the hidden value where the case statement sends it to the proper function.
Code:


if ($panel=="soldiers"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel2\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";   
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add New Soldier\"><input name=\"op\" type=\"hidden\" value=\"addsoldier\"></form>";
   rostermanager();
   echo "</div>";



The switch statement looks like this.

Code:
switch($op) {

case "gamesmanager":
         gamesmanager();      
         break;         
      case "addsoldier":
         addsoldier();
         break;
      case "insertsoldier":
         insertsoldier();
         break;
}


And my case.php looks like this:

Code:
switch($op) {

      
case "addsoldier":
      case "insertsoldier":
      case "editsoldier":
      case "updatesoldier":
include("modules/$module_name/admin/index.php");
   break;
}


I get a blank page where the url ends in /admin.php

I am stuck.
 
View user's profile Send private message Visit poster's website ICQ Number
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Tue Feb 03, 2009 10:21 pm Reply with quote

I don't understand how the first part is called, based on the last 3 bits of code. $op looks like its properly defined and should call function addsoldier()

How is this part called?
Code:


function milpacs($panel) {

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Donovan
PostPosted: Wed Feb 04, 2009 6:12 am Reply with quote

From my case.php
Code:


switch($op) {
      
       case "milpacs":
       case "rostermanager":
            etc...
            etc...

include("modules/$module_name/admin/index.php");
   break;
}


Where milpacs is my admin menu

and this is defined in links.php

Code:
adminmenu($admin_file.'.php?op=milpacs', _MILPACS_MENU, 'milpacs.png');
 
evaders99
PostPosted: Wed Feb 04, 2009 8:12 pm Reply with quote

Again, I really don't understand what the issue is.
The case calls
Code:


include("modules/$module_name/admin/index.php");

Which just includes the admin file.

Where in the admin file does this lead to a call into the milpacs function?
 
Donovan
PostPosted: Wed Feb 04, 2009 8:48 pm Reply with quote

evaders99 wrote:

Where in the admin file does this lead to a call into the milpacs function?


This is at the top of the admin/index.php

Code:
switch($op) {


      case "milpacs":
         milpacs("configuration");      
         break;
      case "configuration":
         configuration();
         break;                  
      case "rostermanager":
         rostermanager();      
         break;
                case "addsoldier":
         addsoldier();
         break;
      case "insertsoldier":
         insertsoldier();
         break;
}
 
evaders99
PostPosted: Wed Feb 04, 2009 8:55 pm Reply with quote

Nothing obviously wrong. I think you're going to have to give us more details
What specifically is being accessed that is causing the white page?
 
Donovan
PostPosted: Wed Feb 04, 2009 8:59 pm Reply with quote

Pretty much anything in my milpacs function. I get a white page whenever I click on anything in the tabbed menu.

For example this form button to add a soldier.

Code:


if ($panel=="soldiers"){$panstyle="";}else{$panstyle="style=\"display: none\"";}
   echo "<div class=\"panel\" id=\"panel2\" $panstyle>";
   echo "<form action=\"".$admin_file.".php\" method=\"post\">";   
   echo "<input name=\"Submit\" type=\"Submit\" value=\"Add New Soldier\"><input name=\"op\" type=\"hidden\" value=\"addsoldier\"></form>";
   rostermanager();
   echo "</div>";
 
evaders99
PostPosted: Wed Feb 04, 2009 10:00 pm Reply with quote

I see this menu uses Javascript
Code:


onclick=\"return showPanel(this, 'panel1');\"


Where is the Javascript function "showPanel" defined?
 
Donovan
PostPosted: Wed Feb 04, 2009 10:05 pm Reply with quote

Code:
function tabmenu(){

    global $prefix, $db, $bgcolor2, $bgcolor3;   
echo "
 <style type=\"text/css\">
     a.tab {
        border-collapse: collapse;
        border-style: solid solid none solid;
        border-color: $bgcolor2;
        border-width: 1px 1px 0px 1px;
        background-color: $bgcolor2;
        padding: 2px 0.5em 1px 0.5em;
        margin-top: 4px;
        font-family: arial;
        text-decoration: none;
      }
          a.tab2 {
        border-collapse: collapse;
        border-style: solid solid solid solid;
        border-color: $bgcolor2;
        border-width: 1px 1px 1px 1px;
        background-color: $bgcolor2;
        padding: 2px 0.5em 1px 0.5em;
        margin-top: 4px;
        font-family: arial;
        text-decoration: none;
      }
      a.tab:hover {
        border-color: $bgcolor2;
        background-color: $bgcolor3;
      text-decoration: none;
       text-decoration: bold;
      }
      a.tab2:hover {
        border-color: $bgcolor2;
        background-color: $bgcolor3;
      text-decoration: none;
       text-decoration: bold;
      }
      .panel { border: solid 1px $bgcolor2; background-color: $bgcolor1; padding: 5px; height: 300px; overflow: none;
     text-decoration: none;}
    </style>";
   ?>
    <script language="JavaScript" type="text/javascript">
      var panels = new Array('panel1', 'panel2', 'panel3', 'panel4', 'panel5', 'panel6', 'panel7', 'panel8','panel9');
      var selectedTab = null;
      function showPanel(tab, name)
      {
        if (selectedTab)
        {
          selectedTab.style.backgroundColor = '<? echo"$bgcolor2";?>';
          selectedTab.style.paddingTop = '';
          selectedTab.style.paddingBottom = '2px';
        }
        selectedTab = tab;
        selectedTab.style.backgroundColor = '<? echo"$bgcolor3";?>';
        selectedTab.style.paddingTop = '4px';
        for(i = 0; i < panels.length; i++)
        {
          document.getElementById(panels[i]).style.display = (name == panels[i]) ? 'block':'none';
        }
        return false;
      }
    </script>
<?

}
 
evaders99
PostPosted: Wed Feb 04, 2009 10:21 pm Reply with quote

Sorry I must not be looking at this right, I'm confused. All showPanel does is activate some part of the existing HTML on the page using JavaScript on the client.
That is distinct from milpacs($panel) function used in PHP on the server.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©