static function process()
 {
     $loginModel = Session_Controller::getLoginContext();
     $client = new Vtiger_WSClient($loginModel->getURL());
     $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
     if ($login) {
         echo "<div class='alert alert-info'>Many of these queries are specific to the coreBOS application they were created for and will fail on your install. You should just need to tweek the IDs and conditions to get them working.</div>";
         foreach (QueryExamples_Controller::$queries as $query) {
             echo '<b>' . $query . '</b><br>';
             $result = $client->doQuery($query);
             QueryExamples_Controller::showresult($result);
         }
     } else {
         echo "<div class='alert alert-danger'><strong>ERROR:</strong> Login failure!</div>";
     }
 }
Ejemplo n.º 2
0
 static function process($request)
 {
     if (isset($request['q'])) {
         $query = $request['q'];
     } else {
         $query = '';
     }
     $escapedQuery = $query;
     echo "\n\t\t<form method='POST' action='index.php' onsubmit='return validateForm(this);'>\n\t\t\t<table cellpadding='0' cellspacing='1'>\n\t\t\t\t<tr valign=top>\n\t\t\t\t\t<td>Try a query like: select firstname, lastname from Leads order by firstname desc limit 0,2; or <a href='index.php?action=queryExamples'>have a look at our tests and examples.</a><br/><textarea name='q' rows='5' cols='80'>{$escapedQuery}</textarea></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><input type='submit' value='Execute &raquo;' name='__submitButton' class='btn btn-primary btn-large'></td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</form>";
     if (!empty($query)) {
         $loginModel = Session_Controller::getLoginContext();
         $client = new Vtiger_WSClient($loginModel->getURL());
         $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
         if ($login) {
             $result = $client->doQuery($query);
             if (is_array($result)) {
                 if (count($result) == 0) {
                     echo "<div class='alert alert-info'><strong>No results found!</strong></div>";
                 } else {
                     echo "<table cellpadding='3' cellspacing='0' class='table table-striped small'>";
                     $columns = $client->getResultColumns($result);
                     echo "<tr>";
                     foreach ($columns as $column) {
                         echo sprintf("<th nowrap='nowrap'>%s</th>", $column);
                     }
                     echo "</tr>";
                     foreach ($result as $row) {
                         echo "<tr>";
                         foreach ($row as $k => $v) {
                             if ($v === '') {
                                 $v = '&nbsp;';
                             }
                             echo sprintf("<td nowrap='nowrap'>%s</td>", $v);
                         }
                         echo "</tr>";
                     }
                     echo "</table>";
                 }
             } else {
                 $lastError = $client->lastError();
                 echo "<div class='alert alert-danger'><strong>ERROR:</strong> " . $lastError['message'] . "</div>";
             }
         } else {
             echo "<div class='alert alert-danger'><strong>ERROR:</strong> Login failure!</div>";
         }
     }
 }