AssistSetting.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class AssistSetting extends BusinessActiveRecord {
  7. public static function model($className = __CLASS__){
  8. return parent::model($className);
  9. }
  10. public function tableName(){
  11. return "assist_setting";
  12. }
  13. //修改后台设置
  14. public function updateAssistSetting($data){
  15. if(!$data) return false;
  16. $trans = $this->getDbConnection()->beginTransaction();
  17. try{
  18. $setting=$this->getDbConnection()->createCommand("select * from assist_setting limit 1")->queryRow();
  19. if($setting){
  20. $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values ";
  21. $insertSql.="('".$setting['accept_school_open']."','".$data['cutting_task']."','".$data['open_cutting_upper_limit']."','".$data['cutting_task_upper_limit_num']."','".$data['scan_task']."','".$data['open_scan_upper_limit']."','".$data['scan_task_upper_limit_num']."')";
  22. }else{
  23. $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values ";
  24. $insertSql.="('0','".$data['cutting_task']."','".$data['open_cutting_upper_limit']."','".$data['cutting_task_upper_limit_num']."','".$data['scan_task']."','".$data['open_scan_upper_limit']."','".$data['scan_task_upper_limit_num']."')";
  25. }
  26. $this->getDbConnection()->createCommand("delete from assist_setting ")->execute();
  27. $this->getDbConnection()->createCommand($insertSql)->execute();
  28. $trans->commit();
  29. return true;
  30. }catch (Exception $e){
  31. $trans->rollback();
  32. }
  33. return false;
  34. }
  35. //读取后台设置
  36. public function getAssistSetting(){
  37. $setting=$this->getDbConnection()->createCommand("select accept_school_open,cutting_task,open_cutting_upper_limit,cutting_task_upper_limit_num,scan_task,open_scan_upper_limit,scan_task_upper_limit_num from assist_setting limit 1")->queryRow();
  38. return $setting;
  39. }
  40. //修改后台学校开关
  41. public function updateAssistSchoolSetting($data){
  42. if(!$data) return false;
  43. $trans = $this->getDbConnection()->beginTransaction();
  44. try{
  45. $setting=$this->getDbConnection()->createCommand("select * from assist_setting limit 1")->queryRow();
  46. if($setting){
  47. $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values ";
  48. $insertSql.="('".$data['accept_school_open']."','".$setting['cutting_task']."','".$setting['open_cutting_upper_limit']."','".$setting['cutting_task_upper_limit_num']."','".$setting['scan_task']."','".$setting['open_scan_upper_limit']."','".$setting['scan_task_upper_limit_num']."')";
  49. }else{
  50. $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values ";
  51. $insertSql.="('".$data['accept_school_open']."','1','0','0','1','0','0')";
  52. }
  53. $this->getDbConnection()->createCommand("delete from assist_setting ")->execute();
  54. $this->getDbConnection()->createCommand($insertSql)->execute();
  55. $trans->commit();
  56. return true;
  57. }catch (Exception $e){
  58. $trans->rollback();
  59. }
  60. return false;
  61. }
  62. }