Пример #1
0
 /**
  * @method send
  *
  * @author 云小印[yunyin.org]
  *
  * @param $pid,$fid
  */
 public function send()
 {
     $pid = pri_id(U('Index/index'));
     if ($pid) {
         $fid = I('fid', null, 'intval');
         $map['pri_id'] = $pid;
         $map['id'] = $fid;
         $map['status'] = array('eq', C('FILE_PRINTED'));
         $map['sended'] = 0;
         $File = D('FileView');
         $info = $File->where($map)->field('use_id,phone,name')->find();
         $Printer = M('Printer');
         $info['pri_name'] = M('Printer')->getFieldById($pid, 'name');
         if ($info['phone'] && $info['name']) {
             unset($info['phone']);
             if (mb_strlen($info['name']) > 18) {
                 $info['name'] = mb_substr($info['name'], 0, 18);
             }
             $phone = get_phone_by_id($info['use_id']);
             unset($info['use_id']);
             $info['fid'] = $fid;
             $SMS = new \Vendor\Sms();
             if ($SMS->printed($phone, $info)) {
                 $File = M('File');
                 $map['id'] = $fid;
                 $result = $File->where($map)->setField('sended', 1);
                 $this->success('提醒信息已发送');
             } else {
                 $this->error('发送不成功');
             }
         } else {
             $this->success('已发送');
         }
     } else {
         $this->error('请先登录');
     }
 }