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

update files documents

parent 4f3ad461
...@@ -419,6 +419,37 @@ class BasesEncuestasController extends CrController ...@@ -419,6 +419,37 @@ class BasesEncuestasController extends CrController
$data=array("check"=>"0"); $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); $model = $this->loadModel($id);
$columnas = 'enc_'.$model->tabla; $columnas = 'enc_'.$model->tabla;
......
...@@ -156,6 +156,37 @@ class DocumentosController extends CrController{ ...@@ -156,6 +156,37 @@ class DocumentosController extends CrController{
public function actionDelete($id){ public function actionDelete($id){
//if(!isset($_GET['ajax']))return false; //if(!isset($_GET['ajax']))return false;
$data=array("check"=>"0"); $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"); if($this->loadModel($id)->delete())$data=array("check"=>"1");
echo json_encode($data); echo json_encode($data);
exit(); exit();
......
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