Ejemplo n.º 1
0
 public function action_entry()
 {
     // Set employees node
     $employees_node = $this->xml_content->appendChild($this->dom->createElement('employees'));
     $employees = array('0option' => array('@value' => '0', 'None'));
     $counter = 1;
     foreach (Employees::get() as $employee) {
         $employees[$counter . 'option'] = array('@value' => $employee['id'], $employee['lastname'] . ', ' . $employee['firstname']);
         $counter++;
     }
     xml::to_XML($employees, $employees_node);
     // This is for the select box
     if (count($_POST)) {
         $post = new Validation($_POST);
         $post->filter('trim');
         $post->filter('floatval', 'sum');
         $post->filter('floatval', 'vat');
         $post->rule('strtotime', 'accounting_date');
         $post->rule('strtotime', 'transfer_date');
         $post->rule('Valid::not_empty', 'description');
         if ($post->Validate()) {
             $new_transaction_data = array('accounting_date' => $post->get('accounting_date'), 'transfer_date' => $post->get('transfer_date'), 'description' => $post->get('description'), 'journal_id' => $post->get('journal_id'), 'vat' => $post->get('vat'), 'sum' => $post->get('sum'), 'employee_id' => $post->get('employee_id'));
             if (!isset($_GET['id'])) {
                 $transaction = new Transaction(NULL, $new_transaction_data);
                 $this->add_message('Transaction ' . $transaction->get_id() . ' added');
             } else {
                 $transaction = new Transaction($_GET['id']);
                 $transaction->set($new_transaction_data);
                 $this->add_message('Transaction ' . $transaction->get_id() . ' updated');
                 $this->set_formdata($transaction->get());
             }
         } else {
             $this->add_form_errors($post->errors());
             $this->set_formdata($post->as_array());
         }
     } elseif (isset($_GET['id'])) {
         $transaction = new Transaction($_GET['id']);
         $this->set_formdata($transaction->get());
     } else {
         $this->set_formdata(array('accounting_date' => date('Y-m-d', time()), 'transfer_date' => date('Y-m-d', time())));
     }
 }
Ejemplo n.º 2
0
 public function action_index()
 {
     $employees_node = $this->xml_content->appendChild($this->dom->createElement('employees'));
     xml::to_XML(Employees::get(), $employees_node, 'employee', 'id');
 }
Ejemplo n.º 3
0
 public function action_payout()
 {
     // Set employees node
     $employees_node = $this->xml_content->appendChild($this->dom->createElement('employees'));
     $employees = array();
     $counter = 0;
     $employees_from_model = Employees::get();
     foreach ($employees_from_model as $employee) {
         $employees[$counter . 'option'] = array('@value' => $employee['id'], $employee['lastname'] . ', ' . $employee['firstname']);
         $counter++;
     }
     xml::to_XML($employees, $employees_node);
     // This is for the select box
     xml::to_XML($employees_from_model, $employees_node, 'employee', 'id');
     if (isset($_GET['id'])) {
         if (count($_POST)) {
             $post = new Validation($_POST);
             $post->filter('trim');
             $salary->set($post->as_array());
         }
         $this->set_formdata($salary->get());
         xml::to_XML(array('statuses' => array('1option' => array('@value' => 'active', 'Active'), '2option' => array('@value' => 'inactive', 'Inactive'))), $this->xml_content);
         xml::to_XML($employee->get(), $this->xml_content->appendChild($this->dom->createElement('employee')), NULL, 'id');
         $this->add_message('Employee ' . $_GET['id'] . ' information updated');
     } elseif (count($_POST)) {
         // Add new payout
         $post = new Validation($_POST);
         $post->filter('trim');
         $post->rule('Valid::digit', 'amount');
         $post->rule('strtotime', 'date');
         if ($post->validate()) {
             $post_array = $post->as_array();
             $transaction_data = array('accounting_date' => date('Y-m-d', strtotime($post_array['date'])), 'transfer_date' => date('Y-m-d', strtotime($post_array['date'])), 'description' => 'Salary payout', 'journal_id' => NULL, 'vat' => 0, 'sum' => -$post_array['amount'], 'employee_id' => $post_array['employee_id']);
             $transaction = new Transaction(NULL, $transaction_data);
             if ($id = $transaction->get_id()) {
                 $this->add_message('New transaction added (ID ' . $id . ')');
             } else {
                 $this->add_error('Something f****d up');
             }
         } else {
             $this->set_formdata($post->as_array());
             $errors = $post->errors();
             $this->add_form_errors($errors);
             if (isset($errors['date'])) {
                 $this->add_form_errors(array('date' => 'Invalid date format'));
             }
             if (isset($errors['amount'])) {
                 $this->add_form_errors(array('amount' => 'Must be numbers ONLY'));
             }
         }
     }
 }
Ejemplo n.º 4
0
<?php

require_once 'includes/session.php';
//Imports
require_once 'includes/db.php';
require_once 'includes/User.php';
require_once 'includes/Employee.php';
$con = connect_db();
$employees = new Employees();
$employees->get($con);
$con->close();
?>

<!DOCTYPE html>
<html>
<head>
	<title>Vehicle Checklist</title>
	
	<meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
	
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
	<link href="css/style.css" rel="stylesheet" />	

	<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
	<script src="js/script.js" defer="defer"></script>
</head>
<body>
	<?php