Esempio n. 1
0
 public function fill_from_post($view)
 {
     $subformat = new DomainEntity($this->subformat_name);
     $subformat->vocab_number = $_GET['subid'];
     $form = generate_formarray($this->subformat_name, $view);
     form_objects($form, $subformat);
     return $subformat;
 }
Esempio n. 2
0
 /**
  * act_edit_document Action to edit document details  
  * 
  * @access public
  * @return void
  */
 public function act_edit_document()
 {
     $this->document_form = document_form('edit');
     if (isset($_POST['update']) || isset($_POST['yes']) || isset($_POST['no'])) {
         $status = shn_form_validate($this->document_form);
         if (!$status) {
             return;
         }
         $this->fileExist = false;
         $type = null;
         $uri = shn_files_store('choose_file_upload', null, $type);
         //"http://test";
         if ($uri == null) {
             $uri = '';
         }
         if (isset($_POST['yes'])) {
             $this->supporting_docs->uri = $_SESSION['uri'];
             $this->supporting_docs->Save();
             shnMessageQueue::addInformation(_t('THE_OLD_FILE_ATTACHMENT_WAS_UPDATED_WITH_THE_NEW_FILE_ATTACHMENT_'));
         } else {
             if (isset($_POST['no'])) {
             } else {
                 if ($this->supporting_docs->uri != null && $uri != '') {
                     $this->fileExist = true;
                     $_SESSION['uri'] = $uri;
                     $_SESSION['type'] = $type;
                     return;
                 } else {
                     if ($this->supporting_docs->uri != null && $uri == '') {
                     } else {
                         $this->supporting_docs->uri = $uri;
                         $this->supporting_docs->Save();
                     }
                 }
             }
         }
         if ($_SESSION['type'] != null) {
             $type = $_SESSION['type'];
         }
         form_objects($this->document_form, $this->supporting_docs_meta);
         $this->supporting_docs_meta->format = $type;
         $this->supporting_docs_meta->SaveAll();
         unset($_SESSION['type']);
         set_redirect_header('docu', 'view_document', null);
         exit;
     }
 }
