本文整理汇总了PHP中invoice::recur方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::recur方法的具体用法?PHP invoice::recur怎么用?PHP invoice::recur使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invoice
的用法示例。
在下文中一共展示了invoice::recur方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
global $db;
$today = date('Y-m-d');
$cron = new cron();
$data = $cron->select_crons_to_run();
$return['cron_message'] = "Cron started";
$number_of_crons_run = "0";
$cron_log = new cronlog();
$cron_log->run_date = $today;
foreach ($data as $key => $value) {
$cron->domain_id = $value['domain_id'];
$cron_log->cron_id = $value['id'];
$cron_log->domain_id = $domain_id = $value['domain_id'];
$check_cron_log = $cron_log->check();
$i = "0";
if ($check_cron_log == 0) {
//only proceed if cron has not been run for today
$run_cron = false;
$start_date = date('Y-m-d', strtotime($value['start_date']));
$end_date = $value['end_date'];
// Seconds in a day = 60 * 60 * 24 = 86400
$diff = number_format((strtotime($today) - strtotime($start_date)) / 86400, 0);
//only check if diff is positive
if ($diff >= 0 and ($end_date == "" or $end_date >= $today)) {
if ($value['recurrence_type'] == 'day') {
$modulus = $diff % $value['recurrence'];
if ($modulus == 0) {
$run_cron = true;
} else {
#$return .= "cron does not runs TODAY-days";
}
}
if ($value['recurrence_type'] == 'week') {
$period = 7 * $value['recurrence'];
$modulus = $diff % $period;
if ($modulus == 0) {
$run_cron = true;
} else {
#$return .= "cron is not runs TODAY-week";
}
}
if ($value['recurrence_type'] == 'month') {
$start_day = date('d', strtotime($value['start_date']));
$start_month = date('m', strtotime($value['start_date']));
$start_year = date('Y', strtotime($value['start_date']));
$today_day = date('d');
$today_month = date('m');
$today_year = date('Y');
$months = $today_month - $start_month + 12 * ($today_year - $start_year);
$modulus = $months % $value['recurrence'];
if ($modulus == 0 and $start_day == $today_day) {
$run_cron = true;
} else {
#$return .= "cron is not runs TODAY-month";
}
}
if ($value['recurrence_type'] == 'year') {
$start_day = date('d', strtotime($value['start_date']));
$start_month = date('m', strtotime($value['start_date']));
$start_year = date('Y', strtotime($value['start_date']));
$today_day = date('d');
$today_month = date('m');
$today_year = date('Y');
$years = $today_year - $start_year;
$modulus = $years % $value['recurrence'];
if ($modulus == 0 and $start_day == $today_day and $start_month == $today_month) {
$run_cron = true;
} else {
#$return .= "cron is not runs TODAY-year";
}
}
//run the recurrence for this invoice
if ($run_cron) {
$number_of_crons_run++;
$return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " was run today :: Info diff=" . $diff;
$i++;
$ni = new invoice();
$ni->id = $value['invoice_id'];
$ni->domain_id = $domain_id;
// $domain_id gets propagated from invoice to be copied from
$new_invoice_id = $ni->recur();
//insert into cron_log date of run
//$cron_log = new cronlog();
//$cron_log->run_date = $today;
//$cron_log->domain_id = $domain_id;
//$cron_log->cron_id = $value['cron_id'];
$cron_log->insert();
## email the people
$invoiceobj = new invoice();
$invoice = $invoiceobj->select($new_invoice_id, $domain_id);
$preference = getPreference($invoice['preference_id'], $domain_id);
$biller = getBiller($invoice['biller_id'], $domain_id);
$customer = getCustomer($invoice['customer_id'], $domain_id);
#print_r($customer);
#create PDF nameVj
$spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
$pdf_file_name_invoice = $spc2us_pref . ".pdf";
// email invoice
if ($value['email_biller'] == "1" or $value['email_customer'] == "1") {
//.........这里部分代码省略.........
示例2: invoice
<?php
$ni = new invoice();
$ni->id = $_GET['id'];
$ni->recur();