public static function run($dataDir = null) { $one_sec = 10000000; # microsecond * 10 $one_min = 60 * $one_sec; $one_hour = 60 * $one_min; # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); $tsk = new Tsk(); $prj = new Prj(); # Add tasks $task1 = $project->getRootTask()->getChildren()->add("1"); $timeUnitType = new TimeUnitType(); $task1->set($tsk->DURATION, $project->getDuration(8, $timeUnitType->Hour)); $task1->set($tsk->START, $project->get($prj->START_DATE)); $task1->set($tsk->FINISH, $project->get($prj->CALENDAR)->getTaskFinishDateFromDuration($task1, (double) (string) $task1->get($tsk->DURATION))); //.toDouble() $task2 = $project->getRootTask()->getChildren()->add("2"); $task2->set($tsk->DURATION, $project->getDuration(8, $timeUnitType->Hour)); $task2->set($tsk->START, $project->get($prj->START_DATE)); $task2->set($tsk->FINISH, $project->get($prj->CALENDAR)->getTaskFinishDateFromDuration($task2, (double) (string) $task2->get($tsk->DURATION))); //.toDouble() $project->getRootTask()->getChildren()->add($task1); $project->getRootTask()->getChildren()->add($task2); # Add four TaskLinks with different TaskLinkTypes $taskLinkType = new TaskLinkType(); $link1 = $project->getTaskLinks()->add($task1, $task2, $taskLinkType->StartToStart); # Save the Project $saveFileFormat = new SaveFileFormat(); $project->save($dataDir . "TaskLinks.mpp", $saveFileFormat->MPP); print "Saved task links data." . PHP_EOL; }
public static function run($dataDir = null) { # Instantiate project object $project = new Project(); $pred = $project->getRootTask()->getChildren()->add("Task 1"); $succ = $project->getRootTask()->getChildren()->add("Task 2"); $link = $project->getTaskLinks()->add($pred, $succ); print "Created task link." . PHP_EOL; }
public static function run($dataDir = null) { # Instantiate project object $project = new Project(); $pred = $project->getRootTask()->getChildren()->add("Task 1"); $succ = $project->getRootTask()->getChildren()->add("Task 2"); $link = $project->getTaskLinks()->add($pred, $succ); $taskLinkType = new TaskLinkType(); $link->setLinkType($taskLinkType->StartToStart); print "Defined task link type." . PHP_EOL; }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); # Create a ChildTasksCollector instance $collector = new ChildTasksCollector(); # Collect all the tasks from RootTask using TaskUtils $taskUtils = new TaskUtils(); $taskUtils->apply($project->getRootTask(), $collector, 0); $tasks = $collector->getTasks(); $tsk = new Tsk(); # Parse through all the collected tasks $i = 0; while ($i < sizeof($tasks)) { $task = $tasks->get($i); if ((string) $task->get($tsk->STOP) == "1/1/2015") { print "NA" . PHP_EOL; } else { print "Task Stop: " . (string) $task->get($tsk->STOP) . PHP_EOL; // . toString() } if ((string) $task->get($tsk->RESUME) == "1/1/2015") { print "NA" . PHP_EOL; } else { print "Task Resume: " . (string) $task->get($tsk->RESUME); // . toString() } print "---------------------------------------------" . PHP_EOL; $i += 1; } }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); $task = $project->getRootTask()->getChildren()->add("Task"); $rsc = $project->getResources()->add("Rsc"); $assn = $project->getResourceAssignments()->add($task, $rsc); print "Created resource assignment." . PHP_EOL; }
public static function run($dataDir = null) { # Instantiate project object $project = new Project(); print $project->getCalculationMode(); $task = $project->getRootTask()->getChildren()->add("Task"); $tsk = new Tsk(); $task->set($tsk->DURATION, $project->getDuration(2)); $task->set($tsk->PERCENT_COMPLETE, 50); print "Changed progress of task." . PHP_EOL; }
public static function set_resource_assignments($dataDir = null) { # Instantiate project object $project = new Project(); $task = $project->getRootTask()->getChildren()->add("Task"); $rsc = $project->getResources()->add("Rsc"); $rscc = new Rsc(); $bigDecimal = new BigDecimal(); $rsc->set($rscc->STANDARD_RATE, $bigDecimal->valueOf(10)); $rsc->set($rscc->OVERTIME_RATE, $bigDecimal->valueOf(15)); $assn = $project->getResourceAssignments()->add($task, $rsc); print "Set resource assignment properties." . PHP_EOL; }
public static function run($dataDir = null) { # Instantiate project object $project = new Project(); $task = $project->getRootTask()->getChildren()->add("Task"); $tsk = new Tsk(); $bigDecimal = new BigDecimal(); $task->set($tsk->COST, $bigDecimal->valueOf(800)); print "Task Remaining Cost: " . (string) $task->get($tsk->REMAINING_COST) . PHP_EOL; //.to_string print "Task Fixed Cost: " . (string) $task->get($tsk->FIXED_COST) . PHP_EOL; //.to_string print "Task Cost Variance: " . (string) $task->get($tsk->COST_VARIANCE) . PHP_EOL; //.to_string print "Project Cost: " . (string) $project->getRootTask()->get($tsk->COST) . PHP_EOL; //.to_string print "Project Fixed Cost: " . (string) $project->getRootTask()->get($tsk->FIXED_COST) . PHP_EOL; //.to_string print "Project Remaining Cost: " . (string) $project->getRootTask()->get($tsk->REMAINING_COST) . PHP_EOL; //.to_string print "Project Variance Cost: " . (string) $project->getRootTask()->get($tsk->COST_VARIANCE) . PHP_EOL; //.to_string }
public static function run($dataDir = null) { # Instantiate project object $project = new Project(); $prj = new Prj(); $tsk = new Tsk(); # Get a standard calendar $calendar = $project->get($prj->CALENDAR); # Set project's calendar settings $cal = new Calendar(); $cal = $cal->getInstance(); $cal->set(2011, 3, 15, 8, 0, 0); $project->set($prj->START_DATE, $cal->getTime()); $cal->set(2011, 3, 21, 17, 0, 0); $project->set($prj->FINISH_DATE, $cal->getTime()); # root task $rootTask = $project->getRootTask(); $rootTask->set($tsk->NAME, "Root"); # Add a new task $taskToSplit = $rootTask->getChildren()->add("Task1"); $taskToSplit->set($tsk->DURATION, $project->getDuration(3)); # Create a new resource assignment $splitResourceAssignment = $project->getResourceAssignments()->add($taskToSplit, null); # Generate resource assignment timephased data $splitResourceAssignment->timephasedDataFromTaskDuration($calendar); # Split the task into 3 parts. # Provide start date and finish date arguments to SplitTask method # These dates will be used for split # Set project's calendar settings $cal = new Calendar(); $cal = $cal->getInstance(); $cal2 = new Calendar(); $cal2 = $cal2->getInstance(); $cal->set(2011, 3, 16, 8, 0, 0); $cal2->set(2011, 3, 16, 17, 0, 0); $splitResourceAssignment->splitTask($cal->getTime(), $cal2->getTime(), $calendar); $cal->set(2011, 3, 18, 8, 0, 0); $cal2->set(2011, 3, 18, 17, 0, 0); $splitResourceAssignment->splitTask($cal->getTime(), $cal2->getTime(), $calendar); $asn = new Asn(); $workContourType = new WorkContourType(); $splitResourceAssignment->set($asn->WORK_CONTOUR, $workContourType->Contoured); # Save the Project $saveFileFormat = new SaveFileFormat(); $project->save($dataDir . "SplitTasks.xml", $saveFileFormat->XML); }
public static function run($dataDir = null) { $onesec = 10000000; $onemin = 60 * $onesec; $onehour = 60 * $onemin; # Instantiate project object $project = new Project(); # Creating TaskBaseline: $task = $project->getRootTask()->getChildren()->add("Task"); $baselineType = new BaselineType(); $project->setBaseline($baselineType->Baseline); $baseline = $task->getBaselines()->toList()->get(0); $duration = (double) (string) $baseline->getDuration(); //.toDouble(); $baseline_duration = $duration / $onehour; print $baseline_duration . PHP_EOL; }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); # create a new task $task = $project->getRootTask()->getChildren()->add("Task1"); # set start date $cal = new Calendar(); $cal = $cal->getInstance(); $cal->set(2015, 7, 1, 8, 0, 0); $tsk = new Tsk(); $task->set($tsk->START, $cal->getTime()); $cal->set(2015, 7, 1, 17, 0, 0); $task->set($tsk->FINISH, $cal->getTime()); # Save the project as MPP project file $saveFileFormat = new SaveFileFormat(); $project->save($dataDir . "AfterLinking.mpp", $saveFileFormat->MPP); print "Project file updated, please check the output file." . PHP_EOL; }
public static function run($dataDir = null) { # Instantiate project object $project = new Project(); $task = $project->getRootTask()->getChildren()->add("Task"); $tsk = new Tsk(); # task duration in days (default time unit) $duration = $task->get($tsk->DURATION); print "Duration in Days: " . $duration->toString(); # convert to hours time unit $timeUnitType = new TimeUnitType(); $duration = $duration->convert($timeUnitType->Hour); print "Duration in Hours: " . (string) $duration . PHP_EOL; //.toString(); # Decrease task duration $task->set($tsk->DURATION, $task->get($tsk->DURATION)->subtract(0.5)); print "0.5 wks: " . (string) $task->get($tsk->DURATION) . PHP_EOL; //.toString(); }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); # Create a ChildTasksCollector instance $collector = new ChildTasksCollector(); # Collect all the tasks from RootTask using TaskUtils $taskUtils = new TaskUtils(); $taskUtils->apply($project->getRootTask(), $collector, 0); $tsk = new Tsk(); # Parse through all the collected tasks $tasks = $collector->getTasks(); $i = 0; while ($i < sizeof($tasks)) { $task = $tasks->get($i); print $str_ed = $task->get($tsk->IS_EFFORT_DRIVEN) != null ? "EffortDriven" : "Non-EffortDriven" . PHP_EOL; print $str_crit = $task->get($tsk->IS_CRITICAL) != null ? "Critical" : "Non-Critical" . PHP_EOL; $i += 1; } }
public static function get_parent_and_child_tasks($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); # Create a ChildTasksCollector instance $collector = new ChildTasksCollector(); # Collect all the tasks from RootTask using TaskUtils $taskUtils = new TaskUtils(); $taskUtils->apply($project->getRootTask(), $collector, 0); $tsk = new Tsk(); $tasks = $collector->getTasks(); # Parse through all the collected tasks $i = 0; while ($i < sizeof($tasks)) { $task = $tasks->get($i); print "Task Name = " . (string) $task->get($tsk->NAME); //.to_string $i += 1; } }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); # Create a ChildTasksCollector instance $collector = new ChildTasksCollector(); # Collect all the tasks from RootTask using TaskUtils $taskUtils = new TaskUtils(); $taskUtils->apply($project->getRootTask(), $collector, 0); $tasks = $collector->getTasks(); $tsk = new Tsk(); # Parse through all the collected tasks $i = 0; while ($i < sizeof($tasks)) { $task = $tasks->get($i); print "Priority: " . (string) $task->get($tsk->PRIORITY) . PHP_EOL; // . toString() print "---------------------------------------------" . PHP_EOL; $i += 1; } }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); $project_summary = $project->getRootTask(); $tsk = new Tsk(); $rsc = new Rsc(); print "Project Budget Work = " . (string) $project_summary->get($tsk->BUDGET_WORK) . PHP_EOL; //.to_string print "Project Budget Cost = " . (string) $project_summary->get($tsk->BUDGET_COST) . PHP_EOL; //.to_string # Get resource by Uid $resource = $project->getResources()->getByUid(1); # Display resource budget work print "Resource BudgetWork = " . (string) $resource->get($rsc->BUDGET_WORK) . PHP_EOL; //.to_string # Get next resource by Uid $resource = $project->getResources()->getByUid(2); # Display resource budget cost print "Resource BudgetCost = " . (string) $resource->get($rsc->BUDGET_COST) . PHP_EOL; //.to_string }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); $prj = new Prj(); $tsk = new Tsk(); $cal = new Calendar(); $cal = $cal->getInstance(); $cal->set(2013, 7, 17, 8, 0, 0); $project->set($prj->START_DATE, $cal->getTime()); $project->set($prj->NEW_TASKS_ARE_MANUAL, new NullableBool(false)); $task = $project->getRootTask()->getChildren()->add("Task"); $rsc = $project->getResources()->add("Rsc"); $rscc = new Rsc(); $bigDecimal = new BigDecimal(); $rsc->set($rscc->STANDARD_RATE, $bigDecimal->valueOf(10)); $rsc->set($rscc->OVERTIME_RATE, $bigDecimal->valueOf(15)); # 6 days duration $task->set($tsk->DURATION, $project->getDuration(6)); $assn = $project->getResourceAssignments()->add($task, $rsc); $d = new Date(0); $asnn = new Asn(); $assn->set($asnn->STOP, new Date(0)); $assn->set($asnn->RESUME, new Date(0)); # backloaded contour increases task duration from 6 to 10 days $workContourType = new WorkContourType(); $assn->set($asnn->WORK_CONTOUR, $workContourType->BackLoaded); $baselineType = new BaselineType(); $project->setBaseline($baselineType->Baseline); $task->set($tsk->PERCENT_COMPLETE, 50); $timephasedDataType = new TimephasedDataType(); $td = $assn->getTimephasedData($assn->get($asnn->START), $assn->get($asnn->FINISH), $timephasedDataType->AssignmentRemainingWork)->toList(); print "Size: " . (string) $td->size() . PHP_EOL; //.to_s print "Value: " . (string) $td->get(0)->getValue() . PHP_EOL; //.to_s }
public static function run($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); $tsk = new Tsk(); $time_unit_type = new TimeUnitType(); # Get a task to calculate its duration in different formats $task = $project->getRootTask()->getChildren()->getById(1); # Get the duration in Minutes print (double) (string) $task->get($tsk->DURATION)->convert($time_unit_type->Minute) . PHP_EOL; //.toDouble(); # Get the duration in Days print (double) (string) $task->get($tsk->DURATION)->convert($time_unit_type->Day) . PHP_EOL; //.toDouble()); # Get the duration in Hours print (double) (string) $task->get($tsk->DURATION)->convert($time_unit_type->Hour) . PHP_EOL; //.toDouble(); # Get the duration in Weeks print (double) (string) $task->get($tsk->DURATION)->convert($time_unit_type->Week) . PHP_EOL; //.toDouble(); # Get the duration in Months print (double) (string) $task->get($tsk->DURATION)->convert($time_unit_type->Month) . PHP_EOL; //.toDouble(); }
public static function get_outline_properties($dataDir = null) { # Instantiate project object $project = new Project($dataDir . 'test_tasks.mpp'); # Create a ChildTasksCollector instance $collector = new ChildTasksCollector(); # Collect all the tasks from RootTask using TaskUtils $taskUtils = new TaskUtils(); $taskUtils->apply($project->getRootTask(), $collector, 0); $tasks = $collector->getTasks(); $tsk = new Tsk(); # Parse through all the collected tasks $i = 0; while ($i < sizeof($tasks)) { $task = $tasks->get($i); print "Outline Level: " . (string) $task->get($tsk->OUTLINE_LEVEL) . PHP_EOL; // . to_string; print "Outline Number: " . (string) $task->get($tsk->OUTLINE_NUMBER) . PHP_EOL; // . to_string; print "---------------------------------------------" . PHP_EOL; $i += 1; } }