sunxia
2022-04-18 85b18058da15575cbf98fc0227d231eb205bc30d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
var url = document.URL;
 
String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
// main.jsのなかのものをoverrideした。
DatePicker.prototype.position=function(){
    for(var a=0,c=0,b=this.myElement;null!=b&&b!=this.calendarDiv.offsetParent;)
        a+=b.offsetLeft-b.scrollLeft,
        c+=b.offsetTop-b.scrollTop,
        b=b.offsetParent;
    c=getObjY(this.myElement)+this.calendarDiv.offsetHeight>Sfdc.Window.getScrollY()+Sfdc.Window.getWindowHeight()?c-(this.calendarDiv.offsetHeight+1):c+(this.myElement.offsetHeight+1);
    b="left";
    if (a + 225 > Sfdc.Window.getWindowWidth()) {
        a = Sfdc.Window.getWindowWidth() - 225;
    }
    LC.isRtlPage()&&(b="right",a=this.calendarDiv.offsetParent.offsetWidth-a-this.myElement.offsetWidth);
    this.shim.setStyle(b,a+"px");
    this.shim.setStyle("top",c+"px")
};
 
function markOpp(color){
    var fromDate = new Date(j$(escapeVfId('allPage:allForm:searchBlock:fromDateId')).value());
    var toDate = new Date(j$(escapeVfId('allPage:allForm:searchBlock:toDateId')).value());
    
    var cnt = j$(escapeVfId('allPage:allForm:oppBlock:oppCount')).value();
    var editFlg = false;
    var matchFlg = false;
    var tempi = 0;
    
    for (var i = 1; i <= cnt; i++) {
        for(var x in keyArray){
            setColor(x, i, '');
            var tempKeyStr;
            //To get the value of the date.
            //tempKeyStr = j$(escapeVfId('allPage:allForm:oppBlock:oppTable:' + i  + ':' + keyArray[x].keyOfOpp)).text();
            if (document.getElementsByClassName(i + "_" + keyArray[x].keyOfOpp)[0] != undefined) {
                tempKeyStr = document.getElementsByClassName(i + "_" + keyArray[x].keyOfOpp)[0].innerText;
                var tempKey = new Date(tempKeyStr);
                
                if(isValidDate(tempKey) == false){
                    //The key of Opp hasn't been edited, Edited Date is invalid. so, do not change the editFlg.
                }
                else{
                    editFlg = true;
                    if((isValidDate(toDate)==true && isValidDate(fromDate) == false && tempKey <= toDate)
                        ||(isValidDate(fromDate) == true && isValidDate(toDate)==false && tempKey >= fromDate)
                        ||(isValidDate(fromDate) == true && isValidDate(toDate)==true && tempKey >= fromDate && tempKey <= toDate)
                    ){
                        setColor(x, i, color);
                        matchFlg = true;
                    }else{
                        //The data is not matching, so that nothing to do
                    }
                }
            }
        }
    }
    if(editFlg != true) alert("没有数据被更新过!");
    if(editFlg == true && matchFlg != true) alert('与检索日期匹配的数据不存在.');
    if(editFlg == true && matchFlg == true) alert('与检索日期匹配的数据已被标记.');
}
function setColor(x, i, color){
    object = document.getElementsByClassName(i + "_" + keyArray[x].keyCol)[0];
    //object = j$(escapeVfId(i + ':' + keyArray[x].keyCol))
    if (object != undefined) {
        //object.css("background-color",color);
        object.style.backgroundColor = color;
    }
}
 
function isValidDate(d) {
  if ( Object.prototype.toString.call(d) !== "[object Date]" )
    return false;
  return !isNaN(d.getTime());
}
 
function searchOppJs() {
    blockme();
    var cnt = document.getElementById('allPage:allForm:oppBlock:oppCount').value;
    var isChanged = false;
    
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:oppBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
    }
    
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并检索\n点击 [取消] 只检索,放弃保存')) {
            saveAndSearch(1);
        } else {
            searchOpp();
        }
    } else {
        searchOpp();
    }
}
 
 
function searchOppJs_Account() {
    blockme();
    var cnt = document.getElementById('allPage:allForm:oppBlock:oppCount').value;
    var isChanged = false;
    
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:oppBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
        if (document.getElementById('allPage:allForm:oppBlock:oppTable:' + i + ':changeFlgRt').value == 1) {
            isChanged = true;
            break;
        }
    }
 
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并检索\n点击 [取消] 只检索,放弃保存')) {
            saveAndSearch(1);
        } else {
            searchOpp();
        }
    } else {
        searchOpp();
    }
}
 
 
function sortTableJs(key) {
    if (typeof event.stopPropagation != "undefined") {
        event.stopPropagation();
    } else {
        event.cancelBubble = true;
    }
    blockme();
    var cnt = document.getElementById('allPage:allForm:oppBlock:oppCount').value;
    var isChanged = false;
    
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:oppBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }        
    }
    
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并排序\n点击 [取消] 只排序,放弃保存')) {
            saveAndSort(2, key);
        } else {
            sortTable(key);
        }
    } else {
        sortTable(key);
    }
}
 
 
 
