Forum

[SOLVED] Find from ...
 
Notifications
Retirer tout

[SOLVED] Find from API the working days for a given resource in a week

20 Posts
2 Utilisateurs
0 Reactions
6,915 Vu
(@cmarti)
Posts: 65
Active Member
Début du sujet
 
[#8470]

Hi all,

I'm working on a script that catch each week the summary of the timesheets through the API to create a weekly report.
It's quite easy to collect all the timesheets and gather the information for each projects or administrative tasks.

But up to now I put by hand the total working days of the group, each week.

My question is then to know if and how I can collect the off-days for each resources through the API.

Thank you


 
Posté : 6 Sep PM 17:099
(@babynus)
Posts: 14952
Membre Admin
 

Off days are work days on Administrative projets.
But you must also take into account Calendar (table calendar) for idCalendar = Resource idCalendar


 
Posté : 7 Sep PM 13:099
(@cmarti)
Posts: 65
Active Member
Début du sujet
 

Hi Babynus,

You are right for the off-days, I express myself badly. I have already have them as well as the illness.
My point is linked indeed to the calendar, that I do not know how to grab from the API.

What I miss is to calculate the number of possible working days by resource, once I have the info on a given resource and therefore its linked calendar.
(I'm in version 9.5.3 today, but can do the upgrade if needed)
Thank you,
 


 
Posté : 7 Sep PM 18:099
(@babynus)
Posts: 14952
Membre Admin
 

You must request API on object Calendar, to get the list for idCalendar = Resource idCalendar


 
Posté : 8 Sep PM 13:099
(@cmarti)
Posts: 65
Active Member
Début du sujet
 

Hello Babynus,

I'm not sure to understand your answer.
Is it today possible to grab the calendar through the API?
or is this need to be implemented?

Thank you,


 
Posté : 14 Sep PM 18:099
(@babynus)
Posts: 14952
Membre Admin
 

You can request API on any object, including CalendarDefinition (one object per calendar) and Calendar (one object per calendar and day)


 
Posté : 15 Sep AM 11:099
(@cmarti)
Posts: 65
Active Member
Début du sujet
 

I didn't know that, I thought it was only on the object listed on the "importable" table.

Could you please give me an example of POST transaction for grabbing the CalendarDefinition information?

[EDIT] I think I was too fast here - I've tried from php instead of python and it works well as for any other element - I need to check my python code

Thank you for the help


 
Posté : 15 Sep AM 11:099
(@cmarti)
Posts: 65
Active Member
Début du sujet
 

I've almost solved my point, but notice that in case of a partial time - when a fix day (like Wednesday) is a non working day, I can't find the information on the "CalendarDefinition" object, whereas it is clearly present on the SQL database.

Did I miss a point here or isn't it present on the API?


 
Posté : 15 Sep PM 12:099
(@babynus)
Posts: 14952
Membre Admin
 

It is defined on Calendar object.


 
Posté : 15 Sep PM 19:099
(@cmarti)
Posts: 65
Active Member
Début du sujet
 

Hello Babynus,

I probably did not explain my point well - also because it was probably not so clear for me.

To finalize the number of working days, I can find the day off (like Christmas, Easter, and so on).
What is now missing is on the calendar of people that are not 100%.

I've created a calendar for people working 80% - Wednesday being a kind of "day-off".
I can find the information on the calendar definition ("Week days off") - but can't find it through the API.
If I use the "Mark every" "Wednesday" as "off days" - they are all present on the Calendar object list, but I do not understand why the "Week days off" part which is working well on the tool itself is not reachable (or I can't reach it) through the API?

Thank you
 


 
Posté : 19 Sep AM 10:099
(@babynus)
Posts: 14952
Membre Admin
 

First Request on object CalendarDefinition.
You'll get information on "global off days" for this calendar.
Then you can request on Calendar to get all specific off days.


 
Posté : 20 Sep AM 11:099
(@cmarti)
Posts: 65
Active Member
Début du sujet
 

Hello Babynus,

I probably missed a point on the way I'm using the API or the tool itself, but I'm still not able to have the off-days of a 80% work week.
So I will try to show what are the steps I've used
First I'm taking the "CalendarDefinition" as below:

$fullUrl="https://url/api/CalendarDefinition/all";
$curl = curl_init($fullUrl);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, $user);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$curl_response = curl_exec($curl);
echo $curl_response;
curl_close($curl);

With the following result:

{"identifier":"id", "items":[{"id":"1", "name":"default", "idle":"0"},
{"id":"2", "name":"CH - Part-time 80% - No Wednesday", "idle":"0"},
{"id":"3", "name":"CH", "idle":"0"},
{"id":"4", "name":"Belgique", "idle":"0"},
{"id":"5", "name":"Italy", "idle":"0"}] }

After that I'm taking the data from the calendar 2 - the one that has a 80% week working time.
So on the code above I'm using the following url

$fullUrl="https://url/api/Calendar/search/idCalendarDefinition=2/calendarDate>='2022-01-01'";

And the result is :

{"identifier":"id", "items":[{"id":"386", "name":"Jour de l'an", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-01-01", "isOffDay":"1"},
{"id":"387", "name":"Christmas", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-12-25", "isOffDay":"1"},
{"id":"388", "name":"Saint Berchtold", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-01-02", "isOffDay":"1"},
{"id":"389", "name":"Easter", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-04-18", "isOffDay":"1"},
{"id":"390", "name":"Ascension", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-05-26", "isOffDay":"1"},
{"id":"391", "name":"Pentecost", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-06-06", "isOffDay":"1"},
{"id":"392", "name":"Swiss Federal", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-08-01", "isOffDay":"1"},
{"id":"393", "name":"Saint Etienne", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-12-26", "isOffDay":"1"},
{"id":"394", "name":"Holy Friday", "idCalendarDefinition":"2", "nameCalendarDefinition":"Bern - Part-time 80% - No Wednesday", "calendarDate":"2022-04-02", "isOffDay":"1"}] }

This corresponds to the same dates as the calendar 3, so no Wednesday are present on the list.

On the tool - calendar definition part - the Wednesday is indicated as day-off (see picture)
 

Could you please let me know what is the code needed or what I should do on the tool for having the Wednesday off days indicated through the API?

Thank you,

 


 
Posté : 22 Sep AM 11:099
(@babynus)
Posts: 14952
Membre Admin
 

For CalendarDefinition, you should have dayOfWeek0 to dayOfWeek6 fields.
It seems API does not retreive them.
We'll have a look.


 
Posté : 22 Sep PM 12:099
(@cmarti)
Posts: 65
Active Member
Début du sujet
 

Hello Babynus,

I haven't look at this item for a long time, but tried again today.
It seems that the latest version still have the same issue of not having the "dayOfWeek" information available through the API.

I looked a bit on the code and found that those fields have an "hidden" attribute, that seems to be filtered out by the API interface.
Obviously I'm not sure of the root reason, but by removing, on a test database, this attribute I have indeed the visibility of those field.
I do not know the drawback of removing those attribute.

Could you please check that this is fully resolving the item without drawbacks?

Thank you


 
Posté : 19 Déc PM 15:1212
(@babynus)
Posts: 14952
Membre Admin
 

Jyst try and change (for each X not only for 0)

self::$_fieldsAttributes["dayOfWeek0"] = "readonly,hidden";

with

self::$_fieldsAttributes["dayOfWeek0"] = "readonly,hidden,forceExport";

Possibly it will fix the issue


 
Posté : 20 Déc AM 10:1212
Page 1 / 2
Share:
Retour en haut