-
Notifications
You must be signed in to change notification settings - Fork 0
/
frm_asset_models.php
180 lines (166 loc) · 8.62 KB
/
frm_asset_models.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
<?php
require_once 'support/config.php';
if(!isLoggedIn()){
toLogin();
die();
}
if(!AllowUser(array(1,2))){
redirect("index.php");
}
if(!empty($_GET['id'])){
$asset_model=$con->myQuery("SELECT id,name,manufacturer_id,category_id,image,model_no,EOL,depreciation_id FROM asset_models WHERE id=?",array($_GET['id']))->fetch(PDO::FETCH_ASSOC);
if(empty($asset_model)){
//Alert("Invalid asset selected.");
Modal("Invalid Asset Model Selected");
redirect("asset_models.php");
die();
}
}
if(!empty($_SESSION[WEBAPP]['frm_inputs'])){
if(!empty($asset_model)){
$old_asset_model=$asset_model;
}
$asset_model=$_SESSION[WEBAPP]['frm_inputs'];
if(!empty($old_asset_model)){
$asset_model['id']=$old_asset_model['id'];
}
}
$manufacturers=$con->myQuery("SELECT id,name FROM manufacturers WHERE is_deleted=0")->fetchAll(PDO::FETCH_ASSOC);
$categories=$con->myQuery("SELECT id,name FROM categories WHERE is_deleted=0 AND category_type_id=1")->fetchAll(PDO::FETCH_ASSOC);
$depreciations=$con->myQuery("SELECT id,name FROM depreciations WHERE is_deleted=0")->fetchAll(PDO::FETCH_ASSOC);
makeHead("Asset Models");
?>
<?php
require_once("template/header.php");
require_once("template/sidebar.php");
?>
<div class='content-wrapper'>
<div class='content-header'>
<h1 class='page-header text-center text-green'>Asset Models Form</h1>
</div>
<section class='content'>
<div class='row'>
<div class='col-md-12'>
<?php
Alert();
?>
<div class='row'>
<div class='col-sm-12 col-md-8 col-md-offset-2'>
<form class='form-horizontal' method='POST' action='save_asset_model.php'>
<input type='hidden' name='id' value='<?php echo !empty($asset_model)?$asset_model['id']:""?>'>
<div class='form-group'>
<label class='col-sm-12 col-md-3 control-label'> Name*</label>
<div class='col-sm-12 col-md-9'>
<input type='text' class='form-control' name='model_name' placeholder='Enter Model Name' value='<?php echo !empty($asset_model)?$asset_model['name']:"" ?>' required>
</div>
</div>
<div class='form-group'>
<label class='col-sm-12 col-md-3 control-label'> Model Number</label>
<div class='col-sm-12 col-md-9'>
<input type='text' class='form-control' name='model_no' placeholder='Enter Model Number' value='<?php echo !empty($asset_model)?$asset_model['model_no']:"" ?>' required>
</div>
</div>
<div class='form-group'>
<label class='col-sm-12 col-md-3 control-label'> Manufacturer*</label>
<div class='col-sm-12 col-md-9'>
<div class='row'>
<div class='col-sm-11'>
<select class='form-control' name='manufacturer_id' data-placeholder="Select a Manufacturer" <?php echo!(empty($asset_model))?"data-selected='".$asset_model['manufacturer_id']."'":NULL ?> required>
<?php
echo makeOptions($manufacturers);
?>
</select>
</div>
<div class='col-ms-1'>
<a href='manufacturers.php' class='btn btn-flat btn-sm btn-success'><span class='fa fa-plus'></span></a>
</div>
</div>
</div>
</div>
<div class='form-group'>
<label class='col-sm-12 col-md-3 control-label'> Category*</label>
<div class='col-sm-12 col-md-9'>
<div class='row'>
<div class='col-sm-11'>
<select class='form-control' name='category_id' data-placeholder="Select a Category" <?php echo!(empty($asset_model))?"data-selected='".$asset_model['category_id']."'":NULL ?>>
<?php
echo makeOptions($categories);
?>
</select>
</div>
<div class='col-ms-1'>
<a href='categories.php' class='btn btn-flat btn-sm btn-success'><span class='fa fa-plus'></span></a>
</div>
</div>
</div>
</div>
<div class='form-group'>
<label class='col-sm-12 col-md-3 control-label'> End of Life (EOL) *</label>
<div class='col-sm-12 col-md-9'>
<?php
$EOL="";
if(!empty($asset_model)){
$EOL=$asset_model['EOL'];
if($EOL=="0000-00-00"){
$EOL="";
}
else
{
$EOL=inputmask_format_date($EOL);
}
}
?>
<input type='text' class='form-control date_picker' name='EOL' id='EOL' value='<?php echo $EOL; ?>' required>
</div>
</div>
<div class='form-group'>
<label class='col-sm-12 col-md-3 control-label'> Depreciation*</label>
<div class='col-sm-12 col-md-9'>
<div class='row'>
<div class='col-sm-11'>
<select class='form-control' name='depreciation_id' data-placeholder="Select a Depreciation" <?php echo!(empty($asset_model))?"data-selected='".$asset_model['depreciation_id']."'":NULL ?>>
<?php
echo makeOptions($depreciations);
?>
</select>
</div>
<div class='col-ms-1'>
<a href='depreciations.php' class='btn btn-flat btn-sm btn-success'><span class='fa fa-plus'></span></a>
</div>
</div>
</div>
</div>
<div class='form-group'>
<div class='col-sm-12 col-md-9 col-md-offset-3 '>
<a href='asset_models.php' class='btn btn-flat btn-default' onclick="return confirm('<?php echo !empty($asset_model['id'])?'Are you sure you want to cancel the modification of the asset model?':'Are you sure you want to cancel the creation of the new asset model?';?>')">Cancel</a>
<button type='submit' class='btn btn-flat btn-success'> <span class='fa fa-check'></span> Save</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
<script type="text/javascript">
<?php
if(!empty($asset_model)):
?>
$(document).ready(function(){
$("#EOL").val("<?php echo $EOL?>");
// console.log($("#purchase_date").inputmask("hasMasked"));
});
<?php
endif;
?>
</script>
<?php
if(!empty($_SESSION[WEBAPP]['frm_inputs'])){
unset($_SESSION[WEBAPP]['frm_inputs']);
}
Modal();
?>
<?php
makeFoot();
?>