/* FILE $Id$ (Built initially by unixservice.com mysqlRAD2) PURPOSE Non schema-dependent table and application table related functions. AUTHOR (C) 2001-2008 Gary Wallis and Hugo Urquiza. */ //ModuleFunctionProtos() void tNSTypeNavList(void); void tNSTypeContextInfo(void); void ExtProcesstNSTypeVars(pentry entries[], int x) { /* register int i; for(i=0;i=9) { ProcesstNSTypeVars(entries,x); guMode=2000; tNSType(LANG_NB_CONFIRMNEW); } else tNSType("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMNEW)) { if(guPermLevel>=9) { unsigned uContactParentCompany=0; ProcesstNSTypeVars(entries,x); GetClientOwner(guLoginClient,&uContactParentCompany); guMode=2000; //Check entries here guMode=0; uNSType=0; uCreatedBy=guLoginClient; uOwner=uContactParentCompany; uModBy=0;//Never modified uModDate=0;//Never modified NewtNSType(0); } else tNSType("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_DELETE)) { ProcesstNSTypeVars(entries,x); if(uAllowDel(uOwner,uCreatedBy)) { guMode=2001; tNSType(LANG_NB_CONFIRMDEL); } else tNSType("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMDEL)) { ProcesstNSTypeVars(entries,x); if(uAllowDel(uOwner,uCreatedBy)) { guMode=5; DeletetNSType(); } else tNSType("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_MODIFY)) { ProcesstNSTypeVars(entries,x); if(uAllowMod(uOwner,uCreatedBy)) { guMode=2002; tNSType(LANG_NB_CONFIRMMOD); } else tNSType("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMMOD)) { ProcesstNSTypeVars(entries,x); if(uAllowMod(uOwner,uCreatedBy)) { guMode=2002; //Check entries here guMode=0; uModBy=guLoginClient; ModtNSType(); } else tNSType("Error: Denied by permissions settings"); } } }//void ExttNSTypeCommands(pentry entries[], int x) void ExttNSTypeButtons(void) { OpenFieldSet("tNSType Aux Panel",100); switch(guMode) { case 2000: printf("

Enter/mod data
"); printf(LANG_NBB_CONFIRMNEW); break; case 2001: printf("

Think twice
"); printf(LANG_NBB_CONFIRMDEL); break; case 2002: printf("

Review changes
"); printf(LANG_NBB_CONFIRMMOD); break; default: printf("Table Tips
"); printf("

