<?php
require '../../conn/codeblocs.php';

// EXIT;
$get = $_GET;
$sid = $get['sid'] ?? '';
$vid = $get['vid'] ?? '';
$whsid = $sid ? "survey_id = :sid AND vendee_id = :vid" : 1;

$survey_batches = doPDOQ("SELECT b.response_batch_id, b.survey_id, b.vendee_id, b.response_token, v.short_vendee, v.vendee_name, b.created_at FROM survey_response_batch b LEFT JOIN survey_vendee v USING(vendee_id) WHERE {$whsid}", ['sid'=>$sid, 'vid'=>$vid]);
// preprint($survey_batches);
?>
        			
        <div class="container-table100">

            <div class="wrap-table100">
                <div class="table100">
                    <table>
                        <thead>
                            <tr class="table100-head">
                                <th class="first-column">Date</th>
                                <th class="">Survey ID</th>
                                <th class="">Batch ID</th>
                                <th class="">Vendee</th>
                                <th class="last-column">R/Token</th>
                                
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach($survey_batches as $survey_batch):?>
                            <tr>
                                <td class=""><?=$survey_batch['created_at']?></td>
                                <td class=""><?=$survey_batch['survey_id']?></td>
                                <td class=""><a href="pages/response-details.inc.php?rbid=<?=$survey_batch['response_batch_id']?>" class="d-anchor"><?=$survey_batch['response_batch_id']?></a></td>
                                <td class=""><?=$survey_batch['short_vendee']?></td>
                                <td class=""><?=$survey_batch['response_token']?></td>
                                
                            </tr>
                            <?php endforeach?>

                        
                        </tbody>
                    </table>
                </div>
            </div>
        </div>