// Get all invoices that are unpaid.
$billingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
- $unpaid_invoices = $billingSupport->getUnPaidInvoices();
- echo '<pre>$unpaid_invoices: ' . print_r( $unpaid_invoices, true ) . '</pre>';
+ //$unpaid_invoices = $billingSupport->getUnPaidInvoices();
+ //echo '<pre>$unpaid_invoices: ' . print_r( $unpaid_invoices, true ) . '</pre>';
+
+ foreach ( $notifications as $notice ) {
+ echo '<pre>$notice: ' . print_r( $notice, true ) . '</pre>';
+ }
// Loop through the invoices and for each one see if any notices are to be sent out.
$currentDate = new DateTime();
echo '<pre>$currentDate: ' . print_r( $currentDate, true ) . '</pre>';
- foreach ( $unpaid_invoices as $invoice ) {
- $due_date = $invoice['due_date'];
-
- // Loop through the notifications and see if this unpaid one is due.
- foreach ( $notifications as $notice ) {
- // Need due date set in this loop each time.
- $dueDate = new DateTime( $due_date );
- // Is this before or after
- switch ( $notice['send_date_when'] ) {
- case $this->config['send_date_when_numb']['Before']:
- echo '<p>Before</p>';
- $dueDate->modify(
- '-' . $notice['send_date_number'] . ' '.
- $this->config['send_date_period'][$notice['send_date_period']] .
- (($notice['send_date_number'] > 1) ? 's': '')
- );
- echo '<pre>$dueDate: ' . print_r( $dueDate, true ) . '</pre>';
- $diff = $dueDate->diff( $currentDate );
- // When the diff is 0 days then the notice needs to go out.
-
- $days_from = $diff->format( '%a' );
- echo '<pre>$days_from: ' . print_r( $days_from, true ) . '</pre>';
- // Check to see if this date occurs today.
- if ( $days_from === '0' ) {
- // Add the notice id and account id to the queue
- $Notifications->queueNotice( $notice['id'], $invoice['account'] );
- }
-
- break;
- case $this->config['send_date_when_numb']['After']:
- echo '<p>After</p>';
- $dueDate->modify(
- '+' . $notice['send_date_number'] . ' '.
- $this->config['send_date_period'][$notice['send_date_period']] .
- (($notice['send_date_number'] > 1) ? 's': '')
- );
- echo '<pre>$dueDate: ' . print_r( $dueDate, true ) . '</pre>';
- $diff = $dueDate->diff( $currentDate );
- $days_from = $diff->format( '%a' );
- echo '<pre>$days_from: ' . print_r( $days_from, true ) . '</pre>';
- // Check to see if this date occurs today.
- if ( $days_from === '0' ) {
- // Create the notice email
- $Notifications->queueNotice( $notice['id'], $invoice['account'] );
- }
- break;
- default:
- break;
- }
- }
- }
+ // foreach ( $unpaid_invoices as $invoice ) {
+ // $due_date = $invoice['due_date'];
+ //
+ // // Loop through the notifications and see if this unpaid one is due.
+ // foreach ( $notifications as $notice ) {
+ // // Need due date set in this loop each time.
+ // $dueDate = new DateTime( $due_date );
+ // // Is this before or after
+ // switch ( $notice['send_date_when'] ) {
+ // case $this->config['send_date_when_numb']['Before']:
+ // echo '<p>Before</p>';
+ // $dueDate->modify(
+ // '-' . $notice['send_date_number'] . ' '.
+ // $this->config['send_date_period'][$notice['send_date_period']] .
+ // (($notice['send_date_number'] > 1) ? 's': '')
+ // );
+ // echo '<pre>$dueDate: ' . print_r( $dueDate, true ) . '</pre>';
+ // $diff = $dueDate->diff( $currentDate );
+ // // When the diff is 0 days then the notice needs to go out.
+ //
+ // $days_from = $diff->format( '%a' );
+ // echo '<pre>$days_from: ' . print_r( $days_from, true ) . '</pre>';
+ // // Check to see if this date occurs today.
+ // if ( $days_from === '0' ) {
+ // // Add the notice id and account id to the queue
+ // $Notifications->queueNotice( $notice['id'], $invoice['account'] );
+ // }
+ //
+ // break;
+ // case $this->config['send_date_when_numb']['After']:
+ // echo '<p>After</p>';
+ // $dueDate->modify(
+ // '+' . $notice['send_date_number'] . ' '.
+ // $this->config['send_date_period'][$notice['send_date_period']] .
+ // (($notice['send_date_number'] > 1) ? 's': '')
+ // );
+ // echo '<pre>$dueDate: ' . print_r( $dueDate, true ) . '</pre>';
+ // $diff = $dueDate->diff( $currentDate );
+ // $days_from = $diff->format( '%a' );
+ // echo '<pre>$days_from: ' . print_r( $days_from, true ) . '</pre>';
+ // // Check to see if this date occurs today.
+ // if ( $days_from === '0' ) {
+ // // Create the notice email
+ // $Notifications->queueNotice( $notice['id'], $invoice['account'] );
+ // }
+ // break;
+ // default:
+ // break;
+ // }
+ // }
+ // }
wp_die();
}