<input type="button" value="New Invoice" onclick="window.location='subscription_report.php?new=1'"> <?php if ($_REQUEST['new'] != '') { //echo "<p>New Invoice"; if ($_REQUEST['go'] != '') { if ($_REQUEST['employer_id'] == '') { $error = "<p><b>Error:</b> Employer account not selected...</p>"; } if ($_REQUEST['subscription_id'] == '') { $error = "<p><b>Error:</b> Subscription not selected...</p>"; } if ($error != '') { echo $error; } else { JB_place_subscription_invoice($_REQUEST['employer_id'], $_REQUEST['subscription_id']); $_REQUEST['new'] = ''; $JBMarkup->ok_msg('New invoice added.'); } } if ($_REQUEST['new'] != '') { ?> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?> ?action=post" > <input type="hidden" name="new" value="<?php echo jb_escape_html($_REQUEST['new']); ?> ">
?> <table width="100%" > <tr> <td width="50%"> <?php // check to see if there are in_cart orders of the same subscription_id $sql = "select * from subscription_invoices where employer_id=" . jb_escape_sql($_SESSION['JB_ID']) . " AND subscription_id='" . jb_escape_sql($_REQUEST['subscription_id']) . "' AND (status='in_cart' ) "; $result = JB_mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result, MYSQL_ASSOC); $invoice_id = $row['invoice_id']; } else { // this is a new order, make a new invoice $invoice_id = JB_place_subscription_invoice($_SESSION['JB_ID'], $_REQUEST['subscription_id']); } if ($invoice_id !== false) { // delete other in_cart orders $sql = "DELETE FROM subscription_invoices WHERE (`status`='in_cart' ) AND `invoice_id` != '{$invoice_id}' AND `employer_id`='" . jb_escape_sql($_SESSION['JB_ID']) . "' "; $result = JB_mysql_query($sql) or die($sql . mysql_error()); $sql = "select * from subscriptions WHERE subscription_id='" . jb_escape_sql($_REQUEST['subscription_id']) . "' "; $result = JB_mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); JB_display_subscription_invoice($invoice_id); ?> </td> <td width="50%"> <p align="center"> <input type="button" class="confirm_order_button" value="<?php