home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------------------------------------------//
- // Create Manager Palmares list : must be called in Manager Page context
- func i32x iCreateManagerPalmaresList()
- {
- var i32x i,iNumItems;
-
- i = InitList(
- "Manager Palmares List", // List name
- 256, // Max item number
- 600,230, // Width, height
- Manager_Palmares_Item_Create,Manager_Palmares_Item_Update,Manager_Palmares_Item_Event, // Item oFunc
- t_btn_slider, // Slider texture
- NullButtonState); // State func for the slider
-
- SetComponentPosition(i,20,230);
-
- return i;
- }
-
-
- //Manager Palmares Item Create func
- //----------------------------------------------------------------------------------------------------------------//
- func void Manager_Palmares_Item_Create ()
- {
- var i32x id;
- SetComponentNumber(1);
- SetObjectMembersNumber(2);
-
- // Palmares result
- oManager_Palmares_Item.m_cResult=InitContainer(tFontArialItalique);
- SetComponentPositionX(oManager_Palmares_Item.m_cResult,20);
- SetComponentSize(oManager_Palmares_Item.m_cResult,580,16);
-
- SetObjectSize(580,16);
- }
-
- //Manager Palmares Item Update func
- //----------------------------------------------------------------------------------------------------------------//
- func void Manager_Palmares_Item_Update (i32x _iItemID)
- {
- var i32x iRank,iRace,iClassification,iCyclistID;
- var szx szText;
- var szx szRaceName,szClassificationName,szRank;
-
- iRank = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_irank,_iItemID);
- iRace = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_ifkIDrace,_iItemID);
- iClassification = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_ifkIDclassification,_iItemID);
-
- // Get the name of the race
- szRaceName = GetLocalizedFromKey(Database_GetIntData(QUERY_GLOBAL_STAGES,"STA_race.gene_strID_race_name",ROW_KEY,iRace));
-
- // Get the name of the classification
- szClassificationName = GetLocalizedFromKey(Database_GetIntData(QUERY_GLOBAL_CLASSIFICATION,"STA_classification.gene_strID_classification_name",ROW_KEY,iClassification));
-
- // Get the name of the rank
- if(iRank == 1)
- szRank = GetLocalizedFromGMKey(421); // First
- else
- {
- if(iRank == 2)
- szRank = GetLocalizedFromGMKey(422); // Second
- else
- szRank = GetLocalizedFromGMKey(423); // Third
- }
-
- szText = strcat(szRaceName, " - ");
- szText = strcat(szText, szClassificationName);
- szText = strcat(szText, " : ");
- szText = strcat(szText, szRank);
-
- // Get Cyclist name
- iCyclistID = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_ifkIDcyclist,_iItemID);
- if(iCyclistID>0)
- {
- var szx szFirstName,szLastName,szName;
-
- szFirstName = Database_GetStringData(QUERY_GLOBAL_CYCLISTS,"DYN_cyclist.gene_sz_firstname",ROW_KEY,iCyclistID);
- szLastName = Database_GetStringData(QUERY_GLOBAL_CYCLISTS,"DYN_cyclist.gene_sz_lastname",ROW_KEY,iCyclistID);
-
- szName = strncpy(szFirstName,1); // First name initial
- szName = strcat(szName,". ");
- szName = strcat(szName,szLastName);
- szText = strcat(szText, " (");
- szText = strcat(szText, szName);
- szText = strcat(szText, ")");
- }
-
- SetContainerText(oManager_Palmares_Item.m_cResult, szText);
- if(iRank == 1)
- SetContainerColor(oManager_Palmares_Item.m_cResult,c_Yellow);
- else
- SetContainerColor(oManager_Palmares_Item.m_cResult,c_White);
- SetContainerOffset(oManager_Palmares_Item.m_cResult,-1);
-
- }
- //Manager Palmares Item Event func
- //----------------------------------------------------------------------------------------------------------------//
- func i32x Manager_Palmares_Item_Event (i32x _iComponentID, i32x _iEvent)
- {
- return 1;
- }
-
- //----------------------------------------------------------------------------------------------------------------//
- // Update Manager Palmares list
- func void Manager_Palmares_Update_List_Display ()
- {
- var i32x iNumItems;
- var component poComponent;
-
- //Save context
- poComponent = GetParserComponent();
- SetParserComponent(oPage_Manager.pThis);
-
- // Clear the subset to fill it with new data
- DatabaseSubset_Clear(TEMP_DATABASE);
-
- // create query to fill the subset
- Query_Create(0, TEMP_DATABASE);
- Query_SetNumJoinTables( 0, 1);
- Query_SelectJoinTable( 0, 0, "DYN_palmares");
-
- // Only results for the current manager
- Query_SelectWhereIntEqual(0, "DYN_palmares.fkIDmanager", oObject_Profil.m_iManagerID); // result for the current manager
- Query_Execute(0);
-
- // Order by race
- Table_Sort(TEMP_DATABASE,"DYN_palmares","fkIDrace",-1);
- Table_Sort(TEMP_DATABASE,"DYN_palmares","fkIDclassification",1);
- Table_Sort(TEMP_DATABASE,"DYN_palmares","gene_i_rank",1);
-
-
- iNumItems = Table_GetNumRows(TEMP_DATABASE,0);
- SetListNbItems(oManager_Palmares.iPalmaresID,iNumItems);
-
- if(iNumItems>0)
- {
- SetListPosition(oManager_Palmares.iPalmaresID,0);
- SetListSelectedItem(oManager_Palmares.iPalmaresID,0);
- }
-
- // Restore context
- SetParserComponent(poComponent);
-
- }
-
- //----------------------------------------------------------------------------------------------------------------//
- // Create manager palmares joins
- //----------------------------------------------------------------------------------------------------------------//
- func void CreateManagerPalmaresJoins()
- {
- // Create subset to store data
- DatabaseSubset_Create( TEMP_DATABASE, QUERY_MANAGER_PALMARES);
- Database_AddTables( TEMP_DATABASE, 1);
- Table_SetName( TEMP_DATABASE, 0, "DYN_palmares");
- TableSubset_SelectColumns( TEMP_DATABASE, 0, "*");
-
- oManager_Palmares.m_jManager_Palmares_irank = Join_Constructor(TEMP_DATABASE,"DYN_palmares.gene_i_rank");
- oManager_Palmares.m_jManager_Palmares_ifkIDrace = Join_Constructor(TEMP_DATABASE,"DYN_palmares.fkIDrace");
- oManager_Palmares.m_jManager_Palmares_ifkIDclassification = Join_Constructor(TEMP_DATABASE,"DYN_palmares.fkIDclassification");
- oManager_Palmares.m_jManager_Palmares_ifkIDcyclist = Join_Constructor(TEMP_DATABASE,"DYN_palmares.fkIDcyclist");
-
- }
-
- //----------------------------------------------------------------------------------------------------------------//
- // Destroy manager palmares joins
- //----------------------------------------------------------------------------------------------------------------//
- func void DestroyManagerPalmaresJoins()
- {
- if(oManager_Palmares.m_jManager_Palmares_irank > 0)
- {
- Join_Destructor(oManager_Palmares.m_jManager_Palmares_irank);
- oManager_Palmares.m_jManager_Palmares_irank = 0;
- }
-
- if(oManager_Palmares.m_jManager_Palmares_ifkIDrace > 0)
- {
- Join_Destructor(oManager_Palmares.m_jManager_Palmares_ifkIDrace);
- oManager_Palmares.m_jManager_Palmares_ifkIDrace = 0;
- }
-
- if(oManager_Palmares.m_jManager_Palmares_ifkIDclassification > 0)
- {
- Join_Destructor(oManager_Palmares.m_jManager_Palmares_ifkIDclassification);
- oManager_Palmares.m_jManager_Palmares_ifkIDclassification = 0;
- }
-
- if(oManager_Palmares.m_jManager_Palmares_ifkIDcyclist > 0)
- {
- Join_Destructor(oManager_Palmares.m_jManager_Palmares_ifkIDcyclist);
- oManager_Palmares.m_jManager_Palmares_ifkIDcyclist = 0;
- }
- }
-