RT# 73993 updated ngselfservice to allow for package change.
[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   echo $results;
57
58 }
59
60 #  if ( $results->{'error'} ) {
61 #    $action = 'customer_change_pkg';
62 #    return {
63 #      $cgi->Vars,
64 #      %{customer_change_pkg()},
65 #      'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
66 #    };
67 #  } else {
68 #    return $results;
69 #  }
70
71
72 ## reload below except pkgnum
73 if ( isset($results['error']) && $results['error'] ) {
74   $error = $results['error'];
75 #  header('Location:services.php?error='. urlencode($error));
76 #  die();
77 }
78
79 #$pkgnum = $results['pkgnum'];
80
81 #header("Location:services.php"); # #pkgnum ?
82 ## end reload
83 ?>
84 <? include('elements/error.php'); ?>
85
86 <FONT SIZE=4>Package Changed Su for "<? echo $pkg; ?>"</FONT><BR><BR>
87
88 <? include('elements/menu_footer.php'); ?>
89 <? include('elements/footer.php'); ?>