Hi.
I hope you can help me to understand the following fragment of code from method getLines in Imputation line.
// fetch all work stored in database for this assignment
foreach ( $workList as $work ) {
if (($work->idAssignment and $work->idAssignment == $elt->idAssignment and !$work->idWorkElement and !isset($elt->_idWorkElement)) or
(!$work->idAssignment and $work->refType == $elt->refType and $work->refId == $elt->refId) or
($work->idAssignment and $work->idAssignment == $elt->idAssignment and $work->idWorkElement and isset($elt->_idWorkElement) and $elt->_idWorkElement == $work->idWorkElement)) {
$workDate=$work->workDate;
$offset=dayDiffDates($startDate, $workDate) + 1;
if (isset($elt->arrayWork [$offset])) {
$elt->arrayWork [$offset]->work+=$work->work;
} else {
$elt->arrayWork [$offset]=$work;
}
}
}
It seems that you collect in the same work object the amount of work from work table having
a) a given assignment and no _idWorkElement
b) no assignment , a given reference
c) a given assignment and a given idWorkElement
Now, I'm to create a) just as a real work referred to an activity, b) as the real work for a ticket, but I'm not able to create c) .
How can I ?
Furthermore, how can I create two or more lines in work table that will be added in the same imputation line ( as in the previous fragment of code ) ?
Conditions appear incompatible, but if not, what will happen at save ?
Thank you for your help
Real work in never linekd directly to the activity but to the assignment.
For Tickets, :link is through WorkElement, that may be linked to Activity if PlanningActivity is set on Ticket.
Each line in Real Work allocation is dedicated to corresponding Assignment or WorkElement (in this last case it is read only)
Thank you for your explanation.
Now I'm able to create a work line with assignment and idWorkElement.
But at the moment I could believe that the condition to add to different amount of work as in the code line
$elt->arrayWork [$offset]->work+=$work->work;
will never happen.
It's true ?
But at the moment I could believe that the condition to add to different amount of work as in the code line
$elt->arrayWork [$offset]->work+=$work->work;
will never happen.
It's true ?
I don't understand the question.
Could you explain ?
Ok, I try to explain.
In the code you test isset($elt->arrayWork [$offset])
If true you add the new work amount to the previously stored.
I cannot understand how this condition can happen : you should find two lines in db having the same date and matching one of the three conditions above.
Is this possible ?
It is a security trick to be sure to display all data.
But you're right it should not happen.