Ejemplo n.º 1
0
                ?>
											 <img src="assets/images/enviado.png" alt="">
											<?php 
                break;
            case 'PEDIDO ENTREGADO':
                ?>
											 <img src="assets/images/entregado.png" alt="">
											<?php 
                break;
                ?>

											<?php 
        }
        ?>
											<p class="text text-uppercase"><?php 
        echo Estado::get($valdetalles->estado);
        ?>
</p>
										</div>
									</td>
									<!--end / estado -->
									
									<!--remito -->
									<td class="col-D remito">
										<div class="background-1">
											<p class="medium-text text-uppercase">Nº <?php 
        echo $valdetalles->remito;
        ?>
</p>
										</div>
									</td>
Ejemplo n.º 2
0
 /**
  * Método para obtener la clave pública (certificado X.509) del SII
  *
  * \code{.php}
  *   $pub_key = \sasco\LibreDTE\Sii::cert(100); // Certificado IDK 100 (certificación)
  * \endcode
  *
  * @param idk IDK de la clave pública del SII. Si no se indica se tratará de determinar con el ambiente que se esté usando
  * @return Contenido del certificado
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
  * @version 2015-09-16
  */
 public static function cert($idk = null)
 {
     // si se pasó un idk y existe el archivo asociado se entrega
     if ($idk) {
         $cert = dirname(dirname(__FILE__)) . '/certs/' . $idk . '.cer';
         if (is_readable($cert)) {
             return file_get_contents($cert);
         }
     }
     // buscar certificado y entregar si existe o =false si no
     $ambiente = self::getAmbiente();
     $cert = dirname(dirname(__FILE__)) . '/certs/' . self::$config['certs'][$ambiente] . '.cer';
     if (!is_readable($cert)) {
         \sasco\LibreDTE\Log::write(Estado::SII_ERROR_CERTIFICADO, Estado::get(Estado::SII_ERROR_CERTIFICADO, self::$config['certs'][$ambiente]));
         return false;
     }
     return file_get_contents($cert);
 }
