Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.9 kB
0
Indexable
Never
  public function filter_feedback($request, $showSoftDeleted, $inbox)
    {
        $this->active_filter=0;
        $model=$this->get_model($this->discipline);
        $layout=$this->get_layout('feedback');
        $select_layout=$layout['select_layout'];
        $select_layout_relation=$layout['select_layout_relation'];
        $relation_with_selected_item='database:'.$select_layout_relation;
        $relation='database';
        $table_main=$model[3];
        $table_second=$model[2];

        $array_explode=['','null','WAITING','WAITING SCHEDULING','CANCELLED SCHEDULING'];

        $select_layout_main_table=[];
        foreach ($select_layout as $lay){
            $select_layout_main_table[]=$table_main.'.'.$lay;
        }
        $queries=$model[1]::select($select_layout_main_table)->with($relation_with_selected_item);

        if( $showSoftDeleted ==2)  return ['queries'=>$queries->onlyTrashed(),'filter'=> $this->active_filter];

        $filter=[];
        $filter['relation']=$relation;
        $filter['table_relation']=$table_second;
        $filter['table_main']=$table_main;
        $filter['slug']=$this->discipline;
        $filter['permission']=$this->discipline;

        $queries = $queries->whereNotIn('wo_process_status',$array_explode);

        $filter['values']='wo_location';
        $filter['key']='wo_location';
        $queries=$this->request_filter_relation_location($request,$queries,$filter);
        $filter['values']='wo_discipline';
        $filter['key']='wo_discipline';
        $queries=$this->request_filter_relation_discipline($request,$queries,$filter);

        //for option list
        $request_array_option=['wo_status_feedback','wo_process_status'];
        $request_array_relation_option=['wo_type','wo_status','wo_resource','wo_sce'];
        $filter['values']=$request_array_option;
        $queries=$this->request_filter_options($request,$queries,$filter);
        $filter['values']=$request_array_relation_option;
        $queries=$this->request_filter_relation_options($request,$queries,$filter);

        //for text area
        $request_array_text=['last_change_by_feedback','wo_spare_parts','wo_feedback'];
        $request_array_relation_text=['wo_number','wo_notification','wo_week','wo_function_location','wo_description'];
        $filter['values']=$request_array_text;
        $queries=$this->request_filter_text($request,$queries,$filter);
        $filter['values']=$request_array_relation_text;
        $queries=$this->request_filter_relation_text($request,$queries,$filter);

        //for date
        $request_filter_date=['wo_complete','feedback_updated_at','wo_status_date'];
        $filter['values']=$request_filter_date;
        $queries=$this->request_filter_date($request,$queries,$filter);

        return ['queries'=>$queries,'filter'=> $this->active_filter];
    }