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