public function responder() { try { DB::beginTransaction(); DB::enableQueryLog(); $data = Input::all(); $new = $data; unset($new['apikey']); unset($new['session_key']); AnamnesisRespuesta::where('paciente_id', '=', $new["paciente_id"])->delete(); if (isset($new["respuesta"])) { foreach ($new["respuesta"] as $i => $r) { $respuesta = array("paciente_id" => $new["paciente_id"], "anamnesis_pregunta_id" => $new["pregunta"][$i]); $AR = AnamnesisRespuesta::firstOrNew($respuesta); $AR->respuesta = $r; if ($AR->save()) { $this->eventoAuditar($AR); } else { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($AR->validator), 'listado' => $data), 200); } } } DB::commit(); return Response::json(array('error' => false, 'listado' => "OK"), 200); } catch (\Exception $e) { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => $e->getMessage()), 200); } }
/** * Creates the application. * * @return \Illuminate\Foundation\Application */ public function createApplication() { $app = (require __DIR__ . '/../bootstrap/app.php'); $app->make('Illuminate\\Contracts\\Console\\Kernel')->bootstrap(); DB::enableQueryLog(); return $app; }
public function setUp() { parent::setUp(); \DB::enableQueryLog(); $this->artisan('migrate', ['--database' => 'testbench', '--realpath' => realpath(__DIR__ . '/../migrations')]); $this->withFactories(realpath(__DIR__ . '/../factories')); $this->repo = new CachingRepository(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Request::all(); Batch::create($input); DB::connection()->enableQueryLog(); \DB::enableQueryLog(); dd($input); // }
/** * Bootstrap any application services. * * @return void */ public function boot() { if (config('app.debug')) { \DB::enableQueryLog(); } \View::composer('widgets.categories', function ($view) { $view->with('categories', \App\Category::ordered()->get()); }); \View::composer(['widgets.categories', 'articles.index'], function ($view) { $view->with('QUERY', \Request::query()); }); }
/** * A basic functional test example. * * @return void */ public function testBasicExample() { // DB::table('lessons')->delete(); // DB::table('lessons')->delete(); DB::enableQueryLog(); // App\Next\Models\User::find(60830) var_dump(App\Next\Data\SportsZoneSource::update()); // var_dump(App\Next\Models\User::find(60829)->next_lesson_of('Economics', \Carbon\Carbon::now()->addDay())); $queries = DB::getQueryLog(); $last_query = end($queries); // var_dump($last_query); // var_dump(App\Next\Models\User::find(60829)->lessons->first()); // $response = $this->call('GET', '/'); // $this->assertEquals(200, $response->getStatusCode()); }
/** * Bootstrap any application services. * * @return void */ public function boot() { // \Validator::extend('mobile', function ($attribute, $value, $parameters) { return mobileCheck($value); }); \Validator::extend('identity', function ($attribute, $value, $parameters) { return identityCardCheck($value); }); \App::environment('local') && \DB::enableQueryLog(); if (\App::environment('local') && file_exists(app_path() . '/localHelper.php')) { include app_path('localHelper.php'); } \DB::listen(function ($sql, $bindings, $time) { }); }
/** * This method calls a sub method handleLogic() if possible and contain the execution logic */ public function handle() { /* * Step 1. Check if we should activate the queries log by looking at the option --with-sql * ----------- */ if ($this->_count_queries == true || $this->option('with-sql') === true) { \DB::enableQueryLog(); $this->_count_queries = true; } $command_name = substr($this->signature, 0, strpos($this->signature, ' ')); $this->info('[*] Beginning of the command ' . $command_name, OutputInterface::VERBOSITY_VERBOSE); /* * Step 2. Execute the logic and catch exception to display as "error" * ----------- */ $starting_time = microtime(true); try { $return = $this->handleLogic(); if (is_array($return)) { $this->_return = array_merge($this->_return, $return); } $this->onSuccess(); } catch (\Exception $e) { $this->onError($e); } $this->_return['execution_time'] = round(microtime(true) - $starting_time, 2); $this->onComplete(); $this->info('[*] End of the command', OutputInterface::VERBOSITY_VERBOSE); $this->comment('- Execution time: ' . $this->_return['execution_time'], OutputInterface::VERBOSITY_VERBOSE, 1); /* * Step 3. Count and display the queries (if activated) * ----------- */ if ($this->_count_queries === true) { $queries = \DB::getQueryLog(); $this->_return['nb_queries'] = count($queries); $this->comment('- Queries: ' . $this->_return['nb_queries'], OutputInterface::VERBOSITY_VERBOSE, 1); // If we are in -vvv, then we want to know more about the queries executed if ($this->getOutput()->getVerbosity() == OutputInterface::VERBOSITY_VERY_VERBOSE) { foreach ($queries as $query) { $this->comment('- ' . $query['query'], null, 1); } } unset($queries); } }
public function liberar($id) { try { $turnos = explode(",", $id); DB::enableQueryLog(); //si son muchos turnos if (count($turnos) > 1) { $affectedRows = Turno::whereIn('id', $turnos)->where('estado', 'A')->whereNotExists(function ($query) { $query->select(DB::raw(1))->from('tratamientos')->whereRaw('tratamientos.turno_id = turnos.id'); })->update(array('estado' => 'L', 'paciente_prepaga_id' => NULL, 'user_id' => Auth::user()->id, "motivo_turno_id" => NULL, 'piezas' => NULL, 'derivado_por' => NULL, 'observaciones' => NULL, 'fuera_de_agenda' => NULL)); if ($affectedRows == count($turnos)) { $objTurnos = Turno::whereIn('id', $turnos)->where('estado', 'L')->get(); foreach ($objTurnos as $cadaTurno) { $this->eventoAuditar($cadaTurno); } $turno = Turno::findOrFail($turnos[0]); return Response::json(array('error' => false, 'listado' => array($turno->find($turno->id)->toArray())), 200); } else { $mensaje = $affectedRows == 0 ? 'No se pudieron desasignar los turnos' : 'No se pudieron desasignar los turnos seleccionados con tratamientos cargados'; return Response::json(array('error' => true, 'mensaje' => $mensaje, 'envio' => $turnos), 200); } } else { $modelo = $this->modelo->find($id); if ($modelo->tratamientos->count()) { return Response::json(array('error' => true, 'mensaje' => 'No se pueden desasignar turnos con tratamientos realizados', 'envio' => $modelo->toArray()), 200); } //elimina si es entreturno if ($modelo->tipo_turno == 'E') { return $this->destroy($id); } $data = array("estado" => 'L', "paciente_prepaga_id" => null, "motivo_turno_id" => null, "piezas" => null, "derivado_por" => null, "observaciones" => null, "fuera_de_agenda" => null, "user_id" => Auth::user()->id); $modelo->fill($data); if ($modelo->save() !== false) { unset($modelo->tratamientos); $this->eventoAuditar($modelo); return Response::json(array('error' => false, 'listado' => array($modelo->toArray())), 200); } else { return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($modelo->validator), 'listado' => array($modelo->toArray())), 200); } } } catch (Exception $e) { return Response::json(array('error' => true, 'mensaje' => $e->getMessage()), 200); } }
/** * Bootstrap the application services. */ public function boot() { \DB::enableQueryLog(); Response::macro('paginate', function ($finder, $per_page = 10) { $page = $finder->paginate($per_page)->toArray(); return response($page['data'])->header('X-Total-Count', $page['total'])->header('Link', '<' . $page['next_page_url'] . '>; rel="next", <' . $page['prev_page_url'] . '>; rel="last"'); }); Response::macro('noContent', function ($resource) { return response(null, 204); }); Response::macro('created', function ($resource) { return response($resource, 201); }); Response::macro('updated', function ($resource) { return response($resource); }); Response::macro('deleted', function () { return response(null, 204); }); }
public function index() { $where = $this->request()->all(); $orderby = array_get($where, 'order', 'created_at'); $sortby = array_get($where, 'sort', 'desc'); \DB::enableQueryLog(); $users = User::orderBy($orderby, $sortby); if (array_get($where, 'status')) { $users->status($where['status']); } if (array_get($where, 'level')) { $users->level($where['level']); } if (array_get($where, 'sex')) { $users->where('sex', $where['sex']); } if (array_get($where, 'age_start')) { $users->where('birthday', '<=', ageToYear($where['age_start'])); } if (array_get($where, 'age_end')) { $users->where('birthday', '>=', ageToYear($where['age_end'])); } if (array_get($where, 'keyword')) { $users->where(function ($query) use($where) { $keyword = '%' . $where['keyword'] . '%'; $query->where('user_name', 'like', $keyword)->orWhere('mobile', 'like', $keyword)->orWhere('realname', 'like', $keyword)->orWhere('user_id', 'like', $keyword); }); } $users = $users->with('likeMe')->paginate(array_get($where, 'size', 10)); foreach ($where as $key => $query) { if ($key && $query) { $users->appends($key, $query); } } return $this->view('index')->with('users', $users); }
public function restaurar($id) { DB::beginTransaction(); try { DB::enableQueryLog(); $data = Input::all(); $presu = Presupuesto::findOrFail($id); $lineas = $presu->lineas()->get(); foreach ($lineas as $l) { $l->aprobado = 0; $l->save(); } $presu->fecha_aprobacion = null; $presu->user_id_aprobacion = null; $presu->importe_bruto = null; $presu->importe_neto = null; $presu->save(); DB::commit(); $this->eventoAuditar($presu); return Response::json(array('error' => false, 'mensaje' => 'Presupuesto ' . $id . ' restaurado correctamente', 'listado' => $presu->toArray()), 200); } catch (Exception $e) { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => $e->getMessage()), 200); } }
public function getListPo(Request $request) { \DB::enableQueryLog(); $list_order = array(); $id_product = session('current_product') !== null ? session('current_product') : 0; $type = $request->has('type')? $request->input('type'): 'all'; $company_id = $request->has('company_id')? $request->input('company_id'): 'all'; $month_year = $request->has('month_year')? $request->input('month_year'): 'all'; if($type=='all' || $type=='po'){ $list_po = Purchaseorder::select('purchaseorders.date','purchaseorders.id','m_products.quantity','m_products.specification','oums.name as oum_name','companies.name as company_name','m_products.id as product_id','product_stocks.in_stock') ->leftJoin('m_products',function($join){ $join->on('m_products.module_id','=','purchaseorders.id') ->where('module_type','=','App\Purchaseorder'); }) ->leftJoin('products','m_products.product_id','=','products.id') ->leftJoin('companies','m_products.company_id','=','companies.id') ->leftJoin('oums','m_products.oum_id','=','oums.id') ->leftJoin('product_stocks','product_stocks.m_product_id','=','m_products.id') ->where('products.id','=',$id_product) ->where('purchaseorders.status','=',1) ->orderBy('date','desc'); if($company_id != 'all') $list_po = $list_po->where('companies.id','=',$company_id); if($month_year != 'all'){ $month = explode('-',$month_year); $list_po = $list_po->whereRaw("MONTH(`purchaseorders`.`date`)=".$month[0]) ->whereRaw("YEAR(`purchaseorders`.`date`)=".$month[1]); } $list_po = $list_po->get()->toArray(); // $query = \DB::getQueryLog(); // print_r($query[count($query)-1]); // pr($list_po);die; foreach ($list_po as $key => $value) { $arr_tmp = array(); $arr_tmp['company_name'] = $value['company_name']; $arr_tmp['oum_name'] = $value['oum_name']; $arr_tmp['specification'] = $value['specification']; $arr_tmp['quantity'] = $value['quantity']; $arr_tmp['id'] = $value['id']; $arr_tmp['product_id'] = $value['product_id']; $arr_tmp['date'] = $value['date']; $arr_tmp['in_stock'] = $value['in_stock']; $arr_tmp['type'] = 'po'; $list_order[] = $arr_tmp; } } if($type=='all' || $type=='rpo'){ $list_rpo = ReturnSaleorder::select('return_saleorders.date','return_saleorders.id','m_products.quantity','m_products.specification','oums.name as oum_name','companies.name as company_name','m_products.id as product_id') ->leftJoin('m_products',function($join){ $join->on('m_products.module_id','=','return_saleorders.id') ->where('module_type','=','App\ReturnSaleorder'); }) ->leftJoin('products','m_products.product_id','=','products.id') ->leftJoin('companies','m_products.company_id','=','companies.id') ->leftJoin('oums','m_products.oum_id','=','oums.id') ->where('products.id','=',$id_product) ->where('return_saleorders.status','=',1) ->orderBy('date','desc'); if($company_id != 'all') $list_rpo = $list_rpo->where('companies.id','=',$company_id); if($month_year != 'all'){ $month = explode('-',$month_year); $list_rpo = $list_rpo->whereRaw("MONTH(`return_saleorders`.`date`)=".$month[0]) ->whereRaw("Year(`return_saleorders`.`date`)=".$month[1]); } $list_rpo = $list_rpo->get()->toArray(); foreach ($list_rpo as $key => $value) { $arr_tmp = array(); $arr_tmp['company_name'] = $value['company_name']; $arr_tmp['oum_name'] = $value['oum_name']; $arr_tmp['specification'] = $value['specification']; $arr_tmp['quantity'] = $value['quantity']; $arr_tmp['id'] = $value['id']; $arr_tmp['date'] = $value['date']; $arr_tmp['in_stock'] = 0; $arr_tmp['type'] = 'rpo'; $list_order[] = $arr_tmp; } } $product = Product::find($id_product)->toArray(); if(($type=='all' || $type=='in_stock') && $month_year == 'all'){ if($product['check_in_stock']){ $list_instock = MProduct::select('m_products.*','product_stocks.in_stock') ->with('company')->with('oum') ->where('m_products.product_id','=',session('current_product')) ->where('module_type','=','in_stock') ->leftJoin('product_stocks','product_stocks.m_product_id','=','m_products.id'); if($company_id != 'all'){ $list_instock = $list_instock->where('m_products.company_id','=',$company_id); } $list_instock = $list_instock->get()->toArray(); foreach ($list_instock as $key => $value) { $arr_tmp = array(); $arr_tmp['company_name'] = $value['company']['name']; $arr_tmp['oum_name'] = $value['oum']['name']; $arr_tmp['specification'] = $value['specification']; $arr_tmp['quantity'] = $value['quantity']; $arr_tmp['id'] = $value['id']; $arr_tmp['product_id'] = $value['product_id']; $arr_tmp['date'] = $value['created_at']; $arr_tmp['in_stock'] = $value['in_stock']; $arr_tmp['type'] = 'in_stock'; $list_order[] = $arr_tmp; } } } $arr_date = array(); foreach ($list_order as $key => $value) { $arr_date[] = $value['date']; } array_multisort($arr_date,SORT_DESC,$list_order); return view('product.list-po',[ 'list_order' => $list_order , 'product' => $product ]); }
/** * Create a new password controller instance. */ public function __construct() { \DB::enableQueryLog(); $this->middleware('auth'); $this->breadcrumb = array(array('label' => 'Dashboard', 'url' => '/', 'class' => 'entypo-home')); }
public function test_it_returns_the_translation_with_inner_join() { DB::enableQueryLog(); $this->app->setLocale('el'); /** @var Country $country */ $country = Country::joinTranslation()->first(); $this->assertEquals('Ελλάδα', $country->name); $queries = DB::getQueryLog(); $this->assertEquals(1, count($queries), 'You have with innerjoin more than one query'); }
public function anyList(Request $request) { \DB::enableQueryLog(); if($request->has('input-sort')){ $arr_sort = $request->input('input-sort'); $arr_sort =(array) json_decode($arr_sort); }elseif( session('sort_filter_returnpurchaseorder.arr_sort') !== null){ $arr_sort = session('sort_filter_returnpurchaseorder.arr_sort'); }else{ $arr_sort=array(); } session('sort_filter_returnpurchaseorder.arr_sort', $arr_sort); if($request->has('input-filter')){ $arr_filter = $request->input('input-filter'); }elseif( session('sort_filter_returnpurchaseorder.arr_filter') !== null ){ $arr_filter = session('sort_filter_returnpurchaseorder.arr_filter'); }else{ $arr_filter=[ 'id'=>'', 'company_id'=>'', 'date'=>'', 'status'=>'' ]; } session(['sort_filter_returnpurchaseorder.arr_sort'=>$arr_sort]); session(['sort_filter_returnpurchaseorder.arr_filter'=> $arr_filter]); //Init array $distributes = array(); $list_id = array(); $list_date = array(); $list_returnpurchaseorder = array(); //Get value array $distributes = Company::getDistributeList()->get()->toArray(); $list_id = ReturnPurchaseorder::lists('id'); $list_date = ReturnPurchaseorder::orderBy('date','desc')->lists('date'); foreach ($list_date as $key => $value) { $list_date[$key] = date('d-m-Y',strtotime($value)); } $list_date = array_unique($list_date); $list_returnpurchaseorder = ReturnPurchaseorder::select('return_purchaseorders.*','suminvest.*','companies.name as company_name')->with('company') ->leftJoin( DB::raw(' ( select module_id, module_type,sum(invest) as sum_invest from m_products where module_type = "App\\\\ReturnPurchaseorder" group by module_id ) as suminvest'), function($join){ $join->on('return_purchaseorders.id', '=', 'module_id'); } ) ->leftJoin('companies','companies.id','=','return_purchaseorders.company_id'); foreach ($arr_sort as $key => $value) { if($key=='company_id'){ $list_returnpurchaseorder = $list_returnpurchaseorder->orderBy('companies.name',$value); }else{ $list_returnpurchaseorder = $list_returnpurchaseorder->orderBy($key,$value); } } if($arr_filter['id']!=''){ $list_returnpurchaseorder->where('id',$arr_filter['id']); }else{ foreach ($arr_filter as $key => $value) { if($value!=''){ if($key=='date'){ $now = date("Y-m-d H:i:s",strtotime($arr_filter['date'])); $tomorow = date("Y-m-d H:i:s",strtotime($arr_filter['date'])+86400); $list_returnpurchaseorder->where('date','>=',$now)->where('date','<',$tomorow); }else{ $list_returnpurchaseorder->where($key,$value); } } } } if(!count($arr_sort)){ $list_returnpurchaseorder = $list_returnpurchaseorder->orderBy('id','desc'); } if(!isset($arr_filter['status'])){ $arr_filter['status'] = ''; } $list_returnpurchaseorder = $list_returnpurchaseorder->paginate(20); foreach($list_returnpurchaseorder as $key => $rpo){ $list_returnpurchaseorder[$key]['date'] = date('d-m-Y',strtotime($rpo['date'])); } \Cache::put('list_returnpurchaseorder'.\Auth::user()->id, $list_returnpurchaseorder, 30); // var_dump(DB::getQueryLog());die; $this->layout->content=view('returnpurchaseorder.list', [ 'distributes' => $distributes, 'arr_sort' => $arr_sort, 'arr_filter' => $arr_filter, 'list_id' => $list_id, 'list_date' => $list_date, 'list_returnpurchaseorder' => $list_returnpurchaseorder ]); }
public function runWorkFlow(Request $request) { $data = $request->all(); TmWorkflow::where(['ID' => $data['ID']])->update(['ISRUN' => 'yes']); \DB::enableQueryLog(); $tmWorkflowTask = TmWorkflowTask::where(['WF_ID' => $data['ID'], 'ISBEGIN' => 1])->first(); \Log::info(\DB::getQueryLog()); if (count($tmWorkflowTask) > 0) { TmWorkflowTask::where(['WF_ID' => $data['ID']])->where('ID', '<>', $tmWorkflowTask['id'])->update(['ISRUN' => 0]); $objRun = new WorkflowProcessController(null, $tmWorkflowTask); $objRun->runTask(null, $tmWorkflowTask); /* $job = (new runAllocation(null, $tmWorkflowTask)); $this->dispatch($job); */ } $result = $this->getTmWorkflow(); return response()->json(['result' => $result]); }
public function postListReceiptCustomer(Request $request) { \DB::enableQueryLog(); $list_order = array(); $company_id = $request->has('company_id')?$request->input('company_id'):0; $month = $request->has('month')?$request->input('month'):0; $year = $request->has('year')?$request->input('year'):0; if($month!='all'){ $begin = date('Y-m-d H:i:s',strtotime('1'.'-'.$month.'-'.$year)); $end = date('Y-m-d H:i:s',strtotime('1'.'-'.($month+1).'-'.$year)); }else{ $begin = date('Y-m-d H:i:s',strtotime('1-1-'.$year)); $end = date('Y-m-d H:i:s',strtotime('1-1-'.($year+1))); } $list_so = Saleorder::where('date','>=',$begin) ->where('date','<',$end) ->where('status','=',1) ->where('company_id','=',$company_id) ->get()->toArray(); $key_order = 1; foreach ($list_so as $key => $value) { $list_order[$key_order]['id'] = $value['id']; $list_order[$key_order]['date'] = $value['date']; $list_order[$key_order]['sum_amount'] = $value['sum_amount']; $list_order[$key_order]['paid'] = 0; $list_order[$key_order]['no_cu'] = 0; $list_order[$key_order]['con_lai'] = 0; $list_order[$key_order]['hinh_thuc'] = 'Đơn hàng mua'; $list_order[$key_order]['updated_at'] = $value['updated_at']; $key_order++; } $list_rso = ReturnSaleorder::where('date','>=',$begin) ->where('date','<',$end) ->where('status','=',1) ->where('company_id','=',$company_id) ->get()->toArray(); foreach ($list_rso as $key => $value) { $list_order[$key_order]['id'] = $value['id']; $list_order[$key_order]['date'] = $value['date']; $list_order[$key_order]['sum_amount'] = -$value['sum_amount']; $list_order[$key_order]['paid'] = 0; $list_order[$key_order]['no_cu'] = 0; $list_order[$key_order]['con_lai'] = 0; $list_order[$key_order]['hinh_thuc'] = 'Trả hàng mua'; $list_order[$key_order]['updated_at'] = $value['updated_at']; $key_order++; } $list_paid = Paid::where('date','>=',$begin) ->where('date','<',$end) ->where('company_id','=',$company_id) ->where('type_paid','=','customer') ->get()->toArray(); foreach ($list_paid as $key => $value) { $list_order[$key_order]['id'] = $value['id']; $list_order[$key_order]['date'] = $value['date']; $list_order[$key_order]['sum_amount'] = 0; $list_order[$key_order]['paid'] = $value['sum_paid']; $list_order[$key_order]['no_cu'] = 0; $list_order[$key_order]['con_lai'] = 0; $list_order[$key_order]['hinh_thuc'] = $value['hinh_thuc']; $list_order[$key_order]['company_id'] = $value['company_id']; $list_order[$key_order]['user_id'] = $value['user_id']; $list_order[$key_order]['updated_at'] = $value['updated_at']; $key_order++; } $date = array(); foreach ($list_order as $key => $value) { $date[$key] = $value['date']; $list_order[$key]['date'] = date('d-m-Y',strtotime($value['date'])); } array_multisort($date,SORT_ASC,$list_order); if($month!='all'){ $receipt_month_prev = ReceiptMonth:: where(function($query){ $query->where('type_receipt','=','customer') ->orWhere('type_receipt','=','no_dau_ky_customer'); }) ->where('company_id','=',$company_id) ->where(function($query) use ($month,$year){ $query->where(function($query2) use ($month,$year){ $query2->where('month','<',$month) ->where('year','=',$year); })->orWhere(function($query2) use ($month,$year){ $query2->where('year','<',$year); }); }) ->orderBy('year','desc') ->orderBy('month','desc') ->limit(1); $receipt_month_prev = $receipt_month_prev->first(); } if($month!='all' && $receipt_month_prev){ $receipt_current = ReceiptMonth::where('year','=',$year) ->where('month','=',$month) ->where('company_id','=',$company_id) ->where('type_receipt','=','customer') ->get()->first(); $receipt_current->no_cu = $receipt_month_prev->con_lai; $receipt_current->con_lai = $receipt_current->sum_amount + $receipt_current->no_cu - $receipt_current->paid; $receipt_current->save(); } foreach ($list_order as $key => $value) { if($key==0){ if(isset($receipt_month_prev)){ $receipt_month_prev = $receipt_month_prev->toArray(); $list_order[$key]['no_cu']=$receipt_month_prev['con_lai']; } }else{ $list_order[$key]['no_cu']=$list_order[$key-1]['con_lai']; } $list_order[$key]['con_lai']=$list_order[$key]['sum_amount'] - $list_order[$key]['paid'] + $list_order[$key]['no_cu']; } $company_name = Company::find($company_id); $company_name = $company_name->name; $arr_cache = [ 'month'=>$month, 'year'=>$year, 'company_name'=>$company_name, 'list_order'=>$list_order ]; \Cache::put('list_receipt_customer'.\Auth::user()->id, $arr_cache, 30); return view('receipt.list-receipt-customer',[ 'list_order' =>$list_order ]); }
public function postUpdateMproduct(Request $request){ \DB::enableQueryLog(); $arr_return= array('status'=>'error','invest'=>0); $id = $request->has('id')?$request->input('id'):0; $log=""; if($id){ $mproduct = MProduct::find($id); if($request->has('oum_id') && $mproduct->oum_id != $request->input('oum_id')){ $old = Oum::find($mproduct->oum_id); $new = Oum::find($request->input('oum_id')); if($old){ $log .= 'đơn vị từ "'.$old->name.'" thành "'.$new->name.'" '; }else{ $log .= 'đơn vị từ " " thành "'.$new->name.'" '; } } if($request->has('sell_price') && $mproduct->sell_price != $request->input('sell_price')){ $log .= 'giá bán từ "'.$mproduct->sell_price.'" thành "'.$request->input('sell_price').'" '; } if($request->has('specification') && $mproduct->specification != $request->input('specification')){ $log .= 'quy cách từ "'.$mproduct->specification.'" thành "'.$request->input('specification').'" '; } if($request->has('quantity') && $mproduct->quantity != $request->input('quantity')){ $log .= 'số lượng từ "'.$mproduct->quantity.'" thành "'.$request->input('quantity').'" '; } $mproduct->oum_id = $request->has('oum_id')?$request->input('oum_id'):0; $mproduct->origin_price = $request->has('origin_price')?$request->input('origin_price'):0; $mproduct->specification = $request->has('specification')?$request->input('specification'):0; $old_quantity = $mproduct->quantity ; $mproduct->quantity = $request->has('quantity')?$request->input('quantity'):0; $product_stock = ProductStock::where('m_product_id',"=",intval($mproduct->id))->first(); if(!$product_stock){ $product_stock = new ProductStock; $product_stock->in_stock = 0; } $product_stock->in_stock = $product_stock->in_stock + ($mproduct->quantity - $old_quantity); $mproduct->invest = $mproduct->specification* $mproduct->quantity* $mproduct->origin_price; // if($product_stock->in_stock >=0){ if( !$mproduct->status){ if($mproduct->save()){ $product = Product::find($mproduct->product_id); Log::create_log(\Auth::user()->id,'App\Purchaseorder','cập nhật '.$log.' sản phẩm '.$product->sku.' đơn hàng mua số '.session('current_purchaseorder')); $arr_return['status'] = 'success'; $arr_return['invest'] = number_format( $mproduct->invest ); }else{ $arr_return['message'] = 'Saving fail !'; } }else{ $arr_return['message'] = 'Đơn hàng đã hoàn thành không thể cập nhật'; } // }else{ // $arr_return['message'] = 'Số lượng nhập thấp hơn số lượng đã bán'; // } } //Init array $list_product = array(); //Get value $purchaseorder = Purchaseorder::find(session('current_purchaseorder')); $list_product = MProduct::select('m_products.*','products.sku','products.name')->where('module_type','=','App\Purchaseorder') ->where('module_id','=',$id) ->where('company_id','=',$purchaseorder['company_id']) ->leftJoin('products','products.id','=','m_products.product_id') ->addSelect('oums.name as oum_name') ->leftJoin('oums','oums.id','=','m_products.oum_id') ->get()->toArray(); \Cache::put('list_product_po'.\Auth::user()->id, $list_product, 30); $purchaseorder->updated_by = \Auth::user()->id; $purchaseorder->save(); self::getListProduct(); return $arr_return; }
public function doFindNextSlot(Request $request, $override_start_date = 0, $override_duration = 0, $override_appointment_type = 0, $override_redirect = 0) { if ($override_start_date) { $start_date = Carbon::createFromFormat('d/m/Y', $override_start_date); } else { $start_date = Carbon::createFromFormat('d/m/Y', $request->input('start_date')); } if ($override_duration) { $duration = $override_duration; } else { $duration = $request->input('minutes'); } if ($override_appointment_type) { $appointment_type = $override_appointment_type; } else { $appointment_type = $request->input('appointment_type'); } $dentist_id = $request->input('dentist'); $found_slot = false; for ($i = 8; $i < 19; $i++) { if ($i < 10) { $times[] = "0" . $i . ":00"; $times[] = "0" . $i . ":05"; $times[] = "0" . $i . ":10"; $times[] = "0" . $i . ":15"; $times[] = "0" . $i . ":20"; $times[] = "0" . $i . ":25"; $times[] = "0" . $i . ":30"; $times[] = "0" . $i . ":35"; $times[] = "0" . $i . ":40"; $times[] = "0" . $i . ":45"; $times[] = "0" . $i . ":50"; $times[] = "0" . $i . ":55"; } else { $times[] = $i . ":00"; $times[] = $i . ":05"; $times[] = $i . ":10"; $times[] = $i . ":15"; $times[] = $i . ":20"; $times[] = $i . ":25"; $times[] = $i . ":30"; $times[] = $i . ":35"; $times[] = $i . ":40"; $times[] = $i . ":45"; $times[] = $i . ":50"; $times[] = $i . ":55"; } if ($i == 18) { $times[] = "19:00"; } } $today = $start_date->copy(); \DB::enableQueryLog(); $slot_start = 'beep'; $slots_found = 0; $slots = array(); $leave_clear = 0; while ($slots_found < 12) { $today_with_timeslot = $today->copy(); foreach ($times as $time) { if ($leave_clear == 0) { $time_exploded = explode(":", $time); $today_with_timeslot->hour = $time_exploded[0]; $today_with_timeslot->minute = $time_exploded[1]; $today_with_timeslot->second = 0; $end_of_slot = $today_with_timeslot->copy()->addMinutes($duration); $end_of_slot->second = 59; if (Appointment::where('dentist_id', $dentist_id)->where(function ($query) use($today_with_timeslot, $end_of_slot) { $query->whereBetween('start_date', array($today_with_timeslot->format('Y-m-d H:i:s'), $end_of_slot->format('Y-m-d H:i:s')))->orWhereBetween('end_date', array($today_with_timeslot->format('Y-m-d H:i:s'), $end_of_slot->format('Y-m-d H:i:s'))); })->count() == 0 && ($end_of_slot->hour < 19 || $end_of_slot->hour == 19 && $end_of_slot->minute == 19)) { $slot_is_good = true; $interval_start = $today_with_timeslot->copy(); $interval_end = $end_of_slot->copy(); $duration = $interval_start->diffInMinutes($interval_end); while ($interval_start->format('H:i') != $interval_end->format('H:i')) { if (CalendarRestriction::where('day', $today_with_timeslot->format('l'))->where('appointment_type_id', '!=', 0)->where('time', $interval_start->format('H:i'))->where('appointment_type_id', '!=', $appointment_type)->count() > 0) { $slot_is_good = false; break; } $interval_start = $interval_start->copy()->addMinutes(5); } if ($slot_is_good) { $slots[$slots_found]['start'] = $today_with_timeslot->copy()->format('H:i'); $slots[$slots_found]['end'] = $end_of_slot->copy()->format('H:i'); $slots[$slots_found]['date'] = $today->copy()->format('d-m-Y'); $slots[$slots_found]['dentist_id'] = $dentist_id; $slots_found++; $leave_clear = $duration / 5 - 1; if ($slots_found == 12) { break; break; } } } } else { $leave_clear--; } } $today = $today->copy()->addDay(); } $request->session()->put('find_slot_trigger_open', true); $request->session()->put('slots', $slots); // $request->session()->put('selected_calendar_day', $slot_date->format('Y-m-d H:i:s')); // $request->session()->put('selected_calendar_layout', 'week'); // $request->session()->put('single_filtered_dentist', $dentist_id); // $request->session()->put('prefilled_start_time', $slot_start->format('H:i')); // $request->session()->put('prefilled_end_time', $slot_end->format('H:i')); // $request->session()->put('prefilled_date', $slot_end->format('d/m/Y')); if (!$override_redirect) { return redirect('dashboard'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { try { // $modelo = $this->modelo->find($id); DB::enableQueryLog(); $eliminado = $modelo->delete(); $this->eventoAuditar($modelo); return Response::json(array('error' => false, 'listado' => $modelo->toArray()), 200); } catch (Exception $e) { return Response::json(array('error' => true, 'mensaje' => $e->getMessage(), 'listado' => $modelo->toArray()), 200); } }
public function getFunction(Request $request) { $data = $request->all(); \DB::enableQueryLog(); $subEbFunctions = EbFunctions::where(['PARENT_CODE' => $data['CODE']])->orderBy('CODE')->get(); \Log::info(\DB::getQueryLog()); return response()->json($subEbFunctions); }
public function tomar_turno($paciente_prepaga_id) { $params = Input::all(); unset($params['apikey']); $turno_id = $params["turno_id"]; $tipo = isset($params["tipo"]) && !empty($params["tipo"]) ? $params["tipo"] : "T"; $user_id = Auth::user()->id; $paciente_prepaga = PacientePrepaga::findOrFail($paciente_prepaga_id); $turnos = explode(",", $turno_id); DB::enableQueryLog(); //si son muchos turnos if (count($turnos) > 1) { $objTurnos = Turno::whereIn('id', $turnos)->where('estado', 'L')->get(); if (count($objTurnos) == count($turnos)) { $affectedRows = Turno::whereIn('id', $turnos)->where('estado', 'L')->update(array('estado' => 'A', 'paciente_prepaga_id' => $paciente_prepaga->id, 'user_id' => $user_id)); if ($affectedRows == count($turnos)) { foreach ($objTurnos as $cadaTurno) { $this->eventoAuditar($cadaTurno); } $turno = Turno::findOrFail($turnos[0]); return Response::json(array('error' => false, 'listado' => array($turno->find($turno->id)->toArray())), 200); } else { return Response::json(array('error' => true, 'mensaje' => 'No se pudieron asignar los turnos', 'envio' => $params), 200); } } else { return Response::json(array('error' => true, 'mensaje' => "alguno de los turnos está tomado"), 200); } } else { //es un solo turno $turno = Turno::findorFail($turno_id); //chequea entreturno if ($tipo == 'E') { $otros_entreturnos = Turno::where('padre', '=', $turno->id)->get(); $new_turno = new Turno(); $new_turno->fill($turno->toArray()); $new_turno->id = null; $new_turno->padre = $turno->id; $turno = $new_turno; $turno->tipo_turno = 'E'; $desde = strtotime(substr($turno->hora_desde, 0, 2) . ":" . substr($turno->hora_desde, -2)); $hasta = strtotime(substr($turno->hora_hasta, 0, 2) . ":" . substr($turno->hora_hasta, -2)); if (count($otros_entreturnos) == 0) { $n_desde = $desde + ($hasta - $desde) / 2; $turno->hora_desde = date('Hi', $n_desde); } else { $intervalo = ($hasta - $desde) / (2 + count($otros_entreturnos)); $n_desde = $desde + $intervalo; foreach ($otros_entreturnos as $entreturno) { $entreturno->hora_desde = date('Hi', $n_desde); $entreturno->save(); $n_desde += $intervalo; } $turno->hora_desde = date('Hi', $n_desde); } $turno->estado = 'L'; } //falta verificar turno bloqueado x mismo usuario if ($turno->estado == 'L') { $turno->estado = 'A'; $turno->paciente_prepaga_id = $paciente_prepaga->id; $turno->user_id = $user_id; if ($turno->save()) { $this->eventoAuditar($turno); return Response::json(array('error' => false, 'listado' => array($turno->find($turno->id)->toArray())), 200); } else { return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($turno->validator), 'envio' => $params), 200); } } else { return Response::json(array('error' => true, 'mensaje' => "turno tomado"), 200); } } }
public function crear() { DB::beginTransaction(); try { DB::enableQueryLog(); $data = Input::all(); $new = $data; unset($new['apikey']); unset($new['session_key']); $items = array(); $pagos = array(); $new = array_map(function ($n) { return $n == 'NULL' ? NULL : $n; }, $new); if (isset($new["items"])) { foreach ($new["items"] as $i => $item) { $items[$i] = array_map(function ($n) { return $n == 'NULL' ? NULL : $n; }, $item); } unset($new["items"]); } if (isset($new["pago"])) { foreach ($new["pago"] as $p => $pago) { $pagos[$p] = array_map(function ($n) { return $n == 'NULL' ? NULL : $n; }, $pago); } unset($new["pago"]); } $new["user_id"] = Auth::user()->id; $modelo_ctacte = new Ctacte(); $ctacte = $modelo_ctacte->create($new); DB::enableQueryLog(); if ($ctacte->save()) { $this->eventoAuditar($ctacte); if (count($items)) { foreach ($items as $item) { $ctacte_fac_lin = new CtacteFacLin(); $item['ctacte_id'] = $ctacte->id; $fac_lin = $ctacte_fac_lin->create($item); if (!$fac_lin->save()) { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($fac_lin->validator), 'listado' => $data, 'paso' => 1), 200); } } } if (count($pagos)) { $referencia = $ctacte->id; if (substr($ctacte->tipo_prev, 0, 1) == 'F') { $new["tipo_cbte"] = !empty($new["tipo_cbte"]) ? 'RE' : NULL; $new["tipo_prev"] = 'RE'; $new["referencia"] = $ctacte->id; $new["importe_iva"] = 0; $importe = 0; foreach ($pagos as $p) { $importe += $p["importe"]; } $new["importe_neto"] = $importe; $new["importe_bruto"] = $importe; $modelo_ctacte1 = new Ctacte(); $ctacte1 = $modelo_ctacte1->create($new); DB::enableQueryLog(); if ($ctacte1->save()) { $this->eventoAuditar($ctacte1); $referencia = $ctacte1->id; } else { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($ctacte1->validator), 'paso' => 2, 'listado' => $data), 200); } } foreach ($pagos as $pago) { $ctacte_rec_lin = new CtacteRecLin(); $pago['ctacte_id'] = $referencia; $rec_lin = $ctacte_rec_lin->create($pago); if (!$rec_lin->save()) { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($rec_lin->validator), 'listado' => $data, 'pas' => 3), 200); } } if (!MovimientoCaja::ingresoCtacte($referencia)) { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => "No se pudo grabar movimiento de caja asociado", 'listado' => $data), 200); } } DB::commit(); return Response::json(array('error' => false, 'listado' => $ctacte->where('id', '=', $ctacte->id)->get()->toArray()), 200); } else { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($ctacte->validator), 'paso' => 4, 'listado' => $data), 200); } } catch (\Exception $e) { DB::rollback(); return Response::json(array('error' => true, 'mensaje' => $e->getMessage()), 200); } }
| Create The Application |-------------------------------------------------------------------------- | | Here we will load the environment and create the application instance | that serves as the central piece of this framework. We'll use this | application as an "IoC" container and router for this framework. | */ $app = new Laravel\Lumen\Application(realpath(__DIR__ . '/../')); // if (env('APP_DEBUG')) { // $app->register(Barryvdh\Debugbar\LumenServiceProvider::class); // $app->configure('debugbar'); // } $app->withFacades(); $app->withEloquent(); DB::enableQueryLog(); /* |-------------------------------------------------------------------------- | Register Container Bindings |-------------------------------------------------------------------------- | | Now we will register a few bindings in the service container. We will | register the exception handler and the console kernel. You may add | your own bindings here if you like or you can make another file. | */ $app->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class); $app->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class); /* |-------------------------------------------------------------------------- | Register Middleware
public static function feedsAndCategories() { \DB::enableQueryLog(); $oQuery = DB::table('categories')->join('feed_user', function ($join) { $join->on('categories.id', '=', 'feed_user.category_id')->where('categories.user_id', '=', Auth::id()); })->join('feeditems', function ($join) { $join->on('feed_user.feed_id', '=', 'feeditems.feed_id'); if (Request::has('feed')) { $join->where("feeditems.feed_id", "=", Request::get('feed')); } })->join('feeds', "feeds.id", "=", "feed_user.feed_id"); $oQuery->orderBy('feeditems.pubDate', 'desc')->select(['feeditems.url as url', 'feeditems.title as title', 'feeds.url as feedurl', 'feeds.id as feed_id', 'feeditems.pubDate as date', 'feed_user.name as name', 'feeditems.thumb as thumb', 'feeds.thumb as feedthumb', 'feed_user.colour as feed_colour', 'categories.id as cat_id']); $iPage = Request::input("page", 1); $iPerPage = 20; $iTotalItems = 0; //$maFeedItems = $oQuery->skip(($iPage * $iPerPage)-$iPerPage)->take($iPerPage)->get(); $maFeedItems = $oQuery->get(); #print_r($maFeedItems);die(); $iTotalItems = count($maFeedItems); $iTotalPages = ceil($iTotalItems / $iPerPage); $maFeedItems = array_slice($maFeedItems, $iPage * $iPerPage - $iPerPage, $iPerPage); #print_r(DB::getQueryLog()); $oaFeedItems = []; foreach ($maFeedItems as $oFeedItem) { $sDate = ''; $oDate = new Carbon($oFeedItem->date); if ($oDate->isToday()) { // 10:41 pm $sDate = $oDate->format('g:i a'); } else { // Aug 12 $sDate = $oDate->format('M j'); } array_push($oaFeedItems, ["url" => $oFeedItem->url, "title" => $oFeedItem->title, "feedurl" => $oFeedItem->feedurl, "feed_id" => $oFeedItem->feed_id, "category_id" => $oFeedItem->cat_id, "date" => $sDate, "name" => $oFeedItem->name, "thumb" => $oFeedItem->thumb !== '' ? $oFeedItem->thumb : $oFeedItem->feedthumb, "feed_thumb" => $oFeedItem->feedthumb]); } if (Request::has('feed')) { $oQuery->where("feeds.id", "=", Request::get('feed')); } $oUser = Auth::user(); $oUser->load('userCategories.userFeeds.feed'); #$oaFeeds = Auth::user();->userCategories()->userFeeds; //$oaFeeds = $oUser->userCategories->userFeeds->feed; #foreach() // what to return // categories / feed structure // array of feed items $oData = ['iAvailablePages' => $iTotalPages, 'iPerPage' => $iPerPage]; $oaCategoryFeeds = []; foreach ($oUser->userCategories as $oCategory) { // get feeds in category $aoFeeds = []; foreach ($oCategory->userFeeds as $oUserFeed) { array_push($aoFeeds, ["id" => $oUserFeed->id, "name" => $oUserFeed->name]); } // now add category with feeds array_push($oaCategoryFeeds, ["category_id" => $oCategory->id, "category_name" => $oCategory->name, "feeds" => $aoFeeds]); } return response()->json(['jsonFeedItems' => $oaFeedItems, 'jsonCategoryFeeds' => $oaCategoryFeeds, 'data' => $oData]); //return response(['jsonFeedItems' => $oaFeedItems, 'jsonFeeds' => $oaFeeds], 200); }
public function __construct($model = null) { $this->model = $model; \DB::enableQueryLog(); }
/** * Boot the VeerApp. * * * */ public function run() { \DB::enableQueryLog(); // @todo remove $this->siteUrl = $this->siteUrl(); $siteDb = $this->isSiteAvailable($this->siteUrl); $this->saveConfiguration($siteDb); $this->booted = true; }