/** * ESCRIBE EN EL FICHERO lastConnection.yml LOS DATOS DE LA * ULTIMA CONEXIÓN QUE ESTAN EN $_POST */ public function saveCurrentParametersConnection() { $texto = sfYaml::dump($this->connection); $archivo = new Archivo("lastConnection.yml"); $archivo->write($texto); unset($archivo); }
static function getCsv($idPedido) { $pedido = new PedidosCab($idPedido); $cabecera = '"Firma";"' . $pedido->getIdFirma()->getRazonSocial() . '"\\n'; $cabecera .= '"Cliente";"' . $pedido->getIdCliente()->getRazonSocial() . '"\\n'; $cabecera .= '"Dir. Entrega";"' . $pedido->getIdDirec()->getDireccion() . '"\\n'; $cabecera .= '"Fecha";"' . $pedido->getFecha() . '"\\n'; $cabecera .= '"S/Pedido";"' . $pedido->getSuPedido() . '"\\n'; $cabecera .= '"Observaciones";"' . $pedido->getObservations() . '"\\n'; $cabecera .= '"Forma de Pago";"' . $pedido->getFormaPago() . '"\\n'; $cabecera .= '"Agencia Tte.";"' . $pedido->getAgencia() . '"\\n\\n'; $lineas = '"Articulo";"Descripcion";"Unidades";"Precio";"Descuento1";"Descuento2";"Descuento3";"Importe"\\n'; foreach ($pedido->getLineas() as $linea) { $lineas .= '"' . $linea->getIdArticulo()->getCodigo() . '";' . '"' . $linea->getIdArticulo()->getDescripcion() . '";' . '"' . $linea->getUnidades() . '";' . '"' . $linea->getPrecio() . '";' . '"' . $linea->getDescuento1() . '";' . '"' . $linea->getDescuento2() . '";' . '"' . $linea->getDescuento3() . '";' . '"' . $linea->getImporte() . '"\\n'; } $csv = $lineas; $fileCsv = Archivo::getTemporalFileName("export", "csv"); $archivo = new Archivo($fileCsv); if (!$archivo->write($csv)) { $fileCsv = ""; } return $fileCsv; }
public function GenerarAction() { if ($this->values['permisos']['permisosModulo']['LI']) { $this->idCircular = $this->request['idCircular']; $this->filePlantilla = $this->pathPlantillas . "/" . $this->request['plantilla']; $formato = $this->circulares[$this->idCircular]; // Leer el contenido de la plantilla $archivo = new Archivo($this->filePlantilla); $this->textoPlantilla = $archivo->read("rb"); unset($archivo); // HACER EL QUERY MASTER $this->queryMaster = $this->circulares[$this->idCircular]['queryMaster']; // Reemplazar en el query los valores del filtro $this->filter = $this->request['filter']; foreach ($this->filter['columnsSelected'] as $key => $value) { $valor = $this->filter['valuesSelected'][$key]; if ($formato['filters'][$key]['type'] == 'date') { $fecha = new Fecha($valor); $valor = $fecha->getaaaammdd(); unset($fecha); } $this->queryMaster = str_replace($value, $valor, $this->queryMaster); } $this->queryMaster = str_replace("DBNAME", $_SESSION['project']['conection']['database'], $this->queryMaster); //echo $this->queryMaster; $em = new EntityManager($_SESSION['project']['conection']); if ($em->getDbLink()) { $em->query($this->queryMaster); $master = $em->fetchResult(); } unset($em); // HACER EL QUERY DETAIL $this->queryDetail = $this->circulares[$this->idCircular]['queryDetail']; if ($this->queryDetail) { // Reemplazar en el query los valores del filtro $this->filter = $this->request['filter']; foreach ($this->filter['columnsSelected'] as $key => $value) { $valor = $this->filter['valuesSelected'][$key]; if ($formato['filters'][$key]['type'] == 'date') { $fecha = new Fecha($valor); $valor = $fecha->getaaaammdd(); unset($fecha); } $this->queryDetail = str_replace($value, $valor, $this->queryDetail); } $this->queryDetail = str_replace("DBNAME", $_SESSION['project']['conection']['database'], $this->queryDetail); } if (!file_exists($this->pathCirculares)) { mkdir($this->pathCirculares); } foreach ($master as $key => $registro) { $texto = $this->SustituyeValores($registro, $this->request['variables']); $archivo = $this->pathCirculares . "/" . $_SESSION['usuarioPortal']['Id'] . "_" . $key . "_" . $this->request['plantilla']; $archivo = new Archivo($archivo); if (!$archivo->write($texto)) { $this->values['errores'] = "No se ha generado {$archivo}"; } } $this->generarZip(); return $this->IndexAction(); } else { $template = "_global/forbiden.html.twig"; } return array('template' => $template, 'values' => $this->values); }
/** * Activa o desactiva el modo debuger de Twig * * Para activar: Index/Debuger/true * Para desactivar: Index/Debuger/false * * @return void */ public function DebugerAction() { $fileConfig = 'config/config.yml'; $array = sfYaml::load($fileConfig); $array['config']['twig']['debug_mode'] = $this->request[2] == 'true' ? true : false; $yml = sfYaml::dump($array, 4); $archivo = new Archivo($fileConfig); $archivo->write($yml); $archivo->close(); echo "Modo debuger Twig: ", $array['config']['twig']['debug_mode'], "----"; return $this->IndexAction(); }
/** * Lee la tablas existentes y genera un archivo yml * con el esquema de la base de datos. * * Este método solo funciona con BDs mysql * * El archivo generado tiene el nombre de la base de datos * * @return boolean TRUE si se construyo con éxito */ public function buildSchema() { $arrayTablas = array(); $dblink = mysql_connect($this->host, $this->user, $this->password); mysql_select_db($this->database, $dblink); $query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='" . $this->database . "'"; $result = mysql_query($query, $dblink); while ($row = mysql_fetch_array($result)) { $entity = new EntityBuilder($row['TABLE_NAME']); $arrayTabla = $entity->getSchema(); $arrayTablas[$row['TABLE_NAME']] = $arrayTabla[$row['TABLE_NAME']]; } unset($entity); $yml = "# ESQUEMA DE LA BD " . $this->database . "\n\n"; $yml .= sfYaml::dump($arrayTablas, 2); $archivo = new Archivo($this->database . ".yml"); $ok = $archivo->write($yml); unset($archivo); return $ok; }