/application/modules/dashboard/models/m_configuration.php

https://bitbucket.org/earnest-tekkies/sample-php-ci · PHP · 112 lines · 66 code · 20 blank · 26 comment · 5 complexity · 8f82343129d9759dda1671ae8cd217c7 MD5 · raw file

  1. <?php
  2. class M_configuration extends CI_Model {
  3. var $title = '';
  4. var $content = '';
  5. var $date = '';
  6. function __construct(){
  7. // Call the Model constructor
  8. parent::__construct();
  9. }
  10. // -----------------------------------------------------------------------------------------
  11. /**
  12. *This function 'll get pdfs protection configuration details from respective database table.
  13. * @return the pdf protection details record.
  14. */
  15. function getPDFConfig(){
  16. $records=array();
  17. $this->db->select('*');
  18. $query=$this->db->get('sm_pdf_protect_config');
  19. $result = $query->result();
  20. foreach($result as $str){
  21. $datas=array('font_size'=>$str->font_size,'font_color'=>$str->font_color,'stamping_position'=>$str->stamping_position,'stamping_data'=>$str->stamping_data);
  22. array_push($records,$datas);
  23. }
  24. return $records;
  25. }
  26. // -----------------------------------------------------------------------------------------
  27. /**
  28. *This function 'll update pdfs protection configuration details in respective database table.
  29. */
  30. function updatePDFConfig($updatepdfProtectionArr){
  31. $rowCount=count($this->getPDFConfig());
  32. //insert the Pdf config details if there is no such row otherwise update the details.
  33. if($rowCount > 0){
  34. $result=$this->db->update('sm_pdf_protect_config',$updatepdfProtectionArr);
  35. }
  36. else {
  37. $result=$this->db->insert('sm_pdf_protect_config',$updatepdfProtectionArr);
  38. }
  39. }
  40. // -----------------------------------------------------------------------------------------
  41. /**
  42. *This function 'll get automatic emails details from respective database table.
  43. * @return the automatic email details record.
  44. */
  45. function getautomaticEmails($type=0,$language=1){
  46. $records=array();
  47. $this->db->select('*');
  48. if($type > 0){
  49. $this->db->where('type' ,$type);
  50. }
  51. $this->db->where('language' ,$language);
  52. $query=$this->db->get('sm_automatic_emails');
  53. $result = $query->result();
  54. foreach($result as $str){
  55. $datas=array('type'=>$str->type,'enabled'=>$str->enabled,'subject'=>$str->subject,'message'=>$str->message,'days_before_expire'=>$str->days_before_expire);
  56. array_push($records,$datas);
  57. }
  58. return $records;
  59. }
  60. // -----------------------------------------------------------------------------------------
  61. /**
  62. *This function 'll get automatic emails details from respective database table.
  63. * @return the number of records.
  64. */
  65. function checkAutomaticEmailTemplateExists($templateId,$language_id=1){
  66. $this->db->select('*');
  67. $this->db->where('type' ,$templateId);
  68. $this->db->where('language' ,$language_id);
  69. $query=$this->db->get('sm_automatic_emails');
  70. if($query->num_rows()==1){
  71. return true;
  72. }else{
  73. return false;
  74. }
  75. }
  76. // -----------------------------------------------------------------------------------------
  77. /**
  78. *This function 'll add automatic emails details in respective database table.
  79. */
  80. function addAutomaticEmailDetails($automaticEmailDetails){
  81. $type = intval($automaticEmailDetails['type']);
  82. $language_id = intval($automaticEmailDetails['language']);
  83. //insert the automatic email details if there is no such record otherwise update the details.
  84. if($this->checkAutomaticEmailTemplateExists($type,$language_id)){
  85. $this->db->where('type' ,$type);
  86. $result=$this->db->update('sm_automatic_emails',$automaticEmailDetails);
  87. }else{
  88. $result=$this->db->insert('sm_automatic_emails',$automaticEmailDetails);
  89. }
  90. }
  91. }
  92. ?>