示例#1
0
文件: reorder.php 项目: jacques/scat
<style>
.order { text-align: right; }
</style>
<button id="download" class="btn btn-default">Download</button>
<?php 
if ($vendor) {
    ?>
  <button id="create" class="btn btn-default">Create Order</button>
<?php 
}
?>
<button id="zero" class="btn btn-default">Zero</button>
<?php 
$q = "SELECT item.id meta,\n            code Code\$item,\n            name Name,\n            SUM(allocated) Stock\$right,\n            minimum_quantity Min\$right,\n            (SELECT -1 * SUM(allocated)\n               FROM txn_line JOIN txn ON (txn = txn.id)\n              WHERE type = 'customer'\n                AND item = item.id AND filled > NOW() - INTERVAL 3 MONTH)\n            AS Last3Months\$right,\n            (SELECT SUM(ordered - allocated)\n               FROM txn_line JOIN txn ON (txn = txn.id)\n              WHERE type = 'vendor'\n                AND item = item.id AND created > NOW() - INTERVAL 3 MONTH)\n            AS Ordered\$hide,\n            minimum_quantity AS Order\$order\n       FROM item\n       LEFT JOIN txn_line ON (item = item.id)\n      WHERE active AND NOT deleted\n        AND code NOT LIKE 'ZZ%' AND code NOT LIKE 'MAG-%'\n        {$extra}\n      GROUP BY item.id\n     HAVING (Stock\$right IS NULL OR NOT Stock\$right OR Stock\$right < Min\$right)\n        AND (Ordered\$hide IS NULL OR NOT Ordered\$hide)\n      ORDER BY code\n      ";
dump_table($db->query($q));
dump_query($q);
?>
<form id="post-csv" style="display: none"
      method="post" action="api/encode-tsv.php">
<textarea id="file" name="file"></textarea>
</form>
<script>
$('.order').editable(function (val, settings) { return val; },
                     { width: '3em', select: true });

$('#download').on('click', function(ev) {
  var tsv= "code\tqty\r\n";
  $.each($(".sortable tr"), function (i, row) {
    if (i > 0 && parseInt($('.order', row).text()) > 0) {
      tsv += $('.item a', row).text() + "\t" + $('.order', row).text() + "\r\n";
    }
示例#2
0
            } else {
                $strOutput .= "host=" . $Gdbhost . " user="******" pass="******" name=" . $Gdbname . "</td></tr><tr><td>" . display_tables($Gdbhost, $Gdbuser, $Gdbpass, $Gdbname);
            }
        }
    }
    $strOutput .= "</pre></td></tr></table><br/>";
}
if (isset($dbH)) {
    $strOutput .= "<table border=1><tr><td><b>mysql access</b></td></tr><tr><td>";
    if ($dbn == "") {
        $strOutput .= "host=" . $dbH . " user="******" pass="******"</td></tr><tr><td>" . display_dbs($dbH, $dbu, $dbp);
    } else {
        if (isset($dbs)) {
            $strOutput .= "host=" . $dbH . " user="******" pass="******" name=" . $dbn . "<br/>sql=" . $dbs . "</td></tr><tr><td>";
            if (isset($dumpfile)) {
                $strOutput .= dump_query($dbH, $dbu, $dbp, $dbn, $dbs, $dumpfile);
            } else {
                $strOutput .= display_query($dbH, $dbu, $dbp, $dbn, $dbs);
            }
        } else {
            if (isset($dbt)) {
                $strOutput .= "host=" . $dbH . " user="******" pass="******" name=" . $dbn . " table=" . $dbt;
                if ($dumpfile != "") {
                    $strOutput .= " dumpfile=" . $dumpfile;
                }
                $strOutput .= "</td></tr><tr><td> ";
                if (isset($dumpfile)) {
                    $strOutput .= dump_rows($dbH, $dbu, $dbp, $dbn, $dbt, $dumpfile);
                } else {
                    $strOutput .= display_rows($dbH, $dbu, $dbp, $dbn, $dbt);
                }