$headerInclude = "reports"; $periodhead = "Ledgers"; $display_stat_wait = true; include 'includes/header.php'; if (!$_REQUEST['InvoiceID']) { dieLog('No Invoice Selected', 'No Invoice Selected'); } $RF = new rates_fees(); $Payouts = $RF->get_payouts(array('pa_ID' => intval($_REQUEST['InvoiceID'])), $curUserInfo['en_ID']); if ($Payouts['status'] === false) { dieLog($Payouts['msg'], $Payouts['msg']); } $Payouts = array('InvoiceInfo' => array_pop($Payouts)); $time = strtotime($Payouts['InvoiceInfo']['pa_date']); $Payouts['ThisPeriodEnd'] = date('Y-m-d', $time); $Payouts['LastPeriodEnd'] = en_get_payout_period($curUserInfo, 'last', $time); $Payouts['ThisPeriodStart'] = date('Y-m-d', strtotime($Payouts['LastPeriodEnd']) + 60 * 60 * 24); $Payouts['InvoiceProfit'] = $RF->get_profit(array('EffectiveOnly' => false, 'hidepayout' => true, 'date_between' => array('Start' => $Payouts['ThisPeriodStart'], 'End' => $Payouts['ThisPeriodEnd'])), $curUserInfo['en_ID']); //etelPrint($Payouts['InvoiceProfit']); $Payouts['PreviousProfit'] = $RF->get_profit(array('EffectiveOnly' => false, 'hidepayout' => true, 'date_between' => array('Start' => '2000-01-01', 'End' => $Payouts['LastPeriodEnd'])), $curUserInfo['en_ID']); foreach ($Payouts['InvoiceProfit']['Revenue'] as $key => $type) { $Payouts['InvoiceProfit']['Revenue'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=" . $Payouts['ThisPeriodStart'] . "&frm_pt_pt_date_effective_to=" . $Payouts['ThisPeriodEnd'] . ""; } foreach ($Payouts['InvoiceProfit']['Deductions'] as $key => $type) { $Payouts['InvoiceProfit']['Deductions'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=" . $Payouts['ThisPeriodStart'] . "&frm_pt_pt_date_effective_to=" . $Payouts['ThisPeriodEnd'] . ""; } foreach ($Payouts['PreviousProfit']['Revenue'] as $key => $type) { $Payouts['PreviousProfit']['Revenue'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=2000-01-01&frm_pt_pt_date_effective_to=" . $Payouts['LastPeriodEnd'] . ""; } foreach ($Payouts['PreviousProfit']['Deductions'] as $key => $type) { $Payouts['PreviousProfit']['Deductions'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=2000-01-01&frm_pt_pt_date_effective_to=" . $Payouts['LastPeriodEnd'] . "";
function en_get_payout_schedule(&$entityInfo) { $week_replace = array('0' => 'Sunday', '1' => 'Monday', '2' => 'Tuesday', '3' => 'Wednesday', '4' => 'Thursday', '5' => 'Friday', '6' => 'Saturday'); $bin = strrev(decbin($entityInfo['en_pay_data'])); for ($i = 0; $i <= 28; $i++) { $binarray[$i] = substr($bin, $i, 1); } if ($entityInfo['en_pay_type'] == 'Weekly') { foreach ($binarray as $key => $val) { if ($key >= 0 && $key <= 6 && $val && $week_replace[$key]) { $days .= (isset($days) ? ", " : '') . $week_replace[$key] . 's'; } } } if ($entityInfo['en_pay_type'] == 'Monthly') { foreach ($binarray as $key => $val) { if ($key > 0 && $key <= 28 && $val) { $days .= (isset($days) ? ", " : '') . $key . date('S', strtotime('2000-01-' . $key)); } } } $return['DayArray'] = $binarray; $return['Days'] = $days; if (strrpos($return['Days'], ',')) { $return['Days'] = substr_replace($return['Days'], " and", strrpos($return['Days'], ','), 1); } $return['Schedule'] = "* Pay Days are " . $entityInfo['en_pay_type'] . " on " . $return['Days']; $return['NextPayDay'] = en_get_payout_period($entityInfo); $return['LastPayDay'] = en_get_payout_period($entityInfo, 'last'); return $return; }