Record Context Info
"); tNSTypeContextInfo(); tNSTypeNavList(); } CloseFieldSet(); }//void ExttNSTypeButtons(void) void ExttNSTypeAuxTable(void) { }//void ExttNSTypeAuxTable(void) void ExttNSTypeGetHook(entry gentries[], int x) { register int i; for(i=0;i11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tNSType ORDER BY" " uNSType", VAR_LIST_tNSType); else //If you own it, the company you work for owns the company that owns it, //you created it, or your company owns it you can at least read access it //select tTemplateSet.cLabel from tTemplateSet,tClient where tTemplateSet.uOwner=tClient.uClient and tClient.uOwner in (select uClient from tClient where uOwner=81 or uClient=51); sprintf(gcQuery,"SELECT %s FROM tNSType,tClient WHERE tNSType.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)" " ORDER BY uNSType", VAR_LIST_tNSType,uContactParentCompany,uContactParentCompany); }//void ExttNSTypeSelect(void) void ExttNSTypeSelectRow(void) { unsigned uContactParentCompany=0; GetClientOwner(guLoginClient,&uContactParentCompany); if(guLoginClient==1 && guPermLevel>11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tNSType WHERE uNSType=%u", VAR_LIST_tNSType,uNSType); else sprintf(gcQuery,"SELECT %s FROM tNSType,tClient" " WHERE tNSType.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)" " AND tNSType.uNSType=%u", VAR_LIST_tNSType ,uContactParentCompany,uContactParentCompany ,uNSType); }//void ExttNSTypeSelectRow(void) void ExttNSTypeListSelect(void) { char cCat[512]; unsigned uContactParentCompany=0; GetClientOwner(guLoginClient,&uContactParentCompany); if(guLoginClient==1 && guPermLevel>11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tNSType", VAR_LIST_tNSType); else sprintf(gcQuery,"SELECT %s FROM tNSType,tClient" " WHERE tNSType.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)", VAR_LIST_tNSType ,uContactParentCompany ,uContactParentCompany); //Changes here must be reflected below in ExttNSTypeListFilter() if(!strcmp(gcFilter,"uNSType")) { sscanf(gcCommand,"%u",&uNSType); if(guPermLevel<10) strcat(gcQuery," AND "); else strcat(gcQuery," WHERE "); sprintf(cCat,"tNSType.uNSType=%u" " ORDER BY uNSType", uNSType); strcat(gcQuery,cCat); } else if(1) { //None NO FILTER strcpy(gcFilter,"None"); strcat(gcQuery," ORDER BY uNSType"); } }//void ExttNSTypeListSelect(void) void ExttNSTypeListFilter(void) { //Filter printf("   Filter on "); printf(""); }//void ExttNSTypeListFilter(void) void ExttNSTypeNavBar(void) { printf(LANG_NBB_SKIPFIRST); printf(LANG_NBB_SKIPBACK); printf(LANG_NBB_SEARCH); if(guPermLevel>=7 && !guListMode) printf(LANG_NBB_NEW); if(uAllowMod(uOwner,uCreatedBy)) printf(LANG_NBB_MODIFY); if(uAllowDel(uOwner,uCreatedBy)) printf(LANG_NBB_DELETE); if(uOwner) printf(LANG_NBB_LIST); printf(LANG_NBB_SKIPNEXT); printf(LANG_NBB_SKIPLAST); printf("   \n"); }//void ExttNSTypeNavBar(void) void tNSTypeNavList(void) { MYSQL_RES *res; MYSQL_ROW field; unsigned uContactParentCompany=0; GetClientOwner(guLoginClient,&uContactParentCompany); GetClientOwner(uContactParentCompany,&guReseller);//Get owner of your owner... if(guReseller==1) guReseller=0;//...except Root companies if(guLoginClient==1 && guPermLevel>11)//Root can read access all sprintf(gcQuery,"SELECT uNSType,cLabel FROM tNSType ORDER BY cLabel"); else sprintf(gcQuery,"SELECT tNSType.uNSType," " tNSType.cLabel" " FROM tNSType,tClient" " WHERE tNSType.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)", uContactParentCompany ,uContactParentCompany); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) { printf("

tNSTypeNavList
\n"); printf("%s",mysql_error(&gMysql)); return; } res=mysql_store_result(&gMysql); if(mysql_num_rows(res)) { printf("

tNSTypeNavList
\n"); while((field=mysql_fetch_row(res))) printf("%s
\n", field[0],field[1]); } mysql_free_result(res); }//void tNSTypeNavList(void) void tNSTypeContextInfo(void) { MYSQL_RES *res; MYSQL_ROW field; if(!uNSType) return; sprintf(gcQuery,"SELECT COUNT(tZone.uZone) FROM tNSSet,tNS,tZone WHERE" " tZone.uNSSet=tNSSet.uNSSet AND tNSSet.uNSSet=tNS.uNSSet AND" " tNS.uNSType=%u",uNSType); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) { printf("tNSTypeContextInfo:
\n"); printf("%s",mysql_error(&gMysql)); return; } res=mysql_store_result(&gMysql); if((field=mysql_fetch_row(res))) { printf("tNSTypeContextInfo:
\n"); printf("%s zones are assigned to NS sets that have NS associated with this type.",field[0]); } mysql_free_result(res); }//void tNSTypeContextInfo(void)