/**
  * Runs a query to get all the dates for meetings based on SearchAttributeData.  Then the data is processed
  * and @returns a data array of dates and quantity.  Quantity stands for how many meetings in a given date.
  * (non-PHPdoc)
  * @see CalendarDataProvider::getData()
  */
 public function getData()
 {
     $sql = $this->makeSqlQuery();
     $rows = R::getAll($sql);
     $data = array();
     foreach ($rows as $row) {
         $localTimeZoneAdjustedDate = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($row['startdatetime'], 'medium', null);
         if (isset($data[$localTimeZoneAdjustedDate])) {
             $data[$localTimeZoneAdjustedDate]['quantity'] = $data[$localTimeZoneAdjustedDate]['quantity'] + 1;
         } else {
             $data[$localTimeZoneAdjustedDate] = array('date' => $localTimeZoneAdjustedDate, 'quantity' => 1, 'dbDate' => $row['startdatetime']);
         }
     }
     foreach ($data as $key => $item) {
         if ($item['quantity'] == 1) {
             $label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModuleSingularLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
         } else {
             $label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModulePluralLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
         }
         $data[$key]['label'] = $label;
         if ($item['quantity'] > 5) {
             $quantityClassSuffix = 6;
         } else {
             $quantityClassSuffix = $item['quantity'];
         }
         $data[$key]['className'] = 'calendar-events-' . $quantityClassSuffix;
     }
     return $data;
 }
Ejemplo n.º 2
0
function getSubscribers($id)
{
    $subs = R::getAll("select * from subscription where category_id='{$id}'");
    if ($subs) {
        return $subs;
    }
}
Ejemplo n.º 3
0
 public function get_Upload_details($last_upl)
 {
     /*
     		$user_delimiter =$this->sql_user_delimiter(0,0);
     
     		$sql 	=	"SELECT 
     							`pima_upload_id`,
     							`upload_date`,
     							`equipment_serial_number`,
     							`facility_name`,
     							`uploader_name`,
     							COUNT(`pima_test_id`) AS `total_tests`,
     							SUM(CASE WHEN `valid`= '1'    THEN 1 ELSE 0 END) AS `valid_tests`,
     							SUM(CASE WHEN `valid`= '0'    THEN 1 ELSE 0 END) AS `errors`,
     							SUM(CASE WHEN `valid`= '1'  AND  `cd4_count` < 350 THEN 1 ELSE 0 END) AS `failed`,
     							SUM(CASE WHEN `valid`= '1'  AND  `cd4_count` >= 350 THEN 1 ELSE 0 END) AS `passed`
     						FROM `v_pima_uploads_details`
     						WHERE 1 
     						AND `pima_upload_id` > $last_upl 
     						$user_delimiter 
     						GROUP BY `pima_upload_id`
     						ORDER BY `upload_date` DESC
     					";
     */
     $sql = "CALL get_last_upload_details(" . $last_upl . ")";
     return $res = R::getAll($sql);
 }
Ejemplo n.º 4
0
 public function printLogs()
 {
     $db_query = "SELECT * FROM (\r\n            SELECT ttylog.session, timestamp, ROUND(LENGTH(ttylog)/1024, 2) AS size\r\n            FROM ttylog\r\n            JOIN auth ON ttylog.session = auth.session\r\n            WHERE auth.success = 1\r\n            GROUP BY ttylog.session\r\n            ORDER BY timestamp DESC\r\n            ) s\r\n            WHERE size > " . PLAYBACK_SIZE_IGNORE;
     $rows = R::getAll($db_query);
     if (count($rows)) {
         //We create a skeleton for the table
         $counter = 1;
         echo '<p>The following table displays a list of all the logs recorded by Kippo.
                  Click on column heads to sort data.</p>';
         echo '<table id="Playlog-List" class="tablesorter"><thead>';
         echo '<tr class="dark">';
         echo '<th>ID</th>';
         echo '<th>Timestamp</th>';
         echo '<th>Size</th>';
         echo '<th>Play the log</th>';
         echo '</tr></thead><tbody>';
         //For every row returned from the database we create a new table row with the data as columns
         foreach ($rows as $row) {
             echo '<tr class="light word-break">';
             echo '<td>' . $counter . '</td>';
             echo '<td>' . $row['timestamp'] . '</td>';
             echo '<td>' . $row['size'] . 'kb' . '</td>';
             echo '<td><a href="include/play.php?f=' . $row['session'] . '" target="_blank"><img class="icon" src="images/play.ico"/>Play</a></td>';
             echo '</tr>';
             $counter++;
         }
         //Close tbody and table element, it's ready.
         echo '</tbody></table>';
         echo '<hr /><br />';
     }
 }
