Esempio n. 1
0
function report_csv($module, $name, $values)
{
    $report = get_report($module, $name);
    if ($report === NULL) {
        die;
    }
    $reportRun = $report->run($values);
    ob_clean();
    $output = fopen("php://output", "rb+");
    if (!$report->isGrouping()) {
        fputcsv($output, array("Pastèque", ""), ";");
        $line = $report->getHeaders();
        fputcsv($output, $line, ";");
        while ($line = $reportRun->fetch()) {
            $data = array();
            foreach ($report->getFields() as $field) {
                $data = init_data($report, $data, $line, $field);
            }
            fputcsv($output, $data, ";");
        }
    } else {
        while ($line = $reportRun->fetch()) {
            $data = array();
            if ($reportRun->isGroupEnd()) {
                if ($report->hasSubtotals()) {
                    write_subtotals($output, $report, $reportRun);
                }
                fputcsv($output, array(), ";");
            }
            if ($reportRun->isGroupStart()) {
                fputcsv($output, array($reportRun->getCurrentGroup()), ";");
                fputcsv($output, $report->getHeaders(), ";");
            }
            foreach ($report->getFields() as $field) {
                $data = init_data($report, $data, $line, $field);
            }
            fputcsv($output, $data, ";");
            unset($data);
        }
        if ($report->hasSubtotals()) {
            write_subtotals($output, $report, $reportRun);
            fputcsv($output, array(), ";");
        }
    }
    if ($report->hasTotals()) {
        fputcsv($output, array(\i18n("Total")), ";");
        fputcsv($output, totalHeader($report, $reportRun), ";");
        fputcsv($output, totals($report, $reportRun), ";");
    }
}
fclose(STDERR);
$STDIN = fopen('/dev/null', 'r');
$STDOUT = fopen(dirname(__FILE__) . "/application.log", 'a+');
$STDERR = fopen(dirname(__FILE__) . "/../error.log", 'a+');
$keys = new keys();
$yesterday = date("Y-m-d", strtotime("yesterday"));
$current_time = date("Y-m-d H:i:s", time());
printf("\n%s\n", $yesterday);
$dbconnection = new mysqlconnect();
$dbconnection->connect($dbName);
$mysqli = $dbconnection->connection;
$merchantid = $keys::almerchantid;
$authkey = $keys::alauthkey;
$module = 'MerchantReport';
$reportid = '12';
$report = get_report($authkey, $merchantid, $module, $reportid, $yesterday);
$xml = new simpleXMLElement($report);
$rowcount = count($xml->children());
//print_r($xml->Table1[2]->Sales);
$query = "insert into al_accountstats(accountdate, impressions, clicks, alsales, convertedsales, mobilesales, mobileconversions, commissions, incentives,\n\tnetworkcommissions, adj, newcustomers, newcustomersales, cpcfees, networkcpcfees, totalcommissions) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on duplicate key update \n\taccountdate=values(accountdate), impressions=values(impressions), clicks=values(clicks), alsales=values(alsales), convertedsales=values(convertedsales), mobilesales=values(mobilesales),\n\tmobileconversions=values(mobileconversions), commissions=values(commissions), incentives=values(incentives), networkcommissions=values(networkcommissions), adj=values(adj),\n\tnewcustomers=values(newcustomers), newcustomersales=values(newcustomersales), cpcfees=values(cpcfees), networkcpcfees=values(networkcpcfees), totalcommissions=values(totalcommissions)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("siidididddiidddd", $accountdate, $impressions, $clicks, $alsales, $convertedsales, $mobilesales, $mobileconversions, $commissions, $incentives, $networkcommissions, $adj, $newcustomers, $newscustomersales, $cpcfees, $networkcpcfees, $totalcommissions);
$mysqli->query("start");
for ($i = 0; $i < $rowcount; ++$i) {
    $row = $xml->Table1[$i];
    $date = strtotime($row->Date);
    $accountdate = date('Y-m-d', $date);
    $impressions = (int) str_replace(',', '', $row->Ad_Impressions);
    $clicks = (int) str_replace(',', '', $row->Click_Throughs);
    $alsales = floatval(str_replace(array(',', '$'), '', $row->Sales));
    $convertedsales = $row->Number_of_Sales;
Esempio n. 3
0
function get_module($init_file = false)
{
    $module_name = get_file_module($init_file);
    $module['slug'] = $module_name;
    $module['display_name'] = ucwords(strtolower(str_replace("-", " ", $module_name)));
    $module['name'] = strtolower(str_replace("-", "_", $module_name));
    $module['current_page'] = $_SERVER['PHP_SELF'];
    $module['pages'] = get_module_pages($module_name);
    if (get_report()) {
        exit;
    } else {
        return $module;
    }
}
<?php

require "../settings.php";
$OUTPUT = get_report();
require "../template.php";
function get_report()
{
    extract($_REQUEST);
    db_conn("exten");
    $get_wh = "SELECT * FROM warehouses ORDER BY whname";
    $run_wh = db_exec($get_wh) or errDie("Unable to get warehouses information.");
    if (pg_numrows($run_wh) > 0) {
        $store_from_drop = "<select name='store_from'>";
        $store_from_drop .= "<option value='0'>All Stores</option>";
        $store_to_drop = "<select name='store_to'>";
        $store_to_drop .= "<option value='0'>All Stores</option>";
        while ($sarr = pg_fetch_array($run_wh)) {
            if (isset($store_from) and $store_from == $sarr['whid']) {
                $store_from_drop .= "<option value='{$sarr['whid']}' selected>({$sarr['whno']}) {$sarr['whname']}</option>";
            } else {
                $store_from_drop .= "<option value='{$sarr['whid']}'>({$sarr['whno']}) {$sarr['whname']}</option>";
            }
            if (isset($store_to) and $store_to == $sarr['whid']) {
                $store_to_drop .= "<option value='{$sarr['whid']}' selected>({$sarr['whno']}) {$sarr['whname']}</option>";
            } else {
                $store_to_drop .= "<option value='{$sarr['whid']}'>({$sarr['whno']}) {$sarr['whname']}</option>";
            }
        }
        $store_from_drop .= "</select>";
        $store_to_drop .= "</select>";
    } else {
Esempio n. 5
0
        }
        $query .= " FROM " . $table_name . " WHERE rownum <= ?;";
        //prepare statement
        $statement = odbc_prepare($client->get_connection(), $query);
        if ($statement === false) {
            return $query . "\n\n" . get_odbc_error();
        }
        $items = array();
        $items[] = (int) $rownum;
        $result = odbc_execute($statement, $items);
        if ($result === false) {
            return $query . "\n\n" . get_odbc_error();
        }
        return $statement;
    }
    $result = get_report($client, totally_escape($_POST["target"]), $_POST["show"], $_POST["rownum"]);
    if (is_string($result)) {
        echo "<div class=\"error_message\">" . $result . "</div>";
    } else {
        make_results_table($result, false, null);
    }
} else {
    //show form
    ?>

<div id="form_message" style="display: none;"></div>

<form action="" method="post" class="report_form" id="report_form">
	<p>Compose report of <input type='number' name='rownum' value='50' min='1'/> rows from table
	<select id="report_target" name="target" onchange="show_fields();">
		<option value="">&lt;select table&gt;</option>