public function testSetGet() { $client = new Client(); $id = 'test_id'; $client->setId($id); $this->assertEquals($id, $client->getId(), 'Unable to setup id!'); $name = 'test_name'; $client->setName($name); $this->assertEquals($name, $client->getName(), 'Unable to setup name!'); $title = 'test_title'; $client->setTitle($title); $this->assertEquals($title, $client->getTitle(), 'Unable to setup title!'); $userAttributes = ['attribute1' => 'value1', 'attribute2' => 'value2']; $client->setUserAttributes($userAttributes); $this->assertEquals($userAttributes, $client->getUserAttributes(), 'Unable to setup user attributes!'); $normalizeUserAttributeMap = ['name' => 'some/name', 'email' => 'some/email']; $client->setNormalizeUserAttributeMap($normalizeUserAttributeMap); $this->assertEquals($normalizeUserAttributeMap, $client->getNormalizeUserAttributeMap(), 'Unable to setup normalize user attribute map!'); $viewOptions = ['option1' => 'value1', 'option2' => 'value2']; $client->setViewOptions($viewOptions); $this->assertEquals($viewOptions, $client->getViewOptions(), 'Unable to setup view options!'); }
public function createClients10() { $client10 = new Client(); $client10->setId('10'); $client10->setNome('NELSON MANDELA'); $client10->setTelefone('1010-1010'); $client10->setEndereco('RUA DO CLIENTE 10'); $client10->setEmail('*****@*****.**'); $client10->setCpf('999.999.999-10'); $client10->setTipo('PF'); return $client10; }
function findClientOrder($projectID, $projectView = false) { $result = $this->database->query($this->buildClientOrderQuery($projectID, $projectView)); if (!is_null($result->getError())) { return $result->getError(); } $clients = array(); while ($row = $result->fetchRow()) { $client = new Client(); $value = $row[0]; $client->setId($value); array_push($clients, $client); } return $clients; }
function actionSaveClient($currentProject) { $backUrl = $this->context->getFlowScopeAttr("backUrl"); $projectID = $this->context->getRequestAttr("projectID"); $edit = $this->context->getRequestAttr("edit"); $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(777); $client->setActive(true); $this->context->setFlashScopeAttr("createClient", $client); $this->context->setFlashScopeAttr("clientErrs", $clientErrs); $this->context->setFlashScopeAttr("projectID", $projectID); 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 && $edit == 0) { $eventHistory = new EventHistory(); $eventHistory->setPid($client->getPid()); $eventHistory->setCid($client->getId()); $eventHistory->setR_date($client->getR_date()); $eventHistory->setDescription("Sukurtas partnerio"); $this->storeEventHistory($eventHistory); } $this->cancelClientCreate(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; }
function actionSaveClient($currentUser) { $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); } } $periodicalID = $this->context->getRequestAttr("periodicalid"); $periodical = $this->context->getRequestAttr("periodCustomer"); $client->setPeriodical($periodical == 1 ? true : false); $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()); $client->setActive(true); if (!is_null($periodicalID) && !$client->isPeriodical()) { $this->clientPeriodicalDao->delete($periodicalID); $this->clientDaol->resetPeriodicalClients($periodicalID); $client->setPeriodicalid(0); } if ($client->isPeriodical()) { $clientPeriodical = new ClientPeriodical(); $clientPeriodical->setId($periodicalID); $clientPeriodical->setPid($client->getPid()); $clientPeriodical->setName($client->getName()); $clientPeriodical->setEmail($client->getEmail()); $clientPeriodical->setCustomer($client->getCustomer()); $clientPeriodical->setTelephone($client->getTelephone()); $clientPeriodical->setComment($client->getComment()); $clientPeriodical->setR_date($time->format("Y-m-d H:i:s")); $clientPeriodical->setR_user($currentUser->getId()); $clientPeriodical->setPeriod_type($this->context->getRequestAttr("period_type")); $clientPeriodical->setWeek_day($this->context->getRequestAttr("week_day")); $clientPeriodical->setMonth_day($this->context->getRequestAttr("month_day")); $clientPeriodical->setHour($this->context->getRequestAttr("hour")); } else { $clientPeriodical = new ClientPeriodical(); } $this->context->setFlashScopeAttr("client", $client); $this->context->setFlashScopeAttr("clientPeriodical", $clientPeriodical); $this->context->setFlashScopeAttr("clientErrs", $clientErrs); $projectID = $client->getPid(); if (!$this->setStoreProject($projectID, "clientProject")) { $this->cancelClientEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } if (count($clientErrs) >= 1) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $insert = false; if (is_null($client->getId())) { $insert = true; } $periodicalStore = false; $clientStore = false; // Jei klientas periodinis - sukuriam periodini klienta atskirai if ($client->isPeriodical()) { $storePeriodical = $this->storeClientPeriodical($clientPeriodical); if (!$storePeriodical) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $client->setPeriodicalid($clientPeriodical->getId()); $periodicalStore = true; } if ($client->isPeriodical() && !$insert || !$client->isPeriodical()) { $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 projekto vadovo"); $this->storeEventHistory($eventHistory); } $clientStore = true; } if ($periodicalStore && !$clientStore) { $this->context->setRequestScopeAttr("success", "Periodinis klientas suskurtas sÄ—kmingai."); } $this->cancelClientEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; }