Пример #1
0
    exit;
}
if (isset($_GET["report-js"])) {
    report_js();
    exit;
}
if (isset($_GET["report-tab"])) {
    report_tab();
    exit;
}
if (isset($_GET["report-popup"])) {
    report_popup();
    exit;
}
if (isset($_GET["report-options"])) {
    report_options();
    exit;
}
if (isset($_POST["report"])) {
    report_save();
    exit;
}
if (isset($_POST["run"])) {
    report_run();
    exit;
}
if (isset($_POST["csv"])) {
    save_options_save();
    exit;
}
if (isset($_GET["csv"])) {
Пример #2
0
        case 'sale':
            echo '.col_a:not(.col_s) {display: none;} .col_l:not(.col_s) {display: none;}';
            break;
        case 'lead':
            echo '.col_a:not(.col_l) {display: none;} .col_s:not(.col_l) {display: none;}';
            break;
    }
    ?>
</style>
<?php 
}
// ---------------------------------------
switch ($_REQUEST['type']) {
    case 'basic':
        // Параметры отчёта
        $params = report_options();
        //$params['where'] = "`is_connected` = '0'"; // только лэндинги
        //$params['mode'] = 'lp';
        if ($params['mode'] == 'popular') {
            $params['mode'] = 'popular';
            $assign['report_name'] = 'Популярные параметры за ';
            $assign['report_params'] = $params;
            $assign['timestep'] = $params['part'] == 'month' ? 'monthly' : 'daily';
            $report = get_clicks_report_grouped2($params);
            $assign['click_params'] = $report['click_params'];
            $assign['arr_report_data'] = $report['data'];
            $assign['arr_dates'] = $report['dates'];
            // Заголовок отчета
            echo tpx('report_name', $assign);
            // Фильтры конвертации
            //echo tpx('report_conv', $assign);
function export_display($_POST)
{
    # get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($fday, "num", 1, 2, "Invalid from Date day.");
    $v->isOk($fmon, "num", 1, 2, "Invalid from Date month.");
    $v->isOk($fyear, "num", 1, 4, "Invalid from Date Year.");
    $v->isOk($today, "num", 1, 2, "Invalid to Date day.");
    $v->isOk($tomon, "num", 1, 2, "Invalid to Date month.");
    $v->isOk($toyear, "num", 1, 4, "Invalid to Date Year.");
    # mix dates
    $fromdate = $fyear . "-" . $fmon . "-" . $fday;
    $todate = $toyear . "-" . $tomon . "-" . $today;
    if (!checkdate($fmon, $fday, $fyear)) {
        $v->isOk($fromdate, "num", 1, 1, "Invalid from date.");
    }
    if (!checkdate($tomon, $today, $toyear)) {
        $v->isOk($todate, "num", 1, 1, "Invalid to date.");
    }
    if ($fromdate > $todate) {
        $v->isOk($todate, "num", 1, 1, "The From date cannot be bigger than the To date!");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>-" . $e["msg"] . "</li>";
        }
        return $confirm . report_options();
    }
    if ($sp != "0") {
        $Whe = " WHERE salesp='{$sp}'";
    } else {
        $Whe = "WHERE 1 = 1";
    }
    $ComRep = "\n\t\t<h3>Commission Report {$fromdate} TO {$todate}</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Inv</th>\n\t\t\t\t<th>Invoice Date</th>\n\t\t\t\t<th>VAT Excl. Invoice Amount</th>\n\t\t\t\t<th>Commission</th>\n\t\t\t</tr>";
    db_conn("exten");
    $i = 0;
    $total_amount = 0;
    $total_com = 0;
    $Sl = "SELECT salespid,salesp FROM salespeople {$Whe} AND div = '" . USER_DIV . "' ORDER BY salesp ASC";
    $RsSr = db_exec($Sl) or errDie("Unable to retrieve Sales People from database.");
    if (pg_numrows($RsSr) < 1) {
        return "<li>There are no Sales People in Cubit.</li>";
    }
    db_conn("cubit");
    while ($SalesReps = pg_fetch_array($RsSr)) {
        // 		$Sl = "SELECT SUM(com) as amount FROM coms_invoices WHERE invdate >= '$fromdate' AND invdate <= '$todate' AND rep='$SalesReps[salesp]' ";
        // 		$Rs = db_exec ($Sl) or errDie ("Unable to retrieve Sales People from database.");
        // 		$Tp = pg_fetch_array($Rs);
        // 		$Tp['amount'] =sprint($Tp['amount']);
        $ComRep .= "\n\t\t\t<tr>\n\t\t\t\t<td><b>{$SalesReps['salesp']}</b></td>\n\t\t\t\t<td colspan='2'></td>\n\t\t\t\t<td align='right'></td>\n\t\t\t</tr>";
        $Sl = "SELECT * FROM coms_invoices WHERE invdate >= '{$fromdate}' AND invdate <= '{$todate}' AND rep='{$SalesReps['salesp']}'";
        $Rx = db_exec($Sl) or errDie(" Unable to get invoices from db.");
        $rep_com = 0;
        $rep_amount = 0;
        while ($inv = pg_fetch_array($Rx)) {
            $ComRep .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$inv['inv']}</td>\n\t\t\t\t\t<td>{$inv['invdate']}</td>\n\t\t\t\t\t<td align='right'>" . CUR . " {$inv['amount']}</td>\n\t\t\t\t\t<td align='right'>" . CUR . " {$inv['com']}</td>\n\t\t\t\t</tr>";
            $rep_com += sprint($inv['com']);
            $rep_amount += sprint($inv['amount']);
        }
        $ComRep .= "\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td><b>Total:</b></td>\n\t\t\t\t<td align='right'><b>" . CUR . " " . sprint($rep_amount) . "</b></td>\n\t\t\t\t<td align='right'><b>" . CUR . " " . sprint($rep_com) . "</b></td>\n\t\t\t</tr>";
        $ComRep .= "<tr><td><br></td></tr>";
        $i++;
        $total_amount += $rep_amount;
        $total_com += $rep_com;
    }
    $total = sprint($total);
    $ComRep .= "\n\t\t<tr>\n\t\t\t<td>Total Reps: {$i}</td>\n\t\t\t<td align='right' colspan='2'>" . CUR . " {$total_amount}</td>\n\t\t\t<td align='right'>" . CUR . " {$total_com}</td>\n\t\t</tr>";
    $ComRep .= "</table>";
    $OUTPUT = $ComRep;
    include "xls/temp.xls.php";
    Stream("Report", $OUTPUT);
    return $ComRep;
}