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
|
<?php require_once(__DIR__ . '/../checkuser.php'); function edit($id) { global $dbh, $sqlsrv_dbh; //----------------------------------------------------------------------------- // Find job by id //----------------------------------------------------------------------------- $sql = "SELECT * FROM sup_job WHERE id = ?"; $parameters = array($id); if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute($parameters)) { throw new Exception("sql execute statement failure: $sql"); } $job = $sth->fetch(PDO::FETCH_ASSOC); if (empty($job)) { throw new Exception('Job not found!'); }
if($job["job_type"] == "JOB"){ redirectAndExit('../job/modifyform.php?id='.$id); exit; }
//----------------------------------------------------------------------------- // Check permission //----------------------------------------------------------------------------- if (!Util::isAdmin()) { if ($job['staff_id'] != $_SESSION['webadmin']['id']) { redirectAndExit('index.php?message=No permission!'); } } require(__DIR__ . '/modify.php');
//----------------------------------------------------------------------------- // Return array parameters //----------------------------------------------------------------------------- $sql = "SELECT * FROM sup_job_detail WHERE job_id = ? ORDER BY id"; $parameters = array($job['id']); if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute($parameters)) { throw new Exception("sql execute statement failure: $sql"); } $job['details'] = $sth->fetchAll(); $json_details = array(); foreach ($job['details'] as $detail) { $json_details[] = json_encode($detail); }
$sql = "SELECT * FROM v_cm_customer_support V_CM_CUSTOMER_SUPPORT ORDER BY company_name"; if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute()) { throw new Exception("sql execute statement failure: $sql"); } $customers = $sth->fetchAll(); $sql = "SELECT * FROM sys_login WHERE deleted = ? ORDER BY username"; $parameters = array(0); if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute($parameters)) { throw new Exception("sql execute statement failure: $sql"); } $staffs = $sth->fetchAll(); return array( 'job' => $job, 'typeOptions' => Job::typeOptions(), 'statusOptions' => Job::statusOptions(), 'customers' => $customers, 'staffs' => $staffs, 'json_details' => $json_details, 'detailStausOptions' => JobDetail::statusOptions(), 'message' => $_GET['message'], ); } extract(edit($_GET['id']));
require(__DIR__ . '/views/form.php');
|