【调度系统】广东民航医疗快线调度系统源代码
hzj
2025-07-09 4418374d26a16ec759e06059c2b1fedabe1827e6
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
/*jshint eqeqeq:false, eqnull:true, devel:true */
/*global jQuery, define */
(function( factory ) {
    "use strict";
    if ( typeof define === "function" && define.amd ) {
        // AMD. Register as an anonymous module.
        define([
            "jquery",
            "./grid.base",
            "./grid.common"
        ], factory );
    } else {
        // Browser globals
        factory( jQuery );
    }
}(function( $ ) {
"use strict";
//module begin
$.jgrid.inlineEdit = $.jgrid.inlineEdit || {};
$.jgrid.extend({
//Editing
    editRow : function(rowid,keys,oneditfunc,successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
        // Compatible mode old versions
        var o={}, args = $.makeArray(arguments).slice(1);
 
        if( $.type(args[0]) === "object" ) {
            o = args[0];
        } else {
            if (keys !== undefined) { o.keys = keys; }
            if ($.isFunction(oneditfunc)) { o.oneditfunc = oneditfunc; }
            if ($.isFunction(successfunc)) { o.successfunc = successfunc; }
            if (url !== undefined) { o.url = url; }
            if (extraparam !== undefined) { o.extraparam = extraparam; }
            if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; }
            if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; }
            if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
            // last two not as param, but as object (sorry)
            //if (restoreAfterError !== undefined) { o.restoreAfterError = restoreAfterError; }
            //if (mtype !== undefined) { o.mtype = mtype || "POST"; }            
        }
        o = $.extend(true, {
            keys : false,
            keyevent : "keydown",
            oneditfunc: null,
            successfunc: null,
            url: null,
            extraparam: {},
            aftersavefunc: null,
            errorfunc: null,
            afterrestorefunc: null,
            restoreAfterError: true,
            mtype: "POST",
            focusField : true
        }, $.jgrid.inlineEdit, o );
 
        // End compatible
        return this.each(function(){
            var $t = this, nm, tmp, editable, cnt=0, focus=null, svr={}, ind,cm, bfer,
            inpclass = $(this).jqGrid('getStyleUI',$t.p.styleUI+".inlinedit",'inputClass', true);
            if (!$t.grid ) { return; }
            ind = $($t).jqGrid("getInd",rowid,true);
            if( ind === false ) {return;}
            bfer = $.isFunction( o.beforeEditRow ) ? o.beforeEditRow.call($t,o, rowid) :  undefined;
            if( bfer === undefined ) {
                bfer = true;
            }
            if(!bfer) { return; }
            editable = $(ind).attr("editable") || "0";
            if (editable === "0" && !$(ind).hasClass("not-editable-row")) {
                cm = $t.p.colModel;
                $('td[role="gridcell"]',ind).each( function(i) {
                    nm = cm[i].name;
                    var treeg = $t.p.treeGrid===true && nm === $t.p.ExpandColumn;
                    if(treeg) { tmp = $("span:first",this).html();}
                    else {
                        try {
                            tmp = $.unformat.call($t,this,{rowId:rowid, colModel:cm[i]},i);
                        } catch (_) {
                            tmp =  ( cm[i].edittype && cm[i].edittype === 'textarea' ) ? $(this).text() : $(this).html();
                        }
                    }
                    if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
                        if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
                        svr[nm]=tmp;
                        if(cm[i].editable===true) {
                            if(focus===null) { focus = i; }
                            if (treeg) { $("span:first",this).html(""); }
                            else { $(this).html(""); }
                            var opt = $.extend({},cm[i].editoptions || {},{id:rowid+"_"+nm,name:nm,rowId:rowid, oper:'edit'});
                            if(!cm[i].edittype) { cm[i].edittype = "text"; }
                            if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';}
                            var elc = $.jgrid.createEl.call($t,cm[i].edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {}));
                            $(elc).addClass("editable inline-edit-cell");
                            if( $.inArray(cm[i].edittype, ['text','textarea','password','select']) > -1) {
                                $(elc).addClass( inpclass );
                            }
                            if(treeg) { $("span:first",this).append(elc); }
                            else { $(this).append(elc); }
                            $.jgrid.bindEv.call($t, elc, opt);
                            //Again IE
                            if(cm[i].edittype === "select" && cm[i].editoptions!==undefined && cm[i].editoptions.multiple===true  && cm[i].editoptions.dataUrl===undefined && $.jgrid.msie) {
                                $(elc).width($(elc).width());
                            }
                            cnt++;
                        }
                    }
                });
                if(cnt > 0) {
                    svr.id = rowid; $t.p.savedRow.push(svr);
                    $(ind).attr("editable","1");
                    if(o.focusField ) {
                        if(typeof o.focusField === 'number' && parseInt(o.focusField,10) <= cm.length) {
                            focus = o.focusField;
                        }
                        setTimeout(function(){ 
                            var fe = $("td:eq("+focus+") :input:visible",ind).not(":disabled"); 
                            if(fe.length > 0) {
                                fe.focus();
                            }
                        },0);
                    }
                    if(o.keys===true) {
                        $(ind).bind( o.keyevent ,function(e) {
                            if (e.keyCode === 27) {
                                $($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
                                if($t.p.inlineNav) {
                                    try {
                                        $($t).jqGrid('showAddEditButtons');
                                    } catch (eer1) {}
                                }
                                return false;
                            }
                            if (e.keyCode === 13) {
                                var ta = e.target;
                                if(ta.tagName === 'TEXTAREA') { return true; }
                                if( $($t).jqGrid("saveRow", rowid, o ) ) {
                                    if($t.p.inlineNav) {
                                        try {
                                            $($t).jqGrid('showAddEditButtons');
                                        } catch (eer2) {}
                                    }
                                }
                                return false;
                            }
                        });
                    }
                    $($t).triggerHandler("jqGridInlineEditRow", [rowid, o]);
                    if( $.isFunction(o.oneditfunc)) { o.oneditfunc.call($t, rowid); }
                }
            }
        });
    },
    saveRow : function(rowid, successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
        // Compatible mode old versions
        var args = $.makeArray(arguments).slice(1), o = {}, $t = this[0];
 
        if( $.type(args[0]) === "object" ) {
            o = args[0];
        } else {
            if ($.isFunction(successfunc)) { o.successfunc = successfunc; }
            if (url !== undefined) { o.url = url; }
            if (extraparam !== undefined) { o.extraparam = extraparam; }
            if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; }
            if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; }
            if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
        }
        o = $.extend(true, {
            successfunc: null,
            url: null,
            extraparam: {},
            aftersavefunc: null,
            errorfunc: null,
            afterrestorefunc: null,
            restoreAfterError: true,
            mtype: "POST",
            saveui : "enable",
            savetext : $.jgrid.getRegional($t,'defaults.savetext')
        }, $.jgrid.inlineEdit, o );
        // End compatible
 
        var success = false, nm, tmp={}, tmp2={}, tmp3= {}, editable, fr, cv, ind, nullIfEmpty=false,
        error = $.trim( $($t).jqGrid('getStyleUI', $t.p.styleUI+'.common', 'error', true) );
        if (!$t.grid ) { return success; }
        ind = $($t).jqGrid("getInd",rowid,true);
        if(ind === false) {return success;}
        var errors = $.jgrid.getRegional(this, 'errors'),
        edit =$.jgrid.getRegional(this, 'edit'),
        bfsr = $.isFunction( o.beforeSaveRow ) ?    o.beforeSaveRow.call($t,o, rowid) :  undefined;
        if( bfsr === undefined ) {
            bfsr = true;
        }
        if(!bfsr) { return; }
        editable = $(ind).attr("editable");
        o.url = o.url || $t.p.editurl;
        if (editable==="1") {
            var cm;
            $('td[role="gridcell"]',ind).each(function(i) {
                cm = $t.p.colModel[i];
                nm = cm.name;
                if ( nm !== 'cb' && nm !== 'subgrid' && cm.editable===true && nm !== 'rn' && !$(this).hasClass('not-editable-cell')) {
                    switch (cm.edittype) {
                        case "checkbox":
                            var cbv = ["Yes","No"];
                            if(cm.editoptions ) {
                                cbv = cm.editoptions.value.split(":");
                            }
                            tmp[nm]=  $("input",this).is(":checked") ? cbv[0] : cbv[1]; 
                            break;
                        case 'text':
                        case 'password':
                        case 'textarea':
                        case "button" :
                            tmp[nm]=$("input, textarea",this).val();
                            break;
                        case 'select':
                            if(!cm.editoptions.multiple) {
                                tmp[nm] = $("select option:selected",this).val();
                                tmp2[nm] = $("select option:selected", this).text();
                            } else {
                                var sel = $("select",this), selectedText = [];
                                tmp[nm] = $(sel).val();
                                if(tmp[nm]) { tmp[nm]= tmp[nm].join(","); } else { tmp[nm] =""; }
                                $("select option:selected",this).each(
                                    function(i,selected){
                                        selectedText[i] = $(selected).text();
                                    }
                                );
                                tmp2[nm] = selectedText.join(",");
                            }
                            if(cm.formatter && cm.formatter === 'select') { tmp2={}; }
                            break;
                        case 'custom' :
                            try {
                                if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) {
                                    tmp[nm] = cm.editoptions.custom_value.call($t, $(".customelement",this),'get');
                                    if (tmp[nm] === undefined) { throw "e2"; }
                                } else { throw "e1"; }
                            } catch (e) {
                                if (e==="e1") { $.jgrid.info_dialog(errors.errcap,"function 'custom_value' "+edit.msg.nodefined,edit.bClose, {styleUI : $t.p.styleUI }); }
                                else { $.jgrid.info_dialog(errors.errcap,e.message,edit.bClose, {styleUI : $t.p.styleUI }); }
                            }
                            break;
                    }
                    cv = $.jgrid.checkValues.call($t,tmp[nm],i);
                    if(cv[0] === false) {
                        return false;
                    }
                    if($t.p.autoencode) { tmp[nm] = $.jgrid.htmlEncode(tmp[nm]); }
                    if(o.url !== 'clientArray' && cm.editoptions && cm.editoptions.NullIfEmpty === true) {
                        if(tmp[nm] === "") {
                            tmp3[nm] = 'null';
                            nullIfEmpty = true;
                        }
                    }
                }
            });
            if (cv[0] === false){
                try {
                    var tr = $($t).jqGrid('getGridRowById', rowid), positions = $.jgrid.findPos(tr);
                    $.jgrid.info_dialog(errors.errcap,cv[1],edit.bClose,{left:positions[0],top:positions[1]+$(tr).outerHeight(), styleUI : $t.p.styleUI });
                } catch (e) {
                    alert(cv[1]);
                }
                return success;
            }
            var idname, opers = $t.p.prmNames, oldRowId = rowid;
            if ($t.p.keyName === false) {
                idname = opers.id;
            } else {
                idname = $t.p.keyName;
            }
            if(tmp) {
                tmp[opers.oper] = opers.editoper;
                if (tmp[idname] === undefined || tmp[idname]==="") {
                    tmp[idname] = rowid;
                } else if (ind.id !== $t.p.idPrefix + tmp[idname]) {
                    // rename rowid
                    var oldid = $.jgrid.stripPref($t.p.idPrefix, rowid);
                    if ($t.p._index[oldid] !== undefined) {
                        $t.p._index[tmp[idname]] = $t.p._index[oldid];
                        delete $t.p._index[oldid];
                    }
                    rowid = $t.p.idPrefix + tmp[idname];
                    $(ind).attr("id", rowid);
                    if ($t.p.selrow === oldRowId) {
                        $t.p.selrow = rowid;
                    }
                    if ($.isArray($t.p.selarrrow)) {
                        var i = $.inArray(oldRowId, $t.p.selarrrow);
                        if (i>=0) {
                            $t.p.selarrrow[i] = rowid;
                        }
                    }
                    if ($t.p.multiselect) {
                        var newCboxId = "jqg_" + $t.p.id + "_" + rowid;
                        $("input.cbox",ind)
                            .attr("id", newCboxId)
                            .attr("name", newCboxId);
                    }
                    // TODO: to test the case of frozen columns
                }
                if($t.p.inlineData === undefined) { $t.p.inlineData ={}; }
                tmp = $.extend({},tmp,$t.p.inlineData,o.extraparam);
            }
            if (o.url === 'clientArray') {
                tmp = $.extend({},tmp, tmp2);
                if($t.p.autoencode) {
                    $.each(tmp,function(n,v){
                        tmp[n] = $.jgrid.htmlDecode(v);
                    });
                }
                var k, resp = $($t).jqGrid("setRowData",rowid,tmp);
                $(ind).attr("editable","0");
                for(k=0;k<$t.p.savedRow.length;k++) {
                    if( String($t.p.savedRow[k].id) === String(oldRowId)) {fr = k; break;}
                }
                if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
                $($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, resp, tmp, o]);
                if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid, resp, tmp, o); }
                success = true;
                $(ind).removeClass("jqgrid-new-row").unbind("keydown");
            } else {
                $($t).jqGrid("progressBar", {method:"show", loadtype : o.saveui, htmlcontent: o.savetext });
                tmp3 = $.extend({},tmp,tmp3);
                tmp3[idname] = $.jgrid.stripPref($t.p.idPrefix, tmp3[idname]);
                $.ajax($.extend({
                    url:o.url,
                    data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData.call($t, tmp3) : tmp3,
                    type: o.mtype,
                    async : false, //?!?
                    complete: function(res,stat){
                        $($t).jqGrid("progressBar", {method:"hide", loadtype : o.saveui, htmlcontent: o.savetext});
                        if (stat === "success"){
                            var ret = true, sucret, k;
                            sucret = $($t).triggerHandler("jqGridInlineSuccessSaveRow", [res, rowid, o]);
                            if (!$.isArray(sucret)) {sucret = [true, tmp3];}
                            if (sucret[0] && $.isFunction(o.successfunc)) {sucret = o.successfunc.call($t, res);}                            
                            if($.isArray(sucret)) {
                                // expect array - status, data, rowid
                                ret = sucret[0];
                                tmp = sucret[1] || tmp;
                            } else {
                                ret = sucret;
                            }
                            if (ret===true) {
                                if($t.p.autoencode) {
                                    $.each(tmp,function(n,v){
                                        tmp[n] = $.jgrid.htmlDecode(v);
                                    });
                                }
                                if(nullIfEmpty) {
                                    $.each(tmp,function( n ){
                                        if(tmp[n] === 'null' ) {
                                            tmp[n] = '';
                                        }
                                    });
                                }
                                tmp = $.extend({},tmp, tmp2);
                                $($t).jqGrid("setRowData",rowid,tmp);
                                $(ind).attr("editable","0");
                                for(k=0;k<$t.p.savedRow.length;k++) {
                                    if( String($t.p.savedRow[k].id) === String(rowid)) {fr = k; break;}
                                }
                                if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
                                $($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, res, tmp, o]);
                                if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid, res, tmp, o); }
                                success = true;
                                $(ind).removeClass("jqgrid-new-row").unbind("keydown");
                            } else {
                                $($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, null, o]);
                                if($.isFunction(o.errorfunc) ) {
                                    o.errorfunc.call($t, rowid, res, stat, null);
                                }
                                if(o.restoreAfterError === true) {
                                    $($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
                                }
                            }
                        }
                    },
                    error:function(res,stat,err){
                        $("#lui_"+$.jgrid.jqID($t.p.id)).hide();
                        $($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, err, o]);
                        if($.isFunction(o.errorfunc) ) {
                            o.errorfunc.call($t, rowid, res, stat, err);
                        } else {
                            var rT = res.responseText || res.statusText;
                            try {
                                $.jgrid.info_dialog(errors.errcap,'<div class="'+error+'">'+ rT +'</div>', edit.bClose, {buttonalign:'right', styleUI : $t.p.styleUI });
                            } catch(e) {
                                alert(rT);
                            }
                        }
                        if(o.restoreAfterError === true) {
                            $($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
                        }
                    }
                }, $.jgrid.ajaxOptions, $t.p.ajaxRowOptions || {}));
            }
        }
        return success;
    },
    restoreRow : function(rowid, afterrestorefunc) {
        // Compatible mode old versions
        var args = $.makeArray(arguments).slice(1), o={};
 
        if( $.type(args[0]) === "object" ) {
            o = args[0];
        } else {
            if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
        }
        o = $.extend(true, {}, $.jgrid.inlineEdit, o );
 
        // End compatible
 
        return this.each(function(){
            var $t= this, fr=-1, ind, ares={}, k;
            if (!$t.grid ) { return; }
            ind = $($t).jqGrid("getInd",rowid,true);
            if(ind === false) {return;}
            var bfcr = $.isFunction( o.beforeCancelRow ) ?    o.beforeCancelRow.call($t, o, rowid) :  undefined;
            if( bfcr === undefined ) {
                bfcr = true;
            }
            if(!bfcr) { return; }
            for(k=0;k<$t.p.savedRow.length;k++) {
                if( String($t.p.savedRow[k].id) === String(rowid)) {fr = k; break;}
            }
            if(fr >= 0) {
                if($.isFunction($.fn.datepicker)) {
                    try {
                        $("input.hasDatepicker","#"+$.jgrid.jqID(ind.id)).datepicker('hide');
                    } catch (e) {}
                }
                $.each($t.p.colModel, function(){
                    if(this.editable === true && $t.p.savedRow[fr].hasOwnProperty(this.name)) {
                        ares[this.name] = $t.p.savedRow[fr][this.name];
                    }
                });
                $($t).jqGrid("setRowData",rowid,ares);
                $(ind).attr("editable","0").unbind("keydown");
                $t.p.savedRow.splice(fr,1);
                if($("#"+$.jgrid.jqID(rowid), "#"+$.jgrid.jqID($t.p.id)).hasClass("jqgrid-new-row")){
                    setTimeout(function(){
                        $($t).jqGrid("delRowData",rowid);
                        $($t).jqGrid('showAddEditButtons');
                    },0);
                }
            }
            $($t).triggerHandler("jqGridInlineAfterRestoreRow", [rowid]);
            if ($.isFunction(o.afterrestorefunc))
            {
                o.afterrestorefunc.call($t, rowid);
            }
        });
    },
    addRow : function ( p ) {
        p = $.extend(true, {
            rowID : null,
            initdata : {},
            position :"first",
            useDefValues : true,
            useFormatter : false,
            addRowParams : {extraparam:{}}
        },p  || {});
        return this.each(function(){
            if (!this.grid ) { return; }
            var $t = this;
            var bfar = $.isFunction( p.beforeAddRow ) ?    p.beforeAddRow.call($t,p.addRowParams) :  undefined;
            if( bfar === undefined ) {
                bfar = true;
            }
            if(!bfar) { return; }
            p.rowID = $.isFunction(p.rowID) ? p.rowID.call($t, p) : ( (p.rowID != null) ? p.rowID : $.jgrid.randId());
            if(p.useDefValues === true) {
                $($t.p.colModel).each(function(){
                    if( this.editoptions && this.editoptions.defaultValue ) {
                        var opt = this.editoptions.defaultValue,
                        tmp = $.isFunction(opt) ? opt.call($t) : opt;
                        p.initdata[this.name] = tmp;
                    }
                });
            }
            $($t).jqGrid('addRowData', p.rowID, p.initdata, p.position);
            p.rowID = $t.p.idPrefix + p.rowID;
            $("#"+$.jgrid.jqID(p.rowID), "#"+$.jgrid.jqID($t.p.id)).addClass("jqgrid-new-row");
            if(p.useFormatter) {
                $("#"+$.jgrid.jqID(p.rowID)+" .ui-inline-edit", "#"+$.jgrid.jqID($t.p.id)).click();
            } else {
                var opers = $t.p.prmNames,
                oper = opers.oper;
                p.addRowParams.extraparam[oper] = opers.addoper;
                $($t).jqGrid('editRow', p.rowID, p.addRowParams);
                $($t).jqGrid('setSelection', p.rowID);
            }
        });
    },
    inlineNav : function (elem, o) {
        var $t = this[0],
        regional =  $.jgrid.getRegional($t, 'nav'),
        icons = $.jgrid.styleUI[$t.p.styleUI].inlinedit;
        o = $.extend(true,{
            edit: true,
            editicon: icons.icon_edit_nav,
            add: true,
            addicon:icons.icon_add_nav,
            save: true,
            saveicon: icons.icon_save_nav,
            cancel: true,
            cancelicon: icons.icon_cancel_nav,
            addParams : {addRowParams: {extraparam: {}}},
            editParams : {},
            restoreAfterSelect : true
        }, regional, o ||{});
        return this.each(function(){
            if (!this.grid  || this.p.inlineNav) { return; }
            var gID = $.jgrid.jqID($t.p.id),
            disabled = $.trim( $($t).jqGrid('getStyleUI', $t.p.styleUI+'.common', 'disabled', true) );
            // check to see if navgrid is started, if not call it with all false parameters.
            if(!$t.p.navGrid) {
                $($t).jqGrid('navGrid',elem, {refresh:false, edit: false, add: false, del: false, search: false, view: false});
            }
            if(!$($t).data('inlineNav')) {
                $($t).data('inlineNav',o);
            }
            if($t.p.force_regional) {
                o = $.extend(o, regional);
            }
 
            $t.p.inlineNav = true;
            // detect the formatactions column
            if(o.addParams.useFormatter === true) {
                var cm = $t.p.colModel,i;
                for (i = 0; i<cm.length; i++) {
                    if(cm[i].formatter && cm[i].formatter === "actions" ) {
                        if(cm[i].formatoptions) {
                            var defaults =  {
                                keys:false,
                                onEdit : null,
                                onSuccess: null,
                                afterSave:null,
                                onError: null,
                                afterRestore: null,
                                extraparam: {},
                                url: null
                            },
                            ap = $.extend( defaults, cm[i].formatoptions );
                            o.addParams.addRowParams = {
                                "keys" : ap.keys,
                                "oneditfunc" : ap.onEdit,
                                "successfunc" : ap.onSuccess,
                                "url" : ap.url,
                                "extraparam" : ap.extraparam,
                                "aftersavefunc" : ap.afterSave,
                                "errorfunc": ap.onError,
                                "afterrestorefunc" : ap.afterRestore
                            };
                        }
                        break;
                    }
                }
            }
            if(o.add) {
                $($t).jqGrid('navButtonAdd', elem,{
                    caption : o.addtext,
                    title : o.addtitle,
                    buttonicon : o.addicon,
                    id : $t.p.id+"_iladd",
                    internal : true,
                    onClickButton : function () {
                        $($t).jqGrid('addRow', o.addParams);
                        if(!o.addParams.useFormatter) {
                            $("#"+gID+"_ilsave").removeClass( disabled );
                            $("#"+gID+"_ilcancel").removeClass( disabled );
                            $("#"+gID+"_iladd").addClass( disabled );
                            $("#"+gID+"_iledit").addClass( disabled );
                        }
                    }
                });
            }
            if(o.edit) {
                $($t).jqGrid('navButtonAdd', elem,{
                    caption : o.edittext,
                    title : o.edittitle,
                    buttonicon : o.editicon,
                    id : $t.p.id+"_iledit",
                    internal : true,
                    onClickButton : function () {
                        var sr = $($t).jqGrid('getGridParam','selrow');
                        if(sr) {
                            $($t).jqGrid('editRow', sr, o.editParams);
                            $("#"+gID+"_ilsave").removeClass( disabled );
                            $("#"+gID+"_ilcancel").removeClass( disabled );
                            $("#"+gID+"_iladd").addClass( disabled );
                            $("#"+gID+"_iledit").addClass( disabled );
                        } else {
                            $.jgrid.viewModal("#alertmod_"+gID, {gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();                            
                        }
                    }
                });
            }
            if(o.save) {
                $($t).jqGrid('navButtonAdd', elem,{
                    caption : o.savetext || '',
                    title : o.savetitle || 'Save row',
                    buttonicon : o.saveicon,
                    id : $t.p.id+"_ilsave",
                    internal : true,
                    onClickButton : function () {
                        var sr = $t.p.savedRow[0].id;
                        if(sr) {
                            var opers = $t.p.prmNames,
                            oper = opers.oper, tmpParams = o.editParams;
                            if($("#"+$.jgrid.jqID(sr), "#"+gID ).hasClass("jqgrid-new-row")) {
                                o.addParams.addRowParams.extraparam[oper] = opers.addoper;
                                tmpParams = o.addParams.addRowParams;
                            } else {
                                if(!o.editParams.extraparam) {
                                    o.editParams.extraparam = {};
                                }
                                o.editParams.extraparam[oper] = opers.editoper;
                            }
                            if( $($t).jqGrid('saveRow', sr, tmpParams) ) {
                                $($t).jqGrid('showAddEditButtons');
                            }
                        } else {
                            $.jgrid.viewModal("#alertmod_"+gID, {gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();                            
                        }
                    }
                });
                $("#"+gID+"_ilsave").addClass( disabled );
            }
            if(o.cancel) {
                $($t).jqGrid('navButtonAdd', elem,{
                    caption : o.canceltext || '',
                    title : o.canceltitle || 'Cancel row editing',
                    buttonicon : o.cancelicon,
                    id : $t.p.id+"_ilcancel",
                    internal : true,
                    onClickButton : function () {
                        var sr = $t.p.savedRow[0].id, cancelPrm = o.editParams;
                        if(sr) {
                            if($("#"+$.jgrid.jqID(sr), "#"+gID ).hasClass("jqgrid-new-row")) {
                                cancelPrm = o.addParams.addRowParams;
                            }
                            $($t).jqGrid('restoreRow', sr, cancelPrm);
                            $($t).jqGrid('showAddEditButtons');
                        } else {
                            $.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();                            
                        }
                    }
                });
                $("#"+gID+"_ilcancel").addClass( disabled );
            }
            if(o.restoreAfterSelect === true) {
                $($t).bind("jqGridBeforeSelectRow.inlineNav", function( event, id ) {
                    if($t.p.savedRow.length > 0 && $t.p.inlineNav===true && ( id !== $t.p.selrow && $t.p.selrow !==null) ) {
                        if($t.p.selrow === o.addParams.rowID ) {
                            $($t).jqGrid('delRowData', $t.p.selrow);
                        } else {
                            $($t).jqGrid('restoreRow', $t.p.selrow, o.editParams);
                        }
                        $($t).jqGrid('showAddEditButtons');
                    }
                });
            }
 
        });
    },
    showAddEditButtons : function()  {
        return this.each(function(){
            if (!this.grid ) { return; }
            var gID = $.jgrid.jqID(this.p.id),
            disabled = $.trim( $(this).jqGrid('getStyleUI', this.p.styleUI+'.common', 'disabled', true) );
            $("#"+gID+"_ilsave").addClass( disabled );
            $("#"+gID+"_ilcancel").addClass( disabled );
            $("#"+gID+"_iladd").removeClass( disabled );
            $("#"+gID+"_iledit").removeClass( disabled );
        });
    }
//end inline edit
});
//module end
}));