public function ejectInvoice() { $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($this->query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_BOTH); //execute the second query $stmt1 = $link->prepare($this->query_row); $stmt1->execute(); $row1 = $stmt1->fetch(PDO::FETCH_BOTH); //convert the material to an array and iterate $codes = explode("*", $row1["stock_code"]); $desc = explode("*", $row1["item_description"]); $qty = explode("*", $row1["qty"]); $rate = explode("*", $row1["unit_price"]); $value = explode("*", $row1["value"]); //print_r($materials); for ($i = 0; $i < sizeof($codes) - 1; $i++) { $this->invoiceRows .= ' <tr class="item-row" id="itemID"><td>' . ($i + 1) . '</td> <td class="item-name"><div class="delete-wpr"><textarea data-role="none" class="item_name">' . $codes[$i] . '</textarea></div></td> <td class="description"><textarea disabled data-role="none" class="item_description">' . html_entity_decode($desc[$i]) . '</textarea></td> <td><span disabled class="cost" data-role="none" id="re-unitCost"><del>N</del>' . $rate[$i] . '</span></td> <td><textarea disabled class="qty" data-role="none" id="re-quantity">' . $qty[$i] . '</textarea></td> <td><span class="price" ><del>N</del>' . $value[$i] . '</span></td> </tr>'; } return array("invoiceDate" => $row["invoiceDate"], "jobid" => $row["jobNumber"], "invoiceNumber" => $row["invoiceNumber"], "subtotal" => $row["subTotal"], "total" => $row["total"], "invoiceRows" => $this->invoiceRows, "amountPaid" => $row["amountPaid"], "balanceDue" => $row["balanceDue"], "vat" => $row["vat"], "labourCost" => $row["labourcost"], "customer" => $row["customerTitle"]); }
/** * * @return \Doctrine\DBAL\Connection */ function getConnection() { if (!$this->connection) { $this->connection = Connection::getConnection(); } return $this->connection; }
public function __call($name, $arguments) { $method = $this->controller->getMethod($name); if ($method) { $connection = Connection::getConnection(); return $connection->call($name, $arguments); } }
public static function addCliente($cliente) { $connection = Connection::getConnection(); $sql = "INSERT INTO clientes (cpf, nome, cidades_id) VALUES ({$cliente->cpf}, '{$cliente->nome}', {$cliente->cidades_id})"; $result = mysqli_query($connection, $sql); $novoCliente = ClienteDAO::getClienteByCPF($cliente->cpf); return $novoCliente; }
public function prpare() { $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($this->query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_BOTH); return array("dategenerated" => $row['date'], "location" => html_entity_decode($row["location"]), "reportcode" => $row["reportcode"], "maintype" => $row["maintype"]); }
public function contarTokensCanjeados($user_id) { $connection = Connection::getConnection(); $user_id = (int) $user_id; $sql_query = "SELECT count(*) AS total FROM token WHERE user_id={$user_id}"; $result = $connection->query($sql_query); $data = $result->fetch_assoc(); $c = (int) $data['total']; return $c; }
public function validate_persona_id($persona_id) { Connection::getConnection()->connect(); $resp = ContrPack1::getInstance()->getPersona($persona_id); if ($resp[0] != null) { Connection::getConnection()->close(); return true; } Connection::getConnection()->close(); return "({$persona_id}) no es una persona válida"; }
function addToDatabase($rname, $rsize, $rtype, $rname_usr, $rtype_usr, $rdesc, $extension, $rprio) { $auth = new Authenticate(); $con = new Connection(); $link = $con->getConnection(); $query = "INSERT INTO `resources`(`ID`, `name`,`rNameUsr`,`rsize`, `rtype`, `format`, `doc_by`,`user_r_type`,`rDescription`,`rprio`, `when`, `approved`) VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?)"; //$query = "INSERT INTO `categories`(`cat_id`,`cat_name`,`cat_description`,`cat_by`) VALUES (NULL,?,?,?)"; $stmt = $link->prepare($query); $stmt->execute(array($rname, $rname_usr, $rsize, $rtype, $extension, $auth->getFullName($_SESSION['user_id']), $rtype_usr, $rdesc, $rprio, date("Y-m-d H:i:m", time()), 0)); $stmt = null; return TRUE; }
public function __construct() { $this->istok = DBHelper::getIstok(Connection::getConnection()); $this->obj = Creator::getObject($this->istok["name"]); $this->columneNames = $this->istok["colnames"]; $this->data = $this->istok["colvalues"]; //print_r($this->istok); //$this->test(); //print_r($this->obj); echo PHP_EOL; //print_r($this->columneNames);echo PHP_EOL; //print_r($this->data);echo PHP_EOL; }
public function verify() { $query = "UPDATE `users` SET `verified`= 1 WHERE `ID` = '{$this->id}'"; $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($query); if ($stmt->execute()) { return true; } else { return false; } }
public static function listarSorteos() { $sorteos = array(); $connection = Connection::getConnection(); $sql_query = "SELECT id, fecha, ganador, nombre FROM sorteo;"; $result = $connection->query($sql_query); if ($result->num_rows > 0) { while ($row = $result->fetch_object()) { $sorteos[] = $row; } } return $sorteos; }
public function configureEValuation($user_id, $qCnt, $qCat, $qStl, $qTim) { $this->userid = $user_id; $this->qCount = $qCnt; $this->qCategory = $qCat; $this->qStyle = $qStl; $this->qTime = $qTim; //connnect to database and store all the values $con = new Connection(); $link = $con->getConnection(); $query = "INSERT INTO `evaluation`(`ID`, `user_id`, `qCount`, `qCategory`, `qStyle`, `qTime`) " . "VALUES (NULL,?,?,?,?,?)"; $stmt = $link->prepare($query); $stmt->execute(array($this->userid, $this->qCount, $this->qCategory, $this->qStyle, $this->qTime)); }
private function getUserStatus($id) { $sql = "SELECT `user_status` FROM `users` WHERE `ID` =?"; $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($sql); $stmt->execute(array($id)); $result = $stmt->fetch(PDO::FETCH_BOTH); if ($result["user_status"] == 1) { return "Active"; } else { return "Disabled"; } }
public function update($id, $matricule, $nom, $prenoms, $telephone, $cellulaire, $ville, $quatier, $responsable, $statut) { $db = parent::getConnection(); $sql = 'UPDATE agent SET matricule = :matricule,nom = :nom,prenoms = :prenoms,telephone = :telephone,cellulaire = :cellulaire,ville = :ville,quatier = :quatier,responsable = :responsable,statut = :statut WHERE id = :id'; $query = $db->prepare($sql); $query->execute(array('matricule' => $matricule, 'nom' => $nom, 'prenoms' => $prenoms, 'telephone' => $telephone, 'cellulaire' => $cellulaire, 'ville' => $ville, 'quatier' => $quatier, 'responsable' => $responsable, 'statut' => $statut, 'id' => $id)); if ($query) { echo "ok"; } else { echo "ko"; } }
public static function getByName($name) { $db = Connection::getConnection(); $obj = new User(); $stmt = $db->prepare("SELECT * FROM {$obj->tableName} WHERE userName = :name"); $stmt->bindParam('name', $name); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); if (!$row) { return null; } $obj->fromArray($row); return $obj; }
public function __construct(array $options = null, PDO $database = null) { if (count($options)) { $this->setOptions($options); } $this->config['adapter'] = "mysql"; $this->config['hostname'] = "localhost"; $this->config['dbname'] = "cew"; $this->config['user'] = "******"; $this->config['password'] = ""; $connection = new Connection(); $this->database = $connection->getConnection($this->config); if (method_exists($this, $_GET['action'])) { call_user_func(array($this, $_GET['action'])); } }
public function selectAll() { $resultArrayWithUsers = array(); $db = Connection::getConnection(); $rows = $db->query("SELECT * FROM `users`"); $count = 0; while ($row = $rows->fetch(PDO::FETCH_ASSOC)) { $user = new User(); $user->setLogin($row[User::$LOGIN]); $user->setPassword($row[User::$PASSWORD]); $user->setUserId($row[User::$USER_ID]); $resultArrayWithUsers[$count] = $user; $count++; } Connection::close(); return $resultArrayWithUsers; }
public function showInvoice() { $tabelHead = "<div>\n<table border='1' data-role='none' class='reporttable ui-responsive'><thead><tr> \n <th class='no_border hide' colspan='3'>Actions</th>\n <th>S/N</th>\n <th>Invoice Number</th>\n <th>Job Number</th>\n <th>Job Type</th>\n <th>Invoice Date</th>\n <th>Customer</th>\n <th>Labour Cost</th>\n <th>VAT</th>\n <th>Balance Due</th>\n <th>Amount Paid</th> \n <th>Stock Code</th>\n <th>Description</th>\n <th>Unit Cost</th>\n <th>Qty</th>\n <th>Price</th>\n <th>Subtotal</th>\n <th>Total</th> \n </tr></thead><tbody>"; //execute the query here $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($this->query); $stmt->execute(); $tableRows = ""; $counter = 1; while ($row = $stmt->fetch(PDO::FETCH_BOTH)) { $tableRows .= $this->populateReportTable($counter, $row); $counter++; } $tableFooter = "<tr class='last_row'>\n\t\t\t<td class='no_border hide'></td>\n\t\t\t<td class='no_border hide'></td>\n\t\t\t<td class='no_border hide'></td>\n\t\t\t<td>Total</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\t\t\n\t\t\t</tr><tbody></table>"; return $tabelHead . $tableRows . $tableFooter . '</div><p class="center hide"><button data-role="none" id="print_report" class="report_button">Print Invoice Report</button> ' . '<button data-role="none" id="save_report" class="report_button">Export Invoice Report</button></p>'; }
public function showReport() { $tabelHead = "<div>\n<table border='1' data-role='none' class='reporttable ui-responsive'><thead><tr> \n <th class='no_border hide noExl' colspan='3'>Actions</th>\n <th>S/N</th>\n <th>Job Id</th>\n <th>Location</th>\n <th>Call Date</th>\n <th>R. Code</th>\n <th>Main. Type</th>\n <th>Unit Type</th>\n <th>Unit Id</th> \n <th>F. Code</th>\n <th>RP. Code</th>\n <th>R. C. Code</th>\n <th>Date Completed</th>\n <th>Hours</th>\n <th>Material Used</th>\n <th>Status</th>\n <th>Material Cost</th>\n <th>Labour Cost</th>\n <th>Total</th>\n </tr></thead><tbody>"; //execute the query here $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($this->query); $stmt->execute(); $tableRows = ""; $counter = 1; while ($row = $stmt->fetch(PDO::FETCH_BOTH)) { $tableRows .= $this->populateReportTable($counter, $row); $counter++; } $this->totalCost += $this->totalLabourCost + $this->totalMaterialCost; $tableFooter = "<tr class='last_row'>\n\t\t\t<td class='no_border hide noExl'></td>\n\t\t\t<td class='no_border hide noExl'></td>\t\t\t\n\t\t\t<td class='no_border hide noExl'></td>\n\t\t\t<td>Total</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>" . $this->totalhours . "</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>" . $this->totalMaterialCost . "</td>\n\t\t\t<td>" . $this->totalLabourCost . "</td>\n\t\t\t<td>" . $this->totalCost . "</td>\n\t\t\t</tr><tbody></table>"; return $tabelHead . $tableRows . $tableFooter . '</div><p class="center hide"><button data-role="none" id="print_report" class="report_button">Print Report</button>' . ' <button data-role="none" id="export_report" class="report_button">Export Report</button></p>'; }
public function showPPMReport() { $tabelHead = "\n\t<table border='1' class='ppmtable' data-role='tabele'><thead><tr> \n <th>S/N</th>\n <th>Job_Id</th>\n <th>Location</th>\n <th>No.Of Houses</th>\n <th>Frequency</th>\n <th>Rate /Yr</th>\n <th>Expected Rate /Yr</th>\n <th>Actual Rate /Yr</th>\n <th>Expected Status (%)</th>\n <th>Current Status(%)</th>\n <th>Last Inspection</th>\n <th>Next Inspection</th>\n <th>Calls Generated</th>\n <th>Calls Completed</th>\n <th>Field Inspections</th>\n <th>No Accsess Resolved</th>\n <th>No Access</th>\n <th>Remarkes</th></tr></thead><tbody>"; //execute the query here $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($this->query); $stmt->execute(); $tableRows = ""; $counter = 1; while ($row = $stmt->fetch(PDO::FETCH_BOTH)) { $tableRows .= $this->populatePPMTable($counter, $row); $counter++; } $stmt = null; $tableFooter = "<tr id='last_row'><td>Total</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>All Locations</td>\n\t\t\t<td>{$this->total_num_of_houses}</td>\n\t\t\t<td>Monthly</td>\n\t\t\t<td>{$this->total_expected}</td>\n\t\t\t<td>{$this->expected_rate}</td>\n\t\t\t<td>{$this->total_num_of_houses_serviced}</td>\n\t\t\t<td>" . $this->core->getStatusTillDate($this->total_expected, $this->expected_rate) . " % </td>\n\t\t\t<td>" . $this->core->getcurrentStatus($this->total_num_of_houses_serviced, $this->total_expected, "January") . " % </td>\n\t\t\t<td>Nill</td>\n\t\t\t<td>Nill</td>\n\t\t\t<td>{$this->total_calls_gen}</td>\n\t\t\t<td>{$this->total_calls_comp}</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>N/A</td>\n\t\t\t<td>{$this->no_access_loc}</td>\n\t\t\t<td>N/A</td>\n\t\t\t</tr><tbody></table>"; return $tabelHead . $tableRows . $tableFooter; }
public static function getAllUser($usuarioLogin) { $connection = Connection::getConnection(); //Pega ID do usuário $sql = "SELECT id FROM TF_usuarios WHERE login LIKE '{$usuarioLogin}'"; $result = mysqli_query($connection, $sql); $id = mysqli_fetch_object($result)->id; $sql = "SELECT * FROM TF_categorias WHERE TF_usuarios_id={$id}"; $result = mysqli_query($connection, $sql); $categorias = array(); while ($categoria = mysqli_fetch_object($result)) { if ($categoria != null) { $categorias[] = $categoria; } } return $categorias; // $novoConta = ContaDAO::getContaByID(mysqli_insert_id($connection)); // return $novoConta; }
public static function autentica($login, $senha) { $connection = Connection::getConnection(); $sql = "SELECT * FROM TF_usuarios"; $result = mysqli_query($connection, $sql); $usuarios = array(); while ($usuario = mysqli_fetch_object($result)) { if ($usuario != null) { $usuarios[] = $usuario; } } foreach ($usuarios as $u) { if ($u->login == $login) { if ($u->senha == $senha) { return true; } } } return false; }
/** * Получить список тем * * @param int $page * @return array */ public function getThreadList($page = 1) { $db = Connection::getConnection(); $offset = intval(($page - 1) * $this->itemsPerPage); $limit = intval($this->itemsPerPage); $query = <<<SQL SELECT t.*, a.userName as authorName, c.postId as lastPostId, c.cnt as postNumber FROM threads t INNER JOIN users a ON (t.userId = a.userId) INNER JOIN (SELECT threadId, max(postId) as postId, count(*) as cnt FROM posts GROUP BY threadId) c ON (c.threadId = t.threadId) LIMIT {$offset}, {$limit} SQL; $stmt = $db->query($query); $threads = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $thread = new Thread(); $thread->fromArray($row); $threads[] = $thread; } return $threads; }
public function displayCourse($tag) { $reply = ""; $query = "SELECT * FROM `course_contents` WHERE `course_code` = '{$tag}'"; $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_BOTH); $reply .= '<a href="#demo-mail"> <p class="topic"><strong>Course Title: ' . $row["course_code"] . '</strong></p> <p class="topic"><strong>CoureName: ' . $row["course_name"] . '</strong></p> <p class="topic"><strong>Unit Load: ' . $row["course_unit"] . '</strong></p> <p class="topic"><strong>course Content:</strong></p> <p>' . $row["course_content"] . '</p> <p class="ui-li-aside"><strong>Level:' . $row["course_level"] . '</strong></p> <p class="topic"><strong>ENG 102</strong></p> <p class="topic"><strong>Hours:' . $row["course_hour"] . '</strong></p> </a>'; return $reply; }
public function insert() { $data = $this->toArray(); print_r($data); $fields = array_keys($this->fieldMap); unset($fields[array_search($this->keyField, $fields)]); $fieldHolders = []; foreach ($fields as $field) { $fieldHolders[] = ":{$field}"; } $db = Connection::getConnection(); $sql = "INSERT INTO {$this->tableName} (" . implode(', ', $fields) . ") " . "VALUES (" . implode(', ', $fieldHolders) . ")"; echo $sql; $stmt = $db->prepare($sql); foreach ($fields as $field) { $prop = $this->fieldMap[$field]; $stmt->bindParam(":{$field}", $this->{$prop}); } $stmt->execute(); $keyField = $this->keyField; $keyProp = $this->fieldMap[$keyField]; $this->{$keyProp} = $db->lastInsertId(); }
public function getAllVideoResources() { //global $auth; $reply = ""; $con = new Connection(); $link = $con->getConnection(); $query = "SELECT * FROM `resources` WHERE `format`= 'mp4' OR `format`= '3gp' OR `format`= 'xvid' OR `format`='flv'"; $stmt = $link->prepare($query); $stmt->execute(); $i = 0; while ($row = $stmt->fetch(PDO::FETCH_BOTH)) { $i++; $reply .= '<li><a href="../usr/uploads/resources/' . $row["name"] . '" data-ajax="false"> <img src="_assets/img/apple.png" class="ui-li-thumb"> <h2> Click To Download</h2> <p>' . $row['rNameUsr'] . '</p> <p class="ui-li-aside">' . $this->getFileType($row['format']) . '</p> </a></li>'; } $stmt = null; $reply .= "<script type='text/javascript'>\$('#page').trigger('create');</script>"; return $reply; }
private function initInvoice() { $core = new Core(); //connnect t data base $query = "SELECT * FROM `ubnkrecords` WHERE `ID` = '{$this->jobidkey}' OR `jobid` = '{$this->jobidkey}'"; $con = new Connection(); $link = $con->getConnection(); $stmt = $link->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_BOTH); $this->invoiceStatus = $row["invoiceStatus"]; $this->invoiceNumber = $core->generateInvoiceNumber(); $this->jobNumber = $row['jobid']; $this->quantity = 1; $this->labour += $row["labourcost"]; $this->customer = $row["customer"]; //convert the material to an array and iterate $materials = explode("+", $row["material"]); //print_r($materials); for ($i = 0; $i < sizeof($materials); $i++) { $details = $core->getAllStockDetails($materials[$i]); $this->stockRows .= '<tr class="item-row" id="item' . $i . '"><td>' . ($i + 1) . '</td>' . '<td class="item-name"><div class="delete-wpr"><textarea data-role="none" class="item_name" >' . $details['part_number'] . '</textarea></div></td>' . '<td class="description"><textarea disabled data-role="none" class="item_description">' . $details['description'] . '</textarea></td>' . '<td><span disabled class="cost" data-role="none" id="unitCost' . $i . '"><del>N</del>' . $details['price'] . '</span></td>' . '<td><textarea disabled class="qty" data-role="none" id="quantity' . $i . '">1</textarea></td>' . '<td><span class="price" >0.00</span></td></tr>'; } }
<?php session_start(); require_once "../models/connection.php"; require_once "../models/dao.php"; if (!isset($_SESSION["Admin_Id"])) { header("location:../views/login.php"); } if ($_SESSION["level"] != 2) { header("location:../views/login.php"); } $con = new Connection(); $connection = $con->getConnection(); $DAOobj = new Dao($connection); ?> <html> <head> <title> BOTOVERIFY QA | VIEW ADMIN</title> <link href="../boot/css/bootstrap.min.css" rel="stylesheet" /> <script type="text/javascript" src="../boot/js/bootstrap.min.js"></script> </head> <body> <br/><br/> <div class="col-md-3 col-md-offset-4"> <h4><b>REGISTERED QA ADMINISTRATORS </b></h4> </div> <br/><br/><br/> <div class="col-md-8 col-md-offset-2"> <table class="table table-hover"> <tr class="active">
public static function update($values, $params) { $db = Connection::getConnection(); $result = $db->update($values, $params, 'layout'); return $result; }
$name = $_POST['name'] or die('nom de grup no informat'); $age = $_POST['age'] or die('edat no informada'); $date_start = $_POST['date_start'] or die('data inici informada'); $date_end = $_POST['date_end'] or die('data fi informada'); $location = $_POST['location'] or die('ubicació no informada'); $observations = isset($_POST['observations']) ? $_POST['observations'] : ''; $comments = isset($_POST['comments']) ? $_POST['comments'] : ''; $group = array('id' => $id, 'name' => $name, 'age' => $age, 'date_start' => $date_start, 'date_end' => $date_end, 'location' => $location, 'comments' => $comments, 'observations' => $observations); } /* echo 'action: '.$action; echo '$group'; print_r($group); */ $c = new Connection(); $conn = $c->getConnection(); $groupDAO = new GroupDAO($conn); switch ($action) { case 'new': $insert_id = $groupDAO->create($group); break; case 'update': $groupDAO->update($group); break; case 'delete': //echo 'delete dao'.$id; exit; $groupDAO->delete($id); break; } if ($isAjax) { echo json_encode($response);