/*sps_menu table query*/
INSERT INTO `sps_menu`
        (`id`, `menu_item`, `menu_url`, `menu_class`, `parent_menu_id`, `action`, `order`, `status`, `location_id`, `area_id`, `created_by`, `created_at`, `updated_at`, `deleted_at`, `updated_by`)
        VALUES (NULL, 'detailed_payments_report', 'admin/detailed_payments_report', 'menu', '46', '', '11.32', '1', '1', '1', '1', CURRENT_TIMESTAMP, '0000-00-00 00:00:00.000000', NULL, '');


/*sps_menu mapping table query*/
INSERT INTO `sps_menu_action_mapping`
        (`id`, `menu_id`, `action_id`, `area_id`, `location_id`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`)
        VALUES (NULL, (SELECT id FROM sps_menu WHERE sps_menu.menu_item = "detailed_payments_report"), '1', '0', '0', '0', '0', CURRENT_TIMESTAMP, '0000-00-00 00:00:00.000000', NULL);

INSERT INTO `sps_menu_action_mapping`
        (`id`, `menu_id`, `action_id`, `area_id`, `location_id`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`)
        VALUES (NULL, (SELECT id FROM sps_menu WHERE sps_menu.menu_item = "detailed_payments_report"), '6', '0', '0', '0', '0', CURRENT_TIMESTAMP, '0000-00-00 00:00:00.000000', NULL);

/*If sps_reports_list table exist in database then run following query for alert configuration*/
INSERT INTO `sps_reports_list` (`id`, `report_name`) VALUES (NULL, 'detailed_payments_report');


/*sps_access_rights table query*/

INSERT INTO `sps_access_rights`
	(`id`, `role_id`, `menu_id`, `action_id`, `created_by`, `updated_at`, `deleted_at`, `location_id`, `area_id`, `updated_by`, `created_at`)
	VALUES (NULL, '1', (SELECT id FROM sps_menu WHERE sps_menu.menu_item = "detailed_payments_report"), '1', '0', CURRENT_TIMESTAMP, NULL, '0', '0', '0', CURRENT_TIMESTAMP);

INSERT INTO `sps_access_rights`
	(`id`, `role_id`, `menu_id`, `action_id`, `created_by`, `updated_at`, `deleted_at`, `location_id`, `area_id`, `updated_by`, `created_at`)
	VALUES (NULL, '1', (SELECT id FROM sps_menu WHERE sps_menu.menu_item = "detailed_payments_report"), '6', '0', CURRENT_TIMESTAMP, NULL, '0', '0', '0', CURRENT_TIMESTAMP);



/*-------Very IMP---------Start - The following query is for new user name as APS user. To do this first create new admin user same as exisiting admin user. Now change and set the user_name = aps, first_name = APS where USER_ID = 1 i.e we are changing the name of admin to APS. Now, USER_ID = 1 will be aps user and New admin user should be created*/


/*This below query first duplicate the record of admin user where user_id = 1 and it will insert as new record*/
INSERT INTO sps_users 
    (SELECT 'null', `user_name`, `first_name`, `last_name`, `user_role`, `phone_no`, `email_id`, `employee_code`, `employment_status`, `password`, `status`, `activate_status`, `login_status`, `created_by`, `updated_by`, `area_id`, `location_id`, `deleted_at`, `updated_at`, `created_at` FROM sps_users WHERE user_id = 1 and user_name = 'admin');

    
/*Below query will change user_name from admin to aps*/
UPDATE `sps_users` SET `user_name` = 'aps', `first_name` = 'Aps', `deleted_at` = NULL WHERE `sps_users`.`user_id` = 1;  
    
    
    
/*Because sr_no = 1 will be as now APS USER, so deleting a record where sr_no=1 if exists*/
DELETE FROM `sps_shift_management` WHERE `sps_shift_management`.`sr_no` = 1



