/** * @Route("/insert", name="project_area_status_insert") */ public function insertAction(Request $request) { $entity = new AreaStatus(); $entity->setProject($this->getActiveProject()); $action = new InsertAction($this->crudInfo, $entity, ProjectAreaStatusForm::class); $action->slug($this->getSlug()); return $action->run($this, $request); }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $pp = new CourseProgress($this->area); $pp->insert(self::$conn); }
public static function fetchById(Connection $conn, $id) { $data = $conn->fetchAssoc('SELECT * FROM `' . ExportTables::DATA_EXPORT_TBL . '` WHERE `id` = :id', [':id' => $id]); if (false === $data) { return false; } $item = self::fromArray($data); $item->project = Project::fetch($conn, $data['projectId']); $item->areaStatus = AreaStatus::fetchByProject($conn, $data['areaStatusId'], $item->project); return $item; }
public static function fetchByProject(Connection $conn, $id, Project $project) { $data = $conn->fetchAssoc('SELECT r.*, ' . ' s1.`id` AS `s1_id`, s1.`name` AS `s1_name`, s1.`label` AS `s1_label`, s1.`isDefault` AS `s1_isDefault`, s1.`areaNum` AS `s1_areaNum`, ' . ' s2.`id` AS `s2_id`, s2.`name` AS `s2_name`, s2.`label` AS `s2_label`, s2.`isDefault` AS `s2_isDefault`, s2.`areaNum` AS `s2_areaNum` ' . 'FROM `' . MilestoneTables::MILESTONE_STATUS_RULE_TBL . '` r ' . 'INNER JOIN `' . CoreTables::AREA_STATUS_TBL . '` s1 ON r.`newStatusId` = s1.`id` ' . 'INNER JOIN `' . CoreTables::AREA_STATUS_TBL . '` s2 ON r.`prevStatusId` = s2.`id` ' . 'WHERE r.`id` = :id AND r.`projectId` = :projectId', [':id' => $id, ':projectId' => $project->getId()]); if (empty($data)) { return false; } $item = self::fromArray($data); $item->project = $project; $item->newStatus = AreaStatus::fromArray($data, 's1'); $item->prevStatus = AreaStatus::fromArray($data, 's2'); $item->newStatus->setProject($project); $item->prevStatus->setProject($project); return $item; }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->area2 = Area::newArea($this->project, $this->territory, $this->status, 'Area2'); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->user2 = User::newUser('login2', 'Another user', $lang); $this->user2->insert(self::$conn); $tpa1 = new CourseProgress($this->area); $tpa1->insert(self::$conn); }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->course = new Course(); $this->course->setProject($this->project); $this->course->setName('Foo'); $this->course->setAuthorName('Foo'); $this->course->setAuthorEmail('*****@*****.**'); $this->course->setPresentationLink('http://www.example.com/'); $this->course->setIsPublished(true); $this->course->insert(self::$conn); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->anotherUser = User::newUser('login2', 'Another user', $lang); $this->anotherUser->insert(self::$conn); $pp = new CourseProgress($this->area); $pp->insert(self::$conn); }
public function insert(Connection $conn) { $this->status = AreaStatus::fetchDefault($conn, $this->project); $groupName = null; if (null !== $this->group) { $groupName = $this->group->getName(); } if (null !== $this->group) { DataMappers::recount($conn, CoreTables::GROUP_TBL, null, $this->group, 'areaNum', 'id'); } DataMappers::recount($conn, CoreTables::AREA_STATUS_TBL, null, $this->status, 'areaNum', 'id'); DataMappers::recount($conn, CoreTables::TERRITORY_TBL, null, $this->territory, 'areaNum', 'id'); $this->entity = new Entity(); $this->entity->setType('Area'); $this->entity->setName($this->name); $this->entity->insert($conn); $this->createdAt = $this->lastUpdatedAt = time(); $this->percentCompleteness = 0; $this->slug = DataMappers::generateSlug($conn, CoreTables::GROUP_TBL); $conn->insert(CoreTables::AREA_TBL, DataMappers::pick($this, ['name', 'slug', 'project', 'group', 'territory', 'status', 'reporter', 'entity', 'createdAt', 'lastUpdatedAt', 'percentCompleteness'], ['customData' => json_encode($this->customData), 'groupName' => $groupName])); return $this->id = $conn->lastInsertId(); }
public function remove(AreaStatus $item) { $this->transaction->requestTransaction(); try { return $item->remove($this->conn); } catch (Exception $ex) { $this->transaction->requestRollback(); throw $ex; } }