This repository has been archived by the owner on Aug 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
completaActos.php
120 lines (110 loc) · 4.39 KB
/
completaActos.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker fileencoding=utf-8:
/**
* Completa categorias replicadas
*
* PHP version 5
*
* @category SIVeL
* @package SIVeL
* @author Vladimir Támara <[email protected]>
* @copyright 2010 Dominio público. Sin garantías.
* @license https://www.pasosdejesus.org/dominio_publico_colombia.html Dominio Público. Sin garantías.
* @link http://sivel.sf.net
*/
/**
* Completa categorias replicadas
*/
require_once "aut.php";
require_once $_SESSION['dirsitio'] . '/conf.php';
require_once "confv.php";
require_once "misc.php";
require_once "DataObjects/Categoria.php";
$aut_usuario = "";
$db = autentica_usuario($dsn, $aut_usuario, 62);
$t = 'Completa actos ' . @date('Y-m-d H:m');
encabezado_envia($t);
echo '<table width="100%">'
. '<td style="white-space: nowrap; background-color: #CCCCCC;" '
. 'align="left" valign="top" colspan="2"><b>'
. '<div align=center>' . $t
. '</div></b></td></table><p/>';
echo "Individuales<br>";
hace_consulta($db, "DROP VIEW replicadas", false, false);
hace_consulta(
$db, "CREATE VIEW replicadas AS " .
" SELECT id_presponsable, contadaen, id_persona, id_caso " .
" FROM acto JOIN categoria ON acto.id_categoria=categoria.id " .
" JOIN caso ON acto.id_caso=caso.id " .
" WHERE caso.fecha >= '2016-06-30' " .
" AND categoria.contadaen IS NOT NULL ORDER BY categoria.id, caso.id;"
);
$pres = " FROM replicadas WHERE (id_presponsable, contadaen, " .
" id_persona, id_caso) NOT IN (select id_presponsable, " .
" id_categoria, id_persona, id_caso from acto)";
$s = "SELECT COUNT(*) $pres";
$ni = $db->getOne($s);
sin_error_pear($ni);
echo " Se insertarán " . (int)$ni . " actos individuales<br>";
hace_consulta(
$db, "INSERT INTO acto (id_presponsable, id_categoria, " .
" id_persona, id_caso) SELECT * $pres"
);
hace_consulta($db, "DROP VIEW replicadas");
echo "Colectivos<br>";
hace_consulta($db, "DROP VIEW replicadasc", false, false);
hace_consulta(
$db, "CREATE VIEW replicadasc AS " .
" SELECT id_presponsable, contadaen, id_grupoper, id_caso " .
" FROM actocolectivo " .
" JOIN categoria ON actocolectivo.id_categoria=categoria.id " .
" JOIN caso ON actocolectivo.id_caso=caso.id " .
" WHERE caso.fecha >= '2016-06-30' " .
" AND categoria.contadaen IS NOT NULL ORDER BY categoria.id, caso.id;"
);
$pres = " FROM replicadasc " .
" WHERE (id_presponsable, contadaen, id_grupoper, id_caso) " .
" NOT IN (SELECT id_presponsable, id_categoria, id_grupoper, id_caso " .
" FROM actocolectivo)";
$s = "SELECT COUNT(*) $pres ";
$ni = $db->getOne($s);
sin_error_pear($ni);
echo " Se insertarán " . (int)$ni . " actos colectivos<br>";
hace_consulta(
$db, "INSERT INTO actocolectivo " .
" (id_presponsable, id_categoria, id_grupoper, id_caso) SELECT * $pres"
);
hace_consulta($db, "DROP VIEW replicadasc");
echo '<table width="100%">' .
'<td style="white-space: nowrap; background-color: #CCCCCC;" ' .
'align="left" valign="top" colspan="2"><b>' .
'<div align=right><a href="index.php">' .
_('Menú Principal') . '</a>' .
'</div></b></td></table>';
/* Completa casos de paramilitares en DIH en DH
CREATE VIEW parasdh AS select id_presponsable, categoria.id, id_persona, id_caso
FROM acto, categoria
WHERE acto.id_categoria = categoria.contadaen and id_presponsable = '14';
SELECT * from parasdh WHERE (id_presponsable, id, id_persona, id_caso)
NOT IN (SELECT id_presponsable, id_categoria, id_persona, id_caso FROM acto);
INSERT INTO acto (id_presponsable, id_categoria, id_persona, id_caso)
SELECT * from parasdh WHERE (id_presponsable, id, id_persona, id_caso)
NOT IN (SELECT id_presponsable, id_categoria, id_persona, id_caso FROM acto);
DROP VIEW parasdh;
CREATE VIEW parasdhc AS select id_presponsable, categoria.id, id_grupoper, id_caso
FROM actocolectivo, categoria
WHERE actocolectivo.id_categoria = categoria.contadaen
AND id_presponsable = '14';
SELECT * from parasdhc WHERE (id_presponsable, id, id_grupoper, id_caso)
NOT IN (SELECT id_presponsable, id_categoria, id_grupoper, id_caso
FROM actocolectivo
);
INSERT INTO actocolectivo (id_presponsable, id_categoria, id_grupoper, id_caso)
SELECT * from parasdhc WHERE (id_presponsable, id, id_grupoper, id_caso)
NOT IN (SELECT id_presponsable, id_categoria, id_grupoper, id_caso
FROM actocolectivo
);
DROP VIEW parasdhc;
*/
pie_envia();
?>