function __construct() { $this->dataFile = "chart"; parent::__construct(); $this->bps = BPS::getAllProperties("StatistikControllingGUI"); $D1 = new Datum(time()); $D1->setToJan1st(date("Y")); $D2 = new Datum(time()); $D2->setToJan1st(date("Y") + 1); $D2->subDay(); $this->startDatum = isset($this->bps["start"]) ? $this->bps["start"] : Util::CLFormatDate($D1->time()); $this->endDatum = isset($this->bps["ende"]) ? $this->bps["ende"] : Util::CLFormatDate($D2->time()); $this->mK = null; }
public static function stamp($args, $die = true) { #if(strtolower($args["P0"]) == "303005f7b4") # die('{"status":"command", "action":"reload"}'); if (!isset($_SESSION["BPS"])) { $_SESSION["BPS"] = new BackgroundPluginState(); } addClassPath(Util::getRootPath() . "personalKartei/Zeiterfassung/"); addClassPath(Util::getRootPath() . "personalKartei/Personal/"); addClassPath(Util::getRootPath() . "personalKartei/ObjekteL/"); #if(file_exists(Util::getRootPath()."personalKartei/Schichten/")) # addClassPath(Util::getRootPath()."personalKartei/Schichten/"); addClassPath(Util::getRootPath() . "open3A/Kategorien/"); $CCP = new CCPage(); $CCP->loadPlugin("personalKartei", "Schichten", true); $T = anyC::getFirst("ZETerminal", "ZETerminalID", $args["P1"]); if (!$T) { if ($die) { die('{"status":"error", "message":"Unbekanntes Terminal"}'); } else { return; } } $CT = FileStorage::getFilesDir() . "ChipTrans.csv"; if ($args["P3"] and $args["P4"] > 0) { $P = new Personal($args["P4"]); if (trim($P->A("PersonalChipNummer")) == "") { $P->changeA("PersonalChipNummer", trim(strtolower($args["P0"]))); $P->saveMe(); } else { file_put_contents($CT, "{$args['P4']}:" . trim(strtolower($args["P0"])) . "\n", FILE_APPEND); } } $A = new stdClass(); $Date = new Datum(); $Date->subDay(); $Date->addDay(); $A->ChipID = trim(strtolower($args["P0"])); $A->Date = $Date->time(); $A->Time = Util::parseTime("de_DE", date("H:i", !isset($args["P5"]) ? time() : $args["P5"])); $A->Type = $args["P2"]; $A->Mode = ""; $A->TerminalID = $args["P1"]; try { $ok = ZEData::addTime($A); } catch (Exception $e) { try { $hex = str_pad(trim(strtolower(dechex($args["P0"]))), 10, "0", STR_PAD_LEFT); $A->ChipID = $hex; $ok = ZEData::addTime($A); } catch (Exception $e) { try { if (!$args["P3"]) { throw new Exception("Chip unknown", 100); } if (!file_exists($CT)) { file_put_contents($CT, ""); } $trans = file_get_contents($CT); $found = false; foreach (explode("\n", $trans) as $line) { $line = trim($line); $ex = explode(":", $line); if (trim(strtolower($ex[1])) != trim(strtolower($args["P0"]))) { continue; } $P = new Personal($ex[0]); $A->ChipID = $P->A("PersonalChipNummer"); $found = true; } if (!$found) { throw new Exception("Learn", 200); } #if(!$found) # throw new Exception ("Chip unknown", 100); $ok = ZEData::addTime($A); } catch (Exception $e) { switch ($e->getCode()) { case 100: try { $F = new Factory("ZETerminalFail"); $F->sA("ZETerminalFailTime", time()); $F->sA("ZETerminalFailData", json_encode($args)); $F->sA("ZETerminalFailZETerminalID", $args["P1"]); $F->store(); } catch (Exception $e) { } if ($die) { die('{"status":"error", "message":"Unbekannter Chip"}'); } else { return; } break; case 200: $AC = anyC::get("Personal", "isDeleted", "0"); $AC->setFieldsV3(array("CONCAT(nachname, ' ', vorname) AS name")); $AC->addAssocV3("TRIM(CONCAT(nachname, vorname))", "!=", ""); $AC->addOrderV3("nachname"); $AC->addOrderV3("vorname"); $knownPID = array(); $file = file($CT); foreach ($file as $line) { $line = trim($line); $ex = explode(":", $line); $knownPID[$ex[0]] = true; } $array = array(); while ($A = $AC->n()) { if (isset($knownPID[$A->getID()])) { continue; } $subArray = array(); foreach ($A->getA() as $key => $value) { $subArray[$key] = $value; } $array[] = $subArray; } if ($die) { die('{"status":"learn", "message":' . json_encode($array, defined("JSON_UNESCAPED_UNICODE") ? JSON_UNESCAPED_UNICODE : 0) . '}'); } else { return; } break; default: try { $F = new Factory("ZETerminalFail"); $F->sA("ZETerminalFailTime", time()); $F->sA("ZETerminalFailData", $e->getMessage()); $F->sA("ZETerminalFailZETerminalID", $args["P1"]); $F->store(); } catch (Exception $e) { } if ($die) { die('{"status":"error", "message":"' . $e->getMessage() . '"}'); } else { return; } } } } } if ($args["P2"] == "G") { $AC = anyC::get("ZEData", "ZEDataPersonalID", $ok["Personal"]->getID()); $AC->addAssocV3("ZEDataType", "=", "K"); $AC->addAssocV3("ZEDataDate + ZEDataTime", ">", time() - 3600 * 13); $AC->addAssocV3("ZEDataDate + ZEDataTime", "<", time()); $AC->addAssocV3("ZEDataIsDeleted", "=", "0"); $AC->addOrderV3("ZEDataDate + ZEDataTime", "DESC"); $AC->setLimitV3("1"); $Kommen = $AC->getNextEntry(); if ($Kommen != null) { $Gehen = $ok["ZEData"]; $T = new ZETerminal($args["P1"]); $AC2 = anyC::get("PZuO", "ObjektLID", $T->A("ZETerminalObjektLID")); $AC2->addAssocV3("PersonalID", "=", $Kommen->A("ZEDataPersonalID")); $PZuO = $AC2->n(); if ($PZuO !== null) { $worked = $Gehen->A("ZEDataDate") + $Gehen->A("ZEDataTime") - ($Kommen->A("ZEDataDate") + $Kommen->A("ZEDataTime")); $AZ = mZEArbeitsZeit::getArbeitszeiten($PZuO->getID(), time()); if (isset($AZ[0])) { $hasTo = $AZ[0]->A("ZEArbeitsZeitEnde") - $AZ[0]->A("ZEArbeitsZeitStart"); if ($worked > 0 and $worked / $hasTo > 0.9) { # AND $hasTo / $worked < 1.15){ $DE = $ok["ZEData"]; $DE->changeA("ZEDataPause", $AZ[0]->A("ZEArbeitsZeitMittag")); $DE->saveMe(false, false); } } } } } #303046a1b7 BPS::setProperty("ZEAuswertung", "objektLID", $T->A("ZETerminalObjektLID")); BPS::setProperty("ZEAuswertung", "personalID", $ok["Personal"]->getID()); BPS::setProperty("ZEAuswertung", "month", date("Ym")); #$ZEA = new ZEAuswertung($A->ChipID); #$ZEA->debug = false; #$current = $ZEA->getContent(); if ($die) { die('{"status":"OK", "message": "' . addslashes($ok["Personal"]->A("vorname") . " " . $ok["Personal"]->A("nachname")) . '", "details": ""}'); } else { return; } }
function __construct() { if ($this->ansicht == null) { $this->ansicht = "monat"; } $display = mUserdata::getUDValueS("KalenderDisplay" . ucfirst($this->ansicht), "0"); switch ($this->ansicht) { case "jahr": $Date = new Datum(Datum::parseGerDate("1.1." . date("Y"))); for ($i = 0; $i < abs($display); $i++) { if ($display > 0) { $Date->addYear(); } else { $Date->subYear(); } } break; case "monat": $Date = new Datum(Datum::parseGerDate("1." . date("m.Y"))); for ($i = 0; $i < abs($display); $i++) { if ($display > 0) { $Date->addMonth(); } else { $Date->subMonth(); } } break; case "woche": $Date = new Datum(Datum::parseGerDate(date("d.m.Y"))); for ($i = 0; $i < abs($display); $i++) { if ($display > 0) { $Date->addWeek(true); } else { $Date->subWeek(); } } break; case "tag": $Date = new Datum(Datum::parseGerDate(date("d.m.Y"))); for ($i = 0; $i < abs($display); $i++) { if ($display > 0) { $Date->addDay(); } else { $Date->subDay(); } } break; } $this->current = clone $Date; if ($this->ansicht != "tag" and $this->ansicht != "jahr") { while (date("w", $Date->time()) > 1) { $Date->subDay(); } if (date("w", $Date->time()) == 0) { $Date->addDay(); } } $this->date = $Date; $this->first = $Date->time(); $D = clone $Date; $rows = 5; if ($this->ansicht == "woche") { $rows = 1; } $cols = 7; if ($this->ansicht == "tag") { $cols = 1; $rows = 1; } if ($this->ansicht == "jahr") { $cols = 31; $rows = 12; } if ($this->ansicht != "jahr") { for ($i = 0; $i < $rows; $i++) { if ($i > 0 and date("m.Y", $D->time()) != date("m.Y", $this->current->time())) { break; } for ($j = 0; $j < 7; $j++) { $D->addDay(); } } $D->subDay(); } if ($this->ansicht == "jahr") { $D->addYear(); $D->subDay(); } $this->rows = $rows; $this->cols = $cols; $this->last = $D->time(); }
public function downloadTrashData() { $andreas = false; if (!$andreas) { $json = file_get_contents("http://awido.cubefour.de/WebServices/Awido.Service.svc/getData/00000000-0000-0000-0000-000000001190?fractions=1,5,2,6,3,4,10&client=awv-nordschwaben"); } else { $json = file_get_contents("http://awido.cubefour.de/WebServices/Awido.Service.svc/getData/00000000-0000-0000-0000-000000000629?fractions=1,5,2,6,3,4,10&client=awv-nordschwaben"); } echo "<pre style=\"font-size:10px;max-height:400px;overflow:auto;\">"; $data = json_decode($json); foreach ($data->calendar as $day) { if ($day->fr == "") { continue; } if ($day->dt < date("Ymd")) { continue; } print_r($day); $tag = new Datum(Util::parseDate("de_DE", substr($day->dt, 6) . "." . substr($day->dt, 4, 2) . "." . substr($day->dt, 0, 4))); if ($andreas) { $tag->subDay(); } $name = ""; foreach ($day->fr as $T) { if ($T == "PT") { $name .= ($name != "" ? ", " : "") . "Papiertonne"; } if ($T == "RT") { $name .= ($name != "" ? ", " : "") . "Restmüll"; } if ($T == "GS") { $name .= ($name != "" ? ", " : "") . "Gelber Sack"; } if ($T == "BT") { $name .= ($name != "" ? ", " : "") . "Biotonne"; } } if ($name == "") { continue; } $F = new Factory("Todo"); $F->sA("TodoName", $name); $F->sA("TodoFromDay", $tag->time()); $F->sA("TodoTillDay", $tag->time()); $F->sA("TodoFromTime", "32400"); $F->sA("TodoTillTime", "36000"); $F->sA("TodoUserID", "-1"); $F->sA("TodoRemind", "-1"); if ($andreas) { $F->sA("TodoFromTime", Util::parseTime("de_DE", "18:00")); $F->sA("TodoTillTime", Util::parseTime("de_DE", "18:05")); $F->sA("TodoUserID", Session::currentUser()->getID()); $F->sA("TodoRemind", 60); } $F->sA("TodoClass", "Kalender"); $F->sA("TodoClassID", "-1"); $F->sA("TodoType", "2"); if ($F->exists()) { continue; } $F->store(); } echo "</pre>"; }
public static function stamp($args) { #if(strtolower($args["P0"]) == "303005f7b4") # die('{"status":"command", "action":"reload"}'); if (!isset($_SESSION["BPS"])) { $_SESSION["BPS"] = new BackgroundPluginState(); } addClassPath(Util::getRootPath() . "personalKartei/Zeiterfassung/"); addClassPath(Util::getRootPath() . "personalKartei/Personal/"); addClassPath(Util::getRootPath() . "personalKartei/ObjekteL/"); addClassPath(Util::getRootPath() . "open3A/Kategorien/"); $T = anyC::getFirst("ZETerminal", "ZETerminalID", $args["P1"]); if (!$T) { die('{"status":"error", "message":"Unbekanntes Terminal"}'); } $A = new stdClass(); $Date = new Datum(); $Date->subDay(); $Date->addDay(); $A->ChipID = trim(strtolower($args["P0"])); $A->Date = $Date->time(); $A->Time = Util::parseTime("de_DE", date("H:i", time())); $A->Type = $args["P2"]; $A->Mode = ""; $A->TerminalID = $args["P1"]; try { $ok = ZEData::addTime($A); } catch (Exception $e) { try { $A->ChipID = trim(strtolower(dechex($args["P0"]))); $ok = ZEData::addTime($A); } catch (Exception $e) { switch ($e->getCode()) { case 100: die('{"status":"error", "message":"Unbekannter Chip"}'); break; default: die('{"status":"error", "message":"' . $e->getMessage() . '"}'); } } } if ($args["P2"] == "G") { $AC = anyC::get("ZEData", "ZEDataChipID", $A->ChipID); $AC->addAssocV3("ZEDataType", "=", "K"); $AC->addAssocV3("ZEDataDate + ZEDataTime", ">", time() - 3600 * 13); $AC->addOrderV3("ZEDataID", "DESC"); $AC->addAssocV3("ZEDataIsDeleted", "=", "0"); $AC->setLimitV3("1"); $D = $AC->getNextEntry(); if ($D != null) { $pause = ZEAuswertung::calcPause($D, $ok["ZEData"]); if ($pause !== null) { $DE = $ok["ZEData"]; $DE->changeA("ZEDataPause", $pause); $DE->saveMe(false, false); } } } #303046a1b7 BPS::setProperty("ZEAuswertung", "objektLID", $T->A("ZETerminalObjektLID")); BPS::setProperty("ZEAuswertung", "personalID", $ok["Personal"]->getID()); BPS::setProperty("ZEAuswertung", "month", date("Ym")); #$ZEA = new ZEAuswertung($A->ChipID); #$ZEA->debug = false; #$current = $ZEA->getContent(); die('{"status":"OK", "message": "' . addslashes($ok["Personal"]->A("vorname") . " " . $ok["Personal"]->A("nachname")) . '", "details": ""}'); #Stunden '.Util::CLMonthName(date("m")).': '.Util::formatSeconds($current["totalHours"][1], false).' }