function getEventList($date, $state) { $criteria = new AndStatement(); $field = $this->eventDao->getQStateName(); $criteria->addStatement($field . "='" . addslashes($state) . "'"); $field = $this->eventDao->getQValid_DateName(); if (is_array($date)) { $criteriaOr = new OrStatement(); foreach ($date as $dt) { $criteriaOr->addStatement($field . " like'" . addslashes($dt) . "%'"); } $criteria->addStatement($criteriaOr); } else { $criteria->addStatement($field . " like '" . addslashes($date) . "%'"); } /*$criteriaOr = new OrStatement(); $criteriaOr->addStatement($field ."='". addslashes($date) ."'"); $criteriaOr->addStatement($field ."='". addslashes($this->minusDaysFromGetDate(1)) ."'"); $criteriaOr->addStatement($field ."='". addslashes($this->minusDaysFromGetDate(2)) ."'"); $criteria->addStatement($criteriaOr);*/ $eventList = $this->eventDao->find($criteria, null, 1000); if (is_string($eventList)) { return false; } else { if (!is_array($eventList)) { return false; } } return $eventList; }
function moveClientHistory($oldClient, $newClient) { $criteria = new AndStatement(); $field = $this->eventHistoryDao->getQCidName(); $criteria->addStatement($field . "='" . addslashes($oldClient->getId()) . "'"); $order = new OrderBys(); $sortField = $this->eventHistoryDao->getQIdName(); $order->addField($sortField, true); $clientHistorys = $this->eventHistoryDao->find($criteria, $order, 1000); if (is_null($clientHistorys)) { $this->context->setRequestScopeAttr("error", "Nepavyko nuskaityti kliento istorijos"); return false; } else { if (is_string($clientHistorys)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $clientHistorys); $clientHistorys = null; return false; } } foreach ($clientHistorys as $history) { $history->setId(null); $history->setCid($newClient->getId()); $this->eventHistoryDao->insert($history, true); } return true; }
function actionSave($currentUser) { $backUrl = $this->context->getFlowScopeAttr("backUrl"); $pass = null; $user = new User(); $userErrs = array(); $user->setId($this->context->getRequestAttr("id")); $user->setUser($this->context->getRequestAttr("email")); if (!is_null($user->getUser())) { $user->setUser(trim($user->getUser())); if (strlen($user->getUser()) < 1) { $user->setUser(null); } } if (is_null($user->getUser())) { $userErrs["email"] = "field.error.empty"; } else { if (is_null($user->getId())) { $field = $this->userDao->getQUserName(); $criteria = new AndStatement(); $criteria->addStatement($field . "='" . htmlspecialchars($user->getUser()) . "'"); $exUsers = $this->userDao->find($criteria, null, 1000); if (is_array($exUsers) and count($exUsers) > 0) { $userErrs["email"] = "field.error.userExists"; } } } $active = $this->context->getRequestAttr("active"); $user->setActive($active == 1 ? true : false); if (is_null($user->getId())) { $pass = $this->generatePass(); $user->setPassword($pass); } $timeZone = new DateTimeZone("Europe/Vilnius"); $time = new DateTime("now", $timeZone); $user->setR_date($time->format("Y-m-d H:i:s")); $user->setR_user($currentUser->getId()); $this->context->setFlashScopeAttr("user", $user); $this->context->setFlashScopeAttr("userErrs", $userErrs); if (count($userErrs) >= 1) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $store = $this->storeUser($user); if (!$store) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } if (!is_null($pass)) { $this->sendNotification($user); } $this->cancelEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; }
private function getReport($code) { $criteria = new AndStatement(); $field = $this->reportsDao->getQCodeName(); $criteria->addStatement($field . "='" . htmlspecialchars($code) . "'"); $reports = $this->reportsDao->find($criteria, null); if (is_null($reports) || is_string($reports) || count($reports) < 1) { return false; } return reset($reports); }
function renderHistoryList($currentUser) { $user_id = $currentUser->getId(); $userP = $this->context->getRequestAttr("user"); $projectP = $this->context->getRequestAttr("project"); $userProjects = null; $this->context->setFlowScopeAttr("currentUser", $currentUser); $order = new OrderBys(); $sortField = $this->eventHistoryDao->getQR_dateName(); $order->addField($sortField, false); if (!is_null($userP) && $userP != "0") { $criteriaUsr = new AndStatement(); $field = $this->projectDao->getQOwnerName(); $criteriaUsr->addStatement($field . "='" . addslashes($userP) . "'"); $userProjects = $this->projectDao->find($criteriaUsr, null, 1000); if (!is_array($userProjects)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $userProjects); $userProjects = null; } if (!is_null($userProjects)) { $criteriaIn = new InStatement(); $field = $this->eventHistoryDao->getQPidName(); $criteriaIn->setField($field); foreach ($userProjects as $userProject) { $criteriaIn->addValue($userProject->getId()); } } } $criteria = new AndStatement(); if (!empty($criteriaIn)) { $criteria->addStatement($criteriaIn); } if (!is_null($projectP) && $projectP != "0") { $field = $this->eventHistoryDao->getQPidName(); $criteria->addStatement($field . "='" . addslashes($projectP) . "'"); } $history = $this->eventHistoryDao->find($criteria, $order, 1000); //$history = $this->eventHistoryDao->find((empty($criteriaIn) ? null : $criteriaIn), $order, 1000); $users = $this->userDao->find(null, null, 1000); if (!is_array($users)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $users); $users = array(); } if (!is_array($history)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $history); $history = array(); } $this->context->setRequestScopeAttr("history", $history); $projects = $this->projectDao->find(null, null, 1000); if (!is_array($projects)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $projects); $projects = array(); } $this->context->setRequestScopeAttr("projects", $projects); $stages = $this->stageDao->find(null, null, 1000); if (!is_array($stages)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $stages); $stages = array(); } $this->context->setRequestScopeAttr("stages", $stages); $clients = $this->clientDaol->find(null, null, 1000); if (!is_array($clients)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $clients); $clients = array(); } $this->context->setRequestScopeAttr("clients", $clients); $users = $this->userDao->find(null, null, 1000); if (!is_array($users)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $users); $users = array(); } $this->context->setFlowScopeAttr("users", $users); $rurls = array(); $rurls["refresh"] = new SimpleUrl(); $this->context->setFlowScopeAttr("backUrl", $rurls["refresh"]->getGetUrl()); $aurls = $this->actionUrls; $texts = $this->texts; $model = $this->context->getModel(); include "./view/historyList.php"; }
function getStageID($projectID, $stageNr, $getResponse) { $field = $this->stageDao->getQPidName(); $criteria = new AndStatement(); $criteria->addStatement($field . "=" . $projectID . ""); $order = new OrderBys(); $sortField = $this->stageDao->getQOrderisName(); $order->addField($sortField, true); $stages = $this->stageDao->find($criteria, $order, 1000); if (is_null($stages)) { $stages = null; } else { if (is_string($stages)) { $stages = NULL; } else { if (!is_array($stages)) { $stages = null; } else { if (count($stages) == 0) { $stages = null; } else { if (!isset($stages[$stageNr - 1])) { $stages = null; } } } } } if (is_null($stages)) { $this->setParamPoz($getResponse->getId(), 2, "[09] Nepavyko rasti pirminio etapo"); return false; } return $stages[$stageNr - 1]; }
function getLastStage($projectID) { $criteria = new AndStatement(); $field = $this->stageDao->getQPidName(); $criteria->addStatement($field . "='" . addslashes($projectID) . "'"); $order = new OrderBys(); $sortField = $this->stageDao->getQOrderisName(); $order->addField($sortField, false); $stages = $this->stageDao->find($criteria, $order, 1000); if (!is_array($stages)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $stages); $stages = null; } else { if (count($stages) == 0) { $stages = null; } } if (is_null($stages)) { return false; } return reset($stages); }
function generateEventsForView($clients) { $eventsArray = array(); $IDfield = $this->eventDao->getQIdName(); $Pfield = $this->eventDao->getQPidName(); $Cfield = $this->eventDao->getQCidName(); foreach ($clients as $client) { $criteria = new AndStatement(); $criteria->addStatement($Pfield . "=" . addslashes($client->getPid())); $criteria->addStatement($Cfield . "=" . addslashes($client->getId())); $order = new OrderBys(); $order->addField($IDfield, true); $events = $this->eventDao->find($criteria, $order, 1000); if (!is_array($events)) { $events = null; } else { if (count($events) == 0) { $events = null; } } if (!is_null($events)) { foreach ($events as $event) { if (!isset($eventsArray[$client->getId()])) { $eventsArray[$client->getId()] = array(); } array_push($eventsArray[$client->getId()], $event); } } } return $eventsArray; }
function loginAction() { $username = $this->context->getRequestAttr("user"); $passwd = $this->context->getRequestAttr("password"); $currentUser = null; $usernameField = $this->userDao->getQUserName(); $passwdField = $this->userDao->getQPasswordName(); $criteria = new AndStatement(); $criteria->addStatement($usernameField . "='" . addslashes($username) . "'"); $criteria->addStatement($passwdField . "='" . addslashes($passwd) . "'"); $users = $this->userDao->find($criteria); if (is_array($users)) { foreach ($users as $user) { $currentUser = $user; break; } } if (is_null($currentUser)) { $this->context->setRequestScopeAttr("error", "user.error.badlogin"); } else { if (!$currentUser->isActive()) { $currentUser = null; $this->context->setRequestScopeAttr("error", "user.error.suspended"); } } if (is_null($currentUser)) { $this->context->setFlowScopeAttr("currentUser", $currentUser); $this->context->setRequestScopeAttr("login", true); return false; } $this->context->setFlowScopeAttr("currentUser", $currentUser); $this->context->setRequestScopeAttr("login", true); return false; }
function chechProjectCruid() { $projectCruid = $this->context->getRequestAttr("project"); if (is_null($projectCruid) || !isset($projectCruid)) { return false; } $field = $this->projectDao->getQCruidName(); $criteria = new AndStatement(); $criteria->addStatement($field . "='" . addslashes($projectCruid) . "'"); $projects = $this->projectDao->find($criteria, null, 1000); if (is_null($projects)) { return false; } else { if (is_string($projects)) { return false; } else { if (!is_array($projects)) { return false; } else { if (count($projects) == 0) { return false; } } } } $project = reset($projects); $this->context->setFlowScopeAttr("currentProject", $project); return true; }