Skip to content

DBC-1315 - Fixing holdings.#2

Merged
avoykov merged 2 commits intodevelopfrom
DBC-1315
Jan 19, 2017
Merged

DBC-1315 - Fixing holdings.#2
avoykov merged 2 commits intodevelopfrom
DBC-1315

Conversation

@bozeak
Copy link
Copy Markdown
Contributor

@bozeak bozeak commented Dec 30, 2016

No description provided.

Comment thread includes/fbs.availability.inc Outdated
function _fbs_set_holdings($res) {
$holdings = array();
$reservation_count = 0;
$reservation_count += (int) $res['reservation_count'];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$reservation_count = 0;
$reservation_count += (int) $res['reservation_count'];

to
$reservation_count = (int) $res['reservation_count'];

Comment thread includes/fbs.availability.inc Outdated
$reservation_count += (int) $res['reservation_count'];
foreach ($res['holdings'] as $holding) {
$holdings[] = $holding;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? just use $res['holdings']

/**
* Getting holdings for preprocessing.
*/
function _fbs_get_holdings($res, $is_periodical = FALSE) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe params and result in phpdoc


/**
* Set holdings for all kinds of material except periodicals.
*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe params and result in phpdoc


/**
* Set holdings if material is periodical only.
*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe params and result in phpdoc

/**
* If the same placement exists several times collect them in one line.
*/
function _clean_up_rows($_rows) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe params and result in phpdoc

Comment thread includes/fbs.availability.inc Outdated
$row['data']['Copies'] = array('data' => $r_count, 'colspan' => 4);
$variables['rows'][] = $row;

return theme_table($variables);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pleae use theme('table', options)

*/
function _sum_placement($placementsarr) {
$row = $placementsarr[0];
for ($i = 1; $i < count($placementsarr); $i++) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not foreach statement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO "for" statement is more suitable for this increment operation.

function _get_placements_with_key($_rows, $currkey) {
$rows = array();
foreach ($_rows as $key) {
if ($key['placement'] == $currkey) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you already looping needed placements, why you dont made actions from _sum_placement here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't wanted to mess all things in one place.

foreach ($h as $key => $data) {
$row = array();

$row['placement'] = implode(' > ', $data['placement']);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$placement = implode(' > ', $data['placement']);
$copies = isset($data['total_count']) ? (int) $data['total_count'] : 0;
$home = isset($data['available_count']) ? (int) $data['available_count'] : 0;
$current = array(
'copies' => isset($rows[$placement]['copies']) ? $rows[$placement]['copies'] : 0,
'home' => isset($rows[$placement]['home']) ? $rows[$placement]['home'] : 0,
);

$rows[$placement] = array(
'placement' => $placement,
'copies' => $copies +$current['copies'] ,
'home ' => $home + $current['home'],
);

@avoykov avoykov merged commit 010ebd3 into develop Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants