1 function NewJobProposalLoadLanguage(_currentUser)
2 {
3 document.getElementById("DropDownListLanguage").length = 0;
4 $().SPServices({
5 operation: "GetListItems",
6 async: true,
7 listName: "z_user",
8 CAMLQuery: "<Query><Where><Eq><FieldRef Name='LinkTitle' /><Value Type='string'>"+_currentUser +"</Value></Eq></Where></Query>",
9 CAMLViewFields: "<ViewFields><FieldRef Name='COMPANY'/><FieldRef Name='NAME'/><FieldRef Name='ID'/></ViewFields>",
10 completefunc: function (xData, Status) {
11 var _companyName = "";
12 var _userName = "";
13 var _userID = "";
14 $(xData.responseXML).find("[nodeName='z:row']").each(function() {
15 _companyName = $(this).attr("ows_COMPANY");
16 _userName = $(this).attr("ows_NAME");
17 _userID = $(this).attr("ows_ID");
18 });
19 //bind Vendor LPM TextBox
20 if(document.getElementById("TextBoxVenderLPM") != null)
21 {
22 document.getElementById("TextBoxVenderLPM").value = _userID+";#"+_userName;
23 }
24 _companyName = _companyName.substring(_companyName.indexOf("#")+1);
25 if(document.getElementById("spanVendorCompany") != null)
26 {
27 document.getElementById("spanVendorCompany").value = _companyName;
28 }
29 //alert(_companyNane);
30 //get languages from Company List
31 $().SPServices({
32 operation: "GetListItems",
33 async: true,
34 listName: "z_company",
35 CAMLQuery: "<Query><Where><Eq><FieldRef Name='LinkTitle'/><Value Type='string'>"+_companyName+"</Value></Eq></Where></Query>",
36 CAMLViewFields: "<ViewFields><FieldRef Name='PO_NUMBER'/><FieldRef Name='LANGUAGES'/></ViewFields>",
37 completefunc: function (xData, Status) {
38 var _PoNumber = ""
39 var _languages = ""
40 $(xData.responseXML).find("[nodeName='z:row']").each(function() {
41 _PoNumber = $(this).attr("ows_PO_NUMBER");
42 _languages = $(this).attr("ows_LANGUAGES");
43 });
44 //bind the PO Number of his company.
45 if(document.getElementById("TextBoxPONumber") != null)
46 {
47 document.getElementById("TextBoxPONumber").value = _PoNumber;
48 }
49 var _languagesArray = new Array();
50 _languagesArray = _languages.split(";#");
51 var languageQueryStr = "#######"
52 for(var i =0;i<_languagesArray.length;i++)
53 {
54 if(i==_languagesArray.length-1)
55 {
56 languageQueryStr = languageQueryStr.replace("#######","<Eq><FieldRef Name=\'LinkTitle\'/><Value Type=\'string\'>"+_languagesArray[i]+"</Value></Eq>");
57
58 }
59 else if(i%2 == 1)
60 {
61 languageQueryStr = languageQueryStr.replace("#######","<Or>#######<Eq><FieldRef Name=\'LinkTitle\'/><Value Type=\'string\'>"+_languagesArray[i]+"</Value></Eq></Or>");
62 }
63 }
64 $().SPServices({
65 operation: "GetListItems",
66 async: true,
67 listName: "m_language",
68 CAMLQuery: "<Query><Where>"+languageQueryStr+"</Where><OrderBy><FieldRef Name='LinkTitle'/></OrderBy></Query>",
69 CAMLViewFields: "<ViewFields><FieldRef Name='LinkTitle'/><FieldRef Name='ID'/></ViewFields>",
70 completefunc: function (xData, Status) {
71 $(xData.responseXML).find("[nodeName='z:row']").each(function() {
72 var _languageName = $(this).attr("ows_LinkTitle");
73 var _languageNameID = $(this).attr("ows_ID");
74 if(document.getElementById("DropDownListLanguage") != null)
75 {
76 document.getElementById("DropDownListLanguage").add(new Option(_languageName,_languageNameID+";#"+_languageName ));
77 }
78 });
79 //bind unit price
80 NewJobProposalLoadUnitPrice();
81 }
82 });
83
84 }//end of completefunc: function (xData, Status) {
85 });
86 //end get languages from Company List
87 }
88 });
89 }