<?php
session_start();
require_once("../head2Altsp.php");
////

if(isset($_POST["post"])){
  $post=$_POST['post'];
  if($post=="Tuma"){
ini_set('upload_max_filesize', '2M');
ini_set('post_max_size', '2M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);
 
 if(isset($_POST['tDate']) && isset($_FILES['lRipoti']['name']) && isset($_POST['id']) && isset($_POST['imei']) && isset( $_FILES["lRipoti"]["tmp_name"])){

 
 $tDate=$_POST['tDate'];

 $fn = $_FILES["lRipoti"]["name"]; 
 
 $type=$_FILES["lRipoti"]["type"];

$size=$_FILES["lRipoti"]["size"];

$error=$_FILES["lRipoti"]["error"];

$tmp_name=$_FILES["lRipoti"]["tmp_name"];

$ext = pathinfo($fn, PATHINFO_EXTENSION);

$imei = $_POST['imei'];  $ownID = $_POST['id'];

$allowedtype=array('png','jpg','jpeg','gif','jpeg','JPG','JPEG','GIF','PNG','PDF','pdf');

//list($height,$width)=getimagesize($tmp_name);


//echo " Name:  ".$fn ."Type:  ".$type ." Size:  ".$size."  Temp_Name:  ".$tmp_name."  Extension:  ".$ext.$hid;

// alternative way for checking type if($ext=='png' || $ext=='JPEG' || $ext=='gif' || $type=='jpg')
 
if(!$dBcon->vImageType($ext,$allowedtype) || !$dBcon->vImageError($error)  || !$dBcon->vImageSize($size) || !$dBcon->vImageExist($fn) || !$dBcon->vTitle($imei) || !$dBcon->vImageSelectF($fn) )
  {
   // require("repostHotelImageUploadForm.php");
    ?>

<center>
  <div><sup>
<?php
   echo $dBcon->eImageType($ext,$allowedtype)."<p/>";
   echo $dBcon->eImageSize($size)."<p/>";
   echo $dBcon->eImageError($error)."<p/>";
   echo $dBcon-> eImageExist($fn)."<p/>" ;
   echo $dBcon-> eTitle($imei)."<p/>" ;
   echo $dBcon->eImageSelectF($fn)
?>
</sup>
</div>
</center>

    <?php
  }
  else{
    $d=$dBcon->getCheckIfPostExist($imei,$ownID);
if ($d->rowCount()<=0) {
  

  ?>
  <center>
    <font color="blue">
    <?php

       echo $dBcon->uploadImage($fn,$imei, $ownID,$tmp_name,$tDate);

      ?>
    </font>
  </center>
<?php
  }else{
  ?>
  <center>
    <font color="red">
    <?php
      echo "Post exist!..";
      ?>
    </font>
  </center>
<?php
}
    //require("successFullHImageUpload.php");
      }
  

      }
else
  {
     ?>
  <center>
    <font color="red">
    <?php
        echo "Error occured when page load!..";
      ?>
    </font>
  </center>
<?php
  
  }
}
}
//else
//{
//  echo "Oops error occured!..";
//}



///////



?>
 <fieldset style="padding-top:5%; padding-right:20%; border-radius:12px; border:0;">
     <center>
     	<form method="POST" action="lostForm.php" autocomplete="on" enctype="multipart/form-data">
        <table width="50%" border="0">
        	<tr><td><b>Ingiza taarifa za simu iliyopotea hapa:</b></td></tr>
        	

           <tr>
            <td>
              <input id= "id" type="hidden" value="<?php echo $ownID;?>" name="id"/>
            </td>
          </tr>
          <tr>
        		<td>Simu(Chagua imei na):</td>
        	</tr>
          <tr>
            <td>
             <select  id="inp" name="imei">
             	<option value="">Chagua imei</option>
      <?php        
         $myp=$dBcon->getMyPhone($ownID);
         if($myp->rowCount()>0){
          $pho=$myp->fetchAll();


           foreach ($pho as $key => $phone)
             {

                 ?>
                 <option value="<?php echo $phone["imei"];?>"><?php echo $phone['imei'];?></option>
                 <?php
              }
          }
          
          ?>

             </select>
            </td>
          </tr>
          <tr>
        		<td>Tarehe ya kupotea:</td>
        	</tr>
          <tr>
            <td>
              <input type="date" id="inp" name="tDate"/>
            </td>
          </tr>
             <tr>
            <td>Nambari ya simu iliyokuwa ikitumika:</td>
          </tr>
          <tr>
        		<td>Pakia lost ripoti:</td>
        	</tr>
          <tr>
            <td>
              <input type="file" id="inp" placeholder="Pakia" name="lRipoti"/>
            </td>
          </tr>
                  <tr>
            <td>
              <input type="submit"  value="Tuma"  name="post"/>
            </td>
          </tr>
       
          
        </table>
      </form>
    </center>
    </fieldset>

<?php
require_once("footer.php");
?>
<script type="text/javascript">
                  var i=0; 
    
                var counter=0;
	
	            var t=28;
                var mgs="";
                var action;
                 var i1=0; 
    
                var counter1=0;
	
	            var t1=28;
                var mgs1="";
                var action1;

	
</script>
