assetmModel.php 2.6 KB

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