Employee calender

Employee calendar


View.xml


<core:View xmlns:core="sap.ui.core"
xmlns:grid="sap.ui.layout.cssgrid" xmlns:unified="sap.ui.unified"
xmlns="sap.m" controllerName="NavApp.view.Main" displayBlock="true"
height="100%">
<App id="AppId">

<Page title="Mahindra Vehicle  Manufactures"
class="sapUiSizeCompact" showHeader="false">
<content>

<!-- <HBox>
<core:Icon src="sap-icon://home" class="size1"
color="#031E48" />
<Toolbar>
<ToolbarSpacer/>
<Text text="DASHBOARD" class="rrrrrr" />
</Toolbar>
</HBox> -->


<VBox class="sapUiSmallMargin">
<IconTabBar id="idTopLevelIconTabBar"
class="sapUiResponsiveContentPadding" select="onSelect"
backgroundDesign="Translucent" expandable="false" expanded="false"
headerBackgroundDesign="Translucent">
<items>
<IconTabFilter id="start" text="Sick"
key="sick" class="tab1">
</IconTabFilter>
<IconTabFilter id="layouts" text="Unplanned"
key="unplanned"></IconTabFilter>
<IconTabFilter id="Containers" text="vacation"
key="vacation"></IconTabFilter>

<IconTabFilter text="Others" key="other">
</IconTabFilter>
</items>
</IconTabBar>

<PlanningCalendar id="PC1" stickyHeader="true"
startDate="{path: '/startDate'}" rows="{/people}"
appointmentsVisualization="Filled" viewKey="One Month"
showEmptyIntervalHeaders="false">
<rows>
<PlanningCalendarRow icon="{pic}"
title="{name}" text="{role}"
appointments="{path : 'appointments', templateShareable: 'false'}">
<appointments>
<unified:CalendarAppointment
startDate="{start}" endDate="{end}" title="{title}"
color="{color}" tooltip="{tooltip}">
</unified:CalendarAppointment>
</appointments>
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>


</content>
</Page>
</App>
</core:View>



controlller.js

var data;
var other = {
startDate : new Date("2019/10/01"),
people : []
}
var sick =  {
startDate : new Date("2019/10/01"),
people : []
}
var unplanned = {
startDate : new Date("2019/10/01"),
people : []
}

var vacation = {
startDate : new Date("2019/10/01"),
people : []

}

