<?php
      if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "transno":
                if(RetRstField("SELECT fnid FROM txdelivery_order_hdr WHERE ftdo_no='{$_REQUEST['fttrans_no']}'")) {
                ?>
                    alert('No. transaksi sudah dipakai...\n System akan mengenerate No. transaksi kembali ...\n Silahkan ulangi proses penyimpanan...  ');
                    OnChangeDate_fdtrans_date();
                <?php
                }
                else {
                ?>
                    submitbutton('Simpan','','','','');
                <?php
                }
            die("");
            break;

            case "gudang":
                $ssql="SELECT ftlocation_code,ftlocation_name FROM tllocation WHERE ftwarehouse_code='{$_REQUEST['ftwarehouse_code']}'";
//                $ssql="SELECT ftlocation_code,ftlocation_name FROM tllocation WHERE ftlocation_code='GBJ'";
                $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);
                            } ";
                }

                ?>
                    document.getElementById('<?php echo $_REQUEST['objQty']; ?>').value=0;
                <?php
                die("");
                break;

            case "oum":
                $ssql="SELECT ftuom_code,ftstock_category_code FROM tlstock_hdr WHERE ftitem_code='{$_REQUEST['ftitem_code']}'";
                $rs=mysql_query( $ssql);
                $r=mysql_fetch_assoc($rs);
                ?>
                    document.getElementById('<?php echo $_REQUEST['ftuom_code']; ?>').value='<?php echo $r['ftuom_code']; ?>';
                    document.getElementById('<?php echo $_REQUEST['ftstock_category_code']; ?>').value='<?php echo $r['ftstock_category_code']; ?>';

                    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;
                            }
                    }
                <?php
                $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;
                            }
                    }

                    var str1='query2.php?code=4&ftwarehouse_code=<?php echo $_SESSION['ftwarehouse_code']; ?>&ftlocation_code=<?php echo $_SESSION['ftlocation_code']; ?>&ftitem_code=<?php echo $_REQUEST['ftitem_code']; ?>&objQty=<?php echo $_REQUEST['objQty']; ?>';
                    ajax_do(str1);
                    <?php
                die("");
                break;

             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);
                if ($ffformula==0) { $ffformula=1; };

                $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

                die("");
            break;

            case "customer":
                /*
                $ssql = "SELECT DISTINCT ftso_no, fdtrans_date FROM
                            (SELECT b.ftitem_code, a.ftso_no, a.fdtrans_date , b.fnqty AS ttlso,
                             COALESCE(SUM(d.fnqty),0) AS ttldo FROM txsales_order_hdr a
                             INNER JOIN txsales_order_det b ON a.ftso_no = b.ftso_no
                             LEFT JOIN txdelivery_order_hdr c ON a.ftso_no = c.ftso_no
                                AND (c.fnstatus = 1 or c.fnstatus = 2)
                             LEFT JOIN txdelivery_order_det d ON c.ftdo_no = d.ftdo_no
                             WHERE a.fnstatus=1 and a.ftcustomer_code = '{$_REQUEST['ftcustomer_code']}'
                             GROUP BY b.ftitem_code, a.ftso_no, a.fdtrans_date
                             HAVING ttldo < ttlso) X order by ftso_no ";  */

                $ssql = "SELECT ftso_no, fdtrans_date FROM txsales_order_hdr
                            WHERE fnstatus <> 0 AND fnstatus <> 3 and fnstatus <> 5 and fnstatus <> 9 and fnreceive_status <> 3
                                    AND ftcustomer_code = '{$_REQUEST['ftcustomer_code']}'
                            ORDER BY ftso_no ";
                $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['ftso_no']}--{$r['fdtrans_date']}','{$r['ftso_no']}'),null,null);
                            } catch(ex) {
                                ObjSelect.add(new Option('{$r['ftso_no']}--{$r['fdtrans_date']}','{$r['ftso_no']}'),$i,$i);
                            } ";
                }

                ?>
                    ajax_do('query2.php?code=611&ftcustomer_code=' + document.getElementById('ftcustomer_code').value + '&ftdo_type=' + document.getElementById('ftdo_type').value + '&objAddress=ftship_address');
                <?php

                die("");
            break;
        }

    }

    Getsecurity('delivery_order_konsinyasi');

    // filter only sales transaction if login by user
    $ftsales_code = RetRstField("Select ifnull(ftsales_code,'') FROM tluser WHERE ftusername = '{$_SESSION['username']}' ");
    if ($ftsales_code != "") { $sql_sales = " AND a.ftsales_code = '{$ftsales_code}' "; }

    // filter warehouse code based on login user
    $ftwarehouse_code = RetRstField("Select ifnull(ftwarehouse_code,'') FROM tluser WHERE ftusername = '{$_SESSION['username']}' ");
    if ($ftwarehouse_code != "") {
        $str_warehouse = explode(",", $ftwarehouse_code);
        $sql_where = "''";

        foreach($str_warehouse as $item) {
            $sql_where = $sql_where . ",'{$item}'";
        }
        $sql_where = " AND e.ftwarehouse_code IN ({$sql_where})";
    }


    $objAxpDB->ViewName("Daftar Delivery Order Konsinyasi");
    //$objAxpDB->ViewTable("vSADo");
    $objAxpDB->ViewSQL("select DISTINCT `a`.`fnid` AS `fnid`,
                        `a`.`fdtrans_date` AS `fdtrans_date`,
                        `a`.`ftdo_no` AS `ftdo_no`,
                        CONCAT(c.ftcustomer_code, ' - ', c.ftcustomer_name) AS ftcustomer_name,

                        `a`.`fftotal_qty` AS `fftotal_qty`,
                         e.ftwarehouse_code,
                         `b`.`fttrans_status_name` AS `fttrans_status_name`
                        from `txdelivery_order_hdr` `A` left join `tstransaction_status` `B` on `a`.`fnstatus` = `b`.`fntrans_status_code` and `b`.`fntrans_group_code` = 2 left join `tlcustomer` `C` on `a`.`ftcustomer_code` = `c`.`ftcustomer_code`
                        INNER JOIN txdelivery_order_det e on a.ftdo_no = e.ftdo_no
                        WHERE 1=1 and ftsales_type_code=2 {$sql_sales} {$sql_where} group by ftdo_no
                        order by `a`.`ftdo_no` desc,`a`.`fdtrans_date` desc");

    $objAxpDB->ViewCaption("ID, Tgl. Transaksi, No. DO, Customer, Total Qty , Gudang, Status, ");
    $objAxpDB->ViewPeriod(TRUE);

    $objAxpDB->FormName("Delivery Order Konsinyasi");
    //$objAxpDB->FormSQL("SELECT ftdo_no, ftdo_type, ftso_no, ftcustomer_code, ftship_address, fdtrans_date, fddue_date, ftdelivery_method, ftreference, ftnotes,  fftotal_qty, fnstatus FROM txdelivery_order_hdr");
    //$objAxpDB->FormCaption("No. DO, Tipe DO, No SO, Customer, Alamat, Tgl. transaksi, Tgl. Jatuh Tempo, Metode Pengiriman, Referensi, Catatan, Total Qty, Status");
    $objAxpDB->FormSQL("SELECT ftdo_no, ftdo_type, ftso_no, ftcustomer_code, ftship_address, fdtrans_date, ftdelivery_method, ftreference, ftnotes,  fftotal_qty, fnstatus FROM txdelivery_order_hdr");
    $objAxpDB->FormCaption("No. DO, Tipe DO, No SO, Customer, Alamat, Tgl. Transaksi, Metode Pengiriman, Referensi, Catatan, Total Qty, Status");
    $objAxpDB->FormPosition("TL, HD, HD, TL, TL, TR, HD, TR, BL, BR, BR");

    $objAxpDB->FormScript(1,"onChange=\"OnChangeDate_fdtrans_date()\"");

    $ajaxCustomer="ajax_do('penjualan.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=customer&ObjLokasi=ftso_no&ftcustomer_code='+document.getElementById('ftcustomer_code').value);";
    $objAxpDB->FormScript(2,"onChange=\"{$ajaxCustomer}\"");

    $ajaxGrid="ajax_do_grid0('penjualan.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=grid&ftso_no='+ document.getElementById('ftso_no').value);";
    $objAxpDB->FormScript(3,"onChange=\"{$ajaxGrid}\"");

    $objAxpDB->GridSQL(0, "SELECT fnindex, ftitem_code, ftlocation_code, ftwarehouse_code, fnqty_available, fnqty_so, ftuom_code as ftuom_code_so, fnqty, ftuom_code, ftprint_name, ftstock_category_code, fnqty_base, ffformula FROM txdelivery_order_det");
    $objAxpDB->GridCaption(0, "No., Kode Barang, Lokasi, Gudang, Qty Avail, Qty SO, Satuan SO, Qty DO, Satuan, Keterangan Barang, Kategori, Qty Base, Formula");
    $objAxpDB->GridHidden(0,"0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1");
    $objAxpDB->GridSize(0, ",10,5,5,,5,,5,5,10,,,,");
     //$objAxpDB->GridScroll(0,true,"100");

    $ajaxOUM_Code="ajax_do('query2.php?code=uom&obj1=' + this.value + '&obj2=ftuom_codeD0_N_&objCategoryftstock_category_codeD0_N_');";
    $ajaxQtyAvail=" onChange=\"ajax_do('query2.php?code=qty&ftwarehouse_code=' + document.getElementById('ftwarehouse_codeD0_N_').value + '&ftlocation_code=' + document.getElementById('ftlocation_codeD0_N_').value+'&ftitem_code=' + document.getElementById('ftitem_codeD0_N_').value+ '&objQty=fnqty_availableD0_N_');\"";
    $ajaxOUM_CodeAndQtyAvail=" onChange=\"{$ajaxOUM_Code};ajax_do('query2.php?code=qty&ftwarehouse_code=' + document.getElementById('ftwarehouse_codeD0_N_').value + '&ftlocation_code=' + document.getElementById('ftlocation_codeD0_N_').value+'&ftitem_code=' + document.getElementById('ftitem_codeD0_N_').value+ '&objQty=fnqty_availableD0_N_');\"";

    $ajaxGudang="OnChange=\"ajax_do('penjualan.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=gudang&ftwarehouse_code='+this.value+'&ObjLokasi=ftlocation_codeD0_N_&objQty=fnqty_availableD0_N_');\"";
    //$ajaxOUM_Code="OnChange=\"ajax_do('penjualan.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=oum&ftitem_code='+this.value+'&ftuom_code=ftuom_codeD0_N_&ftstock_category_code=ftstock_category_codeD0_N_&ObjGudang=ftwarehouse_codeD0_N_&ObjLokasi=ftlocation_codeD0_N_&objQty=fnqty_availableD0_N_');\"";
    $ajaxFormula="ajax_do('penjualan.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=formula&index=_N_&index=_N_&ftitem_code='+ document.getElementById('ftitem_codeD0_N_').value+'&ftuom_code='+ document.getElementById('ftuom_codeD0_N_').value+'&fnqty='+ document.getElementById('fnqtyD0_N_').value);";
    $ajax1=" onChange=\"{$ajaxFormula}DeliveryOrderRecalQty();\"  ";

    $objAxpDB->GridScript(0,1, $ajaxOUM_Code);
    $objAxpDB->GridScript(0,2, $ajaxGudang);
    $objAxpDB->GridScript(0,3, $ajaxQtyAvail);
    $objAxpDB->GridScript(0,7, $ajax1);
    $objAxpDB->GridDelJS(0,"DeliveryOrderRecalQty();");

    if(!$_REQUEST['id']) {
		$m="  WHERE fnstatus=1 ORDER BY ftitem_code ";
    }

    $objAxpDB->Lookup("ftcustomer_code", "SELECT ftcustomer_code, ftcustomer_name FROM tlcustomer ", "ftcustomer_code", "ftcustomer_name", -1,false);
    // $objAxpDB->Lookup("ftso_no", "SELECT ftso_no, fdtrans_date FROM txsales_order_hdr WHERE fnstatus <> 9", "ftso_no", "fdtrans_date", -1,false);
    $objAxpDB->Lookup("ftdelivery_method", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 7", "fntrans_status_code", "fttrans_status_name", -1,true);
    $objAxpDB->Lookup("fnstatus", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 2", "fntrans_status_code", "fttrans_status_name", 0,true);
    $objAxpDB->Lookup("ftdo_type", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 30", "fntrans_status_code", "fttrans_status_name", 0,true);
    $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr $m", "ftitem_code", "ftitem_name", -1,false);
    //$objAxpDB->Lookup("ftuom_code_so", "SELECT ftuom_code, ftuom_name FROM tluom", "ftuom_code", "ftuom_name", -1,true);

    if(!$_REQUEST['id']) {
          $strAutoNumber1="ajax_do('query2.php?&code=2&ftbranch_code={$_SESSION['strbranch']}&ftmodule_code=TN005&thbln=' + document.getElementById(\"fdtrans_date\").value + '&field_name=ftdo_no&no_trans=ftdo_no&table_name=txdelivery_order_hdr&ftdo_type=' + document.getElementById(\"ftdo_type\").value);";
          $ajaxTransDate="ajax_do('penjualan.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=tgl&tgl=' + document.getElementById(\"fdtrans_date\").value + '');";
          $strAutoNumber0=" function OnChangeDate_fdtrans_date() {
                                           {$strAutoNumber1}
                                            {$ajaxTransDate}
                            }
                            OnChangeDate_fdtrans_date();
                                ";

          $objAxpDB->FormJS($strAutoNumber0);

    // refresh qty available if status = draft
    } else if ($objAxpDB->GetStatus("fnstatus") == 0) {
          $strAutoNumber0=" var i=document.getElementsByName('fnindexD0[]').length;
                            for(var j=1;j < i;j++) {
                                vfnqty = ajax_do('query2.php?code=qty&ftwarehouse_code=' + document.getElementsByName('ftwarehouse_codeD0[]')[j].value + '&ftlocation_code=' + document.getElementsByName('ftlocation_codeD0[]')[j].value+'&ftitem_code=' + document.getElementsByName('ftitem_codeD0[]')[j].value+ '&objQty=fnqty_availableD0' + j);
                                document.getElementsByName('fnqty_availableD0[]')[j].value = vfnqty;
                            }

                            ";

          $objAxpDB->FormJS($strAutoNumber0);

    }

    $objAxpDB->SetStatus("id, fnstatus");

    if($_REQUEST['id']==0)
    {
        // $ssql = "SELECT DISTINCT ftso_no, fdtrans_date FROM (SELECT b.ftitem_code, a.ftso_no, a.fdtrans_date , b.fnqty AS ttlso, COALESCE(SUM(d.fnqty),0) AS ttldo FROM txsales_order_hdr a INNER JOIN txsales_order_det b ON a.ftso_no = b.ftso_no  LEFT JOIN txdelivery_order_hdr c ON a.ftso_no = c.ftso_no AND (c.fnstatus = 1 or c.fnstatus = 2) LEFT JOIN txdelivery_order_det d ON c.ftdo_no = d.ftdo_no WHERE a.fnstatus=1 GROUP BY b.ftitem_code, a.ftso_no, a.fdtrans_date  HAVING ttldo < ttlso) X order by ftso_no ";
        // $objAxpDB->Lookup("ftso_no", $ssql, "ftso_no", "fdtrans_date", -1,false);
        $objAxpDB->Lookup("ftso_no", "SELECT ftso_no, fdtrans_date FROM txsales_order_hdr where 0=1 ", "ftso_no", "fdtrans_date", -1,true);
        $objAxpDB->Lookup("ftwarehouse_code", "SELECT ftwarehouse_code, ftwarehouse_name FROM tlwarehouse WHERE ftwarehouse_code='1'", "ftwarehouse_code", "ftwarehouse_name", -1,true);
        $objAxpDB->Lookup("ftlocation_code", "SELECT ftlocation_code, ftlocation_name FROM tllocation WHERE ftlocation_code='WA'", "ftlocation_code", "ftlocation_name", -1,true);
    }
    else
    {
        $objAxpDB->Lookup("ftso_no", "SELECT ftso_no, fdtrans_date FROM txsales_order_hdr", "ftso_no", "fdtrans_date", -1,true);
        $objAxpDB->Lookup("ftwarehouse_code", "SELECT ftwarehouse_code, ftwarehouse_name FROM tlwarehouse", "ftwarehouse_code", "ftwarehouse_name", -1,true);
        $objAxpDB->Lookup("ftlocation_code", "SELECT ftlocation_code, ftlocation_name FROM tllocation", "ftlocation_code", "ftlocation_name", -1,true);
    }

    if ($objAxpDB->GetStatus("id") == "") {
            //$objAxpDB->ButtonShow("baru, cetak_daftar, export_excel , tutup");

    } elseif ($objAxpDB->GetStatus("id") == 0) {
            //$objAxpDB->GridAllowAddNew(0,true);
            //$objAxpDB->GridAllowDelete(0,true);
            $objAxpDB->FormLocked("0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1");
            $objAxpDB->GridLocked(0, "1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1");
            $objAxpDB->GridAllowDelete(0,true);
            $objAxpDB->ButtonShow("reset, simpan, tutup");

    } elseif ($objAxpDB->GetStatus("fnstatus") == 1 || $objAxpDB->GetStatus("fnstatus") == 2) {
            $objAxpDB->GridLocked(0, "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1");
            $objAxpDB->FormLocked("1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1");
            $objAxpDB->ButtonShow("cetak, tutup");

    } elseif (($objAxpDB->GetStatus("fnstatus") == 3) OR ($objAxpDB->GetStatus("fnstatus") == 9)) {
            $objAxpDB->GridLocked(0, "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1");
            $objAxpDB->FormLocked("1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1");
            $objAxpDB->ButtonShow("tutup");
    }

    if($_REQUEST['ajax']) {
           switch($_REQUEST['code']) {
           case "grid":
                ob_start();

                $objAxpDB->GridSQL(0, "SELECT a.fnindex, a.ftitem_code, '' AS ftwarehouse_code, '' AS ftlocation_code, a.fnqty_available, a.fnqty-IFNULL(a.fnqty_accept,0) AS fnqty_so, a.ftuom_code AS ftuom_so, a.fnqty-IFNULL(a.fnqty_accept,0) as fnqty, a.ftuom_code,CONVERT('', CHAR(100)) AS ftdescription, a.ftstock_category_code, a.fnqty_base-IFNULL(a.fnqty_accept_base,0) as fnqty_base, a.ffformula FROM txsales_order_det a INNER JOIN txsales_order_hdr b ON a.ftso_no=b.ftso_no WHERE a.ftso_no='{$_REQUEST['ftso_no']}' AND fnqty_base <> IFNULL(fnqty_accept_base,0) AND b.fnstatus<>9 #");
                $objAxpDB->Process();
                $objAxpDB->setGrid2(0);
                $html = ob_get_contents();
                ob_end_clean();
                ?>

                    div = document.getElementById('txtHint0');
                    var m='<?php echo js_esc($html); ?>';
                    m= m.replace(/^\s*|\s*$/g,"");

                    div.innerHTML =m;
                    RowIndex0();
                    reSize();
                <?php

                $ftcustomer_code=RetRstField("SELECT ftcustomer_code FROM txsales_order_hdr WHERE ftso_no='{$_REQUEST['ftso_no']}' AND fnstatus<>9");
                $ftcustomer_name=RetRstField("SELECT ftcustomer_name FROM tlcustomer WHERE ftcustomer_code='{$ftcustomer_code}'");
                //$ftwarehouse_default=RetRstField("SELECT ftwarehouse_code FROM tllocation WHERE fnlocation_pos  = 1 LIMIT 1;");
                //$ftlocation_default=RetRstField("SELECT ftlocation_code FROM tllocation WHERE fnlocation_pos  = 1 LIMIT 1;");

                ?>
                    var i=document.getElementsByName('fnindexD0[]').length;
                    for(var j=1;j < i;j++) {
                        document.getElementsByName('ftwarehouse_codeD0[]')[j].value='GK173';
                    }

                    DeliveryOrderRecalQty();
                <?php

               break;

           }
           die("");
           exit;
    }
    $objAxpDB->Process();

    $objAxpDB->WriteHtmlTable();