Ejemplo n.º 5
0
 /**
  * Test foreign keys with SQLite.
  * 
  * @return void
  */
 public function testForeignKeysWithSQLite()
 {
     $book = R::dispense('book');
     $page = R::dispense('page');
     $cover = R::dispense('cover');
     list($g1, $g2) = R::dispense('genre', 2);
     $g1->name = '1';
     $g2->name = '2';
     $book->ownPage = array($page);
     $book->cover = $cover;
     $book->sharedGenre = array($g1, $g2);
     R::store($book);
     $fkbook = R::getAll('pragma foreign_key_list(book)');
     $fkgenre = R::getAll('pragma foreign_key_list(book_genre)');
     $fkpage = R::getAll('pragma foreign_key_list(page)');
     asrt($fkpage[0]['from'], 'book_id');
     asrt($fkpage[0]['to'], 'id');
     asrt($fkpage[0]['table'], 'book');
     asrt(count($fkgenre), 2);
     if ($fkgenre[0]['from'] == 'book') {
         asrt($fkgenre[0]['to'], 'id');
         asrt($fkgenre[0]['table'], 'book');
     }
     if ($fkgenre[0]['from'] == 'genre') {
         asrt($fkgenre[0]['to'], 'id');
         asrt($fkgenre[0]['table'], 'genre');
     }
     asrt($fkbook[0]['from'], 'cover_id');
     asrt($fkbook[0]['to'], 'id');
     asrt($fkbook[0]['table'], 'cover');
 }
Ejemplo n.º 6
0
 public function update_facilities($id)
 {
     $sql = "SELECT \n\t\t\t\t\t  `facility_id`,\n\t\t\t\t\t  `equipment_id`,\n                      `serial_number`,\n                      `ctc_id_no`\n\t\t\t\tFROM `facility_equipment_request`\n\t\t\t\tWHERE id = {$id}";
     $facilty = R::getAll($sql);
     //print_r($facilty); die();
     /*foreach ($facilty as $key => $val) {
     			$db = $val;
     				$tumepata = implode(',', $db);
     				echo $tumepata;
     		}
             die;*/
     if ($facilty[0]['equipment_id'] == 4) {
         $facility_equipment_registration = array('id' => NULL, 'facility_id' => $facilty[0]['facility_id'], 'equipment_id' => $facilty[0]['equipment_id'], 'status' => '1', 'deactivation_reason' => ' ', 'date_added' => NULL, 'date_removed' => NULL, 'serial_number' => $facilty[0]['serial_number']);
         $insert = $this->db->insert('facility_equipment', $facility_equipment_registration);
         $asus = $this->db->insert_id();
         $facility_registration = array('id' => NULL, 'facility_equipment_id' => $asus, 'serial_num' => $facilty[0]['serial_number'], 'ctc_id_no' => $facilty[0]['ctc_id_no']);
         //print_r($facility_registration);die;
         $insert = $this->db->insert('facility_pima', $facility_registration);
         // $asus = $this->db->insert_id();
         // $faciility_pima_id = array(
         // 							'facility_equipment_id'    =>   $asus
         // 							);
         // $this->db->where('id', $asus);
         // $this->db->update('facility_pima', $faciility_pima_id);
         //print_r($asus); die();
         return $insert;
     } else {
         $facility_registration = array('id' => NULL, 'facility_id' => $facilty[0]['facility_id'], 'equipment_id' => $facilty[0]['equipment_id'], 'status' => '1', 'deactivation_reason' => '', 'date_added' => NULL, 'date_removed' => NULL, 'serial_number' => $facilty[0]['serial_number']);
         $insert = $this->db->insert('facility_equipment', $facility_registration);
         return $insert;
     }
 }
