-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemo-form.php
150 lines (138 loc) · 5.37 KB
/
memo-form.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
<?php
include_once ('config.php');
include_once ($cfgSecDir.'secure.php');
$_SESSION['scrTok'] = base64_encode(md5(session_id(). str_shuffle('memo'.time())));
if(! isset($_SESSION['login']) || $_SESSION['login'] == ''){
echo "<script>window.location = 'index.php'</script>";
die();
}
$type = $_GET['typ'];
$err = 0;
$inptSubj = '<input type="text" class="textbox" style="width:400px;text-transform:uppercase;color:#000;" name="title" value="" />';
if($type == 'com') {
$id = '';
$title = 'Tulis Memo';
$action = 'memo-send-message.php';
$mfrom = $login;
$mto = 'Operator';
}
if($type == 'rep' || $type == 'fwd'){
$title = 'Balas Memo';
$action = 'memo-send-reply.php';
if($rep == 'rep'){
$mfrom = 'Operator';
$mto = $login;
}else{
$mfrom = $login;
$mto = 'Operator';
}
if (!$_GET["id"])die();
$id = $_GET["id"];
if ($id > 0){
$reqAPIMemoRead = array(
"auth" => $authapi,
"userid" => $login,
"id" => $id,
"type" => 2,
);
$respMemoRead = sendAPI($url_Api."/memo",$reqAPIMemoRead,'JSON','02e97eddc9524a1e');
if($respMemoRead->status != 200){
$err = 1;
$errorReport = "<div class='alert alert-danger' style='margin-left: 0px;'>" . $respMemoRead->msg . "</div>";
}
$inptSubj = $respMemoRead->resp->msubject;
}
}
?>
<style>table td { color: #fff; } .modal-header h2{ color: #000; text-shadow: 2px 4px 3px rgba(0, 0, 0, 0.2), 0 -2px 5px rgba(0, 0, 0, 0.4);}</style>
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<div class="modal-header">
<span class="close">×</span>
<h2><?php echo $title; ?></h2>
</div>
<div class="modal-body">
<center><div class="res" id="res_memo"><?php if(!isset($errorReport)){$errorReport = '';} echo $errorReport?></div></center>
<form method="post" action="<?php echo $action;?>" id="form_memo" style="color:#003642;">
<input type="hidden" name="memtok" value="<?php echo $id?>" />
<table cellpadding="0" cellspacing="0" border="0" style="color:#fff;">
<tr>
<td width="100">From</td>
<td width="10">:</td>
<td><?php echo $mfrom;?></td>
</tr><tr><td height="5"></td></tr>
<tr>
<td width="100">To</td>
<td width="10">:</td>
<td><?php echo $mto;?></td>
</tr><tr><td height="5"></td></tr>
<tr>
<td width="100">Subject</td>
<td width="10">:</td>
<td><?php echo $inptSubj; ?></td>
</tr><tr><td height="5"></td></tr>
<tr valign="top">
<td style="padding-top:5px;">Message</td>
<td style="padding-top:5px;">:</td>
<td>
<textarea style="width:400px;height:200px;color:#000;resize: none;" name="descr" id="descr"></textarea>
</td>
</tr>
<?php
if($type == 'rep' || $type == 'fwd') {
?>
<tr valign="top">
<td >Quote</td>
<td >:</td>
<td>
<?php
$memo = explode("##quote##",$respMemoRead->resp->mbody);
echo $memo[0];
echo "<br>".$memo[1];
?>
</td>
</tr>
<?php
}
?>
<tr><td height="5"></td></tr>
</table>
<div style="height:5px;"></div>
<div align="center">
<?php if($err == 0){?>
<hr>
<div style="height:10px;"></div>
<input type="hidden" name="_tok" value="<?php echo $_SESSION['scrTok'] ?>" id="tok">
<button type="submit" name="submit" value="SUBMITS" class="btn btn_red2">Submit</button>
<?php }?>
</div>
<script language="JavaScript" type="text/javascript">
jQuery(document).ready(function(){
setform("form_memo", "res_memo");
})
</script>
</form>
</div>
<script>
$('.close').click(function () {
var modal = $(this).parent().parent().parent();
modal.css('display', 'none');
$('#Modal .modal-content').html('');
});
$('#form_memo').submit(function() { // catch the form's submit event
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: $(this).attr('method'), // GET or POST
url: $(this).attr('action'), // the file to call
success: function(data) { // on success..
data = JSON.parse(data);
$('#res_memo').html(data.response); // update the DIV
$('#tok').val(data._tok); // update the DIV
if(data.status == '200'){
$("input[name='title']").val('');
$("#descr").val('');
}
}
});
return false; // cancel original event to prevent form submitting
});
</script>