| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- class admin_ertekeles_model extends Model {
- public function getReferensList() {
- $result = $this->query("SELECT * FROM referensek WHERE name<>'' ORDER BY name ASC;");
- return $result;
- }
- public function getAgents() {
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE aktiv='1' ORDER BY nev ASC;");
- return $result;
- }
- public function getAgent($id) {
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE id='".$id."';");
- return $result[0];
- }
- public function isAlredyAgent($id) {
- $result = $this->query("SELECT * FROM referensek WHERE agent_id='".$id."';");
- if (sizeof($result)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- public function getReferensByAgentID($id) {
- $result = $this->query("SELECT * FROM referensek WHERE agent_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 saveErtekeles($data) {
- $data = $this->escapeArray($data);
- $this->execute("UPDATE referensek SET
- ratings='".$data['ratings']."',
- ratings_avg='".$data['ratings_avg']."' WHERE id='".$data['id']."'");
- return true;
- }
- public function add_referens($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- if ($this->isAlredyAgent($id)) {
- return $this->getReferensByAgentID($id);
- }
- else {
- $agent = $this->getAgent($id);
- $this->execute("INSERT INTO referensek SET
- name='".$agent->nev."',
- agent_id='".$agent->id."',
- office_id='".$agent->iroda."';");
- return $this->getLastInsertID();
- }
- }
- else {
- return false;
- }
- }
- public function saveVelemeny($data) {
- $data = $this->escapeArray($data);
- if ($data['velemenyid']=='' || $data['velemenyid']=='0') {
- $agent = $this->getReferens($data['id']);
- $this->execute("INSERT INTO velemenyek SET
- agent_id='".$agent->agent_id."',
- name='".$data['name']."',
- description='".$data['description']."';");
- }
- else {
- $this->execute("UPDATE velemenyek SET
- name='".$data['name']."',
- description='".$data['description']."' WHERE id='".$data['velemenyid']."';");
- }
- return true;
- }
- public function getVelemenyek($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- $agent = $this->getReferens($id);
- $result = $this->query("SELECT * FROM velemenyek WHERE agent_id='".$agent->agent_id."' ORDER BY id DESC;");
- return $result;
- }
- else {
- return false;
- }
- }
- public function getVelemeny($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- $result = $this->query("SELECT * FROM velemenyek WHERE id='".$id."';");
- return $result[0];
- }
- else {
- return false;
- }
- }
- public function deleteVelemeny($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- $this->execute("DELETE FROM velemenyek WHERE id='".$id."';");
- return true;
- }
- else {
- return false;
- }
- }
- public function deleteReferens($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- $agent = $this->getReferens($id);
- $this->execute("DELETE FROM velemenyek WHERE agent_id='".$agent->agent_id."';");
- $this->execute("DELETE FROM referensek WHERE id='".$id."';");
- return true;
- }
- else {
- return false;
- }
- }
- }
|