Esempio n. 1
0
function update_counts($table, $method_name, $condition)
{
    global $db;
    $new = $db->query("SELECT DISTINCT supporter_KEY FROM " . $table . " WHERE " . $condition);
    if ($new->num_rows > 0) {
        while ($new_arr = $new->fetch_assoc()) {
            $supporter_info = $db->query("SELECT * FROM supporter WHERE supporter_KEY=" . $new_arr['supporter_KEY'])->fetch_assoc();
            $supporter = new Supporter($supporter_info);
            $supporter->{$method_name}();
            $supporter->db_update();
            $supporter->data['key'] = $supporter->data['supporter_KEY'];
            //$dia->save('supporter', $supporter->data);
        }
    }
}
 public function synchronize_patients()
 {
     $data['regimens'] = Regimen::getAll();
     $data['supporters'] = Supporter::getAll();
     $data['service_types'] = Regimen_Service_Type::getAll();
     $data['sources'] = Patient_Source::getAll();
     $data['drugs'] = Drugcode::getAll();
     $data['regimen_change_purpose'] = Regimen_Change_Purpose::getAll();
     $data['visit_purpose'] = Visit_Purpose::getAll();
     $data['opportunistic_infections'] = Opportunistic_Infection::getAll();
     $data['regimen_drugs'] = Regimen_Drug::getAll();
 }
 public function listing()
 {
     $access_level = $this->session->userdata('user_indicator');
     $data['access_level'] = $access_level;
     $data['sites'] = Facilities::getFacilities();
     $data['supporter'] = Supporter::getAll();
     //get satellites
     //$data['satellites'] = Facilities::getSatellites($this -> session -> userdata("facility"));
     $district_query = $this->db->query("select * from district");
     $data['districts'] = $district_query->result_array();
     $county_query = $this->db->query("select * from counties");
     $data['counties'] = $county_query->result_array();
     $facility_type_query = $this->db->query("select * from facility_types");
     $data['facility_types'] = $facility_type_query->result_array();
     $data['title'] = "Facility Information";
     $data['banner_text'] = "Facility Information";
     $data['link'] = "facility";
     $actions = array(0 => array('Edit', 'edit'), 1 => array('Disable', 'disable'));
     $data['actions'] = $actions;
     $this->base_params($data);
 }
Esempio n. 4
0
<?php

spl_autoload_register('MyLoader');
function MyLoader($sClass)
{
    if (strstr($sClass, 'Sql')) {
        require_once '../classes/databases/' . $sClass . '.php';
    } else {
        require_once '../classes/' . $sClass . '.php';
    }
}
$oDatabase_connection = new Database();
$oDatabase = $oDatabase_connection->Connect();
$oSupporter = new Supporter();
$bError = false;
// Wenn false dann Fehlerfrei
$sMessage = "";
$aFilterAssoc = array('name' => FILTER_SANITIZE_ENCODED, 'action' => FILTER_SANITIZE_ENCODED, 'password' => FILTER_SANITIZE_ENCODED);
$aUserInputsAssoc = filter_input_array(INPUT_POST, $aFilterAssoc);
if ($aUserInputsAssoc['action'] === 'register') {
    $aResultAssoc = $oSupporter->Login($aUserInputsAssoc, $oDatabase);
    echo json_encode($aResultAssoc);
}
 /**
  * Returns a view with all the supporters
  *
  * @return Response
  */
 public function thankYou()
 {
     return View::make('thank_you')->with(['supporters' => Supporter::all()]);
 }
<?php

