• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

cms/modules/qaos.lib.php

Go to the documentation of this file.
00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 { 
00004         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007         exit(1);
00008 }
00041 class qaos implements module {
00042         private $userId;
00043         private $moduleComponentId;
00044         private $action;
00045         public function getHtml($gotuid, $gotmoduleComponentId, $gotaction) {
00046                 $this->userId = $gotuid;
00047                 $this->moduleComponentId = $gotmoduleComponentId;
00048                 $this->action = $gotaction;
00049                 if ($this->action == "view")
00050                         return $this->actionView();
00051                 if ($this->action == "edit")
00052                         return $this->actionEdit($this->moduleComponentId);
00053                 if ($this->action == "create")
00054                         return $this->createModule($this->moduleComponentId);
00055                 if ($this->action == "delete")
00056                         return $this->deleteModule($this->moduleComponentId);
00057                 if ($this->action == "copy")
00058                         return $this->copyModule($this->moduleComponentId);
00059                 if ($this->action == "score")
00060                         return $this->actionScore($this->moduleComponentId);
00061                 if ($this->action == "qaosadmin")
00062                         return $this->actionQaosadmin();
00063         }
00064         public function actionView(){
00065                 $score = false;
00066                 return $this->generateTree($this->moduleComponentId,$score);
00067         }
00068         public function actionQaosadmin(){
00069                 $moduleComponentId = $this->moduleComponentId;
00070                 $score = true;
00071                 if($_GET['subaction']=='viewscore'){
00072                         if(isset($_GET['useremail'])){
00073                                 $userId = getUserIdFromEmail($_GET['useremail']);
00074                                 $htmlOut = "<br /><br />People who has been rated by this person:<br /><br />";
00075                                 $query = "SELECT * FROM `qaos_scoring` WHERE user_id = $userId";
00076                                 $result = mysql_query($query);
00077                                 $htmlOut .= "<table border=\"1\">";
00078                                 $htmlOut .= "<tr><th>Target User Full Name</th><th>Target User Team</th><th>Target User Designation</th><th>Target User Score1</th><th>Target User Reason1</th><th>Target User Score2</th><th>Target User Reason2</th><th>Target User Score3</th><th>Target User Reason3</th><th>Target User Score4</th><th>Target User Reason4</th><th>Target User Score5</th><th>Target User Reason5</th>";
00079                                 while($row = mysql_fetch_assoc($result)){
00080                                         $targetUserId = $row['targetuser_id'];
00081                                         $targetUserFullName = getUserFullName($targetUserId);
00082                                         $targetUserTeam = $this->getTeamNameFromTeamId($this->getTeamId($targetUserId));
00083                                         $targetUserDesignation = $this->getDesignationNameFromDesignationId($this->getDesignationId($targetUserId));
00084                                         $score1 = $row['qaos_score1'];$score2 = $row['qaos_score2'];$score3 = $row['qaos_score3'];$score4 = $row['qaos_score4'];$score5 = $row['qaos_score5'];
00085                                         $reason1 = $row['qaos_reason1'];$reason2 = $row['qaos_reason2'];$reason3 = $row['qaos_reason3'];$reason4 = $row['qaos_reason4'];$reason5 = $row['qaos_reason5'];
00086                                         $htmlOut .=<<<USERDATA
00087                                                                 <tr>
00088                                                                         <td> $targetUserFullName </td>
00089                                                                         <td> $targetUserTeam </td>
00090                                                                         <td> $targetUserDesignation </td>
00091                                                                         <td> $score1 </td>
00092                                                                         <td> $reason1 </td>
00093                                                                         <td> $score2 </td>
00094                                                                         <td> $reason2 </td>
00095                                                                         <td> $score3 </td>
00096                                                                         <td> $reason3 </td>
00097                                                                         <td> $score4 </td>
00098                                                                         <td> $reason4 </td>
00099                                                                         <td> $score5 </td>
00100                                                                         <td> $reason5 </td>
00101                                                                                                 
00102                                                                         
00103                                                                 </tr>
00104                                                                                                 
00105 USERDATA;
00106                                 }
00107                                 $query = "SELECT count(*) as count FROM `qaos_scoring` WHERE user_id = $userId";
00108                                 $result = mysql_query($query);
00109                                 $row = mysql_fetch_assoc($result);
00110                                 $htmlOut .= "</table> <br />Total No of persons this guy has rated : ".$row['count'];
00111                                  
00112                                 $htmlOut .= "<br /><br /><br />People who has rated this person:<br /><br />";
00113                                 $query = "SELECT * FROM `qaos_scoring` WHERE targetuser_id = $userId";
00114                                 $result = mysql_query($query);
00115                                 $htmlOut .= "<table border=\"1\">";
00116                                 $htmlOut .= "<tr><th>User Full Name</th><th>User Team</th><th>User Designation</th><th>User Score1</th><th>User Reason1</th><th>User Score2</th><th>User Reason2</th><th>User Score3</th><th>User Reason3</th><th>User Score4</th><th>User Reason4</th><th>User Score5</th><th>User Reason5</th>";
00117                                 while($row2 = mysql_fetch_assoc($result)){
00118                                         $targetUserId = $row2['targetuser_id'];
00119                                         $targetUserFullName = getUserFullName($userId);
00120                                         $targetUserTeam = $this->getTeamNameFromTeamId($this->getTeamId($userId));
00121                                         $targetUserDesignation = $this->getDesignationNameFromDesignationId($this->getDesignationId($userId));
00122                                         $score1 = $row2['qaos_score1'];$score2 = $row2['qaos_score2'];$score3 = $row2['qaos_score3'];$score4 = $row2['qaos_score4'];$score5 = $row2['qaos_score5'];
00123                                         $reason1 = $row2['qaos_reason1'];$reason2 = $row2['qaos_reason2'];$reason3 = $row2['qaos_reason3'];$reason4 = $row2['qaos_reason4'];$reason5 = $row2['qaos_reason5'];
00124                                         $htmlOut .=<<<USERDATA
00125                                                                 <tr>
00126                                                                         <td> $targetUserFullName </td>
00127                                                                         <td> $targetUserTeam </td>
00128                                                                         <td> $targetUserDesignation </td>
00129                                                                         <td> $score1 </td>
00130                                                                         <td> $reason1 </td>
00131                                                                         <td> $score2 </td>
00132                                                                         <td> $reason2 </td>
00133                                                                         <td> $score3 </td>
00134                                                                         <td> $reason3 </td>
00135                                                                         <td> $score4 </td>
00136                                                                         <td> $reason4 </td>
00137                                                                         <td> $score5 </td>
00138                                                                         <td> $reason5 </td>
00139                                                                 </tr>
00140 USERDATA;
00141                                 }
00142                                 $query = "SELECT count(*) as count FROM `qaos_scoring` WHERE targetuser_id = $userId";
00143                                 $result = mysql_query($query);
00144                                 $row = mysql_fetch_assoc($result);
00145                                 $htmlOut .= "</table><br />Total number of person who have rated this person : ".$row['count']; 
00146                                 
00147                                 return $htmlOut;
00148                         }
00149                         return $this->generateTree($this->moduleComponentId,$score);
00150                 }
00151                 
00152                 $htmlOut .=<<<ADMIN
00153                                         <a href="./+qaosadmin&subaction=addteam">Add Teams</a><br />
00154                                         <a href="./+qaosadmin&subaction=adddesignation">Add Designation</a><br />
00155                                         <a href="./+qaosadmin&subaction=changeteam">Change teams for the user</a><br />
00156                                         <a href="./+qaosadmin&subaction=viewscore">View Scores</a><br />
00157 ADMIN;
00158                 return $htmlOut;
00159         }
00160         public function actionEdit($moduleComponentId){
00161         global $urlRequestRoot;
00162         global $sourceFolder,$cmsFolder;
00163         global $templateFolder;
00164         $scriptsFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/scripts";
00165         $imagesFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/images";
00166 
00167                 if(isset($_GET['subaction'])){
00168                         if($_GET['subaction']=='addteam'){
00169                                 if(isset($_POST['btnAddTeam'])){
00170                                         $query = "SELECT MAX(`qaos_team_id`)  AS max FROM `qaos_teams`";
00171                                         $result = mysql_query($query);
00172                                         $resultArray = mysql_fetch_assoc($result);
00173                                         $max = $resultArray['max'];
00174                                         for($i=1; $i<6;$i++){
00175                                                 if($teamName=$_POST["qaos_team".$i.""]){
00176                                                         $query = "SELECT * FROM `qaos_teams` WHERE `qaos_team_name` LIKE '$teamName%'";
00177                                                         $result = mysql_query($query);
00178                                                         if(mysql_num_rows($result)>1){
00179                                                                 displayerror("The $teamName team already exists in the database.");
00180                                                                 continue;
00181                                                         }
00182                                                         $teamId = $max + $i;
00183                                                         $teamDesc = $_POST["team_desc".$i.""];
00184                                                         $query = "INSERT INTO `qaos_teams` (`page_modulecomponentid`,`qaos_team_id`,`qaos_team_name`,`qaos_team_description`) VALUES ('$moduleComponentId','$teamId','$teamName','$teamDesc')";
00185                                                         $result = mysql_query($query);
00186                                                         if(!$result)
00187                                                                 displayerror("The team '$teamName' could not be added. Please try again.");
00188 
00189                                                 }
00190                                         }
00191                                 }
00192                         }
00193 
00194                         elseif($_GET['subaction']=='changeversion'){
00195                                 if(isset($_POST['btnSubmitVersion'])){
00196                                         $query = "UPDATE `qaos_version` SET `qaos_version` = '$_POST[qaos_version]' WHERE `page_modulecomponentid` = $moduleComponentId";
00197                                         $result = mysql_query($query);
00198                                         if(mysql_query($query))
00199                                                 displayinfo("The version has been successfully updated.");
00200                                         else
00201                                                 displayinfo("There was some error while updating the version. Please check your query once.");
00202                                         }
00203                         }
00204                         elseif($_GET['subaction']=='addteammember'){
00205                                 if(isset($_POST['btnAddTeamMember'])){
00206                                         $emailName = $_POST['useremail'];
00207                                         $input = explode(" - ",$emailName);
00208                                         $email = $input[0];
00209                                         $designation = $_POST['userdesignation'];
00210                                         $team = $_POST['userteam'];
00211                                         $parentTeam =$_POST['userparentteam'];
00212                                         $parentDesignation = $_POST['userparentdesignation'];
00213                                         $name = $this->addTeamMember($email,$designation,$team,$parentTeam,$parentDesignation);
00214                                         if($team = "Qaos"){
00215                                                 $this->addQaosTeamMember(getUserIdFromEmail($email),$_POST['qaosteam1'],$_POST['qaosteam2'],$_POST['qaosteam3'],$_POST['qaosteam4']);
00216                                         }
00217                                 }
00218                         }
00219                         elseif($_GET['subaction'] == 'getsuggestions' && isset($_GET['forwhat'])) {
00220                                 echo $this->getSuggestions($_GET['forwhat'], $_GET['suggestiontype']);
00221                                 exit();
00222                         }
00223                 }
00224 
00225 
00226                 $queryVersion = "SELECT `qaos_version` FROM `qaos_version` WHERE `page_modulecomponentid` = $moduleComponentId";
00227                 $resultVersion = mysql_query($queryVersion);
00228                 $row = mysql_fetch_row($resultVersion);
00229                 $version = $row[0];
00230                 $html .= "<h2>$version</h2>     <br />";
00231                 if(getPermissions($this->userId,getPageIdFromModuleComponentId("qaos",$this->moduleComponentId),"create")){
00232                         $html .= <<<EDITQAOS
00233                         <div class="changeqaosversion">
00234                                 <form id="changeqaosversion" method="POST" onsubmit="return checkProfileForm(this)" action="./+edit&subaction=changeversion">
00235                                         <fieldset style="width:80%">
00236                                                 <legend><b>Change the Version</b></legend>
00237                                                 <table>
00238                                                         <tr>
00239                                                                 <td>
00240                                                                         Changer Qaos version:
00241                                                                 </td>
00242                                                                 <td>
00243                                                                         <input name="qaos_version" id="qaos_version" value="$version" type="text">
00244                                                                 </td>
00245                                                                 <td><input type="submit" name="btnSubmitVersion" id="submitbutton" value="Save Version"></td>
00246                                                         </tr>
00247                                                 </table>
00248                                         </fieldset>
00249                                 </form>
00250                         </div>
00251 EDITQAOS;
00252                 }
00253                 $html .= "<br /><h3>Teams in Pragyan 2008: </h3><br />";
00254                 $queryTeam = "SELECT * FROM `qaos_teams` WHERE `page_modulecomponentid`=$moduleComponentId ORDER BY `qaos_team_name`";
00255                 $resultTeam = mysql_query($queryTeam);
00256                 $html.= "<table border=\"1\"><tr><td><b>Team Name</b></td><td><b>Team Description</b></td><td><b>Team Representative</b></td></tr>";
00257                 while($row = mysql_fetch_row($resultTeam)){
00258                         $team = $row[2];
00259                         $desc = $row[3];
00260                         $repr = $row[4];
00261                         $html .= "<tr><td>$team</td><td>$desc</td><td>$repr</td></tr>";
00262                 }
00263                 $html .= "</table><br /><br />";
00264                 $userTeamId = $this->getTeamId($this->userId);
00265                 if($userTeamId ==1){
00266                 $html .=<<<ADDTEAMS
00267                 <div class="registrationform">
00268                         <div class="addteam">
00269                                 <form id="addteam" method="POST" onsubmit="return checkProfileForm(this)" action="./+edit&subaction=addteam">
00270                                         <fieldset style="width:80%">
00271                                                 <legend><b>Add Teams</b></legend>
00272                                                 <table>
00273                                                         <tr>
00274                                                                         <tr>
00275                                                                                 <td>
00276                                                                                         Enter the Team Name:
00277                                                                                 </td>
00278                                                                                 <td>
00279                                                                                         <input name="qaos_team1" id="qaos_team" type="text">
00280                                                                                 </td>
00281                                                                         </tr>
00282                                                                         <tr>
00283                                                                                 <td>
00284                                                                                         Enter the Team Description:
00285                                                                                 </td>
00286                                                                                 <td>
00287                                                                                         <input name="team_desc1" id="team_desc" type="text">
00288                                                                                 </td>
00289                                                                         </tr>
00290                                                         </tr>
00291                                                 </table>
00292                                                 <input value="Add more teams" onclick="javascript:toggleuploadfiles(this);" type="button">
00293                                         <span class="hiddenteams"><table>
00294                                                         <tr>
00295                                                                                 <td>
00296                                                                                 Enter the Team Name:
00297                                                                                 </td>
00298                                                                                 <td>
00299                                                                                         <input name="qaos_team2" id="qaos_team" type="text">
00300                                                                                 </td>
00301                                                                         </tr>
00302                                                                         <tr>
00303                                                                                 <td>
00304                                                                                         Enter the Team Description:
00305                                                                                 </td>
00306                                                                                 <td>
00307                                                                                         <input name="team_desc2" id="team_desc" type="text">
00308                                                                                 </td>
00309                                                                         </tr>
00310                                                                         <tr><td><br /></td></tr>
00311 
00312                                                                         <tr>
00313                                                                                 <td>
00314                                                                                         Enter the Team Name:
00315                                                                                 </td>
00316                                                                                 <td>
00317                                                                                         <input name="qaos_team3" id="qaos_team" type="text">
00318                                                                                 </td>
00319                                                                         </tr>
00320                                                                         <tr>
00321                                                                                 <td>
00322                                                                                         Enter the Team Description:
00323                                                                                 </td>
00324                                                                                 <td>
00325                                                                                         <input name="team_desc3" id="team_desc" type="text">
00326                                                                                 </td>
00327                                                                         </tr>
00328                 <tr><td><br /></td></tr>
00329                                                                 <tr>
00330                                                                                 <td>
00331                                                                                         Enter the Team Name:
00332                                                                                 </td>
00333                                                                                 <td>
00334                                                                                         <input name="qaos_team4" id="qaos_team" type="text">
00335                                                                                 </td>
00336                                                                         </tr>
00337                                                                         <tr>
00338                                                                                 <td>
00339                                                                                         Enter the Team Description:
00340                                                                                 </td>
00341                                                                                 <td>
00342                                                                                         <input name="team_desc4" id="team_desc" type="text">
00343                                                                                 </td>
00344                                                                         </tr>
00345                 <tr><td><br /></td></tr>
00346                                                                 <tr>
00347                                                                                 <td>
00348                                                                                         Enter the Team Name:
00349                                                                                 </td>
00350                                                                                 <td>
00351                                                                                         <input name="qaos_team5" id="qaos_team" type="text">
00352                                                                                 </td>
00353                                                                         </tr>
00354                                                                         <tr>
00355                                                                                 <td>
00356                                                                                         Enter the Team Description:
00357                                                                                 </td>
00358                                                                                 <td>
00359                                                                                         <input name="team_desc5" id="team_desc" type="text">
00360                                                                                 </td>
00361                                                                         </tr>
00362 
00363                                                         </table>
00364                                         </span>
00365                                                         <tr>
00366                                                                 <td>
00367                                                                         <input type="submit" name="btnAddTeam" id="submitbutton" value="Submit">
00368                                                                 </td>
00369                                                         </tr>
00370 
00371                                         </fieldset>
00372                                 </form>
00373                         </div>
00374                 </div>
00375                 <style type="text/css">
00376                         .hiddenteams{display:none;}
00377                         .shownteams{display:block;}
00378                 </style>
00379                 <script language="javascript" type="text/javascript">
00380                         function toggleuploadfiles(gett) {
00381                                 if(gett.nextSibling.nextSibling.className != "shownteams")
00382                                 {
00383                                         gett.nextSibling.nextSibling.className = "shownteams";
00384                                         gett = gett.nextSibling.nextSibling;
00385                                 }
00386                                 else
00387                                 {
00388                                         gett.nextSibling.nextSibling.className = "hiddenteams";
00389                                         gett = gett.nextSibling.nextSibling;
00390                                 }
00391                         }
00392                 </script>
00393 ADDTEAMS;
00394                 }
00395                 $html .= "<br />";
00396                 $html .=<<<ADDPERSON
00397                 <script type="text/javascript" language="javascript">
00398                 <!--
00399                         imgAjaxLoading = new Image();
00400                         imgAjaxLoading.src = '$imagesFolder/ajaxloading.gif';
00401                 -->
00402                 </script>
00403                 <style type="text/css">
00404                 <!--
00405                         span.suggestion {
00406                                 padding: 2px 4px 2px 4px;
00407                                 display: block;
00408                                 background-color: white;
00409                                 cursor: pointer;
00410                         }
00411                         span.suggestion:hover {
00412                                 background-color: #DEDEDE;
00413                         }
00414                 -->
00415                 </style>
00416                 <script type="text/javascript" language="javascript" src="$scriptsFolder/ajaxsuggestionbox.js"></script>
00417                 <div class="registrationform">
00418                         <div class="addteammember">
00419 
00420                                 <form id="addteammember" method="POST" onsubmit="return checkProfileForm(this)" action="./+edit&subaction=addteammember">
00421                                         <fieldset style="width:80%">
00422                                                 <legend><b>Add Team Members</b></legend>
00423                                                         <table>
00424                                                                 <tr>
00425                                                                         <td>
00426                                                                                 Enter the Team Member Name:
00427                                                                         </td>
00428                                                                         <td>
00429                                                                                 <input type="text" name="useremail" id="userEmail" autocomplete="off" style="width: 256px" />
00430                                                                                 <div id="suggestionsName" class="suggestionbox"></div>
00431                                                                         </td>
00432                                                                 </tr>
00433                                                                 <tr>
00434                                                                         <td>
00435                                                                                 Enter the User Designation:
00436                                                                         </td>
00437                                                                         <td>
00438                                                                                 <input type="text" name="userdesignation" id="userDesignation" autocomplete="off" style="width: 256px" />
00439                                                                         <div id="suggestionsDesignation" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00440                                                                         </td>
00441                                                                 </tr>
00442                                                                 <tr>
00443                                                                         <td>
00444                                                                                 Enter the Team Name:
00445                                                                         </td>
00446                                                                         <td>
00447                                                                                 <input type="text" name="userteam" id="userTeam" autocomplete="off" style="width: 256px" />
00448                                                                                 <div id="suggestionsTeam" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00449                                                                         </td>
00450                                                                 </tr>
00451                                                                 <tr>
00452                                                                         <td>
00453                                                                                 Enter the Parent Team Name:
00454                                                                         </td>
00455                                                                         <td>
00456                                                                                 <input type="text" name="userparentteam" id="userParentTeam" autocomplete="off" style="width: 256px" />
00457                                                                                 <div id="suggestionsParentTeam" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00458                                                                         </td>
00459                                                                 </tr>
00460                                                                 <tr>
00461                                                                         <td>
00462                                                                                 Enter the Parent Designation:
00463                                                                         </td>
00464                                                                         <td>
00465                                                                                 <input type="text" name="userparentdesignation" id="userParentDesignation" autocomplete="off" style="width: 256px" />
00466                                                                                 <div id="suggestionsParentDesignation" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00467                                                                         </td>
00468                                                                 </tr>
00469                                                                 <tr>
00470                                                                         <td>
00471                                                                                 Enter Qaos Team1:
00472                                                                         </td>
00473                                                                         <td>
00474                                                                                 <input type="text" name="qaosteam1" id="qaosTeam1" autocomplete="off" style="width: 256px" />
00475                                                                                 <div id="suggestionsQaosTeam1" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00476                                                                         </td>
00477                                                                 </tr>
00478                                                                 <tr>
00479                                                                         <td>
00480                                                                                 Enter Qaos Team2:
00481                                                                         </td>
00482                                                                         <td>
00483                                                                                 <input type="text" name="qaosteam2" id="qaosTeam2" autocomplete="off" style="width: 256px" />
00484                                                                                 <div id="suggestionsQaosTeam2" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00485                                                                         </td>
00486                                                                 </tr>
00487                                                                 <tr>
00488                                                                         <td>
00489                                                                                 Enter Qaos Team3:
00490                                                                         </td>
00491                                                                         <td>
00492                                                                                 <input type="text" name="qaosteam3" id="qaosTeam3" autocomplete="off" style="width: 256px" />
00493                                                                                 <div id="suggestionsQaosTeam3" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00494                                                                         </td>
00495                                                                 </tr>
00496                                                                 <tr>
00497                                                                         <td>
00498                                                                                 Enter Qaos Team4:
00499                                                                         </td>
00500                                                                         <td>
00501                                                                                 <input type="text" name="qaosteam4" id="qaosTeam4" autocomplete="off" style="width: 256px" />
00502                                                                                 <div id="suggestionsQaosTeam4" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00503                                                                         </td>
00504                                                                 </tr>
00505                                                                 
00506                                                                 <tr>
00507                                                                         <td><input type="submit" name="btnAddTeamMember" id="submitbutton" value="Add Team Member"></td>
00508                                                                 </tr>
00509 
00510                                                         <script language="javascript" type="text/javascript">
00511                                                         <!--
00512                                                                 nameSuggestionBox = new SuggestionBox(document.getElementById('userEmail'), document.getElementById('suggestionsName'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=username');
00513                                                                 nameSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00514                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userDesignation'), document.getElementById('suggestionsDesignation'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=designation');
00515                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00516                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userTeam'), document.getElementById('suggestionsTeam'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00517                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00518                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userParentTeam'), document.getElementById('suggestionsParentTeam'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00519                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00520                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userParentDesignation'), document.getElementById('suggestionsParentDesignation'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=designation');
00521                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00522                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam1'), document.getElementById('suggestionsQaosTeam1'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00523                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00524                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam2'), document.getElementById('suggestionsQaosTeam2'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00525                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00526                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam3'), document.getElementById('suggestionsQaosTeam3'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00527                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00528                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam4'), document.getElementById('suggestionsQaosTeam4'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00529                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00530                                                                 
00531                                                         -->
00532                                                         </script>
00533 
00534                                                         </table>
00535                                         </fieldset>
00536                                 </form>
00537                         </div>
00538                 </div>
00539 
00540 ADDPERSON;
00541 // if the user team is core, then display the parent team name and designation field, otherwise disable it!
00542 
00543                 if($userTeamId == $this->getTeamIdFromTeamName("Core")){
00544                         $html .=<<<DISABLEPARENTFIELD
00545                                 <script language="javascript" type="text/javascript">
00546                                         document.getElementById("userParentTeam").disabled=false;
00547                                         document.getElementById("userParentDesignation").disabled=false;
00548                                 </script>
00549 DISABLEPARENTFIELD;
00550                 }
00551                 else if($userTeamId == $this->getTeamIdFromTeamName("Qaos")){
00552                         $html .=<<<DISABLEPARENTFIELD
00553                                 <script language="javascript" type="text/javascript">
00554                                         document.getElementById("qaosTeam1").disabled=false;
00555                                         document.getElementById("qaosTeam2").disabled=false;
00556                                         document.getElementById("qaosTeam3").disabled=false;
00557                                         document.getElementById("qaosTeam4").disabled=false;
00558                                 </script>
00559 DISABLEPARENTFIELD;
00560                 }
00561         
00562                 else 
00563                         $html .=<<<DISABLEPARENTFIELD
00564                                 <script language="javascript" type="text/javascript">
00565                                                 document.getElementById("userParentTeam").disabled=true;
00566                                                 document.getElementById("userParentDesignation").disabled=true;
00567                                                 document.getElementById("qaosTeam1").disabled=true;
00568                                                 document.getElementById("qaosTeam2").disabled=true;
00569                                                 document.getElementById("qaosTeam3").disabled=true;
00570                                                 document.getElementById("qaosTeam4").disabled=true;
00571                                 </script>
00572 DISABLEPARENTFIELD;
00573                         return $html;
00574 
00575         }
00576 
00577         function getSuggestions($pattern, $patternType = 'username') {
00578                 if($patternType == 'username') {
00579                         return getSuggestions($pattern);
00580                 }
00581                 else if($patternType == 'designation'){
00582                         $suggestionsQuery = "SELECT `qaos_designation_name` FROM `qaos_designations` WHERE `qaos_designation_name` LIKE \"%$pattern%\"" ;
00583                         $suggestionsResult = mysql_query($suggestionsQuery) or die(mysql_error());
00584                         $suggestions = array($pattern);
00585                         while($suggestionsRow = mysql_fetch_row($suggestionsResult)) {
00586                                 $suggestions[] = $suggestionsRow[0];
00587                         }
00588                         return join($suggestions, ',');
00589                 }
00590                 else if($patternType == 'team'){
00591                         $suggestionsQuery = "SELECT `qaos_team_name` FROM `qaos_teams` WHERE `qaos_team_name` LIKE \"%$pattern%\"" ;
00592                         $suggestionsResult = mysql_query($suggestionsQuery) or die(mysql_error());
00593                         $suggestions = array($pattern);
00594                         while($suggestionsRow = mysql_fetch_row($suggestionsResult)) {
00595                                 $suggestions[] = $suggestionsRow[0];
00596                         }
00597                         return join($suggestions, ',');
00598 
00599                 }
00600         }
00601         function getTeamId($userId){
00602                 $query = "SELECT `qaos_teams`.`qaos_team_id` FROM `qaos_teams`,`qaos_units`,`qaos_users` WHERE `qaos_users`.`user_id`='$userId' AND `qaos_users`.`qaos_unit_id` = `qaos_units`.`qaos_unit_id` AND `qaos_units`.`qaos_team_id`=`qaos_teams`.`qaos_team_id`";
00603                 $result = mysql_query($query);
00604                 $row = mysql_fetch_assoc($result);
00605                 $teamId = $row['qaos_team_id'];
00606                 return $teamId;
00607         }
00608         function getDesignationId($userId){
00609                 $query = "SELECT `qaos_designations`.`qaos_designation_id` FROM `qaos_designations`,`qaos_units`,`qaos_users` WHERE `qaos_users`.`user_id`='$userId' AND `qaos_users`.`qaos_unit_id` = `qaos_units`.`qaos_unit_id` AND `qaos_units`.`qaos_designation_id`=`qaos_designations`.`qaos_designation_id`";
00610                 $result = mysql_query($query);
00611                 $row = mysql_fetch_assoc($result);
00612                 $designationId = $row['qaos_designation_id'];
00613                 return $designationId;
00614         }
00615         function getDesignationPriority($designationId){
00616                 $query = "SELECT `qaos_designation_priority` FROM `qaos_designations` WHERE `qaos_designation_id`=$designationId";
00617                 $result = mysql_query($query);
00618                 $row = mysql_fetch_assoc($result);
00619                 $designationPriority = $row['qaos_designation_priority'];
00620                 return $designationPriority;
00621         }
00622         function getUnitId($teamId,$designationId){
00623                 $query = "SELECT `qaos_unit_id` FROM `qaos_units` WHERE `qaos_team_id`=$teamId AND `qaos_designation_id`=$designationId";
00624                 $result = mysql_query($query);
00625                 $row = mysql_fetch_assoc($result);
00626                 $unitId = $row['qaos_unit_id'];
00627                 return $unitId;
00628         }
00629         function getUnitIdFromUserId($userId){
00630                 $query = "SELECT `qaos_unit_id` FROM `qaos_users` WHERE `user_id`=$userId";
00631                 $result = mysql_query($query);
00632                 $row = mysql_fetch_assoc($result);
00633                 $unitId = $row['qaos_unit_id'];
00634                 return $unitId;
00635                 
00636         }
00637         function getDesignationIdFromDesignationName($designation){
00638                 $query = "SELECT `qaos_designation_id` FROM `qaos_designations` WHERE `qaos_designation_name`='$designation'";
00639                 $result = mysql_query($query);
00640                 $row = mysql_fetch_row($result);
00641                 $designationId = $row[0];
00642                 return $designationId;
00643         }
00644         function getDesignationNameFromDesignationId($designationId){
00645                 $query = "SELECT `qaos_designation_name` FROM `qaos_designations` WHERE `qaos_designation_id`='$designationId'";
00646                 $result = mysql_query($query);
00647                 $row = mysql_fetch_row($result);
00648                 $designationName = $row[0];
00649                 return $designationName;
00650         }
00651         function getTeamIdFromTeamName($teamName){
00652                 $query = "SELECT `qaos_team_id` FROM `qaos_teams` WHERE `qaos_team_name`='$teamName'";
00653                 $result = mysql_query($query);
00654                 $row = mysql_fetch_row($result);
00655                 $teamId = $row[0];
00656                 return $teamId;
00657         }
00658         function getTeamNameFromTeamId($teamId){
00659                 $query = "SELECT `qaos_team_name` FROM `qaos_teams` WHERE `qaos_team_id`='$teamId'";
00660                 $result = mysql_query($query);
00661                 $row = mysql_fetch_row($result);
00662                 $teamName = $row[0];
00663                 return $teamName;
00664         }
00665         function addQaosTeamMember($userId,$qaosTeam1,$qaosTeam2,$qaosTeam3,$qaosTeam4){
00666                 
00667                 if($qaosTeam1){
00668                         $memberadd = false;
00669                         $query = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam1'";
00670                         $result = mysql_query($query);
00671                         $row = mysql_fetch_assoc($result);
00672                         $userRep11 = $row['user1'];
00673                         $userRep12 = $row['user2'];
00674                         if($userRep11 && $userRep12){
00675                                 displayerror("Sorry, this qaos member can not be added to the team. Already two members has been assigned to this team.");
00676                         }
00677                         else if(!$userRep11 && !$memberadd){
00678                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam1'";
00679                                 if($result = mysql_query($query)){
00680                                         displayinfo("User Successfully added in $qaosTeam1");
00681                                         $memberadd = true;
00682                                 }
00683                                 
00684                         }
00685                         else if(!$userRep12 && !$memberadd){
00686                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam1'";
00687                                 if($result = mysql_query($query)){
00688                                         displayinfo("User Successfully added in $qaosTeam1");
00689                                         $memberadd = true;
00690                                 }
00691                         }
00692                 }
00693                 if($qaosTeam2){
00694                         $memberadd = false;
00695                         $userRep1 = NULL;
00696                         $userRep2 = NULL;
00697                         $query2 = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam2'";
00698                         $result2 = mysql_query($query2);
00699                         $row2 = mysql_fetch_assoc($result2);
00700                         $userRep1 = $row2['user1'];
00701                         $userRep2 = $row2['user2'];
00702                         if($userRep1 && $userRep2){
00703                                 displayerror("Sorry, this qaos member can not be added to $qaosTeam2. Already two members has been assigned to this team.");
00704                         }
00705                         else if(!$userRep1 && !$memberadd){
00706                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam2'";
00707                                 if($result = mysql_query($query)){
00708                                         displayinfo("User Successfully added in $qaosTeam2");
00709                                         $memberadd = true;
00710                                 }
00711                                 
00712                         }
00713                         else if(!$userRep2 && !$memberadd){
00714                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam2'";
00715                                 if($result = mysql_query($query)){
00716                                         displayinfo("User Successfully added in $qaosTeam2");
00717                                         $memberadd = true;
00718                                 }
00719                         }
00720                 }
00721                 if($qaosTeam3){
00722                         $memberadd = false;
00723                         $userRep1 = NULL;
00724                         $userRep2 = NULL;
00725                         $query3 = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam3'";
00726                         $result3 = mysql_query($query3);
00727                         $row3 = mysql_fetch_assoc($result3);
00728                         $userRep1 = $row3['user1'];
00729                         $userRep2 = $row3['user2'];
00730                         if($userRep1 && $userRep2){
00731                                 displayerror("Sorry, this qaos member can not be added to $qaosTeam3. Already two members has been assigned to this team.");
00732                         }
00733                         else if(!$userRep1 && !$memberadd){
00734                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam3'";
00735                                 if($result = mysql_query($query)){
00736                                         displayinfo("User Successfully added in $qaosTeam3");
00737                                         $memberadd = true;
00738                                 }
00739                                 
00740                         }
00741                         else if(!$userRep2 && !$memberadd){
00742                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam3'";
00743                                 if($result = mysql_query($query)){
00744                                         displayinfo("User Successfully added in $qaosTeam3");
00745                                         $memberadd = true;
00746                                 }
00747                         }
00748                 }
00749                 if($qaosTeam4){
00750                         $memberadd = false;
00751                         $userRep1 = NULL;
00752                         $userRep2 = NULL;
00753                         $query4 = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam4'";
00754                         $result4 = mysql_query($query4);
00755                         $row4 = mysql_fetch_assoc($result4);
00756                         $userRep1 = $row4['user1'];
00757                         $userRep2 = $row4['user2'];
00758                         if($userRep1 && $userRep2){
00759                                 displayerror("Sorry, this qaos member can not be added to $qaosTeam4. Already two members has been assigned to this team.");
00760                         }
00761                         else if(!$userRep1 && !$memberadd){
00762                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam4'";
00763                                 if($result = mysql_query($query)){
00764                                         displayinfo("User Successfully added in $qaosTeam4");
00765                                         $memberadd = true;
00766                                 }
00767                                 
00768                         }
00769                         else if(!$userRep2 && !$memberadd){
00770                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam4'";
00771                                 if($result = mysql_query($query)){
00772                                         displayinfo("User Successfully added in $qaosTeam4");
00773                                         $memberadd = true;
00774                                 }
00775                         }
00776                 }
00777                 
00778                 return;
00779         }
00780         function addTeamMember($email,$designation,$team,$newparentTeam,$newparentDesignation){
00781 
00782                 $userId = getUserIdFromEmail($email);
00783                 $parentUserId = $this->userId;
00784 
00788                 $parentTeamId = $this->getTeamId($parentUserId);
00789                 $parentDesignationId = $this->getDesignationId($parentUserId);
00790                 $parentUnitId = $this->getUnitId($parentTeamId,$parentDesignationId);
00791                 $parentDesignationPriority = $this->getDesignationPriority($parentDesignationId);
00792 
00793 //              get the team id of the user.
00794 
00795                 $teamId = $this->getTeamIdFromTeamName($team);
00796 
00807                 if($teamId != $parentTeamId && $parentDesignationPriority <= 3){
00808                         displayerror("You cannot add members into some other team.");
00809                         return $name;
00810                 }
00811 // get the designation id of the user being added from the designation name.
00812                 $designationId = $this->getDesignationIdFromDesignationName($designation);
00813 // now check if the parent has higher priority or not.If parent has lower priority, give an error and leave.
00814                 $designationPriority = $this->getDesignationPriority($designationId);
00815                 if($designationPriority > $parentDesignationPriority){
00816                         displayerror("You can not add members higher than your level");
00817                         return $name;
00818                 }
00819                 if(($newparentDesignation)&&($newparentTeam)){
00820                         $parentTeamId = $this->getTeamIdFromTeamName($newparentTeam);
00821                         $parentDesignationId = $this->getDesignationIdFromDesignationName($newparentDesignation);
00822                         $parentUnitId = $this->getUnitId($parentTeamId,$parentDesignationId);
00823                 }
00824 // now check if the user exists or not
00825                 $query = "SELECT `user_id`,`qaos_unit_id` FROM `qaos_users` WHERE `user_id`=$userId";
00826                 $result = mysql_query($query);
00827                 if($row = mysql_fetch_assoc($result)){
00828                         $unitId = $row['qaos_unit_id'];
00829                         $queryTeam = "SELECT `qaos_teams`.`qaos_team_name` FROM `qaos_teams`, `qaos_units` WHERE `qaos_teams`.`qaos_team_id`=`qaos_units`.`qaos_team_id` AND `qaos_units`.`qaos_unit_id`=$unitId";
00830                         $resultTeam = mysql_query($queryTeam);
00831                         $row = mysql_fetch_assoc($resultTeam);
00832                         var_dump($row);
00833                         $teamName = $row['qaos_team_name'];
00834                         displayerror("Sorry, the user can not be added. The person already exists in the ".$teamName." team.");
00835                 }
00836                 else {
00837 // Check whether the unit already exists in the database or not. If not add a new unit, and then add the user otherwise directly add the user
00838                         $queryUnits = "SELECT `qaos_unit_id` FROM `qaos_units` WHERE `qaos_team_id`=$teamId AND `qaos_designation_id`=$designationId";
00839                         $resultUnits = mysql_query($queryUnits);
00840 //if the unit exist, just add the user to the qaos_user table.
00841                         if($rowUnits = mysql_fetch_assoc($resultUnits)){
00842                                 $unitId = $rowUnits['qaos_unit_id'];
00843                                 $queryUsers = "INSERT INTO `qaos_users` (`page_modulecomponentid`,`user_id`,`qaos_unit_id`) VALUES ($this->moduleComponentId,$userId,$unitId)";
00844                                 $resultUsers = mysql_query($queryUsers);
00845                                 if($resultUsers)
00846                                         displayinfo("The User was successfully added to the team");
00847                                 else
00848                                         displayerror("There was some error in adding the user to the table");
00849                         }
00850 //if the unit does not exist, add a new unit, add the unit in the tree and add the new user.
00851                         else{
00852                                 $queryMaxUnitid = "SELECT MAX(`qaos_unit_id`) AS MAX FROM `qaos_units`";
00853                                 $resultMaxUnitid = mysql_query($queryMaxUnitid);
00854                                 $rowMaxUnitid = mysql_fetch_assoc($resultMaxUnitid);
00855                                 $unitId = 1 + $rowMaxUnitid['MAX'];
00856                                 $queryInsertUnit = "INSERT INTO `qaos_units` (`page_modulecomponentid`,`qaos_unit_id`,`qaos_team_id`,`qaos_designation_id`) VALUES ($this->moduleComponentId,$unitId,$teamId,$designationId)";
00857                                 $resultInsertUnit = mysql_query($queryInsertUnit);
00858                                 //echo $parentUnitId."two";
00859                                 $queryInsertTree = "INSERT INTO `qaos_tree` (`page_modulecomponentid`,`qaos_unit_id`,`qaos_parentunit_id`) VALUES ($this->moduleComponentId,$unitId,$parentUnitId)";
00860                                 $resultInsertTree = mysql_query($queryInsertTree);
00861 
00862                                 $queryInsertUser = "INSERT INTO `qaos_users` (`page_modulecomponentid`,`user_id`,`qaos_unit_id`) VALUES ($this->moduleComponentId,$userId,$unitId)";
00863                                 $resultInsertUser = mysql_query($queryInsertUser);
00864                                 displayinfo("The User was successfully added to the team.");
00865                         }
00866                 }
00867                 return $name;
00868         }
00869         function generateTree($moduleComponentId,$score) {
00870                 global $sourceFolder,$cmsFolder;
00871                 global $urlRequestRoot;
00872                 global $templateFolder;
00873                 $imagesFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/images";
00874                 $scriptsFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/scripts";
00875                 $queryVersion = "SELECT `qaos_version` FROM `qaos_version` WHERE `page_modulecomponentid` = $moduleComponentId";
00876                 $resultVersion = mysql_query($queryVersion);
00877                 $row = mysql_fetch_row($resultVersion);
00878                 $version = $row[0];
00879                 $treeData .= "<h2>$version</h2> <br />";
00880                 $treeData .= '<div id="directorybrowser"><ul class="treeview" id="qaos">' .
00881                                 '<script type="text/javascript" language="javascript" src="'.$scriptsFolder.'/ddtree.js"></script>';
00882 // for all those unit id's which have no parent.. like core team!
00883                 $unitId = 0;
00884                 $treeData .= $this->getNodeHtml($unitId,$score);
00885                 $treeData .= '</ul></div>';
00886                 $treeData .= <<<TREEDATA
00887                         <style type="text/css">
00888                         #qaos li{background-color:#F7F4FF;border:#88AAEA solid 1px;margin:10px;}
00889                         </style>
00890                         <script type="text/javascript" language="javascript">
00891                         <!--
00892                                 siteMapLinks = document.getElementById('qaos').getElementsByTagName('a');
00893                                 for(i = 0; i < siteMapLinks.length; i++) {
00894                                         siteMapLinks[i].onclick = treeLinkClicked;
00895                                 }
00896 
00897                                 setupMenuDependencies("$imagesFolder", '');
00898                                 ddtreemenu.createTree("qaos", true, 5);
00899                         -->
00900                         </script>
00901 
00902 TREEDATA;
00903 
00904                 return $treeData;
00905         }
00906         function getNodeHtml($unitId,$score) {
00907                 $htmlOut = '';
00908                 $query = "SELECT `user_id`,us.`qaos_unit_id`,d.`qaos_designation_name`,tm.`qaos_team_name` FROM `qaos_users` us,`qaos_designations` d,`qaos_units` un,`qaos_tree` t,`qaos_teams` tm WHERE t.`qaos_parentunit_id`=$unitId AND us.`qaos_unit_id` = t.`qaos_unit_id` AND un.`qaos_unit_id`=us.`qaos_unit_id` AND d.`qaos_designation_id` = un.`qaos_designation_id` AND tm.`qaos_team_id`=un.`qaos_team_id` ORDER BY d.`qaos_designation_name`,tm.`qaos_team_name`";
00909                 $queryResult = mysql_query($query);
00910                 $arrayUsers = array();
00911                 $arrayUnits = array();
00912                 $arr = array();
00913                 $designation = array();
00914                 $team = array();
00915                 while($queryArray = mysql_fetch_assoc($queryResult))
00916                 {
00917                         //$arrayUsers[] = $queryArray['user_id'];
00918                         //$arrayUnits[] = $queryArray['qaos_unit_id'];
00919                         $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
00920                         $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
00921                         $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
00922                 }
00923                 foreach($arr as $unitId=>$userId)
00924                 {
00925                         $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
00926                         $userFullNameArray= array();
00927                         foreach($userId as $i)
00928                         {
00929                                 if($score){
00930                                 $userEmail = getUserEmail($i);
00931                                 $userFullName = getUserFullName($i);
00932                                 $userFullNameArray[] .=<<<USERNAME
00933                                         <a href="./+qaosadmin&subaction=viewscore&useremail=$userEmail">$userFullName</a> 
00934 USERNAME;
00935                                 }
00936                                 else 
00937                                         $userFullNameArray[] .= getUserFullName($i);
00938                         }
00939                         $htmlOut .= join($userFullNameArray,", ");
00940                         $childHtml = $this->getNodeHtml($unitId,$score);
00941                         if($childHtml != "") {
00942                                 $htmlOut .= "<ul>" . $childHtml . '</ul>';
00943                         }
00944                         $htmlOut .= "</li>";
00945                 }
00946 
00947 
00948                 return $htmlOut;
00949 /*
00950                 if(getPermissions($userId, $pageId, $action, $module)) {
00951                         $pageInfo = getPageInfo($pageId);
00952                         $pagePath = $parentPath;
00953                         if($pageInfo['page_name'] != '')
00954                                 $pagePath .= $pageInfo['page_name'] . '/';
00955 
00956                         $htmlOut .= "<li><a href=\"$pagePath\">" . getPageTitle($pageId) . '</a>';
00957 
00958                         $childrenQuery = 'SELECT `page_id` FROM `' . MYSQL_DATABASE_PREFIX  . 'pages` WHERE `page_parentid` <> `page_id` AND `page_parentid` = ' . $pageId;
00959                         $childrenResult = mysql_query($childrenQuery);
00960                         if(mysql_num_rows($childrenResult) > 0) {
00961                                 $htmlOut .= '<ul>';
00962                         }
00963                         while($childrenRow = mysql_fetch_row($childrenResult)) {
00964                                 $htmlOut .= $this->getNodeHtml($childrenRow[0], $userId, $module, $action, $pagePath);
00965                         }
00966                         if(mysql_num_rows($childrenResult) > 0)
00967                                 $htmlOut .= '</ul>';
00968                         $htmlOut .= '</li>';
00969                 }
00970                 return $htmlOut;
00971         */
00972         }
00973         
00974         /*createModule just creates an empty qaos module*/
00975         public function createModule($newId){
00976                 $query = "INSERT INTO `qaos_version` (`page_modulecomponentid`) VALUES ('$newId')";
00977                 $result = mysql_query($query) or die(mysql_error()."qaos.lib L:76");
00978         }
00979         
00980         public function actionScore($moduleComponentId){
00981                 $moduleComponentId = $this->moduleComponentId;
00982                 $userId = $this->userId;
00983                 $userEmail = getUserEmail($userId);
00984                 $designationId = $this->getDesignationId($userId);
00985                 $designationName = $this->getDesignationNameFromDesignationId($designationId);
00986                 $teamId = $this->getTeamId($userId);
00987                 $htmlOut = '';
00988                 if(isset($_GET['subaction'])){
00989                         if($_GET['subaction']=='scoringUserDone'){
00990                                 if(isset($_POST['btnSubmitScore'])){
00991                                         $targetUserEmail =$_GET['targetUserEmail'];
00992                                         $userEmail = $_GET['userEmail'];
00993                                         $targetUserId = getUserIdFromEmail($targetUserEmail);
00994                                         $userId = getUserIdFromEmail($userEmail);
00995                                         $query = "INSERT INTO `qaos_scoring`(`page_modulecomponentid`,`user_id`,`targetuser_id`,`qaos_score1`,`qaos_score2`,`qaos_score3`,`qaos_score4`,`qaos_score5`,`qaos_reason1`,`qaos_reason2`,`qaos_reason3`,`qaos_reason4`,`qaos_reason5`) VALUES($moduleComponentId,$userId,$targetUserId,{$_POST['qaos_score1']},{$_POST['qaos_score2']},{$_POST['qaos_score3']},{$_POST['qaos_score4']},{$_POST['qaos_score5']},'{$_POST['qaos_reason1']}','{$_POST['qaos_reason2']}','{$_POST['qaos_reason3']}','{$_POST['qaos_reason4']}','{$_POST['qaos_reason5']}')";
00996                                         if(mysql_query($query))
00997                                                 displayinfo("Your scores have been stored.");
00998                                         else
00999                                                 displayerror("There was some error in storing your scores");
01000                                 }
01001                                         
01002                         }
01003                         if($_GET['subaction']=='scoreUser'){                            
01004                                 if(isset($_GET['userEmail'])){
01005                                         $targetUserEmail = $_GET['userEmail'];
01006                                         $targetUserId = getUserIdFromEmail($_GET['userEmail']);
01007                                         $targetUserFullName = getUserFullName($targetUserId);
01008                                         if($targetUserId == $userId){
01009                                                 displayerror("You can not score yourself");
01010                                                 return $htmlOut;
01011                                         }
01012                                         
01013                                         $query ="SELECT * FROM `qaos_scoring` WHERE user_id=$userId AND targetuser_id=$targetUserId";
01014                                         $result = mysql_query($query);
01015                                         if(mysql_affected_rows()>0){
01016                                                 displayerror("You have already scored this person.");
01017                                                 return $htmlOut;
01018                                         }
01019                                         
01020                                         $htmlOut = "";
01021                                         
01022                                         $htmlOut .= <<<SCOREUSER
01023                                         <div class="scoreuser">
01024                                                 <form id="scoreuser" method="POST" onsubmit="return checkProfileForm(this)" action="./+score&userEmail=$userEmail&targetUserEmail=$targetUserEmail&subaction=scoringUserDone">
01025                                                         <fieldset style="width:80%">
01026                                                                 <legend><b>Score, $targetUserFullName</b></legend>
01027                                                                 <table>
01028                                                                         <tr>
01029                                                                                 <td>
01030                                                                                         <b>Question No. 1:</b><br />
01031                                                                                         Is the person regular and punctual in his/her work/meetings?<br />
01032                                                                                 </td>
01033                                                                                 
01034                                                                         </tr>
01035                                                                         <tr>
01036                                                                                 <td>
01037                                                                                         <br />
01038                                                                                 </td>
01039                                                                         </tr>
01040                                                                         <tr>
01041                                                                                 <td> Your Score:
01042                                                                                 </td>   
01043                                                                                 <td>
01044                                                                                         <select name="qaos_score1" id="qaos_score1">
01045                                                                                                 <option value="1">1</option>
01046                                                                                                 <option value="2">2</option>
01047                                                                                                 <option value="3">3</option>
01048                                                                                                 <option value="4">4</option>
01049                                                                                                 <option value="5">5</option>
01050                                                                                                 <option value="6">6</option>
01051                                                                                                 <option value="7">7</option>
01052                                                                                                 <option value="8">8</option>
01053                                                                                                 <option value="9">9</option>
01054                                                                                                 <option value="10">10</option>
01055                                                                                         </select>
01056                                                                                 </td>
01057                                                                         </tr>
01058                                                                         <tr>
01059                                                                                 <td> Your Reason/Comments:
01060                                                                                 </td>
01061                                                                                 <td>
01062                                                                                         <textarea rows="3" columns="20" name="qaos_reason1" id="qaos_reason1" title="Enter your comments/reason here"></textarea>
01063                                                                                 </td>   
01064                                                                         </tr>
01065                                                                         <tr>
01066                                                                                 <td>
01067                                                                                         <b>Question No. 2:</b><br />
01068                                                                                         Is this person a team worker and co ordinates with others well?<br />
01069                                                                                 </td>
01070                                                                                 
01071                                                                         </tr>
01072                                                                         <tr>
01073                                                                                 <td>
01074                                                                                         <br />
01075                                                                                 </td>
01076                                                                         </tr>
01077                                                                         <tr>
01078                                                                                 <td> Your Score:
01079                                                                                 </td>   
01080                                                                                 <td>
01081                                                                                         <select name="qaos_score2" id="qaos_score2">
01082                                                                                                 <option value="1">1</option>
01083                                                                                                 <option value="2">2</option>
01084                                                                                                 <option value="3">3</option>
01085                                                                                                 <option value="4">4</option>
01086                                                                                                 <option value="5">5</option>
01087                                                                                                 <option value="6">6</option>
01088                                                                                                 <option value="7">7</option>
01089                                                                                                 <option value="8">8</option>
01090                                                                                                 <option value="9">9</option>
01091                                                                                                 <option value="10">10</option>
01092                                                                                         </select>
01093                                                                                 </td>
01094                                                                         </tr>
01095                                                                         <tr>
01096                                                                                 <td> Your Reason/Comments:
01097                                                                                 </td>
01098                                                                                 <td>
01099                                                                                         <textarea rows="3" columns="20" name="qaos_reason2" id="qaos_reason2" title="Enter your comments/reason here"></textarea>
01100                                                                                 </td>   
01101                                                                         </tr>
01102                                                                         <tr>
01103                                                                                 <td>
01104                                                                                         <b>Question No. 3:</b><br />
01105                                                                                         How is his/her promptness in completing work?<br />
01106                                                                                 </td>
01107                                                                                 
01108                                                                         </tr>
01109                                                                         <tr>
01110                                                                                 <td>
01111                                                                                         <br />
01112                                                                                 </td>
01113                                                                         </tr>
01114                                                                         <tr>
01115                                                                                 <td> Your Score:
01116                                                                                 </td>   
01117                                                                                 <td>
01118                                                                                         <select name="qaos_score3" id="qaos_score3">
01119                                                                                                 <option value="1">1</option>
01120                                                                                                 <option value="2">2</option>
01121                                                                                                 <option value="3">3</option>
01122                                                                                                 <option value="4">4</option>
01123                                                                                                 <option value="5">5</option>
01124                                                                                                 <option value="6">6</option>
01125                                                                                                 <option value="7">7</option>
01126                                                                                                 <option value="8">8</option>
01127                                                                                                 <option value="9">9</option>
01128                                                                                                 <option value="10">10</option>
01129                                                                                         </select>
01130                                                                                 </td>
01131                                                                         </tr>
01132                                                                         <tr>
01133                                                                                 <td> Your Reason/Comments:
01134                                                                                 </td>
01135                                                                                 <td>
01136                                                                                         <textarea rows="3" columns="20" name="qaos_reason3" id="qaos_reason3" title="Enter your comments/reason here"></textarea>
01137                                                                                 </td>   
01138                                                                         </tr>
01139                                                                         <tr>
01140                                                                                 <td>
01141                                                                                         <b>Question No. 4:</b><br />
01142                                                                                         How is his/her interest/enthusiasm/initiative in his/her work?<br />
01143                                                                                 </td>
01144                                                                                 
01145                                                                         </tr>
01146                                                                         <tr>
01147                                                                                 <td>
01148                                                                                         <br />
01149                                                                                 </td>
01150                                                                         </tr>
01151                                                                         <tr>
01152                                                                                 <td> Your Score:
01153                                                                                 </td>   
01154                                                                                 <td>
01155                                                                                         <select name="qaos_score4" id="qaos_score4">
01156                                                                                                 <option value="1">1</option>
01157                                                                                                 <option value="2">2</option>
01158                                                                                                 <option value="3">3</option>
01159                                                                                                 <option value="4">4</option>
01160                                                                                                 <option value="5">5</option>
01161                                                                                                 <option value="6">6</option>
01162                                                                                                 <option value="7">7</option>
01163                                                                                                 <option value="8">8</option>
01164                                                                                                 <option value="9">9</option>
01165                                                                                                 <option value="10">10</option>
01166                                                                                         </select>
01167                                                                                 </td>
01168                                                                         </tr>
01169                                                                         <tr>
01170                                                                                 <td> Your Reason/Comments:
01171                                                                                 </td>
01172                                                                                 <td>
01173                                                                                         <textarea rows="3" columns="20" name="qaos_reason4" id="qaos_reason4" title="Enter your comments/reason here"></textarea>
01174                                                                                 </td>   
01175                                                                         </tr>
01176                                                                         <tr>
01177                                                                                 <td>
01178                                                                                         <b>Question No. 5:</b><br />
01179                                                                                         How is his/her potential managerial abilities?<br />
01180                                                                                 </td>
01181                                                                                 
01182                                                                         </tr>
01183                                                                         <tr>
01184                                                                                 <td>
01185                                                                                         <br />
01186                                                                                 </td>
01187                                                                         </tr>
01188                                                                         <tr>
01189                                                                                 <td> Your Score:
01190                                                                                 </td>   
01191                                                                                 <td>
01192                                                                                         <select name="qaos_score5" id="qaos_score5">
01193                                                                                                 <option value="1">1</option>
01194                                                                                                 <option value="2">2</option>
01195                                                                                                 <option value="3">3</option>
01196                                                                                                 <option value="4">4</option>
01197                                                                                                 <option value="5">5</option>
01198                                                                                                 <option value="6">6</option>
01199                                                                                                 <option value="7">7</option>
01200                                                                                                 <option value="8">8</option>
01201                                                                                                 <option value="9">9</option>
01202                                                                                                 <option value="10">10</option>
01203                                                                                         </select>
01204                                                                                 </td>
01205                                                                         </tr>
01206                                                                         <tr>
01207                                                                                 <td> Your Reason/Comments:
01208                                                                                 </td>
01209                                                                                 <td>
01210                                                                                         <textarea rows="3" columns="20" name="qaos_reason5" id="qaos_reason5" title="Enter your comments/reason here"></textarea>
01211                                                                                 </td>   
01212                                                                         </tr>
01213                                                                         <tr>
01214                                                                                 <td>
01215                                                                                         <input type="submit" name="btnSubmitScore" id="submitbutton" value="Save Scores">
01216                                                                                 </td>
01217                                                                         </tr>
01218                                                                         
01219                                                                 </table>
01220                                                         </fieldset>
01221                                                 </form>
01222                                         </div>
01223 SCOREUSER;
01224                                         return $htmlOut;
01225                                         }
01226                                 }
01227                         }
01228                 
01229                 $query = "SELECT `user_id`,un.`qaos_unit_id`,d.`qaos_designation_name`,t.`qaos_team_name` FROM `qaos_users` u,`qaos_designations` d,`qaos_teams` t,`qaos_units` un WHERE un.`qaos_unit_id` = u.`qaos_unit_id` AND un.`qaos_team_id`=$teamId AND d.`qaos_designation_id` = un.`qaos_designation_id` AND t.`qaos_team_id`=un.`qaos_team_id`" ;
01230                 $queryResult = mysql_query($query);
01231                 $arrayUsers = array();
01232                 $arrayUnits = array();
01233                 $arr = array();
01234                 $designation = array();
01235                 $team = array();
01236                 while($queryArray = mysql_fetch_assoc($queryResult))
01237                 {
01238                         $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
01239                         $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
01240                         $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
01241                 }
01242                 foreach($arr as $unitId=>$userId)
01243                 {
01244                         $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
01245                         $userFullNameArray= array();
01246                         foreach($userId as $i)
01247                         {
01248                                 $htmlOut .= "<a href=\"./+score&subaction=scoreUser&userEmail=".getUserEmail($i)."\">";
01249                                 $htmlOut .= getUserFullName($i);
01250                                 $htmlOut .= "</a>";
01251                                 $htmlOut .= "<br />";
01252                                 //$userFullNameArray[] .= getUserFullName($i);
01253                         }
01254                         //$htmlOut .= join($userFullNameArray,", ");
01255                         $htmlOut .= "</li>";
01256                 }
01257                 $htmlOut .= "<br /><br />";
01258                 $teamName = $this->getTeamNameFromTeamId($teamId);
01259                 if($teamName=="Core"){
01260                         $unitId = $this->getUnitIdFromUserId($this->userId);
01261                         $query = "SELECT us.user_id,tr.qaos_unit_id,d.qaos_designation_name, tm.qaos_team_name FROM `qaos_tree` tr JOIN qaos_units un ON (tr.qaos_unit_id = un.qaos_unit_id) JOIN qaos_teams tm ON (un.qaos_team_id = tm.qaos_team_id) JOIN qaos_designations d ON (un.qaos_designation_id = d.qaos_designation_id) JOIN qaos_users us ON (un.qaos_unit_id = us.qaos_unit_id) WHERE tr.qaos_parentunit_id=$unitId";
01262                         $queryResult = mysql_query($query);
01263                         $arrayUsers = array();
01264                         $arrayUnits = array();
01265                         $arr = array();
01266                         $designation = array();
01267                         $team = array();
01268                         while($queryArray = mysql_fetch_assoc($queryResult))
01269                         {
01270                                 $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
01271                                 $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
01272                                 $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
01273                         }
01274                         foreach($arr as $unitId=>$userId)
01275                         {
01276                                 $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
01277                                 $userFullNameArray= array();
01278                                 foreach($userId as $i)
01279                                 {
01280                                         $htmlOut .= "<a href=\"./+score&subaction=scoreUser&userEmail=".getUserEmail($i)."\">";
01281                                         $htmlOut .= getUserFullName($i);
01282                                         $htmlOut .= "</a>";
01283                                         $htmlOut .= "<br />";
01284                                         //$userFullNameArray[] .= getUserFullName($i);
01285                                 }
01286                                 //$htmlOut .= join($userFullNameArray,", ");
01287                                 $htmlOut .= "</li>";
01288                         }
01289                 }
01290                 if($teamName=="Qaos"){
01291                         $unitId = $this->getUnitIdFromUserId($this->userId);
01292                         $query = "SELECT us.`user_id`,u.`qaos_unit_id`,d.`qaos_designation_name`,t.`qaos_team_name` FROM `qaos_units` u,`qaos_designations` d,`qaos_users` us,`qaos_teams` t WHERE u.`qaos_unit_id`= us.`qaos_unit_id` AND u.`qaos_designation_id`= d.`qaos_designation_id` AND u.`qaos_team_id` = t.`qaos_team_id` AND u.`qaos_team_id` IN (SELECT t.`qaos_team_id` FROM `qaos_teams` t WHERE t.`qaos_representative_user_id1` = $this->userId OR t.`qaos_representative_user_id2` = $this->userId)";
01293                         $result = mysql_query($query);
01294                         $arrayUsers = array();
01295                         $arrayUnits = array();
01296                         $arr = array();
01297                         $designation = array();
01298                         $team = array();
01299                         while($queryArray = mysql_fetch_assoc($result))
01300                         {
01301                                 $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
01302                                 $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
01303                                 
01304                                 $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
01305                         }
01306                         foreach($arr as $unitId=>$userId)
01307                         {
01308                                 $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
01309                                 $userFullNameArray= array();
01310                                 foreach($userId as $i)
01311                                 {
01312                                         $htmlOut .= "<a href=\"./+score&subaction=scoreUser&userEmail=".getUserEmail($i)."\">";
01313                                         $htmlOut .= getUserFullName($i);
01314                                         $htmlOut .= "</a>";
01315                                         $htmlOut .= "<br />";
01316                                         //$userFullNameArray[] .= getUserFullName($i);
01317                                 }
01318                                 //$htmlOut .= join($userFullNameArray,", ");
01319                                 $htmlOut .= "</li>";
01320                         }       
01321                         
01322                 }
01323                                 
01324                 return $htmlOut;
01325         }
01326         public function deleteModule($moduleComponentId){
01327                 return true;
01328         }
01329         public function copyModule($moduleComponentId,$newId){
01330                 return true;
01331         }
01332 }

Generated on Mon Mar 14 2011 05:35:30 for Pragyan CMS by  doxygen 1.7.1