Show new column in Yii2 Grid, based on difference of dates stored in different records - yii2

I am having a table called postings, which contain the postings of a personnel, identified by the field cpf at various places at different dates. Similar to the one shown in the image below.
Now, in the index view of the Model, I would like show a new column, which calculates the number of days a person was posted at a particular place. For example, the person 39584 was posted at JORHAT for 5322 days (1998-05-29 - 1983-11-02 = 5322). The same person is being posted at IRS for 4259 days (difference of today's date and 2009-05-15).
I am new to Yii2 and need help. Thanks in advance.

Related

MS-ACCESS: How to construct a practical timetable per date?

Don't know how to merely google for an answer on this one: How does one go about constructing an ever-expanding per-date engagement timetable - that links an employee and work type to a specific date?
What I want to achieve:
("RW" and "DO" is supposed to be user input stored in "tblEmployeeEngagement")
This is pretty easy to do with excel's tables, and index and match functions can do wonders, but I don't know how to get user-friendly results in access. Here's my table construction:
tblEmployees
EmployeeID (autoincrement)
First Name
Last Name
...
tblWorkType
WorkTypeID (autoincrement)
ShortName (text, unique)
Description
ShiftStart
ShiftEnd
...
tblDate
DateID (autoincrement)
Date (date, unique)
CompanyOperational (bool)
...
tblEmployeeEngagement
EngagementID
EmployeeID (relationship with above)
DateID (relationship with above)
WorkTypeID (relationship with above)
Let's say these are the tables. Theoretically one can enter multiple Engagements for same person with same date, but this is not at all necessary and let's say this option is eliminated. How do I go about making editable query/table for easy input as the one in picture?
A crosstable constructs it exactly as I want it, but it is NOT editable (as in pic related), which is an issue.
I am open to completely removing "tblDate" and adding "Date" field in "tblEmployeeEngagement", but I still don't see how I would construct this sort of query/table without VBA. The desired result is for end-user to be able to populate "tblEmployeeEngagement" alone.
Help.
I would build a form that does not have a table behind it.
In the header I would have a typed header for Employee and then I would have 7 (or 10 or whatever) number of fields for the dates. Let's assume that you are putting in time in the past, VBA On Open could set the 1st label text to 7 days ago, 2nd to 6 days ago, 3rd to 5 days ago, etc. If you add a date that matches to your tbl and is non-working, simply lock and darken the fields underneath those dates.
Under employee label, I would have a drop-down to choose the employee. Next to that would be 7 fields which each have the choice of RW and DO.
The user would then select an employee from the drop-down and go across the days and set the dates to be RW or DO or blank depending on the status.
When the user clicks the Save (or Close or whatever ) button, the computer would then create records for each employee, each date, and each Engagement to the Engagement table.
If you want them able to edit these Engagements, you could bring in the data for each Employee during the date range given.
Hope this helps.

Database Schema Design for different timesheet format

Could someone help to understand the efficient way of storing the timesheet data (Timesheet_Details)?
The timesheet data can be input in multiple ways
Start time and end time (9am to 5 pm)
Plain input of hours (8 hours)
Input like hours in multiples of 2 (2,4,8)
Based on unit like e.g. 1 = full day, 0.5 = half day.
What I have is a master Timesheet table which will store the start and end date for the job. But I am confused how to store the timesheet hours against each date.
Timesheet
id
client_uuid
user_uuid
job_uuid
start_date
end_date
Timesheet_Details
id
timesheet_uuid (FK)
date
?
?
?
You say that the timesheet data can be input in multiple ways (the four mentioned). Is it something you need to have in the interface of the application? Is it something you really need to duplicate in the database? What I mean is that even though the user experience that is asked is to be able to enter the time in multiple different ways, it does not need to be stored this way, the data can be transformed in a way that is consistent in the database, and then you would show the format according to the user preferences. You would use some algorithm to transform the data and store it correctly in the database.
For instance, you could add a table that contains all the possible ways of showing the time, listing the four that you mentioned here but with codes, let's name it "time_presentation". The interface would show a dropdown and the user would select a way to enter the time. The interface would change according to what they want (for example, two inputs to enter beginning and end, one input to enter only the hours, etc.). Then, the data would be sent to the backend and stored in the Timesheet_Details table but always with the same format that you will have calculated with the code, for example, a float column containing the total hours, and a column containing a foreign key to the table "time_presentation". Then, to show the item in the interface, you would be able to use both columns and reverse the process to show it according to what the user entered and how they entered it (if it's important the user sees it as entered).
If it's absolutly necessary to store the data directly with the 4 methods mentioned, then I would suggest using a varchar column with the value (but this would be a lot less easy to validate).

