- Posts: 23
- Thank you received: 0
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
public function saveWork() {
if ($this->id) { // update existing work
$old=$this->getOld();
$result=$this->save();
$this->updateAssignment($this->work-$old->work);
return $result;
} else { // add new work
if (! $this->idResource and ! $this->idAssignment) { // idResource Mandatory
return "ERROR idResouce mandatory";
}
if (! $this->workDate) {
if ($this->day) {
$this->workDate=substr($this->day,0,4).'-'.substr($this->day,4,2).'-'.substr($this->day,6,2);
} else { // Work Date is mandatory
return "ERROR workDate mandatory";
}
}
if (!$this->idAssignment) { // unknown assignment
if ($this->refType and $this->refId) {
$crit=array('refType'=>$this->refType,'refId'=>$this->refId,'idResource'=>$this->idResource);
$ass=SqlElement::getSingleSqlElementFromCriteria('Assignment', $crit);
if ($ass->id) {
$this->idAssignment=$ass->id;
} else {
$crit=array('refType'=>$this->refType,'refId'=>$this->refId);
$tick=SqlElement::getSingleSqlElementFromCriteria('WorkElement', $crit);
if ($tick->id) {
$this->idWorkElement=$tick->id;
} else {
return "ERROR either idAssignment or idWorkElement is mandatory"; // could not retrieve assignment, so is mandatory
}
}
}
} else { // refType & refId can be retreived from assignment
$ass=new Assignment($this->idAssignment);
$this->refType=$ass->refType;
$this->refId=$ass->refId;
$this->idResource=$ass->idResource;
}
if ($this->idAssignment) {
$crit=array('idAssignment'=>$this->idAssignment,'workDate'=>$this->workDate); // retreive work for this assignment & day (assignment includes resource)
$work=SqlElement::getSingleSqlElementFromCriteria('Work', $crit);
}
else {
$crit=array('idWorkElement'=>$this->idWorkElement,'workDate'=>$this->workDate); // retreive work for this assignment & day (assignment includes resource)
$work=SqlElement::getSingleSqlElementFromCriteria('Work', $crit);
}
if ($work->id) {
$work->work+=$this->work;
$result=$work->save();
$work->updateAssignment($this->work);
return $result;
} else {
$this->setDates($this->workDate);
$result=$this->save();
$work->updateAssignment($this->work);
return $result;
}
}
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
En poursuivant votre navigation, vous acceptez le dépôt de cookies tiers destinés au bon fonctionnement et à la sécurisation du site (gestion de session, reCaptcha) et à une analyse statistique anonymisée des accès sur notre site (Google Analytics). Si vous vous inscrivez, les informations que vous fournirez ne seront jamais divulguées à un tiers sous quelque forme que ce soit. En savoir plus
Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.
Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.