</tr> </thead> <?php if ($tickets == null) { echo "No tickets"; } else { ?> <?php foreach ($tickets as $myTicket) { if ($myTicket == null) { continue; } $domain = Domain::model()->findBySql("SELECT * FROM domain WHERE id=:id", array(":id" => $myTicket->domain_id)); $creator = User::model()->find("id=:id", array(":id" => $myTicket->creator_user_id)); $sub = Subdomain::model()->findByPk($myTicket->subdomain_id); $s = 'N/A'; if ($sub == null) { $s = $sub->name; } ?> <tbody> <tr id="<?php echo $myTicket->id; ?> " class="triggerTicketClick"> <td width="5%"><?php echo $myTicket->id; ?> </td>
$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={$user->id}"); ?> <tbody> <tr> <td><?php echo $domain->name; ?> </td> <td> <?php $res = ''; foreach ($userdom as $udom) { 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>'; } } echo $res; ?> </td> </tr> </tbody> <?php } } ?> </table>
} $optionT .= '</select>'; $i = 0; foreach ($all as $domain) { /*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:50px;overflow-y: scroll;' . $sdcolor . '">'; $curPSubdomains = Subdomain::model()->findAllBySql("select * from subdomain where domain_id = {$domain->id}"); $mySubdomains = UserDomain::model()->findAllBySql("select * from user_domain where user_id = {$model->id}"); $optionS = ''; foreach ($curPSubdomains as $subdomain) { $selectR = '<select id = "' . $domain->id . 'dmrate" name="' . $domain->id . '-' . $subdomain->id . 'dmrate" style="width: 50px";>'; $selectT = '<select id = "' . $domain->id . 'dmtier" name="' . $domain->id . '-' . $subdomain->id . 'dmtier" style="width: 50px;" >'; $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>'; } } $popdiv = '<div id="test-mppover-' . $subdomain->id . '" style="display: none;">
echo $form->labelEx($model, 'domain_id'); ?> <?php echo $form->dropDownList($model, 'domain_id', CHtml::listData(Domain::model()->findAll(), 'id', 'name')); ?> <?php echo $form->error($model, 'domain_id'); ?> </div> <div class="row" style = "margin-left: 40px"> <?php echo $form->labelEx($model, 'subdomain_id'); ?> <?php echo $form->dropDownList($model, 'subdomain_id', CHtml::listData(Subdomain::model()->findAll(), 'id', 'name'), array('prompt' => 'Select')); ?> <?php echo $form->error($model, 'subdomain_id'); ?> </div> <div class ="row"; style = "margin-left: 40px"> <?php $models = User::model()->findAll(); //Needs a getDomainMentor Function $data = array(); foreach ($models as $mod) { $data[$mod->id] = $mod->fname . ' ' . $mod->lname; } ?> <?php
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 */ }
/** * Manages all models. */ public function actionAdmin() { $this->layout = ''; $model = new Ticket('search'); $cUser = User::model()->findAllBySql("select id, fname, lname from user where activated = 1 and disable = 0 order by lname"); $data1 = array(); foreach ($cUser as $u) { $data1[$u->id] = $u->fname . ' ' . $u->lname; } $aUser = User::model()->findAllBySql("select id, fname, lname from user where activated = 1 and disable = 0 order by lname"); $data2 = array(); foreach ($aUser as $u) { $data2[$u->id] = $u->fname . ' ' . $u->lname; } $dom = Domain::model()->findAllBySql("select id, name from domain order by name"); $data3 = array(); foreach ($dom as $u) { $data3[$u->id] = $u->name; } $subdom = Subdomain::model()->findAllBySql("select id, name from subdomain order by name"); $data4 = array(); foreach ($subdom as $u) { $data4[$u->id] = $u->name; } $model->unsetAttributes(); // clear any default values if (isset($_GET['Ticket'])) { $model->attributes = $_GET['Ticket']; } $this->render('admin', array('model' => $model, 'data1' => $data1, 'data2' => $data2, 'data3' => $data3, 'data4' => $data4)); }
public function actionAdmin_Create_User() { $model = new User(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $error = ''; if (isset($_POST['User'])) { /*if ($this->actionVerifyRegistrationOld() != "") { $this->render('create', array('model'=>$model)); }*/ $model->attributes = $_POST['User']; $model->pic_url = '/coplat/images/profileimages/default_pic.jpg'; $model->biography = "Tell us something about yourself..."; $model->activation_chain = $this->genRandomString(10); $model->activated = 1; $error = $this->verifyRegistrationOld(); if (!$model->isProMentor && !$model->isDomMentor && !$model->isPerMentor && !$model->isMentee) { $error = "Please select at least one user role."; } if ($error == null) { $model->save(false); if ($model->isProMentor) { $proMentor = new ProjectMentor(); $proMentor->user_id = $model->id; $proMentor->max_hours = 0; $proMentor->max_projects = 0; $proMentor->save(false); } if ($model->isDomMentor) { $domMentor = new DomainMentor(); $domMentor->user_id = $model->id; $domMentor->max_tickets = 0; $domMentor->save(); } if ($model->isPerMentor) { $perMentor = new PersonalMentor(); $perMentor->user_id = $model->id; $perMentor->max_hours = 0; $perMentor->max_mentees = 0; $perMentor->save(); } if ($model->isMentee()) { $mentee = new Mentee(); $mentee->user_id = $model->id; $mentee->personal_mentor_user_id = null; $mentee->project_id = null; $mentee->save(); } } } if (isset($_POST['Roles'])) { $proMentor = ProjectMentor::model()->getProMentor($_COOKIE['UserID']); $perMentor = PersonalMentor::model()->getPerMentor($_COOKIE['UserID']); $domMentor = DomainMentor::model()->getDomMentor($_COOKIE['UserID']); $mentee = Mentee::model()->getMentee($_COOKIE['UserID']); //$model->save(false); $user = User::model()->findByPk($_COOKIE['UserID']); if ($user->isProMentor == 1) { //$proMentor = new ProjectMentor; $proMentor->user_id = $user->id; $proMentor->max_hours = $_POST['pjmhours']; $all = Project::model()->findAll(); $proMentor->save(); $count = 0; foreach ($all as $each) { if (isset($_POST[$each->id . 'pjm'])) { $p = Project::model()->findByPk($each->id); $p->project_mentor_user_id = $_COOKIE['UserID']; $p->save(false); $count++; } } $proMentor->max_projects = $count; $proMentor->save(); } if ($user->isDomMentor == 1) { //UserDomain::model()->deleteAll("user_id = ".$user->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 ($user->isPerMentor) { //$perMentor = new PersonalMentor(); $perMentor->user_id = $user->id; $perMentor->max_hours = $_POST['pmhours']; $all = Mentee::model()->findAll(); $perMentor->save(); $count = 0; foreach ($all as $each) { if (isset($_POST[$each->user_id . 'pm'])) { $p = Mentee::model()->findByPk($each->user_id); $p->personal_mentor_user_id = $_COOKIE['UserID']; $p->save(false); $count++; } } $perMentor->max_mentees = $count; $perMentor->save(); } if ($user->isMentee) { $changed = false; $menteePersonalMentor = $_POST['mentePersonalMentor']; if (isset($menteePersonalMentor) && $menteePersonalMentor > 0) { $mentee->personal_mentor_user_id = $menteePersonalMentor; $changed = true; } $menteeProject = $_POST['menteeProject']; if (isset($menteeProject) && $menteeProject > 0) { $mentee->project_id = $menteeProject; $changed = true; } if ($changed) { $mentee->save(); } } $hasher = new PasswordHash(8, false); $pw = $this->genRandomString(8); $user->password = $hasher->HashPassword($pw); $user->save(false); $userfullName = $user->fname . ' ' . $user->lname; $adminName = User::getCurrentUser(); User::sendConfirmationEmail($userfullName, $user->email, $user->username, $pw, $adminName->fname . ' ' . $adminName->lname); } //$error = ''; $this->render('admin_create_user', array('model' => $model, 'error' => $error)); return; //$this->render('add',array('model'=>$model, 'error' => $error)); }
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; }
function getTicketColumns($model) { //get or initialize the current column order $columnArrayOrder = getColumnArrayOrder(); //only if make a cache of the columns if needed if (isset($_GET['sourceColumn']) && isset($_GET['destinationColumn'])) { $source = $_GET['sourceColumn']; $destination = $_GET['destinationColumn']; $sourceIndex = $source[0]; $destIndex = $destination[0]; ReportUtils::moveColumnsByIndex($sourceIndex, $destIndex, $columnArrayOrder); Yii::app()->session['TicketColumnOrder'] = $columnArrayOrder; } $columns = array(); for ($i = 0; $i < count($columnArrayOrder); $i++) { switch ($columnArrayOrder[$i]) { case TicketReportColumns::ticketID: $columns[] = array('name' => 'ticketID', 'header' => 'Ticket #', 'filter' => CHtml::activeNumberField($model, 'ticketID'), 'headerHtmlOptions' => array('width' => '75')); break; case TicketReportColumns::creatorName: $columns[] = array('name' => 'creatorName', 'header' => 'Creator Name', 'filter' => CHtml::activeTextField($model, 'creatorName'), 'headerHtmlOptions' => array('width' => '200')); break; case TicketReportColumns::creatorID: $columns[] = array('name' => 'creatorID', 'header' => 'Creator ID', 'filter' => CHtml::activeNumberField($model, 'creatorID'), 'headerHtmlOptions' => array('width' => '75')); break; case TicketReportColumns::creatorDisabled: $columns[] = array('name' => 'creatorDisabled', 'header' => 'Creator Disabled', 'value' => 'ReportUtils::getZeroOneToYesNo($data->creatorDisabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case TicketReportColumns::creatorEmail: $columns[] = array('name' => 'creatorEmail', 'header' => 'Creator Email', 'filter' => CHtml::activeEmailField($model, 'creatorEmail'), 'headerHtmlOptions' => array('width' => '150')); break; case TicketReportColumns::ticketStatus: $columns[] = array('name' => 'ticketStatus', 'header' => 'Ticket Status', 'filter' => array('Close' => 'Close', 'Pending' => 'Pending'), 'headerHtmlOptions' => array('width' => '105')); break; case TicketReportColumns::ticketCreatedDate: $columns[] = array('name' => 'ticketCreatedDate', 'header' => 'Created Date', 'value' => 'ReportUtils::dateformat($data->ticketCreatedDate)', 'filter' => CHtml::activeDateField($model, 'ticketCreatedDate'), 'headerHtmlOptions' => array('width' => '160')); break; case TicketReportColumns::assignedUserName: $columns[] = array('name' => 'assignedUserName', 'header' => 'Assigned To (Name)', 'filter' => CHtml::activeTextField($model, 'assignedUserName'), 'headerHtmlOptions' => array('width' => '150')); break; case TicketReportColumns::ticketAssignUserID: $columns[] = array('name' => 'ticketAssignUserID', 'header' => 'Assigned To (Id)', 'filter' => CHtml::activeNumberField($model, 'ticketAssignUserID'), 'headerHtmlOptions' => array('width' => '100')); break; case TicketReportColumns::assignedUserDisabled: $columns[] = array('name' => 'assignedUserDisabled', 'header' => 'Assigned To (Disabled)', 'value' => 'ReportUtils::getZeroOneToYesNo($data->assignedUserDisabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '100')); break; case TicketReportColumns::assignedUserEmail: $columns[] = array('name' => 'assignedUserEmail', 'header' => 'Assigned To (Email)', 'filter' => CHtml::activeEmailField($model, 'assignedUserEmail'), 'headerHtmlOptions' => array('width' => '150')); break; case TicketReportColumns::ticketDomainName: $columns[] = array('name' => 'ticketDomainName', 'header' => 'Ticket Domain', 'filter' => CHtml::activeDropDownList($model, 'ticketDomainID', CHtml::listData(Domain::model()->findAll(), 'id', 'name'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '200')); break; case TicketReportColumns::ticketSubDomainName: $columns[] = array('name' => 'ticketSubDomainName', 'header' => 'Ticket Sub Domain', 'filter' => CHtml::activeDropDownList($model, 'ticketSubDomainID', CHtml::listData(Subdomain::model()->findAll(), 'id', 'name'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '170')); break; case TicketReportColumns::ticketPriorityDescription: $columns[] = array('name' => 'ticketPriorityDescription', 'header' => 'Ticket Priority', 'filter' => CHtml::activeDropDownList($model, 'ticketPriorityID', CHtml::listData(Priority::model()->findAll(), 'id', 'description'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '110')); break; case TicketReportColumns::ticketAssignedDate: $columns[] = array('name' => 'ticketAssignedDate', 'header' => 'Ticket Assigned Date', 'value' => 'ReportUtils::dateformat($data->ticketAssignedDate)', 'filter' => CHtml::activeDateField($model, 'ticketAssignedDate'), 'headerHtmlOptions' => array('width' => '160')); break; case TicketReportColumns::ticketClosedDate: $columns[] = array('name' => 'ticketClosedDate', 'header' => 'Ticket Closed Date', 'value' => 'ReportUtils::dateformat($data->ticketClosedDate)', 'filter' => CHtml::activeDateField($model, 'ticketClosedDate'), 'headerHtmlOptions' => array('width' => '160')); break; case TicketReportColumns::ticketIsEscalated: $columns[] = array('name' => 'ticketIsEscalated', 'header' => 'Escalated', 'value' => 'ReportUtils::getZeroOneToYesNo($data->ticketIsEscalated)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case TicketReportColumns::ticketSubject: $columns[] = array('name' => 'ticketSubject', 'header' => 'Subject', 'filter' => CHtml::activeTextField($model, 'ticketSubject'), 'headerHtmlOptions' => array('width' => '300')); break; case TicketReportColumns::ticketDescription: $columns[] = array('name' => 'ticketDescription', 'header' => 'Description', 'filter' => CHtml::activeTextField($model, 'ticketDescription'), 'headerHtmlOptions' => array('width' => '400')); break; } } return $columns; }
/** * 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 Subdomain the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Subdomain::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }