コード例 #1
0
ファイル: jobApp.class.php プロジェクト: Faradejus/WorkFlow
 function checkDelays()
 {
     $criteria = new AndStatement();
     $field = $this->eventDao->getQStateName();
     $criteria->addStatement($field . "=1");
     $field = $this->eventDao->getQValid_dateName();
     $criteria->addStatement($field . "< NOW()");
     $field = $this->eventDao->getQDelayName();
     $criteria->addStatement($field . "=0");
     $events = $this->eventDao->find($criteria, null);
     if (is_null($events) || is_string($events) || count($events) == 0) {
         return false;
     }
     foreach ($events as $event) {
         $project = $this->getProject($event->getPid());
         if (!is_object($project)) {
             $mail = new Mail();
             $mail->setTo("*****@*****.**");
             $mail->setSubject("WorkFlow.lt Klaida nuskaitant projekta | checkDelays");
             if (is_string($project)) {
                 $mail->setText($project);
             }
             $mail->sendMail();
             continue;
         }
         $stage = $this->getStageById($event->getSid());
         if (!is_object($stage)) {
             $mail = new Mail();
             $mail->setTo("*****@*****.**");
             $mail->setSubject("WorkFlow.lt Klaida nuskaitant etapa | checkDelays");
             if (is_string($stage)) {
                 $mail->setText($stage);
             }
             $mail->sendMail();
             continue;
         }
         $client = $this->getClientById($event->getCid());
         if (!is_object($client)) {
             $mail = new Mail();
             $mail->setTo("*****@*****.**");
             $mail->setSubject("WorkFlow.lt Klaida nuskaitant klienta | checkDelays");
             if (is_string($client)) {
                 $mail->setText($client);
             }
             //$mail->sendMail();
             continue;
         }
         if (!$client->isActive() || $client->isEnded() || $client->isEnded_eve() || $client->isMoved()) {
             continue;
         }
         $event->setDelays($event->getDelays() + 1);
         $event->setDelay(true);
         $this->storeEvent($event);
         $rss = new Rss($project->getRsskey());
         $eventRss = new EventRss();
         $eventRss->title = $eventRss->getText("warningTitle", array($project->getName()));
         $eventRss->description = $eventRss->getText("warningDescription", array($project->getName(), $stage->getName(), $this->formatClientInfo($client)));
         $eventRss->link = addslashes(htmlspecialchars($this->partnerUrl)) . addslashes(htmlspecialchars($project->getCruid()));
         $eventRss->pubDate = Carbon::now()->toRssString();
         $eventRss->PID = $project->getId();
         $eventRss->CID = $client->getId();
         $eventRss->SID = $stage->getId();
         if (!$rss->addEvent($project, $eventRss)) {
             $mail = new Mail();
             $mail->setTo("*****@*****.**");
             $mail->setSubject("WorkFlow.lt Klaida kuriant RSS irasa | checkDelays");
             $mail->setText(print_r($eventRss, true));
             $mail->sendMail();
         }
         $eventHistory = new EventHistory();
         $eventHistory->setPid($event->getPid());
         $eventHistory->setCid($event->getCid());
         $eventHistory->setSid($event->getSid());
         $eventHistory->setEid($event->getId());
         $eventHistory->setR_date(Carbon::Now()->toDateTimeString());
         $eventHistory->setDescription("Pradėtas vieluoti etapas");
         $eventHistory->setValid_date($event->getValid_date());
         $this->storeEventHistory($eventHistory);
     }
 }
