issue fix
This commit is contained in:
parent
1fa8c4cfd2
commit
c4cc7feb0a
@ -398,8 +398,12 @@ class AuthController extends ResourceController
|
||||
|
||||
// Generate JWT Token
|
||||
$token = generateJWT($user);
|
||||
|
||||
// Store the token in DB for current session
|
||||
$this->userModel->update($user['user_id'], [
|
||||
'current_token' => $token
|
||||
]);
|
||||
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'Login successful',
|
||||
|
||||
@ -379,159 +379,169 @@ class PlanController extends ResourceController
|
||||
{
|
||||
try {
|
||||
|
||||
$json = $this->request->getJSON(true);
|
||||
|
||||
$json = $this->request->getJSON(true);
|
||||
|
||||
// Check if plan_id exists
|
||||
if (!empty($json['plan_id'])) {
|
||||
$plan = $this->planModel->find($json['plan_id']);
|
||||
}
|
||||
|
||||
if (isset($plan)) {
|
||||
// Update existing plan
|
||||
$this->planModel->update($json['plan_id'], $json);
|
||||
$planId = $json['plan_id'];
|
||||
$updatedBy = $json['updated_by'];
|
||||
} else {
|
||||
// Insert new plan
|
||||
$planId = $this->planModel->insert($json, true);
|
||||
$updatedBy = $json['created_by'];
|
||||
}
|
||||
|
||||
$sendMailForEdit = false;
|
||||
|
||||
|
||||
if (!empty($json['flight'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isFlightTripDataChanged($this->flightTripsModel, $planId, $json['flight'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->saveFlights($json['flight'], $planId);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($json['accomodation'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
|
||||
// Check if plan_id exists
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->accomodationModel, $planId, $json['accomodation'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
$plan = $this->planModel->find($json['plan_id']);
|
||||
}
|
||||
|
||||
$this->saveAccomodations($json['accomodation'], $planId);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($json['bus'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->busModel, $planId, $json['bus'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
if (isset($plan)) {
|
||||
// Update existing plan
|
||||
$this->planModel->update($json['plan_id'], $json);
|
||||
$planId = $json['plan_id'];
|
||||
$updatedBy = $json['updated_by'];
|
||||
} else {
|
||||
// Insert new plan
|
||||
$planId = $this->planModel->insert($json, true);
|
||||
$updatedBy = $json['created_by'];
|
||||
}
|
||||
|
||||
$this->saveBuses($json['bus'], $planId);
|
||||
}
|
||||
$sendMailForEdit = false;
|
||||
|
||||
|
||||
if (!empty($json['flight'])) {
|
||||
|
||||
if (!empty($json['insurance'])) {
|
||||
|
||||
$this->saveInsurance($json['insurance'], $planId);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($json['miscellaneous'])) {
|
||||
|
||||
$this->saveMiscellaneous($json['miscellaneous'], $planId);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($json['taxi'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->taxiModel, $planId, $json['taxi'])) {
|
||||
$sendMailForEdit = true;
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isFlightTripDataChanged($this->flightTripsModel, $planId, $json['flight'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->saveFlights($json['flight'], $planId);
|
||||
}
|
||||
|
||||
$this->saveTaxi($json['taxi'], $planId);
|
||||
}
|
||||
|
||||
if (!empty($json['accomodation'])) {
|
||||
|
||||
if (!empty($json['train'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->trainModel, $planId, $json['train'])) {
|
||||
$sendMailForEdit = true;
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->accomodationModel, $planId, $json['accomodation'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->saveAccomodations($json['accomodation'], $planId);
|
||||
}
|
||||
|
||||
$this->saveTrain($json['train'], $planId);
|
||||
}
|
||||
|
||||
if (!empty($json['bus'])) {
|
||||
|
||||
|
||||
if (!empty($json['visa'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->visaModel, $planId, $json['visa'])) {
|
||||
$sendMailForEdit = true;
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->busModel, $planId, $json['bus'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->saveBuses($json['bus'], $planId);
|
||||
}
|
||||
|
||||
$this->saveVisa($json['visa'], $planId);
|
||||
}
|
||||
|
||||
if (!empty($json['insurance'])) {
|
||||
|
||||
if (!empty($json['forex'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->forexModel, $planId, $json['forex'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
$this->saveInsurance($json['insurance'], $planId);
|
||||
}
|
||||
|
||||
$this->saveForex($json['forex'], $planId);
|
||||
}
|
||||
|
||||
if (!empty($json['miscellaneous'])) {
|
||||
|
||||
$this->saveMiscellaneous($json['miscellaneous'], $planId);
|
||||
}
|
||||
|
||||
|
||||
//status handler
|
||||
palnStatusHandler($planId , $sendMailForEdit);
|
||||
if (!empty($json['taxi'])) {
|
||||
|
||||
//update plan status if all action null
|
||||
updatePlanStatus($planId,$updatedBy);
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->taxiModel, $planId, $json['taxi'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
//generate pdf for creation and every updation on the plan
|
||||
$this->generatePlanPdf($planId,false);
|
||||
$this->saveTaxi($json['taxi'], $planId);
|
||||
}
|
||||
|
||||
//send creation mail
|
||||
if (empty($json['plan_id'])) {
|
||||
sendPlanCreationMail($planId);
|
||||
}
|
||||
|
||||
//send updation mail
|
||||
if (!empty($json['plan_id']) && $sendMailForEdit == true) {
|
||||
sendPlanUpdationMail($planId);
|
||||
}
|
||||
if (!empty($json['train'])) {
|
||||
|
||||
// Send mail to agent if plan status is 3
|
||||
$plan = $this->planModel->where('plan_id', $planId)->where('status', 3)->first();
|
||||
if ($plan) {
|
||||
send_email_agent(env('ORG_id'), $planId);
|
||||
}
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->trainModel, $planId, $json['train'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'success', 'plan_id' => $planId]);
|
||||
$this->saveTrain($json['train'], $planId);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($json['visa'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->visaModel, $planId, $json['visa'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->saveVisa($json['visa'], $planId);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($json['forex'])) {
|
||||
|
||||
//check data changed while edit form submit
|
||||
if (!empty($json['plan_id'])) {
|
||||
if (isDataChanged($this->forexModel, $planId, $json['forex'])) {
|
||||
$sendMailForEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->saveForex($json['forex'], $planId);
|
||||
}
|
||||
|
||||
|
||||
//status handler
|
||||
palnStatusHandler($planId , $sendMailForEdit);
|
||||
|
||||
//update plan status if all action null
|
||||
updatePlanStatus($planId,$updatedBy);
|
||||
|
||||
//generate pdf for creation and every updation on the plan
|
||||
$this->generatePlanPdf($planId,false);
|
||||
|
||||
//send creation mail
|
||||
if (empty($json['plan_id'])) {
|
||||
sendPlanCreationMail($planId);
|
||||
}
|
||||
|
||||
//send updation mail
|
||||
if (!empty($json['plan_id']) && $sendMailForEdit == true) {
|
||||
sendPlanUpdationMail($planId);
|
||||
}
|
||||
|
||||
// Send mail to agent if plan status is 3
|
||||
$plan = $this->planModel->where('plan_id', $planId)->where('status', 3)->first();
|
||||
if ($plan) {
|
||||
send_email_agent(env('ORG_id'), $planId);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'success', 'plan_id' => $planId]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
// Log detailed error
|
||||
log_message('error', sprintf("%s Exception caught in %s (line %d): %s\nTrace:\n%s",
|
||||
'createOrUpdatePlan - ',
|
||||
$e->getFile(),
|
||||
$e->getLine(),
|
||||
$e->getMessage(),
|
||||
$e->getTraceAsString()
|
||||
));
|
||||
|
||||
return $this->failServerError('Failed to create : ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user