echo "Error: " . $e->getMessage(); } $bd = NULL; } function sql2mod($sql) { global $dsnWriter; try { $bd = new formas($dsnWriter); $bd->beginTransaction(); $res = $bd->exec($sql); $bd->commit(); echo "Transacción exitosa;"; } catch (PDOException $e) { $bd->rollBack(); echo "Error: " . $e->getMessage(); } $bd = NULL; } $select = "SELECT t1.id as FOLIO, t1.CLIENTE_ID, CONCAT(t2.NOMBRE,' ',t2.APELLIDOS) AS NOMBRE, t2.GENERO, date_format(t5.FECHA_ATENCION,'%d/%m/%Y') as FECHA_ATENCION, t3.NOMBRE as CONCEPTO, t1.*, t4.* FROM examenes t1 INNER JOIN pacientes t2 ON t1.PACIENTE_ID=t2.PACIENTE_ID INNER JOIN conceptos t3 ON t1.CONCEPTO_ID=t3.CONCEPTO_ID LEFT JOIN resultados t4 ON t1.id=t4.EXAMEN_ID LEFT JOIN examenes_adminte t5 ON t1.id=t5.FOLIO_RASTREO WHERE t1.CLIENTE_ID=478 AND (t5.FECHA_ATENCION BETWEEN '2015-03-23 00:00:00' AND '2015-03-26 00:00:00' OR t1.FECHA_IN BETWEEN '2015-03-23 00:00:00' AND '2015-03-26 00:00:00') ORDER BY t1.id DESC ;"; #sql2table($select); $insert = "INSERT INTO conceptos_grupo (NOMBRE,CONCEPTO_ID) \nSELECT 'KIA STAFF', CONCEPTO_ID FROM conceptos WHERE NOMBRE LIKE '%KIA STAFF%';"; #sql2mod($insert); $update = "CREATE TABLE `conceptos_gpo_user` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `USER_ID` int(11) DEFAULT NULL,\n `GRUPO_CONC_ID` int(11) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;\n"; sql2mod($update); $sql = "SELECT \n\tt3.TIPO\nFROM examenes t1\nINNER JOIN conceptos_grupo_hijo t2 ON t1.CONCEPTO_ID=t2.CONCEPTO_ID\nINNER JOIN conceptos_grupo_padre t3 ON t2.GRUPO_ID=t3.id\nWHERE t1.id=746;"; #sql2table($sql); $select = "SELECT\n\tt1.*\nFROM examenes t1\nLEFT JOIN resultados t2 ON t1.id=t2.EXAMEN_ID\nWHERE t2.resultado IS NULL;"; #sql2table($select); $select = "SELECT\n\tt1.id as folio,\n\tCONCAT(t2.NOMBRE,t2.APELLIDOS) as NOMBRE,\n\tCOUNT(*) as cuenta\nFROM examenes t1\nINNER JOIN pacientes t2 ON t1.PACIENTE_ID=t2.PACIENTE_ID\nGROUP BY CONCAT(t2.NOMBRE,t2.APELLIDOS);"; #sql2table($select);
function modifTotal($folio = "", $total = "") { if ($folio == "" || $total == "") { return false; break; } $total = number_format($total, 2); $sql = "UPDATE p_recepcion SET TOTAL='{$total}' WHERE RECEPCION_ID={$folio};"; return sql2mod($sql); }
{ if (date("W", strtotime($f1)) * 1 < date("W", strtotime($f2)) * 1) { return true; } else { return false; } } $sinRes = "SELECT\n\tt1.*\nFROM examenes t1\nWHERE t1.id NOT IN (SELECT FOLIO_RASTREO FROM examenes_adminte t2);"; $r = sql2arr($sinRes); #var_dump($r["data"]); #var_dump($r); #echo $r["data"][0]["id"]; #echo count($r["data"]); #echo date("w"); if (date("w") == "6") { foreach ($r["data"] as $d) { if (comparaSemana($d["FECHA_IN"], date("Y-m-d H:i:s"))) { $sqlBorrar = "DELETE FROM resultados WHERE EXAMEN_ID=" . $d["id"] . ";"; sql2mod($sqlBorrar); $sqlBorrar = "DELETE FROM examenes WHERE id=" . $d["id"] . ";"; sql2mod($sqlBorrar); #echo $d["id"]."<br>"; } } } else { echo 'Todavia no es sabado...'; } #echo date("W"); #echo date("d/m/Y"); if ($r["err"]) { }