include '../Classe/SupporterManager.php';
include '../ConnectBDD.php';
if (!isset($_REQUEST['act'])) {
    header('Location: inscription_vue.php');
} else {
    if ($_REQUEST['act'] == 'inscription') {
        $manager_supporter = connect('Supporter');
        $login = isset($_REQUEST['login']) && $_REQUEST['login'] != '' ? $_REQUEST['login'] : null;
        $pass = isset($_REQUEST['pass']) && $_REQUEST['pass'] != '' ? $_REQUEST['pass'] : null;
        $email = isset($_REQUEST['email']) && $_REQUEST['email'] != '' ? $_REQUEST['email'] : null;
        $mdp = sha1($pass);
        $supporter = new Supporter();
        $supporter->setLogin($login);
        $supporter->setMdp($mdp);
        $supporter->setEmail($email);
        $manager_supporter->addSupporter($supporter);
        header('Location: ../index.php');
    }
}
Esempio n. 7
0
#if ($_REQUEST['supporter_KEY']) {$supporter_KEY = $_REQUEST['supporter_KEY'];}
if (!$supporter_KEY) {
    $args = json_decode(file_get_contents('php://input'), true);
    trigger_error(print_r($args, TRUE));
    $supporter_KEY = $args['supporter_KEY'];
}
#$supporter_KEY = 48965489;
#$file = '/tmp/process.log';
// The new person to add to the file
#trigger_error(print_r($supporter_KEY,TRUE));
$sql = "SELECT * FROM supporter WHERE supporter_KEY=" . $supporter_KEY;
$S = $db->Execute($sql) or die($db->errorMsg() . $sql);
$s = $S->GetAssoc();
$x = 0;
foreach ($s as $supporter_arr) {
    $supporter = new Supporter($supporter_arr);
    #$supporter->process_data_augmentation();
    # $supporter->geovalidate();
    if ($supporter_arr['source_processed'] != 1) {
        $supporter->process_source();
    }
    $supporter->updateDonationCounts();
    $supporter->updateActionCounts();
    $supporter->updateEmailCounts();
    $supporter->updateUnsubscribeInfo();
    $supporter->updateSupporterTypes();
    #update local
    $supporter->db_update();
    #save to salsa
    $data = $supporter->data;
    $data['key'] = $supporter_arr['supporter_KEY'];
require '../../boot.php';
list($cmd, $update_count_date) = $argv;
$unprocessed_supporters = $db->query("SELECT * FROM supporter WHERE source_processed != 'true'");
if ($unprocessed_supporters->num_rows > 0) {
    while ($unprocessed_supporter_arr = $unprocessed_supporters->fetch_assoc()) {
        $supporter = new Supporter($unprocessed_supporter_arr);
        $supporter->process();
        $supporter->db_update();
        $supporter->data['key'] = $supporter->data['supporter_KEY'];
        //$dia->save('supporter', $supporter->data);
    }
}
$unvalidated_supporters = $db->query("SELECT * FROM supporter WHERE data__geo_coded != 'true'");
if ($unvalidated_supporters->num_rows > 0) {
    while ($unvalidated_supporter_arr = $unvalidated_supporters->fetch_assoc()) {
        $supporter = new Supporter($unvalidated_supporter_arr);
        $supporter->geovalidate();
        $supporter->db_update();
        $supporter->data['key'] = $supporter->data['supporter_KEY'];
        //$dia->save('supporter', $supporter->data);
    }
}
$last_modified_condition = "Last_Modified >= '" . $update_count_date . "'";
update_counts('supporter_action', 'updateActionCounts', $last_modified_condition);
update_counts('donation', 'updateDonationCounts', $last_modified_condition);
update_counts('email', 'updateEmailCounts', $last_modified_condition);
update_counts('unsubscribe', 'updateUnsubscribeInfo', $last_modified_condition);
update_counts('unsubscribe', 'updateUnsubscribeInfo', "receive_email < 1 AND (data__unsub_method IS NULL OR data__unsub_method = '')");
function update_counts($table, $method_name, $condition)
{
    global $db;
Esempio n. 9
0
function supporter_array_db($supporter_KEY, $live = NULL)
{
    global $db;
    $sql = "select * from supporter where supporter_KEY = " . $supporter_KEY;
    $S = $db->Execute($sql) or die($db->errorMsg());
    $s = $S->FetchRow();
    if ($live) {
        $sup = new Supporter($s);
        $sup->process_data_augmentation();
        $s = $sup->data;
    }
    #groups
    $sql = 'select * from supporter_groups where supporter_KEY = ' . $supporter_KEY . ' order by Last_Modified desc';
    $G = $db->CacheExecute($sql) or die($db->errorMsg());
    $groups = $G->GetArray();
    foreach ($groups as $key => $i) {
        $sql = 'select groups_KEY, Group_Name, parent_KEY from groups where groups_KEY = ' . $i['groups_KEY'];
        $GD = $db->CacheExecute($sql) or die($db->errorMsg());
        $group_details = $GD->FetchRow();
        $groups[$key]['group'] = $group_details;
    }
    #tags
    $sql = 'select * from tag_data where database_table_KEY=142 and table_key = ' . $supporter_KEY;
    $T = $db->Execute($sql) or die($db->errorMsg());
    $tags = $T->GetArray();
    foreach ($tags as $key => $i) {
        $sql = 'select tag_KEY, prefix, tag, label from tag where tag_KEY = ' . $i['tag_KEY'];
        $TD = $db->Execute($sql) or die($db->errorMsg());
        $tag_details = $TD->FetchRow();
        $tags[$key]['tag'] = $tag_details;
        $tag_name = $tag_details['prefix'] . ':' . $tag_details['tag'];
        $tags[$key]['tag_name'] = $tag_name;
    }
    #actions
    $sql = 'select * from supporter_action where supporter_KEY = ' . $supporter_KEY . ' order by Date_Created desc';
    $A = $db->CacheExecute($sql) or die($db->errorMsg());
    $actions = $A->GetArray();
    foreach ($actions as $key => $i) {
        $sql = 'select action_KEY,Reference_Name from action where action_KEY = ' . $i['action_KEY'] . ' order by Date_Created desc';
        $AD = $db->CacheExecute($sql) or die($db->errorMsg());
        $action_details = $AD->FetchRow();
        $actions[$key]['action'] = $action_details;
    }
    #emails
    $sql = 'select * from email where supporter_KEY = ' . $supporter_KEY . ' order by Time_Sent desc';
    $E = $db->CacheExecute($sql) or die($db->errorMsg());
    $emails = $E->GetArray();
    foreach ($emails as $key => $i) {
        $sql = 'select email_blast_KEY,Subject,Reference_Name,Date_Requested from email_blast where email_blast_KEY = ' . $i['email_blast_KEY'];
        $EB = $db->CacheExecute($sql) or die($db->errorMsg());
        $email_details = $EB->FetchRow();
        $emails[$key]['email'] = $email_details;
    }
    #donations
    $sql = 'select * from donation where supporter_KEY = ' . $supporter_KEY . ' order by Transaction_Date desc';
    $D = $db->CacheExecute($sql) or die($db->errorMsg());
    $donations = $D->GetArray();
    #notes
    $sql = 'select * from contact_history where supporter_KEY = ' . $supporter_KEY . ' and Method = "Note" order by Date_Created desc';
    $N = $db->Execute($sql) or die($db->errorMsg());
    $notes = $N->GetArray();
    #contacts
    $sql = 'select * from contact_history where supporter_KEY = ' . $supporter_KEY . ' and (Method = "Direct Email" or Method ="Phone") order by Date_Created desc';
    $conts = $db->Execute($sql) or die($db->errorMsg());
    $contacts = $conts->GetArray();
    #todos
    $sql = 'select * from contact_history where supporter_KEY = ' . $supporter_KEY . ' and Method = "To Do" order by Date_Created desc';
    $TD = $db->Execute($sql) or die($db->errorMsg());
    $todos = $TD->GetArray();
    #companies
    $sql = 'select * from supporter_company where supporter_KEY = ' . $supporter_KEY;
    $comp = $db->CacheExecute($sql) or die($db->errorMsg());
    $companies = $comp->GetArray();
    #unsub
    $sql = 'select * from unsubscribe where supporter_KEY = ' . $supporter_KEY;
    $unsubs = $db->CacheExecute($sql) or die($db->errorMsg());
    $unsubscribe = $unsubs->GetArray();
    $s['groups'] = $groups;
    $s['tags'] = $tags;
    $s['actions'] = $actions;
    $s['emails'] = $emails;
    $s['donations'] = $donations;
    $s['notes'] = $notes;
    #adds user notes into the notes array, i hope
    if ($s['Notes']) {
        $add_notes[0]['Codes'] = 'Main Note Field';
        $add_notes[0]['Notes'] = $s['Notes'];
        $s['notes'] = array_merge($s['notes'], $add_notes);
    }
    $s['contacts'] = $contacts;
    $s['todos'] = $todos;
    $s['companies'] = $companies;
    $s['unsubscribe'] = $unsubscribe;
    $s = add_computational_data_to_supporter_array($s);
    return $s;
}
Esempio n. 10
0
 public function disable($source_id)
 {
     $this->load->database();
     $query = $this->db->query("UPDATE supporter SET Active='0'WHERE id='{$source_id}'");
     $results = Supporter::getSource($source_id);
     $this->session->set_userdata('message_counter', '2');
     $this->session->set_userdata('msg_error', $results->Name . ' was disabled');
     $this->session->set_flashdata('filter_datatable', $results->Name);
     //Filter datatable
     redirect('settings_management');
 }
Esempio n. 11
0
<?php

require '../../boot.php';
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$sql = "SELECT supporter_KEY, Source_Tracking_Code, Email, Source_Details,City, State, Zip, Country FROM supporter";
$S = $db->CacheExecute($sql) or die($db->errorMsg());
$s = $S->GetArray();
$x = 0;
foreach ($s as $supporter_arr) {
    $supporter = new Supporter($supporter_arr);
    #$supporter->process_data_augmentation();
    #  $supporter->geovalidate();
    #$supporter->process_source();
    $supporter->updateDonationCounts();
    $supporter->updateActionCounts();
    $supporter->updateEmailCounts();
    $supporter->updateUnsubscribeInfo();
    $supporter->updateSupporterTypes();
    $db->AutoExecute('supporter', $supporter->data, 'UPDATE', " supporter_KEY = '" . $supporter->data['supporter_KEY'] . "'") or die($db->errorMsg());
    # $supporter->db_update();   # $supporter->db_update();
    $supporter->data['key'] = $supporter->data['supporter_KEY'];
    //$DIA->save('supporter', $supporter->data);
    #echo '<pre>'.print_r($supporter->data).'</pre>';
    $x++;
    echo $x . '
    ';
}
Esempio n. 12
0
 public function edit()
 {
     $drugcode_id = $this->input->post('drugcode_id');
     $data['generic_names'] = Generic_Name::getAllActive();
     $data['drug_units'] = Drug_Unit::getThemAll();
     $data['doses'] = Dose::getAllActive();
     $data['supporters'] = Supporter::getAllActive();
     $data['doses'] = Dose::getAllActive();
     $data['drugcodes'] = Drugcode::getDrugCodeHydrated($drugcode_id);
     echo json_encode($data);
 }
 function testDeriveDataFromZip()
 {
     global $db;
     $db->query('insert into zipcodes (`zip`,`city`,`state`) VALUES (2215,"Boston","MA")');
     $s = new Supporter(array('Zip' => '02215'));
     $s->derive_data_from_zip();
     $this->assertEqual($s->data['State'], "MA");
     $this->assertEqual($s->data['City'], "Boston");
     $this->assertEqual($s->data['Country'], "US");
 }
Esempio n. 14
0
<?php

spl_autoload_register('MyLoader');
function MyLoader($sClass)
{
    if (strstr($sClass, 'Sql')) {
        require_once '../classes/databases/' . $sClass . '.php';
    } else {
        require_once '../classes/' . $sClass . '.php';
    }
}
$oDatabase_connection = new Database();
$oDatabase = $oDatabase_connection->Connect();
switch ($_POST['action']) {
    case 'getRights':
        $oSupporter = new Supporter();
        $aResultAssoc = $oSupporter->GetRightsList($oDatabase);
        break;
    case 'saveSupporter':
        $aResultAssoc = SaveSupporter($oSupporter, $oDatabase);
        break;
    case 'table':
        $oTable = new Table();
        $aResultAssoc = $oTable->GetTableValues($_POST['table'], $oDatabase);
        break;
    case 'save':
        $oTable = new Table();
        $aResultAssoc = $oTable->SaveTableRow($_POST, $oDatabase);
        break;
}
echo json_encode($aResultAssoc);
<?php

require '../../boot.php';
list($cmd, $supporter_KEY) = $argv;
#$supporter_KEY = 48965489;
$supporter_query = $db->query("SELECT * FROM supporter WHERE supporter_KEY=" . $supporter_KEY);
if ($supporter_query->num_rows > 0) {
    while ($supporter_arr = $supporter_query->fetch_assoc()) {
        $supporter = new Supporter($supporter_arr);
        $supporter->process();
        #$supporter->geovalidate();
        $supporter->updateDonationCounts();
        $supporter->updateActionCounts();
        $supporter->updateEmailCounts();
        $supporter->updateUnsubscribeInfo();
        $supporter->updateSupporterTypes();
        //$supporter->db_update();
        $supporter->data['key'] = $supporter->data['supporter_KEY'];
        //$dia->save('supporter', $supporter->data);
    }
}
echo '<pre>' . print_r($supporter) . '</pre>';
Esempio n. 16
0
function search_person($term, $conditons = NULL, $options = NULL)
{
    global $db;
    if ($conditions) {
        foreach ($conditions as $i) {
            $con = ' and  ' . $i;
        }
    }
    if ($options['groups_KEY']) {
        $sql = "SELECT s.supporter_KEY,   Concat(s.First_Name, ' ', s.Last_Name,', ', s.Email) as fullname FROM supporter as s, supporter_groups as g WHERE CONCAT( s.First_Name,  ' ', s.Last_Name, ' ',s.Email, ' ',s.Organization) LIKE  '%" . $term . "%' " . $con . " and s.supporter_KEY = g.supporter_KEY and g.groups_KEY = " . $options['groups_KEY'] . " order by corporate, s.campaign_manager_KEY, Last_Name, First_Name";
    } else {
        $sql = "SELECT *,   Concat(First_Name, ' ', Last_Name,', ', Email) as fullname FROM supporter\n\tWHERE CONCAT( First_Name,  ' ', Last_Name, ' ',Email, ' ',Organization) LIKE  '%" . $term . "%' " . $con . " order by Last_Name, First_Name ";
    }
    $S = $db->Execute($sql) or die($DB->errorMsg());
    $s = $S->GetArray();
    foreach ($s as $supporter) {
        $sup = new Supporter($supporter);
        $sup->process_data_augmentation();
        $out[] = $sup->data;
    }
    return $out;
}
<?php

require '../../boot.php';
list($cmd, $supporter_KEY) = $argv;
$result = $DIA->get('supporter', $supporter_KEY);
$s = new Supporter($result);
$s->db_upsert();
$model_array = array('SupporterAction', 'Email', 'Donation', 'ContactHistory', 'SupporterEvent', 'SupporterCompany', 'SupporterShare');
foreach ($model_array as $model) {
    $table = $model::$table_name;
    $results = $DIA->get($table, array('condition' => array('supporter_KEY=' . $supporter_KEY)));
    foreach ($results as $result) {
        $instance = new $model($result);
        $instance->db_upsert();
    }
}
$db->query('DELETE FROM `tag_data` WHERE database_table_KEY=142 AND `table_key`=' . $supporter_KEY);
$results = $DIA->get('tag_data', array('condition' => array('database_table_KEY=142', 'table_key=' . $supporter_KEY)));
foreach ($results as $result) {
    print_r($result);
    $instance = new TagData($result);
    $instance->db_insert();
}
$db->query('DELETE FROM `supporter_groups` WHERE `supporter_KEY`=' . $supporter_KEY);
$results = $DIA->get('supporter_groups', array('condition' => array('supporter_KEY=' . $supporter_KEY)));
foreach ($results as $result) {
    $instance = new SupporterGroups($result);
    $instance->db_insert();
}
 public function delete(Supporter $supporter)
 {
     $this->_db->exec('DELETE FROM supporter WHERE id = ' . $supporter->id());
 }
Esempio n. 19
0
<?php

require '../boot.php';
$rs = $db->Execute("SELECT distinct supporter_KEY from donation where amount>0 ");
while ($supporter_arr = $rs->FetchRow()) {
    $supporter = new Supporter($supporter_arr);
    $supporter->updateDonationCounts(NULL);
    $d['gift_string__largest__low'] = $supporter->data['data__gift_string__largest__low'];
    $d['gift_string__largest__medium'] = $supporter->data['data__gift_string__largest__medium'];
    $d['gift_string__largest__high'] = $supporter->data['data__gift_string__largest__high'];
    $d['gift_string__avg__low'] = $supporter->data['data__gift_string__avg__low'];
    $d['gift_string__avg__medium'] = $supporter->data['data__gift_string__avg__medium'];
    $d['gift_string__avg__high'] = $supporter->data['data__gift_string__avg__high'];
    $d['gift_string__last__low'] = $supporter->data['data__gift_string__last__low'];
    $d['gift_string__last__medium'] = $supporter->data['data__gift_string__last__medium'];
    $d['gift_string__last__high'] = $supporter->data['data__gift_string__last__high'];
    $d['donation_history__count'] = $supporter->data['data__donation__count'];
    $d['donation_history__total'] = $supporter->data['data__donation__total'];
    $d['donation_history__average'] = $supporter->data['data__donation__average'];
    $d['donation_history__max'] = $supporter->data['data__donation__max'];
    $d['donation_history__min'] = $supporter->data['data__donation__min'];
    $d['donation_history__last'] = $supporter->data['data__donation__last_amount'];
    $d['key'] = $supporter->data['supporter_KEY'];
    $db->AutoExecute('supporter', $d, 'UPDATE', 'supporter_KEY =' . $supporter->data['supporter_KEY']);
    #    $DIA->save('supporter', $d);
    echo '<pre>';
    print_r($d);
    echo '</pre>';
}