Exemplo n.º 1
0
 public function show($id)
 {
     $payroll = Payroll::findOrFail($id);
     $curr_month = (int) date('m', strtotime($payroll->release_date));
     $curr_year = (int) date('Y', strtotime($payroll->release_date));
     $curr_month = $curr_month - 1;
     if ($curr_month == 0) {
         $curr_month = 12;
         $curr_year = $curr_year - 1;
     }
     $employee = Employee::find($payroll->employee_id);
     $incomes = Income::where('employee_id', '=', $employee->id)->where(DB::raw('year(release_date)'), '=', $curr_year)->where(DB::raw('month(release_date)'), '=', $curr_month)->get();
     $deductions = Deduction::where('employee_id', '=', $employee->id)->where(DB::raw('year(release_date)'), '=', $curr_year)->where(DB::raw('month(release_date)'), '=', $curr_month)->get();
     $teaches = Teach::where('employee_id', '=', $employee->id)->where(DB::raw('year(course_date)'), '=', $curr_year)->where(DB::raw('month(course_date)'), '=', $curr_month)->count();
     $menu = 'employee';
     return View::make('payrolls.show', compact('payroll', 'employee', 'incomes', 'deductions', 'teaches', 'curr_year', 'curr_month', 'menu'));
 }
Exemplo n.º 2
0
 public function getIncome()
 {
     return Income::model()->findAllBySql("select income.* from income \nleft join check_income\n   on check_income.id = income.check_id\nwhere (class_id = :cid and student_id = :sid)\nand (check_income.returned is null or check_income.returned < '2000-01-01')", array('cid' => $this->class_id, 'sid' => $this->student_id));
 }
Exemplo n.º 3
0
/**
 * Generate income fields and populate it with existing data
 */