Ejemplo n.º 7
0
 public function save_fac_equip()
 {
     $this->login_reroute(array(1, 2));
     $cat = $this->input->post("cat");
     $eq = (int) $this->input->post("eq");
     $fac = (int) $this->input->post("fac");
     $serial = $this->input->post("serial");
     $ctc = $this->input->post("ctc");
     $last_eq_auto_id_res = R::getAll("SELECT `id` FROM `facility_equipment` ORDER BY `id` DESC LIMIT 1");
     $next_eq_auto_id = 1;
     if (sizeof($last_eq_auto_id_res) > 0) {
         $next_eq_auto_id = $last_eq_auto_id_res[0]['id'] + 1;
     } else {
         $next_eq_auto_id = 1;
     }
     $this->db->trans_begin();
     $this->db->query("INSERT INTO `facility_equipment` \n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t`id`,\n\t\t\t\t\t\t\t\t\t`facility_id`,\n\t\t\t\t\t\t\t\t\t`equipment_id`,\n\t\t\t\t\t\t\t\t\t`serial_number`,\n\t\t\t\t\t\t\t\t\t`status`\n\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t'{$next_eq_auto_id}',\n\t\t\t\t\t\t\t\t\t\t'{$fac}',\n\t\t\t\t\t\t\t\t\t\t'{$eq}',\n\t\t\t\t\t\t\t\t\t\t'{$serial}',\n\t\t\t\t\t\t\t\t\t\t'1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t");
     if ($eq == 4) {
         $this->db->query("INSERT INTO `facility_pima` \n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t`facility_equipment_id`,\n\t\t\t\t\t\t\t\t\t\t`serial_num`,\n\t\t\t\t\t\t\t\t\t\t`ctc_id_no`\n\t\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t\t'{$next_eq_auto_id}',\n\t\t\t\t\t\t\t\t\t\t\t'{$serial}',\n\t\t\t\t\t\t\t\t\t\t\t'{$ctc}'\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t");
     }
     if ($this->db->trans_status() === FALSE) {
         $this->db->trans_rollback();
     } else {
         $this->db->trans_commit();
     }
     $this->home_page();
 }
Ejemplo n.º 8
0
 /**
  * Tests the various ways to fetch (select queries)
  * data using adapter methods in the facade.
  * Also tests the new R::getAssocRow() method, 
  * as requested in issue #324.
  */
 public function testFetchTypes()
 {
     R::nuke();
     $page = R::dispense('page');
     $page->a = 'a';
     $page->b = 'b';
     R::store($page);
     $page = R::dispense('page');
     $page->a = 'c';
     $page->b = 'd';
     R::store($page);
     $expect = '[{"id":"1","a":"a","b":"b"},{"id":"2","a":"c","b":"d"}]';
     asrt(json_encode(R::getAll('SELECT * FROM page')), $expect);
     $expect = '{"1":"a","2":"c"}';
     asrt(json_encode(R::getAssoc('SELECT id, a FROM page')), $expect);
     asrt(json_encode(R::getAssoc('SELECT id, a, b FROM page')), $expect);
     $expect = '[{"id":"1","a":"a"},{"id":"2","a":"c"}]';
     asrt(json_encode(R::getAssocRow('SELECT id, a FROM page')), $expect);
     $expect = '[{"id":"1","a":"a","b":"b"},{"id":"2","a":"c","b":"d"}]';
     asrt(json_encode(R::getAssocRow('SELECT id, a, b FROM page')), $expect);
     $expect = '{"id":"1","a":"a","b":"b"}';
     asrt(json_encode(R::getRow('SELECT * FROM page WHERE id = 1')), $expect);
     $expect = '"a"';
     asrt(json_encode(R::getCell('SELECT a FROM page WHERE id = 1')), $expect);
     $expect = '"b"';
     asrt(json_encode(R::getCell('SELECT b FROM page WHERE id = 1')), $expect);
     $expect = '"c"';
     asrt(json_encode(R::getCell('SELECT a FROM page WHERE id = 2')), $expect);
     $expect = '["a","c"]';
     asrt(json_encode(R::getCol('SELECT a FROM page')), $expect);
     $expect = '["b","d"]';
     asrt(json_encode(R::getCol('SELECT b FROM page')), $expect);
 }
