Ejemplo n.º 1
0
function download_chips($guid, $clear = false)
{
    $rows = db_getChipsByProj($guid);
    foreach ($rows as &$r) {
        unset($r['id']);
    }
    unset($r);
    $res[] = array('table' => 'chips', 'key' => 'qrcode', 'rows' => $rows, 'clear' => array('ProjGUID' => $guid));
    $res[] = array('table' => 'bill', 'key' => 'BillGUID', 'rows' => db_getBills($guid), 'clear' => array('ProjGUID' => $guid));
    $res[] = array('table' => 's_fee', 'key' => 'FeeGUID', 'rows' => db_getFees($guid), 'clear' => array('ProjGUID' => $guid));
    $res[] = array('table' => 'p_cstattach', 'key' => 'CstAttachGUID', 'rows' => db_getCstAttach($guid), 'clear' => array('ProjGUID' => $guid));
    $res[] = array('table' => 'p_customer', 'key' => 'CstGUID', 'rows' => db_getCustomers($guid));
    $invoices = db_getInvoices($guid);
    $res[] = array('table' => 'p_invoice', 'key' => 'InvoGUID', 'rows' => $invoices, 'clear' => array('ProjGUID' => $guid), 'clearchild' => array('p_invoicedetail'));
    $InvoiceDetails = array();
    foreach ($invoices as $i) {
        $InvoiceDetails = array_merge($InvoiceDetails, db_getInvoiceDetails($i['InvoGUID']));
    }
    $res[] = array('table' => 'p_invoicedetail', 'key' => 'InvoDetailGUID', 'rows' => $InvoiceDetails);
    unset($invoices);
    return $res;
}
Ejemplo n.º 2
0
/**
 * 导出诚意金信息至erp
 * 生成票据信息规则
 * return array()
 */
function export_Voucher($projGUID, $progressFunc)
{
    //生成财务单据表,s_Voucher
    $res = array('total' => 0, 'update' => 0, 'failed' => 0);
    $bills = db_getBills($projGUID, 1, true);
    $count = count($bills);
    $progress = 0;
    $index = 0;
    $showProgress = function () use(&$progress, $count, &$index, $progressFunc) {
        $index++;
        $value = intval($index * 5 / $count);
        if ($value > $progress) {
            $progress = $value;
            if (!empty($progressFunc)) {
                $progressFunc($value);
            }
        }
    };
    $project = biz_getProject($projGUID);
    $res['total'] = 0;
    foreach ($bills as $b) {
        $showProgress();
        if ($b['Money'] > 0 && $b['ErpSync'] == 0 && $b['Printed'] == 1) {
            $res['total']++;
            $inserted = erp_write_Voucher($b, $project);
            if ($inserted) {
                //记录票据信息更新状态,标记为等待更新
                pdo_update('p_invoicedetail', array('ErpSync' => 2, 'signguid' => $projGUID), array('InvoDetailGUID' => $b['InvoDetailGUID']));
                $res['update']++;
            } else {
                $res['failed']++;
                $error = MsSql()->getErrors();
                MsSql()->clearError();
                //记录出错信息
                logging('bill_' . $b['BillGUID'], $error);
            }
            pdo_update('bill', array('ErpSync' => $inserted ? 1 : 2, 'SyncTime' => TIMESTAMP), array('BillGUID' => $b['BillGUID']));
        }
    }
    return $res;
}