Ejemplo n.º 3
0
 /**
  * Método para generar un error usando una excepción de SowerPHP o terminar
  * el script si no se está usando el framework
  * @param msg Mensaje del error
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
  * @version 2015-09-17
  */
 private function error($msg)
 {
     $msg = Estado::get(Estado::FIRMA_ERROR, $msg);
     if (class_exists('\\sowerphp\\core\\Exception')) {
         throw new \sowerphp\core\Exception($msg);
     } else {
         \sasco\LibreDTE\Log::write(Estado::FIRMA_ERROR, $msg);
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * Método que entrega un arreglo con todos los datos de los contribuyentes
  * que operan con factura electrónica descargados desde el SII
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
  * @version 2015-09-30
  */
 public static function getContribuyentes(\sasco\LibreDTE\FirmaElectronica $Firma, $ambiente = null)
 {
     // solicitar token
     $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma);
     if (!$token) {
         return false;
     }
     // definir ambiente y servidor
     $ambiente = self::getAmbiente($ambiente);
     $servidor = self::$config['servidor'][$ambiente];
     // preparar consulta curl
     $curl = curl_init();
     $header = ['User-Agent: Mozilla/4.0 (compatible; PROG 1.0; Windows NT 5.0; YComp 5.0.2.4)', 'Referer: https://' . $servidor . '.sii.cl/cvc/dte/ee_empresas_dte.html', 'Cookie: TOKEN=' . $token, 'Accept-Encoding' => 'gzip, deflate, sdch'];
     $url = 'https://' . $servidor . '.sii.cl/cvc_cgi/dte/ee_consulta_empresas_dwnld?NOMBRE_ARCHIVO=ce_empresas_dwnld_' . date('Ymd') . '.csv';
     curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     // si no se debe verificar el SSL se asigna opción a curl, además si
     // se está en el ambiente de producción y no se verifica SSL se
     // generará un error de nivel E_USER_NOTICE
     if (!self::$verificar_ssl) {
         if ($ambiente == self::PRODUCCION) {
             $msg = Estado::get(Estado::ENVIO_SSL_SIN_VERIFICAR);
             trigger_error($msg, E_USER_NOTICE);
             \sasco\LibreDTE\Log::write(Estado::ENVIO_SSL_SIN_VERIFICAR, $msg, LOG_WARNING);
         }
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     }
     // realizar consulta curl
     $response = curl_exec($curl);
     if (!$response) {
         return false;
     }
     // cerrar sesión curl
     curl_close($curl);
     // entregar datos del archivo CSV
     ini_set('memory_limit', '1024M');
     $lines = explode("\n", $response);
     $n_lines = count($lines);
     $data = [];
     for ($i = 1; $i < $n_lines; $i++) {
         $row = str_getcsv($lines[$i], ';', '');
         unset($lines[$i]);
         if (!isset($row[5])) {
             continue;
         }
         for ($j = 0; $j < 6; $j++) {
             $row[$j] = trim($row[$j]);
         }
         $row[1] = utf8_decode($row[1]);
         $row[4] = strtolower($row[4]);
         $row[5] = strtolower($row[5]);
         $data[] = $row;
     }
     return $data;
 }
Ejemplo n.º 5
0
 /**
  * Método que empaqueta y comprime archivos (uno o varios, o directorios).
  * Si se pide usar formato zip entonces se usará ZipArchive de PHP para
  * comprimir
  * @param filepath Directorio (o archivo) que se desea comprimir
  * @param options Arreglo con opciones para comprmir (format, download, delete)
  * @todo Preparar datos si se pasa un arreglo
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
  * @version 2015-11-03
  */
 public static function compress($file, $options = [])
 {
     // definir opciones por defecto
     $options = array_merge(['format' => 'gz', 'delete' => false, 'download' => true, 'commands' => ['gz' => 'gzip --keep :in', 'tar.gz' => 'tar czf :in.tar.gz :in', 'tar' => 'tar cf :in.tar :in', 'bz2' => 'bzip2 --keep :in', 'tar.bz2' => 'tar cjf :in.tar.bz2 :in', 'zip' => 'zip -r :in.zip :in']], $options);
     // si el archivo no se puede leer se entrega =false
     if (!is_readable($file)) {
         \sasco\LibreDTE\Log::write(Estado::COMPRESS_ERROR_READ, Estado::get(Estado::COMPRESS_ERROR_READ));
         return false;
     }
     // si es formato gz y es directorio se cambia a tgz
     if (is_dir($file)) {
         if ($options['format'] == 'gz') {
             $options['format'] = 'tar.gz';
         } else {
             if ($options['format'] == 'bz2') {
                 $options['format'] = 'tar.bz2';
             }
         }
     }
     // obtener directorio que contiene al archivo/directorio y el nombre de este
     $filepath = $file;
     $dir = dirname($file);
     $file = basename($file);
     $file_compressed = $file . '.' . $options['format'];
     // empaquetar/comprimir directorio/archivo
     if ($options['format'] == 'zip') {
         // crear archivo zip
         $zip = new \ZipArchive();
         if ($zip->open($dir . DIRECTORY_SEPARATOR . $file . '.zip', \ZipArchive::CREATE) !== true) {
             \sasco\LibreDTE\Log::write(Estado::COMPRESS_ERROR_ZIP, Estado::get(Estado::COMPRESS_ERROR_ZIP));
             return false;
         }
         // agregar un único archivo al zip
         if (!is_dir($filepath)) {
             $zip->addFile($filepath, $file);
         } else {
             if (is_dir($filepath)) {
                 $Iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($filepath));
                 foreach ($Iterator as $f) {
                     if (!$f->isDir()) {
                         $path = $f->getPath() . DIRECTORY_SEPARATOR . $f->getFilename();
                         $zip->addFile($path, str_replace($filepath, '', $file . DIRECTORY_SEPARATOR . $path));
                     }
                 }
             }
         }
         // escribir en el sistema de archivos y cerrar archivo
         file_put_contents($dir . DIRECTORY_SEPARATOR . $file_compressed, $zip->getStream(md5($filepath)));
         $zip->close();
     } else {
         exec('cd ' . $dir . ' && ' . str_replace(':in', $file, $options['commands'][$options['format']]));
     }
     // enviar archivo
     if ($options['download']) {
         ob_clean();
         header('Content-Disposition: attachment; filename=' . $file_compressed);
         $mimetype = self::mimetype($dir . DIRECTORY_SEPARATOR . $file_compressed);
         if ($mimetype) {
             header('Content-Type: ' . $mimetype);
         }
         header('Content-Length: ' . filesize($dir . DIRECTORY_SEPARATOR . $file_compressed));
         readfile($dir . DIRECTORY_SEPARATOR . $file_compressed);
         unlink($dir . DIRECTORY_SEPARATOR . $file_compressed);
     }
     // borrar directorio o archivo que se está comprimiendo si así se ha
     // solicitado
     if ($options['delete']) {
         if (is_dir($filepath)) {
             self::rmdir($filepath);
         } else {
             unlink($filepath);
         }
     }
 }
Ejemplo n.º 6
0
 function pegarNomes()
 {
     $data = array();
     $array = array();
     $data[0] = 'Todos';
     $e = new Estado();
     $e->get();
     foreach ($e as $estado) {
         $array[strtolower($estado->nome)] = $estado->nome;
     }
     $data = $data + $array;
     return $data;
 }