function sortTableJs_Account(key) {
    if (typeof event.stopPropagation != "undefined") {
        event.stopPropagation();
    } else {
        event.cancelBubble = true;
    }
    blockme();
    var cnt = document.getElementById('allPage:allForm:oppBlock:oppCount').value;
    var isChanged = false;
    
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:oppBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
        if (document.getElementById('allPage:allForm:oppBlock:oppTable:' + i + ':changeFlgRt').value == 1) {
            isChanged = true;
            break;
        }
    }
    
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并排序\n点击 [取消] 只排序,放弃保存')) {
            saveAndSort(2, key);
        } else {
            sortTable(key);
        }
    } else {
        sortTable(key);
    }
}
// 編集チェック
function setChangeFlg(cnt) {
    
    document.getElementById('allPage:allForm:oppBlock:oppTable:' + cnt + ':changeFlg').value = 1;
}
// list の headerRow の tdに toggleWidth() を追加
function bindTdToggleWidth() {
    var i = 0;
    j$('body .pbBody table#tableHeader tr.headerRow td').each(function() {
        var colClass = getColClassName(this);
        if (colClass != 'col_Scroll') {
            listColClassWidthMap[colClass] = j$('body .pbBody table.list tr.headerRow td.' + colClass).width();
            if (colClass in listColClassMap) {
                j$(this).addClass("colViewing");
                j$(this).addClass(listColClassMap[colClass]);
            } else {
                j$(this).addClass("colViewing");
            }
            rerenderColWidth(colClass, true);
            j$(this).click(function() {
                j$(this).toggleClass("colUnHideIcon");
                rerenderColWidth(colClass, false);
            });
        }
    });
    windowResize();
    // スクロール連動
    j$('div#in_Div').scroll(function() {
        j$('div#out_Div').scrollLeft(j$(this).scrollLeft());
        j$('div#in_Div_L').scrollTop(j$(this).scrollTop());
    });
    j$('div#out_Div').scroll(function() {
        j$('div#in_Div').scrollLeft(j$(this).scrollLeft());
    });
    j$('div#in_Div_L').scroll(function() {
        j$('div#in_Div').scrollTop(j$(this).scrollTop());
    });
}
function windowResize() {
    blockHeight = j$(window).innerHeight() - j$(escapeVfId('allPage:allForm:searchBlock')).height() - heightAjustment;
    sbwidth = scrollbarWidth();
    blockWidth = j$(escapeVfId('allPage:allForm:searchBlock')).width() - j$('div#in_Div_L').width() - widthAjustment - sbwidth;
    j$(escapeVfId('allPage:allForm:oppBlock')).css('height', blockHeight + 78 + 'px');
    j$('div#in_Div').css('width', blockWidth + 'px');
    j$('div#out_Div').css('width', blockWidth + 'px');
    j$('div#in_Div').css('height', blockHeight + 'px');
    j$('div#in_Div_L').css('height', blockHeight + 'px');
 
    // Table tr の height をあわせる
    var tbl = document.getElementById('tableData_L');
    var tbl2 = document.getElementById('tableData');
    for (var i = 0; i < tbl2.rows.length; i++) {
        var ht1 = j$(tbl.rows[i]).height();
        var ht2 = j$(tbl2.rows[i]).height();
        if (ht2 < ht1) {
            j$(tbl2.rows[i]).css('height', ht1 + 'px');
        } else {
            j$(tbl.rows[i]).css('height', ht2 + 'px');
        }
    }
 
    if (j$('table#tableData').height() > j$('div#in_Div').height()) {
        j$('div#in_Div').css('width', (blockWidth + sbwidth) + 'px');
    } else {
       j$('div#out_Div').css('width', (blockWidth + sbwidth) + 'px');
        j$('div#in_Div').css('width', (blockWidth + sbwidth) + 'px');
    }
    if (j$('table#tableData').width() > j$('div#in_Div').width()) {
        j$('div#in_Div').css('height', (blockHeight + sbwidth) +'px');
    }
}
 
function expandAll(){
    // list の headerRow の tdに toggleWidth() を追加
    var i = 0;
    j$('body .pbBody table.list tr.headerRow td').each(function() {
        var colClass = getColClassName(this);
        if(j$(this).hasClass("colUnHideIcon")){
            j$(this).toggleClass("colUnHideIcon");
            rerenderColWidth(colClass, false);
        }
    });
    windowResize();
}
// 見た目用の classレベル 変数
var listColClassMap = {};          // colclass ==> colUnHideIcon or colViewing
var listColClassWidthMap = {};     // colclass ==> classのwidth
var blockHeight = 0;
var sbwidth = 0;
window.onresize = windowResize;
 
function rerenderColWidth(colClass, isFirst) {
    var tableWidth = j$('body .pbBody table#tableHeader').width();
    var headerCol = j$('body .pbBody table.list tr.headerRow td.' + colClass);
    if (headerCol.hasClass("colUnHideIcon")) {
        listColClassMap[colClass] = "colUnHideIcon";
        tableWidth -= headerCol.width();
        // 全部最小化する
        j$('body .pbBody table.list td.' + colClass).children().hide();
        j$('body .pbBody table.list td.' + colClass).width(7).css("font-size", "0");
    } else {
        listColClassMap[colClass] = "colViewing";
        if (isFirst == false) {
            var hiddenWidth = headerCol.width();
            j$('body .pbBody table.list td.' + colClass).width("").css("font-size", "");
            j$('body .pbBody table.list td.' + colClass).children().show();
            tableWidth += listColClassWidthMap[colClass] + 2 - hiddenWidth;    // 2 is border
        }
    }
    
    j$('table#tableData').css('width', (tableWidth + 2) + 'px');
    j$('table#tableHeader').css('width', (tableWidth + 2) + 'px');
}
function getColClassName(pObj) {
    var classList = j$(pObj).attr("class").split(' ');
    var rtn = "";
    if (classList.length > 0) {
        for (var i = 0; i < classList.length; i++) {
            if (classList[i].indexOf("col_") >= 0) {
                rtn = classList[i];
                break;
            }
        }
    }
    return rtn;
}