Пример #1
0
        $fini = "2015-" . date("m") . "-16 00:00:00";
        break;
    case 'm':
        $ffin = date("Y-m-d H:i:s", mktime(23, 59, 59, date("n") + 1, 0, date("Y")));
        $fini = date("Y-m") . "-01 00:00:00";
        break;
    case 'mant':
        $fini = date("Y-m-d H:i:s", mktime(0, 0, 0, date("n") - 1, 1, date("Y")));
        $ffin = date("Y-m-d H:i:s", mktime(23, 59, 59, date("n") + 1, 0, date("Y")));
        break;
}
$tag = array('trauma1' => "SELECT\n\t\t\tT1.RECEPCION_ID AS FOLIO,\n\t\t\tT1.FECHA,\n\t\t\t(SELECT NOMBRE FROM c_clientes A3 WHERE A3.CLIENTE_ID=T1.CLIENTE_ID) AS CLIENTE,\n\t\t\tTRIM(CONCAT(T1.NOMBRE,' ',T1.PATERNO,' ',T1.MATERNO)) AS NOMBRE,\n            #TRIM(CONCAT(T1.NOMBRE,' ',T1.APELLIDOS)) AS NOMBRE,\n\t\t\t(SELECT A2.NOMBRE FROM c_sucursales A2 WHERE A2.SUCURSAL_ID=T1.SUCURSAL_ID) AS ATENDIDO,\n\t\t\tT3.NOMBRE AS FACTURA,\n\t\t\tT1.INFORMACION_CLINICA,\n\t\t\tT1.COMENTARIOS,\n\t\t\tT4.DESCRIPCION,\n\t\t\tT4.CANTIDAD,\n\t\t\tT4.PRECIO\n\t\tFROM p_recepcion T1\n\t\tINNER JOIN c_clientes T2 ON T2.CLIENTE_ID=T1.CLIENTE_ID\n\t\tINNER JOIN c_zonas T3 ON T3.ZONA_ID=T2.ZONA_ID\n\t\tINNER JOIN p_recepcion_partidas T4 ON T4.RECEPCION_ID=T1.RECEPCION_ID\n\t\tWHERE T1.RECEPCION_ID IN (SELECT A1.RECEPCION_ID FROM p_recepcion_partidas A1 WHERE A1.CONCEPTO_ID IN (965,961,1166,706,748,717,715,713))\n\t\tAND T4.CONCEPTO_ID IN (965,961,1166,706,748,717,715,713)\n\t\tAND T1.FECHA BETWEEN '{$fini}' AND '{$ffin}'\n\t\tORDER BY T1.FECHA ASC;", 'trauma2' => "SELECT\n\t\t\tT1.RECEPCION_ID AS FOLIO,\n\t\t\tT1.FECHA,\n\t\t\t(SELECT NOMBRE FROM c_clientes A3 WHERE A3.CLIENTE_ID=T1.CLIENTE_ID) AS CLIENTE,\n\t\t\t#TRIM(CONCAT(T1.NOMBRE,' ',T1.PATERNO,' ',T1.MATERNO)) AS NOMBRE,\n            TRIM(CONCAT(T1.NOMBRE,' ',T1.APELLIDOS)) AS NOMBRE,\n\t\t\t(SELECT A2.NOMBRE FROM c_sucursales A2 WHERE A2.SUCURSAL_ID=T1.SUCURSAL_ID) AS ATENDIDO,\n\t\t\t#T3.NOMBRE AS FACTURA,\n\t\t\tT1.INFORMACION_CLINICA,\n\t\t\tT1.COMENTARIOS,\n\t\t\tT4.DESCRIPCION,\n\t\t\tT4.CANTIDAD,\n\t\t\tT4.PRECIO\n\t\tFROM p_recepcion T1\n\t\tINNER JOIN c_clientes T2 ON T2.CLIENTE_ID=T1.CLIENTE_ID\n\t\t#INNER JOIN c_zonas T3 ON T3.ZONA_ID=T2.ZONA_ID\n\t\tINNER JOIN p_recepcion_partidas T4 ON T4.RECEPCION_ID=T1.RECEPCION_ID\n\t\tWHERE T1.RECEPCION_ID IN (SELECT A1.RECEPCION_ID FROM p_recepcion_partidas A1 WHERE A1.CONCEPTO_ID IN (965,961,1166,706,748,717,715,713))\n\t\tAND T4.CONCEPTO_ID IN (965,961,1166,706,748,717,715,713)\n\t\tAND T1.FECHA BETWEEN '{$fini}' AND '{$ffin}'\n\t\tORDER BY T1.FECHA ASC;");
##se crea el archivo
$fecha = date("Y-m-d H:i:s");
$tag[$p[2]];
$csvStr = sql2csv($tag[$p[2]]);
if (!$sqlBool) {
    file_put_contents("error_log.txt", "({$fecha}) {$csvStr}", LOCK_EX + FILE_APPEND);
    exit;
}
$filename = "reportes/" . date("Y_m_d_His") . ".csv";
file_put_contents($filename, $csvStr);
##enviar el correo desde sistemas@promedic.com.mx
$mail = new PHPMailer();
//$mail->SMTPDebug = 3;                               // Enable verbose debug output
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'ssl://kia.websitewelcome.com';
// Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
Пример #2
0
function dumpcsv($sql, $view = false, $pretty_headers = true)
{
    csvheaders($view);
    echo sql2csv($sql, $pretty_headers);
    exit;
}
 function wichReport($task)
 {
     switch ($task) {
         //advanced report
         case 'csv1':
             $sql = SQLadvancedTermReport($_GET);
             break;
             //free terms
         //free terms
         case 'csv2':
             $sql = SQLverTerminosLibres();
             break;
             //duplicated terms
         //duplicated terms
         case 'csv3':
             $sql = SQLverTerminosRepetidos();
             break;
             //polit BT terms
         //polit BT terms
         case 'csv4':
             $sql = SQLpoliBT();
             break;
             //candidate terms
         //candidate terms
         case 'csv5':
             $sql = SQLtermsXstatus($_SESSION["id_tesa"], "12");
             break;
             //rejected terms
         //rejected terms
         case 'csv6':
             $sql = SQLtermsXstatus($_SESSION["id_tesa"], "14");
             break;
             //preferred and accepted terms without hierarchical relationships
         //preferred and accepted terms without hierarchical relationships
         case 'csv7':
             $sql = SQLtermsXcantNT();
             break;
             //preferred and accepted terms with words count
         //preferred and accepted terms with words count
         case 'csv8':
             $sql = SQLtermsXcantWords($_SESSION["id_tesa"]);
             break;
             //meta terms
         //meta terms
         case 'csv9':
             $sql = SQLtermsIsMetaTerms($_SESSION["id_tesa"]);
             break;
             //Terms with related terms
         //Terms with related terms
         case 'csv10':
             $sql = SQLtermsXrelatedTerms($_SESSION["id_tesa"]);
             break;
             //Terms with non prefered terms
         //Terms with non prefered terms
         case 'csv11':
             $sql = SQLtermsXNonPreferedTerms($_SESSION["id_tesa"]);
             break;
             //Comparative report about mapped terms
         //Comparative report about mapped terms
         case 'csv12':
             $sql = SQLreportTargetTerms($_GET["tvocabs"]);
             break;
             //Preferred terms
         //Preferred terms
         case 'csv13':
             $sql = SQLreportTerminosPreferidos();
             break;
             //Terms without note o note type
         //Terms without note o note type
         case 'csv14':
             $sql = SQLreportNullNotes($_GET["note_type_null"]);
             break;
         default:
             break;
     }
     return sql2csv($sql, string2url($_SESSION["CFGTitulo"]) . '.csv', $_GET["csv_encode"]);
 }
