1
0

customerModel.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. class flow_customerClassModel extends flowModel
  3. {
  4. public function initModel()
  5. {
  6. $this->statearr = c('array')->strtoarray('停用|#888888,启用|green');
  7. $this->statarr = c('array')->strtoarray('否|#888888,是|#ff6600');
  8. }
  9. //高级搜索下
  10. public function flowsearchfields()
  11. {
  12. $arr[] = array('name'=>'所属人...','fields'=>'uid');
  13. $arr[] = array('name'=>'创建人...','fields'=>'createid');
  14. return $arr;
  15. }
  16. public function flowrsreplace($rs, $lx=0)
  17. {
  18. if(isset($rs['status'])){
  19. if($rs['status']==0)$rs['ishui'] = 1;
  20. $zt = $this->statearr[$rs['status']];
  21. $rs['statuss'] = $rs['status'];
  22. $rs['status'] = '<font color="'.$zt[1].'">'.$zt[0].'</font>';
  23. }
  24. if(isset($rs['isstat'])){
  25. $stat = $this->statarr[$rs['isstat']];
  26. $rs['isstat'] = '<font color="'.$stat[1].'">'.$stat[0].'</font>';
  27. }
  28. if(isset($rs['isgys'])){
  29. $gys = $this->statarr[$rs['isgys']];
  30. $rs['isgys'] = '<font color="'.$gys[1].'">'.$gys[0].'</font>';
  31. }
  32. if($this->rock->arrvalue($rs,'htshu','0')==0)$rs['htshu']='';
  33. if($this->rock->arrvalue($rs,'moneyz','0')==0)$rs['moneyz']='';
  34. if($this->rock->arrvalue($rs,'moneyd','0')==0)$rs['moneyd']='';
  35. if($lx==1){
  36. //$rs['suoname'] = $this->adminmodel->getmou('name','id='.$rs['uid'].'');
  37. }
  38. //详情时,移动端
  39. if($lx==1 && $this->rock->ismobile()){
  40. if(!isempt($rs['mobile']))$rs['mobile']='<a onclick="return callPhone(this)" href="tel:'.$rs['mobile'].'">'.$rs['mobile'].'</a>';
  41. if(!isempt($rs['tel']))$rs['tel']='<a onclick="return callPhone(this)" href="tel:'.$rs['tel'].'">'.$rs['tel'].'</a>';
  42. }
  43. return $rs;
  44. }
  45. //是否有查看权限
  46. protected function flowisreadqx()
  47. {
  48. $bo = false;
  49. $shateid = ','.$this->rs['shateid'].',';
  50. if(contain($shateid,','.$this->adminid.','))$bo=true;
  51. return $bo;
  52. }
  53. protected function flowgetfields_qiyong($lx)
  54. {
  55. $arr = array();
  56. if($this->uid==$this->adminid){
  57. $arr['mobile'] = '手机号';
  58. $arr['tel'] = '电话';
  59. $arr['email'] = '邮箱';
  60. $arr['routeline'] = '交通路线';
  61. }
  62. return $arr;
  63. }
  64. protected function flowoptmenu($ors, $crs)
  65. {
  66. $zt = $ors['statusvalue'];
  67. $num = $ors['num'];
  68. if($num=='ztqh'){
  69. $this->update('`status`='.$zt.'', $this->id);
  70. }
  71. //共享
  72. if($num=='shate'){
  73. $cname = $crs['cname'];
  74. $cnameid = $crs['cnameid'];
  75. $this->update(array(
  76. 'shateid' => $cnameid,
  77. 'shate' => $cname,
  78. ), $this->id);
  79. $this->push($cnameid, '客户管理', ''.$this->adminname.'将一个客户【{name}】共享给你');
  80. }
  81. //取消共享
  82. if($num=='unshate'){
  83. $this->update(array(
  84. 'shateid' => '',
  85. 'shate' => '',
  86. ), $this->id);
  87. }
  88. //放入公海
  89. if($num=='ghnoup'){
  90. $this->update(array(
  91. 'isgh' => '1',
  92. 'uid' => 0,
  93. 'suoname'=>''
  94. ), $this->id);
  95. }
  96. }
  97. protected function flowbillwhere($uid, $lx)
  98. {
  99. return array(
  100. 'order' => '`status` desc,`optdt` desc',
  101. //'table' => '`[Q]'.$this->mtable.'` a left join `[Q]admin` b on a.`uid`=b.id',
  102. //'asqom' => 'a.',
  103. //'fields'=> 'a.*,b.name as suoname'
  104. );
  105. }
  106. //导入数据的测试显示
  107. public function flowdaorutestdata()
  108. {
  109. $barr = array(
  110. 'name' => '信呼',
  111. 'type' => '软件',
  112. 'laiyuan' => '网上开拓',
  113. 'unitname' => '厦门信呼科技有限公司',
  114. 'tel' => '0592-123456',
  115. 'mobile' => '15800000000',
  116. 'email' => 'admin@rockoa.com',
  117. 'address' => '福建厦门思明区软件园',
  118. 'linkname' => '磐石',
  119. 'isgh' => '是',
  120. );
  121. $barr1 = array(
  122. 'name' => '百度',
  123. 'type' => '搜索计算',
  124. 'laiyuan' => '电话联系',
  125. 'unitname' => '百度在线网络技术(北京)有限公司',
  126. 'tel' => '010-123456',
  127. 'mobile' => '15800000001',
  128. 'email' => 'admin@baidu.com',
  129. 'address' => '北京软件园百度大厦',
  130. 'linkname' => '李彦宏',
  131. 'isgh' => '否',
  132. );
  133. $barr2 = array(
  134. 'name' => '陈先生',
  135. 'type' => '个人',
  136. 'laiyuan' => '电话联系',
  137. 'unitname' => '',
  138. 'tel' => '010-123456',
  139. 'mobile' => '15800000002',
  140. 'email' => '1111@qq.com',
  141. 'address' => '福建厦门火车站',
  142. 'linkname' => '',
  143. 'isgh' => '否',
  144. );
  145. return array($barr,$barr1,$barr2);
  146. }
  147. public function flowdaorubefore($data)
  148. {
  149. $arr = array();
  150. $dbs = m('admin');
  151. foreach($data as $k=>$rs){
  152. $isgh = (arrvalue($rs,'isgh')=='是') ? 1: 0 ;
  153. $isstat = (arrvalue($rs,'isstat')=='是') ? 1: 0 ;
  154. if(isset($rs['status'])){
  155. $rs['status'] = (arrvalue($rs,'status')=='启用') ? 1: 0 ;
  156. }
  157. if(isset($rs['suoname'])){
  158. if($isgh==0){
  159. $urs = $dbs->geturs('name:'.$rs['suoname']);
  160. if($urs)$rs['uid'] = $urs['id'];
  161. }
  162. //unset($rs['suoname']);
  163. }
  164. $rs['isgh'] = $isgh;
  165. $rs['isstat'] = $isstat;
  166. if($isgh==1)$rs['uid'] = 0;
  167. $arr[] = $rs;
  168. }
  169. return $arr;
  170. }
  171. /**
  172. * 自动放入公海
  173. */
  174. public function addgonghai()
  175. {
  176. $tshu = (int)$this->option->getval('crmaddghai','0');
  177. if($tshu<=0)return;
  178. $sneuar = array();
  179. $rows = $this->getall('`uid`>0 and `htshu`=0 and `isgys`=0 and `id` not in(select `custid` from `[Q]custsale` where `state` in(1)) and `id` not in(select `custid` from `[Q]goodm` where `type`=2 and `status` in(0,1))','lastdt,optdt,id,name,uid,unitname');
  180. $dtobj = c('date');
  181. $addghs = array();
  182. foreach($rows as $k=>$rs){
  183. $lastdt = $rs['lastdt'];
  184. if(isempt($lastdt))$lastdt = $rs['optdt'];
  185. $jg = $dtobj->datediff('d', $lastdt, $this->rock->now);
  186. if($jg > $tshu){
  187. $sneuar[$rs['uid']][] = '['.$rs['name'].']超'.$jg.'天未跟进已放入公海库';
  188. $addghs[] = $rs['id'];
  189. }else{
  190. //要放入之前2天提醒
  191. $ts = $tshu - $jg;
  192. if($ts<3)$sneuar[$rs['uid']][] = '['.$rs['name'].']将'.$ts.'天后放入公海库';
  193. }
  194. }
  195. //通知给对应人
  196. $maxlen = 5;
  197. foreach($sneuar as $uid=>$ursa){
  198. $str = '';
  199. foreach($ursa as $k1=>$s1){
  200. if($str!='')$str.="\n";
  201. if($k1>=$maxlen){
  202. $str.='还有'.(count($ursa)-$maxlen).'条,点击查看更多';
  203. break;
  204. }
  205. $str.="".$s1."";
  206. }
  207. $this->pushs($uid, $str, '客户未跟进提醒', array(
  208. 'wxurl' => $this->getwxurl()
  209. ));
  210. }
  211. if($addghs){
  212. $sid = join(',', $addghs);
  213. $this->update("`uid`=0,`isgh`=1", "`id` in($sid)");
  214. }
  215. }
  216. //对外的详情页
  217. public function flowopenxiang($da, $xiangdata)
  218. {
  219. $zdarr = array('name','type','laiyuan','unitname','tel','mobile','sheng','shi','address','routeline','shibieid','openbank','cardid','explain','linkname');
  220. $slsts = array();
  221. foreach($xiangdata as $k=>$rs){
  222. if(in_array($rs['fields'], $zdarr)){
  223. $slsts[] = $rs;
  224. }
  225. }
  226. return array('xiangdata'=>$slsts,'modename'=>'客户详情');
  227. }
  228. }
粤ICP备19079148号