| 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
 | <?php require("checkuser.php"); ?><?
 $staffid        = $_POST['staffid'];
 $custid            = $_POST['custid'];
 $email            = $_POST['email'];
 $jobtimefr        = $_POST['jobtimefr'];
 $jobtimeto        = $_POST['jobtimeto'];
 $jobdate        = $_POST['jobdate'];
 $jobtype        = $_POST['jobtype'];
 $calldate        = $_POST['calldate'];
 $calltime        = $_POST['calltime'];
 $jobdetail        = htmlspecialchars($_POST['jobdetail'], ENT_QUOTES);
 $jobaction        = htmlspecialchars($_POST['jobaction'], ENT_QUOTES);
 $jobstatus        = $_POST['jobstatus'];
 $remarks        = htmlspecialchars($_POST['remarks'], ENT_QUOTES);
 $creationby        = $_SESSION['userid'];
 $creationdate    = date("Ymdgis");
 $updatedby        = $_SESSION['userid'];
 $updateddate    = date("Ymdgis");
 $filename        = $_FILES['filename']['name'];
 
 if (strlen($jobstatus) == 0)
 $jobstatus = 1;
 
 /*
 echo "<br>". $staffid;
 echo "<br>". $custid;
 echo "<br>". $email;
 echo "<br>". $jobtimefr;
 echo "<br>". $jobtimeto;
 echo "<br>". $jobdate;
 echo "<br>". $calldate;
 echo "<br>". $calltime;
 echo "<br>". $jobdetail;
 echo "<br>". $jobaction;
 echo "<br>". $jobstatus;
 echo "<br>". $remarks;
 echo "<br>". $creationby;
 echo "<br>". $creationdate;
 echo "<br>". $updatedby;
 echo "<br>". $updateddate;
 */
 include("configure.php");
 
 //**
 $sql = "select max(jobid) as maxjobid from SYS_JOB";
 $result = mysql_query($sql);
 if ($row = mysql_fetch_array($result,MYSQL_ASSOC))
 {
 $id = $row{'maxjobid'} + 1;
 }
 
 if (strlen($_FILES['filename']['name']) <> 0)
 {
 if ($_FILES['filename']['size'] < 10000000)
 {
 copy ($_FILES['filename']['tmp_name'], "docs/". $id."_".$_FILES['filename']['name'])
 or die("<br>Can't copy");
 $filename = $id."_".$_FILES['filename']['name'];
 }
 else
 {
 die("<br>File size error");
 }
 }
 //**
 
 $sql = "SELECT * ";
 $sql .= "FROM CM_CUSTOMER_HDR ";
 $sql .= "where custid = ". $custid ." ";
 
 $result = mysql_query($sql);
 if ($row = mysql_fetch_array($result,MYSQL_ASSOC))
 {
 $custname        = $row{'custname'};
 $address        = htmlspecialchars($row{'address'}, ENT_QUOTES);
 $contactperson    = $row{'contactperson'};
 $telno            = $row{'telno'};
 }
 
 $sql = "insert into SYS_JOB ";
 $sql .= "(staffid, custid, email, jobtimefr, jobtimeto, jobdate, jobtype, calldate, calltime, jobdetail, jobaction, jobstatus, remarks, creationby, creationdate, custname, address, contactperson, telno, filename) ";
 $sql .= "values ($staffid, $custid, '$email', '$jobtimefr', '$jobtimeto', '$jobdate', $jobtype, '$calldate', '$calltime', '$jobdetail', '$jobaction', $jobstatus, '$remarks', '$creationby', '$creationdate', '$custname', '$address', '$contactperson', '$telno', '$filename')";
 
 $result = mysql_query($sql);
 if (!$result) {
 die('Invalid query: ' . mysql_error());
 }
 
 $sql = "SELECT max(jobid) as maxjobid, md5(max(jobid)) as md5id ";
 $sql .= "FROM SYS_JOB ";
 $sql .= "where custid = ". $custid ." ";
 
 $result = mysql_query($sql);
 if ($row = mysql_fetch_array($result,MYSQL_ASSOC))
 {
 $jobid = $row{'maxjobid'};
 $md5id = $row{'md5id'};
 }
 
 
 if (strlen($email) <> 0)
 require("sendEmail.php");
 
 
 header("Location: jobdetail.php?jobid=$jobid");
 ?>
 |