mirror of
https://github.com/fspc/Yellow-Bike-Database.git
synced 2025-02-22 17:03:22 -05:00
Adds coordinators name to the csv description.
This commit is contained in:
parent
80d85c9dcd
commit
f23720cf6d
@ -217,6 +217,19 @@ $csv_directory = CSV_DIRECTORY;
|
|||||||
"AND contacts.contact_id = transaction_log.sold_to " .
|
"AND contacts.contact_id = transaction_log.sold_to " .
|
||||||
"AND (transaction_id>" . $transaction_range[0] . " AND transaction_id<" . $transaction_range[1] . ");";
|
"AND (transaction_id>" . $transaction_range[0] . " AND transaction_id<" . $transaction_range[1] . ");";
|
||||||
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
|
// second statement to find coordinator for associated transactions
|
||||||
|
$query = "SELECT transaction_id, " .
|
||||||
|
"CONCAT(contacts.first_name, ' ', contacts.last_name) AS 'coordinator' " .
|
||||||
|
"FROM transaction_log, contacts WHERE paid=1 AND date!='NULL' " .
|
||||||
|
"AND (payment_type='cash' OR payment_type='check') " .
|
||||||
|
"AND contacts.contact_id = transaction_log.sold_by " .
|
||||||
|
"AND (transaction_id>" . $transaction_range[0] . " AND transaction_id<" . $transaction_range[1] . ");";
|
||||||
|
$sql2 = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
|
$coordinator = [];
|
||||||
|
while ( $result = mysql_fetch_assoc($sql2) ) {
|
||||||
|
$coordinator[$result['transaction_id']] = $result['coordinator'];
|
||||||
|
}
|
||||||
|
|
||||||
$gnucash_csv_file = "";
|
$gnucash_csv_file = "";
|
||||||
while ( $result = mysql_fetch_assoc($sql) ) {
|
while ( $result = mysql_fetch_assoc($sql) ) {
|
||||||
$description = preg_replace('/\n/', ' \r ', $result['description']);
|
$description = preg_replace('/\n/', ' \r ', $result['description']);
|
||||||
@ -224,7 +237,7 @@ $csv_directory = CSV_DIRECTORY;
|
|||||||
$description = preg_replace('/,/', ';', $description);
|
$description = preg_replace('/,/', ';', $description);
|
||||||
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] .
|
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] .
|
||||||
', (Income:' . $result['transaction_type'] . ') ' .
|
', (Income:' . $result['transaction_type'] . ') ' .
|
||||||
$description . ' [' . $result['patron'] . ']' .
|
$description . ' [' . $coordinator[$result['transaction_id']] . ' => ' . $result['patron'] . ']' .
|
||||||
', ' . $result['amount'] . ', ' .
|
', ' . $result['amount'] . ', ' .
|
||||||
$accounts_gnucash['checking'] . "\n";
|
$accounts_gnucash['checking'] . "\n";
|
||||||
}
|
}
|
||||||
@ -248,6 +261,19 @@ $csv_directory = CSV_DIRECTORY;
|
|||||||
"AND contacts.contact_id = transaction_log.sold_to " .
|
"AND contacts.contact_id = transaction_log.sold_to " .
|
||||||
"AND (transaction_id>" . $transaction_range[0] . " AND transaction_id<" . $transaction_range[1] . ");";
|
"AND (transaction_id>" . $transaction_range[0] . " AND transaction_id<" . $transaction_range[1] . ");";
|
||||||
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
|
// second statement to find coordinator for associated transactions
|
||||||
|
$query = "SELECT transaction_id, " .
|
||||||
|
"CONCAT(contacts.first_name, ' ', contacts.last_name) AS 'coordinator' " .
|
||||||
|
"FROM transaction_log, contacts WHERE paid=1 AND date!='NULL' " .
|
||||||
|
"AND payment_type='credit' " .
|
||||||
|
"AND contacts.contact_id = transaction_log.sold_by " .
|
||||||
|
"AND (transaction_id>" . $transaction_range[0] . " AND transaction_id<" . $transaction_range[1] . ");";
|
||||||
|
$sql2 = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
|
$coordinator = [];
|
||||||
|
while ( $result = mysql_fetch_assoc($sql2) ) {
|
||||||
|
$coordinator[$result['transaction_id']] = $result['coordinator'];
|
||||||
|
}
|
||||||
|
|
||||||
$gnucash_csv_file = "";
|
$gnucash_csv_file = "";
|
||||||
while ( $result = mysql_fetch_assoc($sql) ) {
|
while ( $result = mysql_fetch_assoc($sql) ) {
|
||||||
$description = preg_replace('/\n/', ' \r ', $result['description']);
|
$description = preg_replace('/\n/', ' \r ', $result['description']);
|
||||||
@ -255,7 +281,7 @@ $csv_directory = CSV_DIRECTORY;
|
|||||||
$description = preg_replace('/,/', ';', $description);
|
$description = preg_replace('/,/', ';', $description);
|
||||||
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] .
|
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] .
|
||||||
', (Income:' . $result['transaction_type'] . ') ' .
|
', (Income:' . $result['transaction_type'] . ') ' .
|
||||||
$description . ' [' . $result['patron'] . ']' .
|
$description . ' [' . $coordinator[$result['transaction_id']] . ' => ' . $result['patron'] . ']' .
|
||||||
', ' . $result['amount'] . ', ' .
|
', ' . $result['amount'] . ', ' .
|
||||||
$accounts_gnucash['credit'] . "\n";
|
$accounts_gnucash['credit'] . "\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user