File indexing completed on 2024-12-29 05:24:45

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 
0023 $cssNoVotes = (($this->product->count_likes+$this->product->count_dislikes) == 0) ? ';opacity:0.5;' : '';
0024 
0025 $model = new Default_Model_DbTable_ProjectRating();
0026 $score2 = $model->getScore($this->product->project_id);   
0027 //$score2 = round($score2/10,1);
0028 $score2 = $score2/10;
0029 
0030 $userScore=0;
0031 if($this->ratingOfUser)
0032 {
0033     $userScore = $this->ratingOfUser['score'];
0034 }
0035 
0036 $userrate ="data-userrate='-1'";
0037 $comment="data-comment=''";
0038 if($this->ratingOfUser){
0039     $userrate ="data-userrate='".$this->ratingOfUser['score']."'";        
0040     $comment="data-comment='".$this->ratingOfUser['comment_text']."'";        
0041 }       
0042 $formproject="data-project='".$this->product->project_id."'";
0043 $creator="data-creator='".$this->product->member_id."'";
0044 $attrhistory = $userrate.' '.$comment.' '.$formproject.' '.$creator;
0045 
0046 
0047 $options = array(1 => 'ugh', 2=>'really bad',3=>'bad',4=>'soso',5=>'average', 6=>'okay',7=>'good', 8=>'great', 9=>'excellent',10=>'the best');
0048 krsort($options);
0049 ?>
0050 <div id="widget-rating" class="prod-widget-box right" style="border:0px !important">    
0051     <table cellpadding="0" cellspacing="0" width="100%">
0052         <tbody>
0053         <tr>
0054             
0055             <td style="padding-left:0.2em;padding-right: 0.2em; width: 80%">
0056                 <div class="rating">
0057                     <div class="rating-text">
0058                         <small class="center-block text-center">
0059                         Score <?=number_format($score2,1)?>%                             
0060                         </small>
0061                     </div>
0062                     <div class="progress" style="margin-bottom: 0;height:12px;background-color: transparent; box-shadow: none; padding:2px;">
0063                         <div class="progress-bar" style="background-color: <?=$this->fetchScoreColor($score2/10)?>;width: <?= floor($score2)?>%;">
0064                             
0065                         </div>
0066                         <div class="progress-bar" style="background-color:#eeeeee;width: <?= floor(100 - $score2) ?>%;<?=$cssNoVotes?>">
0067                           
0068                         </div>
0069                     </div>
0070                 </div>
0071             </td>
0072            
0073         </tr>
0074         </tbody>
0075     </table>
0076 
0077     <div style="text-align: center;">               
0078          <select <?=$attrhistory ?> name="ratingoptions" id="ratingoptions" class="rating-select">
0079             <?php
0080              if($userScore){
0081                 echo '<option value="-1" >Remove Rating</option>';
0082              }else{
0083                 echo '<option value="0">Add Rating</option>';
0084              }
0085              foreach ($options as $key => $value) {
0086                 $selected = '';                
0087                 if($userScore==$key){
0088                   $selected='selected="selected"';                  
0089                 } 
0090                 echo '<option value="'.$key.'" '.$selected.'>'.$key.' '.$value.'</option>';                
0091             } ?>         
0092         </select> 
0093     </div>
0094 </div>
0095 
0096 
0097