admin_services_model.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. class admin_services_model extends Model {
  3. public function getBoxes() {
  4. $result = $this->query("select * from azonics_services where box_status<>'0';");
  5. return $result;
  6. }
  7. public function loadBox() {
  8. $box_id = $this->escapeString($_REQUEST['id']);
  9. $row = $this->query("select * from azonics_services where box_id='".$box_id."';");
  10. return $row[0];
  11. }
  12. public function saveBox() {
  13. $data = $this->escapeArray($_REQUEST);
  14. if ($data['box_id']!='') {
  15. if ($_FILES['box_banner']['tmp_name']!=='') {
  16. $fname = 'banner_'.time().'.jpg';
  17. $path = 'static/uploads/thumbs/';
  18. move_uploaded_file($_FILES['box_banner']['tmp_name'],$path.$fname);
  19. $this->execute("UPDATE azonics_services SET box_banner='".$path.$fname."' WHERE box_id='".$data['box_id']."';");
  20. }
  21. $this->execute("update azonics_services set "
  22. . "box_title='".$data['box_title']."', "
  23. . "box_subtitle='".$data['box_subtitle']."', box_subtitle_en='".$data['box_subtitle_en']."', box_button_text='".$data['box_button_text']."', box_button_text_en='".$data['box_button_text_en']."', parent_service='".$data['parent_service']."' "
  24. . "where box_id='".$data['box_id']."';");
  25. return true;
  26. }
  27. else {
  28. if ($_FILES['box_banner']['tmp_name']!=='') {
  29. $fname = 'banner_'.time().'.jpg';
  30. $path = 'static/uploads/thumbs/';
  31. move_uploaded_file($_FILES['box_banner']['tmp_name'],$path.$fname);
  32. }
  33. $this->execute("insert into azonics_services set "
  34. . "box_slug='".$data['box_slug']."', "
  35. . "box_title='".$data['box_title']."', "
  36. . "box_subtitle='".$data['box_subtitle']."', "
  37. . "box_subtitle_en='".$data['box_subtitle_en']."', "
  38. . "box_button_text='".$data['box_button_text']."', "
  39. . "box_button_text_en='".$data['box_button_text_en']."', "
  40. . "box_status='1', box_banner='".$path.$fname."', "
  41. . "box_user='".$_SESSION['admin_user']->admin_id."', parent_service='".$data['parent_service']."';");
  42. return true;
  43. }
  44. }
  45. public function deleteBox() {
  46. $box_id = $this->escapeString($_REQUEST['id']);
  47. $this->execute("update azonics_services set box_status='0' where box_id='".$box_id."';");
  48. return true;
  49. }
  50. }