/** * Modify a client saved in the database. * * @param Client $client * @return integer */ public function editClient(Client $client) { $mcrypt = new MCrypt(); $sql = "UPDATE client \n\t\t\tSET id_client = '" . $client->getIdClient() . "', client_name = '" . replaceCharacters($client->getClientName()) . "', agent = '" . replaceCharacters($client->getAgent()) . "', address = '" . replaceCharacters($client->getAddress()) . "', phone = '" . $client->getPhone() . "', email = '" . $client->getEmail() . "', website = '" . $client->getWebsite() . "', user = '******', password = '******' WHERE id_client = '" . $client->getIdClient() . "'"; return DB::query($sql); }
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; }
<?php require 'connect.php'; require 'client/Book.php'; require 'client/Employee.php'; require 'client/Client.php'; require 'client/Hire.php'; $book = new Book(1, 'Metro', 'Gluhowsky', 'apokalipsa'); $employee = new Employee(2, 'Jan', 'Kowalski', '*****@*****.**', 'Warszawa'); $client = new Client(3, 'Anna', 'Kowalska', '*****@*****.**'); $hire = new Hire(4, $book, $employee, '2015-12-15', '2015-12-26'); $query = "INSERT INTO `book` (`id`, `title`, `author`, `type`) VALUES ('1', '{$book->getTitle()}', '{$book->getAuthor()}', '{$book->getType()}')"; $libraryRequest = mysql_query($query); $query = "INSERT INTO `employee` (`id`, `firstname`, `lastname`, `email`, `city`) VALUES ('2', '{$employee->getfirstName()}', '{$employee->getlastName()}', '{$employee->getEmail()}', '{$employee->getCity()}')"; $libraryRequest = mysql_query($query); $query = "INSERT INTO `client` (`id`, `firstname`, `lastname`, `email`) VALUES ('3', '{$client->getfirstName()}', '{$client->getlastName()}', '{$client->getEmail()}')"; $libraryRequest = mysql_query($query); $query = "INSERT INTO `hire` (`id`, `id_client`, `id_book`, `id_employee`, `hiredate`, `returndate`) VALUES ('4', '{$client->getId()}', '{$book->getId()}', '{$employee->getId()}', '{$hire->getHireDate()}', '{$hire->getReturnDate()}')"; var_dump($query); $libraryRequest = mysql_query($query);
function formatClientInfo(Client $client, $needBreak = false) { $sep = $needBreak ? "<br />" : " "; return htmlspecialchars($client->getName()) . $sep . htmlspecialchars($client->getEmail()) . $sep . htmlspecialchars($client->getTelephone()); }
<div id="container"> <div id="sidebar" style="float:left;width:15%;"> <?php include 'sidebar.php'; ?> </div> <div id="content" style="float:right;width:85%;"> <table> <tr><td style="width:200px;">Name</td> <td style="width:200px;">Phone</td> <td style="width:200px;">Email</td> <td style="width:200px;">Website</td> <td style="width:200px;">Action</td> </tr> <?php for ($i = 0; $i < sizeof($mClientList); $i++) { $mClient = new Client($mClientList[$i]); echo "<tr>"; echo "<td>" . $mClient->getName() . "</td>"; echo "<td>" . $mClient->getPhone() . "</td>"; echo "<td>" . $mClient->getEmail() . "</td>"; echo "<td>" . $mClient->getWebsite() . "</td>"; echo "<td><input type='submit' value='Assign'><input type='submit' value='Track'></td>"; echo "</tr>"; } ?> </table> <div> </div> </body>
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; }
/** * Renderize the view. * * @return null */ public function render(Client $client) { ?> <!-- JQUERY UI --> <link type="text/css" rel="stylesheet" href="<?php echo APP_PATH; ?> /css/jquery-ui.min.css"> <link type="text/css" rel="stylesheet" href="<?php echo APP_PATH; ?> /css/jquery-ui.theme.min.css"> <script type="text/javascript" src="<?php echo APP_PATH; ?> /js/jquery-ui.min.js"></script> <script type="text/javascript"> $(function(){ $("#date_suscription").datepicker({dateFormat: "yy-mm-dd"}); }); </script> <p> <?php echo REQUIRED_FIELDS_TEXT; ?> </p> <form action="<?php echo $this->generateURL('client', 'edit', $client->getIdClient()); ?> " method="post"> <fieldset> <div class="row"> <div class="col-md-6"> <div> <label for="category"> Categoría <small>(*)</small> </label> <select name="category" required> <option value=""> Seleccionar </option> <?php if ($client->getCategory() === "Socio") { ?> <option value="Socio" selected> Socio </option> <option value="Suscriptor"> Suscriptor </option> <?php } else { if ($client->getCategory() === "Suscriptor") { ?> <option value="Socio"> Socio </option> <option value="Suscriptor" selected> Suscriptor </option> <?php } else { ?> <option value="Socio"> Socio </option> <option value="Suscriptor"> Suscriptor </option> <?php } } ?> </select> </div> <div> <label for="client_name"> Nombre <small>(*)</small> </label> <input name="client_name" type="text" required value="<?php echo $client->getClientName(); ?> " /> </div> <div> <label for="agent"> Representante <small>(*)</small> </label> <input name="agent" type="text" required value="<?php echo $client->getAgent(); ?> " /> </div> <div> <label for="address"> Dirección <small>(*)</small> </label> <input name="address" type="text" required value="<?php echo $client->getAddress(); ?> " /> </div> <div> <label for="phone"> Teléfono <small>(*)</small> </label> <input name="phone" type="tel" required value="<?php echo $client->getPhone(); ?> " /> </div> </div> <div class="col-md-6"> <div> <label for="email"> Correo electrónico <small>(*)</small> </label> <input name="email" type="email" required value="<?php echo $client->getEmail(); ?> " /> </div> <div> <label for="website"> Sitio web </label> <input name="website" type="url" value="<?php echo $client->getWebsite(); ?> " /> </div> <div> <label for="user"> Usuario <small>(*)</small> </label> <input name="user" type="text" required value="<?php echo $client->getUser(); ?> " /> </div> <div> <label for="email"> Contraseña <small>(*)</small> </label> <input name="password" type="text" required /> </div> <div> <label for="date_suscription"> Fecha Suscripción <small>(*)</small> </label> <input id="date_suscription" name="date_suscription" type="text" required value="<?php echo $client->getDateSuscription(); ?> "/> </div> <div> <input type="submit" value="Modificar" /> </div> </div> </div> </fieldset> </form> <?php }
/** * Renderize the view. * * @return null */ public function render(Client $client) { ?> <p> <?php echo REQUIRED_FIELDS_TEXT; ?> </p> <form action="<?php echo $this->generateURL('client', 'edit', $client->getIdClient()); ?> " method="post"> <fieldset> <div class="row"> <div class="col-md-6"> <div> <label for="client_name"> Nombre <small>(*)</small> </label> <input name="client_name" type="text" required value="<?php echo $client->getClientName(); ?> " /> </div> <div> <label for="agent"> Representante <small>(*)</small> </label> <input name="agent" type="text" required value="<?php echo $client->getAgent(); ?> " /> </div> <div> <label for="address"> Dirección <small>(*)</small> </label> <input name="address" type="text" required value="<?php echo $client->getAddress(); ?> " /> </div> <div> <label for="phone"> Teléfono <small>(*)</small> </label> <input name="phone" type="tel" required value="<?php echo $client->getPhone(); ?> " /> </div> </div> <div class="col-md-6"> <div> <label for="email"> Correo electrónico <small>(*)</small> </label> <input name="email" type="email" required value="<?php echo $client->getEmail(); ?> " /> </div> <div> <label for="website"> Sitio web </label> <input name="website" type="url" value="<?php echo $client->getWebsite(); ?> " /> </div> <div> <label for="user"> Usuario <small>(*)</small> </label> <input name="user" type="text" required value="<?php echo $client->getUser(); ?> " /> </div> <div> <label for="email"> Contraseña <small>(*)</small> </label> <input name="password" type="text" required value="<?php echo $client->getPassword(); ?> " /> </div> <div> <input type="submit" value="Modificar" /> </div> </div> </div> </fieldset> </form> <?php }