|
- <?php
- //Sākuma fails CV datubāzei!
- require 'include/head.php';
- require 'include/db.php';
- require 'include/check_session.php';
- echo '
- <div class="w3-container w3-padding-16">
- <h2>Atlasītajiem kritērijiem piemērotas personas</h2>';
- //Pārbaudīsim, vai ir periods
- $nop=$_POST['period1'];
- $lidzp=$_POST['period2'];
- if($nop=='')
- {
- $nop='';
- }
- else
- {
- echo '<h1>NO:'.$nop.'</h1>';
- $nop=strtotime($nop);
- }
- if($lidzp=='')
- {
- $lidzp=time();
- }
- else
- {
- echo '<h1>LIDZ:'.$lidzp.'</h1>';
- $lidzp=strtotime($lidzp);
- }
-
- //Šeit dalām rezultātu veidus
- if(isset($_POST['meklet']))
- {
- $tagsk=$_POST['mekl_sk'];
- $vajadzigie =0;
- $mekl = array();
-
- //vajadzēs ciklu kur mēs būvēsim pieprsījumu,kuru grupēsim pēc personām
- for ($i = 1; $i <= $tagsk; $i++) {
- if(isset($_POST['Tag'.$i]))
- {
- $mekl[] = 'TAGID='.$_POST['Tag'.$i];
- //pieprasījums ievietošanai
- $vajadzigie++;
- }
-
- }
- if(($vajadzigie==0) && isset($_POST['melnais_sar']))
- {
- if($nop=='')
- {
- $meklp="SELECT * FROM tbPersonas WHERE PersBlacklist=1 ORDER BY PersVards ASC";
- $meklpr=mysqli_query($conn,$meklp);
- }
- else
- {
- $nop=strtotime($nop);
- if($lidzp=='')
- {
- $lidzp=time();
- }
- else
- {
- $lidzp=strtotime($lidzp);
- }
- $meklp="SELECT * FROM tbPersonas WHERE PersBlacklist=1 AND PersPievienots between '$nop' AND '$lidzp' ORDER BY PersVards ASC";
- $meklpr=mysqli_query($conn,$meklp);
- }
- echo '<div class="w3-padding-24 w3-container w3-twothird">
- <table class="w3-table w3-striped">
- <tr>
- <th>Vārds</th>
- <th>Uzvārds</th>
- <th>E-pasts</th>
- <th>Pievienots</th>
- <th>Vairāk</th>
- </tr>';
- while($rowpv=mysqli_fetch_assoc($meklpr))
- {
- echo'<tr>';
- echo'<td>'.$rowpv['PersVards'].'</td>';
- echo'<td>'.$rowpv['PersUzvards'].'</td>';
- echo'<td>'.$rowpv['PersEpasts'].'</td>';
- echo '<td>'.date('Y-m-d', $rowp['PersPievienots']).'</td>';
- //echo'<td><a href="/upload/'.$row_pers['CVFails'].'"target="_blank"><button class="w3-button w3-red">CV</button></a></td>';
- echo'<td><form action="cvmarket.php" method="POST"><input type="hidden" value="'.$rowpv['PID'].'" name="pers_i"><input type="submit" class="w3-button w3-red" name="pers_vairak" value="Vairāk"></form></td>';
- echo'</tr>';
- }
- echo '</table>';
- echo '</div>';
- }
- else
- {
- //Izvēlamies vajadzīgo pieprasījumu. Vai tikai melnajā sarakstā, vai visus
- if(isset($_POST['melnais_sar']))
- {
- //dalīsim pa datumiem
- //Ja ir periods
- if($nop==''){
-
- $mekltg="SELECT *, COUNT(*) FROM tbCVTAG INNER JOIN tbPersonas ON tbCVTAG.PersonasID = tbPersonas.PID INNER JOIN tbTag ON tbCVTAG.TAGID = tbTag.TID";
- $mekltg.=" WHERE " . implode (" OR ", $mekl);
- $mekltg.=" AND tbPersonas.PersBlacklist=1 GROUP BY PersonasID ORDER BY COUNT(*) DESC";
- $rezultats = mysqli_query($conn,$mekltg);
- }
- else
- {
- $mekltg="SELECT *, COUNT(*) FROM tbCVTAG INNER JOIN tbPersonas ON tbCVTAG.PersonasID = tbPersonas.PID INNER JOIN tbTag ON tbCVTAG.TAGID = tbTag.TID";
- $mekltg.=" WHERE " . implode (" OR ", $mekl);
- $mekltg.=" AND tbPersonas.PersBlacklist=1 AND PersPievienots between '$nop' AND '$lidzp' GROUP BY PersonasID ORDER BY COUNT(*) DESC";
- $rezultats = mysqli_query($conn,$mekltg);
- }
- }
- else
- {
- if($nop==''){
- $mekltg="SELECT *, COUNT(*) FROM tbCVTAG INNER JOIN tbPersonas ON tbCVTAG.PersonasID = tbPersonas.PID INNER JOIN tbTag ON tbCVTAG.TAGID = tbTag.TID";
- $mekltg.=" WHERE " . implode (" OR ", $mekl);
- $mekltg.=" GROUP BY PersonasID ORDER BY COUNT(*) DESC";
- $rezultats = mysqli_query($conn,$mekltg);
- }
- else
- {
- $mekltg="SELECT *, COUNT(*) FROM tbCVTAG INNER JOIN tbPersonas ON tbCVTAG.PersonasID = tbPersonas.PID INNER JOIN tbTag ON tbCVTAG.TAGID = tbTag.TID";
- $mekltg.=" WHERE " . implode (" OR ", $mekl);
- $mekltg.=" AND PersPievienots between '$nop' AND '$lidzp' GROUP BY PersonasID ORDER BY COUNT(*) DESC";
- $rezultats = mysqli_query($conn,$mekltg);
- }
- }
-
- echo '
- <div class="w3-padding-24 w3-container w3-twothird">
- <table class="w3-table w3-striped">
- <tr>
- <th>Vārds</th>
- <th>Uzvārds</th>
- <th>E-pasts</th>
- <th>Atbilstības</th>
- <!--<th>CV</th>-->
- <th>Pievienots</th>
- <th>Vairāk</th>
- </tr>';
- while($row=mysqli_fetch_assoc($rezultats))
- {
- echo'<tr>';
- echo'<td>'.$row['PersVards'].'</td>';
- echo'<td>'.$row['PersUzvards'].'</td>';
- echo'<td>'.$row['PersEpasts'].'</td>';
- echo'<td>'.$row['COUNT(*)'].'/'.$vajadzigie.'</td>';
- echo '<td>'.date('Y-m-d', $row['PersPievienots']).'</td>';
-
- //echo'<td><a href="/upload/'.$row_pers['CVFails'].'"target="_blank"><button class="w3-button w3-red">CV</button></a></td>';
- echo'<td><form action="cvmarket.php" method="POST"><input type="hidden" value="'.$row['PID'].'" name="pers_i"><input type="submit" class="w3-button w3-red" name="pers_vairak" value="Vairāk"></form></td>';
- echo'</tr>';
- }
- echo '</table>';
- }
- }
- else
- {
- if(isset($_POST['meklet_pers']))
- {
- //meklēsim pēc vārda uzvārda
-
- $persdat=$_POST['vards_uzvards'];
- //Ja nav periods
- if($nop==''){
- $meklp="SELECT * FROM tbPersonas WHERE PersVards LIKE '%$persdat%' OR PersUzvards LIKE '%$persdat%'";
- }
- else{
- //ja ir periods
- $meklp="SELECT * FROM tbPersonas WHERE (PersVards LIKE '%$persdat%' OR PersUzvards LIKE '%$persdat%') AND PersPievienots between '$nop' AND '$lidzp' ";
- //echo '<h1>NO:'.$nop.'</h1>';
- //echo '<h1>LIDZ:'.$lidzp.'</h1>';
- }
-
- $meklpr=mysqli_query($conn,$meklp);
- echo '<div class="w3-padding-24 w3-container w3-twothird">
- <table class="w3-table w3-striped">
- <tr>
- <th>Vārds</th>
- <th>Uzvārds</th>
- <th>E-pasts</th>
- <th>Pievienots</th>
- <th>Vairāk</th>
- </tr>';
- while($rowpv=mysqli_fetch_assoc($meklpr))
- {
- echo'<tr>';
- echo'<td>'.$rowpv['PersVards'].'</td>';
- echo'<td>'.$rowpv['PersUzvards'].'</td>';
- echo'<td>'.$rowpv['PersEpasts'].'</td>';
- echo '<td>'.date('Y-m-d', $rowpv['PersPievienots']).'</td>';
- //echo'<td><a href="/upload/'.$row_pers['CVFails'].'"target="_blank"><button class="w3-button w3-red">CV</button></a></td>';
- echo'<td><form action="cvmarket.php" method="POST"><input type="hidden" value="'.$rowpv['PID'].'" name="pers_i"><input type="submit" class="w3-button w3-red" name="pers_vairak" value="Vairāk"></form></td>';
- echo'</tr>';
- }
- echo '</table>';
- }
- }
- echo '</div>';
- //echo mysqli_error($conn);
- //echo $mekltg;
- ?>
|