// NOTE: Simply uncomment your desired supplement discount day.
// $discount_day = "Sunday";
$discount_day = "Monday";
// $discount_day = "Tuesday";
// $discount_day = "Wednesday";
// $discount_day = "Thursday";
// $discount_day = "Friday";
// $discount_day = "Saturday";
// ************************************
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
$today = date('l');
$dday = date_create($discount_day);
date_add($dday, date_interval_create_from_date_string('1 days'));
$discount_day_after = date_format($dday, 'l');
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
if ($today == $discount_day) {
    $sql->query("INSERT INTO autoCoupons VALUES(999,'Supplement Discount')");
    echo cron_msg("It's {$discount_day}. Supplement discount applied.");
} elseif ($today == $discount_day_after) {
    $sql->query("DELETE FROM autoCoupons WHERE coupID = 999");
    echo cron_msg("It's {$discount_day_after}.  Supplement discount removed.");
} else {
    echo cron_msg("No discounts to apply.");
}
Esempio n. 2
0
while ($row = $sql->fetch_row($checkR)) {
    $done_oids[] = (int) $row['order_id'];
}
$todo = array_diff($order_ids, $done_oids);
echo cron_msg("Found " . count($todo) . " new order headers");
if (count($todo) > 0) {
    $copy_oids = "(";
    foreach ($todo as $o) {
        $copy_oids .= $o . ",";
    }
    $copy_oids = rtrim($copy_oids, ",") . ")";
    //echo "Headers: ".$copy_oids."\n";
    $copyQ = "INSERT INTO CompleteSpecialOrder SELECT * FROM PendingSpecialOrder\n        WHERE trans_id=0 AND order_id IN {$copy_oids}";
    $copyR = $sql->query($copyQ);
}
// remove "empty" orders from pending
$cleanupQ = sprintf("\n    SELECT p.order_id \n    FROM PendingSpecialOrder AS p \n        LEFT JOIN SpecialOrders AS o ON p.order_id=o.specialOrderID\n    WHERE \n        (\n            o.specialOrderID IS NULL\n            OR %s(o.notes)=0\n        )\n        OR p.order_id IN (\n            SELECT order_id FROM CompleteSpecialOrder\n            WHERE trans_id=0\n            GROUP BY order_id\n        )\n    GROUP BY p.order_id\n    HAVING MAX(trans_id)=0", $FANNIE_SERVER_DBMS == "MSSQL" ? 'datalength' : 'length');
$cleanupR = $sql->query($cleanupQ);
$empty = "(";
$clean = 0;
while ($row = $sql->fetch_row($cleanupR)) {
    $empty .= $row['order_id'] . ",";
    $clean++;
}
$empty = rtrim($empty, ",") . ")";
echo cron_msg("Finishing {$clean} orders");
if (strlen($empty) > 2) {
    //echo "Empties: ".$empty."\n";
    $delQ = "DELETE FROM PendingSpecialOrder WHERE order_id IN {$empty} AND trans_id=0";
    $delR = $sql->query($delQ);
}
Esempio n. 3
0
    in the file license.txt along with IT CORE; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*********************************************************************************/
