Skip to content

Commit

Permalink
Stable bulk ISBN lookup (with more handle failed items & duplications)
Browse files Browse the repository at this point in the history
  • Loading branch information
aimakun committed Mar 15, 2010
1 parent 78e571f commit 55f17d3
Show file tree
Hide file tree
Showing 38 changed files with 2,397 additions and 81 deletions.
69 changes: 49 additions & 20 deletions catalog/biblio_copy_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,8 @@
#* to be entered. This can be fixed with a lock or by an atomic
#* get-and-increment-sequence-value operation. I'll fix it later. -- Micah
#****************************************************************************
if (isset($_POST["autobarco"]) and $_POST["autobarco"]) {
$nzeros = "5";
$bibid=$_POST["bibid"];
$CopyNmbr = $copyQ->nextCopyid($bibid);
if ($copyQ->errorOccurred()) {
$copyQ->close();
displayErrorPage($copyQ);
}
$_POST["barcodeNmbr"] = sprintf("%0".$nzeros."s",$bibid).$CopyNmbr;
if ((isset($_POST["autobarco"]) and $_POST["autobarco"]) || 0 + $_GET['hits'] > 1) {
$_POST["barcodeNmbr"] = generateBarcode();
}

#****************************************************************************
Expand All @@ -68,23 +61,31 @@
$pageErrors["barcodeNmbr"] = $copy->getBarcodeNmbrError();
$_SESSION["postVars"] = $_POST;
$_SESSION["pageErrors"] = $pageErrors;
header("Location: ../catalog/biblio_copy_new_form.php?bibid=".U($bibid));
header("Location: ../catalog/biblio_copy_new_form.php?bibid=".U($bibid).(empty($_GET['isbn'])?'':"&isbn={$_GET['isbn']}&hits={$_GET['hits']}"));
exit();
}

#**************************************************************************
#* Insert new bibliography copy
#**************************************************************************
if (!$copyQ->insert($copy)) {
$copyQ->close();
if ($copyQ->getDbErrno() == "") {
$pageErrors["barcodeNmbr"] = $copyQ->getError();
$_SESSION["postVars"] = $_POST;
$_SESSION["pageErrors"] = $pageErrors;
header("Location: ../catalog/biblio_copy_new_form.php?bibid=".U($bibid));
exit();
} else {
displayErrorPage($copyQ);
if (0 + $_GET['hits'] > 1) {
$i = 0;
do {
insertCopy();
$copy->setBarcodeNmbr(generateBarcode());
$i++;
} while ($i < 0 + $_GET['hits']);

require_once("../lookup2/BulkLookup.class.php");
$bl = new BulkLookupQuery();
$bl->clearManualItem($_GET['isbn'], $_GET['hits']);
}
else {
insertCopy();
if (isset($_GET['isbn'], $_GET['hits'])) {
require_once("../lookup2/BulkLookup.class.php");
$bl = new BulkLookupQuery();
$bl->clearManualItem($_GET['isbn'], $_GET['hits']);
}
}
$copyQ->close();
Expand All @@ -98,4 +99,32 @@
$msg = $loc->getText("biblioCopyNewSuccess");
header("Location: ../shared/biblio_view.php?bibid=".U($bibid)."&msg=".U($msg));
exit();

function generateBarcode() {
global $copyQ;
$nzeros = "5";
$bibid=$_POST["bibid"];
$CopyNmbr = $copyQ->nextCopyid($bibid);
if ($copyQ->errorOccurred()) {
$copyQ->close();
displayErrorPage($copyQ);
}
return sprintf("%0".$nzeros."s",$bibid).$CopyNmbr;
}

function insertCopy() {
global $copyQ, $copy;
if (!$copyQ->insert($copy)) {
$copyQ->close();
if ($copyQ->getDbErrno() == "") {
$pageErrors["barcodeNmbr"] = $copyQ->getError();
$_SESSION["postVars"] = $_POST;
$_SESSION["pageErrors"] = $pageErrors;
header("Location: ../catalog/biblio_copy_new_form.php?bibid=".U($bibid));
exit();
} else {
displayErrorPage($copyQ);
}
}
}
?>
2 changes: 1 addition & 1 deletion catalog/biblio_copy_new_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<?php echo $loc->getText("catalogFootnote",array("symbol"=>"*")); ?>
</font>

<form name="newCopyForm" method="POST" action="../catalog/biblio_copy_new.php">
<form name="newCopyForm" method="POST" action="../catalog/biblio_copy_new.php<?=empty($_GET['hits'])?'':'?hits='.$_GET['hits'].(empty($_GET['isbn'])?'':'&isbn='.$_GET['isbn']) ?>">
<table class="primary">
<tr>
<th colspan="2" nowrap="yes" align="left">
Expand Down
12 changes: 9 additions & 3 deletions catalog/biblio_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@

if (!isset($_REQUEST['posted'])) {
require_once("../shared/logincheck.php");
showForm(array('opacFlg'=>'CHECKED'));

$param = array('opacFlg'=>'CHECKED');
// Receive get parameter for ISBN.
if (!empty($_GET['isbn']))
$param['values']['020a'] = $_GET['isbn'];

showForm($param);
} else {
if (!empty($_FILES["values"]["tmp_name"]["902a"])) $_POST["values"]["902a"] = $_FILES["values"];
$postVars = $_POST;
Expand All @@ -37,7 +43,7 @@
$msg = $loc->getText("biblioNewSuccess");
//header("Location: ../shared/biblio_view.php?bibid=".U($bibid)."&msg=".U($msg));
//------following line auto transfers to new copy form (new function)
header("Location: ../catalog/biblio_copy_new_form.php?bibid=".$bibid."&msg=".$msg);
header("Location: ../catalog/biblio_copy_new_form.php?" . (empty($_GET['hits'])?'':'hits=' . $_GET['hits'] . '&' . (empty($_GET['isbn'])?'': 'isbn=' . $_GET['isbn'] . '&')) . "bibid=".$bibid."&msg=".$msg);
exit();
}
}
Expand Down Expand Up @@ -136,7 +142,7 @@ function matCdReload(){
}
//-->
</script>
<form name="newbiblioform" method="POST" action="../catalog/biblio_new.php" enctype="multipart/form-data">
<form name="newbiblioform" method="POST" action="../catalog/biblio_new.php<?=empty($_GET['hits'])?'':'?hits='.$_GET['hits'].(empty($_GET['isbn'])?'':'&isbn=' . $_GET['isbn']) ?>" enctype="multipart/form-data">
<?php
include("../catalog/biblio_fields.php");
include("../shared/footer.php");
Expand Down
6 changes: 5 additions & 1 deletion classes/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ function _act($sql) {
}
$r = mysql_query($sql, $this->_link);
if ($r === false) {
Fatal::dbError($sql, 'Database query failed', mysql_error());
if (mysql_errno() == 1146 && eregi(OBIB_DATABASE . '.settings', mysql_error())) {
// Settings not found
header("Location: ../install/");
}
Fatal::dbError($sql, 'Database query failed (' . mysql_errno() . ')', mysql_error());
}
return $r;
}
Expand Down
Loading

0 comments on commit 55f17d3

Please sign in to comment.