ProjeQtOr free project management software - Cannot import Real work to Ticket - ProjeQtOr
 

Cannot import Real work to Ticket

More
06 Fév 2020 07:05 #1 by burgerzs
Hi,

In version v8.3.0 I cannot import Work for a Ticket item, because in the Import Result field it says "ERROR idAssignment mandatory". (By the way I can import real work to Activities the same way.)

My csv look like this:
id;resource;project;type of item;element id;name;work;date;cost;
;"Username";"Projectname";"Ticket";197;RE: DI Oracle minus alternatíva;0.06;2020-01-27;0.00;
;"Username";"Projectname";"Activity";166;Megvalósítási koncepció elkészítése;1.25;2020-01-28;0.00;

If I dispatch work from the Ticket itself, then in the database table 'work' the idassignment will be null, which is ok, in my opinion.

Is it possible to somehow import real Work to Ticket from Import Data?

Regards,
Zsolt

Please Connexion or Create an account to join the conversation.

More
07 Fév 2020 11:13 #2 by babynus
For work on tickets, you must indicate idWorkElement.

Babynus
Administrator of ProjeQtOr web site

Please Connexion or Create an account to join the conversation.

More
07 Fév 2020 19:15 - 07 Fév 2020 19:17 #3 by burgerzs
It doesn't work neither with idworkelement, nor with workelement. I got the same message.

What value should I put as workelement id, if I want to create a new real work?

resource;project;type of item;element id;work;date;idWorkElement
User;Project;Ticket;208;0.06;2020-02-03;
Last edit: 07 Fév 2020 19:17 by burgerzs.

Please Connexion or Create an account to join the conversation.

More
07 Fév 2020 20:11 - 10 Fév 2020 11:05 #4 by burgerzs
I think Work-->saveWork() doesn't handle this scenario. I mean adding new real work to a new ticket.

I am not sure what I have done doesn't make planning(calculating remaining work) wrong, but I added a few lines of code to saveWork to handle adding real work to a ticket, see below. I am also not sure if updateAssignment needs to be changed as well or not. Sorry if I am on the wrong track.
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;
      }
    }
  }
Last edit: 10 Fév 2020 11:05 by babynus.

Please Connexion or Create an account to join the conversation.

More
10 Fév 2020 11:44 #5 by babynus
Hi,
Thanks for pointing out the issue and proposing a solution.
We'll include your proposal (with minor changes) to next patch.

Babynus
Administrator of ProjeQtOr web site

Please Connexion or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.029 seconds