/*This Insert Query will insert shift record of APS User with USER_ID = 1*/
INSERT INTO `sps_shift_management`
    (`sr_no`, `user_id`, `user_type`, `shift_start`, `shift_end`, `first_login_time`, `end_shift_status`, `shift_login_status`, `shift_activate_status`, `shift_settlement_status`, `difference_status`, `settlement_id`, `float_amount`, `accept_float`, `f_eight_used`, `f_eight_granted`, `area_id`, `location_id`, `created_by`, `updated_by`, `updated_at`, `deleted_at`, `created_at`)
    VALUES ('1', '1', '1', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '1', '0', '1', '1', '0', NULL, '0', '', '1000000', '1000000', '123', '1', '1', '0', '2021-02-09 12:09:30', NULL, '2021-02-08 12:13:56');

/*This insert query will insert record for cashier login time and logout time*/
INSERT INTO `sps_cashiers_log`
    (`log_id`, `user_id`, `gate_id`, `shift_id`, `login_time`, `logout_time`, `location_id`, `area_id`)
    VALUES (NULL, '1', (SELECT gate_id FROM sps_gate_configurations WHERE sps_gate_configurations.is_aps = "1" AND sps_gate_configurations.aps_gate_type = "web"), '1', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0', '0');
/*-------Very IMP---------End*/


/**----EOD MENU Sequence is change as per the APS Reports**/
/*sps_eod_report_select table query - FOR APS EOD Reports*/
INSERT INTO `sps_eod_report_select`
    (`eod_report_id`, `eod_report_name`, `status`, `area_id`, `location_id`, `eod_reportvise_id`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`)
    VALUES (NULL, 'digital_payments', '1', '1', '1', '5', '1', '0', current_timestamp(), NULL, NULL);


UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '6' WHERE `sps_eod_report_select`.`eod_report_name` = 'vehicle_type_wise_revenue';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '6.1' WHERE `sps_eod_report_select`.`eod_report_name` = 'vehicle_type_wise_revenue_report_in_gate';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '6.2' WHERE `sps_eod_report_select`.`eod_report_name` = 'vehicle_type_wise_revenue_report_out_gate';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '6.3' WHERE `sps_eod_report_select`.`eod_report_name` = 'vehicle_type_wise_revenue_report_cps_gate';

UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '7' WHERE `sps_eod_report_select`.`eod_report_name` = 'free_of_cost';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '8' WHERE `sps_eod_report_select`.`eod_report_name` = 'voucher_consumption';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '9' WHERE `sps_eod_report_select`.`eod_report_name` = 'loyalty_discount';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '10' WHERE `sps_eod_report_select`.`eod_report_name` = 'max_charge_discount';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '11' WHERE `sps_eod_report_select`.`eod_report_name` = 'membership_income';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '12' WHERE `sps_eod_report_select`.`eod_report_name` = 'membership_details_change';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '13' WHERE `sps_eod_report_select`.`eod_report_name` = 'membership_block_cancellation';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '14' WHERE `sps_eod_report_select`.`eod_report_name` = 'voucher_income';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '15' WHERE `sps_eod_report_select`.`eod_report_name` = 'down_time_O-Manual';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '16' WHERE `sps_eod_report_select`.`eod_report_name` = 'bank_deposit';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '17' WHERE `sps_eod_report_select`.`eod_report_name` = 'gate_wise_ticket_cashier_status';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '18' WHERE `sps_eod_report_select`.`eod_report_name` = 'transaction_cancellation';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '19' WHERE `sps_eod_report_select`.`eod_report_name` = 'carried_forward_shift';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '20' WHERE `sps_eod_report_select`.`eod_report_name` = 'manual_transaction';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '21' WHERE `sps_eod_report_select`.`eod_report_name` = 'mixed_transaction';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '22' WHERE `sps_eod_report_select`.`eod_report_name` = 'overnight_vehicle_report';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '23' WHERE `sps_eod_report_select`.`eod_report_name` = 'dwell_time_report';
UPDATE `sps_eod_report_select` SET `eod_reportvise_id` = '24' WHERE `sps_eod_report_select`.`eod_report_name` = 'cashier_login_history';
