recommend.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. class recommend_c extends Control
  3. {
  4. var $subject;
  5. function __construct()
  6. {
  7. parent::Control();
  8. $this->load_model("user");
  9. $this->load_model("recommend");
  10. }
  11. function recommend_c()
  12. {
  13. $this->__construct();
  14. }
  15. function index_f()
  16. {
  17. if(!$_SESSION["user_id"])
  18. {
  19. error('',$this->url('login'));
  20. }
  21. $rs = $this->user_m->user_from_id($_SESSION["user_id"]);
  22. $this->tpl->assign("rs",$rs);
  23. $rslist = $this->recommend_m->get_list(3);
  24. $this->tpl->assign("rslist",$rslist);
  25. $sitetitle = $this->lang["recommend"];
  26. $this->tpl->assign("sitetitle",$sitetitle);
  27. $this->tpl->display("recommend.".$this->tpl->ext);
  28. }
  29. function save_f()
  30. {
  31. if(!$_SESSION["user_id"])
  32. {
  33. error('',$this->url('login'));
  34. }
  35. $array = array();
  36. $array["username"] = $this->trans_lib->safe("username");
  37. $array["cellphone"] = $this->trans_lib->safe("cellphone");
  38. $array["proname"] = $this->trans_lib->safe("proname");
  39. $array["appointment_date"] = $this->trans_lib->safe("selorderTime");
  40. $array["appointment_time"] = $this->trans_lib->safe("selorderTime2");
  41. $array["remark"] = $this->trans_lib->safe("remark");
  42. $array["uid"] = $_SESSION["user_id"];
  43. $array["uname"] = $_SESSION["user_name"];
  44. $array["postdate"] = $this->system_time;
  45. $array["status"] = 0;
  46. if(!$array["username"])
  47. {
  48. echo "请输入被推荐人的姓名";
  49. exit;
  50. }
  51. if(!$array["cellphone"])
  52. {
  53. echo "请输入被推荐人的手机号码";
  54. exit;
  55. }
  56. if(!$array["proname"])
  57. {
  58. echo "请选择意向项目";
  59. exit;
  60. }
  61. $checkcellphone = $this->checkcellphone($array["cellphone"]);
  62. if($checkcellphone != "0")
  63. {
  64. echo "该手机号用户已被推荐过了";
  65. exit;
  66. }
  67. $this->recommend_m->save($array);
  68. echo "1";
  69. exit;
  70. }
  71. //检测手机号是否存在
  72. function checkcellphone_f()
  73. {
  74. $cellphone = $this->trans_lib->safe("cellphone");
  75. exit($this->checkcellphone($cellphone));
  76. }
  77. function checkcellphone($cellphone)
  78. {
  79. if(!$cellphone)
  80. {
  81. return "1";
  82. }
  83. $rs = $this->recommend_m->customer_from_cellphone($cellphone);
  84. if($rs)
  85. {
  86. return "1";
  87. }
  88. else
  89. {
  90. return "0";
  91. }
  92. }
  93. //检测是否自己手机号
  94. function checkismycellphone_f()
  95. {
  96. $cellphone = $this->trans_lib->safe("cellphone");
  97. exit($this->checkismycellphone($cellphone));
  98. }
  99. function checkismycellphone($cellphone)
  100. {
  101. if(!$cellphone)
  102. {
  103. return "1";
  104. }
  105. if($_SESSION["user_id"])
  106. {
  107. $rs = $this->user_m->user_my_cellphone($_SESSION["user_id"],$cellphone);
  108. if($rs)
  109. {
  110. return "1";
  111. }
  112. else
  113. {
  114. return "0";
  115. }
  116. }
  117. }
  118. }
  119. ?>