Skip to content

Commit

Permalink
fixed invoice scheduler not sending invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
ole committed Oct 25, 2017
1 parent 05e8783 commit 0cf373b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions menu/invoice-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public function DisplaySettings(){
<div id="wcinvoicepdf-scheduler" class="inside tabs-panel" style="display: none;">
<h3><?php _e('Run commands', 'wc-invoice-pdf') ?></h3>
<p>
<a href="javascript:void(0)" onclick="ISPConfigAdmin.RunReminder(this)" class="button">Run Payment Reminder</a><br />
<a href="javascript:void(0)" onclick="WCInvoicePdfAdmin.RunReminder(this)" class="button">Run Payment Reminder</a><br />
Execute the payment reminder being sent to <strong>Admin Email</strong>.<br />This reminder usually occurs DAILY whenever an invoice is due.
</p>
<p>
<a href="javascript:void(0)" onclick="ISPConfigAdmin.RunRecurr(this)" class="button">Test Recurr Payment</a><br />
<a href="javascript:void(0)" onclick="WCInvoicePdfAdmin.RunRecurr(this)" class="button">Test Recurr Payment</a><br />
Test the recurring payments (which is usually send to customer)<br />by overwriting the recipient addresses to <strong>Admin Email</strong>
</p>
<p>
<a href="javascript:void(0)" onclick="ISPConfigAdmin.RunRecurrReminder(this)" class="button">Run Recurr Reminder</a><br />
<a href="javascript:void(0)" onclick="WCInvoicePdfAdmin.RunRecurrReminder(this)" class="button">Run Recurr Reminder</a><br />
Run the recurring reminder now
</p>
<h3><?php _e('Sender info', 'wc-invoice-pdf') ?></h3>
Expand Down
16 changes: 8 additions & 8 deletions model/invoice-task.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public function payment_recur(){

// remind admin about new recurring invoices
if(!empty($res)) {
$curDate = new DateTime();
$curDate = new \DateTime();

$messageBody = \WCInvoicePdf\WCInvoicePdf::$OPTIONS['wc_recur_message'];

foreach ($res as $v) {
$d = new DateTime($v->post_date_gmt);
$d = new \DateTime($v->post_date_gmt);

if($v->payment_period == 'y') {
// yearly
Expand All @@ -102,8 +102,8 @@ public function payment_recur(){

if(isset($dueDate, $postDate) && $dueDate == $postDate) {
// send the real invoice
$order = new WC_Order($v->ID);
$invoice = new IspconfigInvoice($order);
$order = new \WC_Order($v->ID);
$invoice = new Invoice($order);
$invoice->makeRecurring();

add_action('phpmailer_init', function($phpmailer) use($invoice){
Expand Down Expand Up @@ -160,10 +160,10 @@ public function payment_recur_reminder() {

if(!empty($res)) {
foreach ($res as $v) {
$due_date = new DateTime($v->due_date);
$due_date->add(new DateInterval("P{$age}D"));
$due_date = new \DateTime($v->due_date);
$due_date->add(new \DateInterval("P{$age}D"));

$diff = $due_date->diff(new DateTime());
$diff = $due_date->diff(new \DateTime());
$diffDays = intval($diff->format("%a"));
$rest = $diffDays % $interval;

Expand All @@ -174,7 +174,7 @@ public function payment_recur_reminder() {

$v->reminder_sent++;

$order = new WC_Order($v->wc_order_id);
$order = new \WC_Order($v->wc_order_id);

if(!empty(\WCInvoicePdf\WCInvoicePdf::$OPTIONS['wc_recur_test']))
$recipient = \WCInvoicePdf\WCInvoicePdf::$OPTIONS['wc_mail_reminder'];
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ You should have received a copy of the GNU General Public License along with WP

= 1.0.4 =
* reenable the invoice list filter
* fixed invoice scheduler not sending invoices

= 1.0.3 =
* removed migrated option from WP-ISPConfig3 only when migration succeeded
Expand Down
2 changes: 1 addition & 1 deletion wc-invoice-pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static function doAjax(){
$taskPlaner = new Model\InvoiceTask();
$result = $taskPlaner->payment_reminder();
} else if(!empty($_POST['recurr'])) {
if(!empty(WPISPConfig3::$OPTIONS['wc_recur_test'])) {
if(!empty(self::$OPTIONS['wc_recur_test'])) {
$taskPlaner = new Model\InvoiceTask();
$result = $taskPlaner->payment_recur();
} else
Expand Down

0 comments on commit 0cf373b

Please sign in to comment.