public function testAddNewRootItem()
 {
     $research = new Research();
     $this->assertEquals(null, $research->itemTree);
     $aRootItem = $research->getNewItem("A Root Item");
     $this->assertEquals(1, $aRootItem->id);
     $research->addAsRootItem($aRootItem);
     $this->assertEquals(1, $research->itemTree->id);
     $aNewRootItem = $research->getNewItem("A New Root Item");
     $this->assertEquals(2, $aNewRootItem->id);
     $research->addAsRootItem($aNewRootItem);
     $this->assertEquals(2, $research->itemTree->id);
     $this->assertEquals(1, count($research->itemTree->items));
 }
 public function research()
 {
     if ($_POST) {
         Research::setSearch();
         $this->redirect('/tools/research/');
     } else {
         View::render('tools/research/search', Research::getSearch());
     }
 }
Exemple #3
0
        $fields = '';
        $values = '';
        $sql = '';
        $comma = '';
        $round = 0;
        foreach ($phpArray as $key => $value) {
            $comma = ',';
            if ($round == $sizeOfArray) {
                $comma = '';
            }
            $fields .= $key . '' . $comma;
            $values .= '\'' . trim($value) . '\'' . $comma;
            $round++;
        }
        $sql = 'insert into ' . $table . ' (id,' . $fields . ',date) values (NULL,' . $values . ',NOW());';
        return parent::query($sql, $rows, $num_rows, $last_id);
    }
    public function get()
    {
        $sql = 'select * from research where 1;';
        parent::query($sql, $rows, $num_rows, $last_id);
        print_r($rows);
    }
}
$rs = new Research();
$result = $rs->set($json, 'research');
if ($result === true) {
    echo "success";
} else {
    echo $result;
}
Exemple #4
0
 public function savestudy()
 {
     try {
         # check login
         if (!Check::digits($rid = $_SESSION['user']['researcher_id'])) {
             throw new Exception('invalid researcher id!');
         }
         # check input values
         foreach ($_POST as $pfield => $pvalue) {
             $_POST[$pfield] = trim($pvalue);
         }
         if (empty($_POST['study_title'])) {
             throw new Exception('need a study title!');
         }
         if (!Check::isdate($_POST['startdate'], false)) {
             throw new Exception('bad startdate format should be YYYY-MM-DD');
         }
         if (!Check::isdate($_POST['enddate'], false)) {
             throw new Exception('bad enddate format should be YYYY-MM-DD');
         }
         list($_POST['startdate'], $_POST['enddate']) = Check::order($_POST['startdate'], $_POST['enddate']);
         # first create or save the study
         $s = new Study();
         if (Check::digits($_POST['study_id'], $empty = false)) {
             $study_id = $_POST['study_id'];
             unset($_POST['study_id']);
             if ($s->upd($study_id, $_POST) === false) {
                 throw new Exception($s->err());
             }
         } else {
             if ($s->ins($_POST) === false) {
                 throw new Exception($s->err());
             }
             $study_id = $s->getid();
         }
         # associate the study with the researcher
         $r = new Research();
         if ($r->ins(array('study_id' => $study_id, 'researcher_id' => $rid)) === false) {
             throw new Exception($r->err());
         }
         View::assign('study_id', $study_id);
         return 'study.tpl';
     } catch (Exception $e) {
         $this->err($e);
         View::assign('error', $this->error);
         return 'error.tpl';
     }
 }
