Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate costs in export #316

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -1259,17 +1259,24 @@ public function export($whereAdd, $orderBy) {
R.currentStartDate, R.currentEndDate, R.subscriptionAlertEnabledInd, AUT.shortName authenticationType,
AM.shortName accessMethod, SL.shortName storageLocation, UL.shortName userLimit, R.authenticationUserName,
R.authenticationPassword, R.coverageText, CT.shortName catalogingType, CS.shortName catalogingStatus, R.recordSetIdentifier, R.bibSourceURL,
R.numberRecordsAvailable, R.numberRecordsLoaded, R.hasOclcHoldings, I.isbnOrIssn,
R.numberRecordsAvailable, R.numberRecordsLoaded, R.hasOclcHoldings, GROUP_CONCAT(DISTINCT I.isbnOrIssn ORDER BY isbnOrIssnID SEPARATOR '; ') AS isbnOrIssn,
RPAY.year,
F.shortName as fundName, F.fundCode,
ROUND(COALESCE(RPAY.priceTaxExcluded, 0) / 100, 2) as priceTaxExcluded,
ROUND(COALESCE(RPAY.taxRate, 0) / 100, 2) as taxRate,
ROUND(COALESCE(RPAY.priceTaxIncluded, 0) / 100, 2) as priceTaxIncluded,
ROUND(COALESCE(RPAY.paymentAmount, 0) / 100, 2) as paymentAmount,
RPAY.currencyCode, CD.shortName as costDetails, OT.shortName as orderType, RPAY.costNote, RPAY.invoiceNum,
" . $orgSelectAdd . ",
" . $licSelectAdd . "
GROUP_CONCAT(DISTINCT A.shortName ORDER BY A.shortName DESC SEPARATOR '; ') aliases,
GROUP_CONCAT(DISTINCT PS.shortName ORDER BY PS.shortName DESC SEPARATOR '; ') purchasingSites,
GROUP_CONCAT(DISTINCT AUS.shortName ORDER BY AUS.shortName DESC SEPARATOR '; ') authorizedSites,
GROUP_CONCAT(DISTINCT ADS.shortName ORDER BY ADS.shortName DESC SEPARATOR '; ') administeringSites,
GROUP_CONCAT(DISTINCT RP.titleText ORDER BY RP.titleText DESC SEPARATOR '; ') parentResources,
GROUP_CONCAT(DISTINCT RC.titleText ORDER BY RC.titleText DESC SEPARATOR '; ') childResources,
GROUP_CONCAT(DISTINCT F.shortName, ' [', F.fundCode, ']: ', ROUND(COALESCE(RPAY.paymentAmount, 0) / 100, 2), ' ', RPAY.currencyCode, ' ', OT.shortName ORDER BY RPAY.paymentAmount ASC SEPARATOR '; ') payments
GROUP_CONCAT(DISTINCT RC.titleText ORDER BY RC.titleText DESC SEPARATOR '; ') childResources
FROM Resource R
LEFT JOIN ResourcePayment RPAY ON R.resourceID = RPAY.resourceID
LEFT JOIN Alias A ON R.resourceID = A.resourceID
LEFT JOIN ResourceOrganizationLink ROL ON R.resourceID = ROL.resourceID
" . $orgJoinAdd . "
Expand All @@ -1283,9 +1290,9 @@ public function export($whereAdd, $orderBy) {
LEFT JOIN ResourceType RT ON R.resourceTypeID = RT.resourceTypeID
LEFT JOIN AcquisitionType AT ON R.acquisitionTypeID = AT.acquisitionTypeID
LEFT JOIN ResourceStep RS ON R.resourceID = RS.resourceID
LEFT JOIN ResourcePayment RPAY ON R.resourceID = RPAY.resourceID
LEFT JOIN Fund F ON RPAY.fundID = F.fundID
LEFT JOIN OrderType OT ON RPAY.orderTypeID = OT.orderTypeID
LEFT JOIN CostDetails CD ON RPAY.costDetailsID = CD.costDetailsID
LEFT JOIN Status S ON R.statusID = S.statusID
LEFT JOIN ResourceNote RN ON R.resourceID = RN.resourceID
LEFT JOIN NoteType NT ON RN.noteTypeID = NT.noteTypeID
Expand All @@ -1306,9 +1313,8 @@ public function export($whereAdd, $orderBy) {
LEFT JOIN IsbnOrIssn I ON I.resourceID = R.resourceID
" . $licJoinAdd . "
" . $whereStatement . "
GROUP BY R.resourceID
GROUP BY RPAY.resourcePaymentID
ORDER BY " . $orderBy;

$result = $this->db->processQuery(stripslashes($query), 'assoc');

$searchArray = array();
Expand Down
114 changes: 68 additions & 46 deletions resources/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,53 +54,64 @@ function array_to_csv_row($array) {
header("Content-Disposition: attachment; filename=\"" . $excelfile . "\"");

$columnHeaders = array(
"Record ID",
"Name",
"Type",
"Format",
"Date Created",
"User Created",
"Date Updated",
"User Updated",
"Status",
"ISSN/ISBN",
"Resource URL",
"Alt URL",
"Organizations",
"Aliases",
"Parent Record",
"Child Record",
"Acquisition Type",
"Cost",
"Order Number",
"System Number",
"Purchasing Sites",
"Sub Start",
"Current Sub End",
"Subscription Alert Enabled",
"License Names",
"License Status",
"Authorized Sites",
"Administering Sites",
"Authentication Type",
"Access Method",
"Storage Location",
"Simultaneous User Limit",
"Coverage",
"Username",
"Password",
"Cataloging Type",
"Cataloging Status",
"Catalog Record Set Identifier",
"Catalog Record Source URL",
"Catalog Records Available",
"Catalog Records Loaded",
"OCLC Holdings Updated"
_("Record ID"),
_("Name"),
_("Type"),
_("Format"),
_("Date Created"),
_("User Created"),
_("Date Updated"),
_("User Updated"),
_("Status"),
_("ISSN/ISBN"),
_("Resource URL"),
_("Alt URL"),
_("Organizations"),
_("Year"),
_("Fund Name"),
_("Fund Code"),
_("Tax excluded"),
_("Rate"),
_("Tax included"),
_("Payment"),
_("Currency"),
_("Details"),
_("Order Type"),
_("Cost Note"),
_("Invoice"),
_("Aliases"),
_("Parent Record"),
_("Child Record"),
_("Acquisition Type"),
_("Order Number"),
_("System Number"),
_("Purchasing Sites"),
_("Sub Start"),
_("Current Sub End"),
_("Subscription Alert Enabled"),
_("License Names"),
_("License Status"),
_("Authorized Sites"),
_("Administering Sites"),
_("Authentication Type"),
_("Access Method"),
_("Storage Location"),
_("Simultaneous User Limit"),
_("Coverage"),
_("Username"),
_("Password"),
_("Cataloging Type"),
_("Cataloging Status"),
_("Catalog Record Set Identifier"),
_("Catalog Record Source URL"),
_("Catalog Records Available"),
_("Catalog Records Loaded"),
_("OCLC Holdings Updated")
);

echo array_to_csv_row(array("Resource Record Export " . format_date( date( 'Y-m-d' ))));
echo array_to_csv_row(array(_("Resource Record Export") . " " . format_date( date( 'Y-m-d' ))));
if (!$searchDisplay) {
$searchDisplay = array("All Resource Records");
$searchDisplay = array(_("All Resource Records"));
}
echo array_to_csv_row(array(implode('; ', $searchDisplay)));
echo array_to_csv_row($columnHeaders);
Expand All @@ -118,15 +129,26 @@ function array_to_csv_row($array) {
$updateDateFormatted,
$resource['updateName'],
$resource['status'],
$resource['isbnOrISSN'],
$resource['isbnOrIssn'],
$resource['resourceURL'],
$resource['resourceAltURL'],
$resource['organizationNames'],
$resource['year'],
$resource['fundName'],
$resource['fundCode'],
$resource['priceTaxExcluded'],
$resource['taxRate'],
$resource['priceTaxIncluded'],
$resource['paymentAmount'],
$resource['currencyCode'],
$resource['costDetails'],
$resource['orderType'],
$resource['costNote'],
$resource['invoiceNum'],
$resource['aliases'],
$resource['parentResources'],
$resource['childResources'],
$resource['acquisitionType'],
$resource['payments'],
$resource['orderNumber'],
$resource['systemNumber'],
$resource['purchasingSites'],
Expand Down