001.
<?php
002.
require
(
'connect.php'
);
003.
require
(
'menu.php'
);
004.
?>
005.
<html>
006.
<head>
007.
<title>nOva</title>
011.
</head>
012.
<body>
013.
<?php
014.
global
$con
;
015.
016.
if
(isset(
$_POST
[
'hdnCmd'
]) &&
$_POST
[
'hdnCmd'
]==
"Add"
)
017.
{
018.
019.
$strSQL
=
"INSERT INTO nova_type "
;
020.
$strSQL
.=
"(type_id,type_code,type_name) "
;
021.
$strSQL
.=
"VALUES "
;
022.
$strSQL
.=
"('','"
.
$_POST
[
"type_code"
].
"','"
.
$_POST
[
"type_name"
].
"' ) "
;
023.
$objQuery
= mysqli_query(
$con
,
$strSQL
)
or
die
(
'Could not look up user information; '
. mysqli_error());
024.
025.
026.
}
027.
028.
029.
if
(isset(
$_POST
[
'hdnCmd'
]) &&
$_POST
[
'hdnCmd'
] ==
"Update"
)
030.
{
031.
$strSQL
=
"UPDATE nova_type SET "
;
032.
$strSQL
.=
"type_id = '"
.
$_POST
[
"type_id"
].
"' "
;
033.
$strSQL
.=
",type_code = '"
.
$_POST
[
"type_code"
].
"' "
;
034.
$strSQL
.=
",type_name = '"
.
$_POST
[
"type_name"
].
"' "
;
035.
$strSQL
.=
"WHERE type_id = '"
.
$_POST
[
"type_id"
].
"' "
;
036.
$objQuery
= mysqli_query(
$con
,
$strSQL
);
037.
if
(!
$objQuery
)
038.
{
039.
echo
"Error Update ["
. mysqli_error().
"]"
;
040.
}
041.
042.
}
043.
044.
if
(isset(
$_GET
[
'Action'
]) &&
$_GET
[
'Action'
] ==
"Del"
)
045.
{
046.
$strSQL
=
" DELETE FROM nova_type "
;
047.
$strSQL
.=
" WHERE type_id = '"
.
$_GET
['type_id
']."'
";
048.
$objQuery
= mysqli_query(
$con
,
$strSQL
);
049.
if
(!
$objQuery
)
050.
{
051.
echo
"Error Delete ["
. mysqli_error().
"]"
;
052.
}
053.
054.
}
055.
056.
$strSQL
=
"SELECT * FROM nova_type"
;
057.
$objQuery
= mysqli_query(
$con
,
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
058.
?>
059.
<form name=
"frmMain"
method=
"post"
action=
"<?php echo $_SERVER["
PHP_SELF
"];?>"
>
060.
<input type=
"hidden"
name=
"hdnCmd"
value=
""
>
061.
<table width=
"600"
border=
"0"
align=
"center"
class
=
"table"
valign=
"middle"
>
062.
<tr>
063.
<p>
064.
<td height=
"45"
colspan=
"5"
>
065.
<button type=
"button"
class
=
"btn btn-success"
data-toggle=
"modal"
data-target=
"#exampleModal"
data-whatever=
"@getbootstrap"
>ADD PRODUCT</button>
066.
067.
<div
class
=
"modal fade"
id=
"exampleModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
aria-hidden=
"true"
>
068.
<div
class
=
"modal-dialog"
role=
"document"
>
069.
<div
class
=
"modal-content"
>
070.
<div
class
=
"modal-header"
>
071.
<h5
class
=
"modal-title"
id=
"exampleModalLabel"
>NEW PRODUCT</h5>
072.
<button type=
"button"
class
=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
073.
<span aria-hidden=
"true"
>×</span>
074.
</button>
075.
</div>
076.
<div
class
=
"modal-body"
>
077.
<form>
078.
<div
class
=
"form-group"
>
079.
<label
for
=
"recipient-name"
class
=
"col-form-label"
>PRODUCT CODE:</label>
080.
<input type=
"text"
class
=
"form-control"
id=
"type_code"
name=
"type_code"
>
081.
</div>
082.
<div
class
=
"form-group"
>
083.
<label
for
=
"message-text"
class
=
"col-form-label"
>PRODUCT NAME:</label>
084.
<input type=
"text"
class
=
"form-control"
id=
"type_code"
name=
"type_name"
>
085.
</div>
086.
</form>
087.
</div>
088.
<div
class
=
"modal-footer"
>
089.
<button type=
"button"
class
=
"btn btn-danger"
data-dismiss=
"modal"
>Close</button>
090.
<button name=
"btnAdd"
type=
"button"
id=
"btnAdd"
value=
"Add"
091.
OnClick=
"frmMain.hdnCmd.value='Add';frmMain.submit();"
class
=
"btn btn-success"
>Save</button>
092.
</div>
093.
</div>
094.
</div>
095.
</div>
096.
</td>
097.
</tr>
098.
<tr>
099.
<td align=
"center"
>#</td>
100.
<td>PRODUCT CODE</td>
101.
<td>PRODUCT NAME</td>
102.
<td></td>
103.
<td></td>
104.
</tr>
105.
<?php
106.
while
(
$objResult
= mysqli_fetch_array(
$objQuery
))
107.
{
108.
?>
109.
110.
<?php
111.
$strAction
= isset(
$_GET
[
'Action'
]) ?
$_GET
[
'Action'
] :
''
;
112.
if
(
$strAction
==
"Edit"
)
113.
{
114.
if
(
$objResult
[
"type_id"
] ==
$_GET
[
"type_id"
] &&
$_GET
[
"Action"
] ==
"Edit"
)
115.
{
116.
}
117.
118.
?>
119.
<tr>
120.
<td><input type=
"text"
name=
"type_id"
value=
"<?php echo $objResult["
type_id
"];?>"
></td>
121.
<td><input type=
"text"
name=
"type_code"
value=
"<?php echo $objResult["
type_code
"];?>"
></td>
122.
<td><input type=
"text"
name=
"type_name"
value=
"<?php echo $objResult["
type_name
"];?>"
></td>
123.
<td colspan=
"2"
align=
"right"
>
124.
<div align=
"center"
>
125.
<input name=
"btnAdd"
type=
"button"
id=
"btnUpdate"
value=
"Update"
OnClick=
"frmMain.hdnCmd.value='Update';frmMain.submit();"
>
126.
<input name=
"btnAdd"
type=
"button"
id=
"btnCancel"
value=
"Cancel"
OnClick=
"window.location='<?php echo $_SERVER["
PHP_SELF
"];?>';"
>
127.
</div>
128.
</td>
129.
</tr>
130.
<?php
131.
}
132.
else
133.
{
134.
?>
135.
<tr>
136.
<td align=
"center"
><div align=
"center"
><?php
echo
$objResult
[
"type_id"
];?></div></td>
137.
<td><?php
echo
$objResult
[
"type_code"
];?></td>
138.
<td><?php
echo
$objResult
[
"type_name"
];?></td>
139.
<td align=
"center"
>
140.
141.
<button type=
"button"
class
=
"btn btn-success"
data-toggle=
"modal"
data-target=
"#myModal"
data-whatever=
"@getbootstrap"
><a href=
"<?php echo $_SERVER["
PHP_SELF
"];?>?Action=Edit&type_id=<?php echo $objResult["
type_id
"];?>"
>Edit</a></button>
142.
143.
<button type=
"button"
class
=
"btn btn-danger"
data-dismiss=
"modal"
><a href=
"JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?php echo $_SERVER["
PHP_SELF
"];?>?Action=Del&type_id=<?php echo $objResult["
type_id
"];?>';}"
>
Delete
</a></button>
144.
145.
</td>
146.
</tr>
147.
</tr>
148.
<?php
149.
}
150.
?>
151.
<?php
152.
}
153.
?>
154.
155.
156.
</table>
157.
</form>
158.
<?php
159.
mysqli_close(
$con
);
160.
?>
161.
</body>
162.
</html>