<div id="container" class="my-box-container3" style="<?php if ($model->isDomMentor || $model->isProMentor || $model->isPerMentor) { echo 'display:block; '; } else { echo 'dispaly:none; '; } ?> height: 100%;"> <div class="contactlinks"> <h4>Availability</h4> <?php if ($model->isDomMentor) { ?> <h6>Domain Mentor Availability</h6><?php $dommentor = DomainMentor::model()->findBySql("SELECT max_tickets FROM domain_mentor WHERE user_id={$model->id}"); $userdom = UserDomain::model()->findBySql("SELECT tier_team FROM user_domain WHERE user_id={$model->id}"); if (is_null($dommentor->max_tickets)) { $dommentor->max_tickets = 0; $dommentor->save(); } if ($dommentor->max_tickets == null) { echo "Max tickets: "; ?> <select name="numTickets" style="width:60px;"> <option selected value="<?php echo $dommentor->max_tickets; ?> "><?php echo $dommentor->max_tickets; ?>
/** * 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 DomainMentor the loaded model * @throws CHttpException */ public function loadModel($id) { $model = DomainMentor::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
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 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 */ }
public static function getDomMentor($id) { $dommentor = DomainMentor::model()->findBySql("SELECT * FROM domain_mentor WHERE user_id={$id}"); return $dommentor; }