Example #1
0
 public function api_load_times()
 {
     /*Initialize the Mite API connector class*/
     $mite = new Mite\Mite(MITE_SUB, MITE_KEY);
     /*Get your own userID*/
     $userID = $mite->getMyself()->id;
     $stepper = array('a' => 0, 'u' => 0);
     /*Get all times which belong to me*/
     $e = $mite->getTimes(array(), array(), array(), array($userID), null, false, false, false, false, null, MITE_TIMES, false);
     for ($e->rewind(); $e->valid(); $e->next()) {
         $entry = $e->current();
         /*MAP ALL TIMES WITH WORKTIME*/
         if ($entry->minutes > 0) {
             $time = Time::find(array('conditions' => array('project_name = ? AND service_name = ? AND minutes = ? AND created = ?', $entry->project_name, $entry->service_name, $entry->minutes, strtotime($entry->date_at))));
             if (!$time) {
                 $save = Time::create(array('project_name' => $entry->project_name, 'service_name' => $entry->service_name, 'minutes' => $entry->minutes, 'created' => strtotime($entry->date_at)));
                 $stepper['a']++;
             } else {
                 $time->project_name = $entry->project_name;
                 $time->service_name = $entry->service_name;
                 $time->minutes = $entry->minutes;
                 $time->created = strtotime($entry->date_at);
                 $time->save();
                 $stepper['u']++;
             }
         }
         unset($entry);
     }
     /*Status*/
     echo "\t\t\t" . $stepper['a'] . " entries " . ($stepper['a'] > 1 ? 'have' : 'has') . " been added...\n";
     echo "\t\t\t" . $stepper['u'] . " entries " . ($stepper['u'] > 1 ? 'have' : 'has') . " been updated...\n";
 }
Example #2
0
<?php

// check input params
$endpoint = $_POST['api_endpoint'];
$key = $_POST['api_key'];
if (!isset($endpoint) || empty($endpoint) || !isset($key) || empty($key)) {
    die('Please provide your api credentials!');
}
require_once '../Mite/Mite.php';
$mite = new Mite\Mite($endpoint, $key);
function outputKeyVal($o)
{
    echo "<table><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody>";
    foreach ($o as $k => $v) {
        echo "<tr><td>{$k}</td><td>";
        if (is_object($v)) {
            outputKeyVal($v);
        } else {
            echo $v;
        }
        echo "</td></tr>";
    }
    echo "</tbody></table>";
}
try {
    switch ($_POST['method']) {
        case 'account':
            $acc = $mite->getAccount();
            outputKeyVal($acc);
            break;
        case 'customers':