如果天数小于等于14天,如何对每行发出警告

时间:2019-05-20 13:17:26

标签: jquery datatables

如果没有天数少于或等于Sch的2周(<= 14天),如何对数据表的每一行发出警报或警告。日期在前。

这里endDate是用于将数据导入数据表的字段变量:

var handleAllProjectList = function(staffNo) {
    //console.log("here"+appPath+'projects/user/'+staffNo+'/company     
    if ($('#m_datatable_latest_orders').length === 0) {
      /'+companyId);
      return;
    }

    var datatable = $('.m_datatable').mDatatable({
          data: {
            type: 'remote',
            source: {
              read: {
                //url: appPath+'projects/user/'+staffNo+'/company/'+companyId,
                url: appPath + 'projects/pagedata',
                //url: appPath+'projects/all',
                method: 'GET'
              }
            },
            pageSize: 10,
            saveState: {
              cookie: false,
              webstorage: false
            },
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
          },
          layout: {
            theme: 'default',
            class: 'm-datatable--brand table table-bordered m-table m-table--border-light',
            scroll: true,
            height: 380,
            footer: false,
            smoothScroll: {
              scrollbarShown: true
            },

            spinner: {
              overlayColor: '#000000',
              opacity: 0,
              type: 'loader',
              state: 'brand',
              message: true
            },

            icons: {
              sort: {
                asc: 'la la-arrow-up',
                desc: 'la la-arrow-down'
              },
              pagination: {
                next: 'la la-angle-right',
                prev: 'la la-angle-left',
                first: 'la la-angle-double-left',
                last: 'la la-angle-double-right',
                more: 'la la-ellipsis-h'
              },
              rowDetail: {
                expand: 'fa fa-caret-down',
                collapse: 'fa fa-caret-right'
              }
            }
          },

          sortable: true,

          filterable: true,

          pagination: true,

          search: {
            // search delay in milliseconds
            delay: 400,
            // input text for search
            input: $('#generalSearch'),
          },

          columns: [{
                field: "projectIdFull",
                title: locale == 'de' ? "Nummer" : "Number",
                /*sortable: false,*/
                width: 70,
                textAlign: 'center'
              }, {
                field: "projectName",
                title: "Name",
                sortable: 'asc',
                filterable: false,
                template: function(row) {
                  if (row.projectName != null) {
                    if (row.projectStatus != 'saved' && row.projectStatus != 'gespeichert') {
                      return '<a title="' + row.projectName + '" href="' + appPath + 'project/' + row.projectId + '/view' + '">' + row.projectName + '</a>';
                    } else {
                      return '<a title="' + row.projectName + '" href="' + appPath + 'project/' + row.projectId + '/savedupdate' + '">' + row.projectName + '</a>';
                    }
                  }
                },
                width: 248
              },
              /*{
                  field: "parentProjectName",
                  title: "Parent",
                  width: 100,
                  responsive: {
                    visible: 'xl'
                  }
              }, */
              {
                field: "projectStatus",
                title: "Status",
                template: function(row) {
                  var status = {
                    '4': {
                      'title':

                        locale == 'de' ? "geplant" : "Planned",
                      'class': ' m-badge--metal'
                    },
                    '1': {
                      'title': locale == 'de' ? "beantragt" : "Applied",
                      'class': ' m-badge--primary'
                    },
                    '3': {
                      'title': locale == 'de' ? "abgelehnt" : "Refused",
                      'class': ' m-badge--danger'
                    },
                    '2': {
                      'title': locale == 'de' ? "neu" : "New",
                      'class': ' m-badge--info'
                    },
                    '5': {
                      'title': locale == 'de' ? "in Arbeit" : "Progress",
                      'class': ' m-badge--warning'
                    },
                    '6': {
                      'title': locale == 'de' ? "abnahme" : "Acceptance",
                      'class': ' m-badge--focus'
                    },
                    '7': {
                      'title': locale == 'de' ? "abgeschlossen" : "Completed",
                      'class': ' m-badge--success'
                    },
                    '8': {
                      'title': locale == 'de' ? "abgebrochen" : "Cancelled",
                      'class': ' m-badge--danger'
                    },
                    '9': {
                      'title': locale == 'de' ? "obsolet" : "Obsolete",
                      'class': ' m-badge--danger'
                    },
                    '10': {
                      'title': locale == 'de' ? "wartend" : "On Hold",
                      'class': ' m-badge--danger'
                    },
                    //'11': {'title': locale=='de'?"Moved to Another Project":"Moved to Another Project", 'class': ' m-badge--danger'},
                    '0': {
                      'title': locale == 'de' ? "gespeichert" : "Saved",
                      'class': ' m-badge--info'
                    }


                  };
                  return '<span class="m-badge ' + status[row.projectStatus].class + ' m-badge--wide">' + status[row.projectStatus].title + '</span>';
                },
                width: 95
              },
              {
                field: "projectPriority",
                title: locale == 'de' ? "Priorität" : "Priority",
                template: function(row) {
                  return getPriority(row.projectPriority);
                },
                width: 52
              }, {
                field: "projectLeader",
                title: locale == 'de' ? "Projektleiter" : "Project Leader",
                sortable: false,
                template: function(row) {
                  if (row.projectLeader != null) {
                    //console.log(row.projectLeader.staffName);
                    var plname = row.projectLeader.staffName;
                    return '<span title="' + plname + '"  >
                      '+plname+' < /span>'; 
                  }
                },
                width: 120
              }, {
                field: "customer",
                title: locale == 'de' ? "Auftraggeber" : "Customer",
                sortable: false,
                template: function(row) {
                  if (row.customer != null) {
                    //console.log(row.customer.staffName);
                    var custname = row.customer.staffName;
                    return '<span title="' + custname + '" >' + custname + '</span>';
                  }
                },
                width: 100
              },
              {
                            field: "requester",
                            title: locale=='de'?"Anforderer":"Requester",
                            sortable: false,
                            template: function(row){
                                if(row.requester!=null){
                                //console.log(row.requester.staffName);
                                    var reqname = row.requester.staffName;
                                    return '<span title='+reqname+'qname+'</span>';
                                }
                             },
                             width: 70
                         }, {
                            field: "startDate",
                            title: locale=='de'?"GepStart":"Sch. Start",
                             template: function(row) {
                                return formatDate(row.startDate);
                             },
                             width: 70
                         }, {
                            field: "endDate",
                            title: locale=='de'?"GepEnde":"Sch. End",
                             template: function(row) {
                                return formatDate(row.endDate);
                             },
                             width: 70
                         },{
                            field: "department",
                            title: locale=='de'?"Abteilung":"department",
                             width: 0
                         }, {
                             field: "Actions",
                             title: locale=='de'?"Aktionen":"Actions",
                             sortable: false,
                             overflow: 'visible',
                             template: function(row) {
                                 var dropup = (row.getDatatable().getPageSize() - row.getIndex()) <= 4 ? 'dropup' : '';
                                 var pid = row.projectId;
                                 var pdfurl = appPath+'projectpdf/'+pid;
                                 var ed=locale=='de'?'Bearbeiten':'Edit';
                                 var pr=locale=='de'?'Drucken':'Print';

                                 var uneditable = '<a href="'+pdfurl+'" target="_blank" title="'+pr+'" ><i class="la la-print"></i></a>\
                                 <a style="color:#ccc !important; cursor:not-allowed" href="javascript:;" ><i class="la la-edit"></i></a>';
                                 var editable = '\
                                    <a href="'+pdfurl+'" target="_blank" title="'+pr+'" ><i class="la la-print"></i></a>\
                                    <a href="'+appPath+'project/'+pid+'/update"  title="'+ed+'" ><i class="la la-edit"></i></a>\
                                     ';
                                 if(row.projectStatus==1 || row.projectStatus==7 || row.projectStatus==8 || row.projectStatus==9 || row.projectStatus==11 ){
                                    return uneditable;
                                 } 
                                 var userIsAllowed = false;
                                 if(row.projectLeader != null){
                                    if(row.projectLeader.staffNo == staffNo){
                                        userIsAllowed = true;
                                    }
                                 }
                                 if(!userIsAllowed){
                                    if(row.requester != null){
                                        if(row.requester.staffNo == staffNo){
                                            userIsAllowed = true;
                                        }
                                     }
                                 }

                                 if(!userIsAllowed){
                                    return uneditable;                                          
                                 }
                                 return editable;

                             },
                             width: 50
                         }],//
                         columnDefs: [
                             {
                                 targets:7,
                                 render: function ( data, type, row, meta ) {
                                     if(type === 'display'){
                                         data = '<a href="{{ agent.url }}/job/' + data + '">' + data + '</a>';
                                     }
                                     return data;
                                 }
                             },
                             {
                                 targets:[1,2],
                                 render: function ( data, type, row, meta ) {
                                     if(type === 'display' && row[2] != 0 ){
                                         data = '<a href="{{ agent.url }}/job/' + row[0] + '/' + row[2] + '">' + data + '</a>';
                                     }
                                     return data;
                                 }
                             }
                         ]
                         //
                         toolbar: {
                            layout: ['pagination','info'],

                            placement: ['bottom'],

                            items: {
                                pagination: {
                                    type: 'default',

                                     pages: {
                                         desktop: {
                                             layout: 'default',
                                             pagesNumber: 6
                                         },
                                         tablet: {
                                             layout: 'default',
                                             pagesNumber: 3
                                         },
                                         mobile: {
                                             layout: 'compact'
                                         }
                                     },

                                     navigation: {
                                         prev: true,
                                         next: true,
                                         first: true,
                                         last: true
                                     },

                                     pageSizeSelect: [5, 10, 30, 50, 100]
                                },

                                info: true
                            }
                         },

                         translate: {
                            records: {
                                processing: 'Please Wait...',
                                noRecords: locale=='de'?'Keine Datensätze gefunden':'No records found'
                            },
                            toolbar: {
                                pagination: {
                                    items: {
                                        default: {
                                            first: locale=='de'?'Erste':'First',
                                            prev: locale=='de'?'Vor':'Previous',
                                            next: locale=='de'?'Nächte':'Next',
                                            last: locale=='de'?'Letzte':'Last',
                                            more: locale=='de'?'Weiter Seiten':'More pages',
                                            input: locale=='de'?'Seitennummer':'Page number',
                                            select: 'Select page size'
                                        },
                                        //info: 'Displaying {{start}} - {{end}} of {{total}} records'
                                        info: locale=='de'?'{{start}} - {{end}} von {{total}} Datensätze':'Displaying {{start}} - {{end}} of {{total}} records'
                                    }
                                }
                            }
                         }
                     });

0 个答案:

没有答案