<?php

$code = $_REQUEST["code"];
$obj1 = $_REQUEST["obj1"];
$obj2 = $_REQUEST["obj2"];
$obj3 = $_REQUEST["obj3"];
$obj4 = $_REQUEST["obj4"];
$obj5 = $_REQUEST["obj5"];
$obj6 = $_REQUEST["obj6"];
$obj7 = $_REQUEST["obj7"];

include "include/config.php";
include "include/functions.php";
include "include/fifo.php";


switch($_REQUEST["code"]) {

            case "xx":
                $html=pageDataLaporan($_SERVER["PHP_SELF"],"",$_REQUEST['page'],"","",$_REQUEST['page_count']);
               
                ?>
                    div = document.getElementById('page_laporan');
                    var m='<?php echo js_esc($html); ?>';
                    m= m.replace(/^\s*|\s*$/g,"");
                    div.innerHTML =m;
                <?php
                    break;

                case "17";
                      $html=GetUser();
                      ?>
                      document.getElementById("txtHint").innerHTML='<?php echo $html; ?>';
                      <?php
                     break;
                case "16":
                      $ssql="SELECT a.ftstock_in_no,ftstock_in_company
                              FROM txstock_in_hdr A
                              WHERE a.ftstock_in_no='{$_REQUEST['value']}'";

                      $rs=mysql_query($ssql);
                      $r=mysql_fetch_assoc($rs);
                      $ftcustomer_code=$r['ftstock_in_company'];

                      $ssql1="SELECT ftcustomer_name FROM tlcustomer WHERE ftcustomer_code='{$ftcustomer_code}'";
                      $rs1=mysql_query($ssql1);
                      $r1=mysql_fetch_assoc($rs1);
                      $ftcustomer_name=$r1['ftcustomer_name'];

                      #$html="<input type=hidden id=ftstock_out_company name=ftstock_out_company value=\"{$ftcustomer_code}\">{$ftcustomer_name}";

                       $html.="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";
                        $html.="<td>";
                        $html.="<input id=\"ftstock_out_company\" name=\"ftstock_out_company\" size=\"25\" maxlength=\"20\" value=\"{$ftcustomer_code}\"  readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="</td>";

                                        $html.="<td>";
                        $html.="<input id=\"hidden_ftstock_out_company\" name=\"hidden_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"{$ftcustomer_name}\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="</td>";
                        $html.="</tr>";
                        $html.="</tbody></table>";
                        $ajaxreturn="ajax_do('inventory.php?id=0&form=barang_keluar&mode=edit&ajax=1&code=return&ftdocument_no={$_REQUEST['value']}');";
                     ?>
                      document.getElementById("DivCtl_ftstock_out_company").innerHTML='<?php echo $html; ?>';
                        <?php echo $ajaxreturn; ?>
                      
                       
                    <?php
                    break;
                case "15":
                    if($_REQUEST["value"]=="0") { // retur pembelian
                          $ssql="SELECT DISTINCT a.ftstock_in_no,a.ftstock_in_company,a.ftreff_no
                                        FROM txstock_in_hdr a INNER JOIN txstock_in_det b ON  a.ftstock_in_no=b.ftstock_in_no
                                        LEFT JOIN (SELECT a.ftdocument_no,b.ftitem_code_change,IFNULL(SUM(b.fnqty),0) AS fnqty
                                                        FROM txstock_out_hdr a,txstock_out_det b
                                                        WHERE a.ftstock_out_no=b.ftstock_out_no
                                                        AND a.fnstatus=1 AND a.ftcategory_code='0'
                                                        GROUP BY a.ftdocument_no,b.ftitem_code
                                                    ) c
                                        ON a.ftstock_in_no=c.ftdocument_no AND b.ftitem_code=c.ftitem_code_change
                                        WHERE a.fnstatus=1 AND a.ftcategory_code='4' AND b.fnqty-IFNULL(c.fnqty,0)>0";
                        
                          $rs=mysql_query($ssql);
                          $m=" onChange=\"ajax_do(\'query2.php?code=16&value=\' + this.value +\'\');\"";
                          $html1="<select id=\"ftdocument_no\" name=\"ftdocument_no\" class=\"text\" $m>";
                          $i=0;
                          $ftcustomer_name="";
                          $html1.="<option value=\"\">--PILIH--</option>";
                          while($r=mysql_fetch_assoc($rs)) {
                              if($i==0) {
                                  $ftcustomer_code=$r['ftstock_in_company'];
                                  $ssql1="SELECT ftcustomer_name FROM tlcustomer WHERE ftcustomer_code='{$ftcustomer_code}'";
                                  $rs1=mysql_query($ssql1);
                                  $r1=mysql_fetch_assoc($rs1);
                                  $ftcustomer_name=$r1['ftcustomer_name'];
                              }
                              $html1.="<option value=\"{$r['ftstock_in_no']}\">{$r['ftstock_in_no']}--{$r['ftreff_no']}</option>";
                          }
                        $html1.="</select>";

                        $html.="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";
                        $html.="<td>";
                        $html.="<input id=\"ftstock_out_company\" name=\"ftstock_out_company\" size=\"25\" maxlength=\"20\" value=\"{$ftcustomer_code}\"  readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="</td>";
                        $html.="<td>";
                        $html.="<input id=\"hidden_ftstock_out_company\" name=\"hidden_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"{$ftcustomer_name}\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="<input id=\"span_ftstock_out_company\" name=\"span_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"hidden\">";
                        $html.="</td>";
                        $html.="</tr>";
                        $html.="</tbody></table>";
                         $ajaxreturn="ajax_do('inventory.php?id=0&form=barang_keluar&mode=edit&ajax=1&code=return&ftdocument_no={$r['ftstock_in_no']}');";
                         ?>
                            
                         <?php
                    }
                    // free, sample, pinjaman
                    elseif(($_REQUEST["value"]=="1") or ($_REQUEST["value"]=="2") or ($_REQUEST["value"]=="3")) {
                        $html.="</select>";
                        $html.="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";
                        $html.="<td>";
                        if ($_REQUEST["ftstock_type_code"] == 'inv') {
                            $html.="<input id=\"ftstock_out_company\" name=\"ftstock_out_company\" size=\"25\" maxlength=\"20\" value=\"\" onkeyup=\"ajax_showOptions(this, \'getCountriesByLetters\', event, \'SELECT ftcustomer_code, ftcustomer_name FROM tlcustomer\', \'ftcustomer_code\', \'ftcustomer_name\')\" type=\"text\">";
                        } else {
                            $html.="<input id=\"ftstock_out_company\" name=\"ftstock_out_company\" size=\"25\" maxlength=\"20\" value=\"\" onkeyup=\"ajax_showOptions(this, \'getCountriesByLetters\', event, \'SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier\', \'ftsupplier_code\', \'ftsupplier_name\')\" type=\"text\">";
                        }
                        $html.="</td>";

                        $html.="<td>";
                        $html.="<input id=\"hidden_ftstock_out_company\" name=\"hidden_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="<input id=\"span_ftstock_out_company\" name=\"span_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"hidden\">";
                        $html.="</td>";
                        $html.="</tr>";
                        $html.="</tbody></table>";
                        $html1="<input type=\"text\" id=\"ftdocument_no\" name=\"ftdocument_no\">";
                   }
                   // tukar barang
                    elseif (($_REQUEST["value"]=="7")) {
                        $html.="</select>";
                        $html.="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";
                        $html.="<td>";
                        $html.="<input id=\"ftstock_out_company\" name=\"ftstock_out_company\" size=\"25\" maxlength=\"20\" value=\"\" onkeyup=\"ajax_showOptions(this, \'getCountriesByLetters\', event, \'SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier\', \'ftsupplier_code\', \'ftsupplier_name\')\" type=\"text\">";
                        $html.="</td>";

                        $html.="<td>";
                        $html.="<input id=\"hidden_ftstock_out_company\" name=\"hidden_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="<input id=\"span_ftstock_out_company\" name=\"span_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"hidden\">";
                        $html.="</td>";
                        $html.="</tr>";
                        $html.="</tbody></table>";
                        $html1="<input type=\"text\" id=\"ftdocument_no\" name=\"ftdocument_no\">";
                   }
                   // outsource
                   elseif($_REQUEST["value"]=="6") {
                        if ($_REQUEST["ftstock_type_code"] == 'inv') {
                            $fnpo_type3="3";
                            $ajaxreturn="ajax_do(\'inventory.php?id=0&form=barang_keluar&mode=edit&ajax=1&code=outsource&ftdocument_no=\' + this.value + \'\');";
                        } else if ($_REQUEST["ftstock_type_code"] == 'invbb') {
                            $fnpo_type3="0";
                            $ajaxreturn="ajax_do(\'inventory_bahan_baku.php?id=0&form=inventorybb_stock_keluar&mode=edit&ajax=1&code=outsource&ftdocument_no=\' + this.value + \'\');";
                        } else if ($_REQUEST["ftstock_type_code"] == 'invsj') {
                            $fnpo_type3="1";
                            $ajaxreturn="ajax_do(\'inventory_setengah_jadi.php?id=0&form=inventorysj_barang_keluar&mode=edit&ajax=1&code=outsource&ftdocument_no=\' + this.value + \'\');";
                        } else if ($_REQUEST["ftstock_type_code"] == 'invsp') {
                            $fnpo_type3="2";
                            $ajaxreturn="ajax_do(\'inventory_sparepart.php?id=0&form=inventorysp_barang_keluar&mode=edit&ajax=1&code=outsource&ftdocument_no=\' + this.value + \'\');";
                        }

                        $ftsupplier_code=$_REQUEST["ftstock_out_company"];
                        
                        $ssql="SELECT DISTINCT a.ftpo_no, a.ftsupplier_code, a.ftsupplier_name
                                        FROM txpurchase_order_hdr a
                                        WHERE a.fnstatus=1 AND a.fnreceipt_status <> 3 and ftsupplier_code='{$ftsupplier_code}' and fnhdr_category=1";
                        $rs=mysql_query($ssql);
                        
                        $m=" onChange=\"ajax_do(\'query2.php?code=15&value={$_REQUEST["value"]}&ftstock_type_code={$_REQUEST["ftstock_type_code"]}&ftstock_out_company={$ftsupplier_code}&ftdocument_no=\' + this.value + \'\');\"";
                        $html1="<select id=\"ftdocument_no\" name=\"ftdocument_no\" class=\"text\" $m>";
                        $i=0;
                        $vSelected = "";

                        $html1.="<option value=\"\">--PILIH--</option>";
                        while($r=mysql_fetch_assoc($rs)) {
                            if ($r['ftpo_no'] == $_REQUEST['ftdocument_no']) {
                                $vSelected = "Selected";
                                $ftsupplier_code = $r['ftsupplier_code'];
                            } else {
                                $vSelected = "";
                            }

                            $html1.="<option {$vSelected} value=\"{$r['ftpo_no']}\">{$r['ftpo_no']}</option>";
                        }
                        $html1.="</select>";

                        if ($ftsupplier_code != "") {
                            $ssql1="SELECT ftsupplier_name FROM tlsupplier
                                        WHERE ftsupplier_code='{$ftsupplier_code}'";

                            $rs1=mysql_query($ssql1);
                            $r1=mysql_fetch_assoc($rs1);
                            $ftsupplier_name=$r1['ftsupplier_name'];
                        }

                        $m=" onChange=\"ajax_do(\'query2.php?code=15&value={$_REQUEST["value"]}&ftstock_type_code={$_REQUEST["ftstock_type_code"]}&ftstock_out_company=\' + this.value + \'\');\"";

                        $html.="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";
                        $html.="<td>";
                        $html.="<input id=\"ftstock_out_company\" name=\"ftstock_out_company\" size=\"25\" maxlength=\"20\" value=\"{$ftsupplier_code}\"{$m} onkeyup=\"ajax_showOptions(this, \'getCountriesByLetters\', event, \'SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier\', \'ftsupplier_code\', \'ftsupplier_name\')\" type=\"text\">";
                        $html.="</td>";
                        $html.="<td>";
                        $html.="<input id=\"hidden_ftstock_out_company\" name=\"hidden_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"{$ftsupplier_name}\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="<input id=\"span_ftstock_out_company\" name=\"span_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"hidden\">";
                        $html.="</td>";
                        $html.="</tr>";
                        $html.="</tbody></table>";
                        
                   }
                   else {
                        $html.="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";
                        $html.="<td>";
                        $html.="<input id=\"ftstock_out_company\" name=\"ftstock_out_company\" size=\"25\" maxlength=\"20\" value=\"{$ftcustomer_code}\"  readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="</td>";

                        $html.="<td>";
                        $html.="<input id=\"hidden_ftstock_out_company\" name=\"hidden_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"{$ftcustomer_name}\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"text\">";
                        $html.="<input id=\"span_ftstock_out_company\" name=\"span_ftstock_out_company\" size=\"40\" maxlength=\"20\" value=\"\" readonly=\"readonly\" style=\"background-color: rgb(224, 224, 224);\" type=\"hidden\">";
                        $html.="</td>";
                        $html.="</tr>";
                        $html.="</tbody></table>";
                        $html1="<input type=\"text\" id=\"ftdocument_no\" name=\"ftdocument_no\">";
                   }
                     
                    ?>
                     
                      document.getElementById("DivCtl_ftdocument_no").innerHTML='<?php echo $html1; ?>';
                      document.getElementById("DivCtl_ftstock_out_company").innerHTML='<?php echo $html; ?>';
                        
                    <?php
                    die("");
                    break;
             
                case "14": // Generate Control Suplier Customer Stock Masuk
                    $html="<select id=\"ftstock_in_company\" name=\"ftstock_in_company\" class=\"text\">";

                    if($_REQUEST["value"]=="0") {
                          $html.="<option value=\"\"></option>";
                    }
                    elseif($_REQUEST["value"]=="1") { // Pembelian
                         $ssql="SELECT ftsupplier_code,ftsupplier_name FROM tlsupplier ORDER BY ftsupplier_name";
                         $rs=mysql_query($ssql);
                         while($r=mysql_fetch_assoc($rs)) {
                             $html.="<option value=\"{$r['ftsupplier_code']}\">{$r['ftsupplier_name']}</option>";
                         }
                    }
                    elseif($_REQUEST["value"]=="2") {
                         $ssql="SELECT ftcustomer_code,ftcustomer_name FROM tlcustomer ORDER BY ftcustomer_name";
                         $rs=mysql_query($ssql);
                         while($r=mysql_fetch_assoc($rs)) {
                             $html.="<option value=\"{$r['ftcustomer_code']}\">{$r['ftcustomer_name']}</option>";
                         }
                    }
                    $html.="</select>";
                    
                    
                    ?>
                      document.getElementById("DivCtl_ftstock_in_company").innerHTML='<?php echo $html; ?>';
                    <?php
                break;
         // ftuom_code
	case "uom":
			$result = mysql_query("SELECT ftuom_code FROM tlstock_hdr WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0];
			?>
                            document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
               <?
			break;
        case "uom_bahan_baku":
			$result = mysql_query("SELECT ucase(ftuom_code) as ftuom_code FROM tlstock_hdr_bahan_baku WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0];
			?>
                            document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
               <?
			break;
         case "uom_setengah_jadi":
			$result = mysql_query("SELECT ucase(ftuom_code) as ftuom_code  FROM tlstock_hdr_setengah_jadi WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0];
			?>
                            document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
               <?
			break;
         case "1d":
			$result = mysql_query("SELECT ucase(ftuom_code) as ftuom_code  FROM vBomDetail_Type WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0];
			?>
                            document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
               <?
			break;

        case "uom_sparepart":
			$result = mysql_query("SELECT ucase(ftuom_code) as ftuom_code  FROM tlstock_hdr_sparepart WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0];
			?>
                            document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
               <?
			break;
        case "uom_list":
                $ftUOM_Code1=RetRstField("SELECT UCASE(ftUOM_Code) as ftUOM_Code  FROM tlstock_hdr WHERE ftitem_code='{$_REQUEST['ftitem_code']}'");
                $ftUOM_Code="SELECT UCASE(a.ftUOM_Code) AS ftuom_code ,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_hdr a
                                INNER JOIN tluom b ON a.ftuom_code=b.ftuom_code
                                WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
                                GROUP BY a.ftUOM_Code
                                UNION ALL
                                SELECT UCASE(a.ftuom_code_multi) AS ftuom_code,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_multi_det a
                                        INNER JOIN tluom b ON a.ftuom_code_multi=b.ftuom_code
                                WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
                                GROUP BY a.ftuom_code_multi";
                $rs=mysql_query($ftUOM_Code);
                ?>
                var ObjSelect=document.getElementById('<?php echo $_REQUEST['ObjLokasi']; ?>');
                var len = ObjSelect.length;
                for (var idx=0; idx < len; idx++)
                {
                    if (ObjSelect.options[ObjSelect.length-1].value!='') {
                              ObjSelect.remove(ObjSelect.length-1);
                    }
                }
                <?php

                $i=0;
                while($r=mysql_fetch_assoc($rs))
                {
                    $i++;
                    echo " try  {
                                        ObjSelect.add(new Option('{$r['ftuom_code']}--{$r['ftuom_name']}','{$r['ftuom_code']}'),null,null);
                                }
                                catch(ex)
                                {
                                        ObjSelect.add(new Option('{$r['ftuom_code']}--{$r['ftuom_name']}','{$r['ftuom_code']}'),$i,$i);
                                } ";
                }
                
                ?>
                ObjSelect.value='<?php echo $ftUOM_Code1; ?>';
                <?php

                break;    
        
        case "location_list":
                $ssql="SELECT ftlocation_code,ftlocation_name FROM tllocation WHERE ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}'";
                $rs=mysql_query($ssql); 
                ?>
                var ObjSelect=document.getElementById('<?php echo $_REQUEST['ObjLokasi']; ?>');
                var len = ObjSelect.length;

                for (var idx=0; idx < len; idx++)
                {
                    if (ObjSelect.options[ObjSelect.length-1].value!='') {
                          ObjSelect.remove(ObjSelect.length-1);
                    }
                }
                <?php
                $i=0;
                while($r=mysql_fetch_assoc($rs)) {
                    $i++;
                    echo "  try {
                                ObjSelect.add(new Option('{$r['ftlocation_code']}--{$r['ftlocation_name']}','{$r['ftlocation_code']}'),null,null);
                            }
                            catch(ex) {
                                ObjSelect.add(new Option('{$r['ftlocation_code']}--{$r['ftlocation_name']}','{$r['ftlocation_code']}'), $i, $i);
                            } ";
                }
                break;        
                
         case "111":
			$result = mysql_query("SELECT ftuom_code FROM tlstock_hdr WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0];
			?>
                            document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';

                        var ObjSelect=document.getElementById('<?php echo $_REQUEST['ObjGudang']; ?>');

                            var len = ObjSelect.length;

                            for (var idx=0; idx < len; idx++)
                            {
                                    if (ObjSelect.options[idx].value=='<?php echo $_SESSION['ftwarehouse_code']; ?>') {
                                        ObjSelect.selectedIndex=idx;
                                        break;
                                    }
                            }

                        <?

                    $ssql="SELECT ftlocation_code,ftlocation_name FROM tllocation WHERE ftwarehouse_code='{$_SESSION['ftwarehouse_code']}'";
                     $rs=mysql_query($ssql);
                   ?>

                        var ObjSelect=document.getElementById('<?php echo $_REQUEST['ObjLokasi']; ?>');

                            var len = ObjSelect.length;

                            for (var idx=0; idx < len; idx++)
                            {
                                    if (ObjSelect.options[ObjSelect.length-1].value!='') {
                                          ObjSelect.remove(ObjSelect.length-1);
                                    }
                            }


                    <?php
                         $i=0;
                        while($r=mysql_fetch_assoc($rs)) {
                              $i++;
                               echo " try {
                                     ObjSelect.add(new Option('{$r['ftlocation_code']}--{$r['ftlocation_name']}','{$r['ftlocation_code']}'),null,null);
                                  } catch(ex) {
                                        ObjSelect.add(new Option('{$r['ftlocation_code']}--{$r['ftlocation_name']}','{$r['ftlocation_code']}'),$i,$i);

                                   } ";

                        }
                              ?>
                        var ObjSelect=document.getElementById('<?php echo $_REQUEST['ObjLokasi']; ?>');

                            var len = ObjSelect.length;

                            for (var idx=0; idx < len; idx++)
                            {
                                    if (ObjSelect.options[idx].value=='<?php echo $_SESSION['ftlocation_code']; ?>') {
                                        ObjSelect.selectedIndex=idx;
                                        break;
                                    }
                            }


                    <?php
			break;
                // fttrans_no
		case "2":

			?>
                           document.getElementById('<?php echo $_REQUEST['no_trans']; ?>').value='<?php echo  getAutoNumber($_REQUEST['ftbranch_code'],$_REQUEST['ftmodule_code'],$_REQUEST['table_name'],$_REQUEST['field_name'],$_REQUEST['thbln']); ?>';
			<?php
			break;
                //Cek No transaksi
		case "3":
                         $ssql="SELECT count(fnid) as jml
                                    FROM {$_REQUEST['table_name']}
                                WHERE {$_REQUEST['field_name']}='{$_REQUEST['Field_Value']}'";

                         $rs=mysql_query($ssql);
                         $r=mysql_fetch_assoc($rs);

			 if($r["jml"]>0){
                               ?>
                                 alert("No transaksi Sudah ada");
                                 document.getElementById('<?php echo $_REQUEST['no_trans']; ?>').value='<?php echo  getAutoNumber($_REQUEST['ftmodule_code'],$_REQUEST['table_name'],$_REQUEST['field_name'],$_REQUEST['thbln']); ?>';
                               <?php
                           }
                           else {  ?>
                                     document.form.submit();
                               <?php
                           }
			break;
                   // Qty On Hand
               /* case "4":
                           $ssql=" SELECT IFNULL(SUM(a.fnqty_on_hand),0) as fnqty_on_hand,IFNUlL(SUM(a.fnqty_available),0) as fnqty_available
                                    FROM tlstock_det a
                                    WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";
                           
                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            ?>
                               document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo $r['fnqty_on_hand']; ?>';
                            <?php
                            if($_REQUEST['formx']=="penyesuaian_barang") {
                                 ?>
                                    var ffAvail=0;
                                    var ffqty=0;
                                    var ffOpname=0;
                                    ffAvail=document.getElementById('fnqty_availableD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                    ffOpname=document.getElementById('fnqty_opnameD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;
                                    document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value= ffOpname-ffAvail;
                                    <?php
                            }
                         # break;
                          break;*/
                  /*case "4b":
                            $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                    FROM tlstock_det_bahan_baku a
                                    WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            ?>
                               document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo $r['fnqty_on_hand']; ?>';
                            <?php
                            if($_REQUEST['formx']=="inventorybb_stock_penyesuaian") {
                                  $ssql="SELECT x1.fcNet_Price
                                                    FROM txstockfifo x1
                                                    WHERE x1.ftTableRef='txstock_in_det_bahan_baku'  AND
                                                            x1.fcNet_Price>0 and x1.fnQty>0 AND
                                                            x1.ftitem_code='{$_REQUEST['ftitem_code']}'
                                                    ORDER BY fnid DESC
                                                    LIMIT 1 ";
                                    $fcPrice=RetRstField($ssql)
                                 ?>
                                    var ffAvail=0;
                                    var ffqty=0;
                                    var ffOpname=0;
                                    ffAvail=document.getElementById('fnqty_availableD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                    ffOpname=document.getElementById('fnqty_opnameD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;

                                    document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value= ffOpname-ffAvail;
                                    document.getElementById('fcpriceD0<?  echo $_REQUEST['index']; ?>').value='<?php echo $fcPrice; ?>';
                                 <?php
                            }

                          break; */
                  /*case "4c":
                            $ssql=" SELECT IFNULL(SUM(a.fnqty_on_hand),0) as fnqty_on_hand,IFNUlL(SUM(a.fnqty_available),0) as fnqty_available
                                    FROM tlstock_det_setengah_jadi a
                                    WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            ?>
                               document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo $r['fnqty_on_hand']; ?>';
                             <?php
                            if($_REQUEST['formx']=="inventorysj_stock_penyesuaian") {
                                 ?>
                                    var ffAvail=0;
                                    var ffqty=0;
                                    var ffOpname=0;
                                    ffAvail=document.getElementById('fnqty_availableD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                    ffOpname=document.getElementById('fnqty_opnameD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;
                                    document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value= ffOpname-ffAvail;
                                    <?php
                            }
                          break;
                 case "4D":
                            $ssql=" SELECT IFNULL(SUM(a.fnqty_on_hand),0) as fnqty_on_hand,IFNUlL(SUM(a.fnqty_available),0) as fnqty_available
                                    FROM tlstock_det_setengah_jadi a
                                    WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            ?>
                               document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo $r['fnqty_on_hand']; ?>';
                             <?php
                            if($_REQUEST['formx']=="inventorysj_stock_penyesuaian") {
                                 ?>
                                    var ffAvail=0;
                                    var ffqty=0;
                                    var ffOpname=0;
                                    ffAvail=document.getElementById('fnqty_availableD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                    ffOpname=document.getElementById('fnqty_opnameD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;
                                    document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value= ffOpname-ffAvail;
                                    <?php
                            }
                          break;*/
                   // Qty  Avail
               /* case "5":
                            $ssql=" SELECT IFNULL(SUM(a.fnqty_on_hand),0) as fnqty_on_hand,IFNUL(SUM(a.fnqty_available),0) as fnqty_available
                                    FROM tlstock_det a
                                    WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code=='{$_REQUEST['ftitem_code']}' ";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            ?>
                                document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo $r['fnqty_available']; ?>';
                            <?php
                           break; */
                  // Address
               case "6":
                            $ssql=" SELECT IFNULL(ftaddress,'') AS ftaddress,IFNULL(ftcity,'') AS ftcity,IFNULL(ftzip_code,'') AS ftzip_code,IFNULL(ftstate,'') AS ftstate,IFNULL(ftcountry,'') AS ftcountry
                                    FROM tlcustomer
                                    WHERE ftcustomer_code='{$_REQUEST['ftcustomer_code']}'";
                           # echo $ssql;
                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            $str="{$r['ftaddress']} {$r['ftcity']}-{$r['ftzip_code']} {$r['ftstate']}-{$r['ftcountry']}";

                             ?>
                                document.getElementById('<?php echo $_REQUEST['objAddress']; ?>').value='<?php echo js_esc($str); ?>';
                            <?php
                            break;
                 case "611":
                            $ssql="SELECT IFNULL(ftaddress_2,'') AS ftaddress,IFNULL(ftcity_2,'') AS ftcity,IFNULL(ftzip_code_2,'') AS ftzip_code,IFNULL(ftstate_2,'') AS ftstate,IFNULL(ftcountry,'') AS ftcountry
                                    FROM tlcustomer
                                    WHERE ftcustomer_code='{$_REQUEST['ftcustomer_code']}'";
                           # echo $ssql;
                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);

                            $str=(!empty($r['ftaddress']))? $r['ftaddress']: "";

                            if(!empty($r['ftcity'])){
                              if(!empty($str)) $str.=" - ";
                              $str.=$r['ftcity'];
                            }

                            /*if(!empty($r['ftcountry'])){
                              if(!empty($str)) $str.=" - ";
                              $str.=$r['ftcountry'];
                            }*/

                             ?>
                                document.getElementById('<?php echo $_REQUEST['objAddress']; ?>').value='<?php echo js_esc($str); ?>';
                                OnChangeDate_fdtrans_date();
                            <?php

                            break;
                  // case Customer & Address
               case "7" :
                        $ssql="SELECT  IFNULL(ftcustomer_code,'') AS ftcustomer_code  ,IFNULL(ftship_address,'') AS ftship_address
                              FROM `txdelivery_order_hdr`
                              WHERE ftdo_no='{$_REQUEST['ftdo_no']}'";

                           $rs=mysql_query($ssql) ;
                           $r=mysql_fetch_assoc($rs);

                           $rs1=mysql_query("SELECT ftcustomer_code,ftcustomer_name,fttax_code FROM tlcustomer WHERE ftcustomer_code='{$r['ftcustomer_code']}'");
                           $r1=mysql_fetch_assoc($rs1);
                            ?>

                                document.getElementById("DivCtl_ftcustomer_code").innerHTML='<input type=hidden name=ftcustomer_code value=\'<?php echo $r['ftcustomer_code']; ?>\'><input readonly  style=\'background-color: rgb(224, 224, 224);\' type=text value=\'<?php echo "{$r['ftcustomer_code']}-{$r1['ftcustomer_name']}"; ?>\'>';
                                document.getElementById('<?php echo $_REQUEST['objAddress']; ?>').value='<?php echo str_replace("\r\n","\\n",$r['ftship_address']); ?>';

                            <?php


                           break;
                     //Status Giro Ar

               case "8":
                         $v=$_REQUEST['obj1'];
                         $o=$_REQUEST['obj2'];
                         if(($v==0)||($v==1)) {
                             $ssql="SELECT fntrans_status_code FROM tstransaction_status WHERE fntrans_group_code=11 AND fntrans_status_code=0";
                         }
                         else {
                             $ssql="SELECT  fntrans_status_code FROM tstransaction_status WHERE fntrans_group_code=11 AND fntrans_status_code=1";
                         }

                         $rs=mysql_query($ssql);
                         $r=mysql_fetch_assoc($rs);
                         $html=$r['fntrans_status_code'];
                            ?>
                            document.getElementById('<?php echo $o; ?>').value='<?php echo $html; ?>';
                            <?php
                          break;
                case "9":
                            $ssql=" SELECT IFNULL(SUM(fccm_amount),0) AS fccm_amount FROM txcredit_memo_hist
                                    WHERE ftcustomer_code='{$_REQUEST['ftcustomer_code']}'";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            $str=$r['fccm_amount'];
                             ?>
                                document.getElementById('<?php echo $_REQUEST['objCM']; ?>').value='<?php echo $str; ?>';
                            <?php
                            break;


                case "10": // jml amount Invoice
                            $ssql="SELECT SUM(fcamount) AS fcamount ,SUM(fcoutstanding_amount) AS fcoutstanding_amount
                                    FROM
                                    txsales_invoice_hdr
                                    WHERE (fnpayment_status=1 or fnpayment_status=2) AND fnstatus<>9 AND
                                            ftcustomer_code='{$_REQUEST['ftcustomer_code']}'";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                             ?>
                                document.getElementById('fcinvoice_amount').value='<?php echo $r['fcamount']; ?>';
                                document.getElementById('fcoutstanding_amount').value='<?php echo $r['fcoutstanding_amount']; ?>';
                            <?php

                            break;
                case "11": // adress supplier
                            $ssql=" SELECT IFNULL(ftaddress1,'') AS ftaddress,IFNULL(ftcity_1,'') AS ftcity,IFNULL(ftzip_code_1,'') AS ftzip_code,IFNULL(ftstate_1,'') AS ftstate,IFNULL(ftcountry,'') AS ftcountry
                                    FROM tlsupplier
                                    WHERE ftsupplier_code='{$_REQUEST['ftsupplier_code']}'";
                           # echo $ssql;
                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            $str="{$r['ftaddress']}\\n{$r['ftcity']}-{$r['ftzip_code']}\\n{$r['ftstate']}-{$r['ftcountry']}";

                             ?>
                                document.getElementById('<?php echo $_REQUEST['objAddress']; ?>').value='<?php echo $str; ?>';
                            <?php
                            break;
                case "12":
                            $ssql=" SELECT IFNULL(SUM(fcdm_amount),0) AS fcdm_amount FROM txdebit_memo_hist
                                    WHERE ftsupplier_code='{$_REQUEST['ftsupplier_code']}'";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            $str=$r['fcdm_amount'];
                             ?>
                                document.getElementById('<?php echo $_REQUEST['objDM']; ?>').value='<?php echo $str; ?>';
                            <?php
                            break;

                case "13":
                             // jml amount Invoice
                            $ssql="SELECT SUM(fcamount) AS fcamount ,SUM(fcoutstanding_amount) AS fcoutstanding_amount
                                    FROM
                                    txpayment_projection_det
                                    WHERE (fnpayment_status=1 or fnpayment_status=2) AND fnstatus<>9 AND
                                            ftsupplier_code='{$_REQUEST['ftsupplier_code']}'";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                             ?>

                                document.getElementById('fcinvoice_amount').value='<?php echo $r['fcamount']; ?>';
                                document.getElementById('fcoutstanding_amount').value='<?php echo $r['fcoutstanding_amount']; ?>';
                            <?php

                            break;

		case "44":
			$result = mysql_query("SELECT ftuom_code, fcBuying_Price FROM tlstock_hdr WHERE ftitem_code = '$obj1'") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0];
			$html2 = $row[1];
			?>
			div = document.getElementById('<?php echo $obj2; ?>');
			div.value = '<?php echo $html; ?>';

			div2 = document.getElementById('<?php echo $obj3; ?>');
			div2.value = '<?php echo $html2; ?>';
			<?
			break;
		case "100":
			$result = mysql_query("SELECT fnlevel FROM tlstock_group WHERE ftstock_group_code = \"$obj1\"") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0]+1;
                        if($obj1=="") {
                            $html=0;
                        }
			?>

			div = document.getElementById('<?php echo $obj2; ?>');
			div.value = '<?php echo $html; ?>';
			<?
			break;
		case "101":
			$html = $obj1 . "." . $obj2 . "." . $obj3 . "." . $obj4 . "." . $obj5 . "." . $obj6;
			?>
			div = document.getElementById('<?php echo $obj7; ?>');
			div.value = '<?php echo $html; ?>';
			<?
			break;

                //==============================
                // BAHAN BAKU
                //==============================
                case "bb2":
			?>
                            document.getElementById('<?php echo $_REQUEST['no_trans']; ?>').value='<?php echo  getAutoNumber($_REQUEST['ftmodule_code'],$_REQUEST['table_name'],$_REQUEST['field_name'],$_REQUEST['thbln']); ?>';
			<?php
			break;
                //Cek No transaksi
		case "bb3":
                         $ssql="SELECT count(fnid) as jml
                                    FROM {$_REQUEST['table_name']}
                                WHERE {$_REQUEST['field_name']}='{$_REQUEST['Field_Value']}'";

                         $rs=mysql_query($ssql);
                         $r=mysql_fetch_assoc($rs);

			 if($r["jml"]>0){
                               ?>
                                 alert("No transaksi Sudah ada");
                                 document.getElementById('<?php echo $_REQUEST['no_trans']; ?>').value='<?php echo  getAutoNumber($_REQUEST['ftmodule_code'],$_REQUEST['table_name'],$_REQUEST['field_name'],$_REQUEST['thbln']); ?>';
                               <?php
                           }
                           else {  ?>
                                     document.form.submit();
                               <?php
                           }
			break;
                        
                // Formula & Qty Base        
                case "formula":
                    $ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
                            FROM tlstock_multi_det
                            WHERE ftitem_code='{$_REQUEST['ftitem_code']}'
                            and ftuom_code_multi='{$_REQUEST['ftuom_code']}' ";
                    $ffformula=RetRstField($ssql);
                    $ffQtyMulti=(double)$ffformula*(double)CCur($_REQUEST['fnqty']);
                    ?>
                    document.getElementById('ffformulaD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffformula; ?>';
                    document.getElementById('fnqty_baseD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffQtyMulti; ?>';
                    <?php
                    break;
                        
                // Qty Available
                case "qty":
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND 
                                a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND 
                                a.ftitem_code='{$_REQUEST['ftitem_code']}' AND 
                                a.fdexp_date='{$_REQUEST['fdexp_date']}' ";

                        $rs=mysql_query($ssql);
                        $r=mysql_fetch_assoc($rs);
                        
                        // Penambahan qty berdasarkan transaksi sebelumnya (kasus revisi)
                        if($_REQUEST['qty_revisi']!="") {
                            $qty_revisi = $_REQUEST['qty_revisi'];
                        } else {
                            $qty_revisi = 0;
                        }
                        
                        ?> 
                           document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo number_format(($r['fnqty_available']+$qty_revisi),2); ?>';
                        <?php
                        
                        if($_REQUEST['formx']=="penyesuaian_barang") {
                                $fcPrice = GetLastPriceValue("{$_SESSION['strbranch']}","{$_REQUEST['ftitem_code']}");
                
                                if ($fcPrice == 0) {
                                    $fcPrice = RetRstField("SELECT fcbuying_price FROM tlbuying_price WHERE ftcurrency_code = 'IDR' AND ftitem_code = '{$_REQUEST['ftitem_code']}' ");
                                }
                                if ($fcPrice == '') $fcPrice = 0;         
                                ?>
                                document.getElementById('fcpriceD0<?  echo $_REQUEST['index']; ?>').value='<?php echo CCur($fcPrice); ?>';
                                <?php

                        } else if($_REQUEST['formx']=="assembly") {
                                $fcPrice = GetFIFOPrice($_SESSION['strbranch'], $_REQUEST['ftitem_code'], $_REQUEST['ftlocation_code'],""); 
                                if ($fcPrice == 0) {        
                                    $fcPrice = RetRstField("SELECT fcbuying_price FROM tlbuying_price WHERE ftcurrency_code = 'IDR' AND ftitem_code = '{$_REQUEST['ftitem_code']}' ");
                                }
                                if ($fcPrice == '') $fcPrice = 0; 
                                ?>
                                document.getElementById('fcnet_priceD0<?  echo $_REQUEST['index']; ?>').value='<?php echo number_format($fcPrice,2); ?>';
                                <?php
                                
                        } else if($_REQUEST['formx']=="disassembly") {
                                $fcPrice = GetFIFOPrice($_SESSION['strbranch'], $_REQUEST['ftitem_code'], $_REQUEST['ftlocation_code'],""); 
                                if ($fcPrice == 0) {      
                                    $fcPrice = RetRstField("SELECT fcbuying_price FROM tlbuying_price WHERE ftcurrency_code = 'IDR' AND ftitem_code = '{$_REQUEST['ftitem_code']}' ");
                                }
                                if ($fcPrice == '') $fcPrice = 0; 
                                ?>
                                document.getElementById('fcnet_price').value='<?php echo number_format($fcPrice,2); ?>';
                                <?php
                        }
                        break;

                // Qty On Hand (available - pending sales order)
                case "qty_onhand":
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available,ftstock_category_code 
                                FROM tlstock_det a inner join tlstock_hdr b on a.ftitem_code = b.ftitem_code
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND 
                                a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND 
                                a.ftitem_code='{$_REQUEST['ftitem_code']}' AND 
                                a.fdexp_date='{$_REQUEST['fdexp_date']}' ";

                        $rs=mysql_query($ssql);
                        $r=mysql_fetch_assoc($rs);

                        // Penambahan qty berdasarkan transaksi sebelumnya (kasus revisi)
                        if($_REQUEST['qty_revisi']!="") {
                            $qty_revisi = CCur($_REQUEST['qty_revisi']);
                        } else {
                            $qty_revisi = 0;
                        }
                        
                        // cek qty SO , except the current SO
                        $ssql = "SELECT IFNULL(SUM(a.fnqty),0) AS fnqty FROM txsales_order_det a INNER JOIN txsales_order_hdr b ON a.ftso_no = b.ftso_no 
                                                WHERE b.fnstatus = 1 AND a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND 
                                                    a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND 
                                                    a.ftitem_code='{$_REQUEST['ftitem_code']}'  ";
                        $qty_so = RetRstField($ssql);
                        if ($qty_so == '') { $qty_so = 0; }
                        
                        if ($r['ftstock_category_code'] == 'inv') {
                            $qty_onhand = $r['fnqty_available'] - $qty_so + $qty_revisi;
                        } else {
                            $qty_onhand = 0;
                        }
                        ?> 
                           document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo number_format($qty_onhand,2); ?>';
                        <?php
                        break;
                        
                case "qty_bahan_baku":
                        /*if($_REQUEST["ftcategory_code"]==6){
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";
                        }else{
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det_bahan_baku a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";
                        }*/
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det_bahan_baku a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND 
                                a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND 
                                a.ftitem_code='{$_REQUEST['ftitem_code']}' AND 
                                a.fdexp_date='{$_REQUEST['fdexp_date']}' ";
                        $rs=mysql_query($ssql);
                        $r=mysql_fetch_assoc($rs);
                        ?>
                           document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo number_format($r['fnqty_available'], 2); ?>';
                        <?php
                        if($_REQUEST['formx']=="inventorybb_stock_penyesuaian") {
                              $ssql="SELECT x1.fcNet_Price
                                                FROM txstockfifo x1
                                                WHERE  x1.fcNet_Price>0 and x1.fnQty>0 AND
                                                        x1.ftitem_code='{$_REQUEST['ftitem_code']}'
                                                ORDER BY fnid DESC
                                                LIMIT 1 ";
                                $fcPrice=RetRstField($ssql)
                                ?>
                                var ffAvail=0;
                                var ffqty=0;
                                var ffOpname=0;
                                ffAvail=document.getElementById('fnqty_availableD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                ffOpname=document.getElementById('fnqty_opnameD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;

                                document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value= ffOpname-ffAvail;
                                document.getElementById('fcpriceD0<?  echo $_REQUEST['index']; ?>').value='<?php echo number_format($fcPrice,2); ?>';
                                <?php

                                $ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
                                        FROM tlstock_multi_det_bahan_baku
                                        WHERE ftitem_code='{$_REQUEST['ftitem_code']}'
                                        and ftuom_code_multi='{$_REQUEST['ftuom_code']}'";

                                $ffformula=RetRstField($ssql);
                                $ffQtyMulti=(double)$ffformula*(double)$_REQUEST['fnqty'];

                                ?>
                                document.getElementById('ffformulaD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffformula; ?>';

                                varffformula=document.getElementById('ffformulaD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                varfnqty=document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;
                                document.getElementById('fnqty_baseD0<?php echo $_REQUEST['index']; ?>').value= varffformula * varfnqty;

                                <?php
                        }
                        break;

                case "qty_sparepart":
                    $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det_sparepart a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND 
                                a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND 
                                a.ftitem_code='{$_REQUEST['ftitem_code']}' AND 
                                a.fdexp_date='{$_REQUEST['fdexp_date']}' ";
                    $rs=mysql_query($ssql);
                    $r=mysql_fetch_assoc($rs);
                    ?>
                       document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo number_format($r['fnqty_available'],2); ?>';
                    <?php
                    if($_REQUEST['formx']=="inventorysp_stock_penyesuaian") {
                          $ssql="SELECT x1.fcNet_Price
                                            FROM txstockfifo x1
                                            WHERE x1.fcNet_Price>0 and x1.fnQty>0 AND
                                                    x1.ftitem_code='{$_REQUEST['ftitem_code']}'
                                            ORDER BY fnid DESC
                                            LIMIT 1 ";
                            $fcPrice=RetRstField($ssql)
                         ?>
                            var ffAvail=0;
                            var ffqty=0;
                            var ffOpname=0;
                            ffAvail=document.getElementById('fnqty_availableD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                            ffOpname=document.getElementById('fnqty_opnameD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;

                            document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value= ffOpname-ffAvail;
                            document.getElementById('fcpriceD0<?  echo $_REQUEST['index']; ?>').value='<?php echo number_format($fcPrice,2); ?>';
                         <?php

                         $ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
                                FROM tlstock_multi_det_sparepart
                                WHERE ftitem_code='{$_REQUEST['ftitem_code']}'
                                and ftuom_code_multi='{$_REQUEST['ftuom_code']}'
                                ";

                        $ffformula=RetRstField($ssql);
                        $ffQtyMulti=(double)$ffformula*(double)$_REQUEST['fnqty'];
                        ?>
                            document.getElementById('ffformulaD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffformula; ?>';

                            varffformula=document.getElementById('ffformulaD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                            varfnqty=document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;
                            document.getElementById('fnqty_baseD0<?php echo $_REQUEST['index']; ?>').value= varffformula * varfnqty;
                        <?php


                    }
                    break;
                case "qty_setengah_jadi":
                        /*if($_REQUEST["ftcategory_code"]==6){
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";
                        }else{
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det_setengah_jadi a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";
                        }*/
                        $ssql=" SELECT IFNULL(SUM(a.fnqty_available),0) as fnqty_available
                                FROM tlstock_det_setengah_jadi a
                                WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND 
                                a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND 
                                a.ftitem_code='{$_REQUEST['ftitem_code']}' AND 
                                a.fdexp_date='{$_REQUEST['fdexp_date']}' ";
                        $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            ?>
                               document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo number_format($r['fnqty_available'],2); ?>';
                            <?php
                            if($_REQUEST['formx']=="inventorysj_stock_penyesuaian") {
                            ?>
                                var ffAvail=0;
                                var ffqty=0;
                                var ffOpname=0;
                                ffAvail=document.getElementById('fnqty_availableD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                ffOpname=document.getElementById('fnqty_opnameD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;
                                document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value= ffOpname-ffAvail;
                            
                                <?php

                                $ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
                                        FROM tlstock_multi_det_setengah_jadi
                                        WHERE ftitem_code='{$_REQUEST['ftitem_code']}'
                                        and ftuom_code_multi='{$_REQUEST['ftuom_code']}'";

                                $ffformula=RetRstField($ssql);
                                $ffQtyMulti=(double)$ffformula*(double)$_REQUEST['fnqty'];

                                ?>
                                document.getElementById('ffformulaD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffformula; ?>';

                                varffformula=document.getElementById('ffformulaD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1;
                                varfnqty=document.getElementById('fnqtyD0<?  echo $_REQUEST['index']; ?>').value.replace(/,/g,'')*1 ;
                                document.getElementById('fnqty_baseD0<?php echo $_REQUEST['index']; ?>').value= varffformula * varfnqty;

                                <?php
                            }
                        break;
        /*case "qty_sparepart":
                            $ssql=" SELECT IFNULL(SUM(a.fnqty_on_hand),0) as fnqty_on_hand,IFNUlL(SUM(a.fnqty_available),0) as fnqty_available
                                    FROM tlstock_det_sparepart a
                                    WHERE  a.ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}' AND a.ftlocation_code='{$_REQUEST['ftlocation_code']}' AND a.ftitem_code='{$_REQUEST['ftitem_code']}' ";

                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                            ?>
                               document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value='<?php echo $r['fnqty_available']; ?>';
                            <?php
            break;*/
            
        case "bb6":
                            $ssql=" SELECT IFNULL(ftaddress1,'') AS ftaddress,IFNULL(ftcity_1,'') AS ftcity,IFNULL(ftzip_code_1,'') AS ftzip_code,IFNULL(ftstate_1,'') AS ftstate,IFNULL(ftcountry,'') AS ftcountry
                                     FROM tlsupplier
                                    WHERE ftsupplier_code='{$_REQUEST['ftsupplier_code']}'";
                           # echo $ssql;
                            $rs=mysql_query($ssql);
                            $r=mysql_fetch_assoc($rs);
                          $str="{$r['ftaddress']} {$r['ftcity']}-{$r['ftzip_code']} {$r['ftstate']}-{$r['ftcountry']}";

                             ?>
                                  
                                document.getElementById('<?php echo $_REQUEST['objAddress']; ?>').value='<?php echo js_esc($str); ?>';
                            <?php
            break;


                case 	 "reject_type":
                             $ssql=" SELECT ftreject_type_code FROM tlreject_type
                                     WHERE ftreject_code='{$_REQUEST['ftreject_code']}'";
                            $fnqty_avail=RetRstField($ssql);
                             ?>

                                document.getElementById('<?php echo $_REQUEST['objAddress']; ?>').value='<?php echo $fnqty_avail; ?>';
                            <?php
	    break;
                case 	 "empty_field":
                            $empty='';
                             ?>

                                document.getElementById('<?php echo $_REQUEST['objAddress']; ?>').value='<?php echo $empty; ?>';
                            <?php
	    break;

            case "bb_stock_group":
			$result = mysql_query("SELECT fnlevel FROM tlstock_group_bahan_baku WHERE ftstock_group_code = \"$obj1\"") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0]+1;
                        if($obj1=="") {
                            $html=0;
                        }
			?>

			div = document.getElementById('<?php echo $obj2; ?>');
			div.value = '<?php echo $html; ?>';
			<?php
			break;

            //=====================================
            // Inventory Barang Setengah Jadi
            //=====================================

            case "sj_stock_group":
			$result = mysql_query("SELECT fnlevel FROM tlstock_group_setengah_jadi WHERE ftstock_group_code = \"$obj1\"") or die("Query failed");
			$row = mysql_fetch_array($result);
			$html = $row[0]+1;
                        if($obj1=="") {
                            $html=0;
                        }
			?>

			div = document.getElementById('<?php echo $obj2; ?>');
			div.value = '<?php echo $html; ?>';
			<?php
			break;
          case "penyusutan_asset":
            ?>
                document.getElementById('<?php echo $_REQUEST['fttrans_code']; ?>').value='<?php echo  getAutoNumber($_REQUEST['ftbranch_code'],$_REQUEST['ftmodule_code'],$_REQUEST['table_name'],$_REQUEST['field_name'],$_REQUEST['thbln']); ?>';
            <?php
            break;
          case "tglgiro":
            $v=$_REQUEST['obj1'];
            $o=$_REQUEST['obj2'];
            ?>
            document.getElementById('<?php echo $o; ?>').value=<?php echo $v; ?>;
            <?php
            break;

    // Module keuangan
    // Form Penerimaan Piutang - Munculkan daftar uang muka penjualan
    case "uangmukapenjualan" :
             
        // Metode Giro / Cek
        if (($_REQUEST["obj1"]=="0") || ($_REQUEST["obj1"]=="1")) {
            $html.="<input type=\"text\" id=\"ftgiro_noD0{$_REQUEST['index']}\" name=\"ftgiro_noD0[]\" size=\"30\">";
            $ssql="SELECT ftcoa_code, ftCOA_Description as ftcoa_name FROM tlcoa_setting WHERE ftcoa_no = 'F07'";

        // Metode Credit Memo
        } else if($_REQUEST["obj1"]=="6") {
            $ssql="SELECT a.ftcm_no, a.fcoutstanding_amount  FROM txcredit_memo_hdr a INNER JOIN txcredit_memo_det b ON a.ftcm_no = b.ftcm_no WHERE a.ftcustomer_code = '{$_REQUEST["obj2"]}' AND ((a.fnstatus=1) OR (a.fnstatus =2)) AND a.fcoutstanding_amount > 0 ORDER BY a.ftcm_no";
            $rs=mysql_query($ssql);

            $html="<select id=\"ftgiro_noD0{$_REQUEST['index']}\" name=\"ftgiro_noD0[]\" class=\"text\">";
            $html.="<option value=\"\">--- Pilih ---</option>";
            while($r=mysql_fetch_assoc($rs)) {
                $html.="<option value=\"{$r['ftcm_no']}\">{$r['ftcm_no']} -- {$r['fcoutstanding_amount']} </option>";
            }
            $html.="</select>";
            $ssql="SELECT ftcoa_code, ftCOA_Description as ftcoa_name FROM tlcoa_setting WHERE ftcoa_no = 'f19'";

        // Metode Uang Muka Penjualan
        } else if($_REQUEST["obj1"]== "9") {
            $ssql="SELECT fttrans_no FROM txadvanced_receive WHERE ftcustomer_code = '{$_REQUEST["obj2"]}' AND fcoutstanding_amount > 0 AND fnstatus <> 3 AND fnstatus <> 9 ORDER BY fttrans_no";
            $rs=mysql_query($ssql);

            $html="<select id=\"ftgiro_noD0{$_REQUEST['index']}\" name=\"ftgiro_noD0[]\" class=\"text\">";
            $html.="<option value=\"\">--- Pilih ---</option>";
            while($r=mysql_fetch_assoc($rs)) {
                $html.="<option value=\"{$r['fttrans_no']}\">{$r['fttrans_no']}</option>";
            }
            $html.="</select>";
            $ssql="SELECT ftcoa_code, ftCOA_Description as ftcoa_name FROM tlcoa_setting WHERE ftcoa_no = 'f09'";
            
        } else {
            $html.="<input type=\"text\" id=\"ftgiro_noD0{$_REQUEST['index']}\" name=\"ftgiro_noD0[]\" size=\"30\">";
            $ssql="SELECT a.ftcoa_code, a.ftcoa_name FROM tlcoa a INNER JOIN tlcoa_subgroup b ON a.ftcoa_subgroup_code=b.ftcoa_subgroup_code WHERE (a.ftcoa_subgroup_code=15 OR a.ftcoa_subgroup_code=16) AND RIGHT(a.ftcoa_code, 5)<>'.0000' ORDER BY ftcoa_code ASC";
        }

        $rs=mysql_query($ssql);

        ?>
        document.getElementById("DivCtl_ftgiro_noD0<?php echo $_REQUEST["index"]; ?>").innerHTML='<?php echo $html; ?>';
        
        var ObjSelect=document.getElementById('ftacc_noD0<?  echo $_REQUEST['index']; ?>');
        var len = ObjSelect.length;

        for (var idx=0; idx < len; idx++)
        {
            if (ObjSelect.options[ObjSelect.length-1].value!='') {
                  ObjSelect.remove(ObjSelect.length-1);
            }
        }
     
        <?php
        
        $i=0;
        while($r=mysql_fetch_assoc($rs)) {
                $i++;
                echo " try {
                        ObjSelect.add(new Option('{$r['ftcoa_code']}--{$r['ftcoa_name']}','{$r['ftcoa_code']}'),null,null);
                      } catch(ex) {
                        ObjSelect.add(new Option('{$r['ftcoa_code']}--{$r['ftcoa_name']}','{$r['ftcoa_code']}'),$i,$i);
                      } ";

        }

        if (($_REQUEST["obj1"]=="6") OR ($_REQUEST["obj1"]=="9")) {
                ?>
                var ObjSelect=document.getElementById('ftacc_noD0<?  echo $_REQUEST['index']; ?>');
                ObjSelect.selectedIndex = '1';
                // ObjSelect.disabled = true;
                <?php
        }
        
        break;

    // Form Pembayaran Hutang - Munculkan daftar uang muka pembelian
    case "uangmukapembelian" :

        // Metode Giro / Cek
        if (($_REQUEST["obj1"]=="0") || ($_REQUEST["obj1"]=="1")) {
            $html.="<input type=\"text\" id=\"ftgiro_noD0{$_REQUEST['index']}\" name=\"ftgiro_noD0[]\" size=\"30\">";
            $ssql="SELECT ftcoa_code, ftCOA_Description as ftcoa_name FROM tlcoa_setting WHERE ftcoa_no = 'F08'";

        // Metode Debit Memo
        } else if($_REQUEST["obj1"]=="5") {
            $ssql="SELECT a.ftdm_no, a.fcoutstanding_amount  FROM txdebit_memo_hdr a INNER JOIN txdebit_memo_det b ON a.ftdm_no = b.ftdm_no WHERE a.ftsupplier_code = '{$_REQUEST["obj2"]}' AND ((a.fnstatus=1) OR (a.fnstatus =2)) AND a.fcoutstanding_amount > 0 ORDER BY a.ftdm_no";
            $rs=mysql_query($ssql);

            $html="<select id=\"ftgiro_noD0[]\" name=\"ftgiro_noD0[]\" class=\"text\">";
            $html.="<option value=\"\">--- Pilih ---</option>";
            while($r=mysql_fetch_assoc($rs)) {
                $html.="<option value=\"{$r['ftdm_no']}\">{$r['ftdm_no']} -- {$r['fcoutstanding_amount']} </option>";
            }
            $html.="</select>";
            $ssql="SELECT ftcoa_code, ftCOA_Description as ftcoa_name FROM tlcoa_setting WHERE ftcoa_no = 'f20'";

        // Metode Uang Muka Pembelian
        } else if($_REQUEST["obj1"]=="9") {
            $ssql="SELECT fttrans_no FROM txadvanced_payment WHERE ftsupplier_code = '{$_REQUEST["obj2"]}' AND fcoutstanding_amount > 0 AND fnstatus <> 3 AND fnstatus <> 9  ORDER BY fttrans_no";
            $rs=mysql_query($ssql);

            $html="<select id=\"ftgiro_noD0[]\" name=\"ftgiro_noD0[]\" class=\"text\">";
            $html.="<option value=\"\">--- Pilih ---</option>";
            while($r=mysql_fetch_assoc($rs)) {
                $html.="<option value=\"{$r['fttrans_no']}\">{$r['fttrans_no']}</option>";
            }
            $html.="</select>";

            $ssql="SELECT ftcoa_code, ftCOA_Description as ftcoa_name FROM tlcoa_setting WHERE ftcoa_no = 'f10'";

        } else {
            $html.="<input type=\"text\" id=\"ftgiro_noD0{$_REQUEST['index']}\" name=\"ftgiro_noD0[]\" size=\"30\">";
            $ssql="SELECT a.ftcoa_code, a.ftcoa_name FROM tlcoa a INNER JOIN tlcoa_subgroup b ON a.ftcoa_subgroup_code=b.ftcoa_subgroup_code WHERE (a.ftcoa_subgroup_code=15 OR a.ftcoa_subgroup_code=16) AND RIGHT(a.ftcoa_code, 5)<>'.0000' ORDER BY ftcoa_code ASC";
        } 

        $rs=mysql_query($ssql);

        ?>
        document.getElementById("DivCtl_ftgiro_noD0<?php echo $_REQUEST["index"]; ?>").innerHTML='<?php echo $html; ?>';

        var ObjSelect=document.getElementById('ftacc_noD0<?  echo $_REQUEST['index']; ?>');
        var len = ObjSelect.length;

        for (var idx=0; idx < len; idx++)
        {
            if (ObjSelect.options[ObjSelect.length-1].value!='') {
                  ObjSelect.remove(ObjSelect.length-1);
            }
        }

        <?php
        $i=0;
        while($r=mysql_fetch_assoc($rs)) {
                $i++;
                echo " try {
                        ObjSelect.add(new Option('{$r['ftcoa_code']}--{$r['ftcoa_name']}','{$r['ftcoa_code']}'),null,null);
                      } catch(ex) {
                        ObjSelect.add(new Option('{$r['ftcoa_code']}--{$r['ftcoa_name']}','{$r['ftcoa_code']}'),$i,$i);
                      } ";

        }

        if (($_REQUEST["obj1"]=="5") OR ($_REQUEST["obj1"]=="9")) {
                ?>
                var ObjSelect=document.getElementById('ftacc_noD0<?  echo $_REQUEST['index']; ?>');
                ObjSelect.selectedIndex = '1';
                // ObjSelect.disabled = true;
                <?php
        }
      
    break;

    // Modul Production
    case "level_machine_group":
        $result = mysql_query("SELECT fnlevel FROM tlmachine_group WHERE ftmachine_group_code = \"$obj1\"") or die("Query failed");
        $row = mysql_fetch_array($result);
        $html = $row[0]+1;
        if($obj1=="") {
            $html=0;
        }
        ?>

        div = document.getElementById('<?php echo $obj2; ?>');
        div.value = '<?php echo $html; ?>';
        <?php
        break;
        
    case "exp_date":
        $result = mysql_query("SELECT fdexp_date FROM tlstock_det WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
	$row = mysql_fetch_array($result);
        $html = $row[0];
        ?>
        document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
        <?php
        break;
        
    case "exp_datebb":
        $result = mysql_query("SELECT fdexp_date FROM tlstock_hdr_bahan_baku WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
	$row = mysql_fetch_array($result);
        $html = $row[0];
        ?>
        document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
        <?php
        break;
        
    case "exp_datesj":
        $result = mysql_query("SELECT fdexp_date FROM tlstock_hdr_setengah_jadi WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
	$row = mysql_fetch_array($result);
        $html = $row[0];
        ?>
        document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
        <?php
        break;
        
    case "exp_datesp":
        $result = mysql_query("SELECT fdexp_date FROM tlstock_hdr_sparepart WHERE ftitem_code = '{$_REQUEST['obj1']}'") or die("Query failed");
	$row = mysql_fetch_array($result);
        $html = $row[0];
        ?>
        document.getElementById('<?php echo $_REQUEST['obj2']; ?>').value='<?php echo $html; ?>';
        <?php
        break;
    
}
