1
0

assetmModel.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. class flow_assetmClassModel extends flowModel
  3. {
  4. public function initModel()
  5. {
  6. $this->statearr = c('array')->strtoarray('blue|闲置,#ff6600|在用,red|维修,gray|报废,gray|丢失');
  7. }
  8. public function flowrsreplace($rs,$lx=0)
  9. {
  10. if(isset($rs['typeid']))$rs['typeid'] = $this->db->getmou('[Q]option','name',"`id`='".$rs['typeid']."'");
  11. if(isset($rs['ckid']) && $rs['ckid']>0){
  12. $rs['ckid'] = $this->db->getmou('[Q]option','name',"`id`='".$rs['ckid']."'");
  13. if(isset($rs['address']) && isempt($rs['address'])){
  14. $rs['address'] = $rs['ckid'];
  15. $this->update("`address`='".$rs['address']."'", $rs['id']);
  16. }
  17. }
  18. if(isset($this->statearr[$rs['state']])){
  19. $b = $this->statearr[$rs['state']];
  20. $rs['state'] = '<font color="'.$b[0].'">'.$b[1].'</font>';
  21. }
  22. if(isset($rs['fengmian']) && !isempt($rs['fengmian']))$rs['fengmian'] = '<img src="'.$rs['fengmian'].'" height="100">';
  23. if($lx==1){
  24. $rows = $this->db->getall('select a.runren,a.id,a.optdt from `[Q]planm` a left join `[Q]plans` b on a.id=b.mid where b.itemid='.$rs['id'].' and a.`type`=1');
  25. $str = '';
  26. foreach($rows as $k1=>$rs1){
  27. $url = $this->getxiangurl('assetmly', $rs1['id'],'auto');
  28. $str.=''.$rs1['runren'].'('.$rs1['optdt'].') <a href="'.$url.'">查看</a><br>';
  29. }
  30. $rs['lycount'] = $str;
  31. }
  32. return $rs;
  33. }
  34. protected function flowbillwhere($uid, $lx)
  35. {
  36. $where = '';
  37. $typeid = $this->rock->post('typeid','0');
  38. //$key = $this->rock->post('key');
  39. if($typeid!='0'){
  40. $alltpeid = m('option')->getalldownid($typeid);
  41. $where .= ' and `typeid` in('.$alltpeid.')';
  42. }
  43. //弃用这个,去到表单表示元素管理开启搜索
  44. //if($key != '')$where.=" and (`title` like '%$key%' or `num` like '%$key%' or `usename` like '%$key%')";
  45. return array(
  46. 'where' => $where,
  47. 'orlikefields'=>'title,num,usename',
  48. 'order' => 'optdt desc',
  49. //'fields'=> 'id,title,num,brand,optdt,usename,state,ckid'
  50. );
  51. }
  52. //导入数据的测试显示
  53. public function flowdaorutestdata()
  54. {
  55. return array(
  56. 'typeid' => '电脑/台式电脑',
  57. 'title' => '这是一个电脑啊',
  58. 'num' => 'ZiCAN-001',
  59. 'brand' => '联想',
  60. 'laiyuan' => '购买',
  61. 'buydt' => '2017-01-17',
  62. 'explain' => '简单说明一下',
  63. 'address' => '放哪里了',
  64. );
  65. }
  66. //导入之前
  67. public function flowdaorubefore($rows)
  68. {
  69. foreach($rows as $k=>$rs){
  70. $rows[$k]['typeid'] = $this->option->gettypeid('assetstype',$rs['typeid']);
  71. $rows[$k]['adddt'] = $this->rock->now;
  72. $rows[$k]['optdt'] = $this->rock->now;
  73. }
  74. return $rows;
  75. }
  76. }
粤ICP备19079148号