コード例 #2
0
ファイル: apiApp.class.php プロジェクト: Faradejus/WorkFlow
 function importAction()
 {
     if (!isset($_POST['client'])) {
         $this->setOutPut(array("error" => $this->errorCode['param_not_found']));
         return false;
     }
     $client = json_decode(urldecode($_POST['client']));
     //$client = $this->utf8Decode($client1);
     //var_dumpas($client['projectKey']);
     if (!isset($client->projectKey) || is_null($client->projectKey)) {
         $this->setOutPut(array("error" => $this->errorCode['wrong_param']));
         return false;
     }
     $project = $this->getProject($client->projectKey, $client);
     if (!is_object($project)) {
         return false;
     }
     if (!isset($client->name) || is_null($client->name)) {
         $this->setOutPut(array("error" => $this->errorCode['wrong_param']));
         return false;
     }
     if (!isset($client->email) || is_null($client->email)) {
         $this->setOutPut(array("error" => $this->errorCode['wrong_param']));
         return false;
     }
     if (!isset($client->telephone) || is_null($client->telephone)) {
         $this->setOutPut(array("error" => $this->errorCode['wrong_param']));
         return false;
     }
     /*if (!isset($client->comment) || is_null($client->comment)){
           $this->setOutPut(array("error" => $this->errorCode['wrong_param']));
           return false;
       }*/
     $now = Carbon::Now();
     //Kuriam nauja klienta
     $newClient = new Client();
     $newClient->setPid($project->getId());
     $newClient->setName(substr($client->name, 0, 255));
     $newClient->setEmail(substr($client->email, 0, 255));
     $newClient->setTelephone(substr($client->telephone, 0, 50));
     $newClient->setComment(substr($client->comment, 0, 255));
     $newClient->setCustomer(substr($client->customer, 0, 255));
     $newClient->setActive(true);
     $newClient->setPeriodical(false);
     $newClient->setPeriodicalid(0);
     $newClient->setR_date($now->toDateTimeString());
     $newClient->setR_user(977);
     $store = $this->storeClient($newClient);
     if (!$store) {
         $this->setOutPut(array("error" => $this->errorCode['client_not_stored']));
         $mail_ob = new Mail();
         $mail_ob->setTo("*****@*****.**");
         $mail_ob->setText(print_r($newClient, true));
         $mail_ob->setSubject("WorkFlow.kaizensistema.lt | Nepavyko sukurti importo kliento.");
         $mail_ob->sendMail();
         return false;
     } else {
         $eventHistory = new EventHistory();
         $eventHistory->setPid($newClient->getPid());
         $eventHistory->setCid($newClient->getId());
         $eventHistory->setR_date($newClient->getR_date());
         $eventHistory->setDescription(!is_null($client->from) ? $client->from : "Sukurtas integracijos metu");
         $this->storeEventHistory($eventHistory);
     }
     $this->setOutPut(array("ok" => "ok"));
 }
コード例 #3
0
 function find($criteria = null, $order = null, $limit = 1000, $from = 0)
 {
     $result = $this->database->query($this->buildFindQuery($criteria, $order, $limit, $from));
     if (!is_null($result->getError())) {
         return $result->getError();
     }
     $eventHistorys = array();
     while ($row = $result->fetchRow()) {
         $eventHistory = new EventHistory();
         $value = $row[0];
         $eventHistory->setId($value);
         $value = $row[1];
         $eventHistory->setPid($value);
         $value = $row[2];
         $eventHistory->setCid($value);
         $value = $row[3];
         $eventHistory->setSid($value);
         $value = $row[4];
         $eventHistory->setEid($value);
         $value = $row[5];
         $eventHistory->setValid_date($value);
         $value = $row[6];
         $eventHistory->setReminde_date($value);
         $value = $row[7];
         $eventHistory->setAmount($value);
         $value = $row[8];
         $eventHistory->setState($value);
         $value = $row[9];
         $eventHistory->setComment($value);
         $value = $row[10];
         $eventHistory->setBalance($value);
         $value = $row[11];
         $eventHistory->setR_date($value);
         $value = $row[12];
         $eventHistory->setDescription($value);
         if ($order != null) {
             array_push($eventHistorys, $eventHistory);
         } else {
             $eventHistorys[$eventHistory->getId()] = $eventHistory;
         }
     }
     return $eventHistorys;
 }
コード例 #4
0
 function saveEventHistory($client, $description)
 {
     $eventHistory = new EventHistory();
     $eventHistory->setPid($client->getPid());
     $eventHistory->setCid($client->getId());
     $eventHistory->setR_date($client->getR_date());
     $eventHistory->setDescription($description);
     $this->storeEventHistory($eventHistory);
 }
