Example #1
0
 function actionChangeClientStatus($currentProject)
 {
     $backUrl = $this->context->getFlowScopeAttr("backUrl");
     $id = $this->context->getRequestAttr("id");
     $activePOZ = $this->context->getRequestAttr("active");
     $projectID = $this->context->getRequestAttr("projectID");
     $stageId = $this->context->getRequestAttr("stageID");
     $eventId = $this->context->getRequestAttr("eventID");
     if (is_null($id)) {
         $this->context->setRequestScopeAttr("error", "client.error.notfound");
         $this->cancelClientView();
         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->cancelClientView();
         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->cancelClientView();
             if (!is_null($backUrl)) {
                 header("Location: " . $backUrl);
                 return true;
             }
             return false;
         }
     }
     $stage = $this->stageDao->get($stageId);
     if (!is_object($stage)) {
         $this->context->setRequestScopeAttr("error", "stage.error.notfound");
         $this->cancelClientView();
         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(0);
     $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() ? "Atsisakytas" : "Atsisakytas") . " partnerio");
     $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);
     $proj = $this->projectDao->get($client->getPid());
     $user = $this->userDao->get($proj->getOwner());
     $messageText = $this->mailPatterns->suspendClientText;
     $messageText = str_replace("<PROJECT>", htmlspecialchars($proj->getName()), $messageText);
     $messageText = str_replace("<CLIENT>", htmlspecialchars($client->getName()) . " " . htmlspecialchars($client->getEmail()) . " " . htmlspecialchars($client->getTelephone()), $messageText);
     $messageText = str_replace("<LINKAS>", htmlspecialchars($this->projectUrl) . htmlspecialchars($proj->getCruid()), $messageText);
     $messageText = str_replace("<PRIEZASTIS>", htmlspecialchars($eventHistory->getComment()), $messageText);
     $mail_ob = new Mail();
     $mail_ob->setTo($user->getUser());
     $mail_ob->setText($messageText);
     $mail_ob->setSubject($this->mailPatterns->suspendClientSubject . $proj->getName());
     $mail_ob->sendMail();
     $this->logEmeilSend($mail_ob);
     if ($stage->getCancel_customer() != 0) {
         $action = $stage->getCancel_customer() == 1 ? "copy" : "move";
         $projects = explode(",", $stage->getCancel_customer_pid());
         foreach ($projects as $projectId) {
             $this->moveCopyClient($client, $projectId, $action);
         }
     }
     $this->cancelClientView();
     if (!is_null($backUrl)) {
         header("Location: " . $backUrl);
         return true;
     }
     return false;
 }
Example #2
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;
 }