default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / ng_selfservice / process_packages_change.php
1 <? $title ='Change Package'; include('elements/header.php'); ?>
2 <? $current_menu = 'services.php'; include('elements/menu.php'); ?>
3
4 <?
5
6 require_once('elements/session.php');
7
8 $results = array();
9
10 $params = array( 'custnum', 'pkgpart', 'pkgnum' );
11
12 $matches = array();
13 if ( preg_match( '/^(\d+)_(\d+)$/', $_POST['pkgpart_svcpart'], $matches ) ) {
14   $_POST['pkgpart'] = $matches[1];
15   $_POST['svcpart'] = $matches[2];
16   $params[] = 'svcpart';
17   $svcdb = $_POST['svcdb'];
18   if ( $svcdb == 'svc_acct' ) { $params[] = 'domsvc'; }
19 } else {
20   $svcdb = 'svc_acct';
21 }
22
23 if ( $svcdb == 'svc_acct' ) {
24
25   array_push($params, 'username', '_password', '_password2', 'sec_phrase', 'popnum' );
26
27   #if ( strlen($_POST['_password']) == 0 ) {
28   #  $results['error'] = 'Empty password';
29   #}
30   #if ( $_POST['_password'] != $_POST['_password'] ) {
31   #  $results['error'] = 'Passwords do not match';
32   #  $_POST['_password'] = '';
33   #  $_POST['_password2'] = '';
34   #}
35
36 } elseif ( $svcdb == 'svc_phone' ) {
37
38   array_push($params, 'phonenum', 'sip_password', 'pin', 'phone_name' );
39
40 } else {
41   die("$svcdb not handled on process_change_pkg yet");
42 }
43
44 if ( ! $results['error'] ) {
45
46   $change_pkg = array(
47     'session_id' => $_COOKIE['session_id'],
48   );
49
50   foreach ( $params AS $param ) {
51     $change_pkg[$param] = $_POST[$param];
52   }
53
54   $results = $freeside->change_pkg($change_pkg);
55
56 }
57
58 #  if ( $results->{'error'} ) {
59 #    $action = 'customer_change_pkg';
60 #    return {
61 #      $cgi->Vars,
62 #      %{customer_change_pkg()},
63 #      'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
64 #    };
65 #  } else {
66 #    return $results;
67 #  }
68
69
70 ## reload below except pkgnum
71 if ( isset($results['error']) && $results['error'] ) {
72   $error = $results['error'];
73 #  header('Location:services.php?error='. urlencode($error));
74 #  die();
75 }
76
77 #$pkgnum = $results['pkgnum'];
78
79 #header("Location:services.php"); # #pkgnum ?
80 ## end reload
81 ?>
82 <? include('elements/error.php'); ?>
83
84 <FONT SIZE=4>Package Successfully Changed To "<? echo htmlspecialchars($results['pkg']); ?>"</FONT><BR><BR>
85
86 <? include('elements/menu_footer.php'); ?>
87 <? include('elements/footer.php'); ?>