Пример #1
0
<?php
header("Content-Type:text/html; charset=utf-8");

//字符串的练习
//将1234567890转换成1,234,567,890 每3位用逗号隔开的形式。
$str = 1234567890;

$str = c1($str);
function c1($str){

	$str = strrev($str);
	$arr = str_split($str, 3);
	echo '<pre>';
	print_r($arr);
	echo '</pre>';
	$str = strrev(implode($arr, ','));

	return $str;
}

echo $str;



?>
function imprimir($index, $i, $titulo, $fibra, $movil)
{
    global $objPHPExcel;
    global $border_style;
    if (!isset($movil['residencial']['S'])) {
        $movil['residencial']['S'] = array();
    }
    if (!isset($movil['residencial']['M'])) {
        $movil['residencial']['M'] = array();
    }
    if (!isset($movil['residencial']['L'])) {
        $movil['residencial']['L'] = array();
    }
    //
    if (!isset($movil['autonomo']['linea 1']['S'])) {
        $movil['autonomo']['linea 1']['S'] = array();
    }
    if (!isset($movil['autonomo']['linea 1']['M'])) {
        $movil['autonomo']['linea 1']['M'] = array();
    }
    if (!isset($movil['autonomo']['linea 1']['L'])) {
        $movil['autonomo']['linea 1']['L'] = array();
    }
    if (!isset($movil['autonomo']['linea 2']['S'])) {
        $movil['autonomo']['linea 2']['S'] = array();
    }
    if (!isset($movil['autonomo']['linea 2']['M'])) {
        $movil['autonomo']['linea 2']['M'] = array();
    }
    if (!isset($movil['autonomo']['linea 2']['L'])) {
        $movil['autonomo']['linea 2']['L'] = array();
    }
    // --------------------------------------------- 300
    if (!isset($fibra['residencial']['2P']['300MB'])) {
        $fibra['residencial']['2P']['300MB'] = array();
    }
    if (!isset($fibra['residencial']['3P']['300MB'])) {
        $fibra['residencial']['3P']['300MB'] = array();
    }
    //
    if (!isset($fibra['autonomo']['fibra']['300MB']['Alta Nueva'])) {
        $fibra['autonomo']['fibra']['300MB']['Alta Nueva'] = array();
    }
    if (!isset($fibra['autonomo']['fibra']['300MB']['Portabilidad'])) {
        $fibra['autonomo']['fibra']['300MB']['Portabilidad'] = array();
    }
    // ----------------------------------------- 120
    if (!isset($fibra['residencial']['2P']['120MB'])) {
        $fibra['residencial']['2P']['120MB'] = array();
    }
    if (!isset($fibra['residencial']['3P']['120MB'])) {
        $fibra['residencial']['3P']['120MB'] = array();
    }
    //
    if (!isset($fibra['autonomo']['fibra']['120MB']['Alta Nueva'])) {
        $fibra['autonomo']['fibra']['120MB']['Alta Nueva'] = array();
    }
    if (!isset($fibra['autonomo']['fibra']['120MB']['Portabilidad'])) {
        $fibra['autonomo']['fibra']['120MB']['Portabilidad'] = array();
    }
    // ----------------------------------------- 50
    if (!isset($fibra['residencial']['2P']['50MB'])) {
        $fibra['residencial']['2P']['50MB'] = array();
    }
    if (!isset($fibra['residencial']['3P']['50MB'])) {
        $fibra['residencial']['3P']['50MB'] = array();
    }
    //
    if (!isset($fibra['autonomo']['fibra']['50MB']['Alta Nueva'])) {
        $fibra['autonomo']['fibra']['50MB']['Alta Nueva'] = array();
    }
    if (!isset($fibra['autonomo']['fibra']['50MB']['Portabilidad'])) {
        $fibra['autonomo']['fibra']['50MB']['Portabilidad'] = array();
    }
    // ----------------------------------------- adsl
    if (!isset($fibra['residencial']['2P']['adsl'])) {
        $fibra['residencial']['2P']['adsl'] = array();
    }
    if (!isset($fibra['residencial']['3P']['adsl'])) {
        $fibra['residencial']['3P']['adsl'] = array();
    }
    //
    if (!isset($fibra['autonomo']['adsl']['Alta Nueva'])) {
        $fibra['autonomo']['adsl']['Alta Nueva'] = array();
    }
    if (!isset($fibra['autonomo']['adsl']['Portabilidad'])) {
        $fibra['autonomo']['adsl']['Portabilidad'] = array();
    }
    // ------------------------------------------ TOTAL
    $total_1 = count($fibra['residencial']['2P']['300MB']) + count($fibra['residencial']['2P']['120MB']) + count($fibra['residencial']['2P']['50MB']) + count($fibra['residencial']['3P']['300MB']) + count($fibra['residencial']['3P']['120MB']) + count($fibra['residencial']['3P']['50MB']);
    $total_2 = count($movil['residencial']['S']) + count($movil['residencial']['M']) + count($movil['residencial']['L']);
    $total_3 = count($fibra['autonomo']['fibra']['300MB']['Alta Nueva']) + count($fibra['autonomo']['fibra']['300MB']['Portabilidad']) + count($fibra['autonomo']['fibra']['120MB']['Alta Nueva']) + count($fibra['autonomo']['fibra']['120MB']['Portabilidad']) + count($fibra['autonomo']['fibra']['50MB']['Alta Nueva']) + count($fibra['autonomo']['fibra']['50MB']['Portabilidad']) + count($fibra['autonomo']['adsl']['Alta Nueva']) + count($fibra['autonomo']['adsl']['Portabilidad']);
    $total_4 = count($movil['autonomo']['linea 1']['S']) + count($movil['autonomo']['linea 1']['M']) + count($movil['autonomo']['linea 1']['L']) + count($movil['autonomo']['linea 2']['S']) + count($movil['autonomo']['linea 2']['M']) + count($movil['autonomo']['linea 2']['L']);
    $total_5 = $total_1 + $total_3;
    $total_6 = $total_2 + $total_4;
    $objPHPExcel->getActiveSheet()->getStyle(c2(1, 34, $i, $i + 3))->applyFromArray($border_style);
    $objPHPExcel->setActiveSheetIndex($index)->setCellValue(c1(1, $i), $titulo)->mergeCells(c2(1, 1, $i, $i + 3))->setCellValue(c1(2, $i), 'Fibra 300MB')->setCellValue(c1(3, $i), count($fibra['residencial']['2P']['300MB']))->setCellValue(c1(4, $i), '')->setCellValue(c1(5, $i), count($fibra['residencial']['3P']['300MB']))->setCellValue(c1(6, $i), '')->setCellValue(c1(7, $i), $total_1)->mergeCells(c2(7, 7, $i, $i + 3))->setCellValue(c1(8, $i), count($movil['residencial']['S']))->mergeCells(c2(8, 8, $i, $i + 3))->setCellValue(c1(9, $i), '')->mergeCells(c2(9, 9, $i, $i + 3))->setCellValue(c1(10, $i), count($movil['residencial']['M']))->mergeCells(c2(10, 10, $i, $i + 3))->setCellValue(c1(11, $i), '')->mergeCells(c2(11, 11, $i, $i + 3))->setCellValue(c1(12, $i), count($movil['residencial']['L']))->mergeCells(c2(12, 12, $i, $i + 3))->setCellValue(c1(13, $i), '')->mergeCells(c2(13, 13, $i, $i + 3))->setCellValue(c1(14, $i), $total_2)->mergeCells(c2(14, 14, $i, $i + 3))->setCellValue(c1(15, $i), count($fibra['autonomo']['fibra']['300MB']['Alta Nueva']))->setCellValue(c1(16, $i), '')->setCellValue(c1(17, $i), count($fibra['autonomo']['fibra']['300MB']['Portabilidad']))->setCellValue(c1(18, $i), '')->setCellValue(c1(19, $i), $total_3)->mergeCells(c2(19, 19, $i, $i + 3))->setCellValue(c1(20, $i), count($movil['autonomo']['linea 1']['S']))->mergeCells(c2(20, 20, $i, $i + 3))->setCellValue(c1(21, $i), '')->mergeCells(c2(21, 21, $i, $i + 3))->setCellValue(c1(22, $i), count($movil['autonomo']['linea 1']['M']))->mergeCells(c2(22, 22, $i, $i + 3))->setCellValue(c1(23, $i), '')->mergeCells(c2(23, 23, $i, $i + 3))->setCellValue(c1(24, $i), count($movil['autonomo']['linea 1']['L']))->mergeCells(c2(24, 24, $i, $i + 3))->setCellValue(c1(25, $i), '')->mergeCells(c2(25, 25, $i, $i + 3))->setCellValue(c1(26, $i), count($movil['autonomo']['linea 2']['S']))->mergeCells(c2(26, 26, $i, $i + 3))->setCellValue(c1(27, $i), '')->mergeCells(c2(27, 27, $i, $i + 3))->setCellValue(c1(28, $i), count($movil['autonomo']['linea 2']['M']))->mergeCells(c2(28, 28, $i, $i + 3))->setCellValue(c1(29, $i), '')->mergeCells(c2(29, 29, $i, $i + 3))->setCellValue(c1(30, $i), count($movil['autonomo']['linea 1']['L']))->mergeCells(c2(30, 30, $i, $i + 3))->setCellValue(c1(31, $i), '')->mergeCells(c2(31, 31, $i, $i + 3))->setCellValue(c1(32, $i), $total_4)->mergeCells(c2(32, 32, $i, $i + 3))->setCellValue(c1(33, $i), $total_5)->mergeCells(c2(33, 33, $i, $i + 3))->setCellValue(c1(34, $i), $total_6)->mergeCells(c2(34, 34, $i, $i + 3))->setCellValue(c1(2, $i + 1), 'Fibra 120MB')->setCellValue(c1(3, $i + 1), count($fibra['residencial']['2P']['120MB']))->setCellValue(c1(4, $i + 1), '')->setCellValue(c1(5, $i + 1), count($fibra['residencial']['3P']['120MB']))->setCellValue(c1(6, $i + 1), '')->setCellValue(c1(15, $i + 1), count($fibra['autonomo']['fibra']['120MB']['Alta Nueva']))->setCellValue(c1(16, $i + 1), '')->setCellValue(c1(17, $i + 1), count($fibra['autonomo']['fibra']['120MB']['Portabilidad']))->setCellValue(c1(18, $i + 1), '')->setCellValue(c1(2, $i + 2), 'Fibra 50MB')->setCellValue(c1(3, $i + 2), count($fibra['residencial']['2P']['50MB']))->setCellValue(c1(4, $i + 2), '')->setCellValue(c1(5, $i + 2), count($fibra['residencial']['3P']['50MB']))->setCellValue(c1(6, $i + 2), '')->setCellValue(c1(15, $i + 2), count($fibra['autonomo']['fibra']['50MB']['Alta Nueva']))->setCellValue(c1(16, $i + 2), '')->setCellValue(c1(17, $i + 2), count($fibra['autonomo']['fibra']['50MB']['Portabilidad']))->setCellValue(c1(18, $i + 2), '')->setCellValue(c1(2, $i + 3), 'ADSL')->setCellValue(c1(3, $i + 3), count($fibra['residencial']['2P']['adsl']))->setCellValue(c1(4, $i + 3), '')->setCellValue(c1(5, $i + 3), count($fibra['residencial']['3P']['adsl']))->setCellValue(c1(6, $i + 3), '')->setCellValue(c1(15, $i + 3), count($fibra['autonomo']['adsl']['Alta Nueva']))->setCellValue(c1(16, $i + 3), '')->setCellValue(c1(17, $i + 3), count($fibra['autonomo']['adsl']['Portabilidad']))->setCellValue(c1(18, $i + 3), '');
}
Пример #3
0
function c4()
{
    c1();
}
Пример #4
0
<?php