function getIncomeEntries()
{
    global $incomeTypes;
    global $incomes;
    global $incomeEntries;
    global $inputErrors;
    $result = "";
    $incomeIndex = 0;
    $numEntries = $inputErrors ? count($incomeEntries) : count($incomes);
    do {
        $result .= '<div class="incomeEntry"> ';
        $result .= '<label for="incomeDesc' . $incomeIndex . '" class="altDescLabel">Description: </label>';
        $result .= '<input type="text" id="incomeDesc' . $incomeIndex . '" name="incomeDesc' . $incomeIndex . '" class="desc';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            if ($incomeEntries[$incomeIndex]["descError"]) {
                $result .= ' descError';
            }
        }
        $result .= '" placeholder="Description" maxlength="' . Income::MAX_DESC_LENGTH . '"';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            $result .= ' value="';
            $result .= htmlentities($incomeEntries[$incomeIndex]["desc"]);
            $result .= '"';
        } else {
            if (isset($incomes[$incomeIndex])) {
                $result .= ' value="';
                $result .= htmlentities($incomes[$incomeIndex]->description);
                $result .= '"';
            }
        }
        $result .= '> ';
        $result .= '<label for="incomeType' . $incomeIndex . '" class="altTypeLabel">Category: </label>';
        $result .= '<select id="incomeType' . $incomeIndex . '" name="incomeType' . $incomeIndex . '" class="type';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            if ($incomeEntries[$incomeIndex]["typeError"]) {
                $result .= ' typeError';
            }
        }
        $result .= '"> ';
        foreach ($incomeTypes as $incomeType) {
            $result .= '<option value="' . $incomeType->category . '"';
            if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
                if ($incomeEntries[$incomeIndex]["type"] === $incomeType->category) {
                    $result .= "selected";
                }
            } else {
                if (isset($incomes[$incomeIndex])) {
                    if ($incomes[$incomeIndex]->typeID === $incomeType->id) {
                        $result .= "selected";
                    }
                }
            }
            $result .= '>';
            $result .= $incomeType->category;
            $result .= '</option> ';
        }
        $result .= '</select> ';
        $result .= '<label for="incomeAmount' . $incomeIndex . '" class="altAmountLabel">Amount: </label>';
        $result .= '<input type="text" maxlength="20" id="incomeAmount' . $incomeIndex . '" name="incomeAmount' . $incomeIndex . '" class="amount';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            if ($incomeEntries[$incomeIndex]["amountError"]) {
                $result .= ' amountError';
            }
        }
        $result .= '" placeholder="Amount"';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            $result .= ' value="';
            $result .= htmlentities($incomeEntries[$incomeIndex]["amount"]);
            $result .= '"';
        } else {
            if (isset($incomes[$incomeIndex])) {
                $result .= ' value="';
                $result .= htmlentities(Income::formatDisplayAmount($incomes[$incomeIndex]->amount));
                $result .= '"';
            }
        }
        $result .= '> ';
        $result .= '<label class="removeLabel">Remove: </label>';
        $result .= '<button type="button" id="deleteIncomeButton' . $incomeIndex . '" name="deleteIncomeButton' . $incomeIndex . '" class="deleteButton" title="Delete"> ';
        $result .= '&#10006;';
        $result .= '</button> ';
        $result .= '<br> ';
        $result .= '</div> ';
        $incomeIndex++;
    } while ($incomeIndex < $numEntries);
    return $result;
}
Exemplo n.º 4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['student_id']) && isset($_GET['check_id']) && isset($_GET['class_id'])) {
             // XXX this is stupid and tedious. fix.
             $this->_model = Income::model()->findbyPk(array('student_id' => $_GET['student_id'], 'check_id' => $_GET['check_id'], 'class_id' => $_GET['class_id']));
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Exemplo n.º 5
0
<script type="text/javascript">
    var totalIncome = <?php 
echo htmlentities($totalIncome);
?>
;
    var totalExpenses = <?php 
echo htmlentities($totalExpenses);
?>
;
    var totalIncomeDisplayString = "<?php 
echo htmlentities(Income::formatDisplayAmount($totalIncome));
?>
";
    var totalExpensesDisplayString = "<?php 
echo htmlentities(Expense::formatDisplayAmount($totalExpenses));
?>
";
    var totalTitle = "Income/Expenses";
    var incomeTitle = "Income";
    var expensesTitle = "Expenses";

    var totalChartArray = [<?php 
echo '["Type", "Amount"], ["Income", totalIncome], ["Expenses", totalExpenses]';
?>
];
    var incomeChartArray = [["Category", "Amount"],
        <?php 
foreach ($incomeTypeAmounts as $index => $incomeTypeAmount) {
    echo "['" . htmlentities($incomeTypeAmount["type"]) . "', " . htmlentities($incomeTypeAmount["amount"]) . "]";
    if ($index !== count($incomeTypeAmounts) - 1) {
        echo ", ";
Exemplo n.º 6
0
        <th>Expenses</th>
        <th>Net</th>
    </tr>
    <?php 
for ($ii = 1; $ii <= $daysInSelectedMonth; $ii++) {
    ?>
        <tr>
            <td><a href="<?php 
    echo BASE_URL . "main/?month={$selectedMonth}&day={$ii}&year={$selectedYear}";
    ?>
"><?php 
    echo $selectedMonthName . " " . $ii;
    ?>
</a></td>
            <td><?php 
    echo htmlentities(Income::formatDisplayAmount($incomeEachDay[$ii - 1]));
    ?>
</td>
            <td><?php 
    echo htmlentities(Expense::formatDisplayAmount($expenseEachDay[$ii - 1]));
    ?>
</td>
            <td><?php 
    echo htmlentities(IncomeExpenseObject::formatDisplayAmount($totalEachDay[$ii - 1]));
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>
Exemplo n.º 7
0
 public function destroy($id)
 {
     Income::destroy($id);
     Session::flash('message', 'Sukses menghapus Income Payroll!!');
 }
Exemplo n.º 8
0
     $income = array_pop($incomes);
     $income->delete();
 }
 for ($ii = 0; $ii < $numIncomeEntries; $ii++) {
     if ($ii <= $numIncomeUpdates - 1) {
         // update existing income entry if it has changed
         $income = $incomes[$ii];
         if ($incomeEntries[$ii]["desc"] !== $income->description || intval($incomeEntries[$ii]["typeID"]) !== intval($income->typeID) || floatval($incomeEntries[$ii]["amount"]) !== floatval($income->amount)) {
             $income->description = $incomeEntries[$ii]["desc"];
             $income->amount = Income::formatAmount($incomeEntries[$ii]["amount"]);
             $income->typeID = $incomeEntries[$ii]["typeID"];
             $income->save(array("amount", "description", "typeID"));
         }
     } else {
         // insert new income entry
         $income = new Income();
         $income->userID = $user->id;
         $income->amount = Income::formatAmount($incomeEntries[$ii]["amount"]);
         $income->date = $mySqlFormatedDate;
         $income->description = $incomeEntries[$ii]["desc"];
         $income->typeID = $incomeEntries[$ii]["typeID"];
         $income->save();
     }
 }
 for ($ii = 0; $ii < $numExpenseDeletes; $ii++) {
     $expense = array_pop($expenses);
     $expense->delete();
 }
 for ($ii = 0; $ii < $numExpenseEntries; $ii++) {
     if ($ii <= $numExpenseUpdates - 1) {
         // update existing expense entry if it has changed
Exemplo n.º 9
0
 public function addIncome($id, $date, $amount, $type, $description)
 {
     $newIncome = new Income($id, $date, $amount, $type, $description);
     $this->inc[$newIncome->getOperationId()] = $newIncome;
 }
Exemplo n.º 10
0
<h3>Income</h3>
<table id="incomeSummaryTable">
    <tr>
        <th>Category</th>
        <th>Total</th>
    </tr>
    <?php 
foreach ($incomeTypeAmounts as $incomeTypeAmount) {
    ?>
        <tr>
            <td><?php 
    echo htmlentities($incomeTypeAmount["type"]);
    ?>
</td>
            <td><?php 
    echo htmlentities(Income::formatDisplayAmount($incomeTypeAmount["amount"]));
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>
<div id="incomeChart"></div>

<h3>Expenses</h3>
<table id="expensesSummaryTable">
    <tr>
        <th>Category</th>
        <th>Total</th>
    </tr>
Exemplo n.º 11
0
 function getIncomes()
 {
     return Income::model()->findAllBySql("select income.*\nfrom income\nleft join check_income \n   on income.check_id = check_income.id\nwhere check_income.payee_id = :id\n  and check_income.session_id = :sid\norder by abs(check_income.check_num) asc", array('id' => $this->id, 'sid' => ClassSession::savedSessionId()));
 }
Exemplo n.º 12
0
<?php

$user = User::findById($session->userID);
$incomeTypes = IncomeType::findBySql('SELECT * FROM incometypes WHERE userID = "' . $user->id . '" ORDER BY id');
$expenseTypes = ExpenseType::findBySql('SELECT * FROM expensetypes WHERE userID = "' . $user->id . '" ORDER BY id');
// Fetch income and expense data based on the current view
if ($view === "daily") {
    $incomes = Income::findBySql('SELECT * FROM incomes WHERE userID = "' . $user->id . '" AND date = "' . $mySqlFormatedDate . '" ORDER BY id');
    $expenses = Expense::findBySql('SELECT * FROM expenses WHERE userID = "' . $user->id . '" AND date = "' . $mySqlFormatedDate . '" ORDER BY id');
} else {
    if ($view === "monthly" || $view === "yearly") {
        $incomes = Income::findBySql('SELECT * FROM incomes WHERE userID = "' . $user->id . '" AND date BETWEEN "' . $mySqlFormatedDateStart . '" AND "' . $mySqlFormatedDateEnd . '"');
        $expenses = Expense::findBySql('SELECT * FROM expenses WHERE userID = "' . $user->id . '" AND date BETWEEN "' . $mySqlFormatedDateStart . '" AND "' . $mySqlFormatedDateEnd . '"');
    } else {
        if ($view === "allTime") {
            $incomes = Income::findBySql('SELECT * FROM incomes WHERE userID = "' . $user->id . '" ORDER BY date');
            $expenses = Expense::findBySql('SELECT * FROM expenses WHERE userID = "' . $user->id . '" ORDER BY date');
        }
    }
}
Exemplo n.º 13
0
        <th>Expenses</th>
        <th>Net</th>
    </tr>
    <?php 
for ($ii = $firstYear; $ii <= $lastYear; $ii++) {
    ?>
        <tr>
            <td><a href="<?php 
    echo BASE_URL . "main/?view=yearly&year={$ii}";
    ?>
"><?php 
    echo $ii;
    ?>
</a></td>
            <td><?php 
    echo htmlentities(Income::formatDisplayAmount($incomeEachYear[$ii]));
    ?>
</td>
            <td><?php 
    echo htmlentities(Expense::formatDisplayAmount($expenseEachYear[$ii]));
    ?>
</td>
            <td><?php 
    echo htmlentities(IncomeExpenseObject::formatDisplayAmount($totalEachYear[$ii]));
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>
Exemplo n.º 14
0
 public function getIncomes()
 {
     return Income::model()->findAllBySql('select income.* 
           from income
           left join class_info
            on income.class_id = class_info.id
           where income.student_id = :stid
             and class_info.session_id = :ssid', array('ssid' => ClassSession::savedSessionId(), 'stid' => $this->id));
 }