Ejemplo n.º 1
0
 public function __construct($id = 0, $role_object = null, $show_history = false)
 {
     $database = $_SESSION['database'];
     $this->id = $id;
     $this->roles = array();
     $this->listing = array();
     if ($id != 0) {
         $id = $database->prepare_input($id);
         $projects_query = $database->query("SELECT projects_name, projects_description, projects_customers_contact_name, projects_customers_reference, projects_start_date, projects_end_date, projects_calculated_hours, projects_calculated_hours_period, business_units_id, customers_id FROM " . TABLE_PROJECTS . " WHERE projects_id = '" . (int) $id . "';");
         $projects_result = $database->fetch_array($projects_query);
         if (tep_not_null($projects_result)) {
             // Project exists
             $this->fill($projects_result['projects_name'], $projects_result['projects_description'], $projects_result['projects_customers_contact_name'], $projects_result['projects_customers_reference'], tep_datetouts(DATE_FORMAT_DATABASE, $projects_result['projects_start_date']), $projects_result['projects_end_date'] != '2099-12-31' ? tep_datetouts(DATE_FORMAT_DATABASE, $projects_result['projects_end_date']) : 0, $projects_result['projects_calculated_hours'], $projects_result['projects_calculated_hours_period'], $projects_result['business_units_id'], $projects_result['customers_id']);
             // Retrieve specific role or all available roles for this project
             if (tep_not_null($role_object)) {
                 if (is_object($role_object)) {
                     $this->roles[sizeof($this->roles)] = $role_object;
                 }
             } else {
                 $temp_role = new role();
                 // Create a default role (id==0)
                 $this->roles = $temp_role->get_array($this->id);
             }
         }
     } else {
         // We probably created an empty project object to retrieve the entire project listing
         $this->listing = $this->get_array($show_history);
     }
 }