Example #1
0
     } else {
         $data['publisher_id'] = 'literal{NULL}';
     }
 }
 $data['publish_year'] = trim($dbs->escape_string(strip_tags($_POST['year'])));
 $data['collation'] = trim($dbs->escape_string(strip_tags($_POST['collation'])));
 $data['series_title'] = trim($dbs->escape_string(strip_tags($_POST['seriesTitle'])));
 $data['call_number'] = trim($dbs->escape_string(strip_tags($_POST['callNumber'])));
 $data['language_id'] = trim($dbs->escape_string(strip_tags($_POST['languageID'])));
 // check place
 if ($_POST['placeID'] != '0') {
     $data['publish_place_id'] = intval($_POST['placeID']);
 } else {
     if (!empty($_POST['plc_search_str'])) {
         $new_place = trim(strip_tags($_POST['plc_search_str']));
         $new_id = utility::getID($dbs, 'mst_place', 'place_id', 'place_name', $new_place);
         if ($new_id) {
             $data['publish_place_id'] = $new_id;
         } else {
             $data['publish_place_id'] = 'literal{NULL}';
         }
     } else {
         $data['publish_place_id'] = 'literal{NULL}';
     }
 }
 $data['notes'] = trim($dbs->escape_string(strip_tags($_POST['notes'], '<br><p><div><span><i><em><strong><b><code>s')));
 $data['opac_hide'] = $_POST['opacHide'] == '0' ? 'literal{0}' : '1';
 $data['promoted'] = $_POST['promote'] == '0' ? 'literal{0}' : '1';
 // labels
 $arr_label = array();
 foreach ($_POST['labels'] as $label) {
Example #2
0
 foreach ($record as $field => $content) {
     if (is_string($content)) {
         $biblio[$field] = $dbs->escape_string(trim($content));
     }
 }
 // gmd
 $biblio['gmd_id'] = utility::getID($dbs, 'mst_gmd', 'gmd_id', 'gmd_name', $record['gmd'], $gmd_cache);
 unset($biblio['gmd']);
 // publisher
 $biblio['publisher_id'] = utility::getID($dbs, 'mst_publisher', 'publisher_id', 'publisher_name', $record['publisher'], $publ_cache);
 unset($biblio['publisher']);
 // publish place
 $biblio['publish_place_id'] = utility::getID($dbs, 'mst_place', 'place_id', 'place_name', $record['publish_place'], $place_cache);
 unset($biblio['publish_place']);
 // language
 $biblio['language_id'] = utility::getID($dbs, 'mst_language', 'language_id', 'language_name', $record['language']['name'], $lang_cache);
 unset($biblio['language']);
 // authors
 $authors = array();
 if (isset($record['authors'])) {
     $authors = $record['authors'];
     unset($biblio['authors']);
 }
 // subject
 $subjects = array();
 if (isset($record['subjects'])) {
     $subjects = $record['subjects'];
     unset($biblio['subjects']);
 }
 $biblio['input_date'] = $biblio['create_date'];
 $biblio['last_update'] = $biblio['modified_date'];
Example #3
0
             }
             // remove last comma
             $biblio_author_sql = substr_replace($biblio_author_sql, '', -1);
             // execute query
             $dbs->query($biblio_author_sql);
             // echo $dbs->error;
         }
         // set topic
         if ($data['subjects']) {
             $biblio_subject_sql = 'INSERT IGNORE INTO biblio_topic (biblio_id, topic_id, level) VALUES ';
             foreach ($data['subjects'] as $subject) {
                 $subject['auth_list'] = $subject['auth_list'] ? "'" . $subject['auth_list'] . "'" : 'NULL';
                 @$dbs->query('INSERT IGNORE INTO mst_topic (topic,topic_type,auth_list,input_date,last_update)
                     VALUES (\'' . $subject['name'] . '\', \'' . $subject['type'] . '\', ' . $subject['auth_list'] . ', \'' . $curr_date . '\', \'' . $curr_date . '\')');
                 $subject['name'] = $dbs->escape_string(trim($subject['name']));
                 $subject_id = utility::getID($dbs, 'mst_topic', 'topic_id', 'topic', $subject['name'], $cache_subject);
                 $biblio_subject_sql .= " ({$biblio_id}, {$subject_id}, " . $subject['level'] . "),";
             }
             // remove last comma
             $biblio_subject_sql = substr_replace($biblio_subject_sql, '', -1);
             // execute query
             $dbs->query($biblio_subject_sql);
             // echo $dbs->error;
         }
     }
     $r++;
 }
 // close poll
 ucs_nodes_poll::clear_poll($dbs, $node_id);
 // write log
 utility::writeLogs($dbs, 'nodes', $biblio['node_info']['id'], 'ucs', 'Node ' . $node_id . '(' . $sysconf['node'][$node_id]['name'] . ') upload ' . $r . ' of catalog data');
