Exemplo n.º 1
0
 /**
  * 打印任务
  * POST /task/
  * @method POST_index
  * @param fid 文件id
  * @param pid 打印店id
  * @param
  */
 public function POST_indexAction()
 {
     $userid = $this->auth();
     $response['status'] = 0;
     if (!Input::post('fid', $fid, 'int')) {
         $response['info'] = '未选择文件';
     } elseif (!Input::post('pid', $pid, 'int')) {
         $response['info'] = '未选择打印店';
     } elseif (!($file = FileModel::where('use_id', $userid)->where('status', '>', 0)->field('url,name,status')->find($fid))) {
         $response['info'] = '没有该文件或者此文件已经删除';
     } else {
         $task = TaskModel::create('post');
         $task['name'] = $file['name'];
         $task['use_id'] = $userid;
         $task['pri_id'] = $pid;
         if (!($task['url'] = File::addTask($file['url']))) {
             $response['info'] = '文件转换出错';
         } elseif (!($tid = TaskModel::insert($task))) {
             $response['info'] = '任务添加失败';
         } else {
             $response['status'] = 1;
             $response['info'] = ['msg' => '打印任务添加成功', 'id' => $tid];
         }
     }
     $this->response = $response;
 }
 public function getDelete($id = null)
 {
     if (!is_null($id)) {
         $id = SiteHelpers::encryptID($id, true);
         $del = FileModel::where('id', $id)->first();
         @unlink(public_path('uploads/' . $del->filename));
         FileModel::where('id', $id)->delete();
         return Redirect::to('files')->with('message', SiteHelpers::alert('success', "Data deleted successfully"));
     }
 }
 public function getDestroy()
 {
     $ids = Input::get('del');
     $i = 0;
     foreach ($ids as $id) {
         $del = FileModel::where('id', $id)->first();
         @unlink(public_path('uploads/' . $del->filename));
         FileModel::where('id', $id)->delete();
         $i++;
     }
     return Redirect::to('files')->with('message', SiteHelpers::alert('success', $i . " Data deleted successfully"));
 }
 public function getAdd($id = null)
 {
     if ($id == null) {
         $new = new AutomateModel();
         $new->name = "";
         $data['row'] = $new;
         $data['technology'] = TechnologyModel::all();
         $data['plot'] = PlotModel::join('his_technology', 'his_technology.id', '=', 'his_plot.id_tech')->select('his_plot.id', 'his_plot.name', 'his_technology.name as technology')->orderBy('his_plot.id_tech')->get();
         $data['file'] = FileModel::where('filename', 'like', '%xls%')->get();
     } else {
         $id = SiteHelpers::encryptID($id, true);
         $data['technology'] = TechnologyModel::all();
         $data['plot'] = PlotModel::all();
         $data['file'] = FileModel::where('filename', 'like', '%xls%');
         $data['row'] = AutomateModel::where('id', $id)->first();
     }
     return View::make('automate.form', $data);
 }