-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadblocknumbers.php
executable file
·55 lines (42 loc) · 2.25 KB
/
loadblocknumbers.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
<?php
$user_name= "nmadmvin";
$pwd= "NmOffAdmin";
$database="nmwndb";
$server="127.0.0.1";
$opn_Connection = mysqli_connect($server,$user_name,$pwd);
$opn_Dbf = mysqli_select_db($database, $opn_Connection);
if ($opn_Connection) {
if ($opn_Dbf){
//Open Project Dtl table where project = 'HORANA' and PURCHASED BLOCKS ONLY.
$PrjDtlString = "SELECT * FROM nmwndb.projectdetails where projectcode = '2' and customercode<>0";
$PrjDtl=mysqli_query($PrjDtlString);
while ($Row = mysqli_fetch_assoc($PrjDtl)) {
$Refno = $Row['refno'];
$HouseCatNo = $Row['housecatcode']; //New Refnumber stored in this field.
$CustomerCode = $Row['customercode'];
//Ignore if
if ($HouseCatNo!=0){
//UPDATE Project Dtl table with newly assined Refcode
$NewPrjDtlString ="UPDATE nmwndb.projectdetails SET customercode='$CustomerCode',reservestatus='2' where refno = $HouseCatNo";
$result = mysqli_query($NewPrjDtlString) or die ('Error');
//Remove Customer Code From Old Record
$OldPrjDtlString ="UPDATE nmwndb.projectdetails SET customercode='0',reservestatus='0' where refno = $Refno";
$result = mysqli_query($OldPrjDtlString) or die ('Old record update fail');
//Open Sales File to get Sales number,
$SalesString = "SELECT * FROM nmwndb.sales where blockrefnumber = $Refno";
$SalRslt = mysqli_query($SalesString) or die ('Error');
$sLRow = mysqli_fetch_assoc($SalRslt);
$SalesReferanceNo = $sLRow['refno'];
//Update Slase file
$SalesString2 = "UPDATE nmwndb.sales SET blockrefnumber='$HouseCatNo' where blockrefnumber = $Refno";
$SalRslt = mysqli_query($SalesString2) or die ('fail to update blockrefno-sales file');
//Update Receipts file
$SalesString2 = "UPDATE nmwndb.customerreceipts SET blocknumber='$HouseCatNo' where salerefno = $SalesReferanceNo";
$SalRslt = mysqli_query($SalesString2) or die ('fail to update blockrefno-receipt file');
}
}
}
}
mysqli_close($opn_Connection);
1
?>