$sql = "UPDATE subscription_invoices SET subscr_end='" . jb_escape_sql($d_next_month) . "' WHERE invoice_id = '" . jb_escape_sql($_REQUEST['invoice_id']) . "' "; jb_mysql_query($sql); $JBMarkup->ok_msg('Added 1 month'); } if ($_REQUEST['sub_month'] != '') { $invoice_row = JB_get_subscription_invoice_row($_REQUEST['invoice_id']); $t_end = strtotime($invoice_row['subscr_end']); $t_next_month = mktime(date('H', $t_end), date('i', $t_end), date('s', $t_end), date('n', $t_end) - 1, date('j', $t_end), date('Y', $t_end)); $d_next_month = gmdate("Y-m-d H:i:s", $t_next_month); $sql = "UPDATE subscription_invoices SET subscr_end='" . jb_escape_sql($d_next_month) . "' WHERE invoice_id = '" . jb_escape_sql($_REQUEST['invoice_id']) . "' "; jb_mysql_query($sql); $JBMarkup->ok_msg('Subtracted 1 month'); } if ($_REQUEST['expire'] != '') { $invoice_row = JB_get_subscription_invoice_row($_REQUEST['invoice_id']); JB_expire_subscription($invoice_row, $send_email = false); $JBMarkup->ok_msg('Subscription expired'); } if ($_REQUEST['reactivate'] != '') { $invoice_row = JB_get_subscription_invoice_row($_REQUEST['invoice_id']); $now = gmdate("Y-m-d H:i:s"); $sql = "UPDATE subscription_invoices SET `status`='Completed', `processed_date`='{$now}' WHERE invoice_id='" . $_REQUEST['invoice_id'] . "'"; $result = JB_mysql_query($sql) or JB_mail_error("[{$sql}]" . mysql_error()); JB_start_employer_subscription($invoice_row); $JBMarkup->ok_msg('Subscription reactivated'); } if ($_REQUEST['save'] != '') { $invoice_row = JB_get_subscription_invoice_row($_REQUEST['invoice_id']); if ($_REQUEST['can_view_resumes'] == 'Y') { $can_view_resumes = ", can_view_resumes='Y'"; } else {
function JB_update_employer_subscriptions() { // get all the expired invoices $now = gmdate("Y-m-d H:i:s"); // +3600 add 1 hour, this ads an additional hour to the subscription so that PayPal IPN and other have a chance to renew the invoice. $sql = "SELECT * FROM subscription_invoices WHERE ((`status`='Completed' ) OR ((`status`='Pending') AND `reason`='jb_credit_advanced')) AND UNIX_TIMESTAMP(`subscr_end`)+3600 < UNIX_TIMESTAMP('{$now}')"; $invoice_result = @JB_mysql_query($sql) or JB_mail_error(mysql_error() . $sql); while ($invoice_row = @mysql_fetch_array($invoice_result)) { JB_expire_subscription($invoice_row); } }
// confirm the new invoice clone JB_confirm_membership_invoice($invoice_id); pp_log_entry("Placed & confirmed invoice {$invoice_id}"); } JB_complete_membership_invoice($invoice_id, 'PayPal'); JB_debit_transaction($invoice_id, $mc_gross, $mc_currency, $txn_id, $reason_code, "PayPal", $product_type, $_REQUEST['subscr_id']); } JBPLUG_do_callback('pay_trn_subscr_completed', $invoice_id, $product_type); } if ($txn_type == 'subscr_failed') { } if ($txn_type == 'subscr_eot') { if ($product_type == 'S') { // subscriptions to view resume $invoice_row = JB_get_subscription_invoice_row($invoice_id); JB_expire_subscription($invoice_row); } if ($product_type == 'M') { // Membership $invoice_row = JB_get_membership_invoice_row($invoice_id); JB_expire_membership($invoice_id); } } if ($txn_type == 'subscr_signup') { } if ($txn_type == 'web_accept' || $txn_type == '') { // transaction came from a button or straight from paypal switch ($payment_status) { case "Canceled_Reversal": break; case "Completed":