Ejemplo n.º 9
0
 public function update($id)
 {
     $request_fields = file_get_contents('php://input');
     $report_type = json_decode($request_fields, true);
     $rpt_updated = R::getAll("UPDATE `report_type` \n\t\t\t\t\t\t\t\tSET \n\t\t\t\t\t\t\t\t\t`report_name`='{$report_type['report_name']}',\n\t\t\t\t\t\t\t\t\t`description`='{$report_type['description']}'\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t`id` = '{$id}'\n\t\t\t\t\t\t\t\t");
     return $rpt_updated;
 }
 /**
  * @return array
  */
 protected function makeCombinedData()
 {
     $combinedRows = array();
     $groupBy = $this->resolveGroupBy('EmailMessage', 'sentDateTime');
     $beginDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($this->beginDate);
     $endDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($this->endDate);
     if ($this->marketingList == null) {
         $searchAttributeData = static::makeCampaignsSearchAttributeData('sentDateTime', $beginDateTime, $endDateTime, $this->campaign);
         $sql = static::makeCampaignsSqlQuery($searchAttributeData, $groupBy);
         $rows = R::getAll($sql);
         foreach ($rows as $row) {
             $chartIndexToCompare = $row[$this->resolveIndexGroupByToUse()];
             $combinedRows[$chartIndexToCompare] = $row;
         }
     }
     if ($this->campaign == null) {
         $searchAttributeData = static::makeAutorespondersSearchAttributeData('sentDateTime', $beginDateTime, $endDateTime, $this->marketingList);
         $sql = static::makeAutorespondersSqlQuery($searchAttributeData, $groupBy);
         $rows = R::getAll($sql);
         foreach ($rows as $row) {
             $chartIndexToCompare = $row[$this->resolveIndexGroupByToUse()];
             if (!isset($combinedRows[$chartIndexToCompare])) {
                 $combinedRows[$chartIndexToCompare] = $row;
             } else {
                 $combinedRows[$chartIndexToCompare][self::COUNT] += $row[self::COUNT];
                 $combinedRows[$chartIndexToCompare][self::UNIQUE_OPENS] += $row[self::UNIQUE_OPENS];
                 $combinedRows[$chartIndexToCompare][self::UNIQUE_CLICKS] += $row[self::UNIQUE_CLICKS];
             }
         }
     }
     return $combinedRows;
 }
Ejemplo n.º 11
0
 public function get_pima_controls_reported($user_group_id, $user_filter_used, $from, $to)
 {
     $sql = "CALL get_pima_controls_reported('" . $from . "','" . $to . "'," . $user_group_id . "," . $user_filter_used . ")";
     $res = R::getAll($sql);
     // print_r($res);die();
     return $res;
 }
Ejemplo n.º 12
0
 public function testProcessStatusAndMessagesForEachRow()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $testTableName = $import->getTempTableName();
     $this->assertTrue(ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $testTableName));
     $count = ImportDatabaseUtil::getCount($testTableName);
     $this->assertEquals(5, $count);
     //Now add import results.
     $resultsUtil = new ImportResultsUtil($import);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(2);
     $rowDataResultsUtil->setStatusToUpdated();
     $rowDataResultsUtil->addMessage('the first message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(3);
     $rowDataResultsUtil->setStatusToCreated();
     $rowDataResultsUtil->addMessage('the second message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(4);
     $rowDataResultsUtil->setStatusToError();
     $rowDataResultsUtil->addMessage('the third message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $resultsUtil->processStatusAndMessagesForEachRow();
     $sql = 'select * from ' . $testTableName . ' where id != 1';
     $tempTableData = R::getAll($sql);
     $compareData = array(array('id' => 2, 'column_0' => 'abc', 'column_1' => '123', 'column_2' => 'a', 'status' => 1, 'serializedmessages' => serialize(array('the first message'))), array('id' => 3, 'column_0' => 'def', 'column_1' => '563', 'column_2' => 'b', 'status' => 2, 'serializedmessages' => serialize(array('the second message'))), array('id' => 4, 'column_0' => 'efg', 'column_1' => '456', 'column_2' => 'a', 'status' => 3, 'serializedmessages' => serialize(array('the third message'))), array('id' => 5, 'column_0' => 'we1s', 'column_1' => null, 'column_2' => 'b', 'status' => null, 'serializedmessages' => null));
     $this->assertEquals($compareData, $tempTableData);
 }
Ejemplo n.º 13
0
 public function user_desc($user_group_id, $user_filter_used)
 {
     $sql = "";
     $display = "";
     if ($user_filter_used > 0) {
         if ($user_group_id == 3) {
             $sql = "SELECT COUNT(*), `name` FROM `partner` WHERE `id`= {$user_filter_used} ";
             $display = "Partner: ";
         } elseif ($user_group_id == 9) {
             $sql = "SELECT COUNT(*), `name` FROM `region` WHERE `id`= {$user_filter_used} ";
             $display = "Region: ";
         } elseif ($user_group_id == 8) {
             $sql = "SELECT COUNT(*), `name` FROM `district` WHERE `id`= {$user_filter_used} ";
             $display = "District: ";
         } elseif ($user_group_id == 6) {
             $sql = "SELECT COUNT(*), `name` FROM `facility` WHERE `id`= {$user_filter_used} ";
             $display = "Facility: ";
         }
     }
     if ($sql != "") {
         $res = R::getAll($sql);
         echo $display . $res[0]["name"];
     } else {
         echo "National";
     }
 }
Ejemplo n.º 14
0
 public function read_ctrl()
 {
     $sql_get_ctr = "SELECT * FROM `v_pima_tests_details` WHERE `assay_id`='3'";
     $ctr_res = R::getAll($sql_get_ctr);
     foreach ($ctr_res as $key => $value) {
         $sql_ins = "INSERT INTO `pima_control` \n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t`device_test_id`,\n\t\t\t\t\t\t\t\t\t`pima_upload_id`,\n\t\t\t\t\t\t\t\t\t`assay_id`,\n\t\t\t\t\t\t\t\t\t`sample_code`,\n\t\t\t\t\t\t\t\t\t`error_id`,\n\t\t\t\t\t\t\t\t\t`operator`,\n\t\t\t\t\t\t\t\t\t`barcode`,\n\t\t\t\t\t\t\t\t\t`expiry_date`,\n\t\t\t\t\t\t\t\t\t`device`,\n\t\t\t\t\t\t\t\t\t`software_version`,\n\t\t\t\t\t\t\t\t\t`cd4_count`,\n\t\t\t\t\t\t\t\t\t`facility_equipment_id`,\n\t\t\t\t\t\t\t\t\t`result_date`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(\n\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t";
     }
 }
Ejemplo n.º 15
0
 public function getAll($isBean = false)
 {
     if ($isBean) {
         return R::findAll('guest', 'ORDER BY modify_date DESC');
     } else {
         return R::getAll('SELECT * FROM guest ORDER BY modify_date DESC');
     }
 }
 public function getOptionValueWithLinkAndLine()
 {
     $rows = R::getAll("SELECT  * FROM  line");
     foreach ($rows as $row) {
         $data .= "clientinfo['{$row['linetitle']}'] = '{$row['vsrlink']}';\n";
     }
     return $data;
 }
Ejemplo n.º 17
0
 public function compare($car1, $car2)
 {
     $sql = "SELECT \t`img`.`upload_group_id`,\n\t\t\t\t\t`img`.`img_url`,\n\t\t\t        `lt`.`description`,\n\t\t\t        `lt`.`location`,\n\t\t\t        `lt`.`price`,\n\t\t\t        `lt`.`make`,\n\t\t\t        `lt`.`status`,\n\t\t\t        `lt`.`upload_timestamp`,\n\t\t\t        `lt`.`v_condition`,\n\t\t\t        `lt`.`year`\n\t\t\tFROM \n\t\t\t\t\t`images` AS `img`\n\t\t\tLEFT JOIN \n\t\t\t\t\t`lot` AS `lt`\n\t\t\tON \n\t\t\t\t`lt`.`upload_timestamp` = `img`.`upload_group_id`\n\t\t\tWHERE `lt`.`delete_status`= 0\n\t\t\tAND `lt`.`deal_type` = 0\n\t\t\tAND `lt`.`status` = 0\n\t\t\tAND `img`.`upload_group_id` = '" . $car1 . "'\n\t\t\tAND `img`.`upload_group_id` = '" . $car2 . "'\n\t\t";
     echo $sql;
     die;
     $result = R::getAll($sql);
     return $result;
 }
 /**
  * @return int
  */
 public function calculateTotalItemCount()
 {
     $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
     $sql = $this->makeSqlQueryForFetchingTotalItemCount($selectQueryAdapter);
     $rows = R::getAll($sql);
     $count = count($rows);
     return $count;
 }
Ejemplo n.º 19
0
 /**
  * Build modelcreationapisync table
  */
 public static function buildTable()
 {
     $result = R::getAll("SHOW TABLES LIKE '" . self::TABLE_NAME . "'");
     $tableExists = count($result);
     if (!$tableExists) {
         R::exec("create table " . self::TABLE_NAME . " (\n                               id int(11)         unsigned not null PRIMARY KEY AUTO_INCREMENT ,\n                               servicename        varchar(50) not null,\n                               modelid int(11)    unsigned not null,\n                               modelclassname     varchar(50) not null,\n                               createddatetime    datetime DEFAULT null\n                             )");
     }
 }
Ejemplo n.º 20
0
function getContactosJustNamesByClientId($clientid)
{
    $rows = R::getAll("select c.id, c.clientes_id, c.nombre from contactos c where c.clientes_id=?", array($clientid));
    $contactos = R::convertToBeans('contactos', $rows);
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($contactos));
}
Ejemplo n.º 21
0
 public function save_user()
 {
     $name = $this->input->post("name");
     $username = strtolower($this->input->post("usr"));
     $email = $this->input->post("email");
     $phone = $this->input->post("phone");
     $usr_grp = (int) $this->input->post("usr_grp");
     $par = (int) $this->input->post("par");
     $reg = (int) $this->input->post("reg");
     $dis = (int) $this->input->post("dis");
     $fac = (int) $this->input->post("fac");
     $default_password = "";
     $access_level = 3;
     $activation_clause = $this->create_activation_clause();
     if (!($par == 0 && $reg == 0 && $dis == 0 && $fac == 0) || ($usr_grp == 2 || $usr_grp == 4)) {
         //echo "<br/>saving..<br/>";
         $last_usr_auto_id_res = R::getAll("SELECT `id` FROM `user` ORDER BY `id` DESC LIMIT 1");
         $next_usr_auto_id = 1;
         if (sizeof($last_usr_auto_id_res) > 0) {
             $next_usr_auto_id = $last_usr_auto_id_res[0]['id'] + 1;
         } else {
             $next_usr_auto_id = 1;
         }
         if ($usr_grp == 1) {
             $default_password = $this->encrypt($this->config->item("default_admin_password"));
             $access_level = 1;
         } else {
             if ($usr_grp == 2) {
                 $default_password = $this->encrypt($this->config->item("default_admin_password"));
                 $access_level = 2;
             } else {
                 $default_password = $this->encrypt($this->config->item("default_user_password"));
                 $access_level = 3;
             }
         }
         $this->db->trans_begin();
         $this->db->query("INSERT INTO `user`\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t`id`,\n\t\t\t\t\t\t\t\t\t\t`username`,\n\t\t\t\t\t\t\t\t\t\t`password`,\n\t\t\t\t\t\t\t\t\t\t`name`,\n\t\t\t\t\t\t\t\t\t\t`user_group_id`,\n\t\t\t\t\t\t\t\t\t\t`user_access_level_id`,\n\t\t\t\t\t\t\t\t\t\t`phone`,\n\t\t\t\t\t\t\t\t\t\t`email`,\n\t\t\t\t\t\t\t\t\t\t`status`,\n\t\t\t\t\t\t\t\t\t\t`activation_clause`\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t'{$next_usr_auto_id}',\n\t\t\t\t\t\t\t\t\t\t'{$username}',\n\t\t\t\t\t\t\t\t\t\t'{$default_password}',\n\t\t\t\t\t\t\t\t\t\t'{$name}',\n\t\t\t\t\t\t\t\t\t\t'{$usr_grp}',\n\t\t\t\t\t\t\t\t\t\t'{$access_level}',\n\t\t\t\t\t\t\t\t\t\t'{$phone}',\n\t\t\t\t\t\t\t\t\t\t'{$email}',\n\t\t\t\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t\t\t\t'{$activation_clause}'\n\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t");
         if ($usr_grp == 6) {
             $this->db->query("INSERT INTO `facility_user`\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t`user_id`,\n\t\t\t\t\t\t\t\t\t\t\t`facility_id`\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t\t'{$next_usr_auto_id}',\n\t\t\t\t\t\t\t\t\t\t\t'{$fac}'\n\t\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t");
         }
         if ($usr_grp == 8) {
             $this->db->query("INSERT INTO `district_user`\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t`user_id`,\n\t\t\t\t\t\t\t\t\t\t\t`district_id`\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t\t'{$next_usr_auto_id}',\n\t\t\t\t\t\t\t\t\t\t\t'{$dis}'\n\t\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t");
         }
         if ($usr_grp == 9) {
             $this->db->query("INSERT INTO `region_user`\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t`user_id`,\n\t\t\t\t\t\t\t\t\t\t\t`region_id`\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t\t'{$next_usr_auto_id}',\n\t\t\t\t\t\t\t\t\t\t\t'{$reg}'\n\t\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t");
         }
         if ($usr_grp == 3) {
             $this->db->query("INSERT INTO `partner_user`\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t`user_id`,\n\t\t\t\t\t\t\t\t\t\t\t`partner_id`\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t\t'{$next_usr_auto_id}',\n\t\t\t\t\t\t\t\t\t\t\t'{$fac}'\n\t\t\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t");
         }
         if ($this->db->trans_status() === FALSE) {
             $this->db->trans_rollback();
         } else {
             $this->db->trans_commit();
         }
     }
     redirect("admin/users");
 }
Ejemplo n.º 22
0
 public function getVendorList()
 {
     $rows = R::getAll("SELECT *FROM user where type= 2 and isactive = 1 order by id DESC limit 200 ");
     foreach ($rows as $row) {
         $row['currency'] = L::getBaseCurrencyFromValue($row['currency']);
         $data[] = $row;
     }
     return $data;
 }
Ejemplo n.º 23
0
 function __construct($query, $array)
 {
     //        $this->items = getDataBase::getData("SELECT *
     //        FROM  `menu` ,  `menu_item`
     //        WHERE menu_item.menu_id =" . intval($id) . "
     //        AND menu.menu_id = menu_item.menu_id");
     db_connect::connect();
     $this->items = R::getAll($query, $array);
 }
 /**
  * Function to send notification when events is updated
  * @param \RedBeanPHP\OODBBean $eventDetails Details of event which is added
  * @return void
  * **/
 public function eventUpdateNotifications(\RedBeanPHP\OODBBean $eventDetails)
 {
     // get the users who are participating in event
     $getUserParticipationDetails = "SELECT u.device_token,u.device_type\r\n                                        FROM users_events_participation upe \r\n                                        JOIN users u ON upe.users_id = u.id AND upe.events_id = :eId\r\n                                        WHERE upe.participation_id IN (1,3)";
     $participantDevices = \R::getAll($getUserParticipationDetails, array(':eId' => $eventDetails->id));
     $objUserModel = new Users();
     $requiredTokens = $objUserModel->getUserDevicesWithinDistance(100, $eventDetails->longitude, $eventDetails->latitude, $eventDetails->users_id);
     $message = "{$eventDetails->event_name} is updated";
     $this->_sendNotifications(array_merge($requiredTokens, $participantDevices), $message);
 }
Ejemplo n.º 25
0
function get_services_for_user($userid)
{
    $sql = "select serviceid from services s join userservices us on s.id=us.serviceid where userid=?";
    $data = R::getAll($sql, array($userid));
    $arr = array();
    foreach ($data as $value) {
        array_push($arr, $value["serviceid"]);
    }
    return $arr;
}
Ejemplo n.º 26
0
 public function reset_facility_default_users()
 {
     $sql = "SELECT \n\t\t\t\t\t`u`.`id`AS `user_id`,\n\t\t\t\t\t`u`.`email` AS `mfl_code`,\n\t\t\t\t\t`u`.`name`,\n\t\t\t\t\t`f`.`id` `facility_id`    \n\t\t\t\tFROM `aauth_users` `u` \n\t\t\t\tLEFT JOIN `facility` `f` ON `u`.`email` = `f`.`mfl_code`\n\t\t\t\tWHERE `u`.`email` > 0";
     $res = R::getAll($sql);
     foreach ($res as $key => $value) {
         // echo "j";
         $this->aauth->set_member($value['user_id'], 4);
         $this->aauth->set_user_var('linked_entity_id', $value['facility_id'], $value['user_id']);
     }
 }
Ejemplo n.º 27
0
 public function find_user_group_name($id)
 {
     $sql = "SELECT `user_group`.`name` FROM `user_group` WHERE `user_group`.`id` = '{$id}'";
     $res = R::getAll($sql);
     $name = "";
     foreach ($res as $index) {
         $name = $index['name'];
     }
     return $name;
 }
Ejemplo n.º 28
0
function getSegmentosJustNames($clientid)
{
    $app = \Slim\Slim::getInstance();
    $rows = R::getAll("select s.id, s.clientes_id, s.nombre from segmento s where s.clientes_id=?", array($clientid));
    $segmentos = R::convertToBeans('segmentos', $rows);
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($segmentos));
}
Ejemplo n.º 29
0
 public static function getRowsByCreatedUserId($userId)
 {
     assert('is_int($userId)');
     // Lower is to ensure like's case insensitivity for all databases.
     $sql = 'select filteredlist.id, filteredlist.name ' . 'from filteredlist, item ' . 'where filteredlist.item_id = item.id ' . 'order by filteredlist.name;';
     $rows = array();
     foreach (R::getAll($sql, array('item.createdbyuser__user_id' => $userId)) as $row) {
         $rows[$row['id']] = $row['name'];
     }
     return $rows;
 }
Ejemplo n.º 30
0
 /**
  * Conta as linhas totais do SELECT
  * @return int
  */
 private function getData()
 {
     $rp = $this->rpObj->getRp();
     $page = ($this->curPage - 1) * $this->rpObj->getRp();
     $orderSql = "";
     if ($this->order) {
         $orderSql = " ORDER BY {$this->order}";
     }
     $sqlCount = "SELECT * AS QNT FROM ({$this->sql}) AS TABLE {$orderSql} LIMIT {$page},{$rp}";
     return (int) \R::getAll($sqlCount);
 }