Example #4
0
 $biblio['last_update'] = $input_date;
 // title
 $biblio['title'] = trim(substr_replace($biblio['title'], '', strpos($biblio['title'], '/')));
 // fot debugging purpose
 // var_dump($biblio);
 // die();
 // insert biblio data
 $sql_op->insert('biblio', $biblio);
 $biblio_id = $sql_op->insert_id;
 if ($biblio_id < 1) {
     continue;
 }
 // insert author
 if ($author_main) {
     // author
     $author_id = utility::getID($dbs, 'mst_author', 'author_id', 'author_name', $author_main, $author_cache);
     @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)");
 }
 // insert additional personal name authors
 if ($authors_add) {
     $author_id = 0;
     $author_type = 'p';
     foreach ($authors_add as $add_author) {
         $author_id = getAuthorID($add_author, $author_type, $author_cache);
         @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)");
     }
 }
 // insert corporate body authors
 if ($authors_corp) {
     $author_id = 0;
     $author_type = 'o';
Example #5
0
 foreach ($field as $idx => $value) {
     $field[$idx] = str_replace('\\', '', trim($value));
     $field[$idx] = $dbs->escape_string($field[$idx]);
 }
 // strip leading field encloser if any
 $item_code = '\'' . $field[0] . '\'';
 $call_number = $field[1] ? '\'' . $field[1] . '\'' : 'NULL';
 $coll_type = (int) utility::getID($dbs, 'mst_coll_type', 'coll_type_id', 'coll_type_name', $field[2], $ct_id_cache);
 $inventory_code = $field[3] ? '\'' . $field[3] . '\'' : 'NULL';
 $received_date = $field[4] ? '\'' . $field[4] . '\'' : 'NULL';
 $supplier = (int) utility::getID($dbs, 'mst_supplier', 'supplier_id', 'supplier_name', $field[5], $spl_id_cache);
 $order_no = $field[6] ? '\'' . $field[6] . '\'' : 'NULL';
 $location = utility::getID($dbs, 'mst_location', 'location_id', 'location_name', $field[7], $loc_id_cache);
 $location = $location ? '\'' . $location . '\'' : 'NULL';
 $order_date = $field[8] ? '\'' . $field[8] . '\'' : 'NULL';
 $item_status = utility::getID($dbs, 'mst_item_status', 'item_status_id', 'item_status_name', $field[9], $stat_id_cache);
 $item_status = $item_status ? '\'' . $item_status . '\'' : 'NULL';
 $site = $field[10] ? '\'' . $field[10] . '\'' : 'NULL';
 $source = $field[11] ? '\'' . $field[11] . '\'' : 'NULL';
 $invoice = $field[12] ? '\'' . $field[12] . '\'' : 'NULL';
 $price = $field[13] ? '\'' . $field[13] . '\'' : 'NULL';
 $price_currency = $field[14] ? '\'' . $field[14] . '\'' : 'NULL';
 $invoice_date = $field[15] ? '\'' . $field[15] . '\'' : 'NULL';
 $input_date = '\'' . $field[16] . '\'';
 $last_update = '\'' . $field[17] . '\'';
 // sql insert string
 $sql_str = "INSERT INTO item (item_code, call_number, coll_type_id,\n                        inventory_code, received_date, supplier_id,\n                        order_no, location_id, order_date, item_status_id, site,\n                        source, invoice, price, price_currency, invoice_date,\n                        input_date, last_update)\n                            VALUES ({$item_code}, {$call_number}, {$coll_type},\n                            {$inventory_code}, {$received_date}, {$supplier},\n                            {$order_no}, {$location}, {$order_date}, {$item_status}, {$site},\n                            {$source}, {$invoice}, {$price}, {$price_currency}, {$invoice_date},\n                            {$input_date}, {$last_update})";
 // send query
 // die($sql_str);
 $dbs->query($sql_str);
 // case duplicate do update
Example #6
0
     continue;
 } else {
     // get an array of field
     $field = fgetcsv($file, $max_chars, $field_sep, $field_enc);
     if ($field) {
         // strip escape chars from all fields
         foreach ($field as $idx => $value) {
             $field[$idx] = str_replace('\\', '', trim($value));
             $field[$idx] = $dbs->escape_string($field[$idx]);
         }
         // strip leading field encloser if any
         $member_id = preg_replace('@^\\\\s*' . $field_enc . '@i', '', $field[0]);
         $member_id = '\'' . $member_id . '\'';
         $member_name = '\'' . $field[1] . '\'';
         $gender = $field[2];
         $member_type_id = utility::getID($dbs, 'mst_member_type', 'member_type_id', 'member_type_name', $field[3], $mtype_id_cache);
         $member_email = $field[4] ? '\'' . $field[4] . '\'' : 'NULL';
         $member_address = $field[5] ? '\'' . $field[5] . '\'' : 'NULL';
         $postal_code = $field[6] ? '\'' . $field[6] . '\'' : 'NULL';
         $inst_name = $field[7] ? '\'' . $field[7] . '\'' : 'NULL';
         $is_new = $field[8] ? $field[8] : '0';
         $member_image = $field[9] ? '\'' . $field[9] . '\'' : 'NULL';
         $pin = $field[10] ? '\'' . $field[10] . '\'' : 'NULL';
         $member_phone = $field[11] ? '\'' . $field[11] . '\'' : 'NULL';
         $member_fax = $field[12] ? '\'' . $field[12] . '\'' : 'NULL';
         $member_since_date = '\'' . $field[13] . '\'';
         $register_date = '\'' . $field[14] . '\'';
         $expire_date = '\'' . $field[15] . '\'';
         $birth_date = $field[16] ? '\'' . $field[16] . '\'' : 'NULL';
         $member_notes = preg_replace('@\\\\s*' . $field_enc . '$@i', '', $field[17]);
         $member_notes = $member_notes ? '\'' . $member_notes . '\'' : 'NULL';
Example #7
0
         $author_id = utility::getID($dbs, 'mst_author', 'author_id', 'author_name', $author, $author_id_cache);
         $biblio_author_sql .= " ({$biblio_id}, {$author_id}, 2),";
     }
     // remove last comma
     $biblio_author_sql = substr_replace($biblio_author_sql, '', -1);
     // execute query
     $dbs->query($biblio_author_sql);
     // echo $dbs->error;
 }
 // set topic
 if (!empty($subjects)) {
     $biblio_subject_sql = 'INSERT IGNORE INTO biblio_topic (biblio_id, topic_id, level) VALUES ';
     $subjects = explode('><', $subjects);
     foreach ($subjects as $subject) {
         $subject = trim(str_replace(array('>', '<'), '', $subject));
         $subject_id = utility::getID($dbs, 'mst_topic', 'topic_id', 'topic', $subject, $subject_id_cache);
         $biblio_subject_sql .= " ({$biblio_id}, {$subject_id}, 2),";
     }
     // remove last comma
     $biblio_subject_sql = substr_replace($biblio_subject_sql, '', -1);
     // execute query
     $dbs->query($biblio_subject_sql);
     // echo $dbs->error;
 }
 // items
 if (!empty($items)) {
     $item_sql = 'INSERT IGNORE INTO item (biblio_id, item_code) VALUES ';
     $item_array = explode('><', $items);
     foreach ($item_array as $item) {
         $item = trim(str_replace(array('>', '<'), '', $item));
         $item_sql .= " ({$biblio_id}, '{$item}'),";
Example #8
0
     }
 }
 $column_pos = 0;
 $item_id = $field[$column_pos++];
 $item_code = $field[$column_pos++];
 $call_number = $field[$column_pos++];
 $coll_type_name = $field[$column_pos++];
 $coll_type_id = utility::getID($dbs, 'mst_coll_type', 'coll_type_id', 'coll_type_name', $coll_type_name, $ct_id_cache);
 $inventory_code = $field[$column_pos++];
 $supplier_name = $field[$column_pos++];
 $supplier_id = utility::getID($dbs, 'mst_supplier', 'supplier_id', 'supplier_name', $supplier_name, $spl_id_cache);
 $order_no = $field[$column_pos++];
 $location_name = $field[$column_pos++];
 $location_id = utility::getID($dbs, 'mst_location', 'location_id', 'location_name', $location_name, $loc_id_cache);
 $item_status = $field[$column_pos++];
 $item_status_id = utility::getID($dbs, 'mst_item_status', 'item_status_id', 'item_status_name', $item_status, $stat_id_cache);
 $site = $field[$column_pos++];
 $source = $field[$column_pos++];
 $invoice = $field[$column_pos++];
 $price = $field[$column_pos++];
 $price_currency = $field[$column_pos++];
 $title = $field[$column_pos++];
 // get current datetime
 $curr_datetime = '\'' . date('Y-m-d H:i:s') . '\'';
 if (!empty($item_id)) {
     $sql_str = "UPDATE item set ";
     $sql_str .= " item_id=" . (empty($item_id) ? 'null' : '\'' . $dbs->escape_string($item_id) . '\'');
     $sql_str .= ",item_code=" . (empty($item_code) ? 'null' : '\'' . $dbs->escape_string($item_code) . '\'');
     $sql_str .= ",call_number=" . (empty($call_number) ? 'null' : '\'' . $dbs->escape_string($call_number) . '\'');
     $sql_str .= ",coll_type_id=" . (empty($coll_type_id) ? 'null' : '\'' . $dbs->escape_string($coll_type_id) . '\'');
     $sql_str .= ",inventory_code=" . (empty($inventory_code) ? 'null' : '\'' . $dbs->escape_string($inventory_code) . '\'');
Example #9
0
             if (isset($subject[0])) {
                 // echo $subject[0]->getData();
                 $subject_type = 't';
                 $subject_id = getSubjectID($dbs->escape_string(trim($subject[0]->getData())), $subject_type, $subject_cache);
                 @$dbs->query("INSERT IGNORE INTO biblio_topic (biblio_id, topic_id, level) VALUES ({$biblio_id}, {$subject_id}, 1)");
             }
         }
     }
 }
 // Main entry
 $me_fld = $record->getField('100');
 if ($me_fld) {
     $mes = $me_fld->getSubfields('a');
     if (isset($me[0])) {
         // echo 'Main entry: '.$me[0]->getData();
         $author_id = utility::getID($dbs, 'mst_author', 'author_id', 'author_name', $dbs->escape_string(trim($me[0]->getData())), $author_cache);
         @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)");
     }
 }
 // Author additional
 $author_flds = $record->getFields('700|710|711', true);
 if ($author_flds) {
     // echo 'Author: ';
     foreach ($author_flds as $tag => $auth_fld) {
         if ($tag == '710') {
             $author_type = 'o';
         } else {
             if ($tag == '711') {
                 $author_type = 'c';
             } else {
                 $author_type = 'p';
Example #10
0
             if (isset($subject[0])) {
                 // echo $subject[0]->getData();
                 $subject_type = 't';
                 $subject_id = getSubjectID($subject[0]->getData(), $subject_type, $subject_cache);
                 @$dbs->query("INSERT IGNORE INTO biblio_topic (biblio_id, topic_id, level) VALUES ({$biblio_id}, {$subject_id}, 1)");
             }
         }
     }
 }
 // Main entry
 $me_fld = $record->getField('100');
 if ($me_fld) {
     $mes = $me_fld->getSubfields('a');
     if (isset($me[0])) {
         // echo 'Main entry: '.$me[0]->getData();
         $author_id = utility::getID($dbs, 'mst_author', 'author_id', 'author_name', $me[0]->getData(), $author_cache);
         @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)");
     }
 }
 // Author additional
 $author_flds = $record->getFields('700|710|711', true);
 if ($author_flds) {
     // echo 'Author: ';
     foreach ($author_flds as $tag => $auth_fld) {
         if ($tag == '710') {
             $author_type = 'o';
         } else {
             if ($tag == '711') {
                 $author_type = 'c';
             } else {
                 $author_type = 'p';
Example #11
0
         $data['edition'] .= $dbs->escape_string(trim($ed2[0]->getData()));
     }
 }
 // Publication
 $pbl_fld = $record->getField('260');
 if ($pbl_fld) {
     $place = $pbl_fld->getSubfields('a');
     $publisher = $pbl_fld->getSubfields('b');
     $publish_year = $pbl_fld->getSubfields('c');
     if (isset($place[0])) {
         // echo "\n"; echo 'Publish place: '.$place[0]->getData();
         $data['publish_place_id'] = utility::getID($dbs, 'mst_place', 'place_id', 'place_name', $place[0]->getData(), $place_cache);
     }
     if (isset($publisher[0])) {
         // echo 'Publisher: '.$publisher[0]->getData();
         $data['publisher_id'] = utility::getID($dbs, 'mst_publisher', 'publisher_id', 'publisher_name', $publisher[0]->getData(), $publ_cache);
     }
     if (isset($publish_year[0])) {
         // echo 'Publish year: '.$publish_year[0]->getData();
         $data['publish_year'] = $publish_year[0]->getData();
     }
 }
 // Collation
 $clt_fld = $record->getField('300');
 if ($clt_fld) {
     $data['collation'] = '';
     $pages = $clt_fld->getSubfields('a');
     $ilus = $clt_fld->getSubfields('b');
     $dimension = $clt_fld->getSubfields('c');
     if (isset($pages[0])) {
         // echo 'Pages: '.$pages[0]->getData();