Beispiel #1
0
 function read_prefs()
 {
     if (!isset($this->preference)) {
         $preference_factory = new Preference();
         $preferences = $preference_factory->find_all();
         $this->preference = $preferences[0];
     }
 }
 function index()
 {
     if ($this->request->is_post()) {
         $preference = new Preference($_POST);
         $preference->save();
     }
     $preference_factory = new Preference();
     $preferences = $preference_factory->find_all();
     $this->preference = $preferences[0];
 }
Beispiel #3
0
#!/usr/bin/php
<?php 
ini_set('max_execution_time', 3000);
require_once dirname(__FILE__) . "/lib.inc.php";
require_once dirname(__FILE__) . "/../include/db.inc.php";
require_once dirname(__FILE__) . "/../include/" . DB_ADAPTER . "_adapter.php";
require_once dirname(__FILE__) . "/../models/preference.php";
require_once dirname(__FILE__) . "/../models/bond.php";
require_once dirname(__FILE__) . "/../models/cedola.php";
date_default_timezone_set('Europe/Rome');
echo "Reading preferences...";
$preference_factory = new Preference();
$preferences = $preference_factory->find_all()[0];
// print_r($preferences);
echo "done\n";
function populate_cedole()
{
    $bond_factory = new Bond();
    $today = date('Y-m-d');
    // $bonds = $bond_factory->find_all(array('where_clause' => "`stacco` != '0000-00-00' AND `cadenza` > 0 AND `scadenza` > '{$today}'"));
    $bonds = $bond_factory->find_all(array('where_clause' => "`cadenza` > 0 AND `scadenza` > '{$today}'"));
    // print_r($bonds);
    foreach ($bonds as $bond) {
        if ($bond->stacco != '0000-00-00') {
            $s = strtotime($bond->stacco);
            $k = 1;
        } else {
            $s = strtotime($bond->scadenza);
            $k = -1;
        }
        $d = $today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));