{!! Theme::section('community.pannel.cms.pages-menu',['subpage'=>'cmsurveys']) !!}

<br />
  <a class="btn-sm btn black-color-button pull-right"  href="{{$community->present()->url('addsurvey')}}">{{trans('formsurveys.create-a-form-survey')}}</a>
<br />
<br />

  <div class="">
         <table class="table table-bordered">
            <thead>
                <tr>
                    <th style="width: 20%">Form/Survey Title</th>
                    <th style="width: 30%">{{trans('formsurveys.survey-link')}}</th>
                    
                    @if($community->isOwner())
                    	<th style="width: 20%">Created By</th>
                    @endif
                    
                    <th style="width: 30%">{{trans('formsurveys.survey-action')}}</th>
                </tr>
            </thead>
            <tbody>
            	
                @foreach($surveys as $survey)
                    <tr>
                        <td>{{$survey->title}} @if($survey->original_survey_id!=0) <br /> <span style="color:#F00">({{trans('formsurveys.copied-survey')}})</span> @endif</td>
                        <td>
                        		{{$community->present()->url('survey/'.$survey->slug)}}
                                
                                @if($community->present()->canManage())
                                    <div class="form-group-assign">
                                        @if($categories)
                                            <span class="topic-assign-heading">
                                                {{trans('formsurveys.topic-group-assign')}}
                                            </span>
                                            <select name="set-group" data-id="{{$survey->id}}" data-url="{{$community->present()->url('assignsurveygroup')}}" class="assign-survey-to-group assign-survey-to-group-{{$survey->id}}">
                                                <option value="0">{{trans('formsurveys.do-not-share')}}</option>
                                                @foreach($categories as $category)
                                                    <option value="{{$category->id}}" @if($survey->group_id==$category->id || $survey->admin_group_id==$category->id) selected="selected" @endif>{{$category->title}}</option>
                                                @endforeach
                                            </select> 
                                            
                                            <p>
                                            	{{trans('formsurveys.only-group-admin')}} <input type="checkbox" data-id="{{$survey->id}}" class="assignsurveygroupadmin" data-url="{{$community->present()->url('assignsurveygroupadmin')}}" @if($survey->only_group_admin==1) checked @endif />  
                                            </p>    
                                                 
                                        @endif    
                                    </div>    
                                  @endif
                        </td>
                        
                        @if($community->isOwner())
                        
                        	<?php
								$user=$survey->user;
							?>
                    		<td>
                            	@if($user)
                                	<a href="{{$user->present()->url()}}">{{$user->fullname}}</a>
                                @endif
                            </td>
                    	@endif
                        
                        <td>
                            <a class="edit-survey-btn" href="{{$community->present()->url('editsurvey')}}/{{$survey->id}}" title="{{trans('formsurveys.edit-survey')}}"><i class="fa fa-edit"></i></a> 
                            
                            <a class="btn btn-sm btn-success" href="{{$community->present()->url('managesurvey')}}/{{$survey->id}}">{{trans('formsurveys.manage-questions')}}</a>
                        
                        	<!--<a class="btn btn-sm btn-primary" href="{{$community->present()->url('exportsurveydata')}}/{{$survey->id}}" title="Export as Excel">Export</a>-->
                            
                        	<a class="btn btn-sm btn-primary" href="{{$community->present()->url('surveydatareport')}}/{{$survey->id}}">{{trans('formsurveys.survey-responses')}}</a>
                        
                        	<br />
                        	<a class="btn btn-sm black-color-button" href="{{$community->present()->url('copysurvey')}}/{{$survey->id}}" title="{{trans('formsurveys.copy-survey')}}" style="margin-top:5px">{{trans('formsurveys.copy-survey')}}</a>
                            
                            <a class="btn btn-sm black-color-button" href="{{$community->present()->url('surveyreportsdata')}}/{{$survey->id}}" style="margin-top:5px">{{trans('formsurveys.review-data')}}</a>
                            
                            <a class="btn btn-sm red-color-button delete-action-confirm-custom" data-url="{{$community->present()->url('surveydelete')}}/{{$survey->id}}" data-msg="Are you sure you want to delete this survey?" style="margin-top:5px">{{trans('formsurveys.delete')}}</a>
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
       
        {!! $surveys->appends(request()->except('page'))->render() !!}
   </div>
<br />

