Commit 84d10964 authored by Irving Sánchez's avatar Irving Sánchez

update files documents

parent 4f3ad461
......@@ -418,6 +418,37 @@ class BasesEncuestasController extends CrController
//if(!isset($_GET['ajax']))return false;
$data=array("check"=>"0");
$dir=$_SERVER['DOCUMENT_ROOT'].Yii::app()->request->baseUrl.'/archivos';
$servername = "localhost";
$username = "sec_user";
$password = "Resilencia19@";
$dbname = "ppd";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `tbl_bases_archivos` where id_base_encuesta=".$id;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
if ($row['archivo']!='')
{
unlink($dir.'/'.$row['archivo']);
}
}
}
mysqli_close($conn);
$model = $this->loadModel($id);
$columnas = 'enc_'.$model->tabla;
......
......@@ -156,6 +156,37 @@ class DocumentosController extends CrController{
public function actionDelete($id){
//if(!isset($_GET['ajax']))return false;
$data=array("check"=>"0");
$dir=$_SERVER['DOCUMENT_ROOT'].Yii::app()->request->baseUrl.'/documentos';
$servername = "localhost";
$username = "sec_user";
$password = "Resilencia19@";
$dbname = "ppd";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `tbl_documentos` where id_documento=".$id;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
if ($row['archivo']!='')
{
unlink($dir.'/'.$row['archivo']);
}
}
}
mysqli_close($conn);
if($this->loadModel($id)->delete())$data=array("check"=>"1");
echo json_encode($data);
exit();
......@@ -230,4 +261,4 @@ class DocumentosController extends CrController{
}
}
}
?>
\ No newline at end of file
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment