示例#1
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();
     }
     $stages = array();
     while ($row = $result->fetchRow()) {
         $stage = new Stage();
         $value = $row[0];
         $stage->setId($value);
         $value = $row[1];
         $stage->setPid($value);
         $value = $row[2];
         $stage->setName($value);
         $value = $row[3];
         $stage->setAbout($value);
         $value = $row[4];
         $stage->setOrderis($value);
         $value = $row[5];
         $value = $this->database->toBoolean($value);
         $stage->setLast($value);
         $value = $row[6];
         $stage->setPeriod_type($value);
         $value = $row[7];
         $stage->setPeriod($value);
         $value = $row[8];
         $stage->setDelay($value);
         $value = $row[9];
         $stage->setEnded_stage($value);
         $value = $row[10];
         $stage->setEnded_stage_pid($value);
         $value = $row[11];
         $stage->setCancel_customer($value);
         $value = $row[12];
         $stage->setCancel_customer_pid($value);
         $value = $row[13];
         $value = $this->database->toBoolean($value);
         $stage->setSend($value);
         $value = $row[14];
         $stage->setApi($value);
         $value = $row[15];
         $stage->setCampaign($value);
         $value = $row[16];
         $value = $this->database->toBoolean($value);
         $stage->setSend_mail($value);
         $value = $row[17];
         $stage->setSend_to($value);
         $value = $row[18];
         $stage->setSend_from($value);
         $value = $row[19];
         $stage->setSend_subject($value);
         $value = $row[20];
         $stage->setSend_text($value);
         $value = $row[21];
         $stage->setR_date($value);
         $value = $row[22];
         $stage->setR_user($value);
         if ($order != null) {
             array_push($stages, $stage);
         } else {
             $stages[$stage->getId()] = $stage;
         }
     }
     return $stages;
 }
示例#2
0
 function actionSaveStage($currentUser)
 {
     $backUrl = $this->context->getFlowScopeAttr("backUrl");
     $stage = new Stage();
     $stageErrs = array();
     $stage->setId($this->context->getRequestAttr("id"));
     $stage->setPid($this->context->getRequestAttr("projectID"));
     $stage->setOrderis($this->context->getRequestAttr("order"));
     $stage->setName($this->context->getRequestAttr("name"));
     if (!is_null($stage->getName())) {
         $stage->setName(trim($stage->getName()));
         if (strlen($stage->getName()) < 1) {
             $stage->setName(null);
         }
     }
     if (is_null($stage->getName())) {
         $stageErrs["name"] = "field.error.empty";
     }
     $stage->setAbout($this->context->getRequestAttr("about"));
     if (!is_null($stage->getAbout())) {
         $stage->setAbout(trim($stage->getAbout()));
         if (strlen($stage->getAbout()) < 1) {
             $stage->setAbout(null);
         }
     }
     $stage->setPeriod_type($this->context->getRequestAttr("period_type"));
     $stage->setPeriod($this->context->getRequestAttr("period"));
     if (!is_null($stage->getPeriod())) {
         $stage->setPeriod(trim($stage->getPeriod()));
         if (strlen($stage->getPeriod()) < 1) {
             $stage->setPeriod(null);
         }
     }
     if (is_null($stage->getPeriod())) {
         $stageErrs["period"] = "field.error.empty";
     } else {
         if (!is_numeric($stage->getPeriod())) {
             $stageErrs["period"] = "field.error.notnumber";
         } else {
             if ($stage->getPeriod() < 1) {
                 $stageErrs["period"] = "field.error.morethenzero";
             }
         }
     }
     $stage->setDelay($this->context->getRequestAttr("delay"));
     if (!is_null($stage->getDelay())) {
         $stage->setDelay(trim($stage->getDelay()));
         if (strlen($stage->getDelay()) < 1) {
             $stage->setDelay(null);
         }
     }
     if (is_null($stage->getDelay())) {
         $stageErrs["delay"] = "field.error.empty";
     } else {
         if (!is_numeric($stage->getDelay())) {
             $stageErrs["delay"] = "field.error.notnumber";
         } else {
             if ($stage->getDelay() < 0) {
                 $stageErrs["delay"] = "field.error.morethenzero";
             }
         }
     }
     $stage->setEnded_stage($this->context->getRequestAttr("ended_stege"));
     $stage->setCancel_customer($this->context->getRequestAttr("cancel_customer"));
     $stage->setEnded_stage_pid("");
     $stage->setCancel_customer_pid("");
     if ($stage->getEnded_stage() != "0" && !is_null($stage->getEnded_stage())) {
         $endedStagePid = $this->context->getRequestAttr("ended_stage_pid");
         if (is_null($endedStagePid) || count($endedStagePid) == 0) {
             $stageErrs["ended_stege_pid"] = "field.error.needselectproject";
         } else {
             $stage->setEnded_stage_pid(implode(",", $endedStagePid));
         }
     }
     if ($stage->getCancel_customer() != "0" && !is_null($stage->getCancel_customer())) {
         $cancelCustomerPid = $this->context->getRequestAttr("cancel_customer_pid");
         if (is_null($cancelCustomerPid) || count($cancelCustomerPid) == "0") {
             $stageErrs["cancel_customer_pid"] = "field.error.needselectproject";
         } else {
             $stage->setCancel_customer_pid(implode(",", $cancelCustomerPid));
         }
     }
     $last = $this->context->getRequestAttr("last");
     $stage->setLast($last == 1 ? true : false);
     $send = $this->context->getRequestAttr("send");
     $stage->setSend($send == 1 ? true : false);
     $stage->setApi(null);
     $stage->setCampaign(null);
     if ($stage->isSend()) {
         $stage->setApi($this->context->getRequestAttr("api"));
         if (!is_null($stage->getApi())) {
             $stage->setApi(trim($stage->getApi()));
             if (strlen($stage->getApi()) < 1) {
                 $stage->setApi(null);
             }
         }
         if (is_null($stage->getApi())) {
             $stageErrs["api"] = "field.error.empty";
         }
         $stage->setCampaign($this->context->getRequestAttr("campaign"));
         if (!is_null($stage->getCampaign())) {
             $stage->setCampaign(trim($stage->getCampaign()));
             if (strlen($stage->getCampaign()) < 1) {
                 $stage->setCampaign(null);
             }
         }
         if (is_null($stage->getCampaign())) {
             $stageErrs["campaign"] = "field.error.empty";
         } else {
             if (preg_match('/\\s/', $stage->getCampaign())) {
                 $stageErrs["campaign"] = "Netinkamas pavadinimas. Negalimi tarpai";
             }
         }
     }
     $send_mail = $this->context->getRequestAttr("send_mail");
     $stage->setSend_mail($send_mail == 1 ? true : false);
     if ($stage->isSend_mail()) {
         $leader = $this->context->getRequestAttr("leader");
         $partner = $this->context->getRequestAttr("partner");
         $customer = $this->context->getRequestAttr("customer");
         $sendTo = (!is_null($leader) ? "leader" : "") . (!is_null($partner) ? "partner" : "") . (!is_null($customer) ? "customer" : "");
         $stage->setSend_to($sendTo);
         if (!is_null($stage->getSend_to())) {
             $stage->setSend_to(trim($stage->getSend_to()));
             if (strlen($stage->getSend_to()) < 1) {
                 $stage->setSend_to(null);
             }
         }
         if (is_null($stage->getSend_to())) {
             $stageErrs["send_to"] = "field.error.needatleestone";
         }
         $stage->setSend_from($this->context->getRequestAttr("send_from"));
         if (!is_null($stage->getSend_from())) {
             $stage->setSend_from(trim($stage->getSend_from()));
             if (strlen($stage->getSend_from()) < 1) {
                 $stage->setSend_from(null);
             }
         }
         if (is_null($stage->getSend_from())) {
             $stageErrs["send_from"] = "field.error.empty";
         } else {
             if (!$this->validateEmail($stage->getSend_from())) {
                 $stageErrs["send_to"] = "field.error.wrongemail";
             }
         }
         $stage->setSend_subject($this->context->getRequestAttr("send_subject"));
         if (!is_null($stage->getSend_subject())) {
             $stage->setSend_subject(trim($stage->getSend_subject()));
             if (strlen($stage->getSend_subject()) < 1) {
                 $stage->setSend_subject(null);
             }
         }
         if (is_null($stage->getSend_subject())) {
             $stageErrs["send_subject"] = "field.error.empty";
         }
         $stage->setSend_text($this->context->getRequestAttr("send_text"));
         if (!is_null($stage->getSend_text())) {
             $stage->setSend_text(trim($stage->getSend_text()));
             if (strlen($stage->getSend_text()) < 1) {
                 $stage->setSend_text(null);
             }
         }
         if (is_null($stage->getSend_text())) {
             $stageErrs["send_text"] = "field.error.empty";
         }
     }
     //$stageErrs["apisss"]=1;
     $timeZone = new DateTimeZone("Europe/Vilnius");
     $time = new DateTime("now", $timeZone);
     $stage->setR_date($time->format("Y-m-d H:i:s"));
     $stage->setR_user($currentUser->getId());
     $this->context->setFlashScopeAttr("stage", $stage);
     $this->context->setFlashScopeAttr("stageErrs", $stageErrs);
     $projectID = $stage->getPid();
     if (!$this->setStoreProject($projectID, "stageProject")) {
         $this->cancelStageEdit();
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     if (count($stageErrs) >= 1) {
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $store = $this->storeStage($stage);
     if (!$store) {
         if (!is_null($backUrl)) {
             header("Location: " . $backUrl);
             return true;
         }
         return false;
     }
     $this->cancelStageEdit();
     if (!is_null($backUrl)) {
         header("Location: " . $backUrl);
         return true;
     }
     return false;
 }