forked from abusalam/Lok-Sabha-Election-16th
/
randomise2.php
248 lines (204 loc) · 5.3 KB
/
randomise2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?php
include 'mysqliconn.php';
include 'assemblydata1.php';
include 'grpdtldata.php';
include 'postorderdata.php';
include 'ppdata.php';
include 'randno1.php';
include 'reserve1.php';
include 'reserve2.php';
include 'dcrc.php';
include 'dcrcreserve.php';
include 'countpp1.php';
if(isset($_GET['pc_cd']) && $_GET['pc_cd']!=null)
{
$fpc=$_GET['pc_cd'];
//echo $fpc;
}
else
{
echo "You are not a valid PC user";
exit;
}
if(isset($_GET['dist']) && $_GET['dist']!=null)
{
$dist=$_GET['dist'];
//echo $dist;
}
else
{
echo "You are not a valid District user";
exit;
}
//$fpc='41';
//$dist='18';
new randno1($dist,$fpc);
$asmparty=new assemblydata1($dist,$fpc);
$i=0;
// prepare statement
$sobj= new mysqliconn();
$msqli=$sobj->getconn();
$msqli->query("update personnela set booked=' ',groupid=0,forassembly=' ' where forpc='$fpc'");
$msqli->autocommit(FALSE);
$sql = "update personnela set booked='P',groupid=?,forassembly=? where personcd=? ";
$stmt = $msqli->prepare($sql); //,groupid=?,forasm=?,forpc=? where personcd=? ");
$stmt->bind_param('iss',$grpd,$asmf,$psd);
//
while ($i<=$asmparty->countnumb()-1)
//read from assemblyparty table
{
$partyreqd=$asmparty->getpartyreqdpty($i);
$assembly=$asmparty->getasmpty($i); //Asembly for which party is being formed
$membno=$asmparty->getmembers($i); //Total member in a party
$pc=$asmparty->getpcpty($i); //PC for which party is being formed
$sub=$asmparty->getsubpty($i);
$postdt=new postorderdata($membno);
//echo $assembly.' '.$membno;
$j=0;
$grpdata=new grpdtldata($assembly,$membno);
while ($j<=($postdt->countnumb())-1) //Loop for all poststatus
{
$memslno=$postdt->getmember($j); // member number in a party
$post=$postdt->getpoststat($j); // post status of that member
// echo $pc . ' ' .$assembly . ' n ' .$dist . ' ';
$ppall=new ppdata($pc,$post,$dist,$assembly,'S',2); // pp for subdivision
$cond=0;
$x=0;
$skippp=0;
$k=0;
while( $x<$ppall->countnumb())
{
$cond=0;
$ofcd=$ppall->getofcdpp($x);
$bk=$ppall->getbookedpp($x);
if ($k<$grpdata->countnumb())
{
$asmf=$grpdata->getasmdtl($k);
$pcf=$grpdata->getpcdtl($k);
$gid=$grpdata->getgrpiddtl($k);
$of1=$grpdata->getof1dtl($k);
$of2=$grpdata->getof2dtl($k);
$of3=$grpdata->getof3dtl($k);
$of4=$grpdata->getof4dtl($k);
$of5=$grpdata->getof5dtl($k);
$of6=$grpdata->getof6dtl($k);
}
else
{
break;
}
if ($memslno==1)
{
$grpdata->setof1dtl($k,$ofcd);
// echo $grpdata->getof1dtl($k);
$cond=1;
}
if ($memslno==2)
{
// if ((strcmp($bk,' ')==0)) {
// echo strcmp($bk,'');
// echo $ofcd.' n '.$bk.'b '.$of1;
// }
if ((strcmp($ofcd,$of1)<>0) and (strcmp($of2,' ')==0) and (strcmp($bk,'')==0))
{ // echo ' 2 sele ';
$grpdata->setof2dtl($k,$ofcd);
/*echo $grpdata->getof1dtl($k);
echo ' ';
echo $grpdata->getof2dtl($k);
echo ' ---- ';
*/
$cond=1;
}
}
if ($memslno==3)
{
if ((strcmp($ofcd,$of1)<>0) and (strcmp($ofcd,$of2)<>0) and (strcmp($of3,' ')==0) and (strcmp($bk,'')==0))
{
$grpdata->setof3dtl($k,$ofcd);
$cond=1;
}
}
if ($memslno==4)
{
if ((strcmp($ofcd,$of1)<>0) and (strcmp($ofcd,$of2)<>0) and (strcmp($ofcd,$of3)<>0) and (strcmp($of4,' ')==0) and (strcmp($bk,'')==0))
{
if ($k==0)
{
// echo $k;
echo ' ';
}
$grpdata->setof4dtl($k,$ofcd);
$cond=1;
}
}
if ($memslno==5)
{
if ((strcmp($ofcd,$of1)<>0) and (strcmp($ofcd,$of2)<>0) and (strcmp($ofcd,$of3)<>0) and (strcmp($ofcd,$of4)<>0) and (strcmp($of5,' ')==0) and (strcmp($bk,'')==0))
{
$grpdata->setof5dtl($k,$ofcd);
$cond=1;
}
}
if ($memslno==6)
{
if ((strcmp($ofcd,$of1)<>0) and (strcmp($ofcd,$of2)<>0) and (strcmp($ofcd,$of3)<>0) and (strcmp($ofcd,$of4)<>0) and (strcmp($ofcd,$of5)<>0) and (strcmp($of6,' ')==0) and (strcmp($bk,'')==0))
{
$grpdata->setof6dtl($k,$ofcd);
$cond=1;
}
}
if ($memslno<1 or $memslno>6)
{
break;
}
if ($cond==1)
{
$ppall->setbookedpp($x,'P');
$ppall->setgrpidpp($x,$gid);
$ppall->setforasm($x,$asmf);
$ppall->setforpc($x,$pcf);
$psd=$ppall->getperscdpp($x);
$grpd=$ppall->getgrpidpp($x);
$asmf=$ppall->getasmpp($x);
$pcf=$ppall->getpcpp($x);
$k=$k+1;
$stmt->execute();
}
else
{
$skippp=$skippp+1;
}
if ($x< $ppall->countnumb()-1)
{
$x=$x+1;
}
else
{
if ($skippp< ($grpdata->countnumb()-$k ))
{
$x=0;
}
else
{
echo ' Check Data ....Group Can not be formed ...';
break;
}
}
}
$j=$j+1;
}
$msqli->commit();
$i=$i+1;
}
$stmt->close();
$msqli->close();
new reserve1($dist,$fpc);
new reserve2($dist,$fpc);
new reserve2($dist,$fpc);
new reserve2($dist,$fpc);
new reserve2($dist,$fpc);
new dcrc($dist,$fpc);
new dcrcreserve($dist,$fpc);
new countpp($fpc);
//print_r($grpdata);
?>