/* HELP

   nightly.voidhistory.php

   Updates voidTransHistory to include voided
   transactions from the previous day.

   Should be run after midnight & after
   dtransactions is rotated

*/
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_TRANS_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$query = "INSERT INTO voidTransHistory\n    SELECT datetime,description,\n    " . $sql->concat($sql->convert('emp_no', 'char'), "'-'", $sql->convert('register_no', 'char'), "'-'", $sql->convert('trans_no', 'char'), '') . ",\n    0\n    FROM transarchive WHERE trans_subtype='CM'\n    AND " . $sql->datediff('datetime', $sql->now()) . " = -1\n    AND description LIKE 'VOIDING TRANSACTION %-%-%'\n    AND register_no <> 99 AND emp_no <> 9999 AND trans_status <> 'X'";
$success = $sql->query($query);
if ($success) {
    echo cron_msg("Voids logged");
} else {
    echo cron_msg("Error logging voids");
}
Esempio n. 4
0
    echo cron_msg("Failed: {$fetchQ}");
    return;
}
while ($fetchW = $sql->fetch_row($fetchR)) {
    $data[$fetchW['CardNo']] = $fetchW['balance'];
}
$errors = False;
// connect to each lane and update balances
foreach ($FANNIE_LANES as $lane) {
    $db = new SQLManager($lane['host'], $lane['type'], $lane['op'], $lane['user'], $lane['pw']);
    if ($db === False) {
        echo cron_msg("Can't connect to lane: " . $lane['host']);
        $errors = True;
        continue;
    }
    foreach ($data as $cn => $bal) {
        $upQ = sprintf("UPDATE custdata SET Balance=%.2f WHERE CardNo=%d", $bal, $cn);
        $rslt = $db->query($upQ);
        if ($rslt === False) {
            echo cron_msg("Update of member: {$cn} on lane: {$lane['host']} failed.");
            $errors = True;
        }
    }
}
if ($errors) {
    echo cron_msg("There was an error pushing balances to the lanes.");
    flush();
} else {
    //echo cron_msg("All OK.");
    $a = 0;
}
Esempio n. 5
0
    BEFORE nightly.virtualCoupons) to work as intended.  
    And don't forget to push to lanes overnight!
*/
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$TRANS = $FANNIE_SERVER_DBMS == "MSSQL" ? $FANNIE_TRANS_DB . ".dbo." : $FANNIE_TRANS_DB . ".";
// clear out houseVirtualCoupons
$sql->query("TRUNCATE TABLE houseVirtualCoupons");
echo cron_msg("Truncate table houseVirtualCoupons<br />");
// re-populate houseVirtualCoupons
$insQ = "INSERT INTO houseVirtualCoupons (card_no,coupID,description,start_date,end_date) \n    SELECT c.CardNo, '00001', 'Owner Appreciation 10% Discount', DATE_FORMAT(NOW() ,'%Y-%m-01 00:00:00'), \n    CONCAT(LAST_DAY(NOW()),' 23:59:59') FROM custdata AS c WHERE c.memType <> 0";
$insR = $sql->query($insQ);
echo cron_msg("Re-populate houseVirtualCoupons");
// set custdata.memcoupons equal to the number
// of available coupons (in theory)
$sql->query("UPDATE custdata SET memCoupons = 0");
// set memCoupons = 0 first
$upQ = "UPDATE custdata AS c, houseVirtualCoupons AS h\n    SET c.memCoupons=1\n    WHERE c.CardNo=h.card_no \n    AND " . $sql->now() . " >= h.start_date \n    AND " . $sql->now() . "<= h.end_date\n    AND c.memType <> 0";
$sql->query($upQ);
// update blueline to match memcoupons
$blueLineQ = "UPDATE custdata SET blueLine=" . $sql->concat($sql->convert('CardNo', 'CHAR'), "' '", 'LastName', "' Coup('", $sql->convert('memCoupons', 'CHAR'), "')'", '') . "WHERE memType <> 0";
$sql->query($blueLineQ);
echo cron_msg("Updated values in core_op.custdata");
Esempio n. 6
0
   This script truncates the table batchCutPaste. This table
   acts as a clipboard so users can cut/paste items from
   on sales batch to another. The table must be truncated
   periodically or old data will linger indefinitely.   

   It also clears stale, deleted shelftags from the
   shelftags table. Entries hang around with a negative
   id for recovery in the case of mistakes.
