Forum

Welcome to ProjeQtOr new Forum. We migrated old forum to the new website.
You will find all your posts here, with your usual account.
Just one point : you’ll have to reinitialize your password. Use “Lost password” feature.

Bind the status of ...
 
Notifications
Clear all

Bind the status of a document to an element bound by type Activity

3 Posts
2 Users
0 Reactions
4,014 Views
(@luigy)
Posts: 10
Active Member
Topic starter
 
[#996]

Hi Babynus,

I would like to connect the status of a document to the status of the activity I link to it. I try this code in the fonction save on model/Document.php but it doesn't work

    foreach ($this->_Link as $link){
    	if ($link->ref1Type == "Activity" && count($this->_Link) == 1){
    		$activity = new Activity();
    		$crit = array('id'=>$link->ref1Id);
    		$activity = (object) $activity->getSqlElementsFromCriteria($crit);

    		foreach ($activity as $act){
    			$act->idStatus = $this->idStatus;
    		}
    	}
    		
    }

Can't you tell me how i can do it or how i can save to modify activiy table?


 
Posted : 06 Mar 2013 13H46
babynus
(@babynus)
Posts: 14957
Main Contributor Admin
 

1) Check that $this->_Link is not empty.

3) If you have anoter item linked, nothing is done : check you have only 1 activity linked

4) You don't save your activity after updating status... :whistle:

5) Optimise code

foreach ($this->_Link as $link){
  if ($link->ref1Type == "Activity"){
    $activity = new Activity($link->ref1Id);
    $activity->idStatus = $this->idStatus;
    $activity->save();
  }
}

 
Posted : 06 Mar 2013 15H15
(@luigy)
Posts: 10
Active Member
Topic starter
 

Thank you. It's exactly what I need.


 
Posted : 06 Mar 2013 16H32
Share:

Scroll to Top