The code that does this is the previous module developers. I really like this functionality. It would lend some great flexibility to linked categories for the helpdesk resolution reporting. My problem is I just cant find a way to make it happen as a template. Using it as a plugin is always an option as thats how I am doing it now. Having another example to look at for linked HTML select would really help me wrap my mind around it.
Can anyone point me to an example? Here is the code I am working from.
Code
extract($args);
// Args are softwareid swversionid and formname
$output = new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
$AllowVersionChoice = pnModGetVar('helpdesk', 'AllowVersionChoice');
$output->TableRowStart();
$output->TableColStart(4,'center');
$output->TableStart('','',0,'100%');
$output->TableRowStart();
$output->TableColStart(1,'center');
$output->Text(_SOFTWARE.':');
// First build the Software Drop box:
// Get Array from api
$software_data = pnModAPIFunc('helpdesk','user','softwareselect');
// Start the first Drop box
$output->Text('<select id=software_id name=software_id onChange="dropchg(this.options.selectedIndex)">');
if($softwareid == 0 ){
$output->Text('<option value=0 selected>----------------</option>');
}else{
$output->Text('<option value=0 >----------------</option>');
}
// Next, Cycle through the array
// For each pass, build a temp variable to hold the contents of the next drop box
$DynScriptSupp = '';
$iA=0;
foreach ($software_data as $softwareitem){
if($softwareid == $softwareitem[software_id]){
$itemselected=" selected";
}else{
$itemselected='';
}
// Each pass through this outer loop needs to reset $i2 to zero and increment $iA
$i2=0;
$iA++;
$output->Text('<option value='.$softwareitem[software_id].$itemselected.'>'.$softwareitem[software_name].'</option>');
if ($AllowVersionChoice){
// If we'll be doing versions, let's add corresponding software versions here!
$swversion_data = pnModAPIFunc('helpdesk','user','getswversionslist',array('selected_id'=>$softwareitem[software_id]));
$DynScriptSupp .= "group[$iA][$i2]=new Option('----------------','0')\n";
if (count($swversion_data) > 0){
foreach ($swversion_data as $swversionitem){
$i2++;
$DynScriptSupp .= "group[$iA][$i2]=new Option('".$swversionitem[name]."','".$swversionitem[id]."')\n";
} // End swversion_data loop
} // End If swversion count
} // End allowversion choice
} // End software_data loop
// End the Loop, close the Select box
$output->Text('</select>');
if ($AllowVersionChoice > 0){
$output->Text(' '._VERSION.':');
// create empty second select box ( If Option is set )
$output->Text('<select id=swversion_id name=swversion_id>');
$output->Text('<option value=-1 selected>----------------</option>');
if($swversionid > 0){
$output->Text('<option value='.$swversionid.' selected>'.pnModAPIFunc('helpdesk','user','getswversionidname',$swversionid).'</option>');
}
$output->Text('</select>');
$Drop1Count = count($software_data)+1;
// Now place the Javascript for the second box to react to the first box changes
$DynScript = "<script Language='JavaScript'>\n";
$DynScript .= "<!--\n";
$DynScript .= "var groups=".$Drop1Count."\n";
$DynScript .= "var group=new Array(groups)\n";
$DynScript .= "for (i=0; i<groups; i++)\n";
$DynScript .= "group[i]=new Array()\n";
// This first entry corresponds to the dashed entry in the first drop box
$DynScript .= "group[0][0]=new Option('----------------','0')\n";
// Cycle through and output javascript code from the versions table
// format:
// group[index of software drop][item index]=new Option('name','value')newline
// Grab the $DynScriptSupp created earlier and insert at this point
$DynScript .= $DynScriptSupp;
// Finish up the javascript code
$DynScript .= "var temp=document.".$formname.".swversion_id\n";
$DynScript .= "function dropchg(x){\n";
$DynScript .= "for (m=temp.length-1;m>0;m--)\n";
$DynScript .= "temp.options[m]=null\n";
$DynScript .= "for (i=0;i<group[x].length;i++){\n";
$DynScript .= "temp.options[i]=new Option(group[x][i].text,group[x][i].value)\n";
$DynScript .= "}\n";
$DynScript .= "temp.options[0].selected=true\n";
$DynScript .= "}\n";
$DynScript .= "//-->\n";
$DynScript .= "</script>\n";
// Finally, output the javascript code into the $output object
$output->Text($DynScript);
}
$output->TableColEnd();
$output->TableRowEnd();
$output->TableEnd();
$output->TableColEnd();
$output->TableColEnd();
$output->TableRowEnd();
return $output->GetOutput();
// Args are softwareid swversionid and formname
$output = new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
$AllowVersionChoice = pnModGetVar('helpdesk', 'AllowVersionChoice');
$output->TableRowStart();
$output->TableColStart(4,'center');
$output->TableStart('','',0,'100%');
$output->TableRowStart();
$output->TableColStart(1,'center');
$output->Text(_SOFTWARE.':');
// First build the Software Drop box:
// Get Array from api
$software_data = pnModAPIFunc('helpdesk','user','softwareselect');
// Start the first Drop box
$output->Text('<select id=software_id name=software_id onChange="dropchg(this.options.selectedIndex)">');
if($softwareid == 0 ){
$output->Text('<option value=0 selected>----------------</option>');
}else{
$output->Text('<option value=0 >----------------</option>');
}
// Next, Cycle through the array
// For each pass, build a temp variable to hold the contents of the next drop box
$DynScriptSupp = '';
$iA=0;
foreach ($software_data as $softwareitem){
if($softwareid == $softwareitem[software_id]){
$itemselected=" selected";
}else{
$itemselected='';
}
// Each pass through this outer loop needs to reset $i2 to zero and increment $iA
$i2=0;
$iA++;
$output->Text('<option value='.$softwareitem[software_id].$itemselected.'>'.$softwareitem[software_name].'</option>');
if ($AllowVersionChoice){
// If we'll be doing versions, let's add corresponding software versions here!
$swversion_data = pnModAPIFunc('helpdesk','user','getswversionslist',array('selected_id'=>$softwareitem[software_id]));
$DynScriptSupp .= "group[$iA][$i2]=new Option('----------------','0')\n";
if (count($swversion_data) > 0){
foreach ($swversion_data as $swversionitem){
$i2++;
$DynScriptSupp .= "group[$iA][$i2]=new Option('".$swversionitem[name]."','".$swversionitem[id]."')\n";
} // End swversion_data loop
} // End If swversion count
} // End allowversion choice
} // End software_data loop
// End the Loop, close the Select box
$output->Text('</select>');
if ($AllowVersionChoice > 0){
$output->Text(' '._VERSION.':');
// create empty second select box ( If Option is set )
$output->Text('<select id=swversion_id name=swversion_id>');
$output->Text('<option value=-1 selected>----------------</option>');
if($swversionid > 0){
$output->Text('<option value='.$swversionid.' selected>'.pnModAPIFunc('helpdesk','user','getswversionidname',$swversionid).'</option>');
}
$output->Text('</select>');
$Drop1Count = count($software_data)+1;
// Now place the Javascript for the second box to react to the first box changes
$DynScript = "<script Language='JavaScript'>\n";
$DynScript .= "<!--\n";
$DynScript .= "var groups=".$Drop1Count."\n";
$DynScript .= "var group=new Array(groups)\n";
$DynScript .= "for (i=0; i<groups; i++)\n";
$DynScript .= "group[i]=new Array()\n";
// This first entry corresponds to the dashed entry in the first drop box
$DynScript .= "group[0][0]=new Option('----------------','0')\n";
// Cycle through and output javascript code from the versions table
// format:
// group[index of software drop][item index]=new Option('name','value')newline
// Grab the $DynScriptSupp created earlier and insert at this point
$DynScript .= $DynScriptSupp;
// Finish up the javascript code
$DynScript .= "var temp=document.".$formname.".swversion_id\n";
$DynScript .= "function dropchg(x){\n";
$DynScript .= "for (m=temp.length-1;m>0;m--)\n";
$DynScript .= "temp.options[m]=null\n";
$DynScript .= "for (i=0;i<group[x].length;i++){\n";
$DynScript .= "temp.options[i]=new Option(group[x][i].text,group[x][i].value)\n";
$DynScript .= "}\n";
$DynScript .= "temp.options[0].selected=true\n";
$DynScript .= "}\n";
$DynScript .= "//-->\n";
$DynScript .= "</script>\n";
// Finally, output the javascript code into the $output object
$output->Text($DynScript);
}
$output->TableColEnd();
$output->TableRowEnd();
$output->TableEnd();
$output->TableColEnd();
$output->TableColEnd();
$output->TableRowEnd();
return $output->GetOutput();