if (c1()) {
    f1();
} else {
    f2();
}
if (c2()) {
    f3();
} else {
    f4();
}
Пример #5
0
    for ($j = 0; $row2 = @pg_fetch_assoc($rs2, $j); $j++) {
        if ($ostation != $row2["station"]) {
            if ($stfound > 0 && $stfound % 3 == 0) {
                $table .= "</td></tr>";
                $ostation = "";
            }
            if ($ostation == "") {
                $table .= "<tr><td valign='top'>";
            } else {
                $table .= "</td><td valign='top'>";
            }
            $ostation = $row2["station"];
            $stfound += 1;
            $table .= sprintf("<u>UGC Code: %s</u><br/>", $station2ugc[$row2["station"]]);
        }
        $table .= sprintf("%s %sZ %s/%.0f %s %s %s%s<br>", $row2["station"], $row2["z"], c4($row2["tmpf"]), $row2["dwpf"], c1(relh(f2c($row2["tmpf"]), f2c($row2["dwpf"]))), c3($row2["vsby"]), c2($row2["sknt"], $row2["gust"]), c5($row2["wcht"]));
    }
    $table .= "</td></tr></table>";
}
$t->content = <<<EOF
  <h2>NWS Watch/Warning/Advisory + ASOS Observations</h2>
  
  <p>This app allows you to view an office's warnings for a year and
  then looks for ASOS/AWOS observations valid for the warning period. The observations
  presented are coded like:
  <br />ID DDHHMI TMPF/DWPF RELH VSBY SKNT/GUST WC WINDCHILL
  <br />Where ID is the station identifier, DDHHMI is the day-hour-minute of the
  observation in UTC, TMPF is the air temperature in Fahrenheit, DWPF is the
  dew point temperature in Fahrenheit, RELH is the relative humidity, VSBY is
  the visibility, SKNT is the wind speed in knots and GUST is the wind gust in knots. 
  The wind chill is displayed when the temperature is below 32&deg;F.