SSRS display one of two possible dates

I have a confirmation letter used to display one of two dates to a customer.
Date.Value is the purchase date of a product not tied to a finite inventory.
InventoryDate.Value is the date an activity is taking place, based on inventory availability.
Everything has a purchase date, but not everything has an inventory date. I would like the letter to display InventoryDate.Value if it has one, or display Date.Value if inventory date is null. I've played around with a bunch of variations in my code, but what I currently have is:
=iif( Fields!InventoryDate.Value="", Fields!Date.Value, Fields!InventoryDate.Value)
This is displaying Date.Value correctly, but returning #Error for any product with an Inventory Date. I am very new to SSRS/Reporting, so please keep any suggestions at a newb understanding level.
Working in MS Report Builder.
Thanks for your suggestions!
Depending on the data type of the fields, they can be blank or empty. With ="" you are only checking, if the field is blank.
try this:
=iif(IsNothing(Fields!InventoryDate.Value),Fields!Date.Value,Fields!InventoryDate.Value)

How to create a Multiple date picker for a search form

I am quite a newbie to MS Access.I am working with a search form in MS Access and I want to create a date picker in which I can select multiple dates which will be an input for a Query that is used to search and display the results from my table for the records that have the selected dates. I did some research on this,however I was unable to find out a feasible solution for my problem.
As I see there are only 2 ways in which this can be done.The first way is that is using two date pickers one for from date and other for to date and then search for the records between these days which is not very feasible for my scenario as I might want to choose two different dates for example 4th of Jan and 6th of Jan and display results for only those days.
The other method is to use a list box which displays all the dates that are present in the database and choose from that however this is not going to work for me as if I have a very long list of dates such as from 1st Jan to 31st Jan then it would be very time consuming and also I might select a date which I do not want to to search for also in the results.
Could anybody suggest me how can I solve this problem.I am looking for a multiple date picker property in access.Is it possible to achieve this through the form properties? If yes how can it be done? Or is there any other solution for this problem?
Thanks in Advance.
I would recommend creating a temp table consisting of two fields, a Yes/No field and a Date field. Populate the date field (don't name it 'date') with all of the dates from your list of dates. Then on your search form add a subform bound to the temp table. Users would simply check the box next to the desired dates. Then modify your query to include the temp table with a join on the date fields and criteria that the Yes/No field is True (Yes).
Its doubtful youre still looking for this but for anyone else that happens accross this topic I modified an existing datepicker to allow selection of any number of non-contiguous dates, and insert them to a table. I posted it on UtterAccess (A great forum for Access questions). A link to the forum topic is below, but you need to create an account to download the example file.
http://www.utteraccess.com/forum/index.php?showtopic=1738361&st=0#entry2535392
You could combine the two approaches and have
Two textboxes to filter for a short date range (say 1 month dates)
Show the dates in this date range in a multiselect listbox where the user can select the specific dates they need.

Design - Microsoft Access - Unique "Serial" Number

I am looking for some design techniques to achieve the following:
A 3-part serial number that is generated upon record entry. Format Example: 25-001-14
The number is used to track yearly records from various locations.
The first part states the location the record is associated with, this would be a user input during record creation.
The second part is the record number, I would like for this to be automatically generated, but needs to be sequential and separate for each location and needs to reset each year.
The third part is the two digit number for the year the record was created in. I would like this to be automatically generated if possible. Note: I am currently not concerned with when this cycles back around and I face redundant data issues.
I'm thinking I would like records to be stored in multiple tables that are separated by location, if this would help things!
Any ideas would be greatly welcomed.
I think I would use 3 key fields - one field each for location, record and year. The location and year fields would be created when you get the input to create new records. I would set up a query to find the last record number used by location and year and use that query to assign the new record number when you create a new record. The concatenation of the 3 fields would be the key you described.
With a key field for location, separate tables are not necessary unless that's useful for other reasons. I would probably use just one table - you can always filter the records by location anytime you need to.