-
Notifications
You must be signed in to change notification settings - Fork 0
/
editTNS.php
executable file
·69 lines (58 loc) · 1.93 KB
/
editTNS.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
<?php require('core/init.php'); ?>
<?php
if (!isset($_SESSION['user_name'])) {
redirect('index.php', 'Niste prijavljeni na sistem', 'error');
} else {
// Create Company Object
$editCompany = new EditCompany;
// Create Company Object
$company = new Company;
//Create Validator object
$validate = new Validator;
// Get Template
$template = new Template('templates/editTNS.php');
//Get Vars
$companyId = $_SESSION['company_id'];
$template->tnsNames = $company->getTNS($companyId);
$tnsNames = $company->getTNS($companyId);
foreach ($tnsNames as $tnsName) {
if (isset($_POST['editTns' . $tnsName->id])) {
// Sanitize POST data
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
//Get Vars
$data = [
'tnsId' => $tnsName->id,
'tnsCompanyId' => $tnsName->company_id,
'tnsServer' => trim($_POST['tnsServer']),
'tnsHoustName' => trim($_POST['tnsHoustName']),
'tnsServiceName' => trim($_POST['tnsServiceName']),
'tnsUserName' => trim($_POST['tnsUserName']),
'tnsPassword' => trim($_POST['tnsPassword'])
];
//Required array
$field_array = array('tnsServer', 'tnsHoustName', 'tnsServiceName', 'tnsUserName', 'tnsPassword');
if ($validate->isRequired($field_array)) {
if ($editCompany->editTns($data)) {
redirect('editTNS.php', 'Uspešno ste izmenili TNS podatak', 'success');
} else {
redirect('editTNS.php', 'Izmena TNS podatka nije uspela', 'error');
}
} else {
redirect('editTNS.php', 'Molim vas popunite sva obavezna polja', 'error');
}
} elseif (isset($_POST['deleteTns' . $tnsName->id])) {
//Get Vars
$data = [
'tnsId' => $tnsName->id,
'tnsCompanyId' => $tnsName->company_id
];
if ($editCompany->deleteTns($data)) {
redirect('editTNS.php', 'Uspešno ste obrisali TNS konekciju', 'success');
} else {
redirect('editTNS.php', 'Brisanje TNS podatka nije uspelo', 'error');
}
}
}
// Display template
echo $template;
}