1 |
torben |
2125 |
<?php |
2 |
|
|
|
3 |
|
|
require_once( "../inc/mysql.php" ); |
4 |
|
|
require_once( "ajaxcommon.php" ); |
5 |
|
|
|
6 |
|
|
require("../inc/sendmessages.php"); |
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
$enheder = $_GET["enheder"]; |
12 |
|
|
$individer = $_GET["individer"]; |
13 |
|
|
$besked = $_GET["besked"]; |
14 |
|
|
$samletpris = $_GET["samletpris"]; |
15 |
|
|
|
16 |
|
|
$personer = findPersoner($enheder, $individer); |
17 |
|
|
|
18 |
|
|
$antal = count($personer); |
19 |
|
|
|
20 |
|
|
$besked = escape_string($besked); |
21 |
|
|
|
22 |
|
|
$sql = "INSERT INTO smsjob (enheder,individer,besked,antalmodtagere,samletpris, tidspunkt) VALUES ('$enheder','$individer','$besked', $antal, $samletpris, now());"; |
23 |
|
|
squery($sql); |
24 |
|
|
|
25 |
|
|
$jobid = insert_id(); |
26 |
|
|
|
27 |
|
|
|
28 |
|
|
$count = 0; |
29 |
|
|
$uids = "'" . implode("','", $personer) . "'"; |
30 |
|
|
$sql = "SELECT * FROM stamdata WHERE id IN ($uids) ORDER BY fornavn,efternavn"; |
31 |
|
|
$res = query($sql); |
32 |
|
|
foreach($res as $row) { |
33 |
|
|
|
34 |
|
|
$to = $row->mobil; |
35 |
|
|
|
36 |
|
|
if ($to == "") //ingen grund til at oprette en row i outbox uden mobil nr |
37 |
|
|
continue; |
38 |
|
|
|
39 |
|
|
$cc = substr($to,0,2); |
40 |
|
|
|
41 |
|
|
if ( $cc != "45") { |
42 |
|
|
$to = "45" . $to; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
$sql = "insert into outbox(receiver,message,status,statustime) values('$to','$besked','NEW', now() )"; |
46 |
|
|
squery($sql); |
47 |
|
|
|
48 |
|
|
$count++; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
sendmessages(); |
52 |
|
|
|
53 |
|
|
|
54 |
|
|
?> |