/**
  * Connect to the database
  * 
  * @return bool false on failure / mysqli MySQLi object instance on success
  */
 public function connect()
 {
     // Try and connect to the database
     // if (!isset(self::$connection)) {
     // Load configuration as an array. Use the actual location of your configuration file
     //    self::$connection = new mysqli('localhost', 'root', 'root', 'servicioslegales');
     //  }
     self::$connection = mysqli_init();
     if (!self::$connection) {
         die('mysqli_init failed');
     }
     if (!self::$connection->options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0')) {
         die('Setting MYSQLI_INIT_COMMAND failed');
     }
     if (!self::$connection->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5)) {
         die('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed');
     }
     if (!self::$connection->real_connect('localhost', 'root', 'root', 'servicioslegales')) {
         die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
     }
     // If connection was not successful, handle the error
     if (self::$connection === false) {
         // Handle error - notify administrator, log to a file, show an error screen, etc.
         return false;
     }
     return self::$connection;
 }
Esempio n. 2
0
 public static function closeConnection()
 {
     self::$connection = null;
     return true;
 }
                                        
                                    </td>
                                                <td class="col-md-6">
                                        <div class="panel panel-default">
                                            <div class="panel-heading">Requisitos Actuales</div>
                                            <div class="panel-body">' . $res1 . '
                                            </div>
                                        </div>
                                        
                                    </td> </tr>
                                    </table>';
}
if (isset($_POST['ReqSerVer'])) {
    //Disponibles
    $db = new DB2();
    $db1 = new DB2();
    $var1 = $_POST['ReqSerVer'];
    $result = $db->select("CALL RequisitosNO_Servicio(" . $var1 . ");");
    $res = "<table class=\"table table-striped\">";
    $res .= "<thead><th>idRequisito</th><th>Nombre</th><th></th></thead>";
    foreach ($result as $row) {
        $res .= "<tr><td class=\"col-md-2\">" . $row['idRequisito'] . "</td>";
        $res .= "<td class=\"col-md-4\">" . $row['Nombre'] . "</td>";
        $res .= "<td class=\"col-md-1\"><button type=\"submit\" name=\"Edit\" class=\"btn btn-default btn-xs\" onclick=\"Agregar(" . $row['idRequisito'] . "," . $var1 . ");\"> Agregar </button></td>";
        $res .= '</tr>';
    }
    $res .= "</table>";
    $result1 = $db1->select("CALL Requisitos_Servicio(" . $var1 . ");");
    $res1 = "<table class=\"table table-striped\">";
    $res1 .= "<thead><th>idRequisito</th><th>Nombre</th><th></th></thead>";
    foreach ($result1 as $row1) {
Esempio n. 4
0
 public function repeats()
 {
     PHPWS_Core::initCoreClass('DB2.php');
     $end_date = (int) $_GET['date'];
     $start_date = mktime(0, 0, 0, date('m', $end_date) - 1, date('d', $end_date));
     $this->title = sprintf(dgettext('checkin', 'Multiple visits made between %s and %s'), strftime('%b %e', $start_date), strftime('%b %e', $end_date));
     $limit = 2;
     if (isset($_GET['visit_query'])) {
         $limit = (int) $_GET['visit_query'];
     }
     if ($limit > 10 || $limit < 2) {
         $limit = 2;
     }
     try {
         $sub = new DB2();
         $t1 = $sub->addTable('checkin_visitor', 't1');
         $t1_id = $t1->addField('id');
         $exp = $sub->addExpression('COUNT(' . $t1_id->__toString() . ')', 'num');
         $t1_fn = $t1->addField('firstname');
         $t1_ln = $t1->addField('lastname');
         $t1->addWhere('arrival_time', $start_date, '>=');
         $t1->addWhere('arrival_time', $end_date, '<=');
         $t1->addOrderBy('lastname');
         $sub->setGroupBy(array($t1_fn, $t1_ln));
         $db2 = new DB2();
         $t2 = $db2->addSubSelect($sub, 't2');
         $t2->addWhere($exp, $limit, '>=');
         $result = $db2->select();
     } catch (PEAR_Exception $e) {
         $this->content = dgettext('checkin', 'Sorry an error occurred.');
         $db2->logError($e);
         return;
     }
     if (empty($result)) {
         $this->content = dgettext('checkin', 'No repeat visits within the last month.');
         return;
     }
     $form = new PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'checkin');
     $form->addHidden('aop', 'repeats');
     $form->addHidden('date', $end_date);
     $form->addSelect('visit_query', array(2 => 2, 4 => 4, 6 => 6, 8 => 8, 10 => 10));
     $form->setMatch('visit_query', $limit);
     $form->addSubmit('go', dgettext('checkin', 'Visits greater to or equal to'));
     $tpl = $form->getTemplate();
     foreach ($result as $visit) {
         $rows['NAME'] = PHPWS_Text::moduleLink(sprintf('%s, %s', $visit['lastname'], $visit['firstname']), 'checkin', array('aop' => 'visitor_report', 'vis_id' => $visit['id']));
         $rows['VISITS'] = $visit['num'];
         $tpl['visitors'][] = $rows;
     }
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'repeats.tpl');
 }