Example #1
0
 public function componentArchivedProjects()
 {
     if (!isset($this->target)) {
         $this->projects = entities\Project::getAllRootProjects(true);
         $this->project_count = count($this->projects);
     } elseif ($this->target == 'team') {
         $this->team = entities\Team::getB2DBTable()->selectById($this->id);
         $projects = array();
         foreach (entities\Project::getAllByOwner($this->team) as $project) {
             $projects[$project->getID()] = $project;
         }
         foreach (entities\Project::getAllByLeader($this->team) as $project) {
             $projects[$project->getID()] = $project;
         }
         foreach (entities\Project::getAllByQaResponsible($this->team) as $project) {
             $projects[$project->getID()] = $project;
         }
         foreach ($this->team->getAssociatedProjects() as $project_id => $project) {
             $projects[$project_id] = $project;
         }
         $final_projects = array();
         foreach ($projects as $project) {
             if ($project->isArchived()) {
                 $final_projects[] = $project;
             }
         }
         $this->projects = $final_projects;
     } elseif ($this->target == 'client') {
         $this->client = entities\Client::getB2DBTable()->selectById($this->id);
         $projects = entities\Project::getAllByClientID($this->client->getID());
         $final_projects = array();
         foreach ($projects as $project) {
             if (!$project->isArchived()) {
                 $final_projects[] = $project;
             }
         }
         $this->projects = $final_projects;
     } elseif ($this->target == 'project') {
         $this->parent = entities\Project::getB2DBTable()->selectById($this->id);
         $this->projects = $this->parent->getChildren(true);
     }
     $this->project_count = count($this->projects);
 }
Example #2
0
 /**
  * Client Dashboard
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runClientDashboard(framework\Request $request)
 {
     $this->client = null;
     try {
         $this->client = entities\Client::getB2DBTable()->selectById($request['client_id']);
         $projects = entities\Project::getAllByClientID($this->client->getID());
         $final_projects = array();
         foreach ($projects as $project) {
             if (!$project->isArchived()) {
                 $final_projects[] = $project;
             }
         }
         $this->projects = $final_projects;
         $this->forward403Unless($this->client->hasAccess());
     } catch (\Exception $e) {
         framework\Logging::log($e->getMessage(), 'core', framework\Logging::LEVEL_WARNING);
         return $this->return404(framework\Context::getI18n()->__('This client does not exist'));
     }
 }
Example #3
0
 public function runDeleteClient(framework\Request $request)
 {
     try {
         try {
             $client = entities\Client::getB2DBTable()->selectById($request['client_id']);
         } catch (\Exception $e) {
         }
         if (!$client instanceof entities\Client) {
             throw new \Exception($this->getI18n()->__("You cannot delete this client"));
         }
         if (entities\Project::getAllByClientID($client->getID()) !== null) {
             foreach (entities\Project::getAllByClientID($client->getID()) as $project) {
                 $project->setClient(null);
                 $project->save();
             }
         }
         $client->delete();
         return $this->renderJSON(array('success' => true, 'message' => $this->getI18n()->__('The client was deleted')));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Example #4
0
<div id="client_<?php 
echo $client->getID();
?>
">
    <?php 
echo image_tag('client_large.png', array('style' => 'float: left; margin-right: 5px;'));
?>
    <p class="header">
        <?php 
echo link_tag(make_url('client_dashboard', array('client_id' => $client->getId())), $client->getName());
?>
    </p>
    <p class="info">
        <?php 
echo __('%number_of member(s)', array('%number_of' => '<span id="client_' . $client->getID() . '_membercount">' . $client->getNumberOfMembers() . '</span>'));
?>
,
        <?php 
echo __('%number_of projects(s)', array('%number_of' => '<span id="client_' . $client->getID() . '_projectcount">' . count(\thebuggenie\core\entities\Project::getAllByClientID($client->getID())) . '</span>'));
?>
     </p>
</div>