00001 /* 00002 ** Copyright (C) 2000 Alan McIvor <alan@mcivor.gen.nz> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 #ifdef HAVE_CONFIG_H 00019 #include <config.h> 00020 #endif 00021 00022 using namespace std; 00023 00024 #include "project.h" 00025 00026 #include <algorithm> 00027 00028 extern "C" { 00029 #include "base.h" 00030 } 00031 00032 00033 00034 Project::Project() 00035 { 00036 00037 #ifdef VARIABLE 00038 # undef VARIABLE 00039 #endif 00040 00041 # define VARIABLE(AA,BB,CC) BB = CC; 00042 00043 #include "globals.i" 00044 00045 for ( int i = 0; i < MAX_TIME ; i++ ) 00046 { 00047 days[i].t = 0; 00048 days[i].s = NULL; 00049 days[i].num = 0; 00050 } 00051 00052 monthNames[0] = "Jan"; 00053 monthNames[1] = "Feb"; 00054 monthNames[2] = "Mar"; 00055 monthNames[3] = "Apr"; 00056 monthNames[4] = "May"; 00057 monthNames[5] = "Jun"; 00058 monthNames[6] = "Jul"; 00059 monthNames[7] = "Aug"; 00060 monthNames[8] = "Sep"; 00061 monthNames[9] = "Oct"; 00062 monthNames[10] = "Nov"; 00063 monthNames[11] = "Dec"; 00064 00065 dayNames[0] = "Su"; 00066 dayNames[1] = "Mo"; 00067 dayNames[2] = "Tu"; 00068 dayNames[3] = "We"; 00069 dayNames[4] = "Th"; 00070 dayNames[5] = "Fr"; 00071 dayNames[6] = "Sa"; 00072 }; 00073 00074 00075 Project::~Project() 00076 { 00077 } 00078 00079 00080 00081 MILESTONE * Project::sortedMilestone(int i) 00082 { 00083 return mSortedMilestoneList[i]; 00084 } 00085 00086 00087 void Project::SortMilestones() 00088 { 00089 if ( mSortedMilestoneList.size() != 0 ) 00090 return; 00091 LoadDays(); 00092 mSortedMilestoneList = mMilestoneList; 00093 sort( mSortedMilestoneList.begin(), mSortedMilestoneList.end(), CompareMilestoneDates() ); 00094 } 00095 00096 00097 double Project::itemCost() 00098 { 00099 double value = 0.0; 00100 for ( ITEM::PTRLIST::const_iterator ip = mItems.begin() ; ip != mItems.end() ; ip++) 00101 value += (*ip)->cost(); 00102 00103 return value; 00104 } 00105 00106 00107 void Project::SortTasks(bool tg_sortbyresource) 00108 { 00109 if ( mSortedTaskList.size() != 0 ) 00110 return; 00111 LoadDays(); 00112 mSortedTaskList = mTaskList; 00113 if ( tg_sortbyresource ) 00114 sort( mSortedTaskList.begin(), mSortedTaskList.end(), CompareTaskResources() ); 00115 else 00116 sort( mSortedTaskList.begin(), mSortedTaskList.end(), CompareTaskStarts() ); 00117 } 00118 00119