*/
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$chk = $sql->query("TRUNCATE TABLE batchCutPaste");
if ($chk === false) {
    echo cron_msg("Error clearing batch clipboard");
} else {
    echo cron_msg("Cleared batch clipboard");
}
$chk2 = $sql->query("DELETE FROM shelftags WHERE id < 0");
if ($chk2 === false) {
    echo cron_msg("Error clearing deleted sheltags");
} else {
    echo cron_msg("Cleared deleted shelftags");
}
Esempio n. 7
0
    echo cron_msg("Failed: {$fetchQ}");
    return;
}
while ($fetchW = $sql->fetch_row($fetchR)) {
    $data[$fetchW['card_no']] = $fetchW['recent_payments'];
}
$errors = False;
// connect to each lane and update payments
foreach ($FANNIE_LANES as $lane) {
    $db = new SQLManager($lane['host'], $lane['type'], $lane['op'], $lane['user'], $lane['pw']);
    if ($db === False) {
        echo cron_msg("Can't connect to lane: " . $lane['host']);
        $errors = True;
        continue;
    }
    foreach ($data as $cn => $payment) {
        $upQ = sprintf("UPDATE unpaid_ar_today SET recent_payments=%.2f WHERE card_no=%d", $payment, $cn);
        $rslt = $db->query($upQ);
        if ($rslt === False) {
            echo cron_msg("Update of member: {$cn} on lane: {$lane['host']} failed.");
            $errors = True;
        }
    }
}
if ($errors) {
    echo cron_msg("There was an error pushing unpaid AR info to the lanes.");
    flush();
} else {
    //echo cron_msg("All OK.");
    $a = 0;
}
Esempio n. 8
0
function createViews($dstr, $db)
{
    global $FANNIE_SERVER_DBMS, $FANNIE_ARCHIVE_REMOTE, $FANNIE_ARCHIVE_DBMS, $FANNIE_ARCHIVE_DB, $FANNIE_SERVER, $FANNIE_SERVER_PW, $FANNIE_SERVER_USER, $FANNIE_ARCHIVE_SERVER, $FANNIE_ARCHIVE_USER, $FANNIE_ARCHIVE_PW;
    if ($FANNIE_ARCHIVE_REMOTE) {
        $db->add_connection($FANNIE_ARCHIVE_SERVER, $FANNIE_ARCHIVE_DBMS, $FANNIE_ARCHIVE_DB, $FANNIE_ARCHIVE_USER, $FANNIE_ARCHIVE_PW);
    } else {
        $db->add_connection($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_ARCHIVE_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
    }
    $dbms = $FANNIE_ARCHIVE_REMOTE ? $FANNIE_ARCHIVE_DBMS : $FANNIE_SERVER_DBMS;
    $table_def = $db->table_definition('transArchive' . $str);
    $dlogQ = "CREATE  view dlog{$dstr} as\n        select \n        d.datetime as tdate, \n        d.register_no, \n        d.emp_no, \n        d.trans_no, \n        d.upc, \n        d.description,\n        CASE WHEN (d.trans_subtype IN ('CP','IC') OR d.upc like('%000000052')) then 'T' \n            WHEN d.upc = 'DISCOUNT' then 'S' else d.trans_type end as trans_type, \n        CASE WHEN d.upc = 'MAD Coupon' THEN 'MA' ELSe \n           case when d.upc like('%00000000052') then 'RR' else d.trans_subtype end end as trans_subtype, \n        d.trans_status, \n        d.department, \n        d.quantity, \n        d.scale,\n        d.cost,\n        d.unitPrice, \n        d.total, \n        d.regPrice,\n        d.tax, \n        d.foodstamp, \n        d.discount,\n        d.memDiscount,\n        d.discountable,\n        d.discounttype,\n        d.voided,\n        d.percentDiscount,\n        d.itemQtty, \n        d.memType,\n        d.volDiscType,\n        d.volume,\n        d.VolSpecial,\n        d.mixMatch,\n        d.matched,\n        d.staff,\n        d.numflag,\n        d.charflag,\n        d.card_no, \n        d.trans_id, ";
    if (isset($table_def['pos_row_id'])) {
        $dlogQ .= "d.pos_row_id,";
    }
    if (isset($table_def['store_row_id'])) {
        $dlogQ .= "d.store_row_id,";
    }
    $dlogQ .= "concat(convert(d.emp_no,char), '-', convert(d.register_no,char), '-',\n        convert(d.trans_no,char)) as trans_num\n\n        from transArchive{$dstr} as d\n        where d.trans_status not in ('D','X','Z') and d.emp_no not in (9999,56) and d.register_no  <> 99";
    if ($dbms == "MSSQL") {
        $dlogQ = "CREATE  view dlog{$dstr} as\n            select \n            d.datetime as tdate, \n            d.register_no, \n            d.emp_no, \n            d.trans_no, \n            d.upc, \n            d.description,\n            CASE WHEN (d.trans_subtype IN ('CP','IC') OR d.upc like('%000000052')) then 'T' \n                WHEN d.upc = 'DISCOUNT' then 'S' else d.trans_type end as trans_type, \n            CASE WHEN d.upc = 'MAD Coupon' THEN 'MA' ELSe \n               case when d.upc like('%00000000052') then 'RR' else d.trans_subtype end end as trans_subtype, \n            d.trans_status, \n            d.department, \n            d.quantity, \n            c.scale,\n            d.cost,\n            d.unitPrice, \n            d.total, \n            d.regPrice,\n            d.tax, \n            d.foodstamp, \n            d.discount,\n            d.memDiscount,\n            d.discountable,\n            d.discounttype,\n            d.voided,\n            d.percentDiscount,\n            d.itemQtty, \n            d.volDiscType,\n            d.volume,\n            d.VolSpecial,\n            d.mixMatch,\n            d.matched,\n            d.memType,\n            d.isStaff,\n            d.numflag,\n            d.charflag,\n            d.card_no, \n            d.trans_id,";
        if (isset($table_def['pos_row_id'])) {
            $dlogQ .= "d.pos_row_id,";
        }
        if (isset($table_def['store_row_id'])) {
            $dlogQ .= "d.store_row_id,";
        }
        $dlogQ .= "(convert(varchar,d.emp_no) +  '-' + convert(varchar,d.register_no) + '-' + \n            convert(varchar,d.trans_no)) as trans_num\n\n            from transArchive{$dstr} as d\n            where d.trans_status not in ('D','X','Z') and d.emp_no not in (9999,56) and d.register_no  <> 99";
    }
    $chk = $db->query($dlogQ, $FANNIE_ARCHIVE_DB);
    if ($chk === false) {
        echo cron_msg("Error creating dlog view for new archive table");
    }
}
Esempio n. 9
0
if ($chk === False) {
    echo cron_msg("Could not load batch reporting data for likecodes");
}
$sql->query("use {$FANNIE_TRANS_DB}");
$cashierPerformanceSQL = "\n    SELECT\n    min(tdate) as proc_date,\n    max(emp_no) as emp_no,\n    max(trans_num) as Trans_Num,\n    min(tdate) as startTime,\n    max(tdate) as endTime,\n    CASE WHEN " . $sql->seconddiff('min(tdate)', 'max(tdate)') . " =0 \n        then 1 else \n        " . $sql->seconddiff('min(tdate)', 'max(tdate)') . "\n    END as transInterval,\n    sum(CASE WHEN abs(quantity) > 30 THEN 1 else abs(quantity) END) as items,\n    Count(upc) as rings,\n    SUM(case when trans_status = 'V' then 1 ELSE 0 END) AS Cancels,\n    max(card_no) as card_no\n    from dlog_90_view \n    where trans_type IN ('I','D','0','C')\n    group by year(tdate),month(tdate),day(tdate),trans_num";
if (!$sql->isView('CashPerformDay')) {
    $chk = $sql->query("TRUNCATE TABLE CashPerformDay");
    if ($chk === False) {
        echo cron_msg("Could not truncate CashPerformDay");
    }
    $chk = $sql->query("INSERT INTO CashPerformDay " . $cashierPerformanceSQL);
    if ($chk === False) {
        echo cron_msg("Could not load data for CashPerformDay");
    }
}
if ($sql->tableExists('CashPerformDay_cache')) {
    $chk = $sql->query("TRUNCATE TABLE CashPerformDay_cache");
    if ($chk === False) {
        echo cron_msg("Could not truncate CashPerformDay_cache");
    }
    $chk = $sql->query("INSERT INTO CashPerformDay_cache " . $cashierPerformanceSQL);
    if ($chk === False) {
        echo cron_msg("Could not load data for CashPerformDay_cache");
    }
}
$sql->query("USE " . $FANNIE_ARCHIVE_DB);
if ($sql->table_exists("reportDataCache")) {
    $sql->query("DELETE FROM reportDataCache WHERE expires < " . $sql->now());
}
echo cron_msg("Success");
Esempio n. 10
0
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
/* PURPOSE:
    Crunch the previous month's total sales &
    deliveries into a single archive record
*/
set_time_limit(0);
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$deliveryQ = "INSERT INTO InvDeliveryArchive\n    SELECT max(inv_date),upc,vendor_id,sum(quantity),sum(price)\n    FROM InvDeliveryLM \n    GROUP BY upc,vendor_id";
$chk = $sql->query($deliveryQ);
if ($chk === false) {
    echo cron_msg("Error archiving last month's inventory data");
}
$chk1 = $sql->query("TRUNCATE TABLE InvDeliveryLM");
$lmQ = "INSERT INTO InvDeliveryLM SELECT * FROM InvDelivery WHERE " . $sql->monthdiff($sql->now(), 'inv_date') . " = 1";
$chk2 = $sql->query($lmQ);
if ($chk1 === false || $chk2 === false) {
    echo cron_msg("Error setting up last month's inventory data");
}
$clearQ = "DELETE FROM InvDelivery WHERE " . $sql->monthdiff($sql->now(), 'inv_date') . " = 1";
$chk = $sql->query($clearQ);
if ($chk === false) {
    echo cron_msg("Error clearing inventory data");
}
$salesQ = "INSERT INTO InvSalesArchive\n        select max(datetime),upc,sum(quantity),sum(total)\n        FROM transarchive WHERE " . $sql->monthdiff($sql->now(), 'datetime') . " = 1\n        AND scale=0 AND trans_status NOT IN ('X','R') \n        AND trans_type = 'I' AND trans_subtype <> '0'\n        AND register_no <> 99 AND emp_no <> 9999\n        GROUP BY upc";
$chk = $sql->query($salesQ);
if ($chk === false) {
    echo cron_msg("Error archiving sales data for inventory");
}
Esempio n. 11
0
$path = 'cache/cachefiles/daily/';
if (!file_exists($FANNIE_ROOT . $path)) {
    return;
}
$dh = opendir($FANNIE_ROOT . $path);
if (!$dh) {
    echo cron_msg("{$FANNIE_ROOT}.{$path} does not exist.");
    return;
}
while (($file = readdir($dh)) !== False) {
    if (is_file($FANNIE_ROOT . $path . $file)) {
        unlink($FANNIE_ROOT . $path . $file);
    }
}
closedir($dh);
echo cron_msg("Cleared daily cache");
if (date('j') == 1) {
    $path = 'cache/cachefiles/monthly/';
    $dh = opendir($FANNIE_ROOT . $path);
    if (!$dh) {
        echo cron_msg("{$FANNIE_ROOT}.{$path} does not exist.");
        return;
    }
    while (($file = readdir($dh)) !== False) {
        if (is_file($FANNIE_ROOT . $path . $file)) {
            unlink($FANNIE_ROOT . $path . $file);
        }
    }
    closedir($dh);
    echo cron_msg("Cleared monthly cache");
}
Esempio n. 12
0
$rslt = $sql->query($query);
if ($rslt === False) {
    echo cron_msg("Failed: {$query}");
}
/* turnover view/cache base tables for WFC end-of-month reports */
if (date("j") == 1 && $sql->table_exists("ar_history_backup")) {
    $query = "TRUNCATE TABLE ar_history_backup";
    $rslt = $sql->query($query);
    if ($rslt === False) {
        echo cron_msg("Failed: {$query}");
    }
    $query = "INSERT INTO ar_history_backup SELECT * FROM ar_history";
    $rslt = $sql->query($query);
    if ($rslt === False) {
        echo cron_msg("Failed: {$query}");
    }
    $AR_EOM_Summary_Q = "\n    INSERT INTO AR_EOM_Summary\n    SELECT c.CardNo," . $sql->concat("c.FirstName", "' '", "c.LastName", '') . " AS memName,\n\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -4\n    THEN charges ELSE 0 END)\n    - SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -4\n    THEN payments ELSE 0 END) AS priorBalance,\n\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " = -3\n        THEN a.charges ELSE 0 END) AS threeMonthCharges,\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " = -3\n        THEN a.payments ELSE 0 END) AS threeMonthPayments,\n\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -3\n    THEN charges ELSE 0 END)\n    - SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -3\n    THEN payments ELSE 0 END) AS threeMonthBalance,\n\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " = -2\n        THEN a.charges ELSE 0 END) AS twoMonthCharges,\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " = -2\n        THEN a.payments ELSE 0 END) AS twoMonthPayments,\n\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -2\n    THEN charges ELSE 0 END)\n    - SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -2\n    THEN payments ELSE 0 END) AS twoMonthBalance,\n\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " = -1\n        THEN a.charges ELSE 0 END) AS lastMonthCharges,\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " = -1\n        THEN a.payments ELSE 0 END) AS lastMonthPayments,\n\n    SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -1\n    THEN charges ELSE 0 END)\n    - SUM(CASE WHEN " . $sql->monthdiff('a.tdate', $sql->now()) . " <= -1\n    THEN payments ELSE 0 END) AS lastMonthBalance\n\n    FROM ar_history_backup AS a LEFT JOIN " . $FANNIE_OP_DB . $sql->sep() . "custdata AS c \n    ON a.card_no=c.CardNo AND c.personNum=1\n    GROUP BY c.CardNo,c.LastName,c.FirstName";
    if ($sql->table_exists("AR_EOM_Summary")) {
        $query = "TRUNCATE TABLE AR_EOM_Summary";
        $rslt = $sql->query($query);
        if ($rslt === False) {
            echo cron_msg("Failed: {$query}");
        }
        $rslt = $sql->query($AR_EOM_Summary_Q);
        if ($rslt === False) {
            echo cron_msg("Failed: {$AR_EOM_Summary_Q}");
        }
    }
}
echo cron_msg("Done.");
Esempio n. 13
0
// set class alias so lines don't get too long
use COREPOS\Fannie\API\data\SyncLanes;
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
foreach (array('valutecRequest', 'valutecRequestMod', 'valutecResponse') as $table) {
    $result = SyncLanes::pull_table("{$table}", 'trans', SyncLanes::TRUNCATE_SOURCE);
    echo cron_msg($result['messages']);
}
$regularPushTables = array('products', 'custdata', 'memberCards', 'custReceiptMessage', 'CustomerNotifications', 'employees', 'departments', 'houseCoupons', 'houseCouponItems', 'houseVirtualCoupons');
foreach ($regularPushTables as $table) {
    $result = SyncLanes::push_table("{$table}", 'op', SyncLanes::TRUNCATE_DESTINATION);
    echo cron_msg($result['messages']);
}
if (isset($FANNIE_COMPOSE_LONG_PRODUCT_DESCRIPTION) && $FANNIE_COMPOSE_LONG_PRODUCT_DESCRIPTION == True) {
    $result = SyncLanes::push_table('productUser', 'op', SyncLanes::TRUNCATE_DESTINATION);
    echo cron_msg($result['messages']);
}
if (isset($FANNIE_COOP_ID) && $FANNIE_COOP_ID == 'WEFC_Toronto') {
    $result = SyncLanes::push_table('tenders', 'op', SyncLanes::TRUNCATE_DESTINATION);
    echo cron_msg($result['messages']);
    $result = SyncLanes::push_table('memtype', 'op', SyncLanes::TRUNCATE_DESTINATION);
    echo cron_msg($result['messages']);
}
echo cron_msg(basename(__FILE__) . " done.");
Esempio n. 14
0
function dieHere($msg = "", $mail = "1")
{
    global $dbConn;
    global $dbConn2;
    global $admins;
    global $dieMail;
    if ($mail) {
        $subject = "PoS: Error: Update members";
        $message = "{$msg}";
        $adminString = implode(" ", $admins);
        $lastLine = exec("echo \"{$message}\" | mail -s \"{$subject}\" {$adminString}");
        // Ordinary success returns nothing, or "".
        if ($lastLine != "") {
            echo "from mailing: {$lastLine}\n";
        }
        echo cron_msg("{$msg}\n");
    } else {
        echo "dieHere: {$msg}\n";
    }
    if ($dbConn) {
        // Warning: mysqli::close(): Couldn't fetch mysqli in /home/parkdale/is4c/updateMembers.php on line next
        @$dbConn->close();
    } else {
        1;
    }
    if ($dbConn2) {
        @$dbConn2->close();
    } else {
        1;
    }
    exit;
    //dieHere
}
    1;
}
$subject = "PoS: Update IS4C members: added {$insertCount}";
$message = "Added: {$insertCount}  Updated: {$updateCount}\n";
$adminString = implode(" ", $admins);
if ($debug == 1) {
    echo "Not ready to email. subject: {$subject}  message: {$message}\n";
} else {
    $lastLine = exec("echo \"{$message}\" | mail -s \"{$subject}\" {$adminString}");
    // Ordinary success returns nothing, or "".
    echo "from mailing: {$lastLine}\n";
}
$now = date("Ymd_M H:i:s e");
$writeOK = fwrite($logger, "{$now} {$message}");
//echo cron_msg("Error reloading dlog_15");
echo cron_msg("Success updating members from CiviCRM: {$message}");
/* Tie up and shut down.
*/
// Close the result set.
// May not be able to do something else on the connection until this is done.
$members->close();
// If MYSQL_USE_RESULT mode is used, the you must:
//$members->mysqli_free_result();
// But maybe $members->close() does the same thing.
if ($dbConn) {
    $dbConn->close();
} else {
    //echo "No dbConn to close.\n";
    1;
}
//echo "After ->close \n";
Esempio n. 16
0
// ************************************
// Discount value is the percent * 100, e.g. 10 = 10%
$discount_value = 10;
// NOTE: Simply uncomment your desired senior discount day.
// $discount_day = "Sunday";
// $discount_day = "Monday";
// $discount_day = "Tuesday";
$discount_day = "Wednesday";
// $discount_day = "Thursday";
// $discount_day = "Friday";
// $discount_day = "Saturday";
// ************************************
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
$today = date('l');
$dday = date_create($discount_day);
date_add($dday, date_interval_create_from_date_string('1 days'));
$discount_day_after = date_format($dday, 'l');
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$toggle = $today == $discount_day ? "+" : "-";
if ($today == $discount_day || $today == $discount_day_after) {
    $sql->query("UPDATE custdata SET discount = (discount {$toggle} {$discount_value}) WHERE SSI = 1");
} else {
    echo cron_msg("nightly.seniordiscount.php: Discount active on " . $discount_day . ".<br /> No discounts to apply");
}
Esempio n. 17
0
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
if (!isset($FANNIE_LANES) || !is_array($FANNIE_LANES)) {
    $FANNIE_LANES = array();
}
set_time_limit(0);
$dbc = FannieDB::get($FANNIE_TRANS_DB);
foreach ($FANNIE_LANES as $f) {
    $dbc->add_connection($f['host'], $f['type'], $f['trans'], $f['user'], $f['pw']);
    if ($dbc->connections[$f['trans']] === False) {
        echo cron_msg('Cannot connect to ' . $f['host']);
        continue;
    }
    // valutec tables are deprecated and may no longer
    // exist on the lane
    if (!$dbc->table_exists('valutecRequest', $f['trans'])) {
        continue;
    }
    $try = $dbc->transfer($f['trans'], 'SELECT * FROM valutecRequest', $FANNIE_TRANS_DB, 'INSERT INTO valutecRequest');
    if ($try !== False) {
        $dbc->query('TRUNCATE TABLE valutecRequest', $f['trans']);
    }
    $try = $dbc->transfer($f['trans'], 'SELECT * FROM valutecRequestMod', $FANNIE_TRANS_DB, 'INSERT INTO valutecRequestMod');
    if ($try !== False) {
        $dbc->query('TRUNCATE TABLE valutecRequestMod', $f['trans']);
    }
Esempio n. 18
-1
$batchQ = 'SELECT upc FROM batchList as l LEFT JOIN batches AS b
        ON l.batchID=b.batchID WHERE b.discounttype=0
        AND ' . $sql->datediff($sql->now(), 'b.startDate') . ' = 0';
$batchR = $sql->query($batchQ);
$prodUpdate = new ProdUpdateModel($sql);
while ($batchW = $sql->fetch_row($batchR)) {
    $upcs = array();
    $upc = $batchW['upc'];
    // unpack likecodes to UPCs
    if (substr($upc, 0, 2) == 'LC') {
        $likeR = $sql->execute($likeP, array(substr($upc, 2)));
        while ($likeW = $sql->fetch_row($likeR)) {
            $upcs[] = $likeW['upc'];
        }
    } else {
        $upcs[] = $upc;
    }
    foreach ($upcs as $item) {
        $prodUpdate->reset();
        $prodUpdate->upc($item);
        $logged = $prodUpdate->logUpdate(ProdUpdateModel::UPDATE_PC_BATCH, 1001);
        if (!$logged) {
            $success = false;
        }
    }
}
if ($success) {
    echo cron_msg("Changes logged in prodUpdate");
} else {
    echo cron_msg("Error logging changes");
}
Esempio n. 19
-1
   Sync Fannie custdata balance with live table.
   Usually once a day is enough.

   Do before syncing lane custdata with Fannie's.
   See also: LanePush/UpdateCustBalance.php
   
   Run either after nightly.dtrans and nightly.ar, not between them,
    and before [nightly.]lanesync.api or nightly.lanesync
   Deprecated in favour of cron/tasks/ArHistoryTask.php

*/
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_TRANS_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$query = "UPDATE {$FANNIE_OP_DB}.custdata AS c\n    LEFT JOIN ar_live_balance AS n ON c.CardNo=n.card_no\n    SET c.Balance = n.balance";
if ($FANNIE_SERVER_DBMS == "MSSQL") {
    $query = "UPDATE {$FANNIE_OP_DB}.dbo.custdata SET Balance = n.balance\n        FROM {$FANNIE_OP_DB}.dbo.custdata AS c LEFT JOIN\n        ar_live_balance AS n ON c.CardNo=n.card_no";
}
$rslt = $sql->query($query);
if ($rslt === False) {
    echo cron_msg("Failed.");
} else {
    echo cron_msg("OK.");
}
Esempio n. 20
-1
if (!isset($FANNIE_LANES) || !is_array($FANNIE_LANES)) {
    $FANNIE_LANES = array();
}
set_time_limit(0);
foreach ($FANNIE_LANES as $ln) {
    $sql = new SQLManager($ln['host'], $ln['type'], $ln['trans'], $ln['user'], $ln['pw']);
    if ($sql === False) {
        echo cron_msg("Could not connect to lane: " . $ln['host']);
        continue;
    }
    $table = 'localtrans_today';
    if ($sql->table_exists($table)) {
        $cleanQ = "DELETE FROM {$table} WHERE " . $sql->datediff($sql->now(), 'datetime') . " <> 0";
        $cleanR = $sql->query($cleanQ, $ln['trans']);
        if ($cleanR === False) {
            echo cron_msg("Could not clean {$table} on lane: " . $ln['host']);
        }
    }
    $table = 'localtrans';
    $cleanQ = "DELETE FROM {$table} WHERE " . $sql->datediff($sql->now(), 'datetime') . " > 30";
    $cleanR = $sql->query($cleanQ, $ln['trans']);
    if ($cleanR === False) {
        echo cron_msg("Could not clean {$table} on lane: " . $ln['host']);
    }
    $table = 'efsnetTokens';
    $cleanQ = "DELETE FROM {$table} WHERE " . $sql->datediff($sql->now(), 'expireDay') . " <> 0 ";
    $cleanR = $sql->query($cleanQ, $ln['trans']);
    if ($cleanR === False) {
        echo cron_msg("Could not clean {$table} on lane: " . $ln['host']);
    }
}