function update_stack($data)
 {
     $this->load->helper('call_number');
     //Check for blank data, prevent insert if data is missing
     foreach ($data as $x) {
         if ($x === false) {
             return FALSE;
         }
     }
     //Create the location of the stack
     $ins_data = array('floor_id' => $data['floor'], 'type_id' => $data['item_type'], 'loc_name' => $data['loc_name']);
     $this->db->where('loc_id', $data['loc_id']);
     $this->db->update('tbl_location', $ins_data);
     //Check to see if location being inserted is a stack
     $this->db->where('type_id', $data['item_type']);
     $is_stack_query = $this->db->get('tbl_item_type');
     $is_stack_result = $is_stack_query->row();
     //If item is a stack
     if ($is_stack_result->is_stack == 1) {
         //Create the stack range
         $ins_data = array('stack_type_id' => $data['stack_type'], 'call_range_start' => $data['call_start'], 'call_range_end' => $data['call_end'], 'call_int_start' => convert_callnum($data['call_start']), 'call_int_end' => convert_callnum($data['call_end']));
         $this->db->where('loc_id', $data['loc_id']);
         $this->db->update('tbl_stack_range', $ins_data);
     }
 }
Beispiel #2
0
 function callno_search($callno)
 {
     $this->load->helper('call_number');
     $catalogue = $this->catalogue_info($callno);
     //Convert to long integer first
     $call_int = convert_callnum($catalogue['callNumber']);
     if ($catalogue === '3') {
         return array('3');
     }
     if (is_array($catalogue)) {
         foreach ($catalogue as $property => $value) {
             $data[$property] = $value;
         }
         //Get XISBN info
         if (isset($data['isbn']) && $data['isbn'] != "") {
             foreach ($this->xisbn_info($data['isbn']) as $property => $value) {
                 $data[$property] = $value;
             }
         }
     }
     $online_only = true;
     foreach ($data['availability'] as $item_avail) {
         if (isset($data['location']) && count($data['location']) > 1) {
             $online_only = false;
         } else {
             if (isset($data['location']) && count($data['location']) == 1 && $data['isOnline'] == false) {
                 $online_only = false;
             } else {
                 if (!isset($data['location']) || count($data['location'] === 0)) {
                     if ($online_only === FALSE) {
                         return array("3");
                     }
                 } else {
                     break;
                 }
             }
         }
     }
     if ($online_only) {
         $data['availability'] = "ONLINE";
         return array("2", array($data));
     }
     $loc_data = array();
     $count = 0;
     foreach ($data['location'] as $location) {
         //Get database information
         $stack_location = $this->db->query("SELECT CONCAT('" . MAPS_DIR . "/',c.img_url) as img_url, b.*, s_type.priority \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM tbl_stack_range a, tbl_location b, tbl_floors c, tbl_stack_type s_type \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.stack_type_id = s_type.stack_type_id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $this->db->escape_str(trim($location)) . "' LIKE s_type.catalogue_pattern AND\n\t\t\t\t\t\t\t\t\t\t\t\t\ta.loc_id = b.loc_id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tc.floor_id = b.floor_id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\ta.call_int_start <= " . $call_int . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\ta.call_int_end > " . $call_int);
         if ($stack_location->num_rows() === 0) {
             $temp['hasLocation'] = false;
         } else {
             $temp['hasLocation'] = true;
         }
         //Has a known location, store data into array
         foreach ($stack_location->row() as $property => $value) {
             $temp[$property] = $value;
         }
         if (isset($data['availability'][$count])) {
             $temp['availability'] = trim($data['availability'][$count]);
         }
         $temp['location'] = trim($location);
         if (isset($data['cover_url'])) {
             $temp['cover_url'] = trim($data['cover_url']);
         }
         if (isset($data['isbn'])) {
             $temp['isbn'] = trim($data['isbn']);
         }
         if (isset($data['isOnline'])) {
             $temp['isOnline'] = trim($data['isOnline']);
         }
         if (isset($data['author'])) {
             $temp['author'] = trim($data['author']);
         }
         if (isset($data['title'])) {
             $temp['title'] = trim($data['title']);
         }
         if (isset($data['callNumber'])) {
             $temp['callNumber'] = trim($data['callNumber']);
         }
         if (isset($data['bibno'])) {
             $temp['bibno'] = trim($data['bibno']);
         }
         //If location exists, check its availability. Keep it if it says "AVAILABLE"
         if (isset($loc_data[$location]) && isset($loc_data[$location]['availability']) && $loc_data[$location]['availability'] === "AVAILABLE") {
             $temp['availability'] = "AVAILABLE";
         }
         $loc_data[$location] = $temp;
         //This will keep the last entry of a location's availability
         $count++;
     }
     $json_array = array_values($loc_data);
     //if(count($json_array) === 1 && $json_array[0]['hasLocation'] === false) return array("2", $json_array); //Exists in catalogue but no known location
     $item_located = false;
     foreach ($json_array as $loc) {
         if ($loc['hasLocation']) {
             $item_located = true;
         }
     }
     if (!$item_located) {
         //SEND EMAIL
         $this->load->library('email');
         $this->email->from('*****@*****.**', 'Bookfinder Message');
         $this->email->to(UNMAPPED_EMAIL);
         $this->email->subject('An item was unable to be located in Bookfinder');
         $this->email->message("A user has searched for: <a href=\"http://catalogue.library.ryerson.ca/record=" . urldecode($callno) . "\">" . urldecode($callno) . "</a>, but Bookfinder was unable to find a known location. " . "Please verfify the record has a shelf assigned to it.<br /><br />" . "If you believe this is an error, please contact a member of the LITS Team");
         $this->email->send();
         return array("2", $json_array);
         //Exists in catalogue but no known location
     }
     //print_r($json_array);
     //Sort by priority first
     usort($json_array, "_priority_sort");
     return array("1", $json_array);
     //array_values to return an indexed array rather then assioative
 }