<?php

 session_start();
  $rut=$_SESSION['rut'];
  $cliente=$_SESSION['cliente'];
   include '../../conexion/conn.php';
//comprobamos que sea una petición ajax

   

$pi_folio=$_REQUEST['pi_folio'];
 
     
        $rscampos = mysql_query("SELECT * FROM `cal_cajas` WHERE pi_folio='$pi_folio'");
        while($rowcampos = mysql_fetch_array($rscampos)){
            $caja_id=$rowcampos['caja_id'];
            $sql6 = "DELETE FROM `cal_cajas_det` WHERE caja_id='".$caja_id."'";
                $result6 = @mysql_query($sql6);
         
            

            $sql6 = "DELETE FROM `cal_caja_causal` WHERE caja_id='".$caja_id."'";
                $result6 = @mysql_query($sql6);

            

            $sql6 = "DELETE FROM `cal_cajas` WHERE caja_id='".$caja_id."'";
                $result6 = @mysql_query($sql6);


        }
        $sql6 = "DELETE FROM `cal_caja_peso_fijo` WHERE pi_folio='".$pi_folio."'";
                $result6 = @mysql_query($sql6);
                $sql6 = "DELETE FROM `cal_caja_peso_fruto` WHERE pi_folio='".$pi_folio."'";
                $result6 = @mysql_query($sql6);
                $sql6 = "DELETE FROM `cal_caja_brix_fruto` WHERE pi_folio='".$pi_folio."'";
                $result6 = @mysql_query($sql6);
                $sql6 = "DELETE FROM `cal_cajas_fotos` WHERE pi_folio='".$pi_folio."'";
                $result6 = @mysql_query($sql6);
        $sql6 = "DELETE FROM `cal_planilla_inspeccion` WHERE pi_folio='".$pi_folio."'";
                $result6 = @mysql_query($sql6);

    
 
            
  if($result6){
    echo json_encode(array('success'=>true));
  }else{
    echo json_encode(array('success'=>false));
  }  



