/**
  * Store a newly created resource in storage.
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $order = new OrderDelay();
     $order->fill($request->only('reason'));
     $order->student_id = $this->student->id;
     $order->academystructure_department_id = $this->student->academystructure_department_id;
     $order->semester_id = $this->semester->id;
     $order->state = 'تقديم';
     $order->save();
     // create order history record
     $history = new Orderhistory();
     $history->ref_key = 'order_delays';
     $history->ref_value = $order->id;
     $history->state = 'تقديم';
     $history->save();
     // check if financial item active then create debit record
     $invoice_item = FinancialInvoiceItem::where('slug', 'delayed_fee')->where('state', 'نشط')->first();
     if ($invoice_item) {
         $invoice_data = ['ref_key' => 'order_delays', 'ref_value' => $order->id, 'student_id' => $this->student->id, 'amount' => $invoice_item->amount, 'type' => 'debit', 'semester_id' => $this->semester->id, 'item_id' => $invoice_item->id, 'note' => 'تكلفة طلب تاجيل دراسة'];
         FinancialInvoice::create($invoice_data);
     }
     if ($request->has('files')) {
         OrderFile::whereIn('id', array_pluck($request->input('files'), 'id'))->update(['ref_value' => $order->id, 'ref_key' => 'order_delays']);
     }
     $order->load('files');
     return response()->json($order, 200, [], JSON_NUMERIC_CHECK);
 }
 public function deletefile($file_id, $order_id, $type)
 {
     OrderFile::find($file_id)->delete();
     if ($type == 'delay') {
         $delay_order = DelayOrders::with('files', 'history')->findOrFail($order_id);
         return view('orders::delay.edit', compact('delay_order'));
     } elseif ($type == 'withdraw') {
         $withdraw_order = WithdrawOrders::with('files', 'history')->findOrFail($order_id);
         return view('orders::withdraw.edit', compact('withdraw_order'));
     }
 }
 public function store_subject(Request $request)
 {
     $EqualSubject = new EqualSubject();
     $EqualSubject->equal_order_id = $request->equal_order_id;
     $EqualSubject->subject_name = $request->subject_name;
     $EqualSubject->subject_code = $request->subject_code;
     $EqualSubject->hours = $request->subject_hours;
     $EqualSubject->degree = $request->degree;
     $EqualSubject->max_degree = $request->max_degree;
     $EqualSubject->save();
     // update uploaded files
     if (!empty(request('files'))) {
         OrderFile::whereIn('id', request('files'))->update(['ref_key' => 'order_equal_subjects', 'ref_value' => $EqualSubject->id]);
     }
     return redirect()->route('equal.add_subjects', $request->equal_order_id)->with('success', trans('orders::order.add_subject_success'));
 }
 /**
  * Store a newly created resource in storage.
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $order = new ClassroomSessionExcuse();
     $order->fill($request->only('content', 'session_id'));
     $order->student_id = $this->student->id;
     $order->semester_id = $this->semester->id;
     $order->status = 'waiting';
     $order->save();
     if ($request->has('files')) {
         $update_data = ['ref_value' => $order->id, 'ref_key' => 'order_session_excuses'];
         OrderFile::whereIn('id', array_pluck($request->input('files'), 'id'))->update($update_data);
     }
     $order->load('files');
     Cache::forget('student_' . $this->student->id . '_api_sessions');
     return response()->json($order, 200, [], JSON_NUMERIC_CHECK);
 }
 /**
  * Store a newly created resource in storage.
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $order = new OrderQuranExcuse();
     $order->fill($request->only('reason', 'subject_id'));
     $order->student_id = $this->student->id;
     $order->semester_id = $this->semester->id;
     $order->state = 'تقديم';
     $order->save();
     // create order history record
     $history = new Orderhistory();
     $history->ref_key = 'order_quran_excuses';
     $history->ref_value = $order->id;
     $history->state = 'تقديم';
     $history->save();
     if ($request->has('files')) {
         $update_data = ['ref_value' => $order->id, 'ref_key' => 'order_quran_excuses'];
         OrderFile::whereIn('id', array_pluck($request->input('files'), 'id'))->update($update_data);
     }
     $order->load('files');
     return response()->json($order, 200, [], JSON_NUMERIC_CHECK);
 }
 public function update($delay_order_id, Request $request)
 {
     $delay_order = Delay::find($delay_order_id);
     if ($delay_order->state == 'غير مكتمل') {
         //change order state
         $delay_order->state = 'تقديم';
         $delay_order->save();
         // create order history record
         $order_history = new Orderhistory();
         $order_history->ref_key = 'order_delays';
         $order_history->ref_value = $delay_order_id;
         $order_history->state = 'تقديم';
         $order_history->save();
     }
     if ($delay_order->state == 'غير مكتمل' || $delay_order->state == 'تقديم') {
         // update uploaded files
         if (!empty(request('files'))) {
             OrderFile::whereIn('id', request('files'))->update(['ref_key' => 'order_delays', 'ref_value' => $delay_order_id]);
         }
     }
     return redirect()->route('delay.details', $delay_order_id);
 }
Exemple #7
0
 public function store(Request $request)
 {
     $file = OrderFile::create($request->only('file'));
     return response()->json($file, 200, [], JSON_NUMERIC_CHECK);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     if (Withdraw::count()) {
         // return;
     }
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Equal::truncate();
     Delay::truncate();
     Withdraw::truncate();
     OrderFile::truncate();
     Orderhistory::truncate();
     // $this->call("OthersTableSeeder");
     $old_reason = ["notunderstand" => "عدم استيعاب أسلوب الدراسة عن بعد", "nointernet" => "عدم توافر إنترنت جيد أو مركز خدمات كمبيوتر قريب من السكن", "nomoney" => "عدم إمكانية تحمل الرسوم الدراسية", "baby" => "الولادة / رعاية مولود جديد", "sick" => "المرض", "familysick" => "مرض أحد الأقارب من الدرجة الأولى (الأب، الأم، الزوج، الأخ، الأخت، الابن، الابنة)", "work" => "السفر لدواعي العمل", "family" => "ظروف عائلية", "personal" => "السفر لأسباب شخصية", "workz" => "ظروف العمل"];
     $old_state = ["UN" => "تقديم", "OC" => "مكتمل", "ONC" => "غير مكتمل", "NCON" => "الغاء لعدم الاستكمال", "AC" => "قبول", "NC" => "رفض"];
     $country = [0 => null, 1 => 147, 2 => 1, 3 => 234, 4 => 226, 5 => 4, 6 => 140, 7 => 125, 8 => 211, 9 => 137, 10 => 206, 11 => 253, 12 => 269, 13 => 197, 14 => 118, 15 => 14, 16 => 182, 17 => 225, 18 => 248, 19 => 106, 20 => 114, 21 => 83, 22 => 121, 23 => 218];
     $old_equal_state = [0 => "متقدم", 1 => "مكتمل", 2 => "غير مكتمل", 3 => "قبول كلى", 4 => "قبول جزئى", 5 => "رفض كلى", 7 => "الغاء"];
     $old_certificat = [1 => "دبلوم", 2 => "بكالوريوس", 3 => "ماجستير", 4 => "دكتوراه", 5 => "لم أكمل متطلبات الحصول على الدرجة العلمية"];
     //get all Withdraw order expected REP state (dublicate order)
     //$orders = DB::connection('old')->table('withdrawls')->where('wd_type',0)->where('wd_status','<>','REP')->get();
     $orders = [];
     foreach ($orders as $order) {
         $new_Withdraw = new Withdraw();
         //$new_Withdraw->id = $order->wd_id;
         $new_Withdraw->student_id = $order->wd_userid;
         $new_Withdraw->reason = in_array($order->wd_reasons, $old_reason) ? $old_reason[$order->wd_reasons] : $order->wd_reasons;
         $new_Withdraw->semester_id = $order->wd_semid > 0 ? $order->wd_semid : NULL;
         $new_Withdraw->state = $old_state[$order->wd_status];
         $new_Withdraw->bank_name = $order->wd_bankname;
         $new_Withdraw->bank_account_name = $order->wd_bankfullname;
         $new_Withdraw->bank_account_number = $order->wd_banknum;
         $new_Withdraw->refund_state = 100;
         $new_Withdraw->created_at = $order->wd_created;
         $new_Withdraw->updated_at = $order->wd_created;
         $new_Withdraw->save();
         $files = DB::connection('old')->table('withdrawls_attachments')->where('wda_wdid', $order->wd_id)->get();
         foreach ($files as $file) {
             $new_file = new OrderFile();
             $new_file->ref_key = 'order_withdraws';
             $new_file->ref_value = $order->wd_id;
             //path = iis/assets/forms/
             //$new_file->file = $file->wda_file;
             $new_file->created_at = $file->wda_created;
             $new_file->updated_at = $file->wda_created;
             $new_file->save();
         }
     }
     $this->command->info('withdraw order transfered!');
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //get all Delay order expected REP state (dublicate order)
     $orders = DB::connection('old')->table('withdrawls')->where('wd_type', 1)->where('wd_userid', '!=', 1356)->where('wd_status', '<>', 'REP')->get();
     foreach ($orders as $order) {
         $new_Delay = new Delay();
         //$new_Delay->id = $order->wd_id;
         $new_Delay->student_id = $order->wd_userid;
         $new_Delay->reason = in_array($order->wd_reasons, $old_reason) ? $old_reason[$order->wd_reasons] : $order->wd_reasons;
         $new_Delay->semester_id = $order->wd_semid > 0 ? $order->wd_semid : null;
         $new_Delay->state = $old_state[$order->wd_status];
         $student_info = DB::table('students')->find($order->wd_userid);
         if (!$student_info) {
             echo "This user does not exist " . $order->wd_userid;
         }
         $new_Delay->academystructure_department_id = $student_info->state == 'delayed' ? $student_info->academystructure_department_id : null;
         $new_Delay->refund_state = 100;
         $new_Delay->created_at = $order->wd_created;
         $new_Delay->updated_at = $order->wd_created;
         $new_Delay->save();
         $files = DB::connection('old')->table('withdrawls_attachments')->where('wda_wdid', $order->wd_id)->get();
         foreach ($files as $file) {
             $new_file = new OrderFile();
             $new_file->ref_key = 'order_delays';
             $new_file->ref_value = $order->wd_id;
             //path = iis/assets/forms/
             //$new_file->file = $file->wda_file;
             $new_file->created_at = $file->wda_created;
             $new_file->updated_at = $file->wda_created;
             $new_file->save();
         }
     }
     $this->command->info('delay order transfered!');
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //get all Equation order
     $Eorders = DB::connection('old')->table('user_equation')->whereNotIn('ue_userid', [2943, 2947])->get();
     foreach ($Eorders as $Eorder) {
         $new_Equal = new Equal();
         $new_Equal->id = $Eorder->ue_id;
         $new_Equal->student_id = $Eorder->ue_userid;
         $new_Equal->semester_id = null;
         $new_Equal->grade = is_numeric($Eorder->ue_finalestimate) ? $Eorder->ue_finalestimate : '';
         $new_Equal->country_id = $country[$Eorder->ue_cityid];
         $new_Equal->state = $old_equal_state[$Eorder->ue_curstatus];
         $new_Equal->certificate = $old_certificat[$Eorder->ue_edulevel];
         $new_Equal->old_institute = $Eorder->ue_studyedulevel == 'iis' ? 'كلية العلوم الشرعية' : $Eorder->ue_studyeduleveltext;
         $new_Equal->created_at = $Eorder->ue_date;
         $new_Equal->updated_at = $Eorder->ue_date;
         $new_Equal->save();
         //////////////////////////////////File
         $new_file = new OrderFile();
         $new_file->ref_key = 'order_equals';
         $new_file->ref_value = $Eorder->ue_id;
         //path = iis/assets/equationsubject/
         //$new_file->file = $files->ue_file;
         $new_file->created_at = $Eorder->ue_date;
         $new_file->updated_at = $Eorder->ue_date;
         $new_file->save();
     }
     $this->command->info('Equals order transfered!');
     //get all Equation Subject
     $Eqsubjects = DB::connection('old')->table('equation_subjects_new')->whereNotIn('es_ueid', [174, 204])->get();
     $all_eqsubject = [];
     foreach ($Eqsubjects as $Eqsubject) {
         $new_Eqsubject = [];
         $new_Eqsubject['equal_order_id'] = $Eqsubject->es_ueid;
         $new_Eqsubject['subject_name'] = $Eqsubject->es_name;
         $new_Eqsubject['subject_code'] = $Eqsubject->es_code;
         $new_Eqsubject['hours'] = is_numeric($Eqsubject->es_hours) ? $Eqsubject->es_hours : null;
         $new_Eqsubject['degree'] = is_numeric($Eqsubject->es_degree) ? $Eqsubject->es_degree : null;
         $new_Eqsubject['max_degree'] = is_numeric($Eqsubject->es_alldegree) ? $Eqsubject->es_alldegree : null;
         $new_Eqsubject['equal_subject_id'] = $Eqsubject->es_subjects;
         $new_Eqsubject['created_at'] = '2001-01-01';
         $new_Eqsubject['updated_at'] = '2001-01-01';
         $all_eqsubject[] = $new_Eqsubject;
     }
     foreach (array_chunk($all_eqsubject, 10) as $Eqsubject_group) {
         DB::table('order_equal_subjects')->insert($Eqsubject_group);
     }
     $this->command->info('Equal subjects transfered!');
 }