id = $id; $this->db_table = Config::$db_tables['vendor_designers']; $this->set_data($data); } function get_data() { return(Database::ado_get_row("SELECT * FROM $this->db_table WHERE id='$this->id'", "Designer::get_data")); } function set_data($data='') { $this->data = (is_array($data)) ? $data : $this->get_data(); } function num_items() { if(!$RS = $this->get_items_RecordSet()) { return(0); } else { return($RS->RecordCount()); } } function has_live_items($Items, $Sizes) { if(!$RS = $this->get_items_RecordSet('active')) { return(FALSE); } while($record = $RS->FetchRow()) { $Item = new Item($record['id']); if($Item->is_live_web($Items)) { return(TRUE); } } return(FALSE); } function num_live_items($Items, $Sizes) { if(!$RS = $this->get_items_RecordSet('active')) { return(0); } $num =0; while($record = $RS->FetchRow()) { $Item = new Item($Items, $Sizes, $record['id']); if($Item->is_available_web()) { ++$num; } } return($num); } function is_featured() { return(Database::ado_get_record_count("SELECT * FROM ".Config::$db_tables['vendor_designers_featured_images']." WHERE designer_id='$this->id'", "Designers::is_featured") > 0); } function _delete() { Database::ado_execute_query("DELETE FROM $this->db_table WHERE id='$this->id' LIMIT 1"); } function delete_files_for_image($Items, $filename) { $image_files_to_delete = array(); foreach($Items->images as $image_size=>$image_size_info) { $image_files_to_delete[$image_size] = $image_size_info['path'].$filename; } foreach($image_files_to_delete as $path_file) { Utilities::delete_file($path_file); } } function delete_image_files($Designers, $which='all') { // by default this removes all files for all images associated with this designer ($this->images) // $which can be sent in as an array of image orders to delete if(!isset($this->data)) { echo 'Item->data not set'; return(FALSE); } foreach($this->images as $image_order=>$image_info) { if($which == 'all' || in_array($image_order, $which)) { $this->delete_files_for_image($Items, $image_info['filename']); } } } function get_items_RecordSet($status_web='all', $order_by='') { $query = "SELECT * FROM ".Config::$db_tables['inventory_items']." WHERE designer_id='$this->id'"; if($status_web != 'all') { $query .= " AND status_web='$status_web'"; } if($order_by != '') { $query .= " ORDER BY $order_by"; } return(Database::ado_execute_query($query, 'Designer::get_items_RecordSet')); } } ?>