| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | tJob source code of unxsVZ.cgi |
|---|
| 4 | Built by mysqlRAD2.cgi (C) Gary Wallis 2001-2007 |
|---|
| 5 | $Id$ |
|---|
| 6 | PURPOSE |
|---|
| 7 | Schema dependent RAD generated file. |
|---|
| 8 | Program app functionality in tjobfunc.h while |
|---|
| 9 | RAD is still to be used. |
|---|
| 10 | AUTHOR/LEGAL |
|---|
| 11 | (C) 2001-2010 Gary Wallis for Unixservice, LLC. |
|---|
| 12 | GPLv2 license applies. See LICENSE file. |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | #include "mysqlrad.h" |
|---|
| 17 | |
|---|
| 18 | //Table Variables |
|---|
| 19 | //Table Variables |
|---|
| 20 | //uJob: Primary Key |
|---|
| 21 | static unsigned uJob=0; |
|---|
| 22 | //cLabel: Label for user feedback |
|---|
| 23 | static char cLabel[101]={""}; |
|---|
| 24 | //cJobName: Subsystem.Function style job name |
|---|
| 25 | static char cJobName[65]={""}; |
|---|
| 26 | //uDatacenter: Collection of uNodes |
|---|
| 27 | static unsigned uDatacenter=0; |
|---|
| 28 | //uNode: Hardware node |
|---|
| 29 | static unsigned uNode=0; |
|---|
| 30 | //uContainer: VZ VE container running on uNode |
|---|
| 31 | static unsigned uContainer=0; |
|---|
| 32 | //cJobData: Remote subsystem server function arguments |
|---|
| 33 | static char *cJobData={""}; |
|---|
| 34 | //uJobDate: Unix seconds for job to start to be considered |
|---|
| 35 | static time_t uJobDate=0; |
|---|
| 36 | //uJobStatus: Waiting, being processed, done, error |
|---|
| 37 | static unsigned uJobStatus=0; |
|---|
| 38 | static char cuJobStatusPullDown[256]={""}; |
|---|
| 39 | //cRemoteMsg: Remote subsytem error message |
|---|
| 40 | static char cRemoteMsg[65]={""}; |
|---|
| 41 | //uOwner: Record owner |
|---|
| 42 | static unsigned uOwner=0; |
|---|
| 43 | //uCreatedBy: uClient for last insert |
|---|
| 44 | static unsigned uCreatedBy=0; |
|---|
| 45 | //uCreatedDate: Unix seconds date last insert |
|---|
| 46 | static time_t uCreatedDate=0; |
|---|
| 47 | //uModBy: uClient for last update |
|---|
| 48 | static unsigned uModBy=0; |
|---|
| 49 | //uModDate: Unix seconds date last update |
|---|
| 50 | static time_t uModDate=0; |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | #define VAR_LIST_tJob "tJob.uJob,tJob.cLabel,tJob.cJobName,tJob.uDatacenter,tJob.uNode,tJob.uContainer,tJob.cJobData,tJob.uJobDate,tJob.uJobStatus,tJob.cRemoteMsg,tJob.uOwner,tJob.uCreatedBy,tJob.uCreatedDate,tJob.uModBy,tJob.uModDate" |
|---|
| 54 | |
|---|
| 55 | //Local only |
|---|
| 56 | void Insert_tJob(void); |
|---|
| 57 | void Update_tJob(char *cRowid); |
|---|
| 58 | void ProcesstJobListVars(pentry entries[], int x); |
|---|
| 59 | void tJobNewStep(unsigned uStep); |
|---|
| 60 | void RecurringJobDropDown(unsigned uSelector, unsigned uMode); |
|---|
| 61 | unsigned ReadRecurringDropDown(char *cRecurringJobDropDown); |
|---|
| 62 | static unsigned uRecurringJob=0; |
|---|
| 63 | static char cRecurringJobDropDown[100]={""}; |
|---|
| 64 | |
|---|
| 65 | //In tJobfunc.h file included below |
|---|
| 66 | void ExtProcesstJobVars(pentry entries[], int x); |
|---|
| 67 | void ExttJobCommands(pentry entries[], int x); |
|---|
| 68 | void ExttJobButtons(void); |
|---|
| 69 | void ExttJobNavBar(void); |
|---|
| 70 | void ExttJobGetHook(entry gentries[], int x); |
|---|
| 71 | void ExttJobSelect(void); |
|---|
| 72 | void ExttJobSelectRow(void); |
|---|
| 73 | void ExttJobListSelect(void); |
|---|
| 74 | void ExttJobListFilter(void); |
|---|
| 75 | void ExttJobAuxTable(void); |
|---|
| 76 | |
|---|
| 77 | #include "tjobfunc.h" |
|---|
| 78 | |
|---|
| 79 | //Table Variables Assignment Function |
|---|
| 80 | void ProcesstJobVars(pentry entries[], int x) |
|---|
| 81 | { |
|---|
| 82 | register int i; |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | for(i=0;i<x;i++) |
|---|
| 86 | { |
|---|
| 87 | if(!strcmp(entries[i].name,"uJob")) |
|---|
| 88 | sscanf(entries[i].val,"%u",&uJob); |
|---|
| 89 | else if(!strcmp(entries[i].name,"cLabel")) |
|---|
| 90 | sprintf(cLabel,"%.100s",entries[i].val); |
|---|
| 91 | else if(!strcmp(entries[i].name,"cJobName")) |
|---|
| 92 | sprintf(cJobName,"%.64s",entries[i].val); |
|---|
| 93 | else if(!strcmp(entries[i].name,"uDatacenter")) |
|---|
| 94 | sscanf(entries[i].val,"%u",&uDatacenter); |
|---|
| 95 | else if(!strcmp(entries[i].name,"uNode")) |
|---|
| 96 | sscanf(entries[i].val,"%u",&uNode); |
|---|
| 97 | else if(!strcmp(entries[i].name,"uContainer")) |
|---|
| 98 | sscanf(entries[i].val,"%u",&uContainer); |
|---|
| 99 | else if(!strcmp(entries[i].name,"cJobData")) |
|---|
| 100 | cJobData=entries[i].val; |
|---|
| 101 | else if(!strcmp(entries[i].name,"uJobDate")) |
|---|
| 102 | sscanf(entries[i].val,"%lu",&uJobDate); |
|---|
| 103 | else if(!strcmp(entries[i].name,"uJobStatus")) |
|---|
| 104 | sscanf(entries[i].val,"%u",&uJobStatus); |
|---|
| 105 | else if(!strcmp(entries[i].name,"cuJobStatusPullDown")) |
|---|
| 106 | { |
|---|
| 107 | sprintf(cuJobStatusPullDown,"%.255s",entries[i].val); |
|---|
| 108 | uJobStatus=ReadPullDown("tJobStatus","cLabel",cuJobStatusPullDown); |
|---|
| 109 | } |
|---|
| 110 | else if(!strcmp(entries[i].name,"uRecurringJob")) |
|---|
| 111 | sscanf(entries[i].val,"%u",&uRecurringJob); |
|---|
| 112 | else if(!strcmp(entries[i].name,"cRecurringJobDropDown")) |
|---|
| 113 | { |
|---|
| 114 | sprintf(cRecurringJobDropDown,"%.255s",entries[i].val); |
|---|
| 115 | uRecurringJob=ReadRecurringDropDown(cRecurringJobDropDown); |
|---|
| 116 | } |
|---|
| 117 | else if(!strcmp(entries[i].name,"cRemoteMsg")) |
|---|
| 118 | sprintf(cRemoteMsg,"%.64s",entries[i].val); |
|---|
| 119 | else if(!strcmp(entries[i].name,"uOwner")) |
|---|
| 120 | sscanf(entries[i].val,"%u",&uOwner); |
|---|
| 121 | else if(!strcmp(entries[i].name,"uCreatedBy")) |
|---|
| 122 | sscanf(entries[i].val,"%u",&uCreatedBy); |
|---|
| 123 | else if(!strcmp(entries[i].name,"uCreatedDate")) |
|---|
| 124 | sscanf(entries[i].val,"%lu",&uCreatedDate); |
|---|
| 125 | else if(!strcmp(entries[i].name,"uModBy")) |
|---|
| 126 | sscanf(entries[i].val,"%u",&uModBy); |
|---|
| 127 | else if(!strcmp(entries[i].name,"uModDate")) |
|---|
| 128 | sscanf(entries[i].val,"%lu",&uModDate); |
|---|
| 129 | |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | //After so we can overwrite form data if needed. |
|---|
| 133 | ExtProcesstJobVars(entries,x); |
|---|
| 134 | |
|---|
| 135 | }//ProcesstJobVars() |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | void ProcesstJobListVars(pentry entries[], int x) |
|---|
| 139 | { |
|---|
| 140 | register int i; |
|---|
| 141 | |
|---|
| 142 | for(i=0;i<x;i++) |
|---|
| 143 | { |
|---|
| 144 | if(!strncmp(entries[i].name,"ED",2)) |
|---|
| 145 | { |
|---|
| 146 | sscanf(entries[i].name+2,"%u",&uJob); |
|---|
| 147 | guMode=2002; |
|---|
| 148 | tJob(""); |
|---|
| 149 | } |
|---|
| 150 | } |
|---|
| 151 | }//void ProcesstJobListVars(pentry entries[], int x) |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | int tJobCommands(pentry entries[], int x) |
|---|
| 155 | { |
|---|
| 156 | ProcessControlVars(entries,x); |
|---|
| 157 | |
|---|
| 158 | ExttJobCommands(entries,x); |
|---|
| 159 | |
|---|
| 160 | if(!strcmp(gcFunction,"tJobTools")) |
|---|
| 161 | { |
|---|
| 162 | if(!strcmp(gcFind,LANG_NB_LIST)) |
|---|
| 163 | { |
|---|
| 164 | tJobList(); |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | //Default |
|---|
| 168 | ProcesstJobVars(entries,x); |
|---|
| 169 | tJob(""); |
|---|
| 170 | } |
|---|
| 171 | else if(!strcmp(gcFunction,"tJobList")) |
|---|
| 172 | { |
|---|
| 173 | ProcessControlVars(entries,x); |
|---|
| 174 | ProcesstJobListVars(entries,x); |
|---|
| 175 | tJobList(); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | return(0); |
|---|
| 179 | |
|---|
| 180 | }//tJobCommands() |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | void tJob(const char *cResult) |
|---|
| 184 | { |
|---|
| 185 | MYSQL_RES *res; |
|---|
| 186 | MYSQL_RES *res2; |
|---|
| 187 | MYSQL_ROW field; |
|---|
| 188 | |
|---|
| 189 | //Internal skip reloading |
|---|
| 190 | if(!cResult[0]) |
|---|
| 191 | { |
|---|
| 192 | if(guMode) |
|---|
| 193 | ExttJobSelectRow(); |
|---|
| 194 | else |
|---|
| 195 | ExttJobSelect(); |
|---|
| 196 | |
|---|
| 197 | mysql_query(&gMysql,gcQuery); |
|---|
| 198 | if(mysql_errno(&gMysql)) |
|---|
| 199 | { |
|---|
| 200 | if(strstr(mysql_error(&gMysql)," doesn't exist")) |
|---|
| 201 | { |
|---|
| 202 | CreatetJob(); |
|---|
| 203 | unxsVZ("New tJob table created"); |
|---|
| 204 | } |
|---|
| 205 | else |
|---|
| 206 | { |
|---|
| 207 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 208 | } |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | res=mysql_store_result(&gMysql); |
|---|
| 212 | if((guI=mysql_num_rows(res))) |
|---|
| 213 | { |
|---|
| 214 | if(guMode==6) |
|---|
| 215 | { |
|---|
| 216 | sprintf(gcQuery,"SELECT _rowid FROM tJob WHERE uJob=%u" |
|---|
| 217 | ,uJob); |
|---|
| 218 | MYSQL_RUN_STORE(res2); |
|---|
| 219 | field=mysql_fetch_row(res2); |
|---|
| 220 | sscanf(field[0],"%lu",&gluRowid); |
|---|
| 221 | gluRowid++; |
|---|
| 222 | } |
|---|
| 223 | PageMachine("",0,""); |
|---|
| 224 | if(!guMode) mysql_data_seek(res,gluRowid-1); |
|---|
| 225 | field=mysql_fetch_row(res); |
|---|
| 226 | sscanf(field[0],"%u",&uJob); |
|---|
| 227 | sprintf(cLabel,"%.100s",field[1]); |
|---|
| 228 | sprintf(cJobName,"%.64s",field[2]); |
|---|
| 229 | sscanf(field[3],"%u",&uDatacenter); |
|---|
| 230 | sscanf(field[4],"%u",&uNode); |
|---|
| 231 | sscanf(field[5],"%u",&uContainer); |
|---|
| 232 | cJobData=field[6]; |
|---|
| 233 | sscanf(field[7],"%lu",&uJobDate); |
|---|
| 234 | sscanf(field[8],"%u",&uJobStatus); |
|---|
| 235 | sprintf(cRemoteMsg,"%.64s",field[9]); |
|---|
| 236 | sscanf(field[10],"%u",&uOwner); |
|---|
| 237 | sscanf(field[11],"%u",&uCreatedBy); |
|---|
| 238 | sscanf(field[12],"%lu",&uCreatedDate); |
|---|
| 239 | sscanf(field[13],"%u",&uModBy); |
|---|
| 240 | sscanf(field[14],"%lu",&uModDate); |
|---|
| 241 | |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | }//Internal Skip |
|---|
| 245 | |
|---|
| 246 | Header_ism3(":: tJob",1); |
|---|
| 247 | printf("<table width=100%% cellspacing=0 cellpadding=0>\n"); |
|---|
| 248 | printf("<tr><td colspan=2 align=right valign=center>"); |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | printf("<input type=hidden name=gcFunction value=tJobTools>"); |
|---|
| 252 | printf("<input type=hidden name=gluRowid value=%lu>",gluRowid); |
|---|
| 253 | if(guI) |
|---|
| 254 | { |
|---|
| 255 | if(guMode==6) |
|---|
| 256 | //printf(" Found"); |
|---|
| 257 | printf(LANG_NBR_FOUND); |
|---|
| 258 | else if(guMode==5) |
|---|
| 259 | //printf(" Modified"); |
|---|
| 260 | printf(LANG_NBR_MODIFIED); |
|---|
| 261 | else if(guMode==4) |
|---|
| 262 | //printf(" New"); |
|---|
| 263 | printf(LANG_NBR_NEW); |
|---|
| 264 | printf(LANG_NBRF_SHOWING,gluRowid,guI); |
|---|
| 265 | } |
|---|
| 266 | else |
|---|
| 267 | { |
|---|
| 268 | if(!cResult[0]) |
|---|
| 269 | //printf(" No records found"); |
|---|
| 270 | printf(LANG_NBR_NORECS); |
|---|
| 271 | } |
|---|
| 272 | if(cResult[0]) printf("%s",cResult); |
|---|
| 273 | printf("</td></tr>"); |
|---|
| 274 | printf("<tr><td valign=top width=25%%>"); |
|---|
| 275 | |
|---|
| 276 | ExttJobButtons(); |
|---|
| 277 | |
|---|
| 278 | printf("</td><td valign=top>"); |
|---|
| 279 | // |
|---|
| 280 | OpenFieldSet("tJob Record Data",100); |
|---|
| 281 | |
|---|
| 282 | //Custom right panel for new containers |
|---|
| 283 | if(guMode==9001) |
|---|
| 284 | tJobNewStep(1); |
|---|
| 285 | else if(guMode==9002) |
|---|
| 286 | tJobNewStep(2); |
|---|
| 287 | else if(guMode==9003) |
|---|
| 288 | tJobNewStep(3); |
|---|
| 289 | else if(guMode==9004) |
|---|
| 290 | tJobNewStep(4); |
|---|
| 291 | else if(guMode==2000 || guMode==2002) |
|---|
| 292 | tJobInput(1); |
|---|
| 293 | else |
|---|
| 294 | tJobInput(0); |
|---|
| 295 | |
|---|
| 296 | // |
|---|
| 297 | CloseFieldSet(); |
|---|
| 298 | |
|---|
| 299 | //Bottom table |
|---|
| 300 | printf("<tr><td colspan=2>"); |
|---|
| 301 | ExttJobAuxTable(); |
|---|
| 302 | |
|---|
| 303 | Footer_ism3(); |
|---|
| 304 | |
|---|
| 305 | }//end of tJob(); |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | void tJobNewStep(unsigned uStep) |
|---|
| 309 | { |
|---|
| 310 | |
|---|
| 311 | if(uStep==1) |
|---|
| 312 | { |
|---|
| 313 | OpenRow("Select an available datacenter","black"); |
|---|
| 314 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,1); |
|---|
| 315 | |
|---|
| 316 | OpenRow("Select an organization","black"); |
|---|
| 317 | tTablePullDownResellers(uForClient,0); |
|---|
| 318 | } |
|---|
| 319 | else if(uStep==2) |
|---|
| 320 | { |
|---|
| 321 | OpenRow("Selected datacenter","black"); |
|---|
| 322 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,0); |
|---|
| 323 | |
|---|
| 324 | OpenRow("Selected organization","black"); |
|---|
| 325 | tTablePullDown("tClient;cuClientPullDown","cLabel","cLabel",uForClient,0); |
|---|
| 326 | |
|---|
| 327 | OpenRow("Optionally assign to node","black"); |
|---|
| 328 | tTablePullDownDatacenter("tNode;cuNodePullDown","cLabel","cLabel",uNode,1, |
|---|
| 329 | cuDatacenterPullDown,0,uDatacenter);//0 does not use tProperty, uses uDatacenter |
|---|
| 330 | |
|---|
| 331 | OpenRow("Optionally assign to container","black"); |
|---|
| 332 | tTablePullDownDatacenter("tContainer;cuContainerPullDown","cLabel","cLabel",uContainer,1, |
|---|
| 333 | cuContainerPullDown,0,uDatacenter);//0 does not use tProperty, uses uDatacenter |
|---|
| 334 | |
|---|
| 335 | OpenRow("Select Recurring Job","black"); |
|---|
| 336 | RecurringJobDropDown(uRecurringJob,1); |
|---|
| 337 | |
|---|
| 338 | OpenRow("Assign a label","black"); |
|---|
| 339 | printf("<input title='A useful identification label' type=text name=cLabel" |
|---|
| 340 | " size=40 maxlength=100 value=\"%s\">\n",cLabel); |
|---|
| 341 | |
|---|
| 342 | OpenRow("Select recurring minute","black"); |
|---|
| 343 | printf("<input title='Minute on the hour 0-59' type=text name=uMin" |
|---|
| 344 | " value=0 size=40 maxlength=2 >\n"); |
|---|
| 345 | |
|---|
| 346 | OpenRow("Select recurring hour","black"); |
|---|
| 347 | printf("<input title='Hour of the day 0-24. 0 for all hours' type=text name=uHour" |
|---|
| 348 | " value=0 size=40 maxlength=2 >\n"); |
|---|
| 349 | |
|---|
| 350 | OpenRow("Select recurring day of week number","black"); |
|---|
| 351 | printf("<input title='Day of the week, range 0-7. Sunday is 1. 0 for all days' type=text name=uDayOfWeek" |
|---|
| 352 | " value=0 size=40 maxlength=1 >\n"); |
|---|
| 353 | |
|---|
| 354 | OpenRow("Select recurring day of month number","black"); |
|---|
| 355 | printf("<input title='Day of the month 1-31. 0 for all days. Trumps day of week' type=text name=uDayOfMonth" |
|---|
| 356 | " value=0 size=40 maxlength=1 >\n"); |
|---|
| 357 | |
|---|
| 358 | OpenRow("Select recurring month number","black"); |
|---|
| 359 | printf("<input title='Month of the year. 1-12. 0 for all months' type=text name=uMonth" |
|---|
| 360 | " value=0 size=40 maxlength=2 >\n"); |
|---|
| 361 | |
|---|
| 362 | OpenRow("Select starting date","black"); |
|---|
| 363 | char cTime[32]={""}; |
|---|
| 364 | if(!cStartDate[0]) |
|---|
| 365 | { |
|---|
| 366 | time_t luClock; |
|---|
| 367 | const struct tm *tmTime; |
|---|
| 368 | |
|---|
| 369 | time(&luClock); |
|---|
| 370 | tmTime=localtime(&luClock); |
|---|
| 371 | strftime(cTime,31,"%Y-%m-%d",tmTime); |
|---|
| 372 | } |
|---|
| 373 | else |
|---|
| 374 | { |
|---|
| 375 | sprintf(cTime,"%.31s",cStartDate); |
|---|
| 376 | } |
|---|
| 377 | jsCalendarInput("cStartDate",cTime,1); |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | }//void tJobNewStep(unsigned uStep) |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | void tJobInput(unsigned uMode) |
|---|
| 385 | { |
|---|
| 386 | |
|---|
| 387 | //uJob |
|---|
| 388 | OpenRow(LANG_FL_tJob_uJob,"black"); |
|---|
| 389 | printf("<input title='%s' type=text name=uJob value=%u size=16 maxlength=10 ",LANG_FT_tJob_uJob,uJob); |
|---|
| 390 | if(guPermLevel>=20 && uMode) |
|---|
| 391 | { |
|---|
| 392 | printf("></td></tr>\n"); |
|---|
| 393 | } |
|---|
| 394 | else |
|---|
| 395 | { |
|---|
| 396 | printf("disabled></td></tr>\n"); |
|---|
| 397 | printf("<input type=hidden name=uJob value=%u >\n",uJob); |
|---|
| 398 | } |
|---|
| 399 | //cLabel |
|---|
| 400 | OpenRow(LANG_FL_tJob_cLabel,"black"); |
|---|
| 401 | printf("<input title='%s' type=text name=cLabel value=\"%s\" size=40 maxlength=100 ",LANG_FT_tJob_cLabel, |
|---|
| 402 | EncodeDoubleQuotes(cLabel)); |
|---|
| 403 | if(guPermLevel>=0 && uMode) |
|---|
| 404 | { |
|---|
| 405 | printf("></td></tr>\n"); |
|---|
| 406 | } |
|---|
| 407 | else |
|---|
| 408 | { |
|---|
| 409 | printf("disabled></td></tr>\n"); |
|---|
| 410 | printf("<input type=hidden name=cLabel value=\"%s\">\n",EncodeDoubleQuotes(cLabel)); |
|---|
| 411 | } |
|---|
| 412 | //cJobName |
|---|
| 413 | OpenRow(LANG_FL_tJob_cJobName,"black"); |
|---|
| 414 | printf("<input title='%s' type=text name=cJobName value=\"%s\" size=40 maxlength=64 ",LANG_FT_tJob_cJobName, |
|---|
| 415 | EncodeDoubleQuotes(cJobName)); |
|---|
| 416 | if(guPermLevel>=0 && uMode) |
|---|
| 417 | { |
|---|
| 418 | printf("></td></tr>\n"); |
|---|
| 419 | } |
|---|
| 420 | else |
|---|
| 421 | { |
|---|
| 422 | printf("disabled></td></tr>\n"); |
|---|
| 423 | printf("<input type=hidden name=cJobName value=\"%s\">\n",EncodeDoubleQuotes(cJobName)); |
|---|
| 424 | } |
|---|
| 425 | //uDatacenter |
|---|
| 426 | OpenRow("uDatacenter","black"); |
|---|
| 427 | if(guPermLevel>=0 && uMode) |
|---|
| 428 | { |
|---|
| 429 | printf("%s<input type=hidden name=uDatacenter value=%u >\n", |
|---|
| 430 | ForeignKey("tDatacenter","cLabel",uDatacenter),uDatacenter); |
|---|
| 431 | } |
|---|
| 432 | else |
|---|
| 433 | { |
|---|
| 434 | printf("%s<input type=hidden name=uDatacenter value=%u >\n", |
|---|
| 435 | ForeignKey("tDatacenter","cLabel",uDatacenter),uDatacenter); |
|---|
| 436 | } |
|---|
| 437 | //uNode |
|---|
| 438 | OpenRow("uNode","black"); |
|---|
| 439 | if(guPermLevel>=0 && uMode) |
|---|
| 440 | { |
|---|
| 441 | printf("%s<input type=hidden name=uNode value=%u >\n",ForeignKey("tNode","cLabel",uNode),uNode); |
|---|
| 442 | } |
|---|
| 443 | else |
|---|
| 444 | { |
|---|
| 445 | printf("%s<input type=hidden name=uNode value=%u >\n",ForeignKey("tNode","cLabel",uNode),uNode); |
|---|
| 446 | } |
|---|
| 447 | //uContainer |
|---|
| 448 | OpenRow("uContainer","black"); |
|---|
| 449 | printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tContainer&uContainer=%u>%s</a><input type=hidden name=uContainer value=%u >\n", |
|---|
| 450 | uContainer,ForeignKey("tContainer","cLabel",uContainer),uContainer); |
|---|
| 451 | //cJobData |
|---|
| 452 | OpenRow(LANG_FL_tJob_cJobData,"black"); |
|---|
| 453 | printf("<textarea title='%s' cols=80 wrap=soft rows=8 name=cJobData ",LANG_FT_tJob_cJobData); |
|---|
| 454 | if(guPermLevel>=0 && uMode) |
|---|
| 455 | { |
|---|
| 456 | printf(">%s</textarea></td></tr>\n",cJobData); |
|---|
| 457 | } |
|---|
| 458 | else |
|---|
| 459 | { |
|---|
| 460 | printf("disabled>%s</textarea></td></tr>\n",cJobData); |
|---|
| 461 | printf("<input type=hidden name=cJobData value=\"%s\" >\n",EncodeDoubleQuotes(cJobData)); |
|---|
| 462 | } |
|---|
| 463 | //uJobDate |
|---|
| 464 | OpenRow(LANG_FL_tJob_uJobDate,"black"); |
|---|
| 465 | if(uJobDate) |
|---|
| 466 | printf("<input type=text name=cuJobDate value='%s' size=40 disabled>\n",ctime(&uJobDate)); |
|---|
| 467 | else |
|---|
| 468 | printf("<input type=text name=cuJobDate value='---' size=40 disabled>\n"); |
|---|
| 469 | printf("<input type=hidden name=uJobDate value=%lu>\n",uJobDate); |
|---|
| 470 | //uJobStatus |
|---|
| 471 | OpenRow(LANG_FL_tJob_uJobStatus,"black"); |
|---|
| 472 | if(guPermLevel>=10 && uMode) |
|---|
| 473 | tTablePullDown("tJobStatus;cuJobStatusPullDown","cLabel","cLabel",uJobStatus,1); |
|---|
| 474 | else |
|---|
| 475 | tTablePullDown("tJobStatus;cuJobStatusPullDown","cLabel","cLabel",uJobStatus,0); |
|---|
| 476 | //cRemoteMsg |
|---|
| 477 | OpenRow(LANG_FL_tJob_cRemoteMsg,"black"); |
|---|
| 478 | printf("<input title='%s' type=text name=cRemoteMsg value=\"%s\" size=80 maxlength=64 ",LANG_FT_tJob_cRemoteMsg, |
|---|
| 479 | EncodeDoubleQuotes(cRemoteMsg)); |
|---|
| 480 | if(guPermLevel>=0 && uMode) |
|---|
| 481 | { |
|---|
| 482 | printf("></td></tr>\n"); |
|---|
| 483 | } |
|---|
| 484 | else |
|---|
| 485 | { |
|---|
| 486 | printf("disabled></td></tr>\n"); |
|---|
| 487 | printf("<input type=hidden name=cRemoteMsg value=\"%s\">\n",EncodeDoubleQuotes(cRemoteMsg)); |
|---|
| 488 | } |
|---|
| 489 | //uOwner |
|---|
| 490 | OpenRow(LANG_FL_tJob_uOwner,"black"); |
|---|
| 491 | if(guPermLevel>=20 && uMode) |
|---|
| 492 | { |
|---|
| 493 | printf("%s<input type=hidden name=uOwner value=%u >\n",ForeignKey("tClient","cLabel",uOwner),uOwner); |
|---|
| 494 | } |
|---|
| 495 | else |
|---|
| 496 | { |
|---|
| 497 | printf("%s<input type=hidden name=uOwner value=%u >\n",ForeignKey("tClient","cLabel",uOwner),uOwner); |
|---|
| 498 | } |
|---|
| 499 | //uCreatedBy |
|---|
| 500 | OpenRow(LANG_FL_tJob_uCreatedBy,"black"); |
|---|
| 501 | if(guPermLevel>=20 && uMode) |
|---|
| 502 | { |
|---|
| 503 | printf("%s<input type=hidden name=uCreatedBy value=%u >\n", |
|---|
| 504 | ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); |
|---|
| 505 | } |
|---|
| 506 | else |
|---|
| 507 | { |
|---|
| 508 | printf("%s<input type=hidden name=uCreatedBy value=%u >\n", |
|---|
| 509 | ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); |
|---|
| 510 | } |
|---|
| 511 | //uCreatedDate |
|---|
| 512 | OpenRow(LANG_FL_tJob_uCreatedDate,"black"); |
|---|
| 513 | if(uCreatedDate) |
|---|
| 514 | printf("%s\n\n",ctime(&uCreatedDate)); |
|---|
| 515 | else |
|---|
| 516 | printf("---\n\n"); |
|---|
| 517 | printf("<input type=hidden name=uCreatedDate value=%lu >\n",uCreatedDate); |
|---|
| 518 | //uModBy |
|---|
| 519 | OpenRow(LANG_FL_tJob_uModBy,"black"); |
|---|
| 520 | if(guPermLevel>=20 && uMode) |
|---|
| 521 | { |
|---|
| 522 | printf("%s<input type=hidden name=uModBy value=%u >\n",ForeignKey("tClient","cLabel",uModBy),uModBy); |
|---|
| 523 | } |
|---|
| 524 | else |
|---|
| 525 | { |
|---|
| 526 | printf("%s<input type=hidden name=uModBy value=%u >\n",ForeignKey("tClient","cLabel",uModBy),uModBy); |
|---|
| 527 | } |
|---|
| 528 | //uModDate |
|---|
| 529 | OpenRow(LANG_FL_tJob_uModDate,"black"); |
|---|
| 530 | if(uModDate) |
|---|
| 531 | printf("%s\n\n",ctime(&uModDate)); |
|---|
| 532 | else |
|---|
| 533 | printf("---\n\n"); |
|---|
| 534 | printf("<input type=hidden name=uModDate value=%lu >\n",uModDate); |
|---|
| 535 | printf("</tr>\n"); |
|---|
| 536 | |
|---|
| 537 | }//void tJobInput(unsigned uMode) |
|---|
| 538 | |
|---|
| 539 | |
|---|
| 540 | void NewtJob(unsigned uMode) |
|---|
| 541 | { |
|---|
| 542 | register int i=0; |
|---|
| 543 | MYSQL_RES *res; |
|---|
| 544 | |
|---|
| 545 | sprintf(gcQuery,"SELECT uJob FROM tJob WHERE uJob=%u",uJob); |
|---|
| 546 | MYSQL_RUN_STORE(res); |
|---|
| 547 | i=mysql_num_rows(res); |
|---|
| 548 | |
|---|
| 549 | if(i) |
|---|
| 550 | //tJob("<blink>Record already exists"); |
|---|
| 551 | tJob(LANG_NBR_RECEXISTS); |
|---|
| 552 | |
|---|
| 553 | //insert query |
|---|
| 554 | Insert_tJob(); |
|---|
| 555 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 556 | //sprintf(gcQuery,"New record %u added"); |
|---|
| 557 | uJob=mysql_insert_id(&gMysql); |
|---|
| 558 | uCreatedDate=luGetCreatedDate("tJob",uJob); |
|---|
| 559 | unxsVZLog(uJob,"tJob","New"); |
|---|
| 560 | |
|---|
| 561 | if(!uMode) |
|---|
| 562 | { |
|---|
| 563 | sprintf(gcQuery,LANG_NBR_NEWRECADDED,uJob); |
|---|
| 564 | tJob(gcQuery); |
|---|
| 565 | } |
|---|
| 566 | |
|---|
| 567 | }//NewtJob(unsigned uMode) |
|---|
| 568 | |
|---|
| 569 | |
|---|
| 570 | void DeletetJob(void) |
|---|
| 571 | { |
|---|
| 572 | sprintf(gcQuery,"DELETE FROM tJob WHERE uJob=%u AND ( uOwner=%u OR %u>9 )" |
|---|
| 573 | ,uJob,guLoginClient,guPermLevel); |
|---|
| 574 | MYSQL_RUN; |
|---|
| 575 | //tJob("Record Deleted"); |
|---|
| 576 | if(mysql_affected_rows(&gMysql)>0) |
|---|
| 577 | { |
|---|
| 578 | unxsVZLog(uJob,"tJob","Del"); |
|---|
| 579 | tJob(LANG_NBR_RECDELETED); |
|---|
| 580 | } |
|---|
| 581 | else |
|---|
| 582 | { |
|---|
| 583 | unxsVZLog(uJob,"tJob","DelError"); |
|---|
| 584 | tJob(LANG_NBR_RECNOTDELETED); |
|---|
| 585 | } |
|---|
| 586 | |
|---|
| 587 | }//void DeletetJob(void) |
|---|
| 588 | |
|---|
| 589 | |
|---|
| 590 | void Insert_tJob(void) |
|---|
| 591 | { |
|---|
| 592 | |
|---|
| 593 | //insert query |
|---|
| 594 | sprintf(gcQuery,"INSERT INTO tJob SET uJob=%u,cLabel='%s',cJobName='%s',uDatacenter=%u,uNode=%u,uContainer=%u," |
|---|
| 595 | "cJobData='%s',uJobDate=%lu,uJobStatus=%u,cRemoteMsg='%s',uOwner=%u,uCreatedBy=%u," |
|---|
| 596 | "uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 597 | uJob |
|---|
| 598 | ,TextAreaSave(cLabel) |
|---|
| 599 | ,TextAreaSave(cJobName) |
|---|
| 600 | ,uDatacenter |
|---|
| 601 | ,uNode |
|---|
| 602 | ,uContainer |
|---|
| 603 | ,TextAreaSave(cJobData) |
|---|
| 604 | ,uJobDate |
|---|
| 605 | ,uJobStatus |
|---|
| 606 | ,TextAreaSave(cRemoteMsg) |
|---|
| 607 | ,uOwner |
|---|
| 608 | ,uCreatedBy |
|---|
| 609 | ); |
|---|
| 610 | |
|---|
| 611 | MYSQL_RUN; |
|---|
| 612 | |
|---|
| 613 | }//void Insert_tJob(void) |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | void Update_tJob(char *cRowid) |
|---|
| 617 | { |
|---|
| 618 | |
|---|
| 619 | //update query |
|---|
| 620 | sprintf(gcQuery,"UPDATE tJob SET uJob=%u,cLabel='%s',cJobName='%s',uDatacenter=%u,uNode=%u,uContainer=%u," |
|---|
| 621 | "cJobData='%s',uJobDate=%lu,uJobStatus=%u,cRemoteMsg='%s',uModBy=%u," |
|---|
| 622 | "uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", |
|---|
| 623 | uJob |
|---|
| 624 | ,TextAreaSave(cLabel) |
|---|
| 625 | ,TextAreaSave(cJobName) |
|---|
| 626 | ,uDatacenter |
|---|
| 627 | ,uNode |
|---|
| 628 | ,uContainer |
|---|
| 629 | ,TextAreaSave(cJobData) |
|---|
| 630 | ,uJobDate |
|---|
| 631 | ,uJobStatus |
|---|
| 632 | ,TextAreaSave(cRemoteMsg) |
|---|
| 633 | ,uModBy |
|---|
| 634 | ,cRowid); |
|---|
| 635 | |
|---|
| 636 | MYSQL_RUN; |
|---|
| 637 | |
|---|
| 638 | }//void Update_tJob(void) |
|---|
| 639 | |
|---|
| 640 | |
|---|
| 641 | void ModtJob(void) |
|---|
| 642 | { |
|---|
| 643 | register int i=0; |
|---|
| 644 | MYSQL_RES *res; |
|---|
| 645 | MYSQL_ROW field; |
|---|
| 646 | unsigned uPreModDate=0; |
|---|
| 647 | |
|---|
| 648 | //Mod select gcQuery |
|---|
| 649 | if(guPermLevel<10) |
|---|
| 650 | sprintf(gcQuery,"SELECT tJob.uJob," |
|---|
| 651 | "tJob.uModDate" |
|---|
| 652 | "FROM tJob,tClient" |
|---|
| 653 | "WHERE tJob.uJob=%u" |
|---|
| 654 | "AND tJob.uOwner=tClient.uClient" |
|---|
| 655 | "AND (tClient.uOwner=%u OR tClient.uClient=%u)" |
|---|
| 656 | ,uJob,guLoginClient,guLoginClient); |
|---|
| 657 | else |
|---|
| 658 | sprintf(gcQuery,"SELECT uJob,uModDate FROM tJob WHERE uJob=%u",uJob); |
|---|
| 659 | |
|---|
| 660 | MYSQL_RUN_STORE(res); |
|---|
| 661 | i=mysql_num_rows(res); |
|---|
| 662 | |
|---|
| 663 | //if(i<1) tJob("<blink>Record does not exist"); |
|---|
| 664 | if(i<1) tJob(LANG_NBR_RECNOTEXIST); |
|---|
| 665 | //if(i>1) tJob("<blink>Multiple rows!"); |
|---|
| 666 | if(i>1) tJob(LANG_NBR_MULTRECS); |
|---|
| 667 | |
|---|
| 668 | field=mysql_fetch_row(res); |
|---|
| 669 | sscanf(field[1],"%u",&uPreModDate); |
|---|
| 670 | if(uPreModDate!=uModDate) tJob(LANG_NBR_EXTMOD); |
|---|
| 671 | |
|---|
| 672 | Update_tJob(field[0]); |
|---|
| 673 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 674 | //sprintf(query,"record %s modified",field[0]); |
|---|
| 675 | sprintf(gcQuery,LANG_NBRF_REC_MODIFIED,field[0]); |
|---|
| 676 | uModDate=luGetModDate("tJob",uJob); |
|---|
| 677 | unxsVZLog(uJob,"tJob","Mod"); |
|---|
| 678 | tJob(gcQuery); |
|---|
| 679 | |
|---|
| 680 | }//ModtJob(void) |
|---|
| 681 | |
|---|
| 682 | |
|---|
| 683 | void tJobList(void) |
|---|
| 684 | { |
|---|
| 685 | MYSQL_RES *res; |
|---|
| 686 | MYSQL_ROW field; |
|---|
| 687 | |
|---|
| 688 | ExttJobListSelect(); |
|---|
| 689 | |
|---|
| 690 | MYSQL_RUN_STORE(res); |
|---|
| 691 | guI=mysql_num_rows(res); |
|---|
| 692 | |
|---|
| 693 | PageMachine("tJobList",1,"");//1 is auto header list guMode. Opens table! |
|---|
| 694 | |
|---|
| 695 | //Filter select drop down |
|---|
| 696 | ExttJobListFilter(); |
|---|
| 697 | |
|---|
| 698 | printf("<input type=text size=16 name=gcCommand maxlength=98 value=\"%s\" >",gcCommand); |
|---|
| 699 | |
|---|
| 700 | printf("</table>\n"); |
|---|
| 701 | |
|---|
| 702 | printf("<table bgcolor=#9BC1B3 border=0 width=100%%>\n"); |
|---|
| 703 | printf("<tr bgcolor=black>" |
|---|
| 704 | "<td><font face=arial,helvetica color=white>uJob" |
|---|
| 705 | "<td><font face=arial,helvetica color=white>cLabel" |
|---|
| 706 | "<td><font face=arial,helvetica color=white>cJobName" |
|---|
| 707 | "<td><font face=arial,helvetica color=white>uDatacenter" |
|---|
| 708 | "<td><font face=arial,helvetica color=white>uNode" |
|---|
| 709 | "<td><font face=arial,helvetica color=white>uContainer" |
|---|
| 710 | "<td><font face=arial,helvetica color=white>cJobData" |
|---|
| 711 | "<td><font face=arial,helvetica color=white>uJobDate" |
|---|
| 712 | "<td><font face=arial,helvetica color=white>uJobStatus" |
|---|
| 713 | "<td><font face=arial,helvetica color=white>cRemoteMsg" |
|---|
| 714 | "<td><font face=arial,helvetica color=white>uOwner" |
|---|
| 715 | "<td><font face=arial,helvetica color=white>uCreatedBy" |
|---|
| 716 | "<td><font face=arial,helvetica color=white>uCreatedDate" |
|---|
| 717 | "<td><font face=arial,helvetica color=white>uModBy" |
|---|
| 718 | "<td><font face=arial,helvetica color=white>uModDate</tr>"); |
|---|
| 719 | |
|---|
| 720 | mysql_data_seek(res,guStart-1); |
|---|
| 721 | |
|---|
| 722 | for(guN=0;guN<(guEnd-guStart+1);guN++) |
|---|
| 723 | { |
|---|
| 724 | field=mysql_fetch_row(res); |
|---|
| 725 | if(!field) |
|---|
| 726 | { |
|---|
| 727 | printf("<tr><td><font face=arial,helvetica>End of data</table>"); |
|---|
| 728 | Footer_ism3(); |
|---|
| 729 | } |
|---|
| 730 | if(guN % 2) |
|---|
| 731 | printf("<tr bgcolor=#BBE1D3>"); |
|---|
| 732 | else |
|---|
| 733 | printf("<tr>"); |
|---|
| 734 | time_t luTime7=strtoul(field[7],NULL,10); |
|---|
| 735 | char cBuf7[32]; |
|---|
| 736 | if(luTime7) |
|---|
| 737 | ctime_r(&luTime7,cBuf7); |
|---|
| 738 | else |
|---|
| 739 | sprintf(cBuf7,"---"); |
|---|
| 740 | time_t luTime12=strtoul(field[12],NULL,10); |
|---|
| 741 | char cBuf12[32]; |
|---|
| 742 | if(luTime12) |
|---|
| 743 | ctime_r(&luTime12,cBuf12); |
|---|
| 744 | else |
|---|
| 745 | sprintf(cBuf12,"---"); |
|---|
| 746 | time_t luTime14=strtoul(field[14],NULL,10); |
|---|
| 747 | char cBuf14[32]; |
|---|
| 748 | if(luTime14) |
|---|
| 749 | ctime_r(&luTime14,cBuf14); |
|---|
| 750 | else |
|---|
| 751 | sprintf(cBuf14,"---"); |
|---|
| 752 | printf("<td><input type=submit name=ED%s value=Edit> %s<td>%s<td>%s<td>%s<td>%s<td>%s<td>" |
|---|
| 753 | "<textarea disabled>%s</textarea><td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s</tr>" |
|---|
| 754 | ,field[0] |
|---|
| 755 | ,field[0] |
|---|
| 756 | ,field[1] |
|---|
| 757 | ,field[2] |
|---|
| 758 | ,ForeignKey("tDatacenter","cLabel",strtoul(field[3],NULL,10)) |
|---|
| 759 | ,ForeignKey("tNode","cLabel",strtoul(field[4],NULL,10)) |
|---|
| 760 | ,ForeignKey("tContainer","cLabel",strtoul(field[5],NULL,10)) |
|---|
| 761 | ,field[6] |
|---|
| 762 | ,cBuf7 |
|---|
| 763 | ,ForeignKey("tJobStatus","cLabel",strtoul(field[8],NULL,10)) |
|---|
| 764 | ,field[9] |
|---|
| 765 | ,ForeignKey("tClient","cLabel",strtoul(field[10],NULL,10)) |
|---|
| 766 | ,ForeignKey("tClient","cLabel",strtoul(field[11],NULL,10)) |
|---|
| 767 | ,cBuf12 |
|---|
| 768 | ,ForeignKey("tClient","cLabel",strtoul(field[13],NULL,10)) |
|---|
| 769 | ,cBuf14 |
|---|
| 770 | ); |
|---|
| 771 | |
|---|
| 772 | } |
|---|
| 773 | |
|---|
| 774 | printf("</table></form>\n"); |
|---|
| 775 | Footer_ism3(); |
|---|
| 776 | |
|---|
| 777 | }//tJobList() |
|---|
| 778 | |
|---|
| 779 | |
|---|
| 780 | void CreatetJob(void) |
|---|
| 781 | { |
|---|
| 782 | sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tJob ( " |
|---|
| 783 | "uJob INT UNSIGNED PRIMARY KEY AUTO_INCREMENT," |
|---|
| 784 | "cLabel VARCHAR(100) NOT NULL DEFAULT ''," |
|---|
| 785 | "cJobName VARCHAR(64) NOT NULL DEFAULT ''," |
|---|
| 786 | "uDatacenter INT UNSIGNED NOT NULL DEFAULT 0, INDEX (uDatacenter)," |
|---|
| 787 | "uNode INT UNSIGNED NOT NULL DEFAULT 0, INDEX (uNode)," |
|---|
| 788 | "uContainer INT UNSIGNED NOT NULL DEFAULT 0, INDEX (uContainer)," |
|---|
| 789 | "cJobData TEXT NOT NULL DEFAULT ''," |
|---|
| 790 | "uJobDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 791 | "uJobStatus INT UNSIGNED NOT NULL DEFAULT 0, INDEX (uJobStatus)," |
|---|
| 792 | "cRemoteMsg VARCHAR(64) NOT NULL DEFAULT ''," |
|---|
| 793 | "uOwner INT UNSIGNED NOT NULL DEFAULT 0, INDEX (uOwner)," |
|---|
| 794 | "uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 795 | "uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 796 | "uModBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 797 | "uModDate INT UNSIGNED NOT NULL DEFAULT 0 )"); |
|---|
| 798 | MYSQL_RUN; |
|---|
| 799 | }//CreatetJob() |
|---|
| 800 | |
|---|
| 801 | |
|---|
| 802 | void PropertyDropDown(const char *cTableName, const char *cFieldName, |
|---|
| 803 | const char *cOrderby, unsigned uSelector, unsigned uMode, const char *cDatacenter, |
|---|
| 804 | unsigned uType, unsigned uDatacenter) |
|---|
| 805 | { |
|---|
| 806 | register int i,n; |
|---|
| 807 | char cLabel[256]; |
|---|
| 808 | MYSQL_RES *mysqlRes; |
|---|
| 809 | MYSQL_ROW mysqlField; |
|---|
| 810 | |
|---|
| 811 | char cSelectName[100]={""}; |
|---|
| 812 | char cHidden[100]={""}; |
|---|
| 813 | char cLocalTableName[256]={""}; |
|---|
| 814 | char *cp; |
|---|
| 815 | char *cMode=""; |
|---|
| 816 | |
|---|
| 817 | if(!uMode) |
|---|
| 818 | cMode="disabled"; |
|---|
| 819 | |
|---|
| 820 | if(!cTableName[0] || !cFieldName[0] || !cOrderby[0]) |
|---|
| 821 | { |
|---|
| 822 | printf("Invalid input PropertyDropDown()()"); |
|---|
| 823 | return; |
|---|
| 824 | } |
|---|
| 825 | |
|---|
| 826 | //Extended functionality |
|---|
| 827 | sprintf(cLocalTableName,"%.255s",cTableName); |
|---|
| 828 | if((cp=strchr(cLocalTableName,';'))) |
|---|
| 829 | { |
|---|
| 830 | sprintf(cSelectName,"%.99s",cp+1); |
|---|
| 831 | *cp=0; |
|---|
| 832 | } |
|---|
| 833 | |
|---|
| 834 | |
|---|
| 835 | if(uType) |
|---|
| 836 | sprintf(gcQuery,"SELECT _rowid AS uRowid,%s FROM %s WHERE" |
|---|
| 837 | " LOCATE('All Datacenters'," |
|---|
| 838 | "(SELECT cValue FROM tProperty WHERE cName='cDatacenter' AND uType=%u AND uKey=uRowid))>0" |
|---|
| 839 | " OR LOCATE('%s'," |
|---|
| 840 | "(SELECT cValue FROM tProperty WHERE cName='cDatacenter' AND uType=%u AND uKey=uRowid))>0" |
|---|
| 841 | " ORDER BY %s", |
|---|
| 842 | cFieldName,cLocalTableName,uType,cDatacenter,uType,cOrderby); |
|---|
| 843 | else |
|---|
| 844 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uDatacenter=%u ORDER BY %s", |
|---|
| 845 | cFieldName,cLocalTableName,uDatacenter,cOrderby); |
|---|
| 846 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 847 | i=mysql_num_rows(mysqlRes); |
|---|
| 848 | |
|---|
| 849 | if(cSelectName[0]) |
|---|
| 850 | sprintf(cLabel,"%s",cSelectName); |
|---|
| 851 | else |
|---|
| 852 | sprintf(cLabel,"%s_%sPullDown",cLocalTableName,cFieldName); |
|---|
| 853 | |
|---|
| 854 | if(i>0) |
|---|
| 855 | { |
|---|
| 856 | int unsigned field0; |
|---|
| 857 | printf("<select name=%s %s>\n",cLabel,cMode); |
|---|
| 858 | |
|---|
| 859 | //Default no selection |
|---|
| 860 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 861 | |
|---|
| 862 | for(n=0;n<i;n++) |
|---|
| 863 | { |
|---|
| 864 | |
|---|
| 865 | field0=0; |
|---|
| 866 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 867 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 868 | |
|---|
| 869 | if(uSelector != field0) |
|---|
| 870 | { |
|---|
| 871 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 872 | } |
|---|
| 873 | else |
|---|
| 874 | { |
|---|
| 875 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 876 | if(!uMode) |
|---|
| 877 | sprintf(cHidden,"<input type=hidden name=%.99s value='%.99s'>\n", |
|---|
| 878 | cLabel,mysqlField[1]); |
|---|
| 879 | } |
|---|
| 880 | } |
|---|
| 881 | } |
|---|
| 882 | else |
|---|
| 883 | { |
|---|
| 884 | printf("<select name=%s %s><option title='No selection'>---</option></select>\n" |
|---|
| 885 | ,cLabel,cMode); |
|---|
| 886 | if(!uMode) |
|---|
| 887 | sprintf(cHidden,"<input type=hidden name=%99s value='0'>\n",cLabel); |
|---|
| 888 | } |
|---|
| 889 | printf("</select>\n"); |
|---|
| 890 | if(cHidden[0]) |
|---|
| 891 | printf("%s",cHidden); |
|---|
| 892 | |
|---|
| 893 | }//PropertyDropDown() |
|---|
| 894 | |
|---|
| 895 | |
|---|
| 896 | void RecurringJobDropDown(unsigned uSelector, unsigned uMode) |
|---|
| 897 | { |
|---|
| 898 | MYSQL_RES *mysqlRes; |
|---|
| 899 | MYSQL_ROW mysqlField; |
|---|
| 900 | register int i,n; |
|---|
| 901 | char *cMode=""; |
|---|
| 902 | char cHidden[256]={""}; |
|---|
| 903 | |
|---|
| 904 | if(!uMode) |
|---|
| 905 | cMode="disabled"; |
|---|
| 906 | |
|---|
| 907 | sprintf(gcQuery,"SELECT uProperty,cName FROM tProperty WHERE uType=%u and uKey=0",uPROP_RECJOB); |
|---|
| 908 | |
|---|
| 909 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 910 | i=mysql_num_rows(mysqlRes); |
|---|
| 911 | |
|---|
| 912 | if(i>0) |
|---|
| 913 | { |
|---|
| 914 | int unsigned field0; |
|---|
| 915 | printf("<select name=cRecurringJobDropDown %s>\n",cMode); |
|---|
| 916 | |
|---|
| 917 | //Default no selection |
|---|
| 918 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 919 | |
|---|
| 920 | for(n=0;n<i;n++) |
|---|
| 921 | { |
|---|
| 922 | |
|---|
| 923 | field0=0; |
|---|
| 924 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 925 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 926 | |
|---|
| 927 | if(uSelector != field0) |
|---|
| 928 | { |
|---|
| 929 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 930 | } |
|---|
| 931 | else |
|---|
| 932 | { |
|---|
| 933 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 934 | if(!uMode) |
|---|
| 935 | sprintf(cHidden,"<input type=hidden name=cRecurringJobDropDown value='%.99s'>\n", |
|---|
| 936 | mysqlField[1]); |
|---|
| 937 | } |
|---|
| 938 | } |
|---|
| 939 | } |
|---|
| 940 | else |
|---|
| 941 | { |
|---|
| 942 | printf("<select name=cRecurringJobDropDown %s><option title='No selection'>---</option></select>\n",cMode); |
|---|
| 943 | if(!uMode) |
|---|
| 944 | sprintf(cHidden,"<input type=hidden name=cRecurringJobDropDown value='0'>\n"); |
|---|
| 945 | } |
|---|
| 946 | printf("</select>\n"); |
|---|
| 947 | if(cHidden[0]) |
|---|
| 948 | printf("%s",cHidden); |
|---|
| 949 | |
|---|
| 950 | }//void RecurringJobDropDown(unsigned uSelector, unsigned uMode) |
|---|
| 951 | |
|---|
| 952 | |
|---|
| 953 | unsigned ReadRecurringDropDown(char *cRecurringJobDropDown) |
|---|
| 954 | { |
|---|
| 955 | MYSQL_RES *mysqlRes; |
|---|
| 956 | MYSQL_ROW mysqlField; |
|---|
| 957 | |
|---|
| 958 | unsigned uRowid=0;//Not found |
|---|
| 959 | |
|---|
| 960 | sprintf(gcQuery,"SELECT uProperty FROM tProperty WHERE uKey=0 AND uType=%u AND cName='%.99s'", |
|---|
| 961 | uPROP_RECJOB,cRecurringJobDropDown); |
|---|
| 962 | MYSQL_RUN_STORE(mysqlRes); |
|---|
| 963 | if((mysqlField=mysql_fetch_row(mysqlRes))) |
|---|
| 964 | sscanf(mysqlField[0],"%u",&uRowid); |
|---|
| 965 | mysql_free_result(mysqlRes); |
|---|
| 966 | return(uRowid); |
|---|
| 967 | |
|---|
| 968 | }//unsigned ReadRecurringDropDown(char *cRecurringJobDropDown) |
|---|