Esempio n. 1
0
function parse_csv_file($path, $delimiter = ',', $first_row_as_keys = true)
{
    $file = csv_parse($path, $delimiter);
    $result = array();
    while (($data = csv_row_from($file)) !== FALSE) {
        $result[] = $data;
    }
    return $result;
}
Esempio n. 2
0
//******************************************************************//
// Package:         Zerone-Consulting
// Description:     Online Payment Gateway
// Files:           index.php,home.php,cheque.php,creditcard.php,report.php,reportBottom.php, reportBottomSummary.php,companyEdit.php
//    				config.php,useraccount.php,viewCompany.php,topheader.php,ViewreportPage.php,addcheque.php,blank.php,profile_blank.php
//					VT_blank.php,creditcardfb.php,customerservice_blank.php,report_custom.php,callback.php,ledger.php
//report.php:		The  page functions for selecting the type of report view of the company.
include 'includes/sessioncheckuser.php';
require_once "includes/dbconnection.php";
require_once 'includes/function.php';
include 'includes/header.php';
$sessionlogin = isset($HTTP_SESSION_VARS["sessionlogin"]) ? $HTTP_SESSION_VARS["sessionlogin"] : "";
if ($_FILES['batchfile']['type'] == 'application/vnd.ms-excel') {
    set_time_limit(500);
    $CSV = file_get_contents($_FILES['batchfile']['tmp_name']);
    $CSV_Info = csv_parse($CSV);
    $log = "Attempting to update transactions through batch file:\n";
    $success = 0;
    $failed = 0;
    foreach ($CSV_Info as $info) {
        $transactionInfo = getTransactionInfo(quote_smart($info[0]), quote_smart($_GET['test']), 'reference_number', " and t.userId = '{$sessionlogin}'");
        $transactionId = $transactionInfo['transactionId'];
        if ($transactionInfo == -1) {
            $log .= " Could not locate transaction '" . $info[0] . "'\n";
            $failed++;
        } else {
            //(Reference_ID, Shipping Tracking Number, Date Shipped, Estimate Arrival Time, Shipping Company, Optional Tracking Hyperlink, Extra Info)
            $td_tracking_id = quote_smart($info[1]);
            $td_tracking_link = quote_smart($info[5]);
            $td_tracking_company = quote_smart($info[4]);
            $td_tracking_info = quote_smart($info[6]);
Esempio n. 3
0
/**
 * Handle plan import request.
 *
 * @return The url to display on completion.
 */
function command_member_plan_import()
{
    if (!user_access('member_plan_edit')) {
        error_register('User does not have permission: member_plan_edit');
        return crm_url('members');
    }
    if (!array_key_exists('plan-file', $_FILES)) {
        error_register('No plan file uploaded');
        return crm_url('plans&tab=import');
    }
    $csv = file_get_contents($_FILES['plan-file']['tmp_name']);
    $data = csv_parse($csv);
    foreach ($data as $row) {
        // Convert row keys to lowercase and remove spaces
        foreach ($row as $key => $value) {
            $new_key = str_replace(' ', '', strtolower($key));
            unset($row[$key]);
            $row[$new_key] = $value;
        }
        // Add plan
        $name = mysql_real_escape_string($row['planname']);
        $price = mysql_real_escape_string($row['price']);
        $active = mysql_real_escape_string($row['active']);
        $voting = mysql_real_escape_string($row['voting']);
        $sql = "\n            INSERT INTO `plan`\n            (`name`,`price`,`active`,`voting`)\n            VALUES\n            ('{$name}','{$price}','{$active}','{$voting}')";
        $res = mysql_query($sql);
        if (!$res) {
            crm_error(mysql_error());
        }
        $pid = mysql_insert_id();
    }
    return crm_url('plans');
}
Esempio n. 4
0
/**
 * Handle amazon payment import request.
 *
 * @return The url to display on completion.
 */
function command_amazon_payment_import()
{
    if (!user_access('payment_edit')) {
        error_register('User does not have permission: payment_edit');
        return crm_url('payments');
    }
    if (!array_key_exists('payment-file', $_FILES)) {
        error_register('No payment file uploaded');
        return crm_url('payments&tab=import');
    }
    $csv = file_get_contents($_FILES['payment-file']['tmp_name']);
    $data = csv_parse($csv);
    $count = 0;
    message_register("Processing " . count($data) . " row(s)");
    foreach ($data as $row) {
        // Ignore withdrawals, holds, and failures
        if (strtolower($row['Type']) !== 'payment') {
            message_register("Ignoring row of type: " . $row['Type']);
            continue;
        }
        if (strtolower($row['To/From']) !== 'from') {
            message_register("Ignoring outgoing payment");
            continue;
        }
        if (strtolower($row['Status']) !== 'completed') {
            message_register("Ignoring payment with status: " . $row['Status']);
            continue;
        }
        // Skip transactions that have already been imported
        $payment_opts = array('filter' => array('confirmation' => $row['Transaction ID']));
        $data = payment_data($payment_opts);
        if (count($data) > 0) {
            message_register("Skipping previously imported payment: " . $row['Transaction ID']);
            continue;
        }
        // Parse value
        $value = payment_parse_currency($row['Amount']);
        // Create payment object
        $payment = array('date' => date('Y-m-d', strtotime($row['Date'])), 'code' => $value['code'], 'value' => $value['value'], 'description' => $row['Name'] . ' Amazon Payment', 'method' => 'amazon', 'confirmation' => $row['Transaction ID'], 'notes' => $row['notes'], 'amazon_name' => $row['Name']);
        // Check if the amazon name is linked to a contact
        $opts = array('filter' => array('amazon_name' => $row['Name']));
        $contact_data = amazon_payment_contact_data($opts);
        if (count($contact_data) > 0) {
            $payment['credit_cid'] = $contact_data[0]['cid'];
        }
        // Save the payment
        $payment = payment_save($payment);
        $count++;
    }
    message_register("Successfully imported {$count} payment(s)");
    return crm_url('payments');
}
Esempio n. 5
0
/**
 * Handle paypal payment import request.
 *
 * @return The url to display on completion.
 */
function command_paypal_payment_import()
{
    if (!user_access('payment_edit')) {
        error_register('User does not have permission: payment_edit');
        return crm_url('payments');
    }
    if (!array_key_exists('payment-file', $_FILES)) {
        error_register('No payment file uploaded');
        return crm_url('payments&tab=import');
    }
    $csv = file_get_contents($_FILES['payment-file']['tmp_name']);
    $data = csv_parse($csv);
    $count = 0;
    foreach ($data as $row) {
        // Skip transactions that have already been imported
        $payment_opts = array('filter' => array('confirmation' => $row['Transaction ID']));
        $data = payment_data($payment_opts);
        if (count($data) > 0) {
            continue;
        }
        // Parse value
        $value = payment_parse_currency($row['Gross']);
        // Create payment object
        $payment = array('date' => date('Y-m-d', strtotime($row['Date'])), 'code' => $value['code'], 'value' => $value['value'], 'description' => $row['Name'] . ' Paypal Payment', 'method' => 'paypal', 'confirmation' => $row['Transaction ID'], 'notes' => $row['Item Title'], 'paypal_email' => $row['From Email Address']);
        // Check if the paypal email is linked to a contact
        $opts = array('filter' => array('paypal_email' => $row['From Email Address']));
        $contact_data = paypal_payment_contact_data($opts);
        if (count($contact_data) > 0) {
            $payment['credit_cid'] = $contact_data[0]['cid'];
        }
        // Save the payment
        $payment = payment_save($payment);
        $count++;
    }
    message_register("Successfully imported {$count} payment(s)");
    return crm_url('payments');
}
Esempio n. 6
0
$headerInclude = "ledgers";
$display_stat_wait = true;
include "includes/header.php";
include "../includes/companySubView.php";
require_once "../includes/projSetCalc.php";
require_once "../includes/JSON_functions.php";
$bank_ids = array();
$sql = "SELECT bank_id FROM cs_bank WHERE bk_ignore=0 order by bank_id asc";
$res = sql_query_read($sql) or dieLog(mysql_error());
while ($bankInfo = mysql_fetch_assoc($res)) {
    $bank_ids[] = $bankInfo['bank_id'];
}
if ($_POST['submit'] == 'SM Payout Response') {
    $csv = file_get_contents($_FILES["sm_payout_file"]["tmp_name"]);
    $csv = str_replace("\r", "", $csv);
    $csv_info = csv_parse($csv);
    $error = 0;
    $count = 0;
    foreach ($csv_info as $info) {
        list($company_id, $mi_paydate) = split("_", $info[2]);
        if ($company_id && $company_id != "ETEL") {
            $count++;
            $invoice_sql = "select mi_ID,DATE_FORMAT(mi_paydate, '%W %M %D, %Y') as wiredate,companyname,email,username,password,ReferenceNumber,\n\t\t\tmi_title, mi_status, mi_deduction, mi_balance, mi_notes\n\t\t\t\n\t\t\tfrom `cs_merchant_invoice` left join cs_companydetails on mi_company_id = userId\n\t\t\tWHERE mi_paydate = '" . quote_smart($mi_paydate) . "' and mi_company_id = '" . quote_smart($company_id) . "'";
            $result = sql_query_read($invoice_sql);
            if ($invoiceInfo = mysql_fetch_assoc($result)) {
                $mi_status = 'Pending';
                $mi_ID = intval($invoiceInfo['mi_ID']);
                $emailData = array();
                $emailData["companyname"] = $invoiceInfo['companyname'];
                $emailData["username"] = $invoiceInfo['username'];
                $emailData["password"] = $invoiceInfo['password'];