function set($var, $value) { $value = mydb::cxn()->real_escape_string($value); switch ($var) { case 'serial_num': // Test for the correct form (i.e. COH-123) 2-5 letters, hyphen, 3-7 numbers if (preg_match('/\\b[a-zA-Z]{2,5}-[0-9]{3,7}\\b/', $value) != 1) { throw new Exception('Rappel Equipment serial numbers must be written as 2-5 letters followed by a hyphen and 3-7 numbers (i.e. COH-1234567) : ' . $value); } else { // Make sure that the requested serial_num is NOT already in the database. if ($this->is_duplicate($value, get_class($this))) { throw new Exception('There is already a ' . get_class($this) . ' with a Serial Number of ' . strtoupper($value)); } else { parent::set('serial_num', strtoupper($value)); } } break; case 'mfr_serial_num': //This field will store the manufacturer's serial number in the event that an item has been assigned a 'local' serial number by the owner. //The database allows a VARCHAR of 0-15 characters if (strlen($value) > 15) { throw new Exception('The manufacturer\'s serial number can only be 15 characters'); } else { $this->mfr_serial_num = $value; } break; case 'use_offset': if ($value == "") { $this->use_offset = 0; } elseif (!$this->var_is_int($value)) { throw new Exception('The USE_OFFSET must be an integer value.'); } else { $this->use_offset = $value; } break; case 'in_service_date': //This must be either blank or mm/dd/yyyy $dates = explode("/", $value); // The Date ($value) should be in the form: mm/dd/yyyy if ($value != "" && !checkdate((int) $dates[0], (int) $dates[1], (int) $dates[2])) { throw new Exception('The In-Service Date entered is not a valid date (dates must be in the form: mm/dd/yyyy)'); } else { $this->in_service_date = $value; } break; case 'retired_date': //This must be either blank or mm/dd/yyyy $dates = explode("/", $value); // The Date ($value) should be in the form: mm/dd/yyyy if ($value != "" && !checkdate((int) $dates[0], (int) $dates[1], (int) $dates[2])) { throw new Exception('The Retirement Date entered is not a valid date (dates must be in the form: mm/dd/yyyy)'); } else { $this->retired_date = $value; } break; case 'retired_reason': $this->retired_reason = $value; //This value is a string with no restrictions. Just store it. break; case 'retired_category': /* if(in_array(strtolower($value),$this->valid_retired_categories)) $this->retired_category = strtolower($value); else throw new Exception('The rappel_equipment->set() function attempted to set an invalid \'retired_category\' ('.$value.')'); */ $this->retired_category = strtolower($value); break; default: parent::set($var, $value); // If this request is not specific to a piece of rappel equipment, let the ITEM class deal with it //throw new Exception('The rappel_equipment->set() function attempted to modify an invalid variable ('.$var.')'); break; } // End: switch($var) }