/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { /*Retrieve ticket Details */ $ticket = Ticket::model()->findByPk($id); /*Retrieve the names for each ticket */ $userCreator = User::model()->findBySql("SELECT * from user WHERE id=:id", array(":id" => $ticket->creator_user_id)); $userAssign = User::model()->findBySql("SELECT * from user WHERE id=:id", array(":id" => $ticket->assign_user_id)); $domainName = Domain::model()->findBySql("SELECT * from domain WHERE id=:id", array(":id" => $ticket->domain_id)); $priority = Priority::model()->findBySql("SELECT * from priority WHERE id=:id", array(":id" => $ticket->priority_id)); $tier = UserDomain::model()->findBySql("SELECT * from user_domain WHERE user_id =:id and domain_id =:id2", array(":id" => $ticket->assign_user_id, ":id2" => $ticket->domain_id)); $subdomainName = null; if ($ticket->subdomain_id != null) { $subdomainName = Subdomain::model()->findBySql("SELECT * from subdomain WHERE id=:id", array(":id" => $ticket->subdomain_id)); $tier = UserDomain::model()->findBySql("SELECT * from user_domain WHERE user_id =:id and domain_id =:id2 and subdomain_id =:id3", array(":id" => $ticket->assign_user_id, ":id2" => $ticket->domain_id, ":id3" => $ticket->subdomain_id)); } $this->render('view', array('model' => $this->loadModel($id), 'userCreator' => $userCreator, 'userAssign' => $userAssign, 'domainName' => $domainName, 'subdomainName' => $subdomainName, 'priority' => $priority, 'tier' => $tier)); if (!Yii::app()->request->isPostRequest && !Yii::app()->request->isAjaxRequest) { $curentUserID = User::getCurrentUserId(); if ($ticket->creator_user_id == $curentUserID) { TicketEvents::recordEvent(EventType::Event_Opened_By_Owner, $ticket->id, NULL, NULL, NULL); } else { TicketEvents::recordEvent(EventType::Event_Opened_By_Mentor, $ticket->id, NULL, NULL, NULL); } } }
</select></h6></center></div> <?php } else { ?> <div id="container" class="my-box-container" style="height: 175px; overflow-y: scroll "> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="#mytable" width="100%"> <thead> <tr> <th width="50%">Domain Name</th> <th width="50%">Expertise Level</th> </tr> </thead> <?php foreach ($userdoms as $userdom) { $domain = Domain::model()->find("id=:id", array(":id" => $userdom->domain_id)); $userdom = UserDomain::model()->findBySql("SELECT rate FROM user_domain WHERE domain_id={$domain->id} AND user_id={$model->id}"); ?> <tbody> <tr> <td><?php echo $domain->name; ?> </td> <td><?php if ($userdom->rate == null) { ?> <select name="unrated[]" style="width:60px;"> <?php for ($i = 1; $i <= 10; $i++) { ?> <option value="<?php
echo $res; ?> </td> </tr> </tbody> <?php } } ?> </table> <br> <h4>Domain Mentor Availability</h4><?php $dommentor = DomainMentor::model()->findBySql("SELECT max_tickets FROM domain_mentor WHERE user_id={$user->id}"); $userdom = UserDomain::model()->findBySql("SELECT tier_team FROM user_domain WHERE user_id={$user->id}"); if ($dommentor->max_tickets == null) { echo "Max tickets: N/A"; } else { echo "Max tickets: " . $dommentor->max_tickets; } ?> </div> <?php } ?>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return UserDomain the loaded model * @throws CHttpException */ public function loadModel($id) { $model = UserDomain::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function escalateTicket($domain_id, $sub) { if ($sub) { $userDomain = UserDomain::model()->findAllBySql("SELECT * FROM user_domain WHERE subdomain_id =:id", array(":id" => $domain_id)); $subdomain = Subdomain::model()->findByPk($domain_id); $validator = $subdomain->validator; } else { $userDomain = UserDomain::model()->findAllBySql("SELECT * FROM user_domain WHERE domain_id =:id", array(":id" => $domain_id)); $domain = Domain::model()->findByPk($domain_id); $validator = $domain->validator; } if ($userDomain != null && is_array($userDomain)) { foreach ($userDomain as $auserDomain) { /** @var UserDomain $auserDomain */ if ($auserDomain->tier_team == 2) { if ($auserDomain->rate >= $validator) { /*Query to the domain mentor to see how many tickets is allowed to be assigned */ $domainMentor = DomainMentor::model()->findAllBySql("SELECT * FROM domain_mentor WHERE user_id =:id", array(":id" => $auserDomain->user_id)); /** @var Ticket $count */ if (is_array($domainMentor)) { foreach ($domainMentor as $adomainMentor) { /** @var DomainMentor $adomainMentor */ $count = Ticket::model()->findBySql("SELECT COUNT(id) as `id` FROM ticket WHERE assign_user_id =:id", array(":id" => $adomainMentor->user_id)); if ($count->id < $adomainMentor->max_tickets) { /*return the first available domain mentor on queue */ return $auserDomain->user_id; } } } } } } } return self::$admin; /* Assign the ticket to the admin for reassign */ }
/*row color */ $color = ''; $sdcolor = ''; if ($i++ % 2) { $color = 'style="background: #e8edff;padding: 15px;"'; $sdcolor = 'background: #e8edff;padding: 10px'; } else { $color = 'style="padding: 15px;"'; $sdcolor = 'padding: 10px'; } $selectS = '<div border:1px id = "' . $domain->id . 'dmsub" name="' . $domain->id . 'dmsub" style="width: 150px;height:100px;overflow-y: scroll;' . $sdcolor . '">'; $curPSubdomains = Subdomain::model()->findAllBySql("select * from subdomain where domain_id = {$domain->id}"); /*subdomains*/ $optionS = ''; foreach ($curPSubdomains as $subdomain) { $allsubs = UserDomain::model()->findAllBySql("select * from user_domain where subdomain_id = {$subdomain->id}"); $allsubMentors = 'No mentor for this sub-domain'; if ($allsubs != null) { $allsubMentors = ''; foreach ($allsubs as $sub) { $us = User::model()->findByPk($sub->user_id); $allsubMentors .= $us->fname . ' ' . $us->lname . '<br>'; } } echo '<div id="subs-mpppover-' . $subdomain->id . '" style="display: none;"> <h3>Current Sub-Domain Mentors</h3> <p> ' . $allsubMentors . ' </p> </div>'; //$optionS.='<a href="#test" id="mpppover-'.$subdomain->id.'" class="mpppover" >'.
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { echo "<script>console.log('actionView!');</script>"; $model = $this->loadModel($id); $promentor = ProjectMentor::model()->getProMentor($id); $permentor = PersonalMentor::model()->getPerMentor($id); $dommentor = DomainMentor::model()->getDomMentor($id); $def = User::model()->findBySql("select * from user where username = '******'"); //$isactive = $model->activated; if (isset($_POST['updateRoles'])) { if ($model->isProMentor == 1) { Project::model()->updateAll(array('project_mentor_user_id' => $def->id), 'project_mentor_user_id = ' . $model->id); $promentor->max_hours = $_POST['pjmhours']; $all = Project::model()->findAll(); $count = 0; foreach ($all as $each) { if (isset($_POST[$each->id . 'pjm'])) { $p = Project::model()->findByPk($each->id); $p->project_mentor_user_id = $model->id; $p->save(false); $count++; } } $promentor->max_projects = $count; $promentor->save(); } if ($model->isDomMentor) { UserDomain::model()->deleteAll("user_id = " . $model->id); $dommentor->max_tickets = $_POST['dmmaxtickets']; $dommentor->save(); $all = Domain::model()->findAll(); foreach ($all as $each) { if (isset($_POST[$each->id])) { $user_domain = new UserDomain(); $user_domain->user_id = $dommentor->user_id; $user_domain->domain_id = $each->id; $user_domain->active = 1; $user_domain->save(false); $allsubs = Subdomain::model()->findAllBySql("select * from subdomain where domain_id = {$each->id}"); if ($allsubs != null) { foreach ($allsubs as $onesub) { $temp = $onesub->id . 'ddmsub'; if (isset($_POST[$temp])) { $user_domain = new UserDomain(); $user_domain->user_id = $dommentor->user_id; $user_domain->domain_id = $each->id; $user_domain->active = 1; $rate = $each->id . '-' . $onesub->id . 'dmrate'; $tier = $each->id . '-' . $onesub->id . 'dmtier'; $user_domain->rate = $_POST[$rate]; $user_domain->tier_team = $_POST[$tier]; $user_domain->subdomain_id = $onesub->id; $user_domain->save(false); } } } else { $user_domain = new UserDomain(); $user_domain->user_id = $dommentor->user_id; $user_domain->domain_id = $each->id; $user_domain->active = 1; $user_domain->save(false); } } } } if ($model->isPerMentor) { Mentee::model()->updateAll(array('personal_mentor_user_id' => $def->id), 'personal_mentor_user_id = ' . $model->id); $all = Mentee::model()->findAll(); $count = 0; foreach ($all as $each) { if (isset($_POST[$each->user_id . 'pm'])) { //$p = Mentee::model()->findByPk($each->user_id); $each->personal_mentor_user_id = $model->id; $each->save(false); $count++; } } $permentor->max_hours = $_POST['pmhours']; $permentor->max_mentees = $count; $permentor->save(); } /** @var User $username */ $projects = Project::model()->findAllBySql("SELECT title FROM project WHERE project_mentor_user_id={$id}"); $userdoms = UserDomain::model()->findAllBySql("SELECT distinct domain_id FROM user_domain WHERE user_id={$id}"); $Mentees = Mentee::model()->findAllBySql("SELECT user_id FROM mentee WHERE personal_mentor_user_id={$id}"); $Tickets = Ticket::model()->findAllBySql("SELECT * FROM ticket WHERE assign_user_id=:id", array(":id" => $id)); $this->render('view', array('Tickets' => $Tickets, 'model' => $model, 'userdoms' => $userdoms, 'Mentees' => $Mentees, 'projects' => $projects)); /*$this->render('view',array( 'model'=>$this->loadModel($id), ));*/ } else { $projects = Project::model()->findAllBySql("SELECT title FROM project WHERE project_mentor_user_id={$id}"); $userdoms = UserDomain::model()->findAllBySql("SELECT distinct domain_id FROM user_domain WHERE user_id={$id}"); $Mentees = Mentee::model()->findAllBySql("SELECT user_id FROM mentee WHERE personal_mentor_user_id={$id}"); $Tickets = Ticket::model()->findAllBySql("SELECT * FROM ticket WHERE assign_user_id=:id", array(":id" => $id)); $this->render('view', array('Tickets' => $Tickets, 'model' => $model, 'userdoms' => $userdoms, 'Mentees' => $Mentees, 'projects' => $projects, 'model' => $this->loadModel($id))); } }
public function getSubdomainsForApp($dataprovider) { $subs = array(); foreach ($dataprovider->getData() as $sub) { $temp = array(); $temp["id"] = $sub->id; $temp["name"] = $sub->name; $temp["description"] = $sub->description; $temp["need"] = $sub->need; $d = new UserDomain(); $d->subdomain_id = $sub->id; $temp["mentors"] = UserDomain::model()->getMentorsFromSubdomain($d->search()); $subs[] = $temp; } return $subs; }
public function actioneditProfile() { /** @var User $username */ $username = Yii::app()->user->name; $user = User::model()->find("username=:username", array(':username' => $username)); $projects = Project::model()->findAllBySql("SELECT title FROM project WHERE project_mentor_user_id IS NULL"); $userdoms = UserDomain::model()->findAllBySql("SELECT domain_id FROM user_domain WHERE user_id={$user->id}"); $Mentees = Mentee::model()->findAllBySql("SELECT user_id FROM mentee WHERE personal_mentor_user_id IS NULL"); $Tickets = Ticket::model()->findAllBySql("SELECT * FROM ticket WHERE assign_user_id=:id", array(":id" => $user->id)); $this->render('editProfile', array('Tickets' => $Tickets, 'user' => $user, 'userdoms' => $userdoms, 'Mentees' => $Mentees, 'projects' => $projects)); }
public function getDomainsForApp($dataprovider) { $domains = array(); foreach ($dataprovider->getData() as $domain) { $temp = array(); $temp["id"] = $domain->id; $temp["name"] = $domain->name; $temp["description"] = $domain->description; $temp["need"] = $domain->need; $d = new UserDomain(); $d->domain_id = $domain->id; $temp["mentors"] = UserDomain::model()->getMentorsFromDomain($d->search()); $subs = new Subdomain(); $subs->domain_id = $domain->id; $temp["subdomains"] = Subdomain::model()->getSubdomainsForApp($subs->setCriteriaForApp(), $domain->id); $domains[] = $temp; } return $domains; }
<?php echo "No Assigned Domains</div>"; } else { ?> <div id="container" class="my-box-container" style="height: 200px; overflow-y: scroll "> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="#mytable" width="100%"> <thead> <tr> <th width="50%">Domain Name</th> <th width="50%">Subdomain/Rating/Tier</th> </tr> </thead> <?php foreach ($userdoms as $userdom) { $domain = Domain::model()->find("id=:id", array(":id" => $userdom->domain_id)); $userdom = UserDomain::model()->findAllBySql("SELECT subdomain_id,rate,tier_team FROM user_domain WHERE domain_id={$domain->id} AND user_id={$model->id}"); ?> <tbody> <tr> <td><?php echo $domain->name; ?> </td> <td> <?php /*the table user_domain needs to be normalized!*/ foreach ($userdom as $udom) { $res = ''; if ($udom->subdomain_id != null) { $subdm = Subdomain::model()->findBySql("select * from subdomain where id = {$udom->subdomain_id}"); $res = $subdm->name . ' / ' . $udom->rate . ' / ' . $udom->tier_team . '<br>';