summaryrefslogtreecommitdiff
path: root/ng_selfservice
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-04-25 15:02:15 -0700
committerMark Wells <mark@freeside.biz>2015-04-25 15:02:23 -0700
commitc110da0da864245e47cae019b8a347367cc6430c (patch)
treee406be890446095b8cd59a5b5c827c62dd063fff /ng_selfservice
parent4fda726fa9f8e709c68ec823edc5ae702723281c (diff)
selfservice quotations, #33852
Diffstat (limited to 'ng_selfservice')
-rw-r--r--ng_selfservice/images/cross.pngbin0 -> 655 bytes
-rw-r--r--ng_selfservice/quotation.php130
-rw-r--r--ng_selfservice/quotation_add_pkg.php31
-rw-r--r--ng_selfservice/quotation_order.php15
-rw-r--r--ng_selfservice/quotation_print.php17
-rw-r--r--ng_selfservice/quotation_remove_pkg.php31
6 files changed, 224 insertions, 0 deletions
diff --git a/ng_selfservice/images/cross.png b/ng_selfservice/images/cross.png
new file mode 100644
index 0000000..1514d51
--- /dev/null
+++ b/ng_selfservice/images/cross.png
Binary files differ
diff --git a/ng_selfservice/quotation.php b/ng_selfservice/quotation.php
new file mode 100644
index 0000000..cf45543
--- /dev/null
+++ b/ng_selfservice/quotation.php
@@ -0,0 +1,130 @@
+<STYLE>
+td.amount {
+ text-align: right;
+}
+td.amount:before {
+ content: "$";
+}
+tr.total * {
+ background-color: #ddf;
+ font-weight: bold;
+}
+table.section {
+ width: 100%;
+ border-collapse: collapse;
+}
+table.section td {
+ font-size: small;
+ padding: 1ex 1ex;
+}
+table.section th {
+ text-align: left;
+ padding: 1ex;
+}
+.row0 td {
+ background-color: #eee;
+}
+.row1 td {
+ background-color: #fff;
+}
+</STYLE>
+
+<? $title ='Plan a new service order'; include('elements/header.php'); ?>
+<? $current_menu = 'services_new.php'; include('elements/menu.php'); ?>
+<?
+
+$quotation = $freeside->quotation_info(array(
+ 'session_id' => $_COOKIE['session_id'],
+));
+
+$can_order = 0;
+
+if ( isset($quotation['sections']) and count($quotation['sections']) > 0 ) {
+ $can_order = 1;
+ # there are other ways this could be formatted, yes.
+ # if you want the HTML-formatted quotation, use quotation_print().
+ print(
+ '<INPUT STYLE="float: right" TYPE="button" onclick="window.location.href=\'quotation_print.php\'" value="Download a quotation" />'.
+ '<H3>Order summary</H3>'.
+ "\n"
+ );
+ foreach ( $quotation['sections'] as $section ) {
+ print(
+ '<TABLE CLASS="section">'.
+ '<TR>'.
+ '<TH COLSPAN=4>'. htmlspecialchars($section['description']).'</TH>'.
+ '</TR>'.
+ "\n"
+ );
+ $row = 0;
+ foreach ( $section['detail_items'] as $detail ) {
+ print(
+ '<TR CLASS="row' . $row . '">'.
+ '<TD>'
+ );
+ if ( $detail['pkgnum'] ) {
+ print(
+ '<A HREF="quotation_remove_pkg.php?pkgnum=' .
+ $detail['pkgnum'] . '">'.
+ '<IMG SRC="images/cross.png" /></A>'
+ );
+ }
+ print(
+ '</TD>'.
+ '<TD>'. htmlspecialchars($detail['description']). '</TD>'.
+ '<TD CLASS="amount">'. $detail['amount']. '</TD>'.
+ '</TR>'. "\n"
+ );
+ $row = 1 - $row;
+ }
+ print(
+ '<TR CLASS="total">'.
+ '<TD></TD>'.
+ '<TD>Total</TD>'.
+ '<TD CLASS="amount">'. $section['subtotal']. '</TD>'.
+ '</TR>'.
+ '</TABLE>'.
+ "\n"
+ );
+ } # foreach $section
+}
+
+$pkgselect = $freeside->mason_comp( array(
+ 'session_id' => $_COOKIE['session_id'],
+ 'comp' => '/elements/select-part_pkg.html',
+ 'args' => array( 'onchange' , 'enable_order_pkg()',
+ 'empty_label' , 'Select package',
+ 'form_name' , 'AddPkgForm',
+ ),
+));
+if ( isset($pkgselect['error']) && $pkgselect['error'] ) {
+ $error = $pkgselect['error'];
+ header('Location:index.php?error='. urlencode($pkgselect));
+ die();
+}
+
+?>
+<SCRIPT TYPE="text/javascript">
+function enable_order_pkg () {
+ document.AddPkgForm.submit.disabled =
+ (document.AddPkgForm.pkgpart.value == '');
+}
+</SCRIPT>
+
+<DIV STYLE="border-top: 1px solid; padding: 1ex">
+<? $error = $_REQUEST['error']; include('elements/error.php'); ?>
+
+<FORM NAME="AddPkgForm" ACTION="quotation_add_pkg.php" METHOD=POST>
+<? echo $pkgselect['output']; ?>
+<INPUT NAME="submit" TYPE="submit" VALUE="Add package" <? if ( ! isset($_REQUEST['pkgpart']) ) { echo 'DISABLED'; } ?>>
+</FORM>
+
+<? if ( $can_order ) { ?>
+<FORM NAME="OrderQuoteForm" ACTION="quotation_order.php" METHOD=POST>
+<INPUT TYPE="submit" VALUE="Confirm this order" <? if ( !$can_order ) { echo 'DISABLED'; } ?>>
+<? } ?>
+
+</DIV>
+
+<? include('elements/menu_footer.php'); ?>
+<? include('elements/footer.php'); ?>
diff --git a/ng_selfservice/quotation_add_pkg.php b/ng_selfservice/quotation_add_pkg.php
new file mode 100644
index 0000000..1e7e71f
--- /dev/null
+++ b/ng_selfservice/quotation_add_pkg.php
@@ -0,0 +1,31 @@
+<? require('elements/session.php');
+
+$dest = 'quotation.php';
+
+if ( isset($_REQUEST['pkgpart']) ) {
+
+ $results = array();
+
+ $params = array( 'custnum', 'pkgpart' );
+
+ $matches = array();
+ if ( preg_match( '/^(\d+)$/', $_REQUEST['pkgpart'] ) ) {
+
+ $args = array(
+ 'session_id' => $_COOKIE['session_id'],
+ 'pkgpart' => $_REQUEST['pkgpart'],
+ );
+
+ $results = $freeside->quotation_add_pkg($args);
+
+ }
+
+ if ( isset($results['error']) && $results['error'] ) {
+ $dest .= '?error=' . $results['error'] . ';pkgpart=' . $_REQUEST['pkgpart'];
+ }
+}
+
+header("Location:$dest");
+
+?>
+
diff --git a/ng_selfservice/quotation_order.php b/ng_selfservice/quotation_order.php
new file mode 100644
index 0000000..d35eacb
--- /dev/null
+++ b/ng_selfservice/quotation_order.php
@@ -0,0 +1,15 @@
+<? require('elements/session.php');
+
+$dest = 'services.php';
+
+$args = array( 'session_id' => $_COOKIE['session_id'] );
+
+$results = $freeside->quotation_order($args);
+
+if ( isset($results['error']) && $results['error'] ) {
+ $dest = 'quotation.php?error=' . $results['error'];
+}
+
+header("Location:$dest");
+
+?>
diff --git a/ng_selfservice/quotation_print.php b/ng_selfservice/quotation_print.php
new file mode 100644
index 0000000..9676405
--- /dev/null
+++ b/ng_selfservice/quotation_print.php
@@ -0,0 +1,17 @@
+<? require('elements/session.php');
+
+$args = array(
+ 'session_id' => $_COOKIE['session_id'],
+ 'format' => 'pdf'
+);
+
+$results = $freeside->quotation_print($args);
+if ( isset($results['document']) ) {
+ header('Content-Type: application/pdf');
+ header('Content-Disposition: filename=quotation.pdf');
+ print($results['document']->scalar);
+} else {
+ header("Location: quotation.php?error=" . $results['error']);
+}
+
+?>
diff --git a/ng_selfservice/quotation_remove_pkg.php b/ng_selfservice/quotation_remove_pkg.php
new file mode 100644
index 0000000..07548c7
--- /dev/null
+++ b/ng_selfservice/quotation_remove_pkg.php
@@ -0,0 +1,31 @@
+<? require('elements/session.php');
+
+$dest = 'quotation.php';
+
+if ( isset($_REQUEST['pkgnum']) ) {
+
+ $results = array();
+
+ $params = array( 'custnum', 'pkgnum' );
+
+ $matches = array();
+ if ( preg_match( '/^(\d+)$/', $_REQUEST['pkgnum'] ) ) {
+
+ $args = array(
+ 'session_id' => $_COOKIE['session_id'],
+ 'pkgnum' => $_REQUEST['pkgnum'],
+ );
+
+ $results = $freeside->quotation_remove_pkg($args);
+
+ }
+
+ if ( isset($results['error']) && $results['error'] ) {
+ $dest .= '?error=' . $results['error'];
+ }
+
+}
+
+header("Location:$dest");
+
+?>