Exemple #5
0
 /**
  * @param $where
  * @return bool
  */
 public static function getResearch($where)
 {
     $dado = Database::ReadOne('research', '*', $where);
     if (!$dado) {
         return false;
     }
     $research = new Research();
     $research->setId($dado['ID_RESEARCH']);
     $research->setConsiderAdventista($dado['CONSIDER_ADVENTISTA']);
     $research->setIasdBack($dado['IASD_BACK']);
     $research->setIasdLocal($dado['IASD_LOCAL']);
     $research->setIasdVisit($dado['IASD_VISIT']);
     $research->setKnowAdra($dado['KNOW_ADRA']);
     $research->setKnowAventureiros($dado['KNOW_AVENTUREIRO']);
     $research->setKnowDesbravadores($dado['KNOW_DESBRAVADOR']);
     $research->setKnowIasd($dado['KNOW_IASD']);
     $research->setKnowSignification($dado['KNOW_SIGNIFICATION']);
     $research->setOpnionAdventista($dado['OPNION_ADVENTISTA']);
     $research->setOpnionIasd($dado['OPNION_IASD']);
     $research->setOpnionProjects($dado['OPNION_PROJECTS']);
     $research->setOpnionReason($dado['OPNION_REASON']);
     $research->setTimeFe($dado['TIME_FE']);
     $research->setKnowTv($dado['KNOW_TVNOVOTEMPO']);
     $research->setProgramTv($dado['PROGRAM_TV']);
     $research->setDateResearch($dado['INSERT_DATE']);
     $log = Database::ReadOne('login', '*', 'WHERE id_login = '******'ID_LOGIN']);
     $person = Person::getPerson('WHERE id_person = ' . $log['ID_PERSON']);
     $research->setPerson($person);
     return $research;
 }
Exemple #6
0
 public static function getResident($where)
 {
     $dado = Database::ReadOne("resident r, person p", "r.*, p.*", "WHERE p.id_person = r.id_person {$where}");
     if (!$dado) {
         return '';
     }
     $resident = new Resident();
     $resident->setId($dado['ID_PERSON']);
     $resident->setName($dado['NAME_PERSON']);
     $resident->setEmail($dado['EMAIL']);
     $resident->setAge($dado['AGE']);
     $resident->setSex($dado['SEX']);
     $resident->setPhone($dado['PHONE']);
     $resident->setOperator($dado['OPERATOR']);
     $resident->setMaritalStatus($dado['MARITAL_STATUS']);
     $resident->setChildren($dado['CHILDREN']);
     $resident->setDateInsert($dado['INSERT_DATE']);
     $resident->setNumberResident($dado['NUMBER_RESIDENT_HOUSE']);
     $resident->setHouseFather($dado['HOUSEFATHER']);
     $resident->setCognateAdventista($dado['COGNATE_ADVENTISTA']);
     $religion = Religion::getReligion("WHERE id_religion = " . $dado['ID_RELIGION']);
     $resident->setReligion($religion);
     $address = Address::getAddress("AND id_address = " . $dado['ID_ADDRESS']);
     $resident->setAddress($address);
     $research = Research::getResearch('WHERE id_resident = ' . $dado['ID_PERSON']);
     $resident->setResearch($research);
     return $resident;
 }
Exemple #7
0
                                        <th>Idade</th>
                                        <th>Ação</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php 
if (Resident::getResidents() != '') {
    foreach (Resident::getResidents() as $res) {
        echo '<tr>';
        echo '<td>' . $res->getId() . '</td>';
        echo '<td>' . '<a class="modalResident" data-id="' . $res->getId() . '" >' . $res->getName() . '</a>' . '</td>';
        echo '<td>' . $res->getEmail() . '</td>';
        echo '<td>' . $res->getReligion()->getName() . '</td>';
        echo '<td>' . $res->getAge() . '</td>';
        echo '<td>' . '<a href="forms.php?p=altMorador&cod=' . $res->getId() . '"><i class="icon-pencil"></i>Editar</a>' . '  |  ';
        if (Research::existResearch($res->getId())) {
            echo '<i class="icon icon-check" style="color: green"></i> Pesquisa Realizada';
        } else {
            echo '<a href="forms.php?p=cadPesquisa&cod=' . $res->getId() . '"><i class="icon-edit" style="color: red"></i>Realizar Pesquisa</a>';
        }
        echo '</td>';
        echo '</tr>';
    }
}
?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>