Esempio n. 3
0
function get_data_array()
{
    global $dataFile, $dataCols, $fields, $lists, $docsCount, $biosCount;
    if (($handle = fopen($dataFile, "r")) === FALSE) {
        return array();
    }
    $results = array();
    $j = 0;
    while (($cols = fgetcsv($handle, 0, "\t")) !== FALSE) {
        $glData = array();
        $row = array();
        if ($cols && $cols[1]) {
            //var_dump($cols);exit;
            foreach ($cols as $key => $val) {
                $val = trim($val, '"');
                $val = trim($val);
                $row[$key] = $val;
                $entityField = $dataCols[$key];
                if ($entityField) {
                    $ent = $entityField["ent"];
                    $list_code = $entityField['list_code'];
                    $type = $entityField['field_type'];
                    $mlt = trim($entityField['is_repeat']) == 'Y' || trim($entityField['is_repeat']) == 'y' ? true : false;
                    if ($list_code == 39) {
                        if ($val == "M") {
                            $val = "Hombre";
                        } elseif ($val == "F") {
                            $val = "Mujer";
                        }
                    }
                    if ($list_code && !$lists[$list_code]) {
                        $options = array();
                        $data_array = MtFieldWrapper::getMTList($list_code);
                        $size = count($data_array);
                        for ($i = 0; $i < $size; $i++) {
                            $options[$data_array[$i]['vocab_number']] = strtolower($data_array[$i]['label']);
                        }
                        $lists[$list_code] = $options;
                    }
                    if ($list_code) {
                        if ($mlt) {
                            $val2 = explode(";", $val);
                            $val = array();
                            foreach ($val2 as $v) {
                                $v = trim($v);
                                $vocab_number = array_search(strtolower($v), $lists[$list_code]);
                                if ($vocab_number) {
                                    $val[] = $vocab_number;
                                }
                            }
                        } else {
                            $vocab_number = array_search(strtolower($val), $lists[$list_code]);
                            if ($vocab_number) {
                                $val = $vocab_number;
                            } else {
                                $val = null;
                            }
                        }
                    }
                    if ($type == "date") {
                        if ($val) {
                            $d = date_create_from_format("m/d/Y", $val);
                            if ($d) {
                                $val = date_format($d, 'Y-m-d');
                            } else {
                                $val = null;
                            }
                        } else {
                            $val = null;
                        }
                    } elseif ($type == "location") {
                        $val2 = explode(",", $val);
                        //$row[$entityField['field_name'] . "_latitude"] = -floatval($val2[0]);
                        //$row[$entityField['field_name'] . "_longitude"] = -floatval($val2[1]);
                        $glData[$ent][$entityField['field_name'] . "_latitude"] = -floatval($val2[0]);
                        $glData[$ent][$entityField['field_name'] . "_longitude"] = -floatval($val2[1]);
                        $val = null;
                    } elseif ($type == "radio") {
                        if ($val == "NO" || $val == "no") {
                            $val = "n";
                        } elseif ($val == "SÍ" || $val == "sí") {
                            $val = "y";
                        } else {
                            $val = null;
                        }
                    }
                    if (!is_null($val)) {
                        //$row[$entityField['field_name']] = $val;
                        $glData[$ent][$entityField['field_name']] = $val;
                    }
                }
            }
            if (!$glData['act']['ubicacto']) {
                $v = $row[25];
                $vocab_number = array_search(strtolower($v), $lists[71]);
                if ($vocab_number) {
                    $glData['act']['ubicacto'] = $vocab_number;
                }
            }
            if (!$glData['act']['ubicacto']) {
                $v = $row[24];
                $vocab_number = array_search(strtolower($v), $lists[71]);
                if ($vocab_number) {
                    $glData['act']['ubicacto'] = $vocab_number;
                }
            }
            $browse = new Browse();
            $rows = $browse->ExecuteQuery("select event_record_number as id from event where event_title='" . $glData['event']['event_title'] . "'");
            if ($rows && $rows[0]['id']) {
                $event = new Event();
                $event->LoadFromRecordNumber($rows[0]['id']);
            } else {
                $form = event_form('new');
                $event = new Event();
                $event->event_record_number = shn_create_uuid('event');
                form_objects($form, $event, $glData['event']);
                $event->SaveAll();
            }
            $browse = new Browse();
            $person = null;
            if ($glData['person']['person_name'] != "NN") {
                $rows = $browse->ExecuteQuery("select person_record_number as id from person where person_name='" . $glData['person']['person_name'] . "' \n\t\t\t\tand other_names='" . $glData['person']['other_names'] . "' ");
                if ($rows && $rows[0]['id']) {
                    $person = new Person();
                    $person->LoadFromRecordNumber($rows[0]['id']);
                }
            }
            if (!$person) {
                $person_form = person_form('new');
                $person = new Person();
                form_objects($person_form, $person, $glData['person']);
                $person->deceased = $person->deceased == 'on' ? 'y' : 'n';
                if (isset($person->number_of_persons_in_group) && !$person->number_of_persons_in_group) {
                    $person->number_of_persons_in_group = Null;
                }
                if (isset($person->dependants) && !$person->dependants) {
                    $person->dependants = Null;
                }
                $person->SaveAll();
            }
            $victim = $person;
            $act_form = act_form('new');
            $act = new Act();
            $act->act_record_number = shn_create_uuid('act');
            $glData['act']['victim'] = $victim->person_record_number;
            form_objects($act_form, $act, $glData['act']);
            $act->event = $event->event_record_number;
            $act->SaveAll();
            if ($glData['perpetrator']['person_name']) {
                $browse = new Browse();
                $rows = $browse->ExecuteQuery("select person_record_number as id from person where person_name='" . $glData['perpetrator']['person_name'] . "' ");
                if ($rows && $rows[0]['id']) {
                    $person = new Person();
                    $person->LoadFromRecordNumber($rows[0]['id']);
                } else {
                    $person_form = person_form('new');
                    $person = new Person();
                    form_objects($person_form, $person, $glData['perpetrator']);
                    $person->deceased = $person->deceased == 'on' ? 'y' : 'n';
                    if (isset($person->number_of_persons_in_group) && !$person->number_of_persons_in_group) {
                        $person->number_of_persons_in_group = Null;
                    }
                    if (isset($person->dependants) && !$person->dependants) {
                        $person->dependants = Null;
                    }
                    $person->SaveAll();
                }
                $perpetrator = $person;
                $inv = new Involvement();
                $inv->involvement_record_number = shn_create_uuid('inv');
                $inv->degree_of_involvement = "54010101001921";
                //placeholder
                $inv->event = $event->event_record_number;
                $inv->act = $act->act_record_number;
                $inv->perpetrator = $perpetrator->person_record_number;
                $inv->SaveAll();
            }
            $supporting_documents = array();
            if (trim($row[9])) {
                $document_form = document_form('new');
                unset($document_form['doc_id']);
                $supporting_docs = new SupportingDocs();
                $supporting_docs_meta = new SupportingDocsMeta();
                $type = null;
                $doc_uuid = shn_create_uuid('doc');
                $supporting_docs->doc_id = $doc_uuid;
                $supporting_docs_meta->doc_id = $doc_uuid;
                $supporting_docs->uri = '';
                form_objects($document_form, $supporting_docs, array('title' => $row[9]));
                form_objects($document_form, $supporting_docs_meta, array('title' => $row[9]));
                $supporting_docs_meta->format = $type;
                $supporting_docs->Save();
                $supporting_docs_meta->Save();
                $supporting_documents[] = $doc_uuid;
            }
            for ($j = 1; $j <= $docsCount; $j++) {
                if ($glData["supporting_docs_meta" . $j]) {
                    if (!$glData["supporting_docs_meta" . $j]['title']) {
                        continue;
                    }
                    $document_form = document_form('new');
                    unset($document_form['doc_id']);
                    $supporting_docs = new SupportingDocs();
                    $supporting_docs_meta = new SupportingDocsMeta();
                    $type = null;
                    $doc_uuid = shn_create_uuid('doc');
                    $supporting_docs->doc_id = $doc_uuid;
                    $supporting_docs_meta->doc_id = $doc_uuid;
                    $supporting_docs->uri = '';
                    form_objects($document_form, $supporting_docs, $glData["supporting_docs_meta" . $j]);
                    form_objects($document_form, $supporting_docs_meta, $glData["supporting_docs_meta" . $j]);
                    $supporting_docs_meta->format = $type;
                    $supporting_docs->Save();
                    $supporting_docs_meta->SaveAll();
                    $supporting_documents[] = $doc_uuid;
                }
            }
            if ($supporting_documents) {
                $act->supporting_documents = $supporting_documents;
                $act->SaveDocs();
            }
            $bio_details = array();
            for ($j = 1; $j <= $biosCount; $j++) {
                if ($glData["bio_details" . $j] && $glData["bio_details" . $j]["type_of_relationship"]) {
                    $browse = new Browse();
                    $rows = $browse->ExecuteQuery("select person_record_number as id from person where person_name='" . $glData["bio_details" . $j]['person_name'] . "' \n\t\t\t\t\tand other_names='" . $glData['bio_details']['other_names'] . "' ");
                    if ($rows && $rows[0]['id']) {
                        $person = new Person();
                        $person->LoadFromRecordNumber($rows[0]['id']);
                    } else {
                        $person_form = person_form('new');
                        $person = new Person();
                        form_objects($person_form, $person, $glData["bio_details" . $j]);
                        $person->deceased = $person->deceased == 'on' ? 'y' : 'n';
                        if (isset($person->number_of_persons_in_group) && !$person->number_of_persons_in_group) {
                            $person->number_of_persons_in_group = Null;
                        }
                        if (isset($person->dependants) && !$person->dependants) {
                            $person->dependants = Null;
                        }
                        $person->SaveAll();
                    }
                    if ($glData["bio_details" . $j]["phone"] || $glData["bio_details" . $j]["email"]) {
                        $address = new Address();
                        $address_form = address_form('new');
                        form_objects($address_form, $address, $glData["bio_details" . $j]);
                        $address->person = $person->person_record_number;
                        $address->Save();
                    }
                    $biography_form = biographic_form('new');
                    $biography = new BiographicDetail();
                    //$biography->LoadfromRecordNumber();
                    $biography->biographic_details_record_number = shn_create_uuid('biography');
                    $glData["bio_details" . $j]['person_id'] = $person->person_record_number;
                    form_objects($biography_form, $biography, $glData["bio_details" . $j]);
                    $biography->person = $victim->person_record_number;
                    $biography->related_person = $person->person_record_number;
                    if ($biography->related_person == '') {
                        $biography->related_person = null;
                    }
                    $biography->SaveAll();
                }
            }
        }
        $results[] = $row;
        $j++;
    }
    return $results;
}
Esempio n. 4
0
function get_data_array()
{
    global $dataFile, $dataCols, $fields, $lists, $docsCount, $biosCount;
    if (($handle = fopen($dataFile, "r")) === FALSE) {
        return array();
    }
    $results = array();
    $i = 0;
    while (($cols = fgetcsv($handle, 0, "\t")) !== FALSE) {
        $glData = array();
        $row = array();
        if ($cols && $cols[1]) {
            foreach ($cols as $key => $val) {
                $val = trim($val, '"');
                $val = trim($val);
                $row[$key] = $val;
                $entityField = $dataCols[$key];
                if ($entityField) {
                    $ent = $entityField["ent"];
                    $list_code = $entityField['list_code'];
                    $type = $entityField['field_type'];
                    $mlt = trim($entityField['is_repeat']) == 'Y' || trim($entityField['is_repeat']) == 'y' ? true : false;
                    if ($list_code == 39) {
                        if ($val == "M") {
                            $val == "Hombre";
                        } elseif ($val == "F") {
                            $val == "Mujer";
                        }
                    }
                    if ($list_code && !$lists[$list_code]) {
                        $options = array();
                        $data_array = MtFieldWrapper::getMTList($list_code);
                        $size = count($data_array);
                        for ($i = 0; $i < $size; $i++) {
                            $options[$data_array[$i]['vocab_number']] = strtolower($data_array[$i]['label']);
                        }
                        $lists[$list_code] = $options;
                    }
                    if ($list_code) {
                        if ($mlt) {
                            $val2 = explode(";", $val);
                            $val = array();
                            foreach ($val2 as $v) {
                                $vocab_number = array_search(strtolower($v), $lists[$list_code]);
                                if ($vocab_number) {
                                    $val[] = $vocab_number;
                                }
                            }
                        } else {
                            $vocab_number = array_search(strtolower($val), $lists[$list_code]);
                            if ($vocab_number) {
                                $val = $vocab_number;
                            } else {
                                $val = null;
                            }
                        }
                    }
                    if ($type == "date") {
                        if ($val) {
                            $d = date_create_from_format("m/d/Y", $val);
                            if ($d) {
                                $val = date_format($d, 'Y-m-d');
                            } else {
                                $val = null;
                            }
                        } else {
                            $val = null;
                        }
                    } elseif ($type == "location") {
                        $val2 = explode(",", $val);
                        //$row[$entityField['field_name'] . "_latitude"] = -floatval($val2[0]);
                        //$row[$entityField['field_name'] . "_longitude"] = -floatval($val2[1]);
                        $glData[$ent][$entityField['field_name'] . "_latitude"] = -floatval($val2[0]);
                        $glData[$ent][$entityField['field_name'] . "_longitude"] = -floatval($val2[1]);
                        $val = null;
                    } elseif ($type == "radio") {
                        if ($val == "NO") {
                            $val = "n";
                        } elseif ($val == "SÍ") {
                            $val = "y";
                        } else {
                            $val = null;
                        }
                    }
                    if ($val) {
                        //$row[$entityField['field_name']] = $val;
                        $glData[$ent][$entityField['field_name']] = $val;
                    }
                }
            }
            //var_dump($glData);exit;
            $browse = new Browse();
            $rows = $browse->ExecuteQuery("select event_record_number as id from event where event_title='" . $glData['event']['event_title'] . "'");
            if ($rows && $rows[0]['id']) {
                $event = new Event();
                $event->LoadFromRecordNumber($rows[0]['id']);
                $event->LoadRelationships();
            } else {
                continue;
            }
            if ($event->supporting_documents) {
                $supporting_documents = $event->supporting_documents;
            } else {
                $supporting_documents = array();
            }
            for ($j = 1; $j <= $docsCount; $j++) {
                if ($glData["supporting_docs_meta" . $j]) {
                    if (!$glData["supporting_docs_meta" . $j]['title']) {
                        continue;
                    }
                    $document_form = document_form('new');
                    unset($document_form['doc_id']);
                    $supporting_docs = new SupportingDocs();
                    $supporting_docs_meta = new SupportingDocsMeta();
                    $type = null;
                    $doc_uuid = shn_create_uuid('doc');
                    $supporting_docs->doc_id = $doc_uuid;
                    $supporting_docs_meta->doc_id = $doc_uuid;
                    $supporting_docs->uri = '';
                    form_objects($document_form, $supporting_docs, $glData["supporting_docs_meta" . $j]);
                    form_objects($document_form, $supporting_docs_meta, $glData["supporting_docs_meta" . $j]);
                    $supporting_docs_meta->format = $type;
                    $supporting_docs->Save();
                    $supporting_docs_meta->SaveAll();
                    $supporting_documents[] = $doc_uuid;
                }
            }
            if ($supporting_documents) {
                $event->supporting_documents = $supporting_documents;
                $event->SaveDocs();
            }
        }
        $results[] = $row;
        $i++;
    }
    return $results;
}
Esempio n. 5
0
 public function SavePicture()
 {
     if ($this->picture_doc == true && is_uploaded_file($_FILES['picture']['tmp_name'])) {
         $type = null;
         $uri = shn_files_store('picture', null, $type);
         if ($uri == null) {
             $uri = '';
         }
         $document_form = document_form('new');
         $supporting_docs = new SupportingDocs();
         $supporting_docs_meta = new SupportingDocsMeta();
         $pictureDoc = new SupportingDocEntity(SupportingDocEntity::generateTableName('picture'));
         $pictureDoc->record_number = $this->person_record_number;
         if ($_POST['picture_id'] != null) {
             $picture_id = $_POST['picture_id'];
             if ($uri != '') {
                 $supporting_docs->doc_id = $picture_id;
                 $supporting_docs->uri = $uri;
                 $supporting_docs->_saved = true;
                 form_objects($document_form, $supporting_docs);
                 //$supporting_docs->Delete();
                 $supporting_docs->Save();
                 form_objects($document_form, $supporting_docs_meta);
                 $supporting_docs_meta->title = "Picture";
                 $supporting_docs_meta->doc_id = $picture_id;
                 $supporting_docs_meta->format = $type;
                 $supporting_docs_meta->_saved = true;
                 $supporting_docs_meta->Save();
                 $pictureDoc->doc_id = $picture_id;
                 $pictureDoc->_saved = true;
                 $pictureDoc->linked_by = $_SESSION['username'];
                 $pictureDoc->Save();
             }
         } else {
             $picture_id = shn_create_uuid('picture');
             $supporting_docs->doc_id = $picture_id;
             $supporting_docs->uri = $uri;
             form_objects($document_form, $supporting_docs);
             $supporting_docs->Save();
             form_objects($document_form, $supporting_docs_meta);
             $supporting_docs_meta->title = "Picture";
             $supporting_docs_meta->doc_id = $picture_id;
             $supporting_docs_meta->format = $type;
             $supporting_docs_meta->Save();
             $pictureDoc->doc_id = $picture_id;
             $pictureDoc->linked_by = $_SESSION['username'];
             $pictureDoc->Save();
         }
     }
 }
 protected function save_intervention()
 {
     $intervention_form = intervention_form('new');
     $intv = new Intervention();
     $intv->intervention_record_number = shn_create_uuid('intv');
     form_objects($intervention_form, $intv);
     if (trim($intv->victim) == '') {
         $intv->victim = null;
     }
     //var_dump($intv);
     $intv->SaveAll();
     return $intv;
 }
 function act_supporting_doc()
 {
     include_once APPROOT . 'inc/lib_form_util.inc';
     include_once APPROOT . 'inc/lib_uuid.inc';
     $this->supporting_doc_form = $supporting_doc_form;
     $this->pid = isset($_GET['pid']) && $_GET['pid'] != null ? $_GET['pid'] : $_SESSION['pid'];
     if ($this->pid != null) {
         $person_form = person_form('new');
         $this->person_form = $person_form;
         $this->person = $this->person_information($this->pid, $this->person_form);
         $_SESSION['ppid'] = $this->pid;
     }
     if (isset($_POST['save'])) {
         $status = shn_form_validate($supporting_doc_form);
         if ($status) {
             $supporting_doc = new SupportingDocs();
             $supporting_doc->doc_id = shn_create_uuid('document');
             $supporting_doc->uri = 'www.respere.com';
             $supporting_doc->Save();
             $supporting_docmeta = new SupportingDocsMeta();
             $supporting_docmeta->doc_id = $supporting_doc->doc_id;
             form_objects($supporting_doc_form, $supporting_docmeta);
             $supporting_docmeta->format = $this->findexts($_FILES['document']['name']);
             $supporting_docmeta->Save();
         }
     }
 }