sap.ui
.controller(
"NavApp.view.Main",
{



onInit : function() {

var data1 = {
"results":[

{ PERNR:"00162582",
            EVENT_NAME :"Varsha",
            BEGIN_DATE :null,
            END_DATE:null,
            DESCRIPTION:"",
            LEGENDID:"",
            LEGEND:"",
            LEGEND_TEXT:"",
            FLAG:"",
            TYPE:"",
            APP_MODE:"other",
            ALL_EMPLOYEES:"",
            COMMAND:"",
            EMP_PERNR:"00000000",
            HIDE_PEERS:"",
            PERNR_MEM_ID:"",
            BEGIN_DATE_CHAR:"2019/10/29",
            END_DATE_CHAR:"2019/10/30"
     
         },
         {
PERNR:"00162582",
            EVENT_NAME :"Tushar",
            BEGIN_DATE :null,
            END_DATE:null,
            DESCRIPTION:"",
            LEGENDID:"",
            LEGEND:"",
            LEGEND_TEXT:"",
            FLAG:"",
            TYPE:"",
            APP_MODE:"sick",
            ALL_EMPLOYEES:"",
            COMMAND:"",
            EMP_PERNR:"00000000",
            HIDE_PEERS:"",
            PERNR_MEM_ID:"",
            BEGIN_DATE_CHAR:"2019/10/29",
            END_DATE_CHAR:"2019/10/30"
         },
         {
PERNR:"00162582",
            EVENT_NAME :"Aarti",
            BEGIN_DATE :null,
            END_DATE:null,
            DESCRIPTION:"",
            LEGENDID:"",
            LEGEND:"",
            LEGEND_TEXT:"",
            FLAG:"",
            TYPE:"",
            APP_MODE:"vacation",
            ALL_EMPLOYEES:"",
            COMMAND:"",
            EMP_PERNR:"00000000",
            HIDE_PEERS:"",
            PERNR_MEM_ID:"",
            BEGIN_DATE_CHAR:"2019/10/29",
            END_DATE_CHAR:"2019/10/30"
       
         },
         {
        PERNR:"00162582",
            EVENT_NAME :"Digvijay",
            BEGIN_DATE :null,
            END_DATE:null,
            DESCRIPTION:"",
            LEGENDID:"",
            LEGEND:"",
            LEGEND_TEXT:"",
            FLAG:"",
            TYPE:"",
            APP_MODE:"unplanned",
            ALL_EMPLOYEES:"",
            COMMAND:"",
            EMP_PERNR:"00000000",
            HIDE_PEERS:"",
            PERNR_MEM_ID:"",
            BEGIN_DATE_CHAR:"2019/10/29",
            END_DATE_CHAR:"2019/10/30"
       
         },
       
       
       
         ]
};

debugger;



for(var i = 0;i<data1.results.length;i++)
{
if(data1.results[i].APP_MODE == "other")
{
other.people
.push({
name : data1.results[i].EVENT_NAME,
role : data1.results[i].TYPE,
vacation :  data1.results[i].TYPE,

appointments : [ {
start :new Date(data1.results[i].BEGIN_DATE_CHAR),
end : new Date(data1.results[i].END_DATE_CHAR),
title : "other",
color : "cyan",
tooltip : data1.results[i].FLAG
} ]
})
}
else if(data1.results[i].APP_MODE == "sick")
{
sick.people
.push({
name : data1.results[i].EVENT_NAME,
role : data1.results[i].TYPE,
vacation :  data1.results[i].TYPE,

appointments : [ {
start :new Date(data1.results[i].BEGIN_DATE_CHAR),
end : new Date(data1.results[i].END_DATE_CHAR),
title : "sick",
color : "yellow",
tooltip : data1.results[i].FLAG
} ]
})
}
else if(data1.results[i].APP_MODE == "vacation")
{
vacation.people
.push({
name : data1.results[i].EVENT_NAME,
role : data1.results[i].TYPE,
vacation :  data1.results[i].TYPE,

appointments : [ {
start :new Date(data1.results[i].BEGIN_DATE_CHAR),
end : new Date(data1.results[i].END_DATE_CHAR),
title : "vacation",
color : "red",
tooltip : data1.results[i].FLAG
} ]
})
}
else if(data1.results[i].APP_MODE == "unplanned")
{
unplanned.people
.push({
name : data1.results[i].EVENT_NAME,
role : data1.results[i].TYPE,
vacation :  data1.results[i].TYPE,

appointments : [ {
start :new Date(data1.results[i].BEGIN_DATE_CHAR),
end : new Date(data1.results[i].END_DATE_CHAR),
title : "unplanned",
color : "orange",
tooltip : data1.results[i].FLAG
} ]
})
}
}

debugger;





debugger;
this.oModel = new sap.ui.model.json.JSONModel();
this.oModel.setData(sick);
this.getView().setModel(this.oModel);

debugger;

},

onSelect : function(oEvent) {


var x = oEvent.mParameters.key
console.log(x);

debugger;


if (x == "sick") {
this.oModel = new sap.ui.model.json.JSONModel();
this.oModel.setData(sick);
this.getView().setModel(this.oModel);
this.oModel.refresh();
}
else if (x == "unplanned") {
this.oModel = new sap.ui.model.json.JSONModel();
this.oModel.setData(unplanned);
this.getView().setModel(this.oModel);
this.oModel.refresh();
}
else if (x == "vacation") {
this.oModel = new sap.ui.model.json.JSONModel();
this.oModel.setData(vacation);
this.getView().setModel(this.oModel);
this.oModel.refresh();
}
else if (x == "other") {
this.oModel = new sap.ui.model.json.JSONModel();
this.oModel.setData(other);
this.getView().setModel(this.oModel);
this.oModel.refresh();
}

debugger;



},



});


output =



Post a Comment

Previous Post Next Post