Пример #4
0
             } else {
                 $columndef .= 'new cColumn("' . $control->caption . '","' . $column_name . '",null,null),';
             }
         }
     }
 }
 /* Tyler's additions --
 		Here I want to add a section that runs through items, which has the first row as headers, and creates a new array which it will then push out as a CSV download.
 		*/
 if (LANG_CHARSET == 'UTF-8') {
     $file = chr(0xef) . chr(0xbb) . chr(0xbf) . $file;
     // add utf-8 signature to file to open appropriately in Excel, etc...
 } else {
     $file = "";
 }
 $file .= sql2csv($items);
 //CODE FOR LATER CREAATING A TEMP FILE
 $tmpfname = tempnam(getcwd(), "rep");
 // Rig
 $handle = fopen($tmpfname, "w");
 fwrite($handle, $file);
 fclose($handle);
 if (file_exists($tmpfname)) {
     ob_end_clean();
     // This code was lifted from phpMyAdmin, but this is Open Source, right?
     // 'application/octet-stream' is the registered IANA type but
     //        MSIE and Opera seems to prefer 'application/octetstream'
     // It seems that other headers I've added make IE prefer octet-stream again. - RAM
     $mime_type = EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA' ? 'application/octet-stream;' : 'text/comma-separated-values;';
     header('Content-Type: ' . $mime_type . ' charset=' . LANG_CHARSET . "'");
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');