function imprimir_rangos_asesores_ventas()
{
    global $objPHPExcel;
    global $border_style;
    $objPHPExcel->setActiveSheetIndex(2);
    // border
    $objPHPExcel->getActiveSheet()->getStyle(c2(1, 6, 1, 22))->applyFromArray($border_style);
    $objPHPExcel->getActiveSheet()->getStyle(c2(8, 10, 1, 22))->applyFromArray($border_style);
    // colores
    $objPHPExcel->setActiveSheetIndex(2)->getStyle(c2(1, 6, 1, 2))->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFFFE00');
    // amarillo
    $objPHPExcel->setActiveSheetIndex(2)->getStyle(c2(8, 10, 1, 2))->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFFFE00');
    // amarillo
    // formatos
    $formato2 = '[$S/-280A]#,##0.00;[$S/-280A]-#,##0.00';
    $objPHPExcel->getActiveSheet()->getStyle(c2(3, 3, 1, 22))->getNumberFormat()->setFormatCode($formato2);
    $objPHPExcel->getActiveSheet()->getStyle(c2(4, 4, 1, 22))->getNumberFormat()->setFormatCode($formato2);
    $objPHPExcel->getActiveSheet()->getStyle(c2(5, 5, 1, 22))->getNumberFormat()->setFormatCode($formato2);
    $objPHPExcel->getActiveSheet()->getStyle(c2(6, 6, 1, 22))->getNumberFormat()->setFormatCode($formato2);
    $objPHPExcel->getActiveSheet()->getStyle(c2(10, 10, 1, 22))->getNumberFormat()->setFormatCode($formato2);
    // datos
    $objPHPExcel->setActiveSheetIndex(2)->setCellValue(c1(1, 1), '')->mergeCells(c2(1, 6, 1, 1))->setCellValue(c1(8, 1), 'LINEAS')->mergeCells(c2(8, 10, 1, 1))->setCellValue(c1(1, 2), 'MAYOR IGUAL')->setCellValue(c1(2, 2), 'MENOR')->setCellValue(c1(3, 2), '300MB')->setCellValue(c1(4, 2), '120MB')->setCellValue(c1(5, 2), '50MB')->setCellValue(c1(6, 2), 'ADSL')->setCellValue(c1(8, 2), 'MAYOR IGUAL')->setCellValue(c1(9, 2), 'MENOR')->setCellValue(c1(10, 2), 'MONTO')->setCellValue(c1(1, 22), '0')->setCellValue(c1(2, 22), '∞')->setCellValue(c1(3, 22), '0')->setCellValue(c1(4, 22), '0')->setCellValue(c1(5, 22), '0')->setCellValue(c1(6, 22), '0')->setCellValue(c1(8, 22), '0')->setCellValue(c1(9, 22), '∞')->setCellValue(c1(10, 22), '0');
}