static function getBatcheSchedulesbyCourseandClassID($batchId) { $batch = Batches::where('id', "=", $batchId)->get(); $batchSchedules = BatchSchedule::where("batch_id", "=", $batchId)->get(); $calenderData = array(); $i = 0; $calenderData['gotoDate'] = $batch['0']->start_date; foreach ($batchSchedules as $batchSchedule) { /* * title: 'Birthday Party', start: new Date(y, m, d+1, 19, 0), end: new Date(y, m, d+1, 22, 30), allDay: false, [id] => 1 [batch_id] => 8 [franchisee_id] => 1 [schedule_date] => 2015-11-03 [start_time] => 15:00:00 [end_time] => 16:00:00 [created_by] => 2 [updated_by] => [created_at] => 2015-11-07 20:54:12 [updated_at] => 2015-11-07 20:54:12 */ $calenderData['event'][$i]['title'] = $batch['0']->batch_name; $calenderData['event'][$i]['id'] = $batch['0']->id; $calenderData['event'][$i]['start'] = $batchSchedule->schedule_date . ' ' . $batchSchedule->start_time; $calenderData['event'][$i]['end'] = $batchSchedule->schedule_date . ' ' . $batchSchedule->end_time; $calenderData['event'][$i]['allDay'] = 'false'; $calenderData['event'][$i]['className'] = 'info'; $i++; } return $calenderData; }
static function deleteBatchById($batchId) { return Batches::where('id', '=', $batchId)->delete(); }
static function getBatchID($courseId, $classId, $startYear, $startMonth, $seasonId) { if (Batches::count()) { $batchCount = Batches::where("class_id", "=", $classId)->where('season_id', '=', $seasonId)->count() + 1; } else { $batchCount = 1; } if ($batchCount < 10) { $batchCount = str_pad($batchCount, 2, '0', STR_PAD_LEFT); } $courseSlug = Courses::select("slug")->where("id", "=", $courseId)->get(); $classSlug = Classes::select("slug")->where("id", "=", $classId)->get(); $yearSlug = date("Y", strtotime($startYear)); $monthSlug = date("M", strtotime($startYear)); $batchSlug = $courseSlug['0']->slug . '-' . $classSlug['0']->slug . '-' . strtoupper($monthSlug) . '-' . $yearSlug . '-' . $batchCount; //print_r($classSlug['0']->slug); return $batchSlug; }
public function enrollKid() { $inputs = Input::all(); $batch_data = Batches::find($inputs['batchCbx']); $eachClassCost = $batch_data->class_amount; //return Response::json(array('status'=>$inputs)); //$inputs['discountPercentage']=$inputs['discountP']; $studentClasses['classId'] = $inputs['eligibleClassesCbx']; $studentClasses['batchId'] = $inputs['batchCbx']; $studentClasses['studentId'] = $inputs['studentId']; $season_data = Seasons::find($inputs['SeasonsCbx']); //$inputs['enrollmentEndDate']=$season_data->end_date; //$studentClasses['enrollment_start_date'] = date('Y-m-d', strtotime($inputs['enrollmentStartDate'])); //return Response::json(array('status'=>'working')); //$studentClasses['enrollment_end_date'] = date('Y-m-d', strtotime($inputs['enrollmentEndDate'])); $studentClasses['selected_sessions'] = $inputs['selectedSessions']; $studentClasses['seasonId'] = $inputs['SeasonsCbx']; //for proper enrollment start date and end date $end = Carbon::now(); $start = Carbon::now(); $start->year = date('Y', strtotime($inputs['enrollmentStartDate'])); $start->month = date('m', strtotime($inputs['enrollmentStartDate'])); $start->day = date('d', strtotime($inputs['enrollmentStartDate'])); $end->year = date('Y', strtotime($inputs['enrollmentEndDate'])); $end->month = date('m', strtotime($inputs['enrollmentEndDate'])); $end->day = date('d', strtotime($inputs['enrollmentEndDate'])); $batch_data = BatchSchedule::where('batch_id', '=', $inputs['batchCbx'])->where('schedule_date', '>=', $start->toDateString())->where('schedule_date', '<=', $end->toDateString())->where('holiday', '!=', 1)->orderBy('id')->get(); $studentClasses['enrollment_start_date'] = $batch_data[0]['schedule_date']; $studentClasses['enrollment_end_date'] = $batch_data[count($batch_data) - 1]['schedule_date']; //Batch Start date $BatchDetails = Batches::where('id', '=', $inputs['batchCbx'])->first(); $reminderStartDate = $BatchDetails->start_date; $enrollment = StudentClasses::addStudentClass($studentClasses); $paymentDuesInput['student_id'] = $inputs['studentId']; $paymentDuesInput['customer_id'] = $inputs['customerId']; $paymentDuesInput['batch_id'] = $inputs['batchCbx']; $paymentDuesInput['class_id'] = $inputs['eligibleClassesCbx']; $paymentDuesInput['selected_sessions'] = $inputs['selectedSessions']; $paymentDuesInput['seasonId'] = $inputs['SeasonsCbx']; $paymentDuesInput['each_class_cost'] = $eachClassCost; $order['customer_id'] = $inputs['customerId']; $order['student_id'] = $inputs['studentId']; $order['seasonId'] = $inputs['SeasonsCbx']; $order['student_classes_id'] = $enrollment->id; $order['payment_mode'] = $inputs['paymentTypeRadio']; $order['payment_for'] = "enrollment"; $order['card_last_digit'] = $inputs['card4digits']; $order['card_type'] = $inputs['cardType']; $order['bank_name'] = $inputs['bankName']; $order['cheque_number'] = $inputs['chequeNumber']; //$order['each_class_cost'] =$eachClassCost; if (isset($inputs['membershipType'])) { $order['membershipType'] = $inputs['membershipType']; } $paydue_id; if ($inputs['paymentOptionsRadio'] == 'singlepay') { // for starting and end date of enrollment $enddate = Carbon::now(); $startdate = Carbon::now(); $startdate->year = date('Y', strtotime($inputs['enrollmentStartDate'])); $startdate->month = date('m', strtotime($inputs['enrollmentStartDate'])); $startdate->day = date('d', strtotime($inputs['enrollmentStartDate'])); $enddate->year = date('Y', strtotime($inputs['enrollmentEndDate'])); $enddate->month = date('m', strtotime($inputs['enrollmentEndDate'])); $enddate->day = date('d', strtotime($inputs['enrollmentEndDate'])); $batch_data = BatchSchedule::where('batch_id', '=', $inputs['batchCbx'])->where('schedule_date', '>=', $startdate->toDateString())->where('schedule_date', '<=', $enddate->toDateString())->where('holiday', '!=', 1)->orderBy('id')->get(); $paymentDuesInput['start_order_date'] = $batch_data[0]['schedule_date']; $paymentDuesInput['end_order_date'] = $batch_data[count($batch_data) - 1]['schedule_date']; $paymentDuesInput['payment_due_amount'] = $inputs['singlePayAmount']; $paymentDuesInput['payment_type'] = $inputs['paymentOptionsRadio']; $paymentDuesInput['payment_status'] = "paid"; $paymentDuesInput['discount_applied'] = $inputs['discountPercentage']; $paymentDuesInput['student_class_id'] = $enrollment->id; $paymentDuesInput['selected_order_sessions'] = $inputs['selectedSessions']; //$paymentDuesInput['start_order_date']=$studentClasses['enrollment_start_date']; //$paymentDuesInput['end_order_date']=$studentClasses['enrollment_end_date']; $paymentDuesInput['discount_amount'] = $inputs['discountPercentage'] / 100 * $inputs['singlePayAmount']; $order['amount'] = $inputs['singlePayAmount']; if ($inputs['CustomerType'] == 'OldCustomer') { $paymentDuesInput['created_at'] = date('Y-m-d H:i:s', strtotime($inputs['OrderDate'])); $order['created_at'] = $paymentDuesInput['created_at']; } $paymentDuesResult = PaymentDues::createPaymentDues($paymentDuesInput); $order['payment_dues_id'] = $paymentDuesResult->id; $order['order_status'] = "completed"; if ($inputs['selectedSessions'] > 8) { // creating followup for the single pay $presentDate = Carbon::now(); $startdate = Carbon::now(); $startdate->year = date('Y', strtotime($inputs['enrollmentStartDate'])); $startdate->month = date('m', strtotime($inputs['enrollmentStartDate'])); $startdate->day = date('d', strtotime($inputs['enrollmentStartDate'])); $batch_schedule_data = BatchSchedule::where('batch_id', '=', $inputs['batchCbx'])->where('schedule_date', '>=', $startdate->toDateString())->where('holiday', '!=', 1)->orderBy('id')->get(); $session_number = (int) ($inputs['selectedSessions'] / 2); $reminder_date = $batch_schedule_data[$session_number]['schedule_date']; $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; $customer_log_data['reminderDate'] = $reminder_date; $remindDate = Carbon::now(); $remindDate = $remindDate->createFromFormat('Y-m-d', $reminder_date); if ($remindDate->gt($presentDate)) { $payment_followup_data = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['paymentfollowup_id'] = $payment_followup_data->id; Comments::addSinglePayComment($customer_log_data); } } } else { if ($inputs['paymentOptionsRadio'] == 'multipay') { $today = Carbon::now(); $paymentDuesInput['payment_type'] = $inputs['paymentOptionsRadio']; for ($i = 1; $i <= 4; $i++) { if (isset($inputs['multipayAmount' . $i])) { $firstBrushupCallReminderDate; $firstInitialPaymentCallReminderDate; $firstFinalPaymentCallReminderDate; if ($i == 1) { $paymentDuesInput['payment_status'] = "paid"; $order['amount'] = $inputs['multipayAmount' . $i]; $enddate = Carbon::now(); $startdate = Carbon::now(); $startdate->year = date('Y', strtotime($inputs['enrollmentStartDate'])); $startdate->month = date('m', strtotime($inputs['enrollmentStartDate'])); $startdate->day = date('d', strtotime($inputs['enrollmentStartDate'])); $enddate->year = date('Y', strtotime($inputs['enrollmentEndDate'])); $enddate->month = date('m', strtotime($inputs['enrollmentEndDate'])); $enddate->day = date('d', strtotime($inputs['enrollmentEndDate'])); $batch_data = BatchSchedule::where('batch_id', '=', $inputs['batchCbx'])->where('schedule_date', '>=', $startdate->toDateString())->where('schedule_date', '<=', $enddate->toDateString())->where('holiday', '!=', 1)->orderBy('id')->get(); $paymentDuesInput['start_order_date'] = $batch_data[0]['schedule_date']; $endorderdate = $batch_data[count($batch_data) - 1]['schedule_date']; //$paymentDuesInput['start_order_date']=$studentClasses['enrollment_start_date']; //$startdate= Carbon::create(date('Y,m,d,0', strtotime($inputs['enrollmentStartDate']))); $startdate = Carbon::now(); $startdate->year = date('Y', strtotime($inputs['enrollmentStartDate'])); $startdate->month = date('m', strtotime($inputs['enrollmentStartDate'])); $startdate->day = date('d', strtotime($inputs['enrollmentStartDate'])); $session_no = $inputs['multipayAmount' . $i] / $eachClassCost; $firstSessionNumber = $session_no; $batch_schedule_data = BatchSchedule::where('batch_id', '=', $inputs['batchCbx'])->where('schedule_date', '>=', $startdate->toDateString())->where('holiday', '!=', 1)->orderBy('id')->get(); $session_no = $session_no - 1; //$startdate=$startdate->addWeeks(($inputs['bipayAmount'.$i]/500)); //$startdate=$startdate->addWeeks(($inputs['multipayAmount'.$i]/500)); $paymentDuesInput['end_order_date'] = $batch_schedule_data[$session_no]['schedule_date']; if ($firstSessionNumber >= 6) { $firstBrushupCallReminderDate = $batch_schedule_data[$session_no - 2]['schedule_date']; $firstInitialPaymentCallReminderDate = $batch_schedule_data[$session_no - 1]['schedule_date']; $firstFinalPaymentCallReminderDate = $batch_schedule_data[$session_no]['schedule_date']; } else { $firstFinalPaymentCallReminderDate = $batch_schedule_data[$session_no]['schedule_date']; } $nextstartdate = $batch_schedule_data[$session_no]['schedule_date']; //$paymentDuesInput['end_order_date']=$startdate->toDateString(); $paymentDuesInput['discount_amount'] = $inputs['discountPercentage'] / 100 * $inputs['multipayAmount' . $i]; if ($inputs['CustomerType'] == 'OldCustomer') { $paymentDuesInput['created_at'] = date('Y-m-d H:i:s', strtotime($inputs['OrderDate'])); $order['created_at'] = $paymentDuesInput['created_at']; } } else { $paymentDuesInput['start_order_date'] = $nextstartdate; $batch_schedule_data = BatchSchedule::where('batch_id', '=', $inputs['batchCbx'])->where('schedule_date', '>=', $startdate->toDateString())->where('holiday', '!=', 1)->orderBy('id')->get(); $session_no = $session_no + $inputs['multipayAmount' . $i] / $eachClassCost; $firstBrushupCallReminderDate = $batch_schedule_data[$session_no - 2]['schedule_date']; $firstInitialPaymentCallReminderDate = $batch_schedule_data[$session_no - 1]['schedule_date']; $firstFinalPaymentCallReminderDate = $batch_schedule_data[$session_no]['schedule_date']; //$startdate=$startdate->addWeeks(($inputs['multipayAmount'.$i]/500)); $paymentDuesInput['end_order_date'] = $batch_schedule_data[$session_no]['schedule_date']; if ($i == 4) { //$paymentDuesInput['end_order_date']=date('Y-m-d', strtotime($inputs['enrollmentEndDate'])); $paymentDuesInput['end_order_date'] = $endorderdate; } $nextstartdate = $batch_schedule_data[$session_no]['schedule_date']; //$paymentDuesInput['end_order_date']= $startdate->toDateString(); $paymentDuesInput['payment_status'] = "pending"; $paymentDuesInput['discount_amount'] = $inputs['discountPercentage'] / 100 * $inputs['multipayAmount' . $i]; if ($i == 2 && $inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate2'] != '') { $paymentDuesInput['created_at'] = date('Y-m-d H:i:s', strtotime($inputs['OrderDate2'])); $paymentDuesInput['payment_status'] = "paid"; } if ($i == 3 && $inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate3'] != '') { $paymentDuesInput['created_at'] = date('Y-m-d H:i:s', strtotime($inputs['OrderDate3'])); $paymentDuesInput['payment_status'] = "paid"; } if ($i == 4 && $inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate4'] != '') { $paymentDuesInput['created_at'] = date('Y-m-d H:i:s', strtotime($inputs['OrderDate4'])); $paymentDuesInput['payment_status'] = "paid"; } } $paymentDuesInput['payment_due_amount'] = $inputs['multipayAmount' . $i]; $paymentDuesInput['discount_applied'] = $inputs['discountPercentage']; $paymentDuesInput['selected_order_sessions'] = $inputs['multipayAmount' . $i] / $eachClassCost; $paymentDuesInput['student_class_id'] = $enrollment->id; $paymentDuesResult = PaymentDues::createPaymentDues($paymentDuesInput); if ($i >= 1 && $i <= 3) { if ($i == 1) { if ($firstSessionNumber >= 6) { $firstremind = Carbon::now(); $firstremind = $firstremind->createFromFormat('Y-m-d', $firstBrushupCallReminderDate); //return Response::json(array('status'=>$firstBrushupCallReminderDate,'today'=>$today)); if ($firstremind->gt($today)) { //create 3 payment followup $payment_followup_data1 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data2 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data3 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); //creating logs/followup for first payment $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['paymentfollowup_id'] = $payment_followup_data1->id; $customer_log_data['paymentfollowup_id2'] = $payment_followup_data2->id; $customer_log_data['paymentfollowup_id3'] = $payment_followup_data3->id; $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; $customer_log_data['firstReminderDate'] = $firstBrushupCallReminderDate; $customer_log_data['secondReminderDate'] = $firstInitialPaymentCallReminderDate; $customer_log_data['thirdReminderDate'] = $firstFinalPaymentCallReminderDate; Comments::addPaymentComments($customer_log_data); } else { $final_remind = Carbon::now(); $final_remind = $final_remind->createFromFormat('Y-m-d', $firstFinalPaymentCallReminderDate); if ($final_remind->gt($today)) { $payment_followup_data = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['paymentfollowup_id'] = $payment_followup_data->id; //$customer_log_data['paymentfollowup_id2']=$payment_followup_data2->id; //$customer_log_data['paymentfollowup_id3']=$payment_followup_data3->id; $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; // $customer_log_data['firstReminderDate']=$firstBrushupCallReminderDate; // $customer_log_data['secondReminderDate']=$firstInitialPaymentCallReminderDate; $customer_log_data['reminderDate'] = $firstFinalPaymentCallReminderDate; Comments::addOnebiPaymentComment($customer_log_data); } } } else { $final_r = Carbon::now(); $final_r = $final_r->createFromFormat('Y-m-d', $firstFinalPaymentCallReminderDate); if ($final_r->gt($today)) { //create 1 followup $payment_followup_data = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['paymentfollowup_id'] = $payment_followup_data->id; //$customer_log_data['paymentfollowup_id2']=$payment_followup_data2->id; //$customer_log_data['paymentfollowup_id3']=$payment_followup_data3->id; $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; // $customer_log_data['firstReminderDate']=$firstBrushupCallReminderDate; // $customer_log_data['secondReminderDate']=$firstInitialPaymentCallReminderDate; $customer_log_data['reminderDate'] = $firstFinalPaymentCallReminderDate; Comments::addOnebiPaymentComment($customer_log_data); } } } else { //when i>=3 $firstre = Carbon::now(); $firstre = $firstre->createFromFormat('Y-m-d', $firstBrushupCallReminderDate); if ($firstre->gt($today)) { $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; $customer_log_data['firstReminderDate'] = $firstBrushupCallReminderDate; $customer_log_data['secondReminderDate'] = $firstInitialPaymentCallReminderDate; $customer_log_data['thirdReminderDate'] = $firstFinalPaymentCallReminderDate; if ($i == 2 && isset($inputs['multipayAmount3'])) { $payment_followup_data1 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data2 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data3 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['paymentfollowup_id'] = $payment_followup_data1->id; $customer_log_data['paymentfollowup_id2'] = $payment_followup_data2->id; $customer_log_data['paymentfollowup_id3'] = $payment_followup_data3->id; Comments::addPaymentComments($customer_log_data); } else { if ($i == 3 && isset($inputs['multipayAmount4'])) { $payment_followup_data1 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data2 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data3 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['paymentfollowup_id'] = $payment_followup_data1->id; $customer_log_data['paymentfollowup_id2'] = $payment_followup_data2->id; $customer_log_data['paymentfollowup_id3'] = $payment_followup_data3->id; Comments::addPaymentComments($customer_log_data); } else { if ($i != 3 && $i != 2) { $payment_followup_data1 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data2 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data3 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['paymentfollowup_id'] = $payment_followup_data1->id; $customer_log_data['paymentfollowup_id2'] = $payment_followup_data2->id; $customer_log_data['paymentfollowup_id3'] = $payment_followup_data3->id; Comments::addPaymentComments($customer_log_data); } } } } else { $final = Carbon::now(); $final = $final->createFromFormat('Y-m-d', $firstFinalPaymentCallReminderDate); if ($final->gt($today)) { $payment_followup_data = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['paymentfollowup_id'] = $payment_followup_data->id; //$customer_log_data['paymentfollowup_id2']=$payment_followup_data2->id; //$customer_log_data['paymentfollowup_id3']=$payment_followup_data3->id; $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; // $customer_log_data['firstReminderDate']=$firstBrushupCallReminderDate; // $customer_log_data['secondReminderDate']=$firstInitialPaymentCallReminderDate; $customer_log_data['reminderDate'] = $firstFinalPaymentCallReminderDate; Comments::addOnebiPaymentComment($customer_log_data); } } } } $paydue_id[] = $paymentDuesResult->id; if ($i == 1) { $order['payment_dues_id'] = $paymentDuesResult->id; $order['order_status'] = "completed"; } } } /* $weeksDues = array("6", "9", "14", "19", "24", "29", "34"); $date = date('Y/m/d', strtotime($reminderStartDate)); foreach($weeksDues as $weeksDue){ $weeks = $weeksDue; // Create and modify the date. $dateTime = DateTime::createFromFormat('Y/m/d', $date); $dateTime->add(DateInterval::createFromDateString($weeks . ' weeks')); //$dateTime->modify('next monday'); // Output the new date. //echo $dateTime->format('Y-m-d')."<br>"; $paymentReminderInput['customerId'] = $inputs['customerId']; $paymentReminderInput['studentId'] = $inputs['studentId']; $paymentReminderInput['seasonId'] = $inputs['SeasonsCbx']; $paymentReminderInput['classId'] = $inputs['eligibleClassesCbx']; $paymentReminderInput['batchId'] = $inputs['batchCbx']; $paymentReminderInput['reminder_date'] = $dateTime->format('Y-m-d'); PaymentReminders::addReminderDates($paymentReminderInput); }*/ } else { if ($inputs['paymentOptionsRadio'] == 'bipay') { $followupFirstDate; $followupSecondDate; $followupThirdDate; $paymentDuesInput['payment_type'] = $inputs['paymentOptionsRadio']; for ($i = 1; $i <= 2; $i++) { if (isset($inputs['bipayAmount' . $i])) { if ($i == 1) { //for bipay enrollment classes $paymentDuesInput['payment_status'] = "paid"; $order['amount'] = $inputs['bipayAmount' . $i]; //$paymentDuesInput['start_order_date']=$studentClasses['enrollment_start_date']; //$startdate= Carbon::create(date('Y,m,d,0', strtotime($inputs['enrollmentStartDate']))); $startdate = Carbon::now(); $enddate = Carbon::now(); $startdate->year = date('Y', strtotime($inputs['enrollmentStartDate'])); $startdate->month = date('m', strtotime($inputs['enrollmentStartDate'])); $startdate->day = date('d', strtotime($inputs['enrollmentStartDate'])); $enddate->year = date('Y', strtotime($inputs['enrollmentEndDate'])); $enddate->month = date('m', strtotime($inputs['enrollmentEndDate'])); $enddate->day = date('d', strtotime($inputs['enrollmentEndDate'])); //return Response::json(array('status'=>'success')); $session_no = $inputs['bipayAmount' . $i] / $eachClassCost; $firstsessionno = $session_no; $batch_schedule_data = BatchSchedule::where('batch_id', '=', $inputs['batchCbx'])->where('schedule_date', '>=', $startdate->toDateString())->where('schedule_date', '<=', $enddate->toDateString())->where('holiday', '!=', 1)->orderBy('id')->get(); $session_no = $session_no - 1; //$startdate=$startdate->addWeeks(($inputs['bipayAmount'.$i]/500)); $paymentDuesInput['start_order_date'] = $batch_schedule_data[0]['schedule_date']; $paymentDuesInput['end_order_date'] = $batch_schedule_data[$session_no]['schedule_date']; $endorderdateforbipay = $batch_schedule_data[count($batch_schedule_data) - 1]['schedule_date']; if ($firstsessionno >= 10) { $followupFirstDate = $batch_schedule_data[$session_no - 2]['schedule_date']; $followupSecondDate = $batch_schedule_data[$session_no - 1]['schedule_date']; $followupThirdDate = $batch_schedule_data[$session_no]['schedule_date']; } else { $followupdate = $batch_schedule_data[$session_no]['schedule_date']; } $paymentDuesInput['discount_amount'] = $inputs['discountPercentage'] / 100 * $inputs['bipayAmount' . $i]; if ($inputs['CustomerType'] == 'OldCustomer') { $paymentDuesInput['created_at'] = date('Y-m-d H:i:s', strtotime($inputs['OrderDate'])); $order['created_at'] = $paymentDuesInput['created_at']; } } else { $paymentDuesInput['start_order_date'] = $batch_schedule_data[$session_no]['schedule_date']; //$startdate=$startdate->addWeeks(($inputs['bipayAmount'.$i]/500)); //$paymentDuesInput['end_order_date']= date('Y-m-d', strtotime($inputs['enrollmentEndDate'])); $paymentDuesInput['end_order_date'] = $endorderdateforbipay; $paymentDuesInput['payment_status'] = "pending"; $paymentDuesInput['discount_amount'] = $inputs['discountPercentage'] / 100 * $inputs['bipayAmount' . $i]; if ($inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate2'] != '') { $paymentDuesInput['created_at'] = date('Y-m-d H:i:s', strtotime($inputs['OrderDate2'])); // $order['created_at']=$paymentDuesInput['created_at']; } } $paymentDuesInput['selected_order_sessions'] = $inputs['bipayAmount' . $i] / $eachClassCost; $paymentDuesInput['payment_due_amount'] = $inputs['bipayAmount' . $i]; $paymentDuesInput['discount_applied'] = $inputs['discountPercentage']; $paymentDuesInput['student_class_id'] = $enrollment->id; $paymentDuesResult = PaymentDues::createPaymentDues($paymentDuesInput); if ($i == 1) { $order['payment_dues_id'] = $paymentDuesResult->id; $order['order_status'] = "completed"; $paydueid1 = $paymentDuesResult->id; } if ($i == 2) { if ($firstsessionno >= 10) { // creating customer followup $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $paydue_id2 = $paymentDuesResult->id; $paymentDuesResult->id = $paydueid1; $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; $customer_log_data['firstReminderDate'] = $followupFirstDate; $customer_log_data['secondReminderDate'] = $followupSecondDate; $customer_log_data['thirdReminderDate'] = $followupThirdDate; $brushupremind = Carbon::now(); $finalremind = Carbon::now(); $brushupremind = $brushupremind->createFromFormat('Y-m-d', $followupFirstDate); $finalremind = $finalremind->createFromFormat('Y-m-d', $followupThirdDate); $today = Carbon::now(); if ($brushupremind->gt($today)) { $payment_followup_data = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data2 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $payment_followup_data3 = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['paymentfollowup_id'] = $payment_followup_data->id; $customer_log_data['paymentfollowup_id2'] = $payment_followup_data2->id; $customer_log_data['paymentfollowup_id3'] = $payment_followup_data3->id; Comments::addPaymentComments($customer_log_data); } else { if ($finalremind->gt($today)) { //create single followup $payment_followup_data = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['paymentfollowup_id'] = $payment_followup_data->id; $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['reminderDate'] = $followupThirdDate; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; Comments::addOnebiPaymentComment($customer_log_data); } } } else { $today = Carbon::now(); $reminddate = Carbon::now(); $reminddate = $reminddate->createFromFormat('Y-m-d', $followupdate); if ($reminddate->gt($today)) { $paymentDuesResult->id = $paydueid1; $payment_followup_data = PaymentFollowups::createPaymentFollowup($paymentDuesResult); $customer_log_data['customer_id'] = $paymentDuesResult->customer_id; $customer_log_data['student_id'] = $paymentDuesResult->student_id; $customer_log_data['franchisee_id'] = Session::get('franchiseId'); $customer_log_data['paymentfollowup_id'] = $payment_followup_data->id; $customer_log_data['followup_type'] = 'PAYMENT'; $customer_log_data['reminderDate'] = $followupdate; $customer_log_data['followup_status'] = 'REMINDER_CALL'; $customer_log_data['comment_type'] = 'VERYINTERESTED'; Comments::addOnebiPaymentComment($customer_log_data); } } } } } // to create payment reminders /* $weeksDues = array("6", "12", "19", "24", "34"); $date = date('Y/m/d', strtotime($reminderStartDate)); foreach($weeksDues as $weeksDue){ $weeks = $weeksDue; // Create and modify the date. $dateTime = DateTime::createFromFormat('Y/m/d', $date); $dateTime->add(DateInterval::createFromDateString($weeks . ' weeks')); //$dateTime->modify('next monday'); // Output the new date. //echo $dateTime->format('Y-m-d')."<br>"; $paymentReminderInput['customerId'] = $inputs['customerId']; $paymentReminderInput['studentId'] = $inputs['studentId']; $paymentDuesInput['seasonId'] =$inputs['SeasonsCbx']; $paymentReminderInput['classId'] = $inputs['eligibleClassesCbx']; $paymentReminderInput['batchId'] = $inputs['batchCbx']; $paymentReminderInput['seasonId'] =$inputs['SeasonsCbx']; $paymentDuesInput['seasonId'] = $inputs['SeasonsCbx']; $paymentReminderInput['reminder_date'] = $dateTime->format('Y-m-d'); PaymentReminders::addReminderDates($paymentReminderInput); } * */ //payment reminders for followups. if ($i == 1) { $order['payment_mode'] = $inputs['paymentTypeRadio']; $order['card_last_digit'] = $inputs['card4digits']; $order['cardType'] = $inputs['card_type']; $order['bank_name'] = $inputs['cardBankName']; $order['receipt_number'] = $inputs['cardRecieptNumber']; } } } } $orderCreated = Orders::createOrder($order); if ($inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate2'] != '' && $inputs['paymentOptionsRadio'] == 'bipay') { $payment_due = new PaymentDues(); $payment_due = PaymentDues::find($paydue_id2); $payment_due->payment_status = 'paid'; $payment_due->save(); $order['created_at'] = $paymentDuesInput['created_at']; $order['amount'] = $paymentDuesResult->payment_due_amount - $paymentDuesResult->discount_amount; $order['payment_dues_id'] = $paydue_id2; if ($inputs['paymentTypeRadioOldCustomer2'] == 'cash') { $order['payment_mode'] = 'cash'; $orderCreated = Orders::createOrder($order); } elseif ($inputs['paymentTypeRadioOldCustomer2'] == 'cheque') { $order['payment_mode'] = 'cheque'; $order['bank_name'] = $inputs['bankName2']; $order['cheque_number'] = $inputs['chequeNumber2']; $orderCreated = Orders::createOrder($order); } elseif ($inputs['paymentTypeRadioOldCustomer2'] == 'card') { $order['payment_mode'] = 'card'; $order['card_type'] = $inputs['cardType2']; $order['card_last_digit'] = $inputs['card4digits2']; $order['bank_name'] = $inputs['cardBankName2']; $order['receipt_number'] = $inputs['cardRecieptNumber2']; $orderCreated = Orders::createOrder($order); } } if ($inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate2'] != '' && $inputs['paymentOptionsRadio'] == 'multipay') { $paydue_data = PaymentDues::where('id', '=', $paydue_id[1])->get(); $paydue_data = $paydue_data[0]; $neworder = new Orders(); $neworder['customer_id'] = $paydue_data['customer_id']; $neworder['student_id'] = $paydue_data['student_id']; $neworder['season_id'] = $paydue_data['season_id']; $neworder['student_classes_id'] = $paydue_data['student_class_id']; $neworder['payment_for'] = "enrollment"; $neworder['payment_dues_id'] = $paydue_id[1]; $neworder['amount'] = $paydue_data['payment_due_amount']; $neworder['order_status'] = "completed"; if ($inputs['paymentTypeRadioOldCustomer2'] == 'cash') { $neworder['payment_mode'] = 'cash'; } else { if ($inputs['paymentTypeRadioOldCustomer2'] == 'cheque') { $neworder['payment_mode'] = 'cheque'; $neworder['bank_name'] = $inputs['bankName2']; $neworder['cheque_number'] = $inputs['chequeNumber2']; } else { if ($inputs['paymentTypeRadioOldCustomer2'] == 'card') { $neworder['payment_mode'] = 'card'; $neworder['card_type'] = $inputs['cardType2']; $neworder['card_last_digit'] = $inputs['card4digits2']; $neworder['bank_name'] = $inputs['cardBankName2']; $neworder['receipt_number'] = $inputs['cardRecieptNumber2']; } } } $neworder['created_at'] = $paydue_data['created_at']; $neworder->created_by = Session::get('userId'); $neworder->save(); } if ($inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate3'] != '' && $inputs['paymentOptionsRadio'] == 'multipay') { $paydue_data = PaymentDues::where('id', '=', $paydue_id[2])->get(); $paydue_data = $paydue_data[0]; $neworder = new Orders(); $neworder['customer_id'] = $paydue_data['customer_id']; $neworder['student_id'] = $paydue_data['student_id']; $neworder['season_id'] = $paydue_data['season_id']; $neworder['student_classes_id'] = $paydue_data['student_class_id']; $neworder['payment_for'] = "enrollment"; $neworder['payment_dues_id'] = $paydue_id[2]; $neworder['amount'] = $paydue_data['payment_due_amount']; $neworder['order_status'] = "completed"; if ($inputs['paymentTypeRadioOldCustomer3'] == 'cash') { $neworder['payment_mode'] = 'cash'; } else { if ($inputs['paymentTypeRadioOldCustomer3'] == 'cheque') { $neworder['payment_mode'] = 'cheque'; $neworder['bank_name'] = $inputs['bankName3']; $neworder['cheque_number'] = $inputs['chequeNumber3']; } else { if ($inputs['paymentTypeRadioOldCustomer3'] == 'card') { $neworder['payment_mode'] = 'card'; $neworder['card_type'] = $inputs['cardType3']; $neworder['card_last_digit'] = $inputs['card4digits3']; $neworder['bank_name'] = $inputs['cardBankName3']; $neworder['receipt_number'] = $inputs['cardRecieptNumber3']; } } } $neworder['created_at'] = $paydue_data['created_at']; $neworder->created_by = Session::get('userId'); $neworder->save(); } if ($inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate4'] != '' && $inputs['paymentOptionsRadio'] == 'multipay') { $paydue_data = PaymentDues::where('id', '=', $paydue_id[3])->get(); $paydue_data = $paydue_data[0]; $neworder = new Orders(); $neworder['customer_id'] = $paydue_data['customer_id']; $neworder['student_id'] = $paydue_data['student_id']; $neworder['season_id'] = $paydue_data['season_id']; $neworder['student_classes_id'] = $paydue_data['student_class_id']; $neworder['payment_for'] = "enrollment"; $neworder['payment_dues_id'] = $paydue_id[3]; $neworder['amount'] = $paydue_data['payment_due_amount']; $neworder['order_status'] = "completed"; if ($inputs['paymentTypeRadioOldCustomer4'] == 'cash') { $neworder['payment_mode'] = 'cash'; } else { if ($inputs['paymentTypeRadioOldCustomer4'] == 'cheque') { $neworder['payment_mode'] = 'cheque'; $neworder['bank_name'] = $inputs['bankName4']; $neworder['cheque_number'] = $inputs['chequeNumber4']; } else { if ($inputs['paymentTypeRadioOldCustomer4'] == 'card') { $neworder['payment_mode'] = 'card'; $neworder['card_type'] = $inputs['cardType4']; $neworder['card_last_digit'] = $inputs['card4digits4']; $neworder['bank_name'] = $inputs['cardBankName4']; $neworder['receipt_number'] = $inputs['cardRecieptNumber4']; } } } $neworder['created_at'] = $paydue_data['created_at']; $neworder->created_by = Session::get('userId'); $neworder->save(); } if (isset($inputs['membershipType'])) { $membershipInputs['customer_id'] = $inputs['customerId']; $membershipInputs['membership_type_id'] = $inputs['membershipType']; CustomerMembership::addMembership($membershipInputs); } $student = Students::with('Customers', 'StudentClasses')->where('id', '=', $enrollment->student_id)->get(); $class = Classes::where('id', '=', $enrollment->class_id)->get(); $CustomerObject = Customers::find($inputs['customerId']); $CustomerObject->stage = "ENROLLED"; $CustomerObject->save(); $customer = array(); $customer['customerName'] = $student['0']->Customers->customer_name; $customer['customerEmail'] = $student['0']->Customers->customer_email; $customer['kidName'] = $student['0']->student_name; $customer['className'] = $class['0']->class_name; $commentsInput['customerId'] = $inputs['customerId']; $commentsInput['commentText'] = Config::get('constants.ENROLLED') . ' for ' . $class['0']->class_name; $commentsInput['commentType'] = 'FOLLOW_UP'; $commentsInput['reminderDate'] = null; Comments::addComments($commentsInput); if (isset($inputs['emailOption']) && $inputs['emailOption'] == 'yes') { $orders = Orders::with('Customers', 'Students', 'StudentClasses')->where('id', '=', $orderCreated->id)->get(); $orders = $orders['0']; $paymentDues = PaymentDues::where('id', '=', $orders->payment_dues_id)->get(); $batchDetails = Batches::where('id', '=', $orders->StudentClasses->batch_id)->get(); $class = Classes::where('id', '=', $orders->StudentClasses->class_id)->where('franchisee_id', '=', Session::get('franchiseId'))->first(); $customerMembership = CustomerMembership::getCustomerMembership($orders->customer_id); $class = Classes::where('id', '=', $inputs['eligibleClassesCbx'])->where('franchisee_id', '=', Session::get('franchiseId'))->first(); $batch = Batches::where('id', '=', $inputs['batchCbx'])->first(); $orderDetailsTomail['orders'] = $orders; $orderDetailsTomail['customers'] = $customer; $orderDetailsTomail['paymentDues'] = $paymentDues; $orderDetailsTomail['customerMembership'] = $customerMembership; $orderDetailsTomail['class'] = $class; $orderDetailsTomail['batchDetails'] = $batchDetails; $orderDetailsTomail['studentbatch']['start_date'] = date('Y-m-d', strtotime($inputs['enrollmentStartDate'])); $orderDetailsTomail['studentbatch']['end_date'] = date('Y-m-d', strtotime($inputs['enrollmentEndDate'])); $orderDetailsTomail['customers']['customerMembership'] = CustomerMembership::getCustomerMembership($orders->customer_id); Mail::send('emails.account.enrollment', $orderDetailsTomail, function ($msg) use($orderDetailsTomail) { $msg->from(Config::get('constants.EMAIL_ID'), Config::get('constants.EMAIL_NAME')); $msg->to($orderDetailsTomail['customers']['customerEmail'], $orderDetailsTomail['customers']['customerName'])->subject('The Little Gym - Kids Enrollment Successful'); }); } if (isset($inputs['invoicePrintOption']) && $inputs['invoicePrintOption'] == 'yes') { $printUrl = url() . '/orders/print/' . Crypt::encrypt($orderCreated->id); } else { $printUrl = ""; } //header('Access-Control-Allow-Origin: *'); if ($enrollment) { return Response::json(array("status" => "success", "printUrl" => $printUrl)); } else { return Response::json(array("status" => "failed")); } }
public function printOrder($orderid) { $id = Crypt::decrypt($orderid); $orders = Orders::with('Customers', 'Students', 'StudentClasses')->where('id', '=', $id)->get(); $orders = $orders['0']; $paymentDues = PaymentDues::where('id', '=', $orders->payment_dues_id)->get(); $batchDetails = Batches::where('id', '=', $orders->StudentClasses->batch_id)->get(); $class = Classes::where('id', '=', $orders->StudentClasses->class_id)->where('franchisee_id', '=', Session::get('franchiseId'))->first(); $customerMembership = CustomerMembership::getCustomerMembership($orders->customer_id); /* echo "<pre>"; print_r($paymentDues); exit(); */ $data = compact('orders', 'class', 'paymentDues', 'batchDetails', 'customerMembership'); //$data = compact('orders','class'); return View::make('pages.orders.printorder', $data); }
$inputs = Input::all(); $id = $inputs['id']; $countryCode = $inputs['countryCode']; $cities = Cities::getCities($id, $countryCode); return Response::json($cities); }); Route::get('logout', "VaultController@logout"); }); Route::get('/test', function () { $base_price_no = Batches::find(130)->classes()->select('base_price_no')->get(); $base_price_no = $base_price_no[0]['base_price_no']; echo $base_price_no; die; var_dump(ClassBasePrice::where('base_price_no', '=', Batches::find(130)->classes()->base_price_no)->select('base_price')->get()); $classes_count = StudentClasses::where('student_id', '=', 88)->where('status', '=', 'enrolled')->distinct('class_id')->count(); var_dump($classes_count); exit; echo PaymentMaster::max('payment_no'); exit; echo Batches::where('id', '=', '2')->select('class_amount')->get(); exit; $data = IntroVisit::join('students', 'student_id', '=', 'students.id')->where('introvisit.customer_id', '=', '44')->get(); var_dump($data); exit; // for($i=0;$i<count($birthday_data);$i++){ // $customer_data= Customers::where('id','=',$birthday_data[$i]['customer_id'])->get(); // $birthday_data[$i]['customer_name']= $customer_data[0]['customer_name']; // $birthday_data[$i]['membership']= CustomerMembership::where('customer_id','=',$birthday_data[$i]['customer_id'])->count(); // // } });
public function editbatchByBatchId() { $inputs = Input::all(); $timeString = '2000-3-5 ' . $inputs['batchEndTime']; $timestamp = strtotime($timeString); $endTime24Hours = date('H:i:s', $timestamp); $timeString = '2000-3-5 ' . $inputs['batchStartTime']; $timestamp = strtotime($timeString); $startTime24Hours = date('H:i:s', $timestamp); $data = Batches::where('id', '=', $inputs['batch_id'])->update(array('lead_instructor' => $inputs['l_instructor_id'], 'location_id' => $inputs['location_id'], 'class_amount' => $inputs['class_cost'], 'preferred_time' => $startTime24Hours, 'preferred_end_time' => $endTime24Hours)); return Response::json(array('status' => 'success', 'data' => $data)); }