<?php
#功能列表
#----------------2009.05.22-----------------------------
#說明：產生按鈕列
#輸入：按鈕陣列 ,  統一多加的預設值名稱(加於名稱哪個位置 , 看個案而定)@寬度 , 內頁檔頭名(order_list.php;"order"即是檔頭名)@本身檔頭名
#輸出：按鈕列
#-------------------------------------------------------
function ListAction($List,$OtherStr="",$LinkPaper=""){
    $Tp = explode("?",$_SERVER["PHP_SELF"]);
    $Tmp = explode("/",$_SERVER["PHP_SELF"]);
    $Temp = explode("_",$Tmp[count($Tmp)-1]);
    $Page = $Temp[0]."_";
    $OtherStr = explode("@",$OtherStr);
    $LinkPaper = explode("@",$LinkPaper);
    $OtherWidth = $OtherStr[1]?"style=\"width:".($OtherStr[1]+($_SESSION["font"]=='text'?0:20))."px\"":"";
    $EditList["Blank"] = "　&nbsp;";
    $EditList["Subcarried"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Subcarried(document.form1)\" value=\"結轉\"> "; 
    $EditList["Delcarried"] = "<input type=\"button\" style=\"width:100px\" class=\"button_input\" onClick=\"javascript:Delcarried()\" value=\"刪除前次結轉\"> ";
    $EditList["Finish"] = "<input type=\"button\" class=\"button_input\" onClick=\"javascript:Finish()\" value=\"轉結案\"> ";
    $EditList["View"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:View()\" value=\"檢視".$OtherStr[0]."\"> ";
    $EditList["View_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function View(){
                                var obj = document.getElementById(\"MyList\");
                                var edit = 0;
                                var item = new Array();
                                for(var i=0;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        edit++;
                                    }
                                }
                                if(!edit) alert(\"請選擇欲檢視項目!!\");
                                else window.location.href = \"".($LinkPaper[0]?$LinkPaper[0]."_":$Page)."view.php?main_list=".$LinkPaper[1]."&id=\" +item +\"&main=".(substr($Temp[1],0,4)=="list"?"list":"history")."\";
                            }
                         </script>";
    $EditList["Recok"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Recok()\" value=\"確認付款\"> ";
    $EditList["Recok_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Recok(){
                                var obj = document.getElementById(\"MyList\");
                                var edit = 0;
                                var item = new Array();
                                for(var i=1;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        edit++;
                                    }
                                }
                                if(!edit) alert(\"請選擇確認付款的項目!!\");
                                else if(confirm(\"確定選擇的項目都已確認付款完畢?? \")) window.location.href = \"".$Tp[0]."\" +\"?type=apply&id=\" +item+\"&dept=\"+encodeURIComponent(document.search.dept.value)+\"&person=\"+encodeURIComponent(document.search.person.value);
                            }
                         </script>";
    $EditList["Add"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:window.location.href='".$Page."edit.php'\" value=\"新增".$OtherStr[0]."\"> ";
    $EditList["Addreturn"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:window.location.href='".$Page."add_edit.php'\" value=\"新增".$OtherStr[0]."\"> ";
    $EditList["Buy_Add"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:window.location.href='".$Page."add_edit.php'\" value=\"新增\"> ";#新增採購單
    $EditList["Edit"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Edit()\" value=\"編修".$OtherStr[0]."\"> ";
    $EditList["Edit_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Edit(){
                                var obj = document.getElementById(\"MyList\");
                                var edit = 0;
                                var item = new Array();
                                for(var i=0;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        edit++;
                                    }
                                }
                                
                                if(!edit) alert(\"請選擇欲編修項目!!\");
                                    else window.location.href = \"".($LinkPaper[0]?$LinkPaper[0]."_":$Page)."edit.php?main_list=".$LinkPaper[1]."&id=\" +item;
                            }
                         </script>";
    $EditList["Save"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Save()\" value=\"儲存".$OtherStr[0]."\"> ";
    $EditList["Save_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Save(){
                                var obj = document.getElementById(\"MyList\");
                                var edit = 0;
                                var item = new Array();
                                var val = new Array();
                                for(var i=0;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        val[val.length] = obj.rows[i].cells[2].firstChild.value;
                                        edit++;
                                    }
                                }
                                if(!edit) alert(\"請選擇欲儲存項目!!\");
                                    else window.location.href = \"".$Tp[0]."\" +\"?type=save&id=\" +item +\"&val=\" +val;
                            }
                         </script>";
    $EditList["Update"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Update()\" value=\"列表更新\"> ";
    $EditList["Update_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Update(){
                                var obj = document.getElementById(\"MyList\");
                                var edit = 0;
                                var item = new Array();
                                var val = new Array();
                                var tmpData = SelIndex.split(\",\");
                                for(var i=0;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        var Str = \"\";
                                        for(var k=0;k<tmpData.length;k++){
                                            switch(obj.rows[i].cells[tmpData[k]].firstChild.type){
                                                case \"text\":
                                                    Str = Str+ (Str?'||':'')+(obj.rows[i].cells[tmpData[k]].firstChild.value);
                                                    break;
                                                case \"checkbox\":
                                                    Str = Str+ (Str?'||':'')+(obj.rows[i].cells[tmpData[k]].firstChild.checked?'1':'0');
                                                    break;
                                                default:break;
                                            }
                                        }
                                        val[val.length] = Str;
                                        edit++;
                                    }
                                }
                                if(!edit) alert(\"請選擇欲更新項目!!\");
                                else window.location.href = \"".$Tp[0]."\" +\"?type=save&id=\" +item +\"&val=\" +val;
                            }
                         </script>";
    $EditList["Apply"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Apply()\" value=\"完成".$OtherStr[0]."\"> ";
    $EditList["Apply_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Apply(){
                                var obj = document.getElementById(\"MyList\");
                                var app = 0;
                                var item = new Array();
                                for(var i=obj.rows.length-1;i>=0;i--){
                                    
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        app++;
                                    }
                                }
                                if(!app) alert(\"請選擇已完成的項目!!\");
                                else if(confirm(\"確定選擇的項目都已".$Title."完成?? \")) 
                                     window.location.href = \"".$Tp[0]."\" +\"?type=apply&id=\" +item;
                            }
                          </script>";
    $EditList["Reapply"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Reapply()\" value=\"完成".$OtherStr[0]."\"> ";
    $EditList["Reapply_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Reapply(){
                                var obj = document.getElementById(\"MyList\");
                                var app = 0;
                                var item = new Array();
                                for(var i=obj.rows.length-1;i>=0;i--){
                                    
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        app++;
                                    }
                                }
                                if(!app) alert(\"請選擇重新申請的項目!!\");
                                else if(confirm(\"確定選擇的項目都要重新申請".$Title."審核?? \")) window.location.href = \"".$Tp[0]."\" +\"?type=reapply&id=\" +item;
                            }
                          </script>";
    $EditList["Noagree"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Noagree()\" value=\"不同意".$OtherStr[0]."\"> ";
    $EditList["Noagree_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Noagree(){
                                var obj = document.getElementById(\"MyList\");
                                var app = 0;
                                var item = new Array();
                                for(var i=obj.rows.length-1;i>=0;i--){
                                    
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        app++;
                                    }
                                }
                                if(!app) alert(\"請選擇欲退件的項目!!\");
                                else if(confirm(\"確定選擇的項目都".$Title."退件?? \")) window.location.href = \"".$Tp[0]."\" +\"?type=noagree&id=\" +item;
                            }
                          </script>";

    $EditList["Voucok"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Voucok()\" value=\"轉正式傳票\"> ";
    $EditList["Voucok_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Voucok(){
                                var obj = document.getElementById(\"MyList\");
                                var app = 0;
                                var item = new Array();
                                for(var i=obj.rows.length-1;i>=0;i--){
                                    
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        app++;
                                    }
                                }
                                if(!app) alert(\"請選擇欲轉正式傳票的項目!!\");
                                else if(confirm(\"注意 : 轉正式傳票後 , 不得再更改 , 確定選擇的項目都欲轉正式傳票?? \")) window.location.href = \"".$Tp[0]."\" +\"?type=apply&id=\" +item;
                            }
                          </script>";

    $EditList["Delete"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Delete()\" value=\"刪除".$OtherStr[0]."\"> ";
    $EditList["Delete_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Delete(){
                                var obj = document.getElementById(\"MyList\");
                                var del = 0;
                                var item = new Array();
                                var Num = document.getElementById(\"MyHead\")?0:1;
                                for(var i=Num;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                        item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                        del++;
                                    }
                                }
                                if(!del) alert(\"請選擇欲刪除的項目!!\");
                                else if(confirm(\"確定要刪除選擇的項目?? \")) window.location.href = \"".$Tp[0]."\" +\"?type=del&id=\" +item;
                            }
                           </script>";
    $EditList["Print"] = "<input type=\"button\" class=\"button_input\" onClick=\"javascript:Print()\" value=\"列印\"> ";
    $EditList["AppVouc"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:AppVouc()\" value=\"拋轉傳票\">";
    $EditList["AppVouc_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                                function AppVouc(){
                                    var obj = document.getElementById(\"MyList\");
                                    var app = 0;
                                    var item = new Array();
                                    var bok=true;
                                    for(var i=0;i<obj.rows.length;i++){
                                        if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled && obj.rows[i].cells[0].firstChild.value!='on'){
                                            if(obj.rows[i].cells[6].innerHTML=='已拋轉'){
                                                bok=false;
                                                alert(\"編號 : \"+obj.rows[i].cells[3].innerHTML +\" 已拋轉!!\");
                                                obj.rows[i].cells[0].firstChild.checked=false;
                                            }
                                            else{
                                                item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                                app++;
                                            }
                                        }
                                    }
                                    if(bok){
                                        var ErpVocher = '';
                                        if(document.search.erptovocher){
                                            ErpVocher = \"&erptovocher=\"+document.search.erptovocher.value+\"\";
                                        }
                                        if(!app) alert(\"請選擇欲拋轉的項目!!\");
                                        else if(confirm(\"確定將選擇的項目拋轉傳票?? \")) window.location.href = \"".$Page."edit.php\" +\"?type=pay&id=\" +item+ErpVocher;
                                    }
                                }
                              </script>";
    //$EditList["Export"] = "<input type=\"button\" class=\"button_input\" onClick=\"javascript:Export()\" value=\"匯出Excel\">";
    $EditList["Export_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                                function Export(){
                                    var tmp_url = window.location.href.split(\"?\");
                            		var data = \"?\"+tmp_url[1];
                                    if(tmp_url.length!=2) data='';
                                    //window.open(\"".$Page."export.php\"+data,'_blank','');
                            		document.location.href = \"".$Page."export.php\"+data;
                                }
                                </script>";
    $EditList["AddAcc"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\"  onClick=\"javascript:AddAcc()\" value=\"新增".$OtherStr[0]."\"> ";
    $EditList["EditAcc"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\"  onClick=\"javascript:EditAcc()\" value=\"編修".$OtherStr[0]."\"> ";
    $EditList["DelAcc"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\"  onClick=\"javascript:DelAcc()\" value=\"刪除".$OtherStr[0]."\"> ";
    $EditList["Buy"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\"  onClick=\"javascript:Buy()\" value=\"採購\"> ";
    $EditList["Store"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\"  onClick=\"javascript:Store()\" value=\"".$OtherStr[0]."存貨管理\"> ";
    $EditList["Deny"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Deny()\" value=\"拒絕登入\"> ";
    $EditList["Allow"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Allow()\" value=\"允許登入\"> ";
    $EditList["Batch"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:window.open('batch_price.php','_blank','location=no,top=' +(screen.height/4) +',left=' +(screen.width/4) +',width=500px,height=200px')\" value=\"".$OtherStr[0]."價格修改\"> ";
    $EditList["ImgCreate"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javscript:ImgCreate()\" value=\"建".$OtherStr[0]."資料夾\"> ";
    $EditList["ImgUpload"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javscript:ImgUpload()\" value=\"新增".$OtherStr[0]."檔案\"> ";
    $EditList["ImgMove"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javscript:ImgMove(document.form1)\" value=\"".$OtherStr[0]."檔案移動\"> ";
    $EditList["ImgCopy"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javscript:ImgCopy(document.form1)\" value=\"".$OtherStr[0]."檔案複製\"> ";
    $EditList["ImgDel"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javscript:ImgDel(document.form1)\" value=\"".$OtherStr[0]."檔案刪除\"> ";
    $EditList["ImgClear"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javscript:ImgClear(document.form1)\" value=\"".$OtherStr[0]."檔案清空\"> ";
    $EditList["ColorManager"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javscript:colorList()\" value=\"顏色管理\"> ";
    $Out = "";
    ###權限
    if(strlen($GLOBALS["ThisAuth"][0])){
    
        for($i=1;$i<count($GLOBALS["ThisAuth"][1]);$i++){
            if(!substr($GLOBALS["ThisAuth"][0],$i,1)){
                if($GLOBALS["ThisAuth"][1][$i] == "del"){
                    $EditList["Delete"] = "";
                    $EditList["Clear"] = "";
                }else{
                     $EditList[ucfirst($GLOBALS["ThisAuth"][1][$i])] = "";
                     $EditList[ucfirst($GLOBALS["ThisAuth"][1][$i])."_val"] = "";
                }
            }
        }
    }
    ###
    $Out = "";
    for($i=0;$i<count($List);$i++){
        $NewList = explode("@",$List[$i]);
        if($EditList[$NewList[0]]!=''){
            $strlen = $_SESSION["font"]=="text"?14:20;
            $NewButtonName = "<input type=\"button\" ".($NewList[2]?"style=\"width:".($NewList[2]*$strlen)."px\"":"")." class=\"button_input\" onClick=\"javascript:".$NewList[0]."()\" value=\"".$NewList[1]."\"> ";
            $Out .=($NewList[1]?$NewButtonName:$EditList[$NewList[0]]).$EditList[$NewList[0]."_val"];
        }
    }
    return $Out."　&nbsp;";
}
#----------------2009.05.22-----------------------------
#說明：產生按鈕列
#輸入：按鈕陣列 , list or edit , 統一多加的預設值名稱(加於名稱哪個位置 , 看個案而定)@寬度
#輸出：按鈕列
#-------------------------------------------------------
function EditAction($List,$IdList = "",$OtherStr = ""){
    $Tp = explode("?",$_SERVER["PHP_SELF"]);
    $Tmp = explode("/",$_SERVER["PHP_SELF"]);
    $Temp = explode("_",$Tmp[count($Tmp)-1]);
    $Page = $Temp[0]."_";
    $Tmp_Front = explode("?",$_SERVER["HTTP_REFERER"]);
    $Front = explode("_",$Tmp_Front[0]);
    $OtherStr = explode("@",$OtherStr);
    $OtherWidth = $OtherStr[1]?"style=\"width:".($OtherStr[1]+($_SESSION["font"]=='text'?0:20))."px\"":"";
    $EditList["Blank"] = "　&nbsp;";

    $EditList["Submit"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Sendsubmit(document.form1)\" value=\"送出".$OtherStr[0]."\"> ";
    $EditList["Sendsubmit"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Sendsubmit(document.form1)\" value=\"配貨通知\"> ";
    $EditList["Save"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Sendsubmit(document.form1)\" value=\"存檔\"> ";
    $EditList["Reset"] = "<input type=\"button\" class=\"button_input\" ".($OtherStr[1]?"style=\"width:".$OtherStr[1]."\"":"")." onClick=\"javascript:str=true;window.location.reload()\" value=\"重填".$OtherStr[0]."\"> ";
    $EditList["Back"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:history.back()\" value=\"返回\"> ";
    // $EditList["Back"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:window.location.href = '".($_GET["main_list"]?$_GET["main_list"]."_":$Page).($_GET["main"]?$_GET["main"]:"list").".php'\" value=\"返回\"> ";
    $EditList["Preview"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:history.go(-1)\" value=\"上一筆\" style=\"display:".(($Front[count($Front)-1]=="list.php" OR $Front[count($Front)-1]=="history.php" OR $Front[count($Front)-1]=="edit.php")?"none":"")."\"> ";
    $EditList["Next"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Next('".$IdList."')\" value=\"下一筆\" style=\"display:".($IdList?"":"none")."\">
                            <script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Next(Id){
                                window.location.href = '".$Tp[0]."?id=' +Id +'&main=".$_GET["main"]."&main_list=".$_GET["main_list"]."';
                            }
                            </script>";
    $EditList["Accapart"] = "<input type=\"button\" style=\"background-color:#3333FF;color:#FFFFFF\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:ChangeAcc(1)\" value=\"明細依單\"> ";
    $EditList["Accmerge"] = "<input type=\"button\" style=\"background-color:#3333FF;color:#FFFFFF\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:ChangeAcc(2)\" value=\"明細合併\"> ";
    $EditList["Delete"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Delete()\" value=\"刪除".$OtherStr."\"> ";
    $EditList["Delete_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Delete(){
                                var obj = document.getElementById(\"basic\");
                                var del = 0;
                                var item = new Array();
                                var m=obj.rows.length;
                                if(m>=6)
                                {
                                    for(var i=5;i<m;i++){
                                        if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled ){
                                            item[item.length] = obj.rows[i].cells[0].firstChild.value;
                                            del++;
                                        }
                                    }
                                }
                                if(!del) alert(\"請選擇欲刪除的項目!!\");
                                else if(confirm(\"確定要刪除選擇的項目?? \")) window.location.href = \"".$Tp[0]."\" +\"?id=$_GET[id]&type=del&delid=\" +item;
                            }
                           </script>";
    $EditList["Check"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Check()\" value=\"確認".$OtherStr[0]."\"> ";
    $EditList["Check_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Check(){
                                var obj = document.getElementById('pro_list');
                                for(var i=ItemRowNum;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled ){
                                        for(var j=0;j<obj.rows[i].cells.length;j++){
                                            if(obj.rows[i].cells[j].firstChild.type == 'text') obj.rows[i].cells[j].firstChild.readOnly = true;
                                            else obj.rows[i].cells[j].firstChild.disabled = true;
                                        }
                                    }
                                }
                            }
                            </script>";
    $EditList["Printedit"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:document.getElementById('print').value=1;Sendsubmit(document.form1);\" value=\"列印".$OtherStr[0]."\"> ";
    $EditList["Print"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Print()\" value=\"列印".$OtherStr[0]."\"> ";
    $EditList["Apply"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Apply()\" value=\"完成".$OtherStr[0]."\"> ";
    $EditList["Apply_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Apply(){
                                if(confirm(\"確定單據內容無誤?? \")){
                                    var obj = document.form1;
                                    obj.apply.value = 1;
                                    Sendsubmit(obj);
                                }
                            }
                          </script>";
    $EditList["Noagree"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Noagree()\" value=\"".$OtherStr[0]."退件"."\"> ";
    $EditList["Noagree_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Noagree(){
                                if(confirm(\"確定單據內容要退件?? \")){
                                    var obj = document.form1;
                                    obj.noagree.value = 1;
                                    Sendsubmit(obj);
                                }
                            }
                          </script>";
    $EditList["Reapply"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:Reapply()\" value=\"".$OtherStr[0]."重新申請"."\"> ";
    $EditList["Reapply_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Reapply(){
                                if(confirm(\"確定單據內容要重新申請?? \")){
                                    var obj = document.form1;
                                    obj.reapply.value = 1;
                                    Sendsubmit(obj);
                                }
                            }
                          </script>";
                          
    $Out = "";
    for($i=0;$i<count($List);$i++){
        $NewList = explode("@",$List[$i]);
        if($EditList[$NewList[0]]!=''){
            $strlen = $_SESSION["font"]=="text"?14:18;
            $NewButtonName = "<input type=\"button\" ".($NewList[2]?"style=\"width:".($NewList[2]*$strlen)."px\"":"")." class=\"button_input\" onClick=\"javascript:".$NewList[0]."()\" value=\"".$NewList[1]."\"> ";
            $Out .=($NewList[1]?$NewButtonName:$EditList[$NewList[0]]).$EditList[$NewList[0]."_val"];
        }
    }
    return $Out;
}
#----------------2009.05.22-----------------------------
#說明：產生按鈕列
#輸入：按鈕陣列 , 是否傳問號參數值給另一頁 , 統一多加的預設值名稱(加於名稱哪個位置 , 看個案而定)@寬度
#輸出：按鈕列
#-------------------------------------------------------
function ScanAction($List,$Qs = "",$OtherStr=""){
    $Tmp = explode("_",$_SERVER["PHP_SELF"]);
    $Page = substr($_SERVER["PHP_SELF"],0,-strlen($Tmp[count($Tmp)-1]));
    $PagePc = substr($_SERVER["PHP_SELF"],0,-strlen($Tmp[count($Tmp)-1])-1);

    $OtherStr = explode("@",$OtherStr);
    $OtherWidth = $OtherStr[1]?"style=\"width:".($OtherStr[1]+($_SESSION["font"]=='text'?0:20))."px\"":"";
    $EditList["Delete"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Delete()\" value=\"刪除".$OtherStr[0]."\"> ";
    $EditList["Delete_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Delete(){
                                var obj = document.getElementById(\"pro_list\");
                                var DelNum = obj.rows.length-1;
                                for(var i=DelNum;i>=ItemRowNum;i--){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled) obj.deleteRow(i);
                                }
                                if(document.getElementById('money')) Total();
                                
                            }
                           </script>";
    $EditList["Deletepc"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Deletepc()\" value=\"刪除".$OtherStr[0]."\"> ";
    $EditList["Deletepc_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Deletepc(){
                                var obj = document.getElementById(\"pcpro_list\");
                                var DelNum = obj.rows.length-1;
                                for(var i=DelNum;i>=ItemRowNum;i--){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled) obj.deleteRow(i);
                                }
                                if(document.getElementById('money')) Total();
                                
                            }
                           </script>";
    $EditList["Check"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Check()\" value=\"確認".$OtherStr[0]."\"> ";
    $EditList["Check_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Check(){
                                var obj = document.getElementById('pro_list');
                                for(var i=ItemRowNum;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled){
                                        for(var j=0;j<obj.rows[i].cells.length;j++){
                                            if(obj.rows[i].cells[j].firstChild.type == 'text') obj.rows[i].cells[j].firstChild.readOnly = true;
                                            else obj.rows[i].cells[j].firstChild.disabled = true;
                                        }
                                    }
                                }
                            }
                            </script>";
    $EditList["Chose"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Chose()\" value=\"選擇".$OtherStr[0]."產品\"> ";
    $EditList["Chose_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Chose(){
                                if(document.form1.cus_serial && !document.form1.cus_serial.value ) alert(\"請先選擇客戶!!\");
                                else if(document.form1.cus_title && !document.form1.cus_title.value) alert(\"客戶需先確認!!\");
                                else if(document.form1.sup_serial && !document.form1.sup_serial.value) alert(\"請先選擇廠商!!\");
                                else if(document.form1.sto_id && !document.form1.sto_id.value) alert(\"請先選擇倉庫!!\");
                                else if(document.form1.carry && !document.form1.carry.value) alert(\"請先選擇貨運方式!!\");
                                else{
                                    var Sto = '';
                                    var Sup = '';
                                    var Vid = '';
                                    if(document.form1.sto_id) Sto = document.form1.sto_id.value.split('||');
                                    if(document.form1.sup_serial) Sup = document.form1.sup_serial.value.split('||');
                                    if(document.form1.valuta) Vid = document.form1.valuta.value.split('||');
                                    var qs = ".($Qs?"'?company=' +(document.form1.company?document.form1.company.value:'') +'&discount=' +(document.form1.discount?document.form1.discount.value:'') +'&rate=' +(document.form1.rate?document.form1.rate.value:'') +'&valuta=' +Vid[0] +'&sup=' +(Sup[0]?Sup[0]:'') +'&sto=' +Sto[0];":"''")."
                                    DisPlayDiv('".$Page."pop.php' +qs);
                                    //NewWindow('".$Page."pop.php' +qs);
                                }
                            }
                            </script>";
    $EditList["Chosepc"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Chosepc()\" value=\"選擇".$OtherStr[0]."產品\"> ";
    $EditList["Chosepc_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Chosepc(){
                                if(document.form1.cus_serial && !document.form1.cus_serial.value ) alert(\"請先選擇客戶!!\");
                                else if(document.form1.cus_title && !document.form1.cus_title.value) alert(\"客戶需先確認!!\");
                                else if(document.form1.sup_serial && !document.form1.sup_serial.value) alert(\"請先選擇廠商!!\");
                                else if(document.form1.sto_id && !document.form1.sto_id.value) alert(\"請先選擇倉庫!!\");
                                else if(document.form1.carry && !document.form1.carry.value) alert(\"請先選擇貨運方式!!\");
                                else{
                                    var Sto = '';
                                    var Sup = '';
                                    var Vid = '';
                                    if(document.form1.sto_id) Sto = document.form1.sto_id.value.split('||');
                                    if(document.form1.sup_serial) Sup = document.form1.sup_serial.value.split('||');
                                    if(document.form1.valuta) Vid = document.form1.valuta.value.split('||');
                                    var qs = ".($Qs?"'?company=' +(document.form1.company?document.form1.company.value:'') +'&discount=' +(document.form1.discount?document.form1.discount.value:'') +'&rate=' +(document.form1.rate?document.form1.rate.value:'') +'&valuta=' +Vid[0] +'&sup=' +(Sup[0]?Sup[0]:'') +'&sto=' +Sto[0];":"''")."
                                    DisPlayDiv('".$PagePc."pc_pop.php' +qs);
                                }
                            }
                            </script>";
    $EditList["Load"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Load()\" value=\"載入".$OtherStr[0]."明細\"> ";
    $EditList["Load_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Load(){
                                var qs = '?';
                                if(document.form1.cus_serial){
                                    if(!document.form1.cus_serial.value){
                                        alert(\"請先選擇客戶!!\");
                                        return;
                                    }else{
                                        var Cus = document.form1.cus_serial.value.split('||');
                                        qs += '&cus=' +Cus[0];
                                    }
                                }
                                if(document.form1.sup_serial){
                                    if(!document.form1.sup_serial.value){
                                        alert(\"請先選擇廠商!!\");
                                        return;
                                    }else{
                                        var Sup = document.form1.sup_serial.value.split('||');
                                        qs += '&sup=' +Sup[0];
                                    }
                                }
                                if(document.form1.sto_id){
                                    if(!document.form1.sto_id.value){
                                        alert(\"請先選擇倉庫!!\");
                                        return;
                                    }else{
                                        var Sto = document.form1.sto_id.value.split('||');
                                        qs += '&sto=' +Sto[0];
                                    }
                                }
                                DisPlayDiv('".$Page."chose.php' +qs);
                                //NewWindow('".$Page."chose.php' +qs);
                            }
                            </script>";
    $EditList["AddVouc"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:AddVouc()\" value=\"新增".$OtherStr[0]."\"> ";
    $EditList["DelVouc"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:DelVouc()\" value=\"刪除".$OtherStr[0]."\"> ";
    $Out = "";
    for($i=0;$i<count($List);$i++){
        $NewList = explode("@",$List[$i]);
        if($EditList[$NewList[0]]!=''){
            $strlen = $_SESSION["font"]=="text"?14:18;
            $NewButtonName = "<input type=\"button\" ".($NewList[2]?"style=\"width:".($NewList[2]*$strlen)."px\"":"")." class=\"button_input\" onClick=\"javascript:".$NewList[0]."()\" value=\"".$NewList[1]."\"> ";
            $Out .=($NewList[1]?$NewButtonName:$EditList[$NewList[0]]).$EditList[$NewList[0]."_val"];
        }
    }
    return $Out;
}
#----------------2009.05.22-----------------------------
#說明：產生按鈕列
#輸入：按鈕陣列 , 統一多加的預設值名稱(加於名稱哪個位置 , 看個案而定)@寬度
#輸出：按鈕列
#-------------------------------------------------------
function PopAction($List,$OtherStr=""){
    $OtherStr = explode("@",$OtherStr);
    $OtherWidth = $OtherStr[1]?"style=\"width:".($OtherStr[1]+($_SESSION["font"]=='text'?0:20))."px\"":"";

    $EditList["Chose"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Chose()\" value=\"加入".$OtherStr[0]."\"> ";
    $EditList["Chose_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Chose(){
                                var obj = document.getElementById(\"MyList\");//pop
                                var objweb = parent.document.getElementById(\"web\");
                                var MyObj = objweb.contentWindow.document.getElementById(\"pro_list\");//編修
                             
                                for(var i=0;i<obj.rows.length;i++){
                                    
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled){
alert('Chose_val'+i);                                           
                                        var tmpfld = JoinFld.split(',');
//                                         for(var o=0;o<tmpfld.length;o++){
//                                             objweb.contentWindow.document.getElementById(tmpfld[o]).value = obj.rows[i].cells[parseInt(o)+2].firstChild.value;
//                                         }
                                       var o=0 ;
//alert(parseInt(o)+2 + ':' + obj.rows[0].cells.length);                                           
                                       for(var j=parseInt(o)+2;j<obj.rows[0].cells.length;j++){
//alert( (objweb.contentWindow.ItemRowNum-1) + ':' + ( j-parseInt(tmpfld.length)) + ':' +);                                        
alert(obj.rows[i].cells[j].firstChild.type + ':' + obj.rows[i].cells[j].firstChild.value );                                    
//                                            switch(MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.type){
                                           switch(obj.rows[i].cells[j].firstChild.type){
                                                case 'text':
                                                
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.value = obj.rows[i].cells[j].firstChild.value;
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.alt = obj.rows[i].cells[j].firstChild.alt;
                                                    break;
                                                case 'select-one':
                                                    for(var k=0;k<obj.rows[i].cells[j].firstChild.options.length;k++){
                                                        var x = document.createElement('option');
                                                        x.text = obj.rows[i].cells[j].firstChild.options[k].text;
                                                        x.value = obj.rows[i].cells[j].firstChild.options[k].value;
                                                        x.selected = obj.rows[i].cells[j].firstChild.options[k].selected;
                                                        if(navigator.appName != \"Netscape\") objweb.contentWindow.SelAdd((objweb.contentWindow.ItemRowNum-1),(j-parseInt(tmpfld.length)),x);
                                                        else{
                                                            try{
                                                                MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.add(x,null);
                                                            }catch(ex){
                                                                // MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.add(x);
                                                            }
                                                        }
                                                    }
                                                    
                                                    //MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.options[obj.rows[i].cells[j].firstChild.selectedIndex].selected = true;
                                                    //MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.disabled = obj.rows[i].cells[j].firstChild.disabled;
                                                    break;
                                                default:
                                                break;
                                            }
                                        }
                                        
                                        //objweb.contentWindow.Add();
                                        document.body.focus();
                                        obj.rows[i].cells[0].firstChild.disabled = true;
                                        
                                    }
                                }
                            }
                          </script>";
    $EditList["ChoseReceipt"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:ChoseReceipt()\" value=\"加入".$OtherStr[0]."\"> ";
    $EditList["ChoseReceipt_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function ChoseReceipt(){
                                var obj = document.getElementById(\"MyList\");//pop
                                var objweb = parent.document.getElementById(\"web\");
                                var MyObj = objweb.contentWindow.document.getElementById(\"pro_list\");//編修
                                for(var i=0;i<obj.rows.length;i++){
                                    
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled){
                                        for(var j=2;j<obj.rows[0].cells.length;j++){
                                            switch(MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-1].firstChild.type){
                                                case 'text':
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-1].firstChild.value = obj.rows[i].cells[j].firstChild.value;
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-1].firstChild.alt = obj.rows[i].cells[j].firstChild.alt;
                                                    break;
                                                default:break;
                                            }
                                        }
                                        objweb.contentWindow.AddReceipt();
                                        obj.rows[i].cells[0].firstChild.disabled = true;

                                    }
                                }
                            }
                          </script>";
    $EditList["Chosepc"] = "<input type=\"button\" class=\"button_input\" ".$OtherWidth." onClick=\"javascript:Chosepc()\" value=\"加入".$OtherStr[0]."\"> ";
    $EditList["Chosepc_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                            function Chosepc(){
                                var obj = document.getElementById(\"MyList\");//pop
                                var objweb = parent.document.getElementById(\"web\");
                                var MyObj = objweb.contentWindow.document.getElementById(\"pcpro_list\");//編修
                                for(var i=0;i<obj.rows.length;i++){
                                    if(obj.rows[i].cells[0].firstChild.checked && !obj.rows[i].cells[0].firstChild.disabled){
                                        var tmpfld = 'pid'.split(\",\");
                                        for(var o=0;o<tmpfld.length;o++){
                                            objweb.contentWindow.document.getElementById(tmpfld[o]).value = obj.rows[i].cells[parseInt(o)+2].firstChild.value;
                                        }
                                        for(var j=parseInt(o)+2;j<obj.rows[0].cells.length;j++){
                                            switch(MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.type){
                                                case 'text':    
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.value = obj.rows[i].cells[j].firstChild.value;
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.alt = obj.rows[i].cells[j].firstChild.alt;
                                                    break;
                                                case 'select-one':
                                                    for(var k=0;k<obj.rows[i].cells[j].firstChild.options.length;k++){
                                                        var x = document.createElement('option');
                                                        x.text = obj.rows[i].cells[j].firstChild.options[k].text;
                                                        x.value = obj.rows[i].cells[j].firstChild.options[k].value;
                                                        x.selected = obj.rows[i].cells[j].firstChild.options[k].selected;
                                                        if(navigator.appName != \"Netscape\") objweb.contentWindow.SelAdd((objweb.contentWindow.ItemRowNum-1),(j-parseInt(tmpfld.length)),x);
                                                        else{
                                                            try{
                                                                MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.add(x,null);
                                                            }catch(ex){
                                                                 MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.add(x);
                                                            }
                                                        }
                                                    }
                                                    
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.options[obj.rows[i].cells[j].firstChild.selectedIndex].selected = true;
                                                    MyObj.rows[objweb.contentWindow.ItemRowNum-1].cells[j-parseInt(tmpfld.length)].firstChild.disabled = obj.rows[i].cells[j].firstChild.disabled;
                                                    break;
                                                default:break;
                                            }
                                        }
                                        objweb.contentWindow.Addpc();
                                        obj.rows[i].cells[0].firstChild.disabled = true;
                                        
                                    }
                                }
                            }
                          </script>";
    $EditList["Close"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:str=true;window.close()\" value=\"關閉視窗\"> ";
    $EditList["CloseDiv"] = "<input type=\"button\" ".$OtherWidth." class=\"button_input\" onClick=\"javascript:CloseDiv();\" value=\"關閉圖層\"> ";
    $EditList["CloseDiv_val"] = "<script language=\"JavaScript\" type=\"text/JavaScript\">
                                function CloseDiv(){
                                    var buffer = parent.parent.document.getElementById('buffer');
                                    var pause = parent.parent.document.getElementById('pause');
                                    buffer.style.display = 'none';
                                    pause.style.display = 'none';
                                    buffer.innerHTML = '';
                                }    
                                </script>";
    $Out = "";
    for($i=0;$i<count($List);$i++){
        $NewList = explode("@",$List[$i]);
        if($EditList[$NewList[0]]!=''){
            $strlen = $_SESSION["font"]=="text"?14:18;
            $NewButtonName = "<input type=\"button\" ".($NewList[2]?"style=\"width:".($NewList[2]*$strlen)."px\"":"")." class=\"button_input\" onClick=\"javascript:".$NewList[0]."()\" value=\"".$NewList[1]."\"> ";
            $Out .=($NewList[1]?$NewButtonName:$EditList[$NewList[0]]).$EditList[$NewList[0]."_val"];
        }
    }
    return $Out."　&nbsp;";
}

#----------------2009.12.29-----------------------------
#說明:付款方式為票據存入票據管理
#輸入:付款單編號
#輸出:無
#-------------------------------------------------------
function  AddNumber($Id){   
    $res=DB_QUERY("SELECT * FROM $GLOBALS[DB_PAYLIST] WHERE serial='".$Id."'");
    $row=mysql_fetch_assoc($res);    
    $fil = Array("date","maturity","bank_serial","bank_title","bank_account","number","price","kind","dis_serial","sup_cate","sup_serial","sup_title","remarks");
    $val = Array($row["pay_date"],$row["maturity_date"],$row["bank_serial"],$row["bank_title"],$row["bank_account"],$row["number"],$row["price"],$row["kind"],$row["serial"],$row["sup_cate"],$row["sup_serial"],$row["sup_title"],$row["remarks"]);
    DB_INSERT($GLOBALS["DB_ACCTICKET"],$fil,$val);
}

#----------------2009.12.29-----------------------------
#說明:收款方式為支票-存入客戶票據管理
#輸入:收款單編號
#輸出:無
#-------------------------------------------------------
function  AddRecNumber($Id){   
    $res=DB_QUERY("SELECT * FROM $GLOBALS[DB_RECEIVLIST] WHERE serial='".$Id."'");
    $row=mysql_fetch_assoc($res);    
    $fils=Array("bank_serial","bank_title","rec_date","maturity_date","rec_serial","encash_rub","cus_cate","cus_serial","cus_title","check_number","price","cus_account");
    $row["encash_rub"]=1;
    $row["rec_serial"]=$Id;
    for($x=0;$x<count($fils);$x++){
            $vals[] = $row[$fils[$x]];
    }
    DB_INSERT($GLOBALS["DB_CUS_TICKET"],$fils,$vals);
    $vals="";
}



/***********************下拉式搜尋*************/
#----------------2009.10.09-----------------------------
#說明： 回傳部門職務連動下拉式選單
#輸入： 部門代碼 , 職務代碼 , 更改部門選項需額外呼叫的函數(javascript) / 是否唯讀true 
#-------------------------------------------------------
function FDeptJob($Dval,$Jval,$Func="",$Dis=""){
    $Str = "<select name=\"dept\" class=\"page_main_right_select_02\" onChange=\"javascript:Job(this.value);".($Func?$Func:"")."\" ".($Dis?"disabled":"")."><option value=\"\">-- 請選擇 --</option>";
    $res = DB_QUERY("SELECT * FROM $GLOBALS[DB_DEPT] ORDER BY serial");
    while($row=mysql_fetch_array($res)){
        $Str.= "<option value=\"".$row["serial"]."\" ".($row["serial"]==$Dval?'selected':'').">".$row["title"]."</option>";
    }
    $Str.="</select>";
    $Str.="<select name=\"job\" class=\"page_main_right_select_02\" ".($Dis?"disabled":"").">";
    $res = DB_QUERY("SELECT * FROM $GLOBALS[DB_JOB] WHERE dserial='".$Dval."' ORDER BY serial");
    if(!mysql_num_rows($res)){
        $Str.= "<option value=\"\" >-- 請選擇部門 --</option>";
    }else{
        while($row=mysql_fetch_array($res)){
            $Str.= "<option value=\"".$row["serial"]."\" ".($row["serial"]==$Jval?'selected':'').">".$row["title"]."</option>";
        }
    }
    $Str.="</select>";
    return $Str;
}
#----------------2009.10.09-----------------------------
#說明：回傳部門下拉式選單
#輸入： 部門代碼 , 是否唯讀true
#-------------------------------------------------------
function FDept($Dval,$Dis=""){
    $Str = "<select name=\"did\" class=\"page_main_right_select_02\"  ".($Dis?"disabled":"")."><option value=\"\">-- 請選擇部門 --</option>";
    $res = DB_QUERY("SELECT * FROM $GLOBALS[DB_DEPT] ORDER BY serial");
    while($row=mysql_fetch_array($res)){
        $Str.= "<option value=\"".$row["serial"]."\" ".($row["serial"]==$Dval?'selected':'').">".$row["title"]."</option>";
    }
    $Str.="</select>";
    return $Str;
}


#----------------2009.10.09-----------------------------
#說明：回傳商品屬性1下拉式選單
#輸入： 商品屬性代碼 , 是否唯讀true
#-------------------------------------------------------
function FProChar1($Chv,$Dis="",$WHERE="" ){
    $Str = "<select name=\"uid\" class=\"page_main_right_select_02\"  ".($Dis?"disabled":"")."><option value=\"\">-- 請選擇類別 --</option>";
    $res = DB_QUERY("SELECT * FROM $GLOBALS[DB_PROCHAR1] ".($WHERE?"WHERE ".$WHERE:"")." ORDER BY serial");
    while($row=mysql_fetch_array($res)){
        $Str.= "<option value=\"".$row["serial"]."\" ".($row["serial"]==$Chv?'selected':'').">".$row["title"]."</option>";
    }
    $Str.="</select>";
    return $Str;
}



#----------------2009.10.16-----------------------------
#說明：廠商分類下拉式
#輸入： 分類編號 , 是否唯讀
#-------------------------------------------------------
function FSupCate($Chv,$Dis=""){
    $Str = "<select name=\"cate\" class=\"page_main_right_select_02\" ".($Dis?"disabled":"")."><option value=\"\">-- 請選擇廠商分類 --</option>";
    $res = DB_QUERY("SELECT * FROM $GLOBALS[DB_SUPCATE] ORDER BY sort DESC,serial");
    while($row=mysql_fetch_array($res)){
        $Str.= "<option value=\"".$row["serial"]."\" ".($row["serial"]==$Chv?'selected':'').">".$row["title"]."</option>";
    }
    $Str.="</select>";
    return $Str;
}
#----------------2009.10.16-----------------------------
#說明：會員分類下拉式
#輸入： 分類編號 , 是否唯讀
#-------------------------------------------------------
function FCusCate($Chv,$Dis=""){
    $Str = "<select name=\"cate\" class=\"page_main_right_select_02\" ".($Dis?"disabled":"")."><option value=\"\">-- 請選擇客戶分類 --</option>";
    $res = DB_QUERY("SELECT * FROM $GLOBALS[DB_CUSCATE] ORDER BY sort DESC,serial");
    while($row=mysql_fetch_array($res)){
        $Str.= "<option value=\"".$row["serial"]."\" ".($row["serial"]==$Chv?'selected':'').">".$row["title"]."</option>";
    }
    $Str.="</select>";
    return $Str;
}


/***********************下拉式搜尋*************/
?>