📄 combobox.inc
字号:
<?php
//===================================================================================
// class = Control
// methods :-
// text-combobox( $choice, $name, $data )
// retrieve-itemgroup()
// itemgroup-combobox( $tid, $groupid )
//===================================================================================
define( "A_OR_D", 0 );
define( "YES_NO", 1 );
define( "TYPE" , 2 );
define( "MARITAL", 3 );
define( "SEX", 4 );
define( "CPFIND", 5 );
define( "PAYIND", 6 );
define( "EMYEETYPE",7 );
define( "PERIOD", 8 );
define( "GROUP", 9 );
if(!class_exists('Control'))
{
class Control {
//............................................................
// private variables
//............................................................
var $vardata = array(array( array("A","Allowance"),array("D","Deduction") ),
array( array("Y","Yes"),array("N","No") ),
array( array("H","Hourly"),array("D","Daily"),array("A","Amount") ),
array( array("S","Single"),array( "M","Married") ),
array( array( "M","Male" ),array( "F","Famale") ),
array( array( "C","CPF"), array( "F","FWL") ),
array( array( "M","Mid-Month" ), array( "E","End-Month") ),
array( array( "M","Monthly" ), array( "D","Daily"), array( "H","Hourly") ),
array( array( "1","1st Half" ), array( "2","2nd Half"), array( "3","1st & 2nd"), array( "4","Bonus"), array( "5","All") ),
array( array( "0","OverTime" ), array( "A","Allowance"), array( "D","Deduction"), array( "M","Adjustment"), array( "G","General") )
);
var $maingroup;
var $group;
var $items;
//............................................................
// method 1 : build an option-box based on the choice
//............................................................
function text_combobox( $choice, $name, $code )
{
$option = $this->vardata[ $choice ];
echo "<td><select name=$name><option value=0> </option>";
foreach ( $option as $item ) {
if ( $item[0]==$code ) echo "<option Selected";
else echo "<option";
echo " value=",$item[0],">",$item[1],"</option>";
}
echo "</select></td>\r\n";
}
//............................................................
// method 2 : retrieve the description based the code
// on entry : the choice and the code
// on exit : return the description of the code
//............................................................
function text_retrieve( $choice, $code )
{
$option = $this->vardata[ $choice ];
foreach ( $option as $item ) {
if ( $item[0]==$code ) return $item[1];
}
return " ";
}
//............................................................
// method 3 : retrieve the item-group and stored in memory
//............................................................
function retrieve_itemgroup()
{
$resx = mysql_query( "Select id,itemgroup_name from item_group order by itemgroup_name;" );
$c = 0;
while ( $irow = mysql_fetch_assoc( $resx ) )
{
$this->group[$c]['id' ] = $irow['id'];
$this->group[$c]['name']= $irow['itemgroup_name'];
++$c;
}
}
//............................................................
// method 4 : build an option-box use the item-group in memory
//............................................................
function itemgroup_combobox( $tid, $groupid )
{
if ( $tid ) echo "<td><select name=ITEMGROUP",$tid,">";
else echo "<td><select name=ITEMGROUP>";
echo "<option value=0> </option>";
foreach ( $this->group as $item ) {
if ( $groupid != $item['id'] ) echo "<option value=";
else echo "<option Selected value=";
echo $item['id'],">",$item['name'],"</option>";
}
echo "</select></td>\r\n";
}
//............................................................
// method 5 : retrieve the items and stored in memory
//............................................................
function retrieve_items()
{
$resx = mysql_query( "Select id,item_name from item order by item_name;" );
$c = 0;
while ( $irow = mysql_fetch_assoc( $resx ) )
{
$this->items[$c]['id' ] = $irow['id'];
$this->items[$c]['name']= $irow['item_name'];
++$c;
}
}
//............................................................
// method 6 : build an option-box use the items in memory
//............................................................
function items_combobox( $tid, $itemid, $name="ITEM" )
{
if ( $tid ) echo "<td><select name=$name",$tid,">";
else echo "<td><select name=$name>";
echo "<option value=0> </option>";
foreach ( $this->items as $item ) {
if ( $itemid != $item['id'] ) echo "<option value=";
else echo "<option Selected value=";
echo $item['id'],">",$item['name'],"</option>";
}
echo "</select></td>\r\n";
}
//............................................................
// method 7 : retrieve the main-group and stored in memory
//............................................................
function retrieve_maingroup()
{
$resx = mysql_query( "Select id,maingroup_name from maingroup order by maingroup_name;" );
$c = 0;
while ( $irow = mysql_fetch_assoc( $resx ) )
{
$this->maingroup[$c]['id' ] = $irow['id'];
$this->maingroup[$c]['name']= $irow['maingroup_name'];
++$c;
}
}
//............................................................
// method 8 : build an option-box use the main-group in memory
//............................................................
function maingroup_combobox( $tid, $groupid )
{
if ( $tid ) echo "<td><select name=MAINGROUP",$tid,">";
else echo "<td><select name=MAINGROUP'>";
echo "<option value=0> </option>";
foreach ( $this->maingroup as $item ) {
if ( $groupid != $item['id'] ) echo "<option value=";
else echo "<option Selected value=";
echo $item['id'],">",$item['name'],"</option>";
}
echo "</select></td>\r\n";
}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -