| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- class admin_irodak_model extends Model {
- public function getIrodaList() {
- $result = $this->query("SELECT * FROM irodak WHERE office_id<>'' ORDER BY id ASC;");
- return $result;
- }
- public function getOffices() {
- $result = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1' ORDER BY nev ASC;");
- return $result;
- }
- public function getOffice($id) {
- $result = $this->query("SELECT * FROM hiper_iroda WHERE azonosito='".$id."';");
- return $result[0];
- }
- public function getIroda($id) {
- $result = $this->query("SELECT * FROM irodak WHERE id='".$id."';");
- return $result[0];
- }
- public function isAlredyIroda($id) {
- $result = $this->query("SELECT * FROM irodak WHERE office_id='".$id."';");
- if (sizeof($result)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- public function getIrodaByOfficeID($id) {
- $result = $this->query("SELECT * FROM irodak WHERE office_id='".$id."';");
- return $result[0]->id;
- }
- public function getReferens($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- $result = $this->query("SELECT * FROM referensek WHERE id='".$id."';");
- return $result[0];
- }
- else {
- return false;
- }
- }
- public function saveIroda($data) {
- $data = $this->escapeArray($data);
- $check = $data['pixelid']+0;
- if (is_integer($check)) {
- $this->execute("UPDATE irodak SET description='".$data['description']."', pixelid='".$data['pixelid']."' WHERE id='".$data['id']."'");
- return true;
- }
- else {
- return false;
- }
- }
- public function add_iroda($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- if ($this->isAlredyIroda($id)) {
- return $this->getIrodaByOfficeID($id);
- }
- else {
- $office = $this->getOffice($id);
- $this->execute("INSERT INTO irodak SET office_id='".$office->azonosito."';");
- return $this->getLastInsertID();
- }
- }
- else {
- return false;
- }
- }
- public function deleteIroda($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- $this->execute("DELETE FROM irodak WHERE id='".$id."';");
- return true;
- }
- else {
- return false;
- }
- }
- public function setIrodaState($id) {
- if ($id!='') {
- $res = $this->query("SELECT * FROM irodak WHERE id='".$id."';");
- if ($res[0]->active=='1') {
- $new = '0';
- }
- else {
- $new = '1';
- }
- $this->execute("UPDATE irodak SET active='".$new."' WHERE id='".$id."';");
-
- return true;
- }
- else {
- return false;
- }
- }
- }
|