コード例 #5
0
 function actionSaveEvent($currentProject)
 {
     $backUrl = $this->context->getFlowScopeAttr("backUrl");
     $arUzbaigtas = $this->context->getRequestAttr("uzbaigtas");
     $renderNew = $this->context->getRequestAttr("rendernew");
     $renderNew = $renderNew == "1" ? $renderNew : "0";
     $timeZone = new DateTimeZone("Europe/Vilnius");
     $time = new DateTime("now", $timeZone);
     $eventErrs = array();
     $eventID = $this->context->getRequestAttr("id");
     $state = $this->context->getRequestAttr("state");
     if (is_null($eventID)) {
         $this->context->setRequestScopeAttr("errortxt", "stage.error.notfound");
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $event = $this->eventDao->get($eventID);
     if (is_null($event)) {
         $this->context->setRequestScopeAttr("error", "stage.error.notfound");
         $this->cancelEditEvent();
         return false;
     } else {
         if (is_string($event)) {
             $this->context->setRequestScopeAttr("error", "error.dberror");
             $this->context->setRequestScopeAttr("errortxt", $event);
             $event = null;
             $this->cancelEditEvent();
             return false;
         }
     }
     $stage = $this->stageDao->get($event->getSid());
     if (!is_object($stage)) {
         $this->context->setRequestScopeAttr("error", "stage.error.notfound");
         $this->cancelEditEvent();
         return false;
     }
     $client = $this->clientDaol->get($event->getCid());
     if (!is_object($client)) {
         $this->context->setRequestScopeAttr("error", "client.error.notfound");
         $this->cancelEditEvent();
         return false;
     }
     $event->setR_date($time->format("Y-m-d H:i:s"));
     $event->setComment($this->context->getRequestAttr("comment"));
     if (!is_null($event->getComment())) {
         $event->setComment(trim($event->getComment()));
         if (strlen($event->getComment()) < 1) {
             $event->setComment(null);
         }
     }
     #region BALANCE
     $eventCopy = clone $event;
     $event->setIncome($this->context->getRequestAttr("income"));
     if (!is_null($event->getIncome())) {
         $event->setIncome(trim($event->getIncome()));
         if (strlen($event->getIncome()) < 1) {
             $event->setIncome(null);
         }
     }
     if (!is_null($event->getIncome()) && !is_numeric($event->getIncome())) {
         $eventErrs['balanse'] = true;
     }
     $event->setCost($this->context->getRequestAttr("cost"));
     if (!is_null($event->getCost())) {
         $event->setCost(trim($event->getCost()));
         if (strlen($event->getCost()) < 1) {
             $event->setCost(null);
         }
     }
     if (!is_null($event->getCost()) && !is_numeric($event->getCost())) {
         $eventErrs['balanse'] = true;
     }
     $event->setWasted_time($this->context->getRequestAttr("wasted_time"));
     if (!is_null($event->getWasted_time())) {
         $event->setWasted_time(trim($event->getWasted_time()));
         if (strlen($event->getWasted_time()) < 1) {
             $event->setWasted_time(null);
         }
     }
     if (!is_null($event->getWasted_time()) && !is_numeric($event->getWasted_time())) {
         $eventErrs['balanse'] = true;
     }
     $this->context->setFlashScopeAttr("event", $event);
     $this->context->setFlashScopeAttr("eventErrs", $eventErrs);
     if (count($eventErrs) >= 1) {
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $event->setState(2);
     /* PELNAS */
     $income = !is_null($event->getIncome()) ? $event->getIncome() : 0;
     $cost = !is_null($event->getCost()) ? $event->getCost() : 0;
     if ($income != 0 || $cost != 0) {
         $profit = $income - $cost;
     }
     if ($profit) {
         $event->setProfit($profit);
     }
     if (!is_null($eventCopy->getIncome())) {
         if (!is_null($event->getIncome())) {
             $event->setIncome($eventCopy->getIncome() + $event->getIncome());
         } else {
             $event->setIncome($eventCopy->getIncome());
         }
     }
     if (!is_null($eventCopy->getCost())) {
         if (!is_null($event->getCost())) {
             $event->setCost($eventCopy->getCost() + $event->getCost());
         } else {
             $event->setCost($eventCopy->getCost());
         }
     }
     if (!is_null($eventCopy->getProfit())) {
         if (!is_null($event->getProfit())) {
             $event->setProfit($eventCopy->getProfit() + $event->getProfit());
         } else {
             $event->setProfit($eventCopy->getProfit());
         }
     }
     if (!is_null($eventCopy->getWasted_time())) {
         if (!is_null($event->getWasted_time())) {
             $event->setWasted_time($eventCopy->getWasted_time() + $event->getWasted_time());
         } else {
             $event->setWasted_time($eventCopy->getWasted_time());
         }
     }
     #endregion
     $store = $this->storeEvent($event, $stage, $renderNew);
     if (!$store) {
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $eventHistory = new EventHistory();
     $eventHistory->setDescription("Etapo užbaigimas");
     $eventHistory->setPid($event->getPid());
     $eventHistory->setCid($event->getCid());
     $eventHistory->setSid($event->getSid());
     $eventHistory->setEid($event->getId());
     $eventHistory->setValid_date($event->getValid_date());
     $eventHistory->setReminde_date($event->getReminde_date());
     $eventHistory->setState($event->getState());
     $eventHistory->setComment($event->getComment());
     $eventHistory->setR_date($event->getR_date());
     $balance = "";
     if (!is_null($event->getIncome())) {
         $balance .= (!empty($balance) ? "<br />" : "") . 'Pajamos - ' . $event->getIncome() . '€';
     }
     if (!is_null($event->getCost())) {
         $balance .= (!empty($balance) ? "<br />" : "") . 'Išlaidos - ' . $event->getCost() . '€';
     }
     if (!is_null($event->getProfit())) {
         $balance .= (!empty($balance) ? "<br />" : "") . 'Pelnas (nuostolis) - ' . $event->getProfit() . '€';
     }
     if (!is_null($event->getWasted_time())) {
         $balance .= (!empty($balance) ? "<br />" : "") . 'Sugaištas laikas - ' . $event->getWasted_time() . 'min.';
     }
     if (!empty($balance)) {
         $eventHistory->setBalance($balance);
     }
     $this->storeEventHistory($eventHistory);
     if ($stage->getEnded_stage() != 0) {
         $action = $stage->getEnded_stage() == 1 ? "copy" : "move";
         $projects = explode(",", $stage->getEnded_stage_pid());
         foreach ($projects as $projectId) {
             $this->moveCopyClient($client, $projectId, $action);
         }
     }
     $this->cancelEditEvent();
     if (!is_null($backUrl)) {
         header("Location: " . $backUrl);
         return true;
     }
     return false;
 }
コード例 #6
0
 function moveCopyClient($client, $newProjectId, $action)
 {
     $newProject = $this->projectDao->get($newProjectId);
     if (!is_object($newProject)) {
         return false;
     }
     $project = $this->projectDao->get($client->getPid());
     if (!is_object($project)) {
         return false;
     }
     $oldClient = clone $client;
     $newClient = clone $client;
     $newClient->setId(null);
     $newClient->setActive(true);
     $newClient->setPid($newProject->getId());
     $newClient->setR_date(Carbon::Now()->toDateTimeString());
     $store = $this->storeClient($newClient);
     if (!$store) {
         return false;
     }
     /*if (!$this->saveFirsEvent($newClient))
                     return false;
     
                 if (!$this->sendNotification($newClient))
                     return false;*/
     if ($action == "move") {
         $oldClient->setMoved(true);
         $store = $this->storeClient($oldClient);
         if (!$store) {
             return false;
         }
         $this->moveClientHistory($oldClient, $newClient);
         $eventHistory = new EventHistory();
         $eventHistory->setPid($newClient->getPid());
         $eventHistory->setCid($newClient->getId());
         $eventHistory->setR_date($newClient->getR_date());
         $description = ($action == "copy" ? "Nukopijuotas" : "Perkeltas") . ' iš projekto <a href="./action.php?action=startview&amp;appName=projectApp&amp;id=' . $project->getId() . '">' . htmlspecialchars($project->getName()) . "</a>";
         $eventHistory->setDescription($description);
         $this->storeEventHistory($eventHistory);
         $eventHistory = new EventHistory();
         $eventHistory->setPid($oldClient->getPid());
         $eventHistory->setCid($oldClient->getId());
         $eventHistory->setR_date($oldClient->getR_date());
         $description = 'Perkeltas į projektą <a href="./action.php?action=startview&amp;appName=projectApp&amp;id=' . $newProject->getId() . '">' . htmlspecialchars($newProject->getName()) . "</a>";
         $eventHistory->setDescription($description);
         $this->storeEventHistory($eventHistory);
     } else {
         $this->moveClientHistory($oldClient, $newClient);
         $eventHistory = new EventHistory();
         $eventHistory->setPid($newClient->getPid());
         $eventHistory->setCid($newClient->getId());
         $eventHistory->setR_date($newClient->getR_date());
         $description = ($action == "copy" ? "Nukopijuotas" : "Perkeltas") . ' iš projekto <a href="./action.php?action=startview&amp;appName=projectApp&amp;id=' . $project->getId() . '">' . htmlspecialchars($project->getName()) . "</a>";
         $eventHistory->setDescription($description);
         $this->storeEventHistory($eventHistory);
     }
     return true;
 }
コード例 #7
0
 function actionChangeClientStatus($currentUser)
 {
     $backUrl = $this->context->getFlowScopeAttr("backUrl");
     $id = $this->context->getRequestAttr("id");
     $activePOZ = $this->context->getRequestAttr("active");
     $projectID = $this->context->getRequestAttr("projectID");
     if (is_null($id)) {
         $this->context->setRequestScopeAttr("error", "client.error.notfound");
         $this->cancelClientEdit();
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $client = $this->clientDaol->get($id);
     if (is_null($client)) {
         $this->context->setRequestScopeAttr("error", "client.error.notfound");
         $this->cancelClientEdit();
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     } else {
         if (is_string($client)) {
             $this->context->setRequestScopeAttr("error", "error.dberror");
             $this->context->setRequestScopeAttr("errortxt", $client);
             $client = null;
             $this->cancelClientEdit();
             if (!is_null($backUrl)) {
                 header("Location: " . $backUrl);
                 return true;
             }
             return false;
         }
     }
     if (!$this->setStoreProject($projectID, "clientProject")) {
         $this->cancelPartnerEdit();
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $client->setActive($activePOZ);
     $timeZone = new DateTimeZone("Europe/Vilnius");
     $time = new DateTime("now", $timeZone);
     $client->setR_date($time->format("Y-m-d H:i:s"));
     $client->setR_user($currentUser->getId());
     $store = $this->storeClient($client);
     if (!$store) {
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $eventHistory = new EventHistory();
     $eventHistory->setPid($client->getPid());
     $eventHistory->setCid($client->getId());
     $eventHistory->setR_date($client->getR_date());
     $eventHistory->setDescription(($client->isActive() ? "Atsisakyta" : "Atsisakyta") . " rinkodaristo");
     $eventHistory->setComment($this->context->getRequestAttr("pozcomment"));
     if (!is_null($eventHistory->getComment())) {
         $eventHistory->setComment(trim($eventHistory->getComment()));
         if (strlen($eventHistory->getComment()) < 1) {
             $eventHistory->setComment(null);
         }
     }
     $this->storeEventHistory($eventHistory);
     $this->cancelClientEdit();
     if (!is_null($backUrl)) {
         header("Location: " . $backUrl);
         return true;
     }
     return false;
 }
コード例 #8
0
 function actionSaveClient($currentProject)
 {
     $backUrl = $this->context->getFlowScopeAttr("backUrl");
     $client = new Client();
     $clientErrs = array();
     $client->setId($this->context->getRequestAttr("id"));
     $client->setPid($this->context->getRequestAttr("projectID"));
     $client->setName($this->context->getRequestAttr("name"));
     if (!is_null($client->getName())) {
         $client->setName(trim($client->getName()));
         if (strlen($client->getName()) < 1) {
             $client->setName(null);
         }
     }
     if (is_null($client->getName())) {
         $clientErrs["name"] = "field.error.empty";
     }
     $client->setEmail($this->context->getRequestAttr("email"));
     if (!is_null($client->getEmail())) {
         $client->setEmail(trim($client->getEmail()));
         if (strlen($client->getEmail()) < 1) {
             $client->setEmail(null);
         }
     }
     if (is_null($client->getEmail())) {
         $clientErrs["email"] = "field.error.empty";
     }
     $client->setTelephone($this->context->getRequestAttr("telephone"));
     if (!is_null($client->getTelephone())) {
         $client->setTelephone(trim($client->getTelephone()));
         if (strlen($client->getTelephone()) < 1) {
             $client->setTelephone(null);
         }
     }
     $client->setCustomer($this->context->getRequestAttr("customer"));
     if (!is_null($client->getCustomer())) {
         $client->setCustomer(trim($client->getCustomer()));
         if (strlen($client->getCustomer()) < 1) {
             $client->setCustomer(null);
         }
     }
     $client->setComment($this->context->getRequestAttr("comment"));
     if (!is_null($client->getComment())) {
         $client->setComment(trim($client->getComment()));
         if (strlen($client->getComment()) < 1) {
             $client->setComment(null);
         }
     }
     $client->setPeriodical(false);
     $client->setPeriodicalid(0);
     $timeZone = new DateTimeZone("Europe/Vilnius");
     $time = new DateTime("now", $timeZone);
     $client->setR_date($time->format("Y-m-d H:i:s"));
     $client->setR_user(888);
     $client->setActive(true);
     $this->context->setFlashScopeAttr("client", $client);
     $this->context->setFlashScopeAttr("clientErrs", $clientErrs);
     if (count($clientErrs) >= 1) {
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $insert = true;
     $store = $this->storeClient($client);
     if (!$store) {
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     if ($insert) {
         $eventHistory = new EventHistory();
         $eventHistory->setPid($client->getPid());
         $eventHistory->setCid($client->getId());
         $eventHistory->setR_date($client->getR_date());
         $eventHistory->setDescription("Sukurtas trečio asmens");
         $this->storeEventHistory($eventHistory);
     }
     $this->cancelClientEdit();
     if (!is_null($backUrl)) {
         header("Location: " . $backUrl);
         return true;
     }
     return false;
 }