Beispiel #1
0
$numbers = DB::cleanQuery($sql);
if ($numbers->getRows()) {
    echo <<<_END
    <h3>Please select default units for your site:</h3>
    <form action="process.php" method="POST" class="nomand nocheck form-horizontal">
        <input type="hidden" name="page" value={$include}>
_END;
    $defUnits = $trial->getUser()->getCentreUnits();
    foreach ($numbers->rows as $row) {
        echo "<div class=\"control-group\">";
        echo "<label class=\"control-label\" for=\"{$row->number}\">{$row->name}: </label>";
        echo "<div class=\"controls\">";
        echo "<select class=\"input-small\" id=\"{$row->number}\" name=\"{$row->number}\">";
        $sql = "SELECT id, unit FROM units \n            WHERE number = ? \n            ORDER BY unitorder";
        $pA = array('s', $row->number);
        $units = DB::cleanQuery($sql, $pA);
        foreach ($units->rows as $unitRow) {
            echo "<option value={$unitRow->id}";
            if ($defUnits && $defUnits[$row->number]['units_id'] == $unitRow->id) {
                echo " selected=\"selected\" ";
            }
            echo ">{$unitRow->unit}</option>";
        }
        echo "</select>";
        echo "</div>";
        echo "</div>";
    }
    $_SESSION['csrfToken'] = $token = base64_encode(openssl_random_pseudo_bytes(32));
    echo "<input type=\"hidden\" name=\"csrfToken\" value=\"{$token}\"/>";
    echo "<div class=\"form-actions\">\n\t\t<button type=\"submit\" class=\"btn btn-primary\">Submit</button>\n\n\t\t</div>";
    echo "</form>";
Beispiel #2
0
<?php

echo "<p class=\"lead\">Lock your site for data entry</p>";
$centre = new Centre($user->getCentre());
if (!$trial->checkComplete('siteinfo', $centre)) {
    echo "<p>";
    echo "Please go to Admin -> Site Information and complete the one-time hospital information form there, this must be done before you can submit your completed data.";
    echo "</p>";
} else {
    $sql = "SELECT count(link.id) AS numCRF\n\t\t\t\tFROM link \n\t\t\t\t\tINNER JOIN core ON link.core_id = core.id \n\t\t\t\t\tINNER JOIN centre ON core.centre_id = centre.id  \n                WHERE centre.id = ?  \n                    AND signed = 0";
    $pA = array('i', $centre->getID());
    $result = DB::cleanQuery($sql, $pA);
    if ($result->numCRF > 0) {
        echo "<p>You have {$result->numCRF} CRFs submitted by your site that have not been signed off as complete and correct.  Please use the Worklist tabs above to find these CRFs and sign them off.</p>";
    } else {
        $sql = "SELECT count( link.id ) as numFlagged\n\t\t\t\tFROM link \n\t\t\t\t\tINNER JOIN core ON link.core_id = core.id \n\t\t\t\t\tINNER JOIN centre ON core.centre_id = centre.id \n                    LEFT JOIN flag ON link.id = flag.link_id \n                WHERE centre.id = ? \n                    AND signed = 1\n                    AND (( link.comment IS NOT NULL AND link.comment != '' ) \n                    OR flag.id IS NOT NULL )";
        $pA = array('i', $centre->getID());
        $result = DB::query($sql, $pA);
        echo "<p>All the CRFs for your hospital have been signed";
        if ($result->numFlagged) {
            echo " (though {$result->numFlagged} still have flags suggesting incomplete or incorrect data)";
        }
        echo ". If all your patients have been entered, you can now lock your data.</p>";
        echo "<p>By clicking 'Agree and lock data', you are confirming that the \n            data for your hospital are complete and correct. Once you do this \n            your data will be locked and you will not be able to make further \n            changes. You will then be able to download and check your data on a \n            spreadsheet. If you identify any errors after your data have been \n            locked then we have an SOP for unlocking sites available \n                <a href=\"/docs/ISOSSiteUnlock.pdf\" target=\"_blank\">here</a>.\n            You can contact us with any queries at \n                <a href=\"mailto:data@isos.org.uk?subject=Data unlocking enquiry\">data@isos.org.uk</a>.</p>";
        echo "<form action=\"process.php\" method=\"POST\">";
        echo "<input type=\"hidden\" name=\"lockSite\" value=\"1\"/>";
        echo "<input type=\"hidden\" name=\"page\" value=\"locksite\"/>";
        $_SESSION['csrfToken'] = $token = base64_encode(openssl_random_pseudo_bytes(32));
        echo "<input type=\"hidden\" name=\"csrfToken\" value=\"{$token}\"/>";
        echo "<div class=\"form-actions\">\n            <button type=\"submit\" class=\"btn btn-primary\">Agree and Lock data</button>\n            </div>";
        echo "</form>";
Beispiel #3
0
                $form->addButton('Lock site', array('btn-warning', 'hidden'));
            }
        }
        $form->addCancelButton('index.php?page=sitereg');
        echo $form->writeHTML();
    }
}
if ($showSearch) {
    $sql = "SELECT count(case when privilege_id <= 10 then 1 else NULL end) AS localAdmin,\n                count(user.id) as regUsers,\n                centre.id as centreID, centre.name as centreName, country.name as countryName, datalock FROM centre\n            LEFT JOIN user ON centre_id = centre.id\n            LEFT JOIN country ON country_id = country.id";
    if ($user->isRegional()) {
        $sql .= " WHERE centre.country_id = ? GROUP BY centre.id";
        $pA = array('i', $user->getCountry());
        $userSearch = DB::cleanQuery($sql, $pA);
    } else {
        $sql .= " GROUP BY centre.id";
        $userSearch = DB::cleanQuery($sql);
    }
    if (isset($_GET['country']) && isset($_GET['status'])) {
        $showArr = array();
        switch ($_GET['status']) {
            case 1:
                $sql = "SELECT COUNT( user.id ) as numUsers, centre.id as id FROM centre LEFT JOIN user ON user.centre_id = centre.id LEFt JOIN country ON country.id = centre.country_id WHERE country.name = ? GROUP BY centre.id HAVING numUsers = 0";
                $pA = array('s', $_GET['country']);
                $centreSearch = DB::query($sql, $pA);
                $showArr = $centreSearch->getArray('id');
                break;
            case 2:
                $sql = "SELECT count(DISTINCT core.centre_id) AS numCRFs, centre.id as id FROM centre LEFT JOIN core ON core.centre_id = centre.id RIGHT JOIN user ON centre.id = user.centre_id LEFT JOIN country ON centre.country_id = country.id WHERE country.name = ? GROUP BY centre.id HAVING numCRFs = 0";
                $pA = array('s', $_GET['country']);
                $centreSearch = DB::query($sql, $pA);
                $showArr = $centreSearch->getArray('id');
Beispiel #4
0
 public function getFormFields($page = NULL, $multiple = false, $multiSuffix = NULL, $record = NULL)
 {
     if (!$page) {
         $page = $this->getPage();
     }
     Timer::start();
     $fields = array();
     if ($multiple) {
         if (!isset($this->multipleFormFields[$page])) {
             $sql = "SELECT id, labelText, fieldName, defaultVal,\n\t\t\t\t  \ttype, toggle, mandatory, multiple, size, class \t\t \n\t\t\t\t  FROM formFields  \n\t\t\t\t  WHERE pages_name=?  \n                  AND multiple = ?\n\t\t\t\t  ORDER BY entryorder";
             $pA = array('ss', $page, $multiple);
             $result = $this->multipleFormFields[$page] = DB::query($sql, $pA);
         } else {
             $result = $this->multipleFormFields[$page];
         }
     } else {
         if (!isset($this->formFields[$page])) {
             $sql = "SELECT formFields.id, IFNULL( label_text, formFields.labelText ) as label_text, fieldName, defaultVal,\n\t\t\t\t\ttype, toggle, mandatory, size, class, readonly\t\t \n\t\t\t\tFROM formFields\n\t\t\t\tLEFT JOIN formFields_labels\n\t\t\t\tON formFields.id = formFields_id AND language_code = '{$this->getFormLanguage()}' \n\t\t\t\tWHERE pages_name=? \n                AND multiple IS NULL\t\t\t\n\t\t\t\tORDER BY entryorder";
             $pA = array('s', $page);
             $result = $this->formFields[$page] = DB::query($sql, $pA);
         } else {
             $result = $this->formFields[$page];
         }
     }
     $excluded = $this->getExcludedFormFields($record);
     $counter = 1;
     foreach ($result->rows as $row) {
         if (in_array($row->id, $excluded)) {
             continue;
         }
         if (!$row->fieldName) {
             $row->fieldName = $counter++;
         }
         if ($row->type != 'data') {
             $name = "{$page}-{$row->fieldName}";
             // Prepends the name with the current page
         } else {
             $name = $row->fieldName;
         }
         if ($multiSuffix) {
             $name .= "_{$multiSuffix}";
         }
         $fields[$name]['type'] = $row->type;
         $fields[$name]['label'] = $row->label_text;
         $fields[$name]['toggle'] = $row->toggle;
         $fields[$name]['mandatory'] = $row->mandatory;
         $fields[$name]['default'] = $row->defaultVal;
         $fields[$name]['size'] = $row->size;
         $fields[$name]['readonly'] = $row->readonly;
         $fields[$name]['class'] = $row->class;
         if ($row->type == 'checkbox' || $row->type == 'radio') {
             // Add checkbox options from validation table
             if (!isset($this->checkboxRadioOptions[$row->id])) {
                 $options = array();
                 $sql = "SELECT value, special FROM formVal \n                    WHERE formFields_id = ?\n                    AND operator = 'IN LIST'\n                    ORDER BY groupNum";
                 $pA = array('i', $row->id);
                 $getTable = DB::cleanQuery($sql, $pA);
                 if ($getTable->getRows() > 1) {
                     $sql = "SELECT a.option_value, IFNULL( b.option_text, a.option_text ) as option_text \n\t\t\t\t\tFROM {$getTable->value} a \n\t\t\t\t\tLEFT JOIN {$getTable->value} b \n\t\t\t\t\tON a.option_value = b.option_value AND b.language_code = '{$this->language}' ";
                     if ($getTable->value != 'centre') {
                         $sql .= "WHERE a.language_code = 'en' ";
                     }
                     $sql .= "ORDER BY a.option_order";
                     $result = DB::query($sql);
                     foreach ($result->rows as $row) {
                         $this->addOption($row->option_text, $row->option_value);
                     }
                 } else {
                     $sql = "SELECT a.option_value, IFNULL( b.option_text, a.option_text ) as option_text \n\t\t\t\t\t\tFROM {$getTable->value} a \n\t\t\t\t\t\tLEFT JOIN {$getTable->value} b \n\t\t\t\t\t\tON a.option_value = b.option_value AND b.language_code = '{$this->language}' \n\t\t\t\t\t\tWHERE a.language_code = 'en' ORDER BY a.option_order";
                     $ref = DB::query($sql);
                 }
                 foreach ($ref->rows as $rRow) {
                     $options[$rRow->option_value] = $rRow->option_text;
                 }
                 $fields[$name]['options'] = $this->checkboxRadioOptions[$row->id] = $options;
             } else {
                 $fields[$name]['options'] = $this->checkboxRadioOptions[$row->id];
             }
         }
         if ($row->type == 'select') {
             // Adds select options from table
             if (!isset($this->selectOptions[$row->id])) {
                 $options = array();
                 $sql = "SELECT value, special, operator FROM formVal \n                    WHERE formFields_id = ? ORDER BY groupNum";
                 $pA = array('i', $row->id);
                 $getTable = DB::query($sql, $pA);
                 foreach ($getTable->rows as $vRow) {
                     $filterNum = NULL;
                     switch ($vRow->operator) {
                         case 'IN LIST':
                             if ($vRow->special == 'FILTER') {
                                 $filter = explode('-', $vRow->value);
                                 $filterNum = $this->record->getField($filter[0], $filter[1]);
                             } else {
                                 $refTable = DB::clean($vRow->value);
                                 $order = $vRow->special == 'ALPHA' ? 'name' : 'option_order';
                                 if (strpos($refTable, '-')) {
                                     $filterBy = explode('-', $refTable);
                                     $refTable = $filterBy[0];
                                     $filterTable = $filterBy[1];
                                 } else {
                                     $filterTable = NULL;
                                 }
                                 $sql = "SELECT a.option_value, IFNULL( b.option_text, a.option_text ) as option_text\n\t\t\t\t\t\t\t\t\tFROM {$refTable} a \n\t\t\t\t\t\t\t\t\tLEFT JOIN {$refTable} b\n\t\t\t\t\t\t\t\t\tON a.option_value = b.option_value AND b.language_code = '{$this->language}' ";
                                 if ($filterTable) {
                                     $sql .= "RIGHT JOIN {$filterTable} c\n                                            ON a.id = c.{$refTable}_id ";
                                 }
                                 if ($refTable != 'centre') {
                                     $sql .= "WHERE a.language_code = 'en' ";
                                 }
                                 $sql .= "ORDER BY a.{$order}";
                                 $ref = DB::query($sql);
                             }
                             break;
                         case 'NOT IN LIST':
                             $excludeArr = explode(',', $vRow->value);
                             break;
                         default:
                             if ($vRow->special == 'REFERENCE') {
                                 $valArr = explode('-', $vRow->value);
                                 if ($valArr[0] == 'user') {
                                     $valNum = $_SESSION['user']->get($valArr[1]);
                                 }
                                 foreach ($ref->rows as $key => $rRow) {
                                     if ($valNum > $rRow->option_value) {
                                         unset($ref->rows[$key]);
                                     }
                                 }
                             }
                             break;
                     }
                 }
                 foreach ($ref->rows as $rRow) {
                     if (isset($excludeArr) && in_array($rRow->option_value, $excludeArr)) {
                         continue;
                     }
                     if ($row->fieldName == 'centre_id') {
                         // If making fields for centre_id and user is only allowed local then restrict to local
                         if (isset($this->user) && $this->user->isLocal() && $rRow->option_value != $this->user->getCentre()) {
                             continue;
                         } else {
                             $options[$rRow->option_value] = $rRow->option_text;
                         }
                     } else {
                         if (isset($filterNum)) {
                             $filterRef = explode(',', $rRow->filterRef);
                             if (!in_array($filterNum, $filterRef)) {
                                 continue;
                             }
                             $options[$rRow->option_value] = $rRow->option_text;
                         } else {
                             $options[$rRow->option_value] = $rRow->option_text;
                         }
                     }
                 }
                 $fields[$name]['options'] = $this->selectOptions[$row->id] = $options;
             } else {
                 $fields[$name]['options'] = $this->selectOptions[$row->id];
             }
         }
         if ($row->type == 'number') {
             // Gets potential units for units table
             $unit = array();
             $sql = "SELECT unit, conversion, decimal_places FROM units WHERE number = ? ORDER BY unitorder";
             $pA = array('s', $row->fieldName);
             $ref = DB::query($sql, $pA);
             foreach ($ref->rows as $rRow) {
                 $unit[$rRow->unit]['conversion'] = $rRow->conversion;
                 $unit[$rRow->unit]['decimals'] = $rRow->decimal_places;
             }
             $fields[$name]['unit'] = $unit;
         }
         if ($row->type == 'multiple') {
             $page = substr($name, 0, strpos($name, "-"));
             // Split out class and name from input field
             $name = substr($name, strpos($name, "-") + 1);
             $data = $this->record->getData($page);
             $number = $data->get($name);
             if ($number) {
                 for ($i = 0; $i < $number; $i++) {
                     $fields = array_merge($fields, $this->getFormFields($page, $name, $i + 1));
                 }
             }
         }
     }
     $getFormFields = $fields;
     $this->fields = $getFormFields;
     return $getFormFields;
 }