Exemplo n.º 1
0
 public function testResource()
 {
     $object = new Task();
     $oResource = new Resource();
     $this->assertInstanceOf('PhpOffice\\PhpProject\\Task', $object->addResource($oResource));
     $this->assertCount(1, $object->getResources());
     $this->assertEquals(1, $object->getResourceCount());
     $this->assertInstanceOf('PhpOffice\\PhpProject\\Task', $object->addResource($oResource));
     $this->assertCount(1, $object->getResources());
     $this->assertEquals(1, $object->getResourceCount());
 }
Exemplo n.º 2
0
 private function writeTask(XMLWriter $oXML, Task $oTask, $iNbTasks)
 {
     ++$iNbTasks;
     $oXML->startElement('task');
     $oXML->writeAttribute('id', $iNbTasks);
     $oXML->writeAttribute('name', $oTask->getName());
     $oXML->writeAttribute('start', date('Y-m-d', $oTask->getStartDate()));
     $oXML->writeAttribute('duration', $oTask->getDuration());
     $oXML->writeAttribute('complete', $oTask->getProgress() * 100);
     $oXML->writeAttribute('meeting', 'false');
     $oXML->writeAttribute('expand', 'true');
     // Resources Allocations
     if ($oTask->getResourceCount() > 0) {
         foreach ($oTask->getResources() as $oResource) {
             $itmAllocation = array();
             $itmAllocation['id_res'] = $oResource->getIndex();
             $itmAllocation['id_task'] = $iNbTasks;
             $this->arrAllocations[] = $itmAllocation;
         }
     }
     // Children
     if ($oTask->getTaskCount() > 0) {
         $arrTasksChilds = $oTask->getTasks();
         foreach ($arrTasksChilds as $oTaskChild) {
             $iNbTasks = $this->writeTask($oXML, $oTaskChild, $iNbTasks);
         }
     } else {
         // Nothing
     }
     $oXML->endElement();
     return $iNbTasks;
 }