update 1.0.8.0
Commits for version update
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,10 +1,11 @@
|
||||
# Please try and keep this file organized by alphabetical order. Single files first, then directories.
|
||||
.env
|
||||
example.env
|
||||
Homestead.yaml
|
||||
Homestead.json
|
||||
/app/Plugins/Reseller/
|
||||
/app/Plugins/
|
||||
/app/Plugins/ServiceDesk/
|
||||
/app/Plugins/Social/
|
||||
/config/lfm.php
|
||||
/nbproject/private/
|
||||
/node_modules
|
||||
@@ -12,3 +13,8 @@ Homestead.json
|
||||
/public/lb-faveo/media/
|
||||
/public/uploads
|
||||
/public/photos/
|
||||
/app/FaveoJob
|
||||
|
||||
app/Plugins/ServiceDesk.zip
|
||||
|
||||
app/Plugins/Social.zip
|
||||
|
@@ -114,7 +114,9 @@ CREATE TABLE IF NOT EXISTS `common_settings` (
|
||||
INSERT INTO `common_settings` (`id`, `option_name`, `option_value`, `status`, `optional_field`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'ticket_token_time_duration', '1', '', '', '2016-08-04 09:13:08', '2016-08-04 09:13:08'),
|
||||
(2, 'enable_rtl', '', '', '', '2016-08-04 09:13:08', '2016-08-04 09:13:08'),
|
||||
(3, 'user_set_ticket_status', '', '1', '', '2016-08-04 09:13:08', '2016-08-04 09:13:08');
|
||||
(3, 'user_set_ticket_status', '', '1', '', '2016-08-04 09:13:08', '2016-08-04 09:13:08'),
|
||||
(4, 'send_otp', '',0,'','2016-06-14 09:07:17','2016-06-14 09:07:17'),
|
||||
(5, 'email_mandatory', '',1,'','2016-06-14 09:07:17','2016-06-14 09:07:17');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -1348,7 +1350,7 @@ CREATE TABLE IF NOT EXISTS `settings_ticket` (
|
||||
--
|
||||
|
||||
INSERT INTO `settings_ticket` (`id`, `num_format`, `num_sequence`, `priority`, `sla`, `help_topic`, `max_open_ticket`, `collision_avoid`, `lock_ticket_frequency`, `captcha`, `status`, `claim_response`, `assigned_ticket`, `answered_ticket`, `agent_mask`, `html`, `client_update`, `max_file_size`, `created_at`, `updated_at`) VALUES
|
||||
(1, '#ABCD 1234 1234567', '0', '1', '2', '1', '', '2', '0', '', 1, 0, 0, 0, 0, 0, 0, 0, '2016-08-04 09:12:50', '2016-08-04 09:12:50');
|
||||
(1, '$$$$-####-####', 'sequence', '1', '2', '1', '', '2', '0', '', 1, 0, 0, 0, 0, 0, 0, 0, '2016-08-04 09:12:50', '2016-08-04 09:12:50');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -1718,6 +1720,7 @@ INSERT INTO `ticket_status` (`id`, `name`, `state`, `mode`, `message`, `flags`,
|
||||
(3, 'Closed', 'closed', 3, 'Ticket have been Closed by', 0, 3, 0, '', 'Closed tickets. Tickets will still be accessible on client and staff panels.', '2016-08-04 09:12:48', '2016-08-04 09:12:48'),
|
||||
(4, 'Archived', 'archived', 3, 'Ticket have been Archived by', 0, 4, 0, '', 'Tickets only adminstratively available but no longer accessible on ticket queues and client panel.', '2016-08-04 09:12:48', '2016-08-04 09:12:48'),
|
||||
(5, 'Deleted', 'deleted', 3, 'Ticket have been Deleted by', 0, 5, 0, '', 'Tickets queued for deletion. Not accessible on ticket queues.', '2016-08-04 09:12:48', '2016-08-04 09:12:48');
|
||||
-- (6, 'Unverified', 'unverified', 3, 'User account verification required.', 0, 6, 0, '', 'Ticket will be open after user verifies his/her account.', '2016-06-14 09:07:04', '2016-06-14 09:07:04');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -2289,6 +2292,25 @@ ALTER TABLE `workflow_action`
|
||||
ALTER TABLE `workflow_rules`
|
||||
ADD CONSTRAINT `workflow_rules_1` FOREIGN KEY (`workflow_id`) REFERENCES `workflow_name` (`id`) ON UPDATE NO ACTION;
|
||||
|
||||
-- ------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `field_values`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `field_values`;
|
||||
CREATE TABLE IF NOT EXISTS `field_values` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`field_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`child_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`field_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`field_value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `field_values_field_id_foreign` (`field_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
|
@@ -114,7 +114,9 @@ CREATE TABLE IF NOT EXISTS `common_settings` (
|
||||
INSERT INTO `common_settings` (`id`, `option_name`, `option_value`, `status`, `optional_field`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'ticket_token_time_duration', '1', '', '', '2016-06-14 09:07:17', '2016-06-14 09:07:17'),
|
||||
(2, 'enable_rtl', '', '', '', '2016-06-14 09:07:17', '2016-06-14 09:07:17'),
|
||||
(3, 'user_set_ticket_status', '',1,'','2016-06-14 09:07:17','2016-06-14 09:07:17');
|
||||
(3, 'user_set_ticket_status', '',1,'','2016-06-14 09:07:17','2016-06-14 09:07:17'),
|
||||
(4, 'send_otp', '',0,'','2016-06-14 09:07:17','2016-06-14 09:07:17'),
|
||||
(5, 'email_mandatory', '',1,'','2016-06-14 09:07:17','2016-06-14 09:07:17');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -1348,7 +1350,7 @@ CREATE TABLE IF NOT EXISTS `settings_ticket` (
|
||||
--
|
||||
|
||||
INSERT INTO `settings_ticket` (`id`, `num_format`, `num_sequence`, `priority`, `sla`, `help_topic`, `max_open_ticket`, `collision_avoid`, `lock_ticket_frequency`, `captcha`, `status`, `claim_response`, `assigned_ticket`, `answered_ticket`, `agent_mask`, `html`, `client_update`, `max_file_size`, `created_at`, `updated_at`) VALUES
|
||||
(1, '#ABCD 1234 1234567', '0', '1', '2', '1', '', '2', '0', '', 1, 0, 0, 0, 0, 0, 0, 0, '2016-06-14 09:07:06', '2016-06-14 09:07:06');
|
||||
(1, '$$$$-####-####', 'sequence', '1', '2', '1', '', '2', '0', '', 1, 0, 0, 0, 0, 0, 0, 0, '2016-06-14 09:07:06', '2016-06-14 09:07:06');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -1589,7 +1591,7 @@ CREATE TABLE IF NOT EXISTS `tickets` (
|
||||
--
|
||||
|
||||
INSERT INTO `tickets` (`id`, `ticket_number`, `user_id`, `dept_id`, `team_id`, `priority_id`, `sla`, `help_topic_id`, `status`, `rating`, `ratingreply`, `flags`, `ip_address`, `assigned_to`, `lock_by`, `lock_at`, `source`, `isoverdue`, `reopened`, `isanswered`, `html`, `is_deleted`, `closed`, `is_transferred`, `transferred_at`, `reopened_at`, `duedate`, `closed_at`, `last_message_at`, `last_response_at`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'AAAB-0001-0000001', 2, 1, NULL, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, NULL, 3, 0, 0, 1, 0, 0, 0, 0, '0000-00-00 00:00:00', NULL, '2016-06-14 20:48:09', NULL, NULL, NULL, '2016-06-14 09:18:09', '2016-06-14 09:18:37');
|
||||
(1, 'AAAA-0000-0000', 2, 1, NULL, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, NULL, 3, 0, 0, 1, 0, 0, 0, 0, '0000-00-00 00:00:00', NULL, '2016-06-14 20:48:09', NULL, NULL, NULL, '2016-06-14 09:18:09', '2016-06-14 09:18:37');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -1727,6 +1729,7 @@ INSERT INTO `ticket_status` (`id`, `name`, `state`, `mode`, `message`, `flags`,
|
||||
(3, 'Closed', 'closed', 3, 'Ticket have been Closed by', 0, 3, 0, '', 'Closed tickets. Tickets will still be accessible on client and staff panels.', '2016-06-14 09:07:04', '2016-06-14 09:07:04'),
|
||||
(4, 'Archived', 'archived', 3, 'Ticket have been Archived by', 0, 4, 0, '', 'Tickets only adminstratively available but no longer accessible on ticket queues and client panel.', '2016-06-14 09:07:04', '2016-06-14 09:07:04'),
|
||||
(5, 'Deleted', 'deleted', 3, 'Ticket have been Deleted by', 0, 5, 0, '', 'Tickets queued for deletion. Not accessible on ticket queues.', '2016-06-14 09:07:04', '2016-06-14 09:07:04');
|
||||
-- (6, 'Unverified', 'unverified', 3, 'User account verification required.', 0, 6, 0, '', 'Ticket will be open after user verifies his/her account.', '2016-06-14 09:07:04', '2016-06-14 09:07:04');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -2315,6 +2318,25 @@ ALTER TABLE `workflow_action`
|
||||
ALTER TABLE `workflow_rules`
|
||||
ADD CONSTRAINT `workflow_rules_1` FOREIGN KEY (`workflow_id`) REFERENCES `workflow_name` (`id`) ON UPDATE NO ACTION;
|
||||
|
||||
-- ------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `field_values`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `field_values`;
|
||||
CREATE TABLE IF NOT EXISTS `field_values` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`field_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`child_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`field_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`field_value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `field_values_field_id_foreign` (`field_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
|
@@ -6,6 +6,40 @@
|
||||
INSERT INTO `common_settings` (`id`, `option_name`, `option_value`, `status`, `optional_field`, `created_at`, `updated_at`)
|
||||
VALUES (2, 'enable_rtl', '', '', '', '2016-06-14 09:07:17', '2016-06-14 09:07:17'),
|
||||
(3, 'user_set_ticket_status', '',1,'','2016-06-14 09:07:17','2016-06-14 09:07:17'),
|
||||
(4, 'send_otp', '',0,'','2016-06-14 09:07:17','2016-06-14 09:07:17');
|
||||
INSERT INTO `ticket_status` (`id`, `name`, `state`, `mode`, `message`, `flags`, `sort`, `email_user`, `icon_class`, `properties`, `created_at`, `updated_at`)
|
||||
VALUES (6, 'Unverified', 'unverified', 3, 'User account verification required.', 0, 6, 0, '', 'Ticket will be open after user verifies his/her account.', '2016-06-14 09:07:04', '2016-06-14 09:07:04');
|
||||
(4, 'send_otp', '',0,'','2016-06-14 09:07:17','2016-06-14 09:07:17'),
|
||||
(5, 'email_mandatory', '',1,'','2016-06-14 09:07:17','2016-06-14 09:07:17');
|
||||
-- INSERT INTO `ticket_status` (`id`, `name`, `state`, `mode`, `message`, `flags`, `sort`, `email_user`, `icon_class`, `properties`, `created_at`, `updated_at`)
|
||||
-- VALUES (6, 'Unverified', 'unverified', 3, 'User account verification required.', 0, 6, 0, '', 'Ticket will be open after user verifies his/her account.', '2016-06-14 09:07:04', '2016-06-14 09:07:04');
|
||||
|
||||
--
|
||||
-- Alter Table structure for table `users`
|
||||
--
|
||||
ALTER TABLE `users` ADD `fcm_token` VARCHAR( 500 ) NULL AFTER `profile_pic`;
|
||||
|
||||
-- ------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `field_values`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `field_values`;
|
||||
CREATE TABLE IF NOT EXISTS `field_values` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`field_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`child_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`field_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`field_value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `field_values_field_id_foreign` (`field_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Update values in table `settings_ticket`
|
||||
--
|
||||
UPDATE `settings_ticket` SET `num_format` = '$$$$-####-####', `num_sequence` = 'sequence' WHERE `id` = 1;
|
||||
|
||||
----------------------------------------------------------------------
|
318
DB/update from 1.0.7.9 to 1.0.8.0/Updatedatabase.sql
Normal file
318
DB/update from 1.0.7.9 to 1.0.8.0/Updatedatabase.sql
Normal file
@@ -0,0 +1,318 @@
|
||||
-- -----------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `conditions`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `conditions`;
|
||||
CREATE TABLE IF NOT EXISTS `conditions` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`job` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`value` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `failed_jobs`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `failed_jobs`;
|
||||
CREATE TABLE IF NOT EXISTS `failed_jobs` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`connection` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`queue` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`payload` longtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `faveo_mails`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `faveo_mails`;
|
||||
CREATE TABLE IF NOT EXISTS `faveo_mails` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`email_id` int(11) NOT NULL,
|
||||
`drive` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`value` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `faveo_queues`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `faveo_queues`;
|
||||
CREATE TABLE IF NOT EXISTS `faveo_queues` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`service_id` int(11) NOT NULL,
|
||||
`key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`value` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `field_values`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `field_values`;
|
||||
CREATE TABLE IF NOT EXISTS `field_values` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`field_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`child_id` int(10) UNSIGNED DEFAULT NULL,
|
||||
`field_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`field_value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `field_values_field_id_foreign` (`field_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `jobs`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `jobs`;
|
||||
CREATE TABLE IF NOT EXISTS `jobs` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`queue` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`payload` longtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`attempts` tinyint(3) UNSIGNED NOT NULL,
|
||||
`reserved` tinyint(3) UNSIGNED NOT NULL,
|
||||
`reserved_at` int(10) UNSIGNED DEFAULT NULL,
|
||||
`available_at` int(10) UNSIGNED NOT NULL,
|
||||
`created_at` int(10) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `jobs_queue_reserved_reserved_at_index` (`queue`,`reserved`,`reserved_at`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `mail_services`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `mail_services`;
|
||||
CREATE TABLE IF NOT EXISTS `mail_services` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`short_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `mail_services`
|
||||
--
|
||||
|
||||
INSERT INTO `mail_services` (`id`, `name`, `short_name`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'SMTP', 'smtp', '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(2, 'Php Mail', 'mail', '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(3, 'Send Mail', 'sendmail', '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(4, 'Mailgun', 'mailgun', '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(5, 'Mandrill', 'mandrill', '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(6, 'Log file', 'log', '2016-10-09 15:32:44', '2016-10-09 15:32:44');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `queue_services`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `queue_services`;
|
||||
CREATE TABLE IF NOT EXISTS `queue_services` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`short_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`status` int(11) NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `queue_services`
|
||||
--
|
||||
|
||||
INSERT INTO `queue_services` (`id`, `name`, `short_name`, `status`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'Sync', 'sync', 1, '2016-10-09 15:32:44', '2016-10-09 16:05:03'),
|
||||
(2, 'Database', 'database', 0, '2016-10-09 15:32:44', '2016-10-09 16:05:03'),
|
||||
(3, 'Beanstalkd', 'beanstalkd', 0, '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(4, 'SQS', 'sqs', 0, '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(5, 'Iron', 'iron', 0, '2016-10-09 15:32:44', '2016-10-09 15:32:44'),
|
||||
(6, 'Redis', 'redis', 0, '2016-10-09 15:32:44', '2016-10-09 15:32:44');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `social_media`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `social_media`;
|
||||
CREATE TABLE IF NOT EXISTS `social_media` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`provider` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`value` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `user_additional_infos`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `user_additional_infos`;
|
||||
CREATE TABLE IF NOT EXISTS `user_additional_infos` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`owner` int(11) NOT NULL,
|
||||
`service` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------------
|
||||
--
|
||||
-- Alter Table structure for table `common_settings`
|
||||
--
|
||||
INSERT INTO `common_settings` (`id`, `option_name`, `option_value`, `status`, `optional_field`, `created_at`, `updated_at`)
|
||||
VALUES (4, 'send_otp', '',0,'','2016-06-14 09:07:17','2016-06-14 09:07:17'),
|
||||
(5, 'email_mandatory', '',1,'','2016-06-14 09:07:17','2016-06-14 09:07:17'),
|
||||
(6, 'user_priority', '', '0', '', '2016-10-09 15:32:50', '2016-10-09 15:32:50');
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `approval`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `approval`;
|
||||
CREATE TABLE IF NOT EXISTS `approval` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`status` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `approval`
|
||||
--
|
||||
|
||||
INSERT INTO `approval` (`id`, `name`, `status`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'approval', '0', '2016-10-09 15:32:45', '2016-10-09 15:32:45');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `followup`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `followup`;
|
||||
CREATE TABLE IF NOT EXISTS `followup` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`status` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`condition` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `followup`
|
||||
--
|
||||
|
||||
INSERT INTO `followup` (`id`, `name`, `status`, `condition`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'followup', '', '', '2016-10-09 15:32:45', '2016-10-09 15:32:45');
|
||||
|
||||
-- --------------------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Alter ticket_priority table
|
||||
--
|
||||
ALTER TABLE `ticket_priority` ADD (`status` tinyint(1) DEFAULT 0, `is_default` varchar(30));
|
||||
|
||||
--
|
||||
-- Update ticket_priority table values
|
||||
--
|
||||
UPDATE `ticket_priority`
|
||||
SET `status` = 1
|
||||
WHERE `priority` = 'Normal';
|
||||
|
||||
UPDATE `ticket_priority`
|
||||
SET `priority_color` = '#80ff00'
|
||||
WHERE `priority_id` = 1;
|
||||
|
||||
UPDATE `ticket_priority`
|
||||
SET `priority_color` = '#367FA9'
|
||||
WHERE `priority_id` = 2;
|
||||
|
||||
UPDATE `ticket_priority`
|
||||
SET `priority_color` = '#ffff00'
|
||||
WHERE `priority_id` = 3;
|
||||
|
||||
UPDATE `ticket_priority`
|
||||
SET `priority_color` = '#ff6666'
|
||||
WHERE `priority_id` = 4;
|
||||
-- --------------------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Alter `users` table
|
||||
--
|
||||
ALTER TABLE `users` MODIFY `mobile` VARCHAR(30) DEFAULT NULL;
|
||||
UPDATE `users` SET `mobile` = NULL WHERE `mobile` = '';
|
||||
ALTER TABLE `users` ADD UNIQUE (`mobile`);
|
||||
|
||||
-- --------------------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Alter `settings_ticket` table
|
||||
--
|
||||
UPDATE `settings_ticket`
|
||||
SET `num_format` = '$$$$-####-###' , `num_sequence` = 'sequence';
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Insert new values in `template_types`
|
||||
--
|
||||
INSERT INTO `template_types` (`id`, `name`, `created_at`, `updated_at`) VALUES
|
||||
(12, 'team_assign_ticket', '2016-10-10 01:29:36', '2016-10-10 01:29:36'),
|
||||
(13, 'reset_new_password', '2016-10-10 01:29:36', '2016-10-10 01:29:36');
|
||||
|
||||
-- --------------------------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Insert new values in `templates` table
|
||||
--
|
||||
INSERT INTO `templates` (`id`, `name`, `variable`, `type`, `subject`, `message`, `description`, `set_id`, `created_at`, `updated_at`) VALUES
|
||||
(12, 'This template is for sending notice to team when ticket is assigned to team', '1', 12, '', '<div>Hello {!!$ticket_agent_name!!},<br /><br /><b>Ticket No:</b> {!!$ticket_number!!}<br />Has been assigned to your team : {!!$team!!} by {!!$ticket_assigner!!} <br /><br />Thank You<br />Kind Regards,<br />{!!$system_from!!}</div>', '', 1, '2016-10-10 01:29:38', '2016-10-10 01:29:38'),
|
||||
(13, 'This template is for sending notice to client when password is changed', '1', 13, 'Verify your email address', 'Hello {!!$user!!},<br /><br />Your password is successfully changed.Your new password is : {!!$user_password!!}<br /><br />Thank You.<br /><br />Kind Regards,<br /> {!!$system_from!!}', '', 1, '2016-10-10 01:29:38', '2016-10-10 01:29:38');
|
||||
-- --------------------------------------------------------------------------
|
||||
|
50
app/Console/Commands/CloseWork.php
Normal file
50
app/Console/Commands/CloseWork.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Http\Controllers\Client\helpdesk\UnAuthController;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CloseWork extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ticket:close';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Ticket will close according to workflow';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (env('DB_INSTALL') == 1) {
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$controller = new UnAuthController($PhpMailController);
|
||||
$controller->autoCloseTickets();
|
||||
loging('ticket-close-workflow', 'Close ticket workflow executed', 'info');
|
||||
//\Log::info('Close ticket workflow executed');
|
||||
$this->info('Close ticket workflow executed');
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,8 +22,6 @@ class SendReport extends Command
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Sending the report mail ';
|
||||
protected $report;
|
||||
protected $mail;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
@@ -32,9 +30,6 @@ class SendReport extends Command
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$mail = new PhpMailController();
|
||||
$report = new NotificationController($mail);
|
||||
$this->report = $report;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -46,11 +41,23 @@ class SendReport extends Command
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$this->report->send_notification();
|
||||
\Log::info('Report has send');
|
||||
$this->info('Report has send');
|
||||
if (env('DB_INSTALL') == 1) {
|
||||
$mail = new PhpMailController();
|
||||
$mail->setQueue();
|
||||
$this_report = new NotificationController($mail);
|
||||
$report = $this_report->send_notification();
|
||||
|
||||
if ($report !== 0) {
|
||||
loging('sending-mail-report', 'Report has send', 'info');
|
||||
//\Log::info("Report has send");
|
||||
$this->info('Report has send');
|
||||
} else {
|
||||
loging('sending-mail-report', 'Nothing to send', 'info');
|
||||
$this->info('Nothing to send');
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
//dd($ex);
|
||||
$this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
67
app/Console/Commands/TicketFetch.php
Normal file
67
app/Console/Commands/TicketFetch.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Http\Controllers\Agent\helpdesk\MailController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
|
||||
use Event;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class TicketFetch extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ticket:fetch';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fetching the tickets from service provider';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (env('DB_INSTALL') == 1) {
|
||||
$controller = $this->mailController();
|
||||
$emails = new \App\Model\helpdesk\Email\Emails();
|
||||
$settings_email = new \App\Model\helpdesk\Settings\Email();
|
||||
$system = new \App\Model\helpdesk\Settings\System();
|
||||
$ticket = new \App\Model\helpdesk\Settings\Ticket();
|
||||
$controller->readmails($emails, $settings_email, $system, $ticket);
|
||||
Event::fire('ticket.fetch', ['event' => '']);
|
||||
loging('fetching-ticket', 'Ticket has read', 'info');
|
||||
//\Log::info('Ticket has read');
|
||||
$this->info('Ticket has read');
|
||||
}
|
||||
}
|
||||
|
||||
public function mailController()
|
||||
{
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$ticket = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
|
||||
$work = new TicketWorkflowController($ticket);
|
||||
$controller = new MailController($work);
|
||||
|
||||
return $controller;
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Model\MailJob\Condition;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -14,6 +15,9 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\Inspire',
|
||||
'App\Console\Commands\SendReport',
|
||||
'App\Console\Commands\CloseWork',
|
||||
'App\Console\Commands\TicketFetch',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -25,12 +29,97 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('inspire')
|
||||
->hourly();
|
||||
if (env('DB_INSTALL') == 1) {
|
||||
$queue = $this->getCurrentQueue();
|
||||
$schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute()->withoutOverlapping();
|
||||
$this->execute($schedule, 'fetching');
|
||||
$this->execute($schedule, 'notification');
|
||||
$this->execute($schedule, 'work');
|
||||
$this->execute($schedule, 'followup');
|
||||
$this->execute($schedule, 'message');
|
||||
loging('cron', 'executed successfully', 'info');
|
||||
}
|
||||
}
|
||||
|
||||
$schedule->call(function () {
|
||||
$user = new User();
|
||||
$user->save();
|
||||
})->everyFiveMinutes();
|
||||
public function execute($schedule, $task)
|
||||
{
|
||||
$condition = new Condition();
|
||||
$command = $condition->getConditionValue($task);
|
||||
switch ($task) {
|
||||
case 'fetching':
|
||||
$this->getCondition($schedule->command('ticket:fetch'), $command);
|
||||
break;
|
||||
case 'notification':
|
||||
$this->getCondition($schedule->command('report:send'), $command);
|
||||
break;
|
||||
case 'work':
|
||||
$this->getCondition($schedule->command('ticket:close'), $command);
|
||||
break;
|
||||
case 'followup':
|
||||
$this->getCondition($schedule->command('users:followup'), $command);
|
||||
break;
|
||||
case 'message':
|
||||
$this->getCondition($schedule->command('message:send'), $command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCondition($schedule, $command)
|
||||
{
|
||||
$condition = $command['condition'];
|
||||
$at = $command['at'];
|
||||
switch ($condition) {
|
||||
case 'everyMinute':
|
||||
$schedule->everyMinute()->withoutOverlapping();
|
||||
break;
|
||||
case 'everyFiveMinutes':
|
||||
$schedule->everyFiveMinutes()->withoutOverlapping();
|
||||
break;
|
||||
case 'everyTenMinutes':
|
||||
$schedule->everyTenMinutes()->withoutOverlapping();
|
||||
break;
|
||||
case 'everyThirtyMinutes':
|
||||
$schedule->everyThirtyMinutes()->withoutOverlapping();
|
||||
break;
|
||||
case 'hourly':
|
||||
$schedule->hourly()->withoutOverlapping();
|
||||
break;
|
||||
case 'daily':
|
||||
$schedule->daily()->withoutOverlapping();
|
||||
break;
|
||||
case 'dailyAt':
|
||||
$this->getConditionWithOption($schedule, $condition, $at);
|
||||
break;
|
||||
case 'weekly':
|
||||
$schedule->weekly()->withoutOverlapping();
|
||||
break;
|
||||
case 'monthly':
|
||||
$schedule->monthly()->withoutOverlapping();
|
||||
break;
|
||||
case 'yearly':
|
||||
$schedule->yearly()->withoutOverlapping();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getConditionWithOption($schedule, $command, $at)
|
||||
{
|
||||
switch ($command) {
|
||||
case 'dailyAt':
|
||||
$schedule->dailyAt($at)->withoutOverlapping();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrentQueue()
|
||||
{
|
||||
$queue = 'database';
|
||||
$services = new \App\Model\MailJob\QueueService();
|
||||
$current = $services->where('status', 1)->first();
|
||||
if ($current) {
|
||||
$queue = $current->short_name;
|
||||
}
|
||||
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
|
@@ -90,6 +90,8 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
if (config('app.debug') == true) {
|
||||
return parent::render($request, $e);
|
||||
} elseif ($e instanceof ValidationException) {
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
return response()->view('errors.500');
|
||||
|
195
app/FaveoLog/LaravelLogViewer.php
Normal file
195
app/FaveoLog/LaravelLogViewer.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace App\FaveoLog;
|
||||
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Psr\Log\LogLevel;
|
||||
use ReflectionClass;
|
||||
use UTC;
|
||||
|
||||
/**
|
||||
* Class LaravelLogViewer.
|
||||
*/
|
||||
class LaravelLogViewer
|
||||
{
|
||||
/**
|
||||
* @var string file
|
||||
*/
|
||||
private static $file;
|
||||
private static $levels_classes = [
|
||||
'debug' => 'info',
|
||||
'info' => 'info',
|
||||
'notice' => 'info',
|
||||
'warning' => 'warning',
|
||||
'error' => 'danger',
|
||||
'critical' => 'danger',
|
||||
'alert' => 'danger',
|
||||
'emergency' => 'danger',
|
||||
];
|
||||
private static $levels_imgs = [
|
||||
'debug' => 'info',
|
||||
'info' => 'info',
|
||||
'notice' => 'info',
|
||||
'warning' => 'warning',
|
||||
'error' => 'warning',
|
||||
'critical' => 'warning',
|
||||
'alert' => 'warning',
|
||||
'emergency' => 'warning',
|
||||
];
|
||||
|
||||
const MAX_FILE_SIZE = 52428800; // Why? Uh... Sorry
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
*/
|
||||
public static function setFile($file)
|
||||
{
|
||||
$file = self::pathToLogFile($file);
|
||||
|
||||
if (File::exists($file)) {
|
||||
self::$file = $file;
|
||||
}
|
||||
}
|
||||
|
||||
public static function pathToLogFile($file)
|
||||
{
|
||||
$logsPath = storage_path('logs');
|
||||
|
||||
if (File::exists($file)) { // try the absolute path
|
||||
return $file;
|
||||
}
|
||||
|
||||
$file = $logsPath.'/'.$file;
|
||||
|
||||
// check if requested file is really in the logs directory
|
||||
if (dirname($file) !== $logsPath) {
|
||||
throw new \Exception('No such log file');
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getFileName()
|
||||
{
|
||||
return basename(self::$file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function all()
|
||||
{
|
||||
$log = [];
|
||||
|
||||
$log_levels = self::getLogLevels();
|
||||
|
||||
$pattern = '/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/';
|
||||
|
||||
if (!self::$file) {
|
||||
$log_file = self::getFiles();
|
||||
if (!count($log_file)) {
|
||||
return [];
|
||||
}
|
||||
self::$file = $log_file[0];
|
||||
}
|
||||
|
||||
if (File::size(self::$file) > self::MAX_FILE_SIZE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = File::get(self::$file);
|
||||
|
||||
preg_match_all($pattern, $file, $headings);
|
||||
|
||||
if (!is_array($headings)) {
|
||||
return $log;
|
||||
}
|
||||
|
||||
$log_data = preg_split($pattern, $file);
|
||||
|
||||
if ($log_data[0] < 1) {
|
||||
array_shift($log_data);
|
||||
}
|
||||
|
||||
foreach ($headings as $h) {
|
||||
for ($i = 0, $j = count($h); $i < $j; $i++) {
|
||||
foreach ($log_levels as $level_key => $level_value) {
|
||||
if (strpos(strtolower($h[$i]), '.'.$level_value)) {
|
||||
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?(\w+)\.'.$level_key.': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current);
|
||||
|
||||
if (!isset($current[3])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$array = explode(':-:-:-', $current[3]);
|
||||
$message = $current[3];
|
||||
$context = $current[2];
|
||||
|
||||
if (is_array($array)) {
|
||||
if (array_key_exists(0, $array)) {
|
||||
$message = $array[0];
|
||||
}
|
||||
if (array_key_exists(1, $array)) {
|
||||
$context = $array[1];
|
||||
} else {
|
||||
$context = $current[2];
|
||||
}
|
||||
}
|
||||
//dd($current);
|
||||
$log[] = [
|
||||
'context' => $context,
|
||||
'level' => $level_value,
|
||||
'level_class' => self::$levels_classes[$level_value],
|
||||
'level_img' => self::$levels_imgs[$level_value],
|
||||
'date' => self::date($current[1]),
|
||||
'text' => $message,
|
||||
'in_file' => isset($current[4]) ? $current[4] : null,
|
||||
'stack' => preg_replace("/^\n*/", '', $log_data[$i]),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_reverse($log);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $basename
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFiles($basename = false)
|
||||
{
|
||||
$files = glob(storage_path().'/logs/*');
|
||||
$files = array_reverse($files);
|
||||
$files = array_filter($files, 'is_file');
|
||||
if ($basename && is_array($files)) {
|
||||
foreach ($files as $k => $file) {
|
||||
$files[$k] = basename($file);
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($files);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private static function getLogLevels()
|
||||
{
|
||||
$class = new ReflectionClass(new LogLevel());
|
||||
|
||||
return $class->getConstants();
|
||||
}
|
||||
|
||||
public static function date($utc)
|
||||
{
|
||||
$system_date = UTC::usertimezone($utc);
|
||||
|
||||
return $system_date;
|
||||
}
|
||||
}
|
58
app/FaveoLog/LaravelLogViewerServiceProvider.php
Normal file
58
app/FaveoLog/LaravelLogViewerServiceProvider.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\FaveoLog;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class LaravelLogViewerServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (method_exists($this, 'package')) {
|
||||
$this->package('rap2hpoutre/laravel-log-viewer', 'laravel-log-viewer', __DIR__.'/../../');
|
||||
}
|
||||
|
||||
|
||||
$view_path = app_path().DIRECTORY_SEPARATOR.'FaveoLog'.DIRECTORY_SEPARATOR.'views';
|
||||
$this->loadViewsFrom($view_path, 'log');
|
||||
|
||||
$lang_path = app_path().DIRECTORY_SEPARATOR.'FaveoLog'.DIRECTORY_SEPARATOR.'lang';
|
||||
$this->loadTranslationsFrom($lang_path, 'log');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
// Add routes
|
||||
$routes = app_path('/FaveoLog/routes.php');
|
||||
if (file_exists($routes)) {
|
||||
require $routes;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
0
app/FaveoLog/config/.gitkeep
Normal file
0
app/FaveoLog/config/.gitkeep
Normal file
0
app/FaveoLog/controllers/.gitkeep
Normal file
0
app/FaveoLog/controllers/.gitkeep
Normal file
38
app/FaveoLog/controllers/LogViewerController.php
Normal file
38
app/FaveoLog/controllers/LogViewerController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\FaveoLog\controllers;
|
||||
|
||||
use App\FaveoLog\LaravelLogViewer;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class LogViewerController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (Request::input('l')) {
|
||||
//dd(base64_decode(Request::input('l')));
|
||||
LaravelLogViewer::setFile(base64_decode(Request::input('l')));
|
||||
}
|
||||
|
||||
if (Request::input('dl')) {
|
||||
return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl'))));
|
||||
} elseif (Request::has('del')) {
|
||||
File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del'))));
|
||||
|
||||
return Redirect::to(Request::url());
|
||||
}
|
||||
|
||||
$logs = LaravelLogViewer::all();
|
||||
|
||||
return View::make('log::log', [
|
||||
'logs' => $logs,
|
||||
'files' => LaravelLogViewer::getFiles(true),
|
||||
'current_file' => LaravelLogViewer::getFileName(),
|
||||
]);
|
||||
}
|
||||
}
|
0
app/FaveoLog/lang/.gitkeep
Normal file
0
app/FaveoLog/lang/.gitkeep
Normal file
5
app/FaveoLog/lang/en/lang.php
Normal file
5
app/FaveoLog/lang/en/lang.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'logs' => 'Logs',
|
||||
];
|
9
app/FaveoLog/routes.php
Normal file
9
app/FaveoLog/routes.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
Breadcrumbs::register('logs', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
$breadcrumbs->push('System Logs', route('logs'));
|
||||
});
|
||||
Route::group(['middleware' => ['web', 'auth', 'roles']], function () {
|
||||
Route::get('logs', ['as' => 'logs', 'uses' => 'App\FaveoLog\controllers\LogViewerController@index']);
|
||||
});
|
0
app/FaveoLog/views/.gitkeep
Normal file
0
app/FaveoLog/views/.gitkeep
Normal file
132
app/FaveoLog/views/log.blade.php
Normal file
132
app/FaveoLog/views/log.blade.php
Normal file
@@ -0,0 +1,132 @@
|
||||
@extends('themes.default1.admin.layout.admin')
|
||||
@section('Log')
|
||||
active
|
||||
@stop
|
||||
|
||||
@section('logs')
|
||||
class="active"
|
||||
@stop
|
||||
|
||||
@section('HeadInclude')
|
||||
@stop
|
||||
<!-- header -->
|
||||
@section('PageHeader')
|
||||
<h1>{{Lang::get('log::lang.logs')}}</h1>
|
||||
@stop
|
||||
<!-- /header -->
|
||||
<!-- breadcrumbs -->
|
||||
@section('breadcrumbs')
|
||||
<ol class="breadcrumb">
|
||||
</ol>
|
||||
@stop
|
||||
@section('content')
|
||||
<style>
|
||||
|
||||
|
||||
.stack {
|
||||
font-size: 0.85em;
|
||||
}
|
||||
.date {
|
||||
min-width: 75px;
|
||||
}
|
||||
.text {
|
||||
word-break: break-all;
|
||||
}
|
||||
a.llv-active {
|
||||
z-index: 2;
|
||||
background-color: #f5f5f5;
|
||||
border-color: #777;
|
||||
}
|
||||
</style>
|
||||
<div class="container-fluid">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h4>System Logs</h4>
|
||||
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="list-group">
|
||||
@foreach($files as $file)
|
||||
<a href="?l={{ base64_encode($file) }}" class="list-group-item @if ($current_file == $file) llv-active @endif">
|
||||
{{$file}}
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-10 table-container">
|
||||
@if ($logs === null)
|
||||
<div>
|
||||
Log file >50M, please download it.
|
||||
</div>
|
||||
@else
|
||||
<table id="table-log" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:10%">Level</th>
|
||||
<th style="width:12%">Context</th>
|
||||
<th>Date</th>
|
||||
<th>Content</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@foreach($logs as $key => $log)
|
||||
<tr>
|
||||
<td class="text-{{{$log['level_class']}}}"><span class="glyphicon glyphicon-{{{$log['level_img']}}}-sign" aria-hidden="true"></span> {{ucfirst($log['level'])}}</td>
|
||||
<td class="text">{{ucfirst($log['context'])}}</td>
|
||||
<td class="date">{{{$log['date']}}}</td>
|
||||
<td class="text">
|
||||
@if ($log['stack']) <a class="pull-right expand btn btn-default btn-xs" data-display="stack{{{$key}}}"><span class="glyphicon glyphicon-search"></span></a>@endif
|
||||
{{{$log['text']}}}
|
||||
@if (isset($log['in_file'])) <br />{{{$log['in_file']}}}@endif
|
||||
@if ($log['stack']) <div class="stack" id="stack{{{$key}}}" style="display: none; white-space: pre-wrap;">{{{ trim($log['stack']) }}}</div>@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
<div>
|
||||
<a href="?dl={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-download-alt"></span> Download file</a>
|
||||
-
|
||||
<a id="delete-log" href="?del={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-trash"></span> Delete file</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@stop
|
||||
@section('FooterInclude')
|
||||
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>-->
|
||||
<!--<script src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>-->
|
||||
<script src="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#table-log').DataTable({
|
||||
"order": [1, 'desc'],
|
||||
"stateSave": true,
|
||||
"stateSaveCallback": function (settings, data) {
|
||||
window.localStorage.setItem("datatable", JSON.stringify(data));
|
||||
},
|
||||
"stateLoadCallback": function (settings) {
|
||||
var data = JSON.parse(window.localStorage.getItem("datatable"));
|
||||
if (data)
|
||||
data.start = 0;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
$('.table-container').on('click', '.expand', function () {
|
||||
$('#' + $(this).data('display')).toggle();
|
||||
});
|
||||
$('#delete-log').click(function () {
|
||||
return confirm('Are you sure?');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@stop
|
106
app/FaveoLog/views/logold.blade.php
Normal file
106
app/FaveoLog/views/logold.blade.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Laravel log viewer</title>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.css">
|
||||
|
||||
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 col-md-2 sidebar">
|
||||
<h1><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span> Laravel Log Viewer</h1>
|
||||
<p class="text-muted"><i>by Rap2h</i></p>
|
||||
<div class="list-group">
|
||||
@foreach($files as $file)
|
||||
<a href="?l={{ base64_encode($file) }}" class="list-group-item @if ($current_file == $file) llv-active @endif">
|
||||
{{$file}}
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9 col-md-10 table-container">
|
||||
@if ($logs === null)
|
||||
<div>
|
||||
Log file >50M, please download it.
|
||||
</div>
|
||||
@else
|
||||
<table id="table-log" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Level</th>
|
||||
<th>Context</th>
|
||||
<th>Date</th>
|
||||
<th>Content</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@foreach($logs as $key => $log)
|
||||
<tr>
|
||||
<td class="text-{{{$log['level_class']}}}"><span class="glyphicon glyphicon-{{{$log['level_img']}}}-sign" aria-hidden="true"></span> {{$log['level']}}</td>
|
||||
<td class="text">{{$log['context']}}</td>
|
||||
<td class="date">{{{$log['date']}}}</td>
|
||||
<td class="text">
|
||||
@if ($log['stack']) <a class="pull-right expand btn btn-default btn-xs" data-display="stack{{{$key}}}"><span class="glyphicon glyphicon-search"></span></a>@endif
|
||||
{{{$log['text']}}}
|
||||
@if (isset($log['in_file'])) <br />{{{$log['in_file']}}}@endif
|
||||
@if ($log['stack']) <div class="stack" id="stack{{{$key}}}" style="display: none; white-space: pre-wrap;">{{{ trim($log['stack']) }}}</div>@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
<div>
|
||||
<a href="?dl={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-download-alt"></span> Download file</a>
|
||||
-
|
||||
<a id="delete-log" href="?del={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-trash"></span> Delete file</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('#table-log').DataTable({
|
||||
"order": [ 1, 'desc' ],
|
||||
"stateSave": true,
|
||||
"stateSaveCallback": function (settings, data) {
|
||||
window.localStorage.setItem("datatable", JSON.stringify(data));
|
||||
},
|
||||
"stateLoadCallback": function (settings) {
|
||||
var data = JSON.parse(window.localStorage.getItem("datatable"));
|
||||
if (data) data.start = 0;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
$('.table-container').on('click', '.expand', function(){
|
||||
$('#' + $(this).data('display')).toggle();
|
||||
});
|
||||
$('#delete-log').click(function(){
|
||||
return confirm('Are you sure?');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
184
app/Helper/Finder.php
Normal file
184
app/Helper/Finder.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helper;
|
||||
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Groups;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\TicketStatusType;
|
||||
|
||||
/**
|
||||
*------------------------------------------------------------------
|
||||
* Class Finder
|
||||
*------------------------------------------------------------------
|
||||
* Description: This class is used for defining some common functions
|
||||
* used in the project.
|
||||
*
|
||||
* @author <Ladybird Web Solution>
|
||||
*/
|
||||
class Finder
|
||||
{
|
||||
/**
|
||||
* DEPARTMENT
|
||||
* This function is used for returning department name with respect to id.
|
||||
*
|
||||
* @param $id type int
|
||||
* @param $custom type array/null
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public static function department($id, $custom = null)
|
||||
{
|
||||
if ($custom == null) {
|
||||
$department = Department::whereId($id)->select(['name']);
|
||||
} elseif (isset($custom)) {
|
||||
$department = Department::whereId($id)->select($custom);
|
||||
}
|
||||
|
||||
return $department->first()->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* GROUP
|
||||
* This function is used for returning group name with respect to id.
|
||||
*
|
||||
* @param $id type int
|
||||
* @param $custom type array/null
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public static function group($id, $custom = null)
|
||||
{
|
||||
if ($custom == null) {
|
||||
$group = Groups::whereId($id)->select(['name']);
|
||||
} elseif (isset($custom)) {
|
||||
$group = Groups::whereId($id)->select($custom);
|
||||
}
|
||||
|
||||
return $group->first()->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* STATUS TYPE
|
||||
* This function is used for returning status type name with respect to id.
|
||||
*
|
||||
* @param $id type int
|
||||
* @param $custom type array/null
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public static function statusType($id, $custom = null)
|
||||
{
|
||||
if ($custom == null) {
|
||||
$status_type = TicketStatusType::whereId($id)->select(['name']);
|
||||
} elseif (isset($custom)) {
|
||||
$status_type = TicketStatusType::whereId($id)->select($custom);
|
||||
}
|
||||
|
||||
return $status_type->first()->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* STATUS
|
||||
* This function is used for returning status name with respect to id.
|
||||
*
|
||||
* @param $id type int
|
||||
* @param $custom type array/null
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public static function status($id, $custom = null)
|
||||
{
|
||||
if ($custom == null) {
|
||||
$status = Ticket_Status::whereId($id)->first();
|
||||
} elseif (isset($custom)) {
|
||||
$status = Ticket_Status::whereId($id)->select($custom);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* USER ROLES IN A GROUP FOR STATUS LIST
|
||||
* This function is used to return roles of users from a given value.
|
||||
* If the value is 1 the response is client
|
||||
* If the value is 2 the response is agent
|
||||
* If the value is 4 the response is admin
|
||||
* If the value is 1+2 = 3 the response is client, agent
|
||||
* If the value is 1+4 = 5 the response is client, admin
|
||||
* If the value is 2+4 = 6 the response is agent, admin
|
||||
* If the value is 1+2+4 = 7 the response is client, agent, admin.
|
||||
*
|
||||
* @param $id type int
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public static function rolesGroup($id)
|
||||
{
|
||||
switch ($id) {
|
||||
case null:
|
||||
return \Lang::get('lang.none');
|
||||
case 1:
|
||||
return 'Client';
|
||||
case 2:
|
||||
return 'Agent';
|
||||
case 4:
|
||||
return 'Admin';
|
||||
case 3:
|
||||
return 'Client,Agent';
|
||||
case 5:
|
||||
return 'Client,Admin';
|
||||
case 6:
|
||||
return 'Agent,Admin';
|
||||
case 7:
|
||||
return 'Client,Agent,Admin';
|
||||
default:
|
||||
return 'Undefined!';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ANY TYPE STATUS
|
||||
* This function is used to return the set of status which are of any type passed in the param.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public static function anyTypeStatus($id)
|
||||
{
|
||||
$status_group = Ticket_Status::where('purpose_of_status', '=', $id)->select(['id'])->get();
|
||||
foreach ($status_group as $status) {
|
||||
$status_group2[] = $status->id;
|
||||
}
|
||||
|
||||
return $status_group2;
|
||||
}
|
||||
|
||||
/**
|
||||
* RETURNS ALL STATUS
|
||||
* This function is used to return all the status given in the system.
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public static function getAllStatus()
|
||||
{
|
||||
$status = Ticket_Status::where('purpose_of_status', '!=', 3)->orwhere('purpose_of_status', '!=', 4)->get();
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* VARIABLE REPLACEMENT
|
||||
* This function is used to replace the replaceable variables form a given content for templates.
|
||||
*/
|
||||
public static function replaceTemplateVariables($variables, $data, $contents)
|
||||
{
|
||||
foreach ($variables as $key => $variable) {
|
||||
$messagebody = str_replace($variables[$key], $data[$key], $contents);
|
||||
$contents = $messagebody;
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
}
|
17
app/Http/Controllers/Admin/MailFetch.php
Normal file
17
app/Http/Controllers/Admin/MailFetch.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Fetch\Server as Server;
|
||||
|
||||
class MailFetch extends Server
|
||||
{
|
||||
public function __construct($serverPath, $port = 143, $service = 'imap')
|
||||
{
|
||||
$this->serverPath = $serverPath;
|
||||
|
||||
$this->port = $port;
|
||||
|
||||
$this->service = $service;
|
||||
}
|
||||
}
|
@@ -91,7 +91,9 @@ class AgentController extends Controller
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
// returns to the page with all the variables and their datas
|
||||
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team'))->with('phonecode', $phonecode->phonecode);
|
||||
$send_otp = DB::table('common_settings')->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team', 'send_otp'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
// returns if try fails with exception meaagse
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -118,7 +120,12 @@ class AgentController extends Controller
|
||||
}
|
||||
}
|
||||
// fixing the user role to agent
|
||||
$user->fill($request->except(['group', 'primary_department', 'agent_time_zone']))->save();
|
||||
$user->fill($request->except(['group', 'primary_department', 'agent_time_zone', 'mobile']))->save();
|
||||
if ($request->get('mobile')) {
|
||||
$user->mobile = $request->get('mobile');
|
||||
} else {
|
||||
$user->mobile = null;
|
||||
}
|
||||
$user->assign_group = $request->group;
|
||||
$user->primary_dpt = $request->primary_department;
|
||||
$user->agent_tzone = $request->agent_time_zone;
|
||||
@@ -149,6 +156,10 @@ class AgentController extends Controller
|
||||
}
|
||||
}
|
||||
// returns for the success case
|
||||
if ($request->input('active') == '0' || $request->input('active') == 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
}
|
||||
|
||||
return redirect('agents')->with('success', Lang::get('lang.agent_creation_success'));
|
||||
} else {
|
||||
// returns if fails
|
||||
|
@@ -77,7 +77,9 @@ class DepartmentController extends Controller
|
||||
{
|
||||
try {
|
||||
$slas = $sla->get();
|
||||
$user = $user->where('role', 'agent2')->get();
|
||||
$user = $user->where('role', '<>', 'user')
|
||||
->where('active', '=', 1)
|
||||
->get();
|
||||
$emails = $email->get();
|
||||
$templates = $template->get();
|
||||
$department = $department->get();
|
||||
@@ -154,7 +156,9 @@ class DepartmentController extends Controller
|
||||
->where('id', '=', 1)
|
||||
->first();
|
||||
$slas = $sla->get();
|
||||
$user = $user->where('primary_dpt', $id)->get();
|
||||
$user = $user->where('primary_dpt', $id)
|
||||
->where('active', '=', 1)
|
||||
->get();
|
||||
$emails = $email->get();
|
||||
$templates = $template->get();
|
||||
$departments = $department->whereId($id)->first();
|
||||
|
@@ -3,21 +3,20 @@
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\Http\Requests\helpdesk\EmailsEditRequest;
|
||||
use App\Http\Requests\helpdesk\EmailsRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
// model
|
||||
use App\Http\Requests\helpdesk\Mail\MailRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
// classes
|
||||
use App\Model\helpdesk\Utility\MailboxProtocol;
|
||||
use Crypt;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
@@ -81,8 +80,12 @@ class EmailsController extends Controller
|
||||
$priority = $ticket_priority->get();
|
||||
// fetch all the types of mailbox protocols from the mailbox_protocols table
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
|
||||
$service = new \App\Model\MailJob\MailService();
|
||||
$services = $service->lists('name', 'id')->toArray();
|
||||
|
||||
// return with all the table data
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps'));
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'services'));
|
||||
} catch (Exception $e) {
|
||||
// return error messages if any
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -96,77 +99,61 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettings(Request $request)
|
||||
public function validatingEmailSettings(MailRequest $request, $id = '')
|
||||
{
|
||||
$validator = \Validator::make(
|
||||
[
|
||||
'email_address' => $request->input('email_address'),
|
||||
'email_name' => $request->input('email_name'),
|
||||
'password' => $request->input('password'),
|
||||
], [
|
||||
'email_address' => 'required|email|unique:emails',
|
||||
'email_name' => 'required',
|
||||
'password' => 'required',
|
||||
]
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
$jsons = $validator->messages();
|
||||
$val = '';
|
||||
foreach ($jsons->all() as $key => $value) {
|
||||
$val .= $value;
|
||||
}
|
||||
$return_data = rtrim(str_replace('.', ',', $val), ',');
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
if ($request->input('imap_validate') == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} elseif (!$request->input('imap_validate')) {
|
||||
//dd($request->all());
|
||||
try {
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
|
||||
$service = $request->input('sending_protocol');
|
||||
$validate = '/novalidate-cert';
|
||||
$fetch = 1;
|
||||
$send = 1;
|
||||
//dd($request->input('fetching_status'));
|
||||
if ($request->input('fetching_status')) {
|
||||
$fetch = $this->getImapStream($request, $validate);
|
||||
}
|
||||
if ($request->input('sending_status') === 'on') {
|
||||
$this->emailService($service, $service_request);
|
||||
$send = $this->sendDiagnoEmail($request);
|
||||
}
|
||||
if ($send == 1 && $fetch == 1) {
|
||||
$this->store($request, $service_request, $id);
|
||||
|
||||
return $this->jsonResponse('success', Lang::get('lang.success'));
|
||||
}
|
||||
|
||||
return $this->validateEmailError($send, $fetch);
|
||||
} catch (Exception $ex) {
|
||||
$message = $ex->getMessage();
|
||||
if ($request->input('fetching_status') && imap_last_error()) {
|
||||
$message = imap_last_error();
|
||||
}
|
||||
loging('mail-config', $message);
|
||||
|
||||
return $this->jsonResponse('fails', $message);
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check[0] == 0) {
|
||||
return Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
|
||||
}
|
||||
$need_to_check_imap = 1;
|
||||
} else {
|
||||
$imap_check = 0;
|
||||
$need_to_check_imap = 0;
|
||||
}
|
||||
|
||||
public function validateEmailError($out, $in)
|
||||
{
|
||||
if ($out !== 1) {
|
||||
return $this->jsonResponse('fails', Lang::get('lang.outgoing_email_connection_failed'));
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$smtp_check = $this->getSmtp($request);
|
||||
if ($smtp_check == 0) {
|
||||
return Lang::get('lang.outgoing_email_connection_failed');
|
||||
}
|
||||
$need_to_check_smtp = 1;
|
||||
} else {
|
||||
$smtp_check = 0;
|
||||
$need_to_check_smtp = 0;
|
||||
if ($in !== 1) {
|
||||
return $this->jsonResponse('fails', Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings'));
|
||||
}
|
||||
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check != 0 && $smtp_check != 0) {
|
||||
$this->store($request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 1 && $need_to_check_smtp == 0) {
|
||||
if ($imap_check != 0 && $smtp_check == 0) {
|
||||
$this->store($request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check == 0 && $smtp_check != 0) {
|
||||
$this->store($request, null);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 0) {
|
||||
if ($imap_check == 0 && $smtp_check == 0) {
|
||||
$this->store($request, null);
|
||||
$return = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonResponse($type, $message)
|
||||
{
|
||||
if ($type == 'fails') {
|
||||
$result = ['fails' => $message];
|
||||
}
|
||||
if ($type == 'success') {
|
||||
$result = ['success' => $message];
|
||||
}
|
||||
|
||||
return $return;
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,75 +164,136 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request, $imap_check)
|
||||
public function store($request, $service_request = [], $id = '')
|
||||
{
|
||||
$email = new Emails();
|
||||
try {
|
||||
// saving all the fields to the database
|
||||
// if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save() == true) {
|
||||
$email->email_address = $request->email_address;
|
||||
$email->email_name = $request->email_name;
|
||||
$email->fetching_host = $request->fetching_host;
|
||||
$email->fetching_port = $request->fetching_port;
|
||||
$email->fetching_protocol = $request->fetching_protocol;
|
||||
$email->sending_host = $request->sending_host;
|
||||
$email->sending_port = $request->sending_port;
|
||||
$email->sending_protocol = $request->sending_protocol;
|
||||
$email->sending_encryption = $request->sending_encryption;
|
||||
if ($id !== '') {
|
||||
$email = $email->find($id);
|
||||
}
|
||||
|
||||
if ($request->smtp_validate == 'on') {
|
||||
$email->smtp_validate = $request->smtp_validate;
|
||||
}
|
||||
$email->email_address = $request->email_address;
|
||||
|
||||
if ($request->input('password')) {
|
||||
$email->password = Crypt::encrypt($request->input('password'));
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$email->fetching_status = 1;
|
||||
} else {
|
||||
$email->fetching_status = 0;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$email->sending_status = 1;
|
||||
} else {
|
||||
$email->sending_status = 0;
|
||||
}
|
||||
if ($request->input('auto_response') == 'on') {
|
||||
$email->auto_response = 1;
|
||||
} else {
|
||||
$email->auto_response = 0;
|
||||
}
|
||||
if ($imap_check !== null) {
|
||||
$email->fetching_encryption = $imap_check;
|
||||
} else {
|
||||
$email->fetching_encryption = $request->input('fetching_encryption');
|
||||
}
|
||||
// fetching department value
|
||||
$email->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$email->priority = $this->priorityValue($request->input('priority'));
|
||||
// fetching helptopic value
|
||||
$email->help_topic = $this->helpTopicValue($request->input('help_topic'));
|
||||
// inserting the encrypted value of password
|
||||
$email->email_name = $request->email_name;
|
||||
$email->fetching_host = $request->fetching_host;
|
||||
$email->fetching_port = $request->fetching_port;
|
||||
$email->fetching_protocol = $request->fetching_protocol;
|
||||
$email->sending_host = $request->sending_host;
|
||||
$email->sending_port = $request->sending_port;
|
||||
$email->sending_protocol = $this->getDriver($request->sending_protocol);
|
||||
$email->sending_encryption = $request->sending_encryption;
|
||||
|
||||
if ($request->smtp_validate == 'on') {
|
||||
$email->smtp_validate = $request->smtp_validate;
|
||||
}
|
||||
|
||||
if ($request->input('password')) {
|
||||
$email->password = Crypt::encrypt($request->input('password'));
|
||||
$email->save(); // run save
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$email->fetching_status = 1;
|
||||
} else {
|
||||
$email->fetching_status = 0;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$email->sending_status = 1;
|
||||
} else {
|
||||
$email->sending_status = 0;
|
||||
}
|
||||
if ($request->input('auto_response') == 'on') {
|
||||
$email->auto_response = 1;
|
||||
} else {
|
||||
$email->auto_response = 0;
|
||||
}
|
||||
$email->fetching_encryption = $request->input('fetching_encryption');
|
||||
if (!$request->input('imap_validate')) {
|
||||
$email->mailbox_protocol = 'novalidate-cert';
|
||||
}
|
||||
$email->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$email->priority = $this->priorityValue($request->input('priority'));
|
||||
// fetching helptopic value
|
||||
$email->help_topic = $this->helpTopicValue($request->input('help_topic'));
|
||||
// inserting the encrypted value of password
|
||||
$email->password = Crypt::encrypt($request->input('password'));
|
||||
$email->save(); // run save
|
||||
if ($request->input('fetching_status')) {
|
||||
$this->fetch($email);
|
||||
}
|
||||
if ($id === '') {
|
||||
// Creating a default system email as the first email is inserted to the system
|
||||
$email_settings = Email::where('id', '=', '1')->first();
|
||||
$email_settings->sys_email = $email->id;
|
||||
$email_settings->save();
|
||||
// returns success message for successful email creation
|
||||
// return redirect('emails')->with('success', 'Email Created sucessfully');
|
||||
return 1;
|
||||
// } else {
|
||||
// returns fail message for unsuccessful save execution
|
||||
// return redirect('emails')->with('fails', 'Email can not Create');
|
||||
// return 0;
|
||||
// }
|
||||
} catch (Exception $e) {
|
||||
// returns if try fails
|
||||
// return redirect()->back()->with('fails', $e->getMessage());
|
||||
return 0;
|
||||
} else {
|
||||
$this->update($id, $request);
|
||||
}
|
||||
if (count($service_request) > 0) {
|
||||
$this->saveMailService($email->id, $service_request, $this->getDriver($request->sending_protocol));
|
||||
}
|
||||
if ($request->input('fetching_status')) {
|
||||
$this->fetch($email);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function sendDiagnoEmail($request)
|
||||
{
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$name = $request->input('email_name');
|
||||
$host = $request->input('sending_host');
|
||||
$port = $request->input('sending_port');
|
||||
$enc = $request->input('sending_encryption');
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
|
||||
|
||||
$this->emailService($driver, $service_request);
|
||||
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
|
||||
$controller = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$to = 'example@ladybirdweb.com';
|
||||
$toname = 'test';
|
||||
$subject = 'test';
|
||||
$data = 'test';
|
||||
//dd(\Config::get('mail'),\Config::get('services'));
|
||||
$send = $controller->laravelMail($to, $toname, $subject, $data, [], []);
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
|
||||
{
|
||||
$configs = [
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $name],
|
||||
'password' => $password,
|
||||
'encryption' => $enc,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $driver,
|
||||
];
|
||||
foreach ($configs as $key => $config) {
|
||||
if (is_array($config)) {
|
||||
foreach ($config as $from) {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
} else {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDriver($driver_id)
|
||||
{
|
||||
$short = '';
|
||||
$email_drivers = new \App\Model\MailJob\MailService();
|
||||
$email_driver = $email_drivers->find($driver_id);
|
||||
if ($email_driver) {
|
||||
$short = $email_driver->short_name;
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,8 +325,12 @@ class EmailsController extends Controller
|
||||
$priority = $ticket_priority->get();
|
||||
// get all the mailbox protocols
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
|
||||
$service = new \App\Model\MailJob\MailService();
|
||||
$services = $service->lists('name', 'id')->toArray();
|
||||
|
||||
// return if the execution is succeeded
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails', 'sys_email'))->with('count', $count);
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails', 'sys_email', 'services'))->with('count', $count);
|
||||
} catch (Exception $e) {
|
||||
// return if try fails
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -292,78 +344,20 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettingsUpdate($id, Request $request)
|
||||
public function validatingEmailSettingsUpdate($id, MailRequest $request)
|
||||
{
|
||||
$validator = \Validator::make(
|
||||
[
|
||||
'email_address' => $request->input('email_address'),
|
||||
'email_name' => $request->input('email_name'),
|
||||
'password' => $request->input('password'),
|
||||
], [
|
||||
'email_address' => 'email',
|
||||
'email_name' => 'required',
|
||||
'password' => 'required',
|
||||
]
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
$jsons = $validator->messages();
|
||||
$val = '';
|
||||
foreach ($jsons->all() as $key => $value) {
|
||||
$val .= $value;
|
||||
try {
|
||||
return $this->validatingEmailSettings($request, $id);
|
||||
} catch (Exception $ex) {
|
||||
$message = $ex->getMessage();
|
||||
if (imap_last_error()) {
|
||||
$message = imap_last_error();
|
||||
}
|
||||
$return_data = rtrim(str_replace('.', ',', $val), ',');
|
||||
|
||||
return $return_data;
|
||||
//dd($ex->getMessage());
|
||||
loging('mail-config', $message);
|
||||
//Log::error($ex->getMessage());
|
||||
return $this->jsonResponse('fails', $message);
|
||||
}
|
||||
// return $request;
|
||||
if ($request->input('imap_validate') == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} elseif (!$request->input('imap_validate')) {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check[0] == 0) {
|
||||
return Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
|
||||
}
|
||||
$need_to_check_imap = 1;
|
||||
} else {
|
||||
$imap_check = 0;
|
||||
$need_to_check_imap = 0;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$smtp_check = $this->getSmtp($request);
|
||||
if ($smtp_check == 0) {
|
||||
return Lang::get('lang.outgoing_email_connection_failed');
|
||||
}
|
||||
$need_to_check_smtp = 1;
|
||||
} else {
|
||||
$smtp_check = 0;
|
||||
$need_to_check_smtp = 0;
|
||||
}
|
||||
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check != 0 && $smtp_check != 0) {
|
||||
$this->update($id, $request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 1 && $need_to_check_smtp == 0) {
|
||||
if ($imap_check != 0 && $smtp_check == 0) {
|
||||
$this->update($id, $request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check == 0 && $smtp_check != 0) {
|
||||
$this->update($id, $request, null);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 0) {
|
||||
if ($imap_check == 0 && $smtp_check == 0) {
|
||||
$this->update($id, $request, null);
|
||||
$return = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,70 +369,20 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, $request, $imap_check)
|
||||
public function update($id, $request)
|
||||
{
|
||||
try {
|
||||
// fetch the selected emails
|
||||
$emails = Emails::whereId($id)->first();
|
||||
// insert all the requested parameters with except
|
||||
$emails->email_address = $request->email_address;
|
||||
$emails->email_name = $request->email_name;
|
||||
$emails->fetching_host = $request->fetching_host;
|
||||
$emails->fetching_port = $request->fetching_port;
|
||||
$emails->fetching_protocol = $request->fetching_protocol;
|
||||
$emails->sending_host = $request->sending_host;
|
||||
$emails->sending_port = $request->sending_port;
|
||||
$emails->sending_protocol = $request->sending_protocol;
|
||||
$emails->sending_encryption = $request->sending_encryption;
|
||||
if ($request->smtp_validate == 'on') {
|
||||
$emails->smtp_validate = $request->smtp_validate;
|
||||
}
|
||||
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$emails->fetching_status = 1;
|
||||
} else {
|
||||
$emails->fetching_status = 0;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$emails->sending_status = 1;
|
||||
} else {
|
||||
$emails->sending_status = 0;
|
||||
}
|
||||
if ($request->input('auto_response') == 'on') {
|
||||
$emails->auto_response = 1;
|
||||
} else {
|
||||
$emails->auto_response = 0;
|
||||
}
|
||||
if ($imap_check !== null) {
|
||||
$emails->fetching_encryption = $imap_check;
|
||||
} else {
|
||||
$emails->fetching_encryption = $request->fetching_encryption;
|
||||
}
|
||||
$emails->password = Crypt::encrypt($request->input('password'));
|
||||
// dd($email->fetching_encryption);
|
||||
// fetching department value
|
||||
$emails->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$emails->priority = $this->priorityValue($request->input('priority'));
|
||||
// fetching helptopic value
|
||||
$emails->help_topic = $this->helpTopicValue($request->input('help_topic'));
|
||||
// inserting the encrypted value of password
|
||||
// $emails->password = Crypt::encrypt($request->input('password'));
|
||||
$emails->save();
|
||||
//dd($request->sys_email);
|
||||
if ($request->sys_email == 'on') {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => $id]);
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => $id]);
|
||||
} elseif ($request->input('count') <= 1 && $request->sys_email == null) {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => null]);
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => null]);
|
||||
}
|
||||
// returns success message for successful email update
|
||||
$return = 1;
|
||||
} catch (Exception $e) {
|
||||
// // returns if try fails
|
||||
$return = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -467,11 +411,9 @@ class EmailsController extends Controller
|
||||
// fetching the database instance of the current email
|
||||
$emails = $email->whereId($id)->first();
|
||||
// checking if deleting the email is success or if it's carrying any dependencies
|
||||
if ($emails->delete() == true) {
|
||||
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
|
||||
} else {
|
||||
return redirect('emails')->with('fails', Lang::get('lang.email_can_not_delete'));
|
||||
}
|
||||
$emails->delete();
|
||||
|
||||
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
// returns if the try fails
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -485,40 +427,30 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request, $validate)
|
||||
public function getImapStream($request)
|
||||
{
|
||||
$fetching_status = $request->input('fetching_status');
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$service = $request->input('fetching_protocol');
|
||||
$encryption = $request->input('fetching_encryption');
|
||||
$validate = $request->input('imap_validate');
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$protocol_id = $request->input('mailbox_protocol');
|
||||
$fetching_protocol = '/'.$request->input('fetching_protocol');
|
||||
$fetching_encryption = '/'.$request->input('fetching_encryption');
|
||||
if ($fetching_encryption == '/none') {
|
||||
$fetching_encryption2 = '/novalidate-cert';
|
||||
$mailbox_protocol = $fetching_encryption2;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$fetching_protocol.$mailbox_protocol.'}INBOX';
|
||||
} else {
|
||||
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX';
|
||||
$mailbox_protocol = $fetching_encryption.$validate;
|
||||
$server = new Fetch($host, $port, $service);
|
||||
//$server->setFlag('novalidate-cert');
|
||||
if ($encryption != '') {
|
||||
$server->setFlag($encryption);
|
||||
}
|
||||
try {
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
} catch (\Exception $ex) {
|
||||
return $ex->getMessage();
|
||||
}
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
if ($imap_stream) {
|
||||
$return = [0 => 1, 1 => $mailbox_protocol];
|
||||
if (!$validate) {
|
||||
$server->setFlag('novalidate-cert');
|
||||
} else {
|
||||
$return = [0 => 0];
|
||||
$server->setFlag('validate-cert');
|
||||
}
|
||||
|
||||
return $return;
|
||||
$server->setAuthentication($username, $password);
|
||||
$server->getImapStream();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -643,4 +575,69 @@ class EmailsController extends Controller
|
||||
|
||||
return $email_help_topic;
|
||||
}
|
||||
|
||||
public function emailService($service, $value = [])
|
||||
{
|
||||
switch ($service) {
|
||||
case 'mailgun':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'mandrill':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'ses':
|
||||
$this->setServiceConfig($service, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setServiceConfig($service, $value)
|
||||
{
|
||||
//dd($service);
|
||||
if (count($value) > 0) {
|
||||
foreach ($value as $k => $v) {
|
||||
\Config::set("services.$service.$k", $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function saveMailService($emailid, $request, $driver)
|
||||
{
|
||||
$mail_service = new \App\Model\MailJob\FaveoMail();
|
||||
$mails = $mail_service->where('email_id', $emailid)->get();
|
||||
if (count($request) > 0) {
|
||||
foreach ($mails as $mail) {
|
||||
$mail->delete();
|
||||
}
|
||||
foreach ($request as $key => $value) {
|
||||
$mail_service->create([
|
||||
'drive' => $driver,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'email_id' => $emailid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function readMails()
|
||||
{
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
|
||||
$TicketWorkflowController = new \App\Http\Controllers\Agent\helpdesk\TicketWorkflowController($TicketController);
|
||||
$controller = new \App\Http\Controllers\Agent\helpdesk\MailController($TicketWorkflowController);
|
||||
$emails = new Emails();
|
||||
$settings_email = new Email();
|
||||
$system = new \App\Model\helpdesk\Settings\System();
|
||||
$ticket = new \App\Model\helpdesk\Settings\Ticket();
|
||||
$controller->readmails($emails, $settings_email, $system, $ticket);
|
||||
}
|
||||
|
||||
public function fetch($email)
|
||||
{
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
|
||||
$TicketWorkflowController = new \App\Http\Controllers\Agent\helpdesk\TicketWorkflowController($TicketController);
|
||||
$controller = new \App\Http\Controllers\Agent\helpdesk\MailController($TicketWorkflowController);
|
||||
$controller->fetch($email);
|
||||
}
|
||||
}
|
||||
|
637
app/Http/Controllers/Admin/helpdesk/EmailsControllerOld.php
Normal file
637
app/Http/Controllers/Admin/helpdesk/EmailsControllerOld.php
Normal file
@@ -0,0 +1,637 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\Http\Requests\helpdesk\EmailsEditRequest;
|
||||
use App\Http\Requests\helpdesk\EmailsRequest;
|
||||
use App\Http\Requests\helpdesk\Mail\MailRequest;
|
||||
// model
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Utility\MailboxProtocol;
|
||||
// classes
|
||||
use Crypt;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
* EmailsController.
|
||||
* ======================================
|
||||
* This Controller is used to define below mentioned set of functions applied to the Emails in the system.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class EmailsControllerOld extends Controller
|
||||
{
|
||||
/**
|
||||
* Defining constructor variables.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the Emails.
|
||||
*
|
||||
* @param type Emails $emails
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index(Emails $email)
|
||||
{
|
||||
try {
|
||||
// fetch all the emails from emails table
|
||||
$emails = $email->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param type Department $department
|
||||
* @param type Help_topic $help
|
||||
* @param type Priority $priority
|
||||
* @param type MailboxProtocol $mailbox_protocol
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
try {
|
||||
// fetch all the departments from the department table
|
||||
$departments = $department->get();
|
||||
// fetch all the helptopics from the helptopic table
|
||||
$helps = $help->get();
|
||||
// fetch all the types of priority from the ticket_priority table
|
||||
$priority = $ticket_priority->get();
|
||||
// fetch all the types of mailbox protocols from the mailbox_protocols table
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
|
||||
$service = new \App\Model\MailJob\MailService();
|
||||
$services = $service->lists('name', 'id')->toArray();
|
||||
|
||||
// return with all the table data
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'services'));
|
||||
} catch (Exception $e) {
|
||||
// return error messages if any
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for email input validation.
|
||||
*
|
||||
* @param EmailsRequest $request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettings(MailRequest $request, $id = '')
|
||||
{
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
|
||||
$service = $request->input('sending_protocol');
|
||||
$send = 0;
|
||||
$imap_check[0] = 0;
|
||||
if ($request->input('imap_validate') == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} elseif (!$request->input('imap_validate')) {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
try {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
} catch (Exception $ex) {
|
||||
\Log::error($ex->getMessage());
|
||||
$result = ['fails' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
if ($imap_check[0] == 0) {
|
||||
$response = Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
|
||||
}
|
||||
} else {
|
||||
$imap_check[0] = 1;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$this->emailService($service, $service_request);
|
||||
try {
|
||||
$send = $this->sendDiagnoEmail($request);
|
||||
} catch (Exception $ex) {
|
||||
\Log::error($ex->getMessage());
|
||||
$result = ['fails' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
if ($send === 0) {
|
||||
$response = Lang::get('lang.outgoing_email_connection_failed');
|
||||
}
|
||||
} else {
|
||||
$send = 1;
|
||||
}
|
||||
if ($send === 1 && $imap_check[0] === 1) {
|
||||
$this->store($request, $imap_check, $service_request, $id);
|
||||
}
|
||||
|
||||
return $this->jsonResponse($send, $imap_check);
|
||||
}
|
||||
|
||||
public function sendDiagnoEmail($request)
|
||||
{
|
||||
try {
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$name = $request->input('email_name');
|
||||
$host = $request->input('sending_host');
|
||||
$port = $request->input('sending_port');
|
||||
$enc = $request->input('sending_encryption');
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
|
||||
|
||||
$this->emailService($driver, $service_request);
|
||||
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
|
||||
$controller = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$to = 'example@ladybirdweb.com';
|
||||
$toname = 'test';
|
||||
$subject = 'test';
|
||||
$data = 'test';
|
||||
//dd(\Config::get('mail'),\Config::get('services'));
|
||||
$send = $controller->laravelMail($to, $toname, $subject, $data, [], []);
|
||||
} catch (Exception $e) {
|
||||
\Log::error($e->getMessage());
|
||||
//dd($e);
|
||||
}
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
|
||||
{
|
||||
$configs = [
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $name],
|
||||
'password' => $password,
|
||||
'encryption' => $enc,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $driver,
|
||||
];
|
||||
foreach ($configs as $key => $config) {
|
||||
if (is_array($config)) {
|
||||
foreach ($config as $from) {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
} else {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDriver($driver_id)
|
||||
{
|
||||
$short = '';
|
||||
$email_drivers = new \App\Model\MailJob\MailService();
|
||||
$email_driver = $email_drivers->find($driver_id);
|
||||
if ($email_driver) {
|
||||
$short = $email_driver->short_name;
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param type Emails $email
|
||||
* @param type EmailsRequest $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request, $imap_check, $service_request = [], $id = '')
|
||||
{
|
||||
$email = new Emails();
|
||||
if ($id !== '') {
|
||||
$email = $email->find($id);
|
||||
}
|
||||
try {
|
||||
$email->email_address = $request->email_address;
|
||||
|
||||
$email->email_name = $request->email_name;
|
||||
$email->fetching_host = $request->fetching_host;
|
||||
$email->fetching_port = $request->fetching_port;
|
||||
$email->fetching_protocol = $request->fetching_protocol;
|
||||
$email->sending_host = $request->sending_host;
|
||||
$email->sending_port = $request->sending_port;
|
||||
$email->sending_protocol = $this->getDriver($request->sending_protocol);
|
||||
$email->sending_encryption = $request->sending_encryption;
|
||||
|
||||
if ($request->smtp_validate == 'on') {
|
||||
$email->smtp_validate = $request->smtp_validate;
|
||||
}
|
||||
|
||||
if ($request->input('password')) {
|
||||
$email->password = Crypt::encrypt($request->input('password'));
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$email->fetching_status = 1;
|
||||
} else {
|
||||
$email->fetching_status = 0;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$email->sending_status = 1;
|
||||
} else {
|
||||
$email->sending_status = 0;
|
||||
}
|
||||
if ($request->input('auto_response') == 'on') {
|
||||
$email->auto_response = 1;
|
||||
} else {
|
||||
$email->auto_response = 0;
|
||||
}
|
||||
//dd($email);
|
||||
if ($imap_check !== null) {
|
||||
$email->fetching_encryption = $imap_check[0];
|
||||
} else {
|
||||
$email->fetching_encryption = $request->input('fetching_encryption');
|
||||
}
|
||||
|
||||
// fetching department value
|
||||
$email->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$email->priority = $this->priorityValue($request->input('priority'));
|
||||
// fetching helptopic value
|
||||
$email->help_topic = $this->helpTopicValue($request->input('help_topic'));
|
||||
// inserting the encrypted value of password
|
||||
$email->password = Crypt::encrypt($request->input('password'));
|
||||
$email->save(); // run save
|
||||
if ($id === '') {
|
||||
// Creating a default system email as the first email is inserted to the system
|
||||
$email_settings = Email::where('id', '=', '1')->first();
|
||||
$email_settings->sys_email = $email->id;
|
||||
$email_settings->save();
|
||||
} else {
|
||||
$this->update($id, $request);
|
||||
}
|
||||
if (count($service_request) > 0) {
|
||||
$this->saveMailService($email->id, $service_request, $this->getDriver($request->sending_protocol));
|
||||
}
|
||||
|
||||
return 1;
|
||||
} catch (Exception $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Department $department
|
||||
* @param type Help_topic $help
|
||||
* @param type Emails $email
|
||||
* @param type Priority $priority
|
||||
* @param type MailboxProtocol $mailbox_protocol
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
try {
|
||||
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
|
||||
// dd($sys_email);
|
||||
// fetch the selected emails
|
||||
$emails = $email->whereId($id)->first();
|
||||
// get all the departments
|
||||
$departments = $department->get();
|
||||
//get count of emails
|
||||
$count = $email->count();
|
||||
// get all the helptopic
|
||||
$helps = $help->get();
|
||||
// get all the priority
|
||||
$priority = $ticket_priority->get();
|
||||
// get all the mailbox protocols
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
|
||||
$service = new \App\Model\MailJob\MailService();
|
||||
$services = $service->lists('name', 'id')->toArray();
|
||||
|
||||
// return if the execution is succeeded
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails', 'sys_email', 'services'))->with('count', $count);
|
||||
} catch (Exception $e) {
|
||||
// return if try fails
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for email input validation.
|
||||
*
|
||||
* @param EmailsRequest $request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettingsUpdate($id, MailRequest $request)
|
||||
{
|
||||
return $this->validatingEmailSettings($request, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Emails $email
|
||||
* @param type EmailsEditRequest $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, $request)
|
||||
{
|
||||
try {
|
||||
if ($request->sys_email == 'on') {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => $id]);
|
||||
} elseif ($request->input('count') <= 1 && $request->sys_email == null) {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => null]);
|
||||
}
|
||||
$return = 1;
|
||||
} catch (Exception $e) {
|
||||
$return = $e->getMessage();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Emails $email
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Emails $email)
|
||||
{
|
||||
// fetching the details on the basis of the $id passed to the function
|
||||
$default_system_email = Email::where('id', '=', '1')->first();
|
||||
if ($default_system_email->sys_email) {
|
||||
// checking if the default system email is the passed email
|
||||
if ($id == $default_system_email->sys_email) {
|
||||
return redirect('emails')->with('fails', Lang::get('lang.you_cannot_delete_system_default_email'));
|
||||
}
|
||||
}
|
||||
try {
|
||||
// fetching the database instance of the current email
|
||||
$emails = $email->whereId($id)->first();
|
||||
// checking if deleting the email is success or if it's carrying any dependencies
|
||||
if ($emails->delete() == true) {
|
||||
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
|
||||
} else {
|
||||
return redirect('emails')->with('fails', Lang::get('lang.email_can_not_delete'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// returns if the try fails
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create imap connection.
|
||||
*
|
||||
* @param type $request
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request, $validate)
|
||||
{
|
||||
$fetching_status = $request->input('fetching_status');
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$protocol_id = $request->input('mailbox_protocol');
|
||||
$fetching_protocol = '/'.$request->input('fetching_protocol');
|
||||
$fetching_encryption = '/'.$request->input('fetching_encryption');
|
||||
if ($fetching_encryption == '/none') {
|
||||
$fetching_encryption2 = '/novalidate-cert';
|
||||
$mailbox_protocol = $fetching_encryption2;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$fetching_protocol.$mailbox_protocol.'}INBOX';
|
||||
} else {
|
||||
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX';
|
||||
$mailbox_protocol = $fetching_encryption.$validate;
|
||||
}
|
||||
try {
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
} catch (\Exception $ex) {
|
||||
\Log::error($ex->getMessage());
|
||||
|
||||
return $ex->getMessage();
|
||||
}
|
||||
//$imap_stream = imap_open($mailbox, $username, $password);
|
||||
if ($imap_stream) {
|
||||
$return = [0 => 1, 1 => $mailbox_protocol];
|
||||
} else {
|
||||
$return = [0 => 0];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check connection.
|
||||
*
|
||||
* @param type $imap_stream
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function checkImapStream($imap_stream)
|
||||
{
|
||||
$check_imap_stream = imap_check($imap_stream);
|
||||
if ($check_imap_stream) {
|
||||
$imap_stream = 1;
|
||||
} else {
|
||||
$imap_stream = 0;
|
||||
}
|
||||
|
||||
return $imap_stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get smtp connection.
|
||||
*
|
||||
* @param type $request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSmtp($request)
|
||||
{
|
||||
$sending_status = $request->input('sending_status');
|
||||
// cheking for the sending protocol
|
||||
if ($request->input('sending_protocol') == 'smtp') {
|
||||
$mail = new \PHPMailer();
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $request->input('sending_host'); // Specify main and backup SMTP servers
|
||||
//$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $request->input('email_address'); // SMTP username
|
||||
$mail->Password = $request->input('password'); // SMTP password
|
||||
$mail->SMTPSecure = $request->input('sending_encryption'); // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $request->input('sending_port'); // TCP port to connect to
|
||||
if (!$request->input('smtp_validate')) {
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->SMTPOptions = [
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
];
|
||||
if ($mail->smtpConnect($mail->SMTPOptions) == true) {
|
||||
$mail->smtpClose();
|
||||
$return = 1;
|
||||
} else {
|
||||
$return = 0;
|
||||
}
|
||||
} else {
|
||||
if ($mail->smtpConnect()) {
|
||||
$mail->smtpClose();
|
||||
$return = 1;
|
||||
} else {
|
||||
$return = 0;
|
||||
}
|
||||
}
|
||||
} elseif ($request->input('sending_protocol') == 'mail') {
|
||||
$return = 1;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if department value is null.
|
||||
*
|
||||
* @param type $dept
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function departmentValue($dept)
|
||||
{
|
||||
if ($dept) {
|
||||
$email_department = $dept;
|
||||
} else {
|
||||
$email_department = null;
|
||||
}
|
||||
|
||||
return $email_department;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if priority value is null.
|
||||
*
|
||||
* @param type $priority
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function priorityValue($priority)
|
||||
{
|
||||
if ($priority) {
|
||||
$email_priority = $priority;
|
||||
} else {
|
||||
$email_priority = null;
|
||||
}
|
||||
|
||||
return $email_priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if helptopic value is null.
|
||||
*
|
||||
* @param type $help_topic
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function helpTopicValue($help_topic)
|
||||
{
|
||||
if ($help_topic) {
|
||||
$email_help_topic = $help_topic;
|
||||
} else {
|
||||
$email_help_topic = null;
|
||||
}
|
||||
|
||||
return $email_help_topic;
|
||||
}
|
||||
|
||||
public function emailService($service, $value = [])
|
||||
{
|
||||
switch ($service) {
|
||||
case 'mailgun':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'mandrill':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'ses':
|
||||
$this->setServiceConfig($service, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setServiceConfig($service, $value)
|
||||
{
|
||||
//dd($service);
|
||||
if (count($value) > 0) {
|
||||
foreach ($value as $k => $v) {
|
||||
\Config::set("services.$service.$k", $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonResponse($out, $in)
|
||||
{
|
||||
if ($out !== 1) {
|
||||
$result = ['fails' => Lang::get('lang.outgoing_email_connection_failed')];
|
||||
}
|
||||
if ($in[0] !== 1) {
|
||||
$result = ['fails' => Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings')];
|
||||
}
|
||||
if ($out === 1 && $in[0] === 1) {
|
||||
$result = ['success' => Lang::get('lang.success')];
|
||||
}
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
public function saveMailService($emailid, $request, $driver)
|
||||
{
|
||||
$mail_service = new \App\Model\MailJob\FaveoMail();
|
||||
$mails = $mail_service->where('email_id', $emailid)->get();
|
||||
if (count($request) > 0) {
|
||||
foreach ($mails as $mail) {
|
||||
$mail->delete();
|
||||
}
|
||||
foreach ($request as $key => $value) {
|
||||
$mail_service->create([
|
||||
'drive' => $driver,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'email_id' => $emailid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,8 +9,10 @@ use App\Model\helpdesk\Form\Fields;
|
||||
use App\Model\helpdesk\Form\Forms;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
// Request
|
||||
use Illuminate\Http\Request;
|
||||
use Exception;
|
||||
// Class
|
||||
use Form;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
@@ -30,7 +32,20 @@ class FormController extends Controller
|
||||
{
|
||||
$this->fields = $fields;
|
||||
$this->forms = $forms;
|
||||
$this->middleware('auth');
|
||||
$this->middleware('auth', [
|
||||
'except' => [
|
||||
'renderForm',
|
||||
'getType',
|
||||
'getAttribute',
|
||||
'getForm',
|
||||
'createValues',
|
||||
'addChild',
|
||||
'renderChild',
|
||||
'jqueryScript',
|
||||
'jqueryCheckboxScript',
|
||||
'jquerySelectScript',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +83,7 @@ class FormController extends Controller
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.form.form');
|
||||
} catch (Exception $ex) {
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -83,9 +98,17 @@ class FormController extends Controller
|
||||
public function show($id)
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('id'));
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($id);
|
||||
//dd($form);
|
||||
if ($form) {
|
||||
$fields = $form->fields();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('form', 'fields'));
|
||||
}
|
||||
throw new Exception("Sorry we can't find your request");
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,38 +117,41 @@ class FormController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Forms $forms)
|
||||
public function store(Request $request)
|
||||
{
|
||||
if (!Input::get('formname')) {
|
||||
return Redirect::back()->with('fails', Lang::get('lang.please_fill_form_name'));
|
||||
}
|
||||
$required = Input::get('required');
|
||||
$count = count($required);
|
||||
$require = [];
|
||||
for ($i = 2; $i < $count + 2; $i++) {
|
||||
for ($j = 0; $j < 1; $j++) {
|
||||
array_push($require, $required[$i][$j]);
|
||||
}
|
||||
}
|
||||
$forms->formname = Input::get('formname');
|
||||
$forms->save();
|
||||
$count = count(Input::get('name'));
|
||||
$fields = [];
|
||||
for ($i = 0; $i <= $count; $i++) {
|
||||
if (!empty(Input::get('name')[$i])) {
|
||||
array_push($fields, [
|
||||
'forms_id' => $forms->id,
|
||||
'label' => Input::get('label')[$i],
|
||||
'name' => Input::get('name')[$i],
|
||||
'type' => Input::get('type')[$i],
|
||||
'value' => Input::get('value')[$i],
|
||||
'required' => $require[$i],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Fields::insert($fields);
|
||||
$this->validate($request, [
|
||||
'formname' => 'required|unique:custom_forms,formname',
|
||||
'label.*' => 'required',
|
||||
'name.*' => 'required',
|
||||
'type.*' => 'required',
|
||||
]);
|
||||
try {
|
||||
$forms = new Forms();
|
||||
$require = Input::get('required');
|
||||
|
||||
return Redirect::back()->with('success', Lang::get('lang.successfully_created_form'));
|
||||
$forms->formname = Input::get('formname');
|
||||
$forms->save();
|
||||
$count = count(Input::get('name'));
|
||||
$fields = [];
|
||||
for ($i = 0; $i <= $count; $i++) {
|
||||
if (!empty(Input::get('name')[$i])) {
|
||||
$name = str_slug(Input::get('name')[$i], '_');
|
||||
$field = Fields::create([
|
||||
'forms_id' => $forms->id,
|
||||
'label' => Input::get('label')[$i],
|
||||
'name' => $name,
|
||||
'type' => Input::get('type')[$i],
|
||||
'required' => $require[$i],
|
||||
]);
|
||||
$field_id = $field->id;
|
||||
$this->createValues($field_id, Input::get('value')[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect::back()->with('success', Lang::get('lang.successfully_created_form'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,4 +180,441 @@ class FormController extends Controller
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.form_deleted_successfully'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
try {
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($id);
|
||||
$select_forms = $forms->where('id', '!=', $id)->lists('formname', 'id')->toArray();
|
||||
//dd($form);
|
||||
if ($form) {
|
||||
$fields = $form->fields();
|
||||
//dd($fields);
|
||||
return view('themes.default1.admin.helpdesk.manage.form.edit', compact('form', 'fields', 'select_forms'));
|
||||
}
|
||||
throw new Exception("Sorry we can't find your request");
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function addChildForm($id)
|
||||
{
|
||||
try {
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($id);
|
||||
$select_forms = $forms->where('id', '!=', $id)->lists('formname', 'id')->toArray();
|
||||
//dd($form);
|
||||
if ($form) {
|
||||
$fields = $form->fields();
|
||||
//dd($fields);
|
||||
return view('themes.default1.admin.helpdesk.manage.form.add-child', compact('form', 'fields', 'select_forms'));
|
||||
}
|
||||
throw new Exception("Sorry we can't find your request");
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'formname' => 'required|unique:custom_forms,formname,'.$id,
|
||||
'label.*' => 'required',
|
||||
'name.*' => 'required',
|
||||
'type.*' => 'required',
|
||||
]);
|
||||
try {
|
||||
if (!$request->input('formname')) {
|
||||
throw new Exception(Lang::get('lang.please_fill_form_name'));
|
||||
}
|
||||
$form = new Forms();
|
||||
$forms = $form->find($id);
|
||||
if (!$forms) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
}
|
||||
$forms->formname = Input::get('formname');
|
||||
$forms->save();
|
||||
$count = count(Input::get('name'));
|
||||
$field = new Fields();
|
||||
$fields = $field->where('forms_id', $forms->id)->get();
|
||||
if ($fields->count($fields) > 0) {
|
||||
foreach ($fields as $fi) {
|
||||
$fi->delete();
|
||||
}
|
||||
}
|
||||
//dd(Input::get('label'),Input::get('name'),Input::get('type'),Input::get('required'));
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$name = str_slug(Input::get('name')[$i], '_');
|
||||
$field = $field->create([
|
||||
'forms_id' => $forms->id,
|
||||
'label' => Input::get('label')[$i],
|
||||
'name' => $name,
|
||||
'type' => Input::get('type')[$i],
|
||||
'required' => Input::get('required')[$i],
|
||||
]);
|
||||
$field_id = $field->id;
|
||||
$this->createValues($field_id, Input::get('value')[$i]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'updated');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function renderForm($formid)
|
||||
{
|
||||
$html = '';
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($formid);
|
||||
if ($form) {
|
||||
$fields = $form->fields();
|
||||
foreach ($fields as $field) {
|
||||
$html .= self::getForm($field);
|
||||
}
|
||||
}
|
||||
|
||||
return self::requiredStyle().$html;
|
||||
}
|
||||
|
||||
public static function getType($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'select':
|
||||
return 'select';
|
||||
case 'text':
|
||||
return 'text';
|
||||
case 'email':
|
||||
return 'email';
|
||||
case 'textarea':
|
||||
return 'textarea';
|
||||
case 'select':
|
||||
return 'select';
|
||||
case 'radio':
|
||||
return 'radio';
|
||||
case 'checkbox':
|
||||
return 'checkbox';
|
||||
case 'hidden':
|
||||
return 'hidden';
|
||||
case 'password':
|
||||
return 'password';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getAttribute($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'select':
|
||||
return "null,['class'=>'form-control']";
|
||||
case 'text':
|
||||
return "['class'=>'form-control']";
|
||||
case 'email':
|
||||
return "['class'=>'form-control']";
|
||||
case 'textarea':
|
||||
return "['class'=>'form-control']";
|
||||
case 'radio':
|
||||
return '';
|
||||
case 'checkbox':
|
||||
return '';
|
||||
case 'hidden':
|
||||
return '';
|
||||
case 'password':
|
||||
return "['class'=>'form-control']";
|
||||
}
|
||||
}
|
||||
|
||||
public static function getForm($field)
|
||||
{
|
||||
$required = false;
|
||||
$required_class = self::requiredClass($field->required);
|
||||
if ($field->required === '1') {
|
||||
$required = true;
|
||||
}
|
||||
$type = $field->type;
|
||||
$field_type = self::getType($type);
|
||||
switch ($field_type) {
|
||||
case 'select':
|
||||
return self::selectForm($field_type, $field, $required, $required_class);
|
||||
case 'text':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case 'email':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case 'password':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
Form::$field_type($field->name, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
|
||||
case 'textarea':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case 'radio':
|
||||
return self::radioForm($field_type, $field, $required, $required_class);
|
||||
|
||||
case 'checkbox':
|
||||
return self::checkboxForm($field_type, $field, $required, $required_class);
|
||||
case 'hidden':
|
||||
return Form::$field_type($field->name, null, ['id' => $field->id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function createValues($fieldid, $values, $childid = null, $key = '')
|
||||
{
|
||||
if ($values) {
|
||||
$values_array = explode(',', $values);
|
||||
$field_values = new \App\Model\helpdesk\Form\FieldValue();
|
||||
$field_value = $field_values->where('field_id', $fieldid)->get();
|
||||
if ($field_value->count() > 0) {
|
||||
foreach ($field_value as $fv) {
|
||||
$fv->delete();
|
||||
}
|
||||
}
|
||||
if (count($values_array) > 0) {
|
||||
foreach ($values_array as $value) {
|
||||
$field_values->create([
|
||||
'field_id' => $fieldid,
|
||||
'child_id' => $childid,
|
||||
'field_key' => $key,
|
||||
'field_value' => str_slug($value, '_'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addChild($fieldid, Request $request)
|
||||
{
|
||||
$ids = $request->except('_token');
|
||||
try {
|
||||
foreach ($ids as $valueid => $formid) {
|
||||
$field_value = new \App\Model\helpdesk\Form\FieldValue();
|
||||
$field_values = $field_value->where('field_id', $fieldid);
|
||||
$values = $field_values->where('id', $valueid)->first();
|
||||
if ($values) {
|
||||
//if ($formid) {
|
||||
$values->child_id = $formid;
|
||||
$values->save();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Updated');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function renderChild(Request $request)
|
||||
{
|
||||
self::setSession();
|
||||
$render = '';
|
||||
$value = $request->input('valueid');
|
||||
$fieldid = $request->input('fieldid');
|
||||
$field_values = new \App\Model\helpdesk\Form\FieldValue();
|
||||
$field_value = $field_values->where('field_id', $fieldid)->where('field_value', $value)->first();
|
||||
$child = '';
|
||||
if ($field_value) {
|
||||
$child = $field_value->child_id;
|
||||
}
|
||||
if ($child !== '') {
|
||||
$render = $this->renderForm($child);
|
||||
}
|
||||
|
||||
return $render;
|
||||
}
|
||||
|
||||
public static function jqueryScript($value, $fieldid, $fieldname, $type = '', $index = '')
|
||||
{
|
||||
if ($type == 'select') {
|
||||
return self::jquerySelectScript($fieldid);
|
||||
}
|
||||
if ($type == 'checkbox') {
|
||||
return self::jqueryCheckboxScript($fieldid, $index);
|
||||
}
|
||||
|
||||
return '<script>
|
||||
$("#'.str_slug($value).'").on("change", function () {
|
||||
var valueid = $("#'.str_slug($value).'").val();
|
||||
var fieldid = $("#'.$fieldid.str_slug($value).'").val();
|
||||
send'.$fieldid.str_slug($value).'(valueid,fieldid);
|
||||
});
|
||||
function send'.$fieldid.str_slug($value).'(valueid,fieldid) {
|
||||
$.ajax({
|
||||
url: "'.url('forms/render/child/').'",
|
||||
dataType: "html",
|
||||
data: {"valueid": valueid,"fieldid": fieldid},
|
||||
success: function (response) {
|
||||
$("#'.$fieldname.'").html(response);
|
||||
},
|
||||
error: function (response) {
|
||||
$("#'.$fieldname.'").html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
|
||||
public static function jqueryCheckboxScript($fieldid, $index)
|
||||
{
|
||||
$session = self::getSession();
|
||||
$fields = new Fields();
|
||||
$field = $fields->find($fieldid);
|
||||
if ($field) {
|
||||
return '<script>
|
||||
$("#'.$session.$index.'").on("change", function () {
|
||||
var valueid = $("#'.$session.$index.'").val();
|
||||
var fieldid = $("#f'.$session.$index.'").val();
|
||||
if($(this).is(":checked")) {
|
||||
send'.$session.$index.'(valueid,fieldid);
|
||||
}else{
|
||||
$("#div'.$session.'"+valueid).empty();
|
||||
}
|
||||
});
|
||||
function send'.$session.$index.'(valueid,fieldid) {
|
||||
$.ajax({
|
||||
url: "'.url('forms/render/child/').'",
|
||||
dataType: "html",
|
||||
data: {"valueid": valueid,"fieldid": fieldid},
|
||||
success: function (response) {
|
||||
|
||||
$("#div'.$session.'"+valueid).html(response);
|
||||
|
||||
},
|
||||
error: function (response) {
|
||||
$("#div'.$session.'"+valueid).html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function jquerySelectScript($fieldid)
|
||||
{
|
||||
$fields = new Fields();
|
||||
$field = $fields->find($fieldid);
|
||||
$session = self::getSession();
|
||||
if ($field) {
|
||||
return '<script>
|
||||
$(document).ready(function () {
|
||||
var valueid = $(".'.$session.$fieldid.'").val();
|
||||
var fieldid = $("#hidden'.$session.$fieldid.'").val();
|
||||
send'.$session.$fieldid.'(valueid,fieldid);
|
||||
$(".'.$session.$fieldid.'").on("change", function () {
|
||||
valueid = $(".'.$session.$fieldid.'").val();
|
||||
var fieldid = $("#hidden'.$session.$fieldid.'").val();
|
||||
send'.$session.$fieldid.'(valueid,fieldid);
|
||||
});
|
||||
function send'.$session.$fieldid.'(valueid,fieldid) {
|
||||
$.ajax({
|
||||
url: "'.url('forms/render/child/').'",
|
||||
dataType: "html",
|
||||
data: {"valueid": valueid,"fieldid": fieldid},
|
||||
success: function (response) {
|
||||
$("#'.$session.$field->name.'").html(response);
|
||||
},
|
||||
error: function (response) {
|
||||
$("#'.$session.$field->name.'").html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function selectForm($field_type, $field, $required, $required_class)
|
||||
{
|
||||
$session = self::getSession();
|
||||
$script = self::jqueryScript($field_value = '', $field->id, $field->name, $field_type);
|
||||
$form_hidden = Form::hidden('fieldid[]', $field->id, ['id' => 'hidden'.$session.$field->id]).Form::label($field->label, $field->label, ['class' => $required_class]);
|
||||
$select = Form::$field_type($field->name, ['' => 'Select', 'Selects' => $field->values()->lists('field_value', 'field_value')->toArray()], null, ['class' => "form-control $session$field->id", 'id' => $session.$field->id, 'required' => $required]).'</br>';
|
||||
$html = $script.$form_hidden.$select;
|
||||
$response_div = '<div id='.$session.$field->name.'></div>';
|
||||
|
||||
return $html.$response_div;
|
||||
}
|
||||
|
||||
public static function radioForm($field_type, $field, $required, $required_class)
|
||||
{
|
||||
$radio = '';
|
||||
$html = '';
|
||||
$values = $field->values()->lists('field_value')->toArray();
|
||||
if (count($values) > 0) {
|
||||
foreach ($values as $field_value) {
|
||||
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type);
|
||||
$radio .= '<div>'.Form::hidden('fieldid[]', $field->id, ['id' => $field->id.str_slug($field_value)]);
|
||||
$radio .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => str_slug($field_value), 'required' => $required]).$script.'<span> '.removeUnderscore($field_value).'</span></div>';
|
||||
}
|
||||
$html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$radio.'<div id='.$field->name.'></br></div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function checkboxForm($field_type, $field, $required, $required_class)
|
||||
{
|
||||
$session = self::getSession();
|
||||
$checkbox = '';
|
||||
$html = '';
|
||||
$values = $field->values()->lists('field_value')->toArray();
|
||||
if (count($values) > 0) {
|
||||
$i = 1;
|
||||
foreach ($values as $field_value) {
|
||||
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type, $i);
|
||||
$checkbox .= Form::hidden('fieldid[]', $field->id, ['id' => 'f'.$session.$i]);
|
||||
$checkbox .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => $session.$i, 'required' => $required]);
|
||||
$checkbox .= '<span> '.removeUnderscore($field_value).'</span>';
|
||||
//$checkbox .="</br>";
|
||||
$checkbox .= '<div>'.$script.'<div id=div'.$session.$field_value.'></div></div>';
|
||||
$i++;
|
||||
}
|
||||
$html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$checkbox;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function requiredStyle()
|
||||
{
|
||||
$style = "<style>
|
||||
.required:after {
|
||||
color: #e32 !important;
|
||||
content: ' * ' !important;
|
||||
display:inline !important;
|
||||
}
|
||||
</style>";
|
||||
|
||||
return $style;
|
||||
}
|
||||
|
||||
public static function requiredClass($required)
|
||||
{
|
||||
$class = '';
|
||||
if ($required === '1') {
|
||||
$class = 'required';
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function setSession()
|
||||
{
|
||||
$form = self::getSession();
|
||||
$form++;
|
||||
\Session::set('fromid', $form);
|
||||
}
|
||||
|
||||
public static function getSession()
|
||||
{
|
||||
$form = 0;
|
||||
if (\Session::has('fromid')) {
|
||||
$form = \Session::get('fromid');
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ class HelptopicController extends Controller
|
||||
$forms = $form->get();
|
||||
$agents = $agent->where('role', '=', 'agent')->get();
|
||||
$slas = $sla->get();
|
||||
$priority = $priority->get();
|
||||
$priority = Ticket_Priority::where('status', '=', 1)->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
|
||||
} catch (Exception $e) {
|
||||
@@ -148,7 +148,7 @@ class HelptopicController extends Controller
|
||||
$topics = $topic->whereId($id)->first();
|
||||
$forms = $form->get();
|
||||
$slas = $sla->get();
|
||||
$priority = $priority->get();
|
||||
$priority = Ticket_Priority::where('status', '=', 1)->get();
|
||||
$sys_help_topic = \DB::table('settings_ticket')
|
||||
->select('help_topic')
|
||||
->where('id', '=', 1)->first();
|
||||
|
@@ -8,7 +8,6 @@ use App;
|
||||
use App\Http\Controllers\Controller;
|
||||
//supports
|
||||
use App\Http\Requests;
|
||||
use Cache;
|
||||
use Config;
|
||||
//classes
|
||||
use File;
|
||||
@@ -17,6 +16,7 @@ use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Input;
|
||||
use Lang;
|
||||
use UnAuth;
|
||||
use Validator;
|
||||
|
||||
/**
|
||||
@@ -46,24 +46,12 @@ class LanguageController extends Controller
|
||||
*/
|
||||
public function switchLanguage($lang)
|
||||
{
|
||||
//if(Cache::has('language'))
|
||||
//{
|
||||
// return Cache::get('language');
|
||||
//} else return 'false';
|
||||
// Cache::put('language',$)
|
||||
$path = base_path('resources/lang'); // Path to check available language packages
|
||||
if (array_key_exists($lang, Config::get('languages')) && in_array($lang, scandir($path))) {
|
||||
// dd(array_key_exists($lang, Config::get('languages')));
|
||||
// app()->setLocale($lang);
|
||||
|
||||
Cache::forever('language', $lang);
|
||||
// dd(Cache::get('language'));
|
||||
// dd()
|
||||
$changed = UnAuth::changeLanguage($lang);
|
||||
if (!$changed) {
|
||||
return \Redirect::back()->with('fails', Lang::get('lang.language-error'));
|
||||
} else {
|
||||
return Redirect::back()->with('fails', Lang::get('lang.language-error'));
|
||||
return \Redirect::back();
|
||||
}
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
/**
|
||||
|
195
app/Http/Controllers/Admin/helpdesk/PriorityController.php
Normal file
195
app/Http/Controllers/Admin/helpdesk/PriorityController.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Common\NotificationController;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\PriorityRequest;
|
||||
// models
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Exception;
|
||||
// classes
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\support\Collection;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* TicketController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PriorityController extends Controller
|
||||
{
|
||||
public function __construct(PhpMailController $PhpMailController, NotificationController $NotificationController)
|
||||
{
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
$this->NotificationController = $NotificationController;
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function priorityIndex()
|
||||
{
|
||||
$user_status = CommonSettings::where('id', '=', 6)->first();
|
||||
// dd( $user_status);
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.ticket_priority.index', compact('user_status'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function userPriorityIndex(Request $request)
|
||||
{
|
||||
try {
|
||||
$user_status = $request->user_settings_priority;
|
||||
|
||||
CommonSettings::where('id', '=', 6)->update(['status' => $user_status]);
|
||||
|
||||
return 'Your Status Updated';
|
||||
} catch (Exception $e) {
|
||||
return Redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type
|
||||
*/
|
||||
public function priorityIndex1()
|
||||
{
|
||||
try {
|
||||
$ticket = new Ticket_Priority();
|
||||
$tickets = $ticket->select('priority_id', 'priority', 'priority_desc', 'priority_color', 'status', 'is_default', 'ispublic')->get();
|
||||
|
||||
return \Datatable::Collection($tickets)
|
||||
->showColumns('priority', 'priority_desc')
|
||||
->addColumn('priority_color', function ($model) {
|
||||
return "<button class='btn' style = 'background-color:$model->priority_color'></button>";
|
||||
})
|
||||
->addColumn('status', function ($model) {
|
||||
if ($model->status == 1) {
|
||||
return "<a style='color:green'>active</a>";
|
||||
} elseif ($model->status == 0) {
|
||||
Ticket_Priority::where('priority_id', '=', '$priority_id')
|
||||
->update(['priority_id' => '']);
|
||||
|
||||
return "<a style='color:red'>inactive</a>";
|
||||
}
|
||||
})
|
||||
->addColumn('action', function ($model) {
|
||||
if ($model->is_default > 0) {
|
||||
return '<a href='.url('ticket_priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs' disabled='disabled'>Edit</a> <a href=".url('ticket_priority/'.$model->priority_id.'/destroy')." class='btn btn-warning btn-info btn-xs' disabled='disabled' > delete </a>";
|
||||
} else {
|
||||
return '<a href='.url('ticket_priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs'>Edit</a> <a class='btn btn-danger btn-xs' onclick='confirmDelete(".$model->priority_id.")'>Delete </a>";
|
||||
}
|
||||
})
|
||||
->searchColumns('priority')
|
||||
->orderColumns('priority', 'priority_color')
|
||||
->make();
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type
|
||||
*/
|
||||
public function priorityCreate()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.manage.ticket_priority.create');
|
||||
}
|
||||
|
||||
public function priorityCreate1(PriorityRequest $request)
|
||||
{
|
||||
$tk_priority = new Ticket_Priority();
|
||||
$tk_priority->priority = $request->priority;
|
||||
$tk_priority->status = $request->status;
|
||||
$tk_priority->priority_desc = $request->priority_desc;
|
||||
$tk_priority->priority_color = $request->priority_color;
|
||||
$tk_priority->ispublic = $request->ispublic;
|
||||
$tk_priority->save();
|
||||
|
||||
return \Redirect::route('priority.index')->with('success', Lang::get('lang.priority_successfully_created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type $priority_id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function priorityEdit($priority_id)
|
||||
{
|
||||
$tk_priority = Ticket_Priority::wherepriority_id($priority_id)->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.ticket_priority.edit', compact('tk_priority'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PriorityRequest $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function priorityEdit1(PriorityRequest $request)
|
||||
{
|
||||
$priority_id = $request->priority_id;
|
||||
$tk_priority = Ticket_Priority::findOrFail($priority_id);
|
||||
$tk_priority->priority = $request->priority;
|
||||
$tk_priority->status = $request->status;
|
||||
$tk_priority->priority_desc = $request->priority_desc;
|
||||
$tk_priority->priority_color = $request->priority_color;
|
||||
$tk_priority->ispublic = $request->ispublic;
|
||||
$tk_priority->save();
|
||||
if ($request->input('default_priority') == 'on') {
|
||||
Ticket_Priority::where('is_default', '>', '0')
|
||||
->update(['is_default' => '0']);
|
||||
Ticket_Priority::where('priority_id', '=', $priority_id)
|
||||
->update(['is_default' => $priority_id]);
|
||||
}
|
||||
|
||||
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.priority_successfully_updated')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type $priority_id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function destroy($priority_id)
|
||||
{
|
||||
$default_priority = Ticket_Priority::where('is_default', '>', '0')->first();
|
||||
// dd($default_priority->is_default);
|
||||
$topic = DB::table('help_topic')->where('priority', '=', $priority_id)->update(['priority' => $default_priority->is_default]);
|
||||
// if ($topic > 0) {
|
||||
// if ($topic > 1) {
|
||||
// $text_topic = 'Emails';
|
||||
// } else {
|
||||
// $text_topic = 'Email';
|
||||
// }
|
||||
// $topic = '<li>'.Lang::get('lang.associated_help_topic_have_been_moved_to_default_sla').'</li>';
|
||||
// } else {
|
||||
// $topic = '';
|
||||
// }
|
||||
// dd('llll');
|
||||
$tk_priority = Ticket_Priority::findOrFail($priority_id);
|
||||
|
||||
$tk_priority->delete();
|
||||
|
||||
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.delete_successfully')));
|
||||
}
|
||||
}
|
@@ -7,10 +7,11 @@ use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CompanyRequest;
|
||||
use App\Http\Requests\helpdesk\EmailRequest;
|
||||
use App\Http\Requests\helpdesk\Job\TaskRequest;
|
||||
use App\Http\Requests\helpdesk\RatingUpdateRequest;
|
||||
use App\Http\Requests\helpdesk\StatusRequest;
|
||||
use App\Http\Requests\helpdesk\SystemRequest;
|
||||
// models
|
||||
use App\Http\Requests\helpdesk\SystemRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Email\Template;
|
||||
@@ -22,6 +23,7 @@ use App\Model\helpdesk\Settings\Alert;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Settings\Followup;
|
||||
use App\Model\helpdesk\Settings\Responder;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Ticket;
|
||||
@@ -31,8 +33,8 @@ use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use App\Model\helpdesk\Workflow\WorkflowClose;
|
||||
use DateTime;
|
||||
// classes
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Exception;
|
||||
use File;
|
||||
@@ -156,10 +158,17 @@ class SettingsController extends Controller
|
||||
/* Fetch the values from Timezones table */
|
||||
$timezones = $timezone->get();
|
||||
/* Fetch status value of common settings */
|
||||
$common_setting = $common_settings->select('status')->where('option_name', '=', 'user_set_ticket_status')->first();
|
||||
// /dd($common_setting);
|
||||
$common_setting = $common_settings->select('status')
|
||||
->where('option_name', '=', 'user_set_ticket_status')
|
||||
->first();
|
||||
$send_otp = $common_settings->select('status')
|
||||
->where('option_name', '=', 'send_otp')
|
||||
->first();
|
||||
$email_mandatory = $common_settings->select('status')
|
||||
->where('option_name', '=', 'email_mandatory')
|
||||
->first();
|
||||
/* Direct to System Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time', 'common_setting'));
|
||||
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time', 'common_setting', 'send_otp', 'email_mandatory'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -177,7 +186,6 @@ class SettingsController extends Controller
|
||||
public function postsystem($id, System $system, SystemRequest $request)
|
||||
{
|
||||
try {
|
||||
//dd($request->user_set_ticket_status);
|
||||
/* fetch the values of system request */
|
||||
$systems = $system->whereId('1')->first();
|
||||
/* fill the values to coompany table */
|
||||
@@ -196,6 +204,10 @@ class SettingsController extends Controller
|
||||
$usts->status = $request->user_set_ticket_status;
|
||||
$usts->save();
|
||||
}
|
||||
$sotp = CommonSettings::where('option_name', '=', 'send_otp')
|
||||
->update(['status' => $request->send_otp]);
|
||||
$email_mandatory = CommonSettings::where('option_name', '=', 'email_mandatory')
|
||||
->update(['status' => $request->email_mandatory]);
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
@@ -343,8 +355,42 @@ class SettingsController extends Controller
|
||||
$emails1 = $email1->get();
|
||||
|
||||
$workflow = $workflow->whereId('1')->first();
|
||||
$cron_path = base_path('artisan');
|
||||
$command = ":- <pre>***** php $cron_path schedule:run >> /dev/null 2>&1</pre>";
|
||||
$shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run >> /dev/null 2>&1</pre>";
|
||||
$warn = '';
|
||||
$condition = new \App\Model\MailJob\Condition();
|
||||
$job = $condition->checkActiveJob();
|
||||
$commands = [
|
||||
'' => 'Select',
|
||||
'everyMinute' => 'Every Minute',
|
||||
'everyFiveMinutes' => 'Every Five Minute',
|
||||
'everyTenMinutes' => 'Every Ten Minute',
|
||||
'everyThirtyMinutes' => 'Every Thirty Minute',
|
||||
'hourly' => 'Every Hour',
|
||||
'daily' => 'Every Day',
|
||||
'dailyAt' => 'Daily at',
|
||||
'weekly' => 'Every Week',
|
||||
'monthly' => 'Monthly',
|
||||
'yearly' => 'Yearly',
|
||||
];
|
||||
$followupcommands = [
|
||||
'' => 'Select',
|
||||
'everyMinute' => 'Every Minute',
|
||||
'everyFiveMinutes' => 'Every Five Minute',
|
||||
'everyTenMinutes' => 'Every Ten Minute',
|
||||
'everyThirtyMinutes' => 'Every Thirty Minute',
|
||||
'hourly' => 'Every Hour',
|
||||
'daily' => 'Every Day',
|
||||
'weekly' => 'Every Week',
|
||||
'monthly' => 'Monthly',
|
||||
'yearly' => 'Yearly',
|
||||
];
|
||||
if (ini_get('register_argc_argv') == '') {
|
||||
//$warn = "Please make 'register_argc_argv' flag as on. Or you can set all your job url in cron";
|
||||
}
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.crone', compact('emails', 'templates', 'emails1', 'workflow'));
|
||||
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands', 'followupcommands', 'condition', 'shared'));
|
||||
// } catch {
|
||||
// }
|
||||
}
|
||||
@@ -357,10 +403,25 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postSchedular(Email $email, Template $template, Emails $email1, Request $request, WorkflowClose $workflow)
|
||||
public function postSchedular(Email $email, Template $template, Followup $followup, Emails $email1, TaskRequest $request, WorkflowClose $workflow)
|
||||
{
|
||||
// dd($request);
|
||||
try {
|
||||
$followup = $followup->whereId('1')->first();
|
||||
$status = $request->followup_notification_cron;
|
||||
|
||||
if ($status = 'null') {
|
||||
$followup->status = $request->followup_notification_cron;
|
||||
}
|
||||
if ($status = 1) {
|
||||
$followup->status = $request->followup_notification_cron;
|
||||
$followup->condition = $request->followup_notification_commands;
|
||||
$followup->save();
|
||||
}
|
||||
if ($request->followup_notification_dailyAt) {
|
||||
$followup->condition = $request->followup_notification_dailyAt;
|
||||
$followup->save();
|
||||
}
|
||||
|
||||
/* fetch the values of email request */
|
||||
$emails = $email->whereId('1')->first();
|
||||
if ($request->email_fetching) {
|
||||
@@ -376,12 +437,13 @@ class SettingsController extends Controller
|
||||
$emails->save();
|
||||
//workflow
|
||||
$work = $workflow->whereId('1')->first();
|
||||
if ($request->condition == 'on') {
|
||||
if ($request->condition) {
|
||||
$work->condition = 1;
|
||||
} else {
|
||||
$work->condition = 0;
|
||||
}
|
||||
$work->save();
|
||||
$this->saveConditions();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success'));
|
||||
} catch (Exception $e) {
|
||||
@@ -725,7 +787,7 @@ class SettingsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* To display the list of ratings in the system.
|
||||
* To display the list of ratings in the system.
|
||||
*
|
||||
* @return type View
|
||||
*/
|
||||
@@ -759,7 +821,7 @@ class SettingsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* To store rating data.
|
||||
* To store rating data.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
@@ -822,7 +884,7 @@ class SettingsController extends Controller
|
||||
/**
|
||||
* To delete a type of rating.
|
||||
*
|
||||
* @return type Redirect
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs)
|
||||
{
|
||||
@@ -831,4 +893,171 @@ class SettingsController extends Controller
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully'));
|
||||
}
|
||||
|
||||
public function saveConditions()
|
||||
{
|
||||
if (\Input::get('fetching-commands') && \Input::get('notification-commands')) {
|
||||
$fetching_commands = \Input::get('fetching-commands');
|
||||
$fetching_dailyAt = \Input::get('fetching-dailyAt');
|
||||
$notification_commands = \Input::get('notification-commands');
|
||||
$notification_dailyAt = \Input::get('notification-dailyAt');
|
||||
$work_commands = \Input::get('work-commands');
|
||||
$workflow_dailyAt = \Input::get('workflow-dailyAt');
|
||||
$fetching_command = $this->getCommand($fetching_commands, $fetching_dailyAt);
|
||||
$notification_command = $this->getCommand($notification_commands, $notification_dailyAt);
|
||||
$work_command = $this->getCommand($work_commands, $workflow_dailyAt);
|
||||
$jobs = ['fetching' => $fetching_command, 'notification' => $notification_command, 'work' => $work_command];
|
||||
$this->storeCommand($jobs);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCommand($command, $daily_at)
|
||||
{
|
||||
if ($command == 'dailyAt') {
|
||||
$command = "dailyAt,$daily_at";
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
public function storeCommand($array = [])
|
||||
{
|
||||
$command = new \App\Model\MailJob\Condition();
|
||||
$commands = $command->get();
|
||||
if ($commands->count() > 0) {
|
||||
foreach ($commands as $condition) {
|
||||
$condition->delete();
|
||||
}
|
||||
}
|
||||
if (count($array) > 0) {
|
||||
foreach ($array as $key => $save) {
|
||||
$command->create([
|
||||
'job' => $key,
|
||||
'value' => $save,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTicketNumber(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'format' => ['required', 'regex:/^(?=.*[$|-|#]).+$/'],
|
||||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$format = $request->input('format');
|
||||
$type = $request->input('type');
|
||||
$number = $this->switchNumber($format, $type);
|
||||
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function switchNumber($format, $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'random':
|
||||
return $this->createRandomNumber($format);
|
||||
case 'sequence':
|
||||
return $this->createSequencialNumber($format);
|
||||
}
|
||||
}
|
||||
|
||||
public function createRandomNumber($format)
|
||||
{
|
||||
$number = '';
|
||||
$array = str_split($format);
|
||||
for ($i = 0; $i < count($array); $i++) {
|
||||
if ($array[$i] === '$') {
|
||||
$number .= $this->getRandomAlphebet();
|
||||
}
|
||||
if ($array[$i] === '#') {
|
||||
$number .= rand(0, 9);
|
||||
}
|
||||
if ($array[$i] !== '$' && $array[$i] !== '#') {
|
||||
$number .= $array[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function createSequencialNumber($format)
|
||||
{
|
||||
$number = '';
|
||||
$array_format = str_split($format);
|
||||
$count = count($array_format);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
//dd($sub);
|
||||
if ($array_format[$i] === '$') {
|
||||
$number .= 'A';
|
||||
}
|
||||
|
||||
if ($array_format[$i] === '#') {
|
||||
$number .= '0';
|
||||
}
|
||||
|
||||
|
||||
if ($array_format[$i] !== '$' && $array_format[$i] !== '#') {
|
||||
$number .= $array_format[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $number;
|
||||
//return $this->nthTicketNumber($number);
|
||||
}
|
||||
|
||||
public function checkCurrentFormat($current, $format)
|
||||
{
|
||||
$check = true;
|
||||
$array_current = str_split($current);
|
||||
$array_format = str_split($format);
|
||||
$count_current = count($array_current);
|
||||
$count_format = count($array_format);
|
||||
if ($count_current === $count_format) {
|
||||
return false;
|
||||
}
|
||||
for ($i = 0; $i < $count_current; $i++) {
|
||||
if ($array_current[$i] !== $array_format[$i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function nthTicketNumber($current, $type, $format, $force = false)
|
||||
{
|
||||
$check = $this->checkCurrentFormat($current, $format);
|
||||
if ($check === false && $force === false) {
|
||||
$current = $this->createSequencialNumber($format);
|
||||
}
|
||||
if ($type === 'sequence') {
|
||||
$pos_first = stripos($current, '-');
|
||||
$pos_last = strpos($current, '-', $pos_first + 1);
|
||||
$current = str_replace('-', '', $current);
|
||||
$number = ++$current;
|
||||
if ($pos_first) {
|
||||
$number = substr_replace($number, '-', $pos_first, 0);
|
||||
}
|
||||
if ($pos_last) {
|
||||
$number = substr_replace($number, '-', $pos_last, 0);
|
||||
}
|
||||
}
|
||||
if ($type === 'random') {
|
||||
$number = $this->createRandomNumber($format);
|
||||
}
|
||||
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function getRandomAlphebet()
|
||||
{
|
||||
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$shuffled = str_shuffle($alpha);
|
||||
$shuffled_array = str_split($shuffled);
|
||||
$char = $shuffled_array[0];
|
||||
|
||||
return $char;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk\SocialMedia;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Settings\SocialMedia;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SocialMediaController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['auth', 'roles'], ['except' => ['configService']]);
|
||||
}
|
||||
|
||||
public function settings($provider)
|
||||
{
|
||||
try {
|
||||
$social = new SocialMedia();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.social-media.settings', compact('social', 'provider'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postSettings($provider, Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'client_id' => 'required',
|
||||
'client_secret' => 'required',
|
||||
'redirect' => 'required|url',
|
||||
]);
|
||||
try {
|
||||
$requests = $request->except('_token');
|
||||
$this->insertProvider($provider, $requests);
|
||||
|
||||
return redirect()->back()->with('success', 'Updated');
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProvider($provider, $requests)
|
||||
{
|
||||
$social = new SocialMedia();
|
||||
$socials = $social->where('provider', $provider)->get();
|
||||
if ($socials->count() > 0) {
|
||||
foreach ($socials as $media) {
|
||||
if (array_key_exists($media->key, $requests)) {
|
||||
$media->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function insertProvider($provider, $requests = [])
|
||||
{
|
||||
$this->deleteProvider($provider, $requests);
|
||||
$social = new SocialMedia();
|
||||
foreach ($requests as $key => $value) {
|
||||
$social->create([
|
||||
'provider' => $provider,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$social = new SocialMedia();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.social-media.index', compact('social'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function configService()
|
||||
{
|
||||
$social = new SocialMedia();
|
||||
$services = $this->services();
|
||||
foreach ($services as $service) {
|
||||
\Config::set("services.$service.client_id", $social->getvalueByKey($service, 'client_id'));
|
||||
\Config::set("services.$service.client_secret", $social->getvalueByKey($service, 'client_secret'));
|
||||
\Config::set("services.$service.redirect", $social->getvalueByKey($service, 'redirect'));
|
||||
}
|
||||
// dd(\Config::get('services'));
|
||||
}
|
||||
|
||||
public function services()
|
||||
{
|
||||
return [
|
||||
'facebook',
|
||||
'google',
|
||||
'github',
|
||||
'twitter',
|
||||
'linkedin',
|
||||
'bitbucket',
|
||||
];
|
||||
}
|
||||
}
|
@@ -9,6 +9,8 @@ use App\Http\Requests\helpdesk\TeamRequest;
|
||||
use App\Http\Requests\helpdesk\TeamUpdate;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Assign_team_agent;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Groups;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\User;
|
||||
// classes
|
||||
@@ -66,7 +68,7 @@ class TeamController extends Controller
|
||||
public function create(User $user)
|
||||
{
|
||||
try {
|
||||
$user = $user->get();
|
||||
$user = $user->where('role', '<>', 'user')->where('active', '=', 1)->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user'));
|
||||
} catch (Exception $e) {
|
||||
@@ -111,11 +113,99 @@ class TeamController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team)
|
||||
public function show($id, User $user, Assign_team_agent $assign_team_agent, Teams $team)
|
||||
{
|
||||
try {
|
||||
$user = $user->whereId($id)->first();
|
||||
$teams = $team->whereId($id)->first();
|
||||
|
||||
// $team_lead_name=User::whereId($teams->team_lead)->first();
|
||||
|
||||
// $team_lead = $team_lead_name->first_name . " " . $team_lead_name->last_name;
|
||||
|
||||
// $total_members = $assign_team_agent->where('team_id',$id)->count();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.teams.show', compact('user', 'teams', 'id'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getshow($id)
|
||||
{
|
||||
// dd($request);
|
||||
|
||||
// $id = $request->input('show_id');
|
||||
|
||||
// dd($id);
|
||||
|
||||
$users = DB::table('team_assign_agent')->select('team_assign_agent.id', 'team_assign_agent.team_id', 'users.user_name', 'users.first_name', 'users.last_name', 'users.active', 'users.assign_group', 'users.primary_dpt', 'users.role')
|
||||
->join('users', 'users.id', '=', 'team_assign_agent.agent_id')
|
||||
->where('team_assign_agent.team_id', '=', $id);
|
||||
// ->get();
|
||||
// dd($users);
|
||||
return \Datatable::query($users)
|
||||
->showColumns('user_name')
|
||||
|
||||
->addColumn('first_name', function ($model) {
|
||||
$full_name = ucfirst($model->first_name).' '.ucfirst($model->last_name);
|
||||
|
||||
return $full_name;
|
||||
})
|
||||
|
||||
|
||||
->addColumn('active', function ($model) {
|
||||
if ($model->active == '1') {
|
||||
$role = "<a class='btn btn-success btn-xs'>".'Active'.'</a>';
|
||||
} elseif ($model->active == 'agent') {
|
||||
$role = "<a class='btn btn-primary btn-xs'>".'Inactive'.'</a>';
|
||||
}
|
||||
|
||||
return $role;
|
||||
})
|
||||
|
||||
|
||||
->addColumn('assign_group', function ($model) {
|
||||
$group = Groups::whereId($model->assign_group)->first();
|
||||
|
||||
return $group->name;
|
||||
})
|
||||
->addColumn('primary_dpt', function ($model) {
|
||||
$dept = Department::whereId($model->primary_dpt)->first();
|
||||
|
||||
return $dept->name;
|
||||
})
|
||||
->addColumn('role', function ($model) {
|
||||
if ($model->role == 'admin') {
|
||||
$role = "<a class='btn btn-success btn-xs'>".$model->role.'</a>';
|
||||
} elseif ($model->role == 'agent') {
|
||||
$role = "<a class='btn btn-primary btn-xs'>".$model->role.'</a>';
|
||||
}
|
||||
|
||||
return $role;
|
||||
})
|
||||
|
||||
// ->showColumns('role')
|
||||
->searchColumns('first_name', 'last_name')
|
||||
->orderColumns('first_name', 'last_name')
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type User $user
|
||||
* @param type Assign_team_agent $assign_team_agent
|
||||
* @param type Teams $team
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team)
|
||||
{
|
||||
try {
|
||||
$user = $user->where('role', '<>', 'user')->where('active', '=', 1)->get();
|
||||
$teams = $team->whereId($id)->first();
|
||||
$agent_team = $assign_team_agent->where('team_id', $id)->get();
|
||||
$agent_id = $agent_team->lists('agent_id', 'agent_id');
|
||||
|
||||
|
@@ -12,13 +12,11 @@ use App\Http\Requests\helpdesk\TemplateUdate;
|
||||
// models
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Email\Template;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Utility\Languages;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* TemplateController.
|
||||
@@ -320,69 +318,22 @@ class TemplateController extends Controller
|
||||
public function postDiagno(DiagnosRequest $request)
|
||||
{
|
||||
try {
|
||||
$email_details = Emails::where('id', '=', $request->from)->first();
|
||||
if ($email_details->sending_protocol == 'mail') {
|
||||
$mail = new \PHPMailer(); // defaults to using php "mail()"
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
$mail->SetFrom($email_details->email_address, $email_details->email_name); // sender details
|
||||
$address = $request->to; // receiver email
|
||||
$mail->AddAddress($address);
|
||||
$mail->Subject = $request->subject; // subject of the email
|
||||
$body = $request->message; // body of the email
|
||||
$mail->CharSet = 'utf8';
|
||||
// $mail->MsgHTML($body);
|
||||
// $body = $request->message;
|
||||
$rtl = CommonSettings::where('option_name', '=', 'enable_rtl')->first();
|
||||
if ($rtl->option_value == 1) {
|
||||
$mail->ContentType = 'text/html';
|
||||
$body = '<html dir="rtl" xml:lang="ar" lang="ar"><head></head><body dir="rtl">'.$body.'</body></html>';
|
||||
} else {
|
||||
}
|
||||
if (!$mail->Send()) {
|
||||
$return = Lang::get('lang.mailer_error').': '.$mail->ErrorInfo;
|
||||
} else {
|
||||
$return = Lang::get('lang.message_has_been_sent');
|
||||
}
|
||||
} elseif ($email_details->sending_protocol == 'smtp') {
|
||||
$mail = new \PHPMailer();
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
if ($email_details->smtp_validate == '1') {
|
||||
$mail->SMTPOptions = [
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
$mail->Host = $email_details->sending_host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $email_details->email_address; // SMTP username
|
||||
$mail->Password = \Crypt::decrypt($email_details->password); // SMTP password
|
||||
$mail->SMTPSecure = $email_details->sending_encryption; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $email_details->sending_port; // TCP port to connect to
|
||||
$mail->setFrom($email_details->email_address, $email_details->email_name);
|
||||
$mail->addAddress($request->to, ''); // Add a recipient
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
$mail->CharSet = 'utf8';
|
||||
$mail->Subject = $request->subject;
|
||||
$body = $request->message;
|
||||
$rtl = CommonSettings::where('option_name', '=', 'enable_rtl')->first();
|
||||
if ($rtl->option_value == 1) {
|
||||
$mail->ContentType = 'text/html';
|
||||
$body = '<html dir="rtl" xml:lang="ar" lang="ar"><head></head><body dir="rtl">'.$body.'</body></html>';
|
||||
} else {
|
||||
}
|
||||
$mail->Body = $body;
|
||||
if (!$mail->send()) {
|
||||
$return = Lang::get('lang.mailer_error').': '.$mail->ErrorInfo;
|
||||
} else {
|
||||
$return = Lang::get('lang.message_has_been_sent');
|
||||
}
|
||||
$to = $request->input('to');
|
||||
$subject = $request->input('subject');
|
||||
$msg = $request->input('message');
|
||||
$from = $request->input('from');
|
||||
$from_address = Emails::where('id', '=', $from)->first();
|
||||
if (!$from_address) {
|
||||
throw new Exception('Sorry! We can not find your request');
|
||||
}
|
||||
$controller = new PhpMailController();
|
||||
$controller->setMailConfig($from_address);
|
||||
$controller->laravelMail($to, '', $subject, $msg, [], null);
|
||||
|
||||
return redirect()->back()->with('success', $return);
|
||||
return redirect()->back()->with('success', 'Mail has send successfully');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
168
app/Http/Controllers/Admin/helpdesk/UrlSettingController.php
Normal file
168
app/Http/Controllers/Admin/helpdesk/UrlSettingController.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UrlSettingController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function settings(Request $request)
|
||||
{
|
||||
$url = $request->url();
|
||||
$www = $this->checkWWW($url);
|
||||
$https = $this->checkHTTP($url);
|
||||
//dd($www, $https);
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.settings.url.settings', compact('www', 'https'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postSettings(Request $request)
|
||||
{
|
||||
try {
|
||||
$www = $request->input('www');
|
||||
$ssl = $request->input('ssl');
|
||||
$string_www = $this->www($www);
|
||||
$sting_ssl = $this->ssl($ssl);
|
||||
$string = $string_www.$sting_ssl;
|
||||
$this->writeHtaccess($string);
|
||||
|
||||
return redirect()->back()->with('success', 'updated');
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function www($www)
|
||||
{
|
||||
switch ($www) {
|
||||
case 'yes':
|
||||
return $this->changeWww();
|
||||
case 'no':
|
||||
return $this->changeNonwww();
|
||||
}
|
||||
}
|
||||
|
||||
public function changeWww()
|
||||
{
|
||||
$string = "RewriteCond %{HTTP_HOST} !^www\.
|
||||
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function changeNonwww()
|
||||
{
|
||||
// $string = "\nRewriteEngine On
|
||||
//RewriteBase /
|
||||
//RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
|
||||
//RewriteRule ^(.*)$ http://%1/$1 [R=301,L]\n";
|
||||
$string = '';
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function ssl($ssl)
|
||||
{
|
||||
switch ($ssl) {
|
||||
case 'yes':
|
||||
return $this->changeHttps();
|
||||
case 'no':
|
||||
return $this->changeHttp();
|
||||
}
|
||||
}
|
||||
|
||||
public function changeHttps()
|
||||
{
|
||||
$string = "RewriteCond %{HTTPS} off
|
||||
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function changeHttp()
|
||||
{
|
||||
//$string = "RewriteCond %{HTTPS} off
|
||||
//RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
$string = '';
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function writeHtaccess($string)
|
||||
{
|
||||
$file = public_path('.htaccess');
|
||||
$this->deleteCustom();
|
||||
$content = file_get_contents($file);
|
||||
file_put_contents($file, $content."#custom\n".$string);
|
||||
$new_content = file_get_contents($file);
|
||||
}
|
||||
|
||||
public function deleteCustom()
|
||||
{
|
||||
$file = public_path('.htaccess');
|
||||
$content = file_get_contents($file);
|
||||
$custom_pos = strpos($content, '#custom');
|
||||
if ($custom_pos) {
|
||||
$content = substr_replace($content, '', $custom_pos);
|
||||
}
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
public function checkWwwInUrl($url)
|
||||
{
|
||||
$check = false;
|
||||
if (strpos($url, 'www') !== false) {
|
||||
$check = true;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function checkHttpsInUrl($url)
|
||||
{
|
||||
$check = false;
|
||||
if (strpos($url, 'https') !== false) {
|
||||
$check = true;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function checkWWW($url)
|
||||
{
|
||||
$check = $this->checkWwwInUrl($url);
|
||||
$array['www'] = true;
|
||||
$array['nonwww'] = false;
|
||||
if ($check == false) {
|
||||
$array['www'] = false;
|
||||
$array['nonwww'] = true;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function checkHTTP($url)
|
||||
{
|
||||
$check = $this->checkHttpsInUrl($url);
|
||||
$array['https'] = true;
|
||||
$array['http'] = false;
|
||||
if ($check == false) {
|
||||
$array['https'] = false;
|
||||
$array['http'] = true;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
@@ -132,7 +132,7 @@ class WorkflowController extends Controller
|
||||
->addColumn('Actions', function ($model) {
|
||||
$confirmation = 'Are you sure?';
|
||||
|
||||
return "<a class='btn btn-info btn-xs btn-flat' href='".route('workflow.edit', $model->id)."'><i class='fa fa-edit text-black'></i> Edit</a> <a class='btn btn-danger btn-xs btn-flat' href='".route('workflow.delete', $model->id)."' onclick='return confirm_delete()'><i class='fa fa-trash text-black'></i> Delete</a> ";
|
||||
return "<a class='btn btn-info btn-xs btn-flat' href='".route('workflow.edit', $model->id)."'><i class='fa fa-edit text-black'></i> Edit</a> <a class='btn btn-danger btn-xs btn-flat' href='".route('workflow.delete', $model->id)."'><i class='fa fa-trash text-black'></i> Delete</a>";
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
31
app/Http/Controllers/Agent/helpdesk/ImapMail.php
Normal file
31
app/Http/Controllers/Agent/helpdesk/ImapMail.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
use PhpImap\Mailbox;
|
||||
|
||||
class ImapMail extends Mailbox
|
||||
{
|
||||
public function get_overview($mailId)
|
||||
{
|
||||
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
|
||||
|
||||
return $overview;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function uses imap_search() to perform a search on the mailbox currently opened in the given IMAP stream.
|
||||
* For example, to match all unanswered mails sent by Mom, you'd use: "UNANSWERED FROM mom".
|
||||
*
|
||||
* @param string $criteria See http://php.net/imap_search for a complete list of available criteria
|
||||
*
|
||||
* @return array mailsIds (or empty array)
|
||||
*/
|
||||
public function searchMailbox($criteria = 'ALL')
|
||||
{
|
||||
//dd($this->getImapStream());
|
||||
$mailsIds = imap_search($this->getImapStream(), $criteria, SE_UID);
|
||||
//dd($mailsIds);
|
||||
return $mailsIds ? $mailsIds : [];
|
||||
}
|
||||
}
|
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App;
|
||||
// models
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
@@ -14,13 +13,8 @@ use App\Model\helpdesk\Settings\Ticket;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
// classes
|
||||
use App\Model\helpdesk\Utility\MailboxProtocol;
|
||||
use Crypt;
|
||||
use File;
|
||||
use ForceUTF8\Encoding;
|
||||
use PhpImap\Mailbox as ImapMailbox;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
|
||||
/**
|
||||
* MailController.
|
||||
@@ -48,200 +42,13 @@ class MailController extends Controller
|
||||
*/
|
||||
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket)
|
||||
{
|
||||
// $path_url = $system->first()->url;
|
||||
//dd($emails);
|
||||
if ($settings_email->first()->email_fetching == 1) {
|
||||
if ($settings_email->first()->all_emails == 1) {
|
||||
// $helptopic = $this->TicketController->default_helptopic();
|
||||
// $sla = $this->TicketController->default_sla();
|
||||
$email = $emails->get();
|
||||
foreach ($email as $e_mail) {
|
||||
if ($e_mail->fetching_status == 1) {
|
||||
$auto_response = $e_mail->auto_response;
|
||||
$priority = $e_mail->priority;
|
||||
$dept = $e_mail->department;
|
||||
$helptopic = $e_mail->help_topic;
|
||||
if ($priority == null) {
|
||||
$priority = $ticket->first()->priority;
|
||||
}
|
||||
if ($dept == null) {
|
||||
$dept = $system->first()->department;
|
||||
}
|
||||
if ($helptopic == null) {
|
||||
$helptopic = $ticket->first()->help_topic;
|
||||
}
|
||||
$get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
|
||||
$sla = $get_helptopic->sla_plan;
|
||||
$host = $e_mail->fetching_host;
|
||||
$port = $e_mail->fetching_port;
|
||||
if ($e_mail->mailbox_protocol) {
|
||||
$protocol_value = $e_mail->mailbox_protocol;
|
||||
$get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol_value)->first();
|
||||
$protocol = $get_mailboxprotocol->value;
|
||||
} elseif ($e_mail->fetching_encryption == '/none') {
|
||||
$fetching_encryption2 = '/novalidate-cert';
|
||||
$protocol = $fetching_encryption2;
|
||||
} else {
|
||||
if ($e_mail->fetching_protocol) {
|
||||
$fetching_protocol = '/'.$e_mail->fetching_protocol;
|
||||
} else {
|
||||
$fetching_protocol = '';
|
||||
}
|
||||
if ($e_mail->fetching_encryption) {
|
||||
$fetching_encryption = $e_mail->fetching_encryption;
|
||||
} else {
|
||||
$fetching_encryption = '';
|
||||
}
|
||||
$protocol = $fetching_protocol.$fetching_encryption;
|
||||
}
|
||||
$imap_config = '{'.$host.':'.$port.$protocol.'}INBOX';
|
||||
$password = Crypt::decrypt($e_mail->password);
|
||||
try {
|
||||
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
|
||||
} catch (\PhpImap\Exception $e) {
|
||||
echo 'Connection error';
|
||||
}
|
||||
$mails = [];
|
||||
try {
|
||||
$mailsIds = $mailbox->searchMailBox('SINCE '.date('d-M-Y', strtotime('-1 day')));
|
||||
} catch (\PhpImap\Exception $e) {
|
||||
echo 'Connection error';
|
||||
}
|
||||
if (!$mailsIds) {
|
||||
die('Mailbox is empty');
|
||||
}
|
||||
foreach ($mailsIds as $mailId) {
|
||||
try {
|
||||
$overview = $mailbox->get_overview($mailId);
|
||||
} catch (Exception $e) {
|
||||
return \Lang::get('lang.unable_to_fetch_emails');
|
||||
}
|
||||
$var = $overview[0]->seen ? 'read' : 'unread';
|
||||
if ($var == 'unread') {
|
||||
$mail = $mailbox->getMail($mailId);
|
||||
try {
|
||||
$mail = $mailbox->getMail($mailId);
|
||||
} catch (\PhpImap\Exception $e) {
|
||||
echo 'Connection error';
|
||||
}
|
||||
if ($settings_email->first()->email_collaborator == 1) {
|
||||
$collaborator = $mail->cc;
|
||||
} else {
|
||||
$collaborator = null;
|
||||
}
|
||||
$body = $mail->textHtml;
|
||||
if ($body != null) {
|
||||
$body = self::trimTableTag($body);
|
||||
}
|
||||
// if mail body has no messages fetch backup mail
|
||||
if ($body == null) {
|
||||
$body = $mail->textPlain;
|
||||
}
|
||||
if ($body == null) {
|
||||
$attach = $mail->getAttachments();
|
||||
if (is_array($attach)) {
|
||||
if (array_key_exists('html-body', $attach)) {
|
||||
$path = $attach['html-body']->filePath;
|
||||
}
|
||||
if ($path == null) {
|
||||
if (array_key_exists('text-body', $attach)) {
|
||||
$path = $attach['text-body']->filePath;
|
||||
}
|
||||
}
|
||||
if ($path) {
|
||||
$body = file_get_contents($path);
|
||||
}
|
||||
if ($body) {
|
||||
$body = self::trimTableTag($body);
|
||||
} else {
|
||||
$body = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
// if ($body == null) {
|
||||
// $body = $mailbox->backup_getmail($mailId);
|
||||
// $body = str_replace('\r\n', '<br/>', $body);
|
||||
// }
|
||||
$date = $mail->date;
|
||||
$datetime = $overview[0]->date;
|
||||
$date_time = explode(' ', $datetime);
|
||||
$date = $date_time[1].'-'.$date_time[2].'-'.$date_time[3].' '.$date_time[4];
|
||||
$date = date('Y-m-d H:i:s', strtotime($date));
|
||||
if (isset($mail->subject)) {
|
||||
$subject = $mail->subject;
|
||||
} else {
|
||||
$subject = 'No Subject';
|
||||
}
|
||||
|
||||
$to = $mail->to;
|
||||
$fromname = $mail->fromName;
|
||||
$fromaddress = $mail->fromAddress;
|
||||
$ticket_source = Ticket_source::where('name', '=', 'email')->first();
|
||||
$source = $ticket_source->id;
|
||||
$phone = '';
|
||||
$phonecode = '';
|
||||
$mobile_number = '';
|
||||
$assign = $get_helptopic->auto_assign;
|
||||
$form_data = null;
|
||||
$team_assign = null;
|
||||
$ticket_status = null;
|
||||
$result = $this->TicketWorkflowController->workflow($fromaddress, $fromname, $to, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $mail->getAttachments());
|
||||
|
||||
if ($result[1] == true) {
|
||||
$ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();
|
||||
$thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
|
||||
|
||||
$thread_id = $thread_id;
|
||||
foreach ($mail->getAttachments() as $attachment) {
|
||||
$support = 'support';
|
||||
|
||||
$dir_img_paths = __DIR__;
|
||||
$dir_img_path = explode('/code', $dir_img_paths);
|
||||
|
||||
$filepath = explode('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'public', $attachment->filePath);
|
||||
|
||||
if ($filepath[1]) {
|
||||
$path = public_path().$filepath[1];
|
||||
|
||||
$filesize = filesize($path);
|
||||
$file_data = file_get_contents($path);
|
||||
$ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
|
||||
$imageid = $attachment->id;
|
||||
$string = str_replace('-', '', $attachment->name);
|
||||
$filename = explode('src', $attachment->filePath);
|
||||
$filename = str_replace('\\', '', $filename);
|
||||
$body = str_replace('cid:'.$imageid, $filepath[1], $body);
|
||||
$pos = strpos($body, $filepath[1]);
|
||||
if ($pos == false) {
|
||||
if ($settings_email->first()->attachment == 1) {
|
||||
$upload = new Ticket_attachments();
|
||||
$upload->file = $file_data;
|
||||
$upload->thread_id = $thread_id;
|
||||
$upload->name = $filepath[1];
|
||||
$upload->type = $ext;
|
||||
$upload->size = $filesize;
|
||||
$upload->poster = 'ATTACHMENT';
|
||||
$upload->save();
|
||||
}
|
||||
} else {
|
||||
$upload = new Ticket_attachments();
|
||||
$upload->file = $file_data;
|
||||
$upload->thread_id = $thread_id;
|
||||
$upload->name = $filepath[1];
|
||||
$upload->type = $ext;
|
||||
$upload->size = $filesize;
|
||||
$upload->poster = 'INLINE';
|
||||
$upload->save();
|
||||
}
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
$body = $body;
|
||||
$thread = Ticket_Thread::where('id', '=', $thread_id)->first();
|
||||
$thread->body = $this->separate_reply($body);
|
||||
$thread->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($email->count() > 0) {
|
||||
foreach ($email as $e_mail) {
|
||||
$this->fetch($e_mail);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,40 +71,263 @@ class MailController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode Imap text.
|
||||
* @param object $email
|
||||
*
|
||||
* @param type $str
|
||||
*
|
||||
* @return type string
|
||||
* @return int
|
||||
*/
|
||||
public function decode_imap_text($str)
|
||||
public function priority($email)
|
||||
{
|
||||
$result = '';
|
||||
$decode_header = imap_mime_header_decode($str);
|
||||
foreach ($decode_header as $obj) {
|
||||
$result .= htmlspecialchars(rtrim($obj->text, "\t"));
|
||||
$priority = $email->priority;
|
||||
if (!$priority) {
|
||||
$priority = $this->ticketController()->getSystemDefaultPriority();
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch_attachments.
|
||||
* get department.
|
||||
*
|
||||
* @return type
|
||||
* @param object $email
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function fetch_attachments()
|
||||
public function department($email)
|
||||
{
|
||||
$uploads = Upload::all();
|
||||
foreach ($uploads as $attachment) {
|
||||
$image = @imagecreatefromstring($attachment->file);
|
||||
ob_start();
|
||||
imagejpeg($image, null, 80);
|
||||
$data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,'.base64_encode($data).'"/></a>';
|
||||
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>';
|
||||
$department = $email->department;
|
||||
if (!$department) {
|
||||
$department = $this->ticketController()->getSystemDefaultDepartment();
|
||||
}
|
||||
|
||||
return $department;
|
||||
}
|
||||
|
||||
/**
|
||||
* get help topic.
|
||||
*
|
||||
* @param object $email
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function helptopic($email)
|
||||
{
|
||||
//dd($email);
|
||||
$helptopic = $email->help_topic;
|
||||
if (!$helptopic) {
|
||||
$helptopic = $this->ticketController()->getSystemDefaultHelpTopic();
|
||||
}
|
||||
|
||||
return $helptopic;
|
||||
}
|
||||
|
||||
/**
|
||||
* get sla.
|
||||
*
|
||||
* @param object $email
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function sla($email)
|
||||
{
|
||||
$helptopic = $this->helptopic($email);
|
||||
$help = Help_topic::where('id', '=', $helptopic)->first();
|
||||
if ($help) {
|
||||
$sla = $help->sla_plan;
|
||||
}
|
||||
if (!$sla) {
|
||||
$sla = $this->ticketController()->getSystemDefaultSla();
|
||||
}
|
||||
|
||||
return $sla;
|
||||
}
|
||||
|
||||
/**
|
||||
* get ticket controller.
|
||||
*
|
||||
* @return \App\Http\Controllers\Agent\helpdesk\TicketController
|
||||
*/
|
||||
public function ticketController()
|
||||
{
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$controller = new TicketController($PhpMailController, $NotificationController);
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
public function fetch($email)
|
||||
{
|
||||
// dd($email);
|
||||
if ($email) {
|
||||
$username = $email->email_address;
|
||||
$password = $email->password;
|
||||
$service = $email->fetching_protocol;
|
||||
$host = $email->fetching_host;
|
||||
$port = $email->fetching_port;
|
||||
$encryption = $email->fetching_encryption;
|
||||
$cert = $email->mailbox_protocol;
|
||||
$server = new Fetch($host, $port, $service);
|
||||
if ($encryption != null || $encryption != '') {
|
||||
$server->setFlag($encryption);
|
||||
}
|
||||
$server->setFlag($cert);
|
||||
$server->setAuthentication($username, $password);
|
||||
$messages = $server->search('UNSEEN', 10);
|
||||
$this->message($messages, $email);
|
||||
}
|
||||
}
|
||||
|
||||
public function message($messages, $email)
|
||||
{
|
||||
foreach ($messages as $message) {
|
||||
$this->getMessageContent($message, $email);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMessageContent($message, $email)
|
||||
{
|
||||
$body = $message->getMessageBody(true);
|
||||
if (!$body) {
|
||||
$body = $message->getMessageBody();
|
||||
}
|
||||
$subject = $message->getSubject();
|
||||
$address = $message->getAddresses('reply-to');
|
||||
if (!$address) {
|
||||
$address = $message->getAddresses('from');
|
||||
}
|
||||
$collaborators = $this->collaburators($message, $email);
|
||||
$attachments = $message->getAttachments();
|
||||
//dd(['body' => $body, 'subject' => $subject, 'address' => $address, 'cc' => $collaborator, 'attachments' => $attachments]);
|
||||
$this->workflow($address, $subject, $body, $collaborators, $attachments, $email);
|
||||
}
|
||||
|
||||
public function workflow($address, $subject, $body, $collaborator, $attachments, $email)
|
||||
{
|
||||
$fromaddress = checkArray('address', $address[0]);
|
||||
$fromname = checkArray('name', $address[0]);
|
||||
$helptopic = $this->helptopic($email);
|
||||
$sla = $this->sla($email);
|
||||
$priority = $this->priority($email);
|
||||
$ticket_source = Ticket_source::where('name', '=', 'email')->first();
|
||||
$source = $ticket_source->id;
|
||||
$dept = $this->department($email);
|
||||
$get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
|
||||
$assign = $get_helptopic->auto_assign;
|
||||
$form_data = null;
|
||||
$team_assign = null;
|
||||
$ticket_status = null;
|
||||
$auto_response = $email->auto_response;
|
||||
$result = $this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone = '', $phonecode = '', $mobile_number = '', $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data = [], $auto_response);
|
||||
if ($result[1] == true) {
|
||||
$this->updateThread($result[0], $body, $attachments);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateThread($ticket_number, $body, $attachments)
|
||||
{
|
||||
$ticket_table = Tickets::where('ticket_number', '=', $ticket_number)->first();
|
||||
$thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
|
||||
$thread = Ticket_Thread::where('id', '=', $thread_id)->first();
|
||||
$thread->body = $this->separate_reply($body);
|
||||
$thread->save();
|
||||
$this->saveAttachments($thread->id, $attachments);
|
||||
\Log::info('Ticket has created : ', ['id' => $thread->ticket_id]);
|
||||
}
|
||||
|
||||
public function saveAttachments($thread_id, $attachments = [])
|
||||
{
|
||||
if (is_array($attachments) && count($attachments) > 0) {
|
||||
foreach ($attachments as $attachment) {
|
||||
$structure = $attachment->getStructure();
|
||||
$disposition = 'ATTACHMENT';
|
||||
if (isset($structure->disposition)) {
|
||||
$disposition = $structure->disposition;
|
||||
}
|
||||
|
||||
$filename = str_random(16).'-'.$attachment->getFileName();
|
||||
$type = $attachment->getMimeType();
|
||||
$size = $attachment->getSize();
|
||||
$data = $attachment->getData();
|
||||
$this->manageAttachment($data, $filename, $type, $size, $disposition, $thread_id);
|
||||
$this->updateBody($attachment, $thread_id, $filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id)
|
||||
{
|
||||
$upload = new Ticket_attachments();
|
||||
$upload->file = $data;
|
||||
$upload->thread_id = $thread_id;
|
||||
$upload->name = $filename;
|
||||
$upload->type = $type;
|
||||
$upload->size = $size;
|
||||
$upload->poster = $disposition;
|
||||
if ($data && $size && $disposition) {
|
||||
$upload->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function updateBody($attachment, $thread_id, $filename)
|
||||
{
|
||||
$structure = $attachment->getStructure();
|
||||
$disposition = 'ATTACHMENT';
|
||||
if (isset($structure->disposition)) {
|
||||
$disposition = $structure->disposition;
|
||||
}
|
||||
if ($disposition == 'INLINE') {
|
||||
$id = str_replace('>', '', str_replace('<', '', $structure->id));
|
||||
//$filename = $attachment->getFileName();
|
||||
$path = public_path('attachments');
|
||||
$filepath = asset('attachments/'.$filename);
|
||||
$threads = new Ticket_Thread();
|
||||
$thread = $threads->find($thread_id);
|
||||
$body = $thread->body;
|
||||
$body = str_replace('cid:'.$id, $filename, $body);
|
||||
$thread->body = $body;
|
||||
$thread->save();
|
||||
$attachment->saveToDirectory($path);
|
||||
}
|
||||
}
|
||||
|
||||
public function collaburators($message, $email)
|
||||
{
|
||||
$this_address = $email->email_address;
|
||||
$collaborator_cc = $message->getAddresses('cc');
|
||||
//dd($collaborator_cc);
|
||||
$collaborator_bcc = $message->getAddresses('bcc');
|
||||
$collaborator_to = $message->getAddresses('to');
|
||||
$cc_array = [];
|
||||
$bcc_array = [];
|
||||
$to_array = [];
|
||||
if ($collaborator_cc) {
|
||||
foreach ($collaborator_cc as $cc) {
|
||||
$name = checkArray('name', $cc);
|
||||
$address = checkArray('address', $cc);
|
||||
$cc_array[$address] = $name;
|
||||
}
|
||||
}
|
||||
if ($collaborator_bcc) {
|
||||
foreach ($collaborator_bcc as $bcc) {
|
||||
$name = checkArray('name', $bcc);
|
||||
$address = checkArray('address', $bcc);
|
||||
$bcc_array[$address] = $name;
|
||||
}
|
||||
}
|
||||
if ($collaborator_to) {
|
||||
foreach ($collaborator_to as $to) {
|
||||
$name = checkArray('name', $to);
|
||||
$address = checkArray('address', $to);
|
||||
$to_array[$address] = $name;
|
||||
}
|
||||
}
|
||||
$array = array_merge($bcc_array, $cc_array);
|
||||
$array = array_merge($array, $to_array);
|
||||
if (array_key_exists($this_address, $array)) {
|
||||
unset($array[$this_address]);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,47 +339,22 @@ class MailController extends Controller
|
||||
*/
|
||||
public function get_data($id)
|
||||
{
|
||||
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
|
||||
$attachments = \App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
|
||||
foreach ($attachments as $attachment) {
|
||||
header('Content-type: application/'.$attachment->type.'');
|
||||
header('Content-Disposition: inline; filename='.$attachment->name.'');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
echo $attachment->file;
|
||||
$headers = [
|
||||
'Content-type: application/'.$attachment->type.'',
|
||||
'Content-Disposition: inline; filename='.$attachment->name.'',
|
||||
'Content-Transfer-Encoding: binary',
|
||||
];
|
||||
$file = $attachment->file;
|
||||
echo $file;
|
||||
// return response($file)
|
||||
// ->header('Content-Type', $attachment->type)
|
||||
// ->header('Content-Disposition', 'inline; filename='.$attachment->name.'')
|
||||
// ->header('Content-Transfer-Encoding', 'binary');
|
||||
}
|
||||
}
|
||||
|
||||
public static function trimTableTag($html)
|
||||
{
|
||||
if (strpos('<table>', $html) != false) {
|
||||
$first_pos = strpos($html, '<table');
|
||||
$fist_string = substr_replace($html, '', 0, $first_pos);
|
||||
$last_pos = strrpos($fist_string, '</table>', -1);
|
||||
$total = strlen($fist_string);
|
||||
$diff = $total - $last_pos;
|
||||
$str = substr_replace($fist_string, '', $last_pos, -1);
|
||||
$final_str = str_finish($str, '</table>');
|
||||
|
||||
return $final_str;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function trim3D($html)
|
||||
{
|
||||
$body = str_replace('=3D', '', $html);
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public static function trimInjections($html, $tags = ['<script>', '</script>', '<style>', '</style>', '<?php', '?>'])
|
||||
{
|
||||
$replace = [];
|
||||
foreach ($tags as $key => $tag) {
|
||||
$replace[$key] = htmlspecialchars($tag);
|
||||
}
|
||||
$body = str_replace($tags, $replace, $html);
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
@@ -34,28 +34,37 @@ class NotificationController extends Controller
|
||||
* */
|
||||
public function send_notification()
|
||||
{
|
||||
// dd('sdckjdsc');
|
||||
//fetching email settings
|
||||
$email = Email::where('id', '=', '1')->first();
|
||||
//dd('yes');
|
||||
$send = 0;
|
||||
$date = [0];
|
||||
// dd($date);
|
||||
// checking if the daily notification is enabled or not
|
||||
if ($email->notification_cron == 1) {
|
||||
// checking if current date is equal to the last entered daily notification log
|
||||
$notification = Log_notification::where('log', '=', 'NOT-1')->orderBy('id', 'DESC')->first();
|
||||
$date = explode(' ', $notification->created_at);
|
||||
if (date('Y-m-d') == $date[0]) {
|
||||
} else {
|
||||
if ($notification) {
|
||||
$date = explode(' ', $notification->created_at);
|
||||
}
|
||||
// if (date('Y-m-d') !== $date[0]) {
|
||||
// creating a daily notification log
|
||||
Log_notification::create(['log' => 'NOT-1']);
|
||||
|
||||
$company = $this->company();
|
||||
// Send notification details to admin
|
||||
$this->send_notification_to_admin($company);
|
||||
$send += $this->send_notification_to_admin($company);
|
||||
// Send notification details to team lead
|
||||
//$this->send_notification_to_team_lead($company);
|
||||
$send += $this->send_notification_to_team_lead($company);
|
||||
// Send notification details to manager of a department
|
||||
//$this->send_notification_to_manager($company);
|
||||
$send += $this->send_notification_to_manager($company);
|
||||
// Send notification details to all the agents
|
||||
//$this->send_notification_to_agent($company);
|
||||
}
|
||||
$send += $this->send_notification_to_agent($company);
|
||||
//}
|
||||
Log_notification::create(['log' => 'NOT-1']);
|
||||
}
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,14 +88,17 @@ class NotificationController extends Controller
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
];
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
];
|
||||
$this->dispatch((new \App\Jobs\SendEmail($from, $to, $message))->onQueue('emails'));
|
||||
//$this->PhpMailController->sendEmail($from,$to,$message);
|
||||
];
|
||||
$job = new \App\Jobs\SendEmail($from, $to, $message);
|
||||
$dispatch = $this->dispatch($job);
|
||||
|
||||
return $dispatch;
|
||||
//return $this->PhpMailController->sendEmail($from,$to,$message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +121,19 @@ class NotificationController extends Controller
|
||||
$user_name = $user->first_name.' '.$user->last_name;
|
||||
$view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]);
|
||||
$contents = $view->render();
|
||||
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
$from = $this->PhpMailController->mailfrom('1', '0');
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
];
|
||||
|
||||
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
|
||||
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +158,19 @@ class NotificationController extends Controller
|
||||
$user_name = $user->first_name.' '.$user->last_name;
|
||||
$view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id]);
|
||||
$contents = $view->render();
|
||||
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
$from = $this->PhpMailController->mailfrom('1', '0');
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
];
|
||||
|
||||
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
|
||||
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,7 +191,19 @@ class NotificationController extends Controller
|
||||
$user_name = $user->first_name.' '.$user->last_name;
|
||||
$view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => $user->id]);
|
||||
$contents = $view->render();
|
||||
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
$from = $this->PhpMailController->mailfrom('1', '0');
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
];
|
||||
|
||||
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
|
||||
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@ use App\Model\helpdesk\Agent_panel\User_org;
|
||||
use App\User;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
@@ -328,4 +329,16 @@ class OrganizationController extends Controller
|
||||
|
||||
return '['.$last.']';
|
||||
}
|
||||
|
||||
public function getOrgAjax(Request $request)
|
||||
{
|
||||
$org = new Organization();
|
||||
$q = $request->input('term');
|
||||
$orgs = $org->where('name', 'LIKE', '%'.$q.'%')
|
||||
->select('name as label', 'id as value')
|
||||
->get()
|
||||
->toJson();
|
||||
|
||||
return $orgs;
|
||||
}
|
||||
}
|
||||
|
269
app/Http/Controllers/Agent/helpdesk/ReportController.php
Normal file
269
app/Http/Controllers/Agent/helpdesk/ReportController.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
// request
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
// Model
|
||||
use Illuminate\Http\Request;
|
||||
// classes
|
||||
use PDF;
|
||||
|
||||
/**
|
||||
* ReportController
|
||||
* This controlleris used to fetch reports in the agent panel.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ReportController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// checking for authentication
|
||||
$this->middleware('auth');
|
||||
// checking if the role is agent
|
||||
$this->middleware('role.agent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Report page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.report.index');
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get help_topic graph.
|
||||
*
|
||||
* @param type $date111
|
||||
* @param type $date122
|
||||
* @param type $helptopic
|
||||
*/
|
||||
public function chartdataHelptopic(Request $request, $date111 = '', $date122 = '', $helptopic = '')
|
||||
{
|
||||
$date11 = strtotime($date122);
|
||||
$date12 = strtotime($date111);
|
||||
$help_topic = $helptopic;
|
||||
$duration = $request->input('duration');
|
||||
if ($date11 && $date12 && $help_topic) {
|
||||
$date2 = $date12;
|
||||
$date1 = $date11;
|
||||
$duration = null;
|
||||
if ($request->input('open') == null || $request->input('closed') == null || $request->input('reopened') == null || $request->input('overdue') == null || $request->input('deleted') == null) {
|
||||
$duration = 'day';
|
||||
}
|
||||
} else {
|
||||
// generating current date
|
||||
$date2 = strtotime(date('Y-m-d'));
|
||||
$date3 = date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
// generating a date range of 1 month
|
||||
if ($request->input('duration') == 'day') {
|
||||
$date1 = strtotime(date($format, strtotime('-15 day'.$date3)));
|
||||
} elseif ($request->input('duration') == 'week') {
|
||||
$date1 = strtotime(date($format, strtotime('-69 days'.$date3)));
|
||||
} elseif ($request->input('duration') == 'month') {
|
||||
$date1 = strtotime(date($format, strtotime('-179 days'.$date3)));
|
||||
} else {
|
||||
$date1 = strtotime(date($format, strtotime('-30 days'.$date3)));
|
||||
}
|
||||
// $help_topic = Help_topic::where('status', '=', '1')->min('id');
|
||||
}
|
||||
|
||||
|
||||
$return = '';
|
||||
$last = '';
|
||||
$j = 0;
|
||||
$created1 = '';
|
||||
$closed1 = '';
|
||||
$reopened1 = '';
|
||||
$in_progress = \DB::table('tickets')->where('help_topic_id', '=', $help_topic)->where('status', '=', 1)->count();
|
||||
|
||||
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
|
||||
$j++;
|
||||
$thisDate = date('Y-m-d', $i);
|
||||
$thisDate1 = date('jS F', $i);
|
||||
$open_array = [];
|
||||
$closed_array = [];
|
||||
$reopened_array = [];
|
||||
|
||||
if ($request->input('open') || $request->input('closed') || $request->input('reopened')) {
|
||||
if ($request->input('open') && $request->input('open') == 'on') {
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$open_array = ['open' => $created];
|
||||
}
|
||||
if ($request->input('closed') && $request->input('closed') == 'on') {
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed_array = ['closed' => $closed];
|
||||
}
|
||||
if ($request->input('reopened') && $request->input('reopened') == 'on') {
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened_array = ['reopened' => $reopened];
|
||||
}
|
||||
// if ($request->input('overdue') && $request->input('overdue') == 'on') {
|
||||
// $overdue = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $dept->id)->orderBy('id', 'DESC')->get();
|
||||
// }
|
||||
// $open_array = ['open'=>$created1];
|
||||
// $closed_array = ['closed'=>$closed1];
|
||||
// $reopened_array = ['reopened'=>$reopened1];
|
||||
$value = ['date' => $thisDate1];
|
||||
// if($open_array) {
|
||||
$value = array_merge($value, $open_array);
|
||||
$value = array_merge($value, $closed_array);
|
||||
$value = array_merge($value, $reopened_array);
|
||||
$value = array_merge($value, ['inprogress' => $in_progress]);
|
||||
// } else {
|
||||
// $value = "";
|
||||
// }
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
} else {
|
||||
if ($duration == 'week') {
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$created1 += $created;
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed1 += $closed;
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened1 += $reopened;
|
||||
if ($j % 7 == 0) {
|
||||
$open_array = ['open' => $created1];
|
||||
$created1 = 0;
|
||||
$closed_array = ['closed' => $closed1];
|
||||
$closed1 = 0;
|
||||
$reopened_array = ['reopened' => $reopened1];
|
||||
$reopened1 = 0;
|
||||
$value = ['date' => $thisDate1];
|
||||
// if($open_array) {
|
||||
$value = array_merge($value, $open_array);
|
||||
$value = array_merge($value, $closed_array);
|
||||
$value = array_merge($value, $reopened_array);
|
||||
$value = array_merge($value, ['inprogress' => $in_progress]);
|
||||
// } else {
|
||||
// $value = "";
|
||||
// }
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
} elseif ($duration == 'month') {
|
||||
$created_month = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$created1 += $created_month;
|
||||
$closed_month = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed1 += $closed_month;
|
||||
$reopened_month = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened1 += $reopened_month;
|
||||
if ($j % 30 == 0) {
|
||||
$open_array = ['open' => $created1];
|
||||
$created1 = 0;
|
||||
$closed_array = ['closed' => $closed1];
|
||||
$closed1 = 0;
|
||||
$reopened_array = ['reopened' => $reopened1];
|
||||
$reopened1 = 0;
|
||||
$value = ['date' => $thisDate1];
|
||||
|
||||
$value = array_merge($value, $open_array);
|
||||
$value = array_merge($value, $closed_array);
|
||||
$value = array_merge($value, $reopened_array);
|
||||
$value = array_merge($value, ['inprogress' => $in_progress]);
|
||||
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
} else {
|
||||
if ($request->input('default') == null) {
|
||||
$help_topic = Help_topic::where('status', '=', '1')->min('id');
|
||||
}
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$open_array = ['open' => $created];
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed_array = ['closed' => $closed];
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened_array = ['reopened' => $reopened];
|
||||
if ($j % 1 == 0) {
|
||||
$open_array = ['open' => $created];
|
||||
$created = 0;
|
||||
$closed_array = ['closed' => $closed];
|
||||
$closed = 0;
|
||||
$reopened_array = ['reopened' => $reopened];
|
||||
$reopened = 0;
|
||||
$value = ['date' => $thisDate1];
|
||||
if ($request->input('default') == null) {
|
||||
$value = array_merge($value, $open_array);
|
||||
$value = array_merge($value, $closed_array);
|
||||
$value = array_merge($value, $reopened_array);
|
||||
$value = array_merge($value, ['inprogress' => $in_progress]);
|
||||
} else {
|
||||
if ($duration == null) {
|
||||
if ($request->input('open') == 'on') {
|
||||
$value = array_merge($value, $open_array);
|
||||
}
|
||||
if ($request->input('closed') == 'on') {
|
||||
$value = array_merge($value, $closed_array);
|
||||
}
|
||||
if ($request->input('reopened') == 'on') {
|
||||
$value = array_merge($value, $reopened_array);
|
||||
}
|
||||
} else {
|
||||
$value = array_merge($value, $open_array);
|
||||
$value = array_merge($value, $closed_array);
|
||||
$value = array_merge($value, $reopened_array);
|
||||
$value = array_merge($value, ['inprogress' => $in_progress]);
|
||||
}
|
||||
}
|
||||
|
||||
// } else {
|
||||
// $value = "";
|
||||
// }
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $value = ['date' => $thisDate];
|
||||
// if($open_array) {
|
||||
// $value = array_merge($value,$open_array);
|
||||
// }
|
||||
// if($closed_array) {
|
||||
// $value = array_merge($value,$closed_array);
|
||||
// }
|
||||
// if($reopened_array) {
|
||||
// $value = array_merge($value,$reopened_array);
|
||||
// }
|
||||
}
|
||||
$last = rtrim($return, ',');
|
||||
|
||||
return '['.$last.']';
|
||||
}
|
||||
|
||||
public function helptopicPdf(Request $request)
|
||||
{
|
||||
$table_datas = json_decode($request->input('pdf_form'));
|
||||
$table_help_topic = json_decode($request->input('pdf_form_help_topic'));
|
||||
$html = view('themes.default1.agent.helpdesk.report.pdf', compact('table_datas', 'table_help_topic'))->render();
|
||||
$html1 = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
return PDF::load($html1)->show();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -40,35 +40,33 @@ class TicketWorkflowController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function workflow($fromaddress, $fromname, $to, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $mail)
|
||||
public function workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response)
|
||||
{
|
||||
$contact_details = ['email' => $fromaddress, 'email_name' => $fromname, 'email_to' => $to, 'subject' => $subject, 'message' => $body];
|
||||
$contact_details = ['email' => $fromaddress, 'email_name' => $fromname, 'subject' => $subject, 'message' => $body];
|
||||
$ticket_settings_details = ['help_topic' => $helptopic, 'sla' => $sla, 'priority' => $priority, 'source' => $source, 'dept' => $dept, 'assign' => $assign, 'team' => $team_assign, 'status' => $ticket_status, 'reject' => false];
|
||||
// get all the workflow common to the entire system which includes any type of ticket creation where the execution order of the workflow should be starting with ascending order
|
||||
$workflows = WorkflowName::where('target', '=', 'A-0')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
|
||||
foreach ($workflows as $workflow) {
|
||||
// checking if any workflow defined in the system
|
||||
if ($workflow) {
|
||||
// get all the rules of workflow which has a foreign key of those workflow which are applied to creating any ticket from any source
|
||||
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflow->id)->get();
|
||||
|
||||
foreach ($workflow_rules as $workflow_rule) {
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflow->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($workflow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'subject') {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
@@ -80,24 +78,24 @@ class TicketWorkflowController extends Controller
|
||||
$workflows_webs = WorkflowName::where('target', '=', 'A-1')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
foreach ($workflows_webs as $workflows_web) {
|
||||
if ($workflows_web) {
|
||||
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflows_web->id)->get();
|
||||
foreach ($workflow_rules as $workflow_rule) {
|
||||
if ($workflow_rule) {
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_web->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
if ($worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($workflow_rule->matching_scenario == 'email') {
|
||||
if ($this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'email_name') {
|
||||
if ($this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'subject') {
|
||||
if ($this->checkRuleCondition($contact_details['subject'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'message') {
|
||||
if ($this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
@@ -111,31 +109,24 @@ class TicketWorkflowController extends Controller
|
||||
$workflows_emails = WorkflowName::where('target', '=', 'A-2')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
foreach ($workflows_emails as $workflows_email) {
|
||||
if ($workflows_email) {
|
||||
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflows_email->id)->get();
|
||||
foreach ($workflow_rules as $workflow_rule) {
|
||||
if ($workflow_rule) {
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_email->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
if ($worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($workflow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'email_to') {
|
||||
foreach ($contact_details['email_to'] as $email_toaddress => $email_toname) {
|
||||
if ($rule_condition = $this->checkRuleCondition($email_toaddress, $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
@@ -149,28 +140,24 @@ class TicketWorkflowController extends Controller
|
||||
$workflows_apis = WorkflowName::where('target', '=', 'A-4')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
foreach ($workflows_apis as $workflows_api) {
|
||||
if ($workflows_api) {
|
||||
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflows_api->id)->get();
|
||||
foreach ($workflow_rules as $workflow_rule) {
|
||||
if ($workflow_rule) {
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_api->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
if ($worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($workflow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'email_to') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($workflow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
@@ -179,10 +166,12 @@ class TicketWorkflowController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//dd($form_data);
|
||||
if ($ticket_settings_details['reject'] == true) {
|
||||
return ['0' => false, '1' => false];
|
||||
} else {
|
||||
$create_ticket = $this->TicketController->create_user($contact_details['email'], $contact_details['email_name'], $contact_details['subject'], $contact_details['message'], $phone, $phonecode, $mobile_number, $ticket_settings_details['help_topic'], $ticket_settings_details['sla'], $ticket_settings_details['priority'], $source, $collaborator, $ticket_settings_details['dept'], $ticket_settings_details['assign'], $form_data, $auto_response, $ticket_settings_details['status'], $mail);
|
||||
$create_ticket = $this->TicketController->create_user($contact_details['email'], $contact_details['email_name'], $contact_details['subject'], $contact_details['message'], $phone, $phonecode, $mobile_number, $ticket_settings_details['help_topic'], $ticket_settings_details['sla'], $ticket_settings_details['priority'], $source, $collaborator, $ticket_settings_details['dept'], $ticket_settings_details['assign'], $form_data, $auto_response, $ticket_settings_details['status']);
|
||||
|
||||
return $create_ticket;
|
||||
}
|
||||
@@ -217,7 +206,6 @@ class TicketWorkflowController extends Controller
|
||||
// } elseif($condition == 'not_match') {
|
||||
//
|
||||
// }
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@@ -7,23 +7,39 @@ use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
/* Include Sys_user Model */
|
||||
use App\Http\Requests\helpdesk\ProfilePassword;
|
||||
use App\Http\Requests\helpdesk\ChangepasswordRequest;
|
||||
/* For validation include Sys_userRequest in create */
|
||||
use App\Http\Requests\helpdesk\ProfileRequest;
|
||||
use App\Http\Requests\helpdesk\OtpVerifyRequest;
|
||||
/* For validation include Sys_userUpdate in update */
|
||||
use App\Http\Requests\helpdesk\Sys_userRequest;
|
||||
use App\Http\Requests\helpdesk\ProfilePassword;
|
||||
/* include guest_note model */
|
||||
use App\Http\Requests\helpdesk\ProfileRequest;
|
||||
use App\Http\Requests\helpdesk\Sys_userRequest;
|
||||
// change password request
|
||||
use App\Http\Requests\helpdesk\Sys_userUpdate;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Assign_team_agent;
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
use App\Model\helpdesk\Notification\Notification;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\Model\helpdesk\Utility\Otp;
|
||||
use App\User;
|
||||
// classes
|
||||
use Auth;
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Exception;
|
||||
use GeoIP;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
@@ -79,19 +95,23 @@ class UserController extends Controller
|
||||
public function user_list()
|
||||
{
|
||||
// displaying list of users with chumper datatables
|
||||
return \Datatable::collection(User::where('role', '=', 'user')->get())
|
||||
return \Datatable::collection(User::where('role', '!=', 'admin')->get())
|
||||
/* searchable column username and email */
|
||||
->searchColumns('user_name', 'email', 'phone')
|
||||
/* order column username and email */
|
||||
->orderColumns('user_name', 'email')
|
||||
/* column username */
|
||||
->addColumn('user_name', function ($model) {
|
||||
$string = strip_tags($model->user_name);
|
||||
if (strlen($string) > 10) {
|
||||
// truncate string
|
||||
$stringCut = substr($string, 0, 10);
|
||||
if ($model->first_name) {
|
||||
$string = strip_tags($model->first_name.' '.$model->last_name);
|
||||
} else {
|
||||
$stringCut = $model->user_name;
|
||||
$string = strip_tags($model->user_name);
|
||||
}
|
||||
if (strlen($string) > 20) {
|
||||
// truncate string
|
||||
$stringCut = substr($string, 0, 20);
|
||||
} else {
|
||||
$stringCut = $string;
|
||||
}
|
||||
|
||||
return $stringCut;
|
||||
@@ -133,7 +153,7 @@ class UserController extends Controller
|
||||
if ($status == 1) {
|
||||
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
|
||||
} else {
|
||||
$stat = '<button class="btn btn-success btn-xs">Active</button>';
|
||||
$stat = '<button class="btn btn-success btn-xs">Not Banned</button>';
|
||||
}
|
||||
|
||||
return $stat;
|
||||
@@ -144,6 +164,12 @@ class UserController extends Controller
|
||||
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
/* column Role */
|
||||
->addColumn('role', function ($model) {
|
||||
$role = $model->role;
|
||||
|
||||
return $role;
|
||||
})
|
||||
/* column actions */
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
|
||||
@@ -159,10 +185,13 @@ class UserController extends Controller
|
||||
public function create(CountryCode $code)
|
||||
{
|
||||
try {
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
$org = Organization::lists('name', 'id')->toArray();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.create')->with('phonecode', $phonecode->phonecode);
|
||||
return view('themes.default1.agent.helpdesk.user.create', compact('org', 'settings', 'email_mandatory'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
@@ -180,11 +209,20 @@ class UserController extends Controller
|
||||
{
|
||||
/* insert the input request to sys_user table */
|
||||
/* Check whether function success or not */
|
||||
$user->email = $request->input('email');
|
||||
|
||||
if ($request->input('email') != '') {
|
||||
$user->email = $request->input('email');
|
||||
} else {
|
||||
$user->email = null;
|
||||
}
|
||||
$user->first_name = $request->input('first_name');
|
||||
$user->last_name = $request->input('last_name');
|
||||
$user->user_name = $request->input('user_name');
|
||||
$user->mobile = $request->input('mobile');
|
||||
if ($request->input('mobile') != '') {
|
||||
$user->mobile = $request->input('mobile');
|
||||
} else {
|
||||
$user->mobile = null;
|
||||
}
|
||||
$user->ext = $request->input('ext');
|
||||
$user->phone_number = $request->input('phone_number');
|
||||
$user->country_code = $request->input('country_code');
|
||||
@@ -204,6 +242,8 @@ class UserController extends Controller
|
||||
}
|
||||
// save user credentails
|
||||
if ($user->save() == true) {
|
||||
$orgid = $request->input('org_id');
|
||||
$this->storeUserOrgRelation($user->id, $orgid);
|
||||
// fetch user credentails to send mail
|
||||
$name = $user->first_name;
|
||||
$email = $user->email;
|
||||
@@ -217,6 +257,12 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
// returns for the success case
|
||||
// returns for the success case
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
if (($request->input('active') == '0' || $request->input('active') == 0) || ($email_mandatory->status == '0') || $email_mandatory->status == 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
}
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.User-Created-Successfully'));
|
||||
}
|
||||
// $user->save();
|
||||
@@ -228,6 +274,266 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Random Password Genetor for users.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function randomPassword()
|
||||
{
|
||||
try {
|
||||
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*(){}[]';
|
||||
$pass = []; //remember to declare $pass as an array
|
||||
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$n = rand(0, $alphaLength);
|
||||
$pass[] = $alphabet[$n];
|
||||
}
|
||||
|
||||
return implode($pass);
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Random Password Genetor for users.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function randomPostPassword($id, ChangepasswordRequest $request)
|
||||
{
|
||||
try {
|
||||
$changepassword = $request->change_password;
|
||||
$user = User::whereId($id)->first();
|
||||
$password = $request->change_password;
|
||||
$user->password = Hash::make($password);
|
||||
$user->save();
|
||||
$name = $user->first_name;
|
||||
$email = $user->email;
|
||||
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController
|
||||
->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => null, 'scenario' => 'reset_new_password'], $template_variables = ['user' => $name, 'user_password' => $password]);
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.password_change_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('user')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type $id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function changeRoleAdmin($id, Request $request)
|
||||
{
|
||||
try {
|
||||
$user = User::whereId($id)->first();
|
||||
$user->role = 'admin';
|
||||
$user->assign_group = $request->group;
|
||||
$user->primary_dpt = $request->primary_department;
|
||||
$user->save();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type $id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function changeRoleAgent($id, Request $request)
|
||||
{
|
||||
try {
|
||||
$user = User::whereId($id)->first();
|
||||
$user->role = 'agent';
|
||||
$user->assign_group = $request->group;
|
||||
$user->primary_dpt = $request->primary_department;
|
||||
$user->save();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type $id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function changeRoleUser($id)
|
||||
{
|
||||
try {
|
||||
$ticket = Tickets::where('assigned_to', '=', $id)->where('status', '=', '1')->get();
|
||||
if ($ticket) {
|
||||
$ticket = Tickets::where('assigned_to', '=', $id)->update(['assigned_to' => null]);
|
||||
}
|
||||
$user = User::whereId($id)->first();
|
||||
$user->role = 'user';
|
||||
$user->assign_group = null;
|
||||
$user->primary_dpt = null;
|
||||
$user->remember_token = null;
|
||||
$user->save();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', $e->getMessage());
|
||||
}
|
||||
// return 'Agent Role Successfully Change to User';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type $id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function deleteAgent($id)
|
||||
{
|
||||
// try {
|
||||
$delete_all = Input::get('delete_all');
|
||||
$users = User::where('id', '=', $id)->first();
|
||||
if ($users->role == 'user') {
|
||||
if ($delete_all == null || $delete_all == 1) {
|
||||
$tickets = Tickets::where('user_id', '=' ,$id)->get();
|
||||
if(count($tickets) > 0) {
|
||||
foreach ($tickets as $ticket) {
|
||||
$notification = Notification::select('id')->where('model_id', '=', $ticket->id)->get();
|
||||
foreach ($notification as $id) {
|
||||
$user_notification = UserNotification::where(
|
||||
'notification_id', '=', $id->id);
|
||||
$user_notification->delete();
|
||||
}
|
||||
$notification = Notification::select('id')->where('model_id', '=', $ticket->id);
|
||||
$notification->delete();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $ticket->id)->get();
|
||||
foreach ($thread as $th_id) {
|
||||
// echo $th_id->id." ";
|
||||
$attachment = Ticket_attachments::where('thread_id', '=', $th_id->id)->get();
|
||||
if (count($attachment)) {
|
||||
foreach ($attachment as $a_id) {
|
||||
Ticket_attachments::where('id','=', $a_id->id)
|
||||
->delete();
|
||||
}
|
||||
// echo "<br>";
|
||||
}
|
||||
$thread = Ticket_Thread::find($th_id->id);
|
||||
// dd($thread);
|
||||
$thread->delete();
|
||||
}
|
||||
$collaborators = Ticket_Collaborator::where('ticket_id', '=', $ticket->id)->get();
|
||||
if (count($collaborators)) {
|
||||
foreach ($collaborators as $collab_id) {
|
||||
echo $collab_id->id;
|
||||
$collab = Ticket_Collaborator::where('id', '=', $collab_id->id)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
$tickets = Tickets::find($ticket->id);
|
||||
$tickets->delete();
|
||||
}
|
||||
}
|
||||
$organization = User_org::where('user_id', '=', $users->id)->delete();
|
||||
$user = User::where('id', '=', $users->id)
|
||||
->delete();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.user_delete_successfully'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($users->role == 'agent') {
|
||||
if ($delete_all == null) {
|
||||
$UserEmail = Input::get('assign_to');
|
||||
$assign_to = explode('_', $UserEmail);
|
||||
$ticket = Tickets::where('assigned_to', '=', $id)->where('status', '=', '1')->get();
|
||||
if ($assign_to[0] == 'user') {
|
||||
if ($users->id == $assign_to[1]) {
|
||||
return redirect('user')->with('warning', Lang::get('lang.select_another_user'));
|
||||
}
|
||||
$user_detail = User::where('id', '=', $assign_to[1])->first();
|
||||
$assignee = $user_detail->first_name.' '.$user_detail->last_name;
|
||||
$ticket_logic1 = Tickets::where('assigned_to', '=', $id)
|
||||
->update(['assigned_to' => $assign_to[1]]);
|
||||
if ($ticket_logic2 = Tickets::where('user_id', '=', $id)->get()) {
|
||||
$ticket_logic2 = Tickets::where('user_id', '=', $id)->update(['user_id' => $assign_to[1]]);
|
||||
}
|
||||
if ($ticket_logic3 = Ticket_Thread::where('user_id', '=', $id)->get()) {
|
||||
$ticket_logic3 = Ticket_Thread::where('user_id', '=', $id)->update(['user_id' => $assign_to[1]]);
|
||||
}
|
||||
if ($ticket_logic4 = User_org::where('user_id', '=', $id)->get()) {
|
||||
$ticket_logic4 = User_org::where('user_id', '=', $id)->update(['user_id' => $assign_to[1]]);
|
||||
}
|
||||
|
||||
// $thread2 = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first();
|
||||
// $thread2->body = 'This Ticket have been Reassigned to' .' '. $assignee;
|
||||
// $thread2->save();
|
||||
// UserNotification::where('notification_id', '=', $ticket->id)->delete();
|
||||
// $users = User::where('id', '=', $id)->get();
|
||||
// $organization = User_org::where('user_id', '=', $id)->delete();
|
||||
Assign_team_agent::where('agent_id', '=', $id)->update(['agent_id' => $assign_to[1]]);
|
||||
$user = User::find($id);
|
||||
$user->delete();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully_and_ticket_assign_to_another_user'));
|
||||
}
|
||||
if (User_org::where('user_id', '=', $id)) {
|
||||
DB::table('user_assign_organization')->where('user_id', '=', $id)->delete();
|
||||
}
|
||||
$user = User::find($id);
|
||||
$user->delete();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
|
||||
} elseif ($delete_all == 1) {
|
||||
if ($ticket = Tickets::where('user_id', '=', $id)->first()) {
|
||||
$ticket_assign = $ticket->assigned_to;
|
||||
Ticket_Thread::where('ticket_id', '=', $ticket->id)->delete();
|
||||
if ($ticket->user_id = $id) {
|
||||
Tickets::where('user_id', '=', $id)->delete();
|
||||
}
|
||||
if ($ticket_assign) {
|
||||
UserNotification::where('notification_id', '=', $ticket_assign)->delete();
|
||||
}
|
||||
UserNotification::where('notification_id', '=', $ticket->id)->delete();
|
||||
$users = User::where('id', '=', $id)->get();
|
||||
$user = User::find($id);
|
||||
$user->delete();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
|
||||
} else {
|
||||
Assign_team_agent::where('agent_id', '=', $id)->delete();
|
||||
User_org::where('user_id', '=', $id)->delete();
|
||||
$user = User::find($id);
|
||||
$user->delete();
|
||||
|
||||
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
// } catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
// return redirect('user')->with('fails', $e->getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified users.
|
||||
*
|
||||
@@ -239,11 +545,12 @@ class UserController extends Controller
|
||||
public function show($id)
|
||||
{
|
||||
try {
|
||||
$user = new User();
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
|
||||
$users = User::where('id', '=', $id)->first();
|
||||
if (count($users) > 0) {
|
||||
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', Lang::get('lang.user-not-found'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -260,13 +567,17 @@ class UserController extends Controller
|
||||
public function edit($id, CountryCode $code)
|
||||
{
|
||||
try {
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
|
||||
$user = new User();
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
$org = Organization::lists('name', 'id')->toArray();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.edit', compact('users'))->with('phonecode', $phonecode->phonecode);
|
||||
return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'org', '$settings', '$email_mandatory'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -302,6 +613,8 @@ class UserController extends Controller
|
||||
}
|
||||
// dd($request->input());
|
||||
$users->fill($request->input())->save();
|
||||
$orgid = $request->input('org_id');
|
||||
$this->storeUserOrgRelation($users->id, $orgid);
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', Lang::get('lang.User-profile-Updated-Successfully'));
|
||||
} catch (Exception $e) {
|
||||
@@ -335,8 +648,12 @@ class UserController extends Controller
|
||||
$user = Auth::user();
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$status = $settings->status;
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'))->with('phonecode', $phonecode->phonecode);
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'))
|
||||
->with(['phonecode' => $phonecode->phonecode,
|
||||
'verify' => $status, ]);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -391,7 +708,13 @@ class UserController extends Controller
|
||||
}
|
||||
$user->country_code = $request->country_code;
|
||||
}
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
$user->fill($request->except('profile_pic', 'gender', 'mobile'))->save();
|
||||
if ($request->get('mobile')) {
|
||||
$user->mobile = $request->get('mobile');
|
||||
} else {
|
||||
$user->mobile = null;
|
||||
}
|
||||
$user->save();
|
||||
|
||||
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
@@ -533,4 +856,126 @@ class UserController extends Controller
|
||||
// return random string
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
public function storeUserOrgRelation($userid, $orgid)
|
||||
{
|
||||
$org_relations = new User_org();
|
||||
$org_relation = $org_relations->where('user_id', $userid)->first();
|
||||
if ($org_relation) {
|
||||
$org_relation->delete();
|
||||
}
|
||||
$org_relations->create([
|
||||
'user_id' => $userid,
|
||||
'org_id' => $orgid,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getExportUser()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.export');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function exportUser(Request $request)
|
||||
{
|
||||
try {
|
||||
$date = $request->input('date');
|
||||
$date = str_replace(' ', '', $date);
|
||||
$date_array = explode(':', $date);
|
||||
$first = $date_array[0].' 00:00:00';
|
||||
$second = $date_array[1].' 23:59:59';
|
||||
$first_date = $this->convertDate($first);
|
||||
$second_date = $this->convertDate($second);
|
||||
$users = $this->getUsers($first_date, $second_date);
|
||||
$excel_controller = new \App\Http\Controllers\Common\ExcelController();
|
||||
$filename = 'users'.$date;
|
||||
$excel_controller->export($filename, $users);
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function convertDate($date)
|
||||
{
|
||||
$converted_date = date('Y-m-d H:i:s', strtotime($date));
|
||||
|
||||
return $converted_date;
|
||||
}
|
||||
|
||||
public function getUsers($first, $last)
|
||||
{
|
||||
$user = new User();
|
||||
$users = $user->leftJoin('user_assign_organization', 'users.id', '=', 'user_assign_organization.user_id')
|
||||
->leftJoin('organization', 'user_assign_organization.org_id', '=', 'organization.id')
|
||||
->whereBetween('users.created_at', [$first, $last])
|
||||
->where('role', 'user')
|
||||
->where('active', 1)
|
||||
->select('users.user_name as Username', 'users.email as Email', 'users.first_name as Fisrtname', 'users.last_name as Lastname', 'organization.name as Organization')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function resendOTP(OtpVerifyRequest $request)
|
||||
{
|
||||
if (\Schema::hasTable('sms')) {
|
||||
$sms = DB::table('sms')->get();
|
||||
if (count($sms) > 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return 'Plugin has not been setup successfully.';
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyOTP()
|
||||
{
|
||||
// dd(Input::all());
|
||||
// $user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))->first();
|
||||
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', Input::get('u_id'))
|
||||
->first();
|
||||
if ($otp != null) {
|
||||
$otp_length = strlen(Input::get('otp'));
|
||||
if (($otp_length == 6 && !preg_match('/[a-z]/i', Input::get('otp')))) {
|
||||
$otp2 = Hash::make(Input::get('otp'));
|
||||
$date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
|
||||
$date2 = date('Y-m-d h:i:sa');
|
||||
$time1 = new DateTime($date2);
|
||||
$time2 = new DateTime($date1);
|
||||
$interval = $time1->diff($time2);
|
||||
if ($interval->i > 10 || $interval->h > 0) {
|
||||
$message = Lang::get('lang.otp-expired');
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
if (Hash::check(Input::get('otp'), $otp->otp)) {
|
||||
Otp::where('user_id', '=', Input::get('u_id'))
|
||||
->update(['otp' => '']);
|
||||
// User::where('id', '=', $user->id)
|
||||
// ->update(['active' => 1]);
|
||||
// $this->openTicketAfterVerification($user->id);
|
||||
return 1;
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-invalid');
|
||||
|
||||
return $message;
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -138,19 +138,20 @@ class SettingsController extends Controller
|
||||
public function getData()
|
||||
{
|
||||
return \Datatable::collection(Comment::All())
|
||||
->searchColumns('name', 'email', 'comment', 'created')
|
||||
->orderColumns('name')
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
->addColumn('email', function ($model) {
|
||||
return $model->email;
|
||||
})
|
||||
->addColumn('website', function ($model) {
|
||||
return $model->website;
|
||||
->searchColumns('details', 'comment', 'created')
|
||||
->orderColumns('details')
|
||||
->addColumn('details', function ($model) {
|
||||
$name = "<p>$model->name</p><br>";
|
||||
$email = "<p>$model->email</p><br>";
|
||||
$website = "<p>$model->website</p><br>";
|
||||
|
||||
return $name.$email.$website;
|
||||
})
|
||||
|
||||
->addColumn('comment', function ($model) {
|
||||
return $model->comment;
|
||||
$created = TicketController::usertimezone(date($model->created_at));
|
||||
|
||||
return $model->comment."<p>$created</p>";
|
||||
})
|
||||
->addColumn('status', function ($model) {
|
||||
$status = $model->status;
|
||||
@@ -160,11 +161,9 @@ class SettingsController extends Controller
|
||||
return '<p style="color:red"">'.\Lang::get('lang.not_published');
|
||||
}
|
||||
})
|
||||
->addColumn('Created', function ($model) {
|
||||
return TicketController::usertimezone(date($model->created_at));
|
||||
})
|
||||
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<a href=comment/delete/'.$model->id.' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a> <a href=published/'.$model->id.' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a>';
|
||||
return '<div class="row"><div class="col-md-12"><a href=comment/delete/'.$model->id.' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a></div><div class="col-md-12"><a href=published/'.$model->id.' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a></div></div>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
//use Illuminate\Support\Facades\Request as Value;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
@@ -119,24 +120,9 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function createTicket()
|
||||
public function createTicket(\App\Http\Requests\helpdesk\CreateTicketRequest $request, \App\Model\helpdesk\Utility\CountryCode $code)
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'subject' => 'required',
|
||||
'body' => 'required',
|
||||
'helptopic' => 'required|exists:help_topic,id',
|
||||
'sla' => 'required|exists:sla_plan,id',
|
||||
'priority' => 'required|exists:ticket_priority,priority_id',
|
||||
'dept' => 'required|exists:department,id',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
$error = $v->errors();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
|
||||
$user_id = $this->request->input('user_id');
|
||||
|
||||
$subject = $this->request->input('subject');
|
||||
@@ -159,15 +145,19 @@ class ApiController extends Controller
|
||||
/*
|
||||
* return s ticket number
|
||||
*/
|
||||
$response = $this->ticket->createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach);
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$core = new CoreTicketController($PhpMailController, $NotificationController);
|
||||
$response = $core->post_newticket($request, $code, true);
|
||||
//$response = $this->ticket->createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach);
|
||||
//return $response;
|
||||
/*
|
||||
* return ticket details
|
||||
*/
|
||||
//dd($response);
|
||||
$result = $this->thread->where('id', $response)->first();
|
||||
//$result = $this->thread->where('id', $response)->first();
|
||||
//$result = $this->attach($result->id,$file);
|
||||
return response()->json(compact('result'));
|
||||
return response()->json(compact('response'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
@@ -347,6 +337,7 @@ class ApiController extends Controller
|
||||
//dd('sdhjbc');
|
||||
// $result = $this->model->where('assigned_to', '=', null)->where('status', '1')->orderBy('id', 'DESC')->get();
|
||||
// return response()->json(compact('result'));
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$unassigned = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->whereNull('assigned_to')->where('status', '=', 1);
|
||||
@@ -361,6 +352,11 @@ class ApiController extends Controller
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->where(function ($query) use ($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
})
|
||||
->orderBy('updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
@@ -391,7 +387,7 @@ class ApiController extends Controller
|
||||
try {
|
||||
// $result = $this->model->where('status', '>', 1)->where('status', '<', 4)->orderBy('id', 'DESC')->get();
|
||||
// return response()->json(compact('result'));
|
||||
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$result = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('status', '=', 3)->orWhere('status', '=', 2);
|
||||
@@ -406,6 +402,11 @@ class ApiController extends Controller
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->where(function ($query) use ($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
})
|
||||
->orderBy('updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
@@ -946,6 +947,7 @@ class ApiController extends Controller
|
||||
public function inbox()
|
||||
{
|
||||
try {
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$inbox = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('status', '=', 1);
|
||||
@@ -959,7 +961,12 @@ class ApiController extends Controller
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('ticket_thread.title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'ticket_thread.title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'ticket_thread.title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name', 'department.id as department_id', 'users.primary_dpt as user_dpt')
|
||||
->where(function ($query) use ($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
})
|
||||
->orderBy('updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
@@ -1021,6 +1028,7 @@ class ApiController extends Controller
|
||||
public function getTrash()
|
||||
{
|
||||
try {
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$trash = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('status', '=', 5);
|
||||
@@ -1035,6 +1043,11 @@ class ApiController extends Controller
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->where(function ($query) use ($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
})
|
||||
->orderBy('updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
@@ -1072,9 +1085,10 @@ class ApiController extends Controller
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
//$user = \JWTAuth::parseToken()->authenticate();
|
||||
$result = $this->user->join('tickets', function ($join) use ($id) {
|
||||
$join->on('users.id', '=', 'tickets.assigned_to')
|
||||
->where('status', '=', 1);
|
||||
->where('status', '=', 1);
|
||||
//->where('user_id', '=', $id);
|
||||
})
|
||||
->join('department', 'department.id', '=', 'tickets.dept_id')
|
||||
@@ -1088,6 +1102,11 @@ class ApiController extends Controller
|
||||
})
|
||||
->where('users.id', $id)
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
// ->where(function($query) use($user) {
|
||||
// if ($user->role != 'admin') {
|
||||
// $query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
// }
|
||||
// })
|
||||
->orderBy('updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
@@ -1182,9 +1201,9 @@ class ApiController extends Controller
|
||||
->where('tickets.id', '=', $id);
|
||||
});
|
||||
$response = $this->differenciateHelpTopic($query);
|
||||
//$select = 'users.email','users.user_name','users.first_name','users.last_name','tickets.id','ticket_number','num_sequence','user_id','priority_id','sla','max_open_ticket','captcha','status','lock_by','lock_at','source','isoverdue','reopened','isanswered','is_deleted', 'closed','is_transfer','transfer_at','reopened_at','duedate','closed_at','last_message_at','last_response_at';
|
||||
//$select = 'users.email','users.user_name','users.first_name','users.last_name','tickets.id','ticket_number','num_sequence','user_id','priority_id','sla','max_open_ticket','captcha','status','lock_by','lock_at','source','isoverdue','reopened','isanswered','is_deleted', 'closed','is_transfer','transfer_at','reopened_at','duedate','closed_at','last_message_at';
|
||||
|
||||
$result = $response->addSelect('users.email', 'users.user_name', 'users.first_name', 'users.last_name', 'tickets.id', 'ticket_number', 'user_id', 'priority_id', 'sla', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'reopened_at', 'duedate', 'closed_at', 'last_message_at', 'last_response_at', 'tickets.created_at', 'tickets.updated_at')->first();
|
||||
$result = $response->addSelect('users.email', 'users.user_name', 'users.first_name', 'users.last_name', 'tickets.id', 'ticket_number', 'user_id', 'priority_id', 'sla', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'reopened_at', 'duedate', 'closed_at', 'tickets.created_at', 'tickets.updated_at')->first();
|
||||
|
||||
return response()->json(compact('result'));
|
||||
} catch (\Exception $e) {
|
||||
|
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// Requests
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
// Models
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
use FCM;
|
||||
// classes
|
||||
use Illuminate\Http\Request;
|
||||
use LaravelFCM\Message\OptionsBuilder;
|
||||
use LaravelFCM\Message\PayloadDataBuilder;
|
||||
use LaravelFCM\Message\PayloadNotificationBuilder;
|
||||
use LaravelFCM\Response\DownstreamResponse;
|
||||
|
||||
/**
|
||||
* **********************************************
|
||||
* PushNotificationController
|
||||
* **********************************************
|
||||
* This controller is used to send notification to FCM cloud which later will
|
||||
* foreward notification to Mobile Application.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PushNotificationController extends Controller
|
||||
{
|
||||
public function Response($token, $body, $ticket_id = null)
|
||||
{
|
||||
$optionBuiler = new OptionsBuilder();
|
||||
$optionBuiler->setTimeToLive(60 * 60);
|
||||
|
||||
$notificationBuilder = new PayloadNotificationBuilder();
|
||||
$notificationBuilder->setBody($body)
|
||||
->setSound('default')
|
||||
->setIcon('ic_stat_f1')
|
||||
->setClickAction('OPEN_ACTIVITY_1');
|
||||
|
||||
if ($ticket_id != null) {
|
||||
$ticket_data = Tickets::where('id', '=', $ticket_id)->first();
|
||||
$thread_data = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first();
|
||||
$dataBuilder = new PayloadDataBuilder();
|
||||
$dataBuilder->addData(['ticket_id' => $ticket_id]);
|
||||
$dataBuilder->addData(['ticket_number' => $ticket_data->ticket_number]);
|
||||
$dataBuilder->addData(['ticket_opened_by' => $ticket_data->user_id]);
|
||||
$dataBuilder->addData(['ticket_subject' => $thread_data->title]);
|
||||
}
|
||||
|
||||
$option = $optionBuiler->build();
|
||||
$notification = $notificationBuilder->build();
|
||||
$data = $dataBuilder->build();
|
||||
|
||||
$tokens = $token;
|
||||
|
||||
$downstreamResponse = FCM::sendTo($tokens, $option, $notification, $data);
|
||||
|
||||
// $downstreamResponse = new DownstreamResponse($response, $tokens);
|
||||
|
||||
// dd($downstreamResponse);
|
||||
$downstreamResponse->numberSuccess();
|
||||
$downstreamResponse->numberFailure();
|
||||
$downstreamResponse->numberModification();
|
||||
// return Array - you must remove all this tokens in your database
|
||||
$downstreamResponse->tokensToDelete();
|
||||
// return Array (key : oldToken, value : new token - you must change the token in your database )
|
||||
$downstreamResponse->tokensToModify();
|
||||
// return Array - you should try to resend the message to the tokens in the array
|
||||
$downstreamResponse->tokensToRetry();
|
||||
// return Array (key:token, value:errror) - in production you should remove from your database the tokens
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get the fcm token from the api under a user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function fcmToken(Request $request, User $user)
|
||||
{
|
||||
// get the requested details
|
||||
$user_id = $request->input('user_id');
|
||||
$fcm_token = $request->input('fcm_token');
|
||||
// check for all the valid details
|
||||
if ($user_id != null && $user_id != '' && $fcm_token != null && $fcm_token != '') {
|
||||
// search the user_id in database
|
||||
$user = $user->where('id', '=', $user_id)->first();
|
||||
if ($user != null) {
|
||||
$user->fcm_token = $fcm_token;
|
||||
$user->save();
|
||||
// success response for success case
|
||||
return ['response' => 'success'];
|
||||
} else {
|
||||
// failure respunse for invalid user_id in the system
|
||||
return ['response' => 'fail', 'reason' => 'Invalid user_id'];
|
||||
}
|
||||
} else {
|
||||
// failure respunse for invalid input credentials
|
||||
return ['response' => 'fail', 'reason' => 'Invalid Credentials'];
|
||||
}
|
||||
}
|
||||
}
|
@@ -108,8 +108,6 @@ class TicketController extends Controller
|
||||
|
||||
return $thread;
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
@@ -3,20 +3,29 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Admin\helpdesk\SocialMedia\SocialMediaController;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\LoginRequest;
|
||||
use App\Http\Requests\helpdesk\OtpVerifyRequest;
|
||||
use App\Http\Requests\helpdesk\RegisterRequest;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Plugin;
|
||||
use App\Model\helpdesk\Settings\Security;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
// classes
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\Otp;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Hash;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use Socialite;
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------
|
||||
@@ -40,6 +49,7 @@ class AuthController extends Controller
|
||||
/* Direct After Logout */
|
||||
protected $redirectAfterLogout = '/';
|
||||
protected $loginPath = '/auth/login';
|
||||
protected $social;
|
||||
|
||||
/**
|
||||
* Create a new authentication controller instance.
|
||||
@@ -49,10 +59,62 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
public function __construct(PhpMailController $PhpMailController, SocialMediaController $social)
|
||||
{
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
$social->configService();
|
||||
$this->middleware('guest', ['except' => ['getLogout', 'verifyOTP', 'redirectToProvider']]);
|
||||
}
|
||||
|
||||
public function redirectToProvider($provider, $redirect = '')
|
||||
{
|
||||
if ($redirect !== '') {
|
||||
$this->setSession($provider, $redirect);
|
||||
}
|
||||
//dd(\Config::get('services'));
|
||||
$s = Socialite::driver($provider)->redirect();
|
||||
//dd('dscd');
|
||||
return $s;
|
||||
}
|
||||
|
||||
public function handleProviderCallback($provider)
|
||||
{
|
||||
try {
|
||||
//notice we are not doing any validation, you should do it
|
||||
$this->changeRedirect();
|
||||
|
||||
$user = Socialite::driver($provider)->user();
|
||||
if ($user) {
|
||||
// stroing data to our use table and logging them in
|
||||
$username = $user->getEmail();
|
||||
$first_name = $user->getName();
|
||||
if ($user->nickname) {
|
||||
$username = $user->nickname;
|
||||
}
|
||||
if (!$first_name) {
|
||||
$first_name = $username;
|
||||
}
|
||||
$data = [
|
||||
'first_name' => $first_name,
|
||||
'email' => $user->getEmail(),
|
||||
'user_name' => $username,
|
||||
'role' => 'user',
|
||||
'active' => 1,
|
||||
];
|
||||
$user = User::where('email', $data['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::where('user_name', $data['user_name'])->first();
|
||||
}
|
||||
if (!$user) {
|
||||
$user = User::firstOrCreate($data);
|
||||
}
|
||||
Auth::login($user);
|
||||
}
|
||||
//after login redirecting to home page
|
||||
return redirect('/');
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,9 +122,12 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getRegister()
|
||||
public function getRegister(CommonSettings $settings)
|
||||
{
|
||||
// Event for login
|
||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
//dd($settings->status);
|
||||
\Event::fire(new \App\Events\FormRegisterEvent());
|
||||
if (Auth::user()) {
|
||||
if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') {
|
||||
@@ -71,7 +136,7 @@ class AuthController extends Controller
|
||||
// return view('auth.register');
|
||||
}
|
||||
} else {
|
||||
return view('auth.register');
|
||||
return view('auth.register', compact('settings', 'email_mandatory'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,27 +150,59 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function postRegister(User $user, RegisterRequest $request)
|
||||
{
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
$request_array = $request->input();
|
||||
$password = Hash::make($request->input('password'));
|
||||
$user->password = $password;
|
||||
$name = $request->input('full_name');
|
||||
$user->first_name = $name;
|
||||
$user->user_name = $request->input('email');
|
||||
$user->email = $request->input('email');
|
||||
|
||||
if ($request_array['email'] == '') {
|
||||
$user->email = null;
|
||||
} else {
|
||||
$user->email = $request->input('email');
|
||||
}
|
||||
if ($request_array['mobile'] == '') {
|
||||
$user->mobile = null;
|
||||
} else {
|
||||
$user->mobile = $request->input('mobile');
|
||||
}
|
||||
if ($request_array['code'] == '') {
|
||||
$user->country_code = 0;
|
||||
} else {
|
||||
$user->country_code = $request->input('code');
|
||||
}
|
||||
if ($request_array['email'] != '') {
|
||||
$user->user_name = $request->input('email');
|
||||
} else {
|
||||
$user->user_name = $request->input('mobile');
|
||||
}
|
||||
$user->role = 'user';
|
||||
$code = str_random(60);
|
||||
$user->remember_token = $code;
|
||||
$user->save();
|
||||
$message12 = '';
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/'.$code)]);
|
||||
if ($var == null) {
|
||||
$message12 = Lang::get('lang.failed_to_send_email_contact_administrator');
|
||||
|
||||
return redirect('home')->with('warning', $message12);
|
||||
return redirect('home')->with('fails', $message12);
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
|
||||
if ($settings->status == 1 || $settings->status == '1') {
|
||||
if (count($sms) > 0) {
|
||||
if ($sms->status == 1 || $sms->status == '1') {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_and_moble');
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_sms_plugin_inactive_or_not_setup');
|
||||
}
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_sms_plugin_inactive_or_not_setup');
|
||||
}
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
|
||||
}
|
||||
}
|
||||
|
||||
return redirect('home')->with('success', $message12);
|
||||
@@ -125,6 +222,7 @@ class AuthController extends Controller
|
||||
$user->active = 1;
|
||||
$user->remember_token = null;
|
||||
$user->save();
|
||||
$this->openTicketAfterVerification($user->id);
|
||||
|
||||
return redirect('/auth/login')->with('status', 'Acount activated. Login to start');
|
||||
} else {
|
||||
@@ -185,18 +283,24 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function postLogin(LoginRequest $request)
|
||||
{
|
||||
// dd($request->input());
|
||||
\Event::fire('auth.login.event', []); //added 5/5/2016
|
||||
// Set login attempts and login time
|
||||
$value = $_SERVER['REMOTE_ADDR'];
|
||||
$usernameinput = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
if ($request->input('referer')) {
|
||||
$referer = 'form';
|
||||
} else {
|
||||
$referer = '/';
|
||||
}
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
$result = $this->confirmIPAddress($value, $usernameinput);
|
||||
// If attempts > 3 and time < 30 minutes
|
||||
$security = Security::whereId('1')->first();
|
||||
//dd($security->lockout_message);
|
||||
if ($result == 1) {
|
||||
return redirect()->back()->withErrors('email', 'Incorrect details')->with('error', $security->lockout_message);
|
||||
return redirect()->back()->withErrors('email', 'Incorrect details')->with(['error' => $security->lockout_message, 'referer' => $referer]);
|
||||
}
|
||||
//dd($request->input('email'));
|
||||
$check_active = User::where('email', '=', $request->input('email'))->orwhere('user_name', '=', $request->input('email'))->first();
|
||||
@@ -204,17 +308,32 @@ class AuthController extends Controller
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.this_account_is_currently_inactive'));
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.not-registered'),
|
||||
'referer' => $referer, ]);
|
||||
}
|
||||
if ($check_active->active == 0) {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.this_account_is_currently_inactive'));
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
if ($settings->status == '0' || $settings->status == 0) {
|
||||
if ($check_active->active == 0) {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.this_account_is_currently_inactive'),
|
||||
'referer' => $referer, ]);
|
||||
}
|
||||
} else {
|
||||
if ($check_active->active == 0 && !$check_active->mobile) {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.this_account_is_currently_inactive'),
|
||||
'referer' => $referer, ]);
|
||||
}
|
||||
}
|
||||
$loginAttempts = 1;
|
||||
// If session has login attempts, retrieve attempts counter and attempts time
|
||||
@@ -227,10 +346,9 @@ class AuthController extends Controller
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
// If attempts > 3 and time < 10 minutes
|
||||
if ($loginAttempts > $security->backlist_threshold && (time() - $loginAttemptTime <= ($security->lockout_period * 60))) {
|
||||
//
|
||||
return redirect()->back()->withErrors('email', 'incorrect email')->with('error', $security->lockout_message);
|
||||
}
|
||||
if ($loginAttempts > $security->backlist_threshold && (time() - $loginAttemptTime <= ($security->lockout_period * 60))) {
|
||||
return redirect()->back()->withErrors('email', 'incorrect email')->with('error', $security->lockout_message);
|
||||
}
|
||||
// If time > 10 minutes, reset attempts counter and time in session
|
||||
if (time() - $loginAttemptTime > ($security->lockout_period * 60)) {
|
||||
\Session::put('loginAttempts', 1);
|
||||
@@ -245,7 +363,23 @@ class AuthController extends Controller
|
||||
\Session::put('loginAttempts', $loginAttempts + 1);
|
||||
|
||||
if (Auth::Attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) {
|
||||
if ($check_active->active == 0) {
|
||||
\Auth::logout();
|
||||
\Session::flush();
|
||||
|
||||
return \Redirect::route('otp-verification')
|
||||
->withInput($request->input())
|
||||
->with(['values' => $request->input(),
|
||||
'referer' => $referer,
|
||||
'name' => $check_active->first_name,
|
||||
'number' => $check_active->mobile,
|
||||
'code' => $check_active->country_code, ]);
|
||||
}
|
||||
if (Auth::user()->role == 'user') {
|
||||
if ($request->input('referer')) {
|
||||
return \Redirect::route($request->input('referer'));
|
||||
}
|
||||
|
||||
return \Redirect::route('/');
|
||||
} else {
|
||||
return redirect()->intended($this->redirectPath());
|
||||
@@ -255,9 +389,10 @@ class AuthController extends Controller
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.invalid'));
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.invalid'),
|
||||
'referer' => $referer, ]);
|
||||
// Increment login attempts
|
||||
}
|
||||
|
||||
@@ -345,4 +480,137 @@ class AuthController extends Controller
|
||||
{
|
||||
return Lang::get('lang.this_field_do_not_match_our_records');
|
||||
}
|
||||
|
||||
/**
|
||||
*@category function to show verify OTP page
|
||||
*
|
||||
*@param null
|
||||
*
|
||||
*@return response|view
|
||||
*/
|
||||
public function getVerifyOTP()
|
||||
{
|
||||
if (\Session::has('values')) {
|
||||
return view('auth.otp-verify');
|
||||
} else {
|
||||
return redirect('auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@category function to verify OTP
|
||||
*
|
||||
*@param $request
|
||||
*
|
||||
*@return int|string
|
||||
*/
|
||||
public function verifyOTP(LoginRequest $request)
|
||||
{
|
||||
$user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))
|
||||
->orWhere('user_name', '=', $request->input('email'))->first();
|
||||
$otp_length = strlen($request->input('otp'));
|
||||
if (!\Schema::hasTable('user_verification')) {
|
||||
$message = Lang::get('lang.opt-can-not-be-verified');
|
||||
} else {
|
||||
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', $user->id)
|
||||
->first();
|
||||
if ($otp != null) {
|
||||
if (($otp_length == 6 && !preg_match('/[a-z]/i', $request->input('otp')))) {
|
||||
$otp2 = Hash::make($request->input('otp'));
|
||||
$date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
|
||||
$date2 = date('Y-m-d h:i:sa');
|
||||
$time1 = new DateTime($date2);
|
||||
$time2 = new DateTime($date1);
|
||||
$interval = $time1->diff($time2);
|
||||
if ($interval->i > 30 || $interval->h > 0) {
|
||||
$message = Lang::get('lang.otp-expired');
|
||||
} else {
|
||||
if (Hash::check($request->input('otp'), $otp->otp)) {
|
||||
Otp::where('user_id', '=', $user->id)
|
||||
->update(['otp' => '']);
|
||||
User::where('id', '=', $user->id)
|
||||
->update(['active' => 1]);
|
||||
$this->openTicketAfterVerification($user->id);
|
||||
|
||||
return $this->postLogin($request);
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-invalid');
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
}
|
||||
}
|
||||
|
||||
return \Redirect::route('otp-verification')
|
||||
->withInput($request->input())
|
||||
->with(['values' => $request->input(),
|
||||
'number' => $user->mobile,
|
||||
'name' => $user->user_name,
|
||||
'fails' => $message, ]);
|
||||
}
|
||||
|
||||
public function resendOTP(OtpVerifyRequest $request)
|
||||
{
|
||||
if (!\Schema::hasTable('user_verification') || !\Schema::hasTable('sms')) {
|
||||
$message = Lang::get('lang.opt-can-not-be-verified');
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
$sms = DB::table('sms')->get();
|
||||
if (count($sms) > 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$message = Lang::get('lang.opt-can-not-be-verified');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @category function to change ticket status when user verifies his account
|
||||
*
|
||||
* @param int $id => user_id
|
||||
*
|
||||
* @return null
|
||||
*
|
||||
* @author manish.verma@ladybirdweb.com
|
||||
*/
|
||||
public function openTicketAfterVerification($id)
|
||||
{
|
||||
// dd($id);
|
||||
$ticket = Tickets::select('id')
|
||||
->where(['user_id' => $id, 'status' => 6])
|
||||
->get();
|
||||
Tickets::where(['user_id' => $id, 'status' => 6])
|
||||
->update(['status' => 1]);
|
||||
if ($ticket != null) {
|
||||
foreach ($ticket as $value) {
|
||||
$ticket_id = $value->id;
|
||||
Ticket_Thread::where('ticket_id', '=', $ticket_id)
|
||||
->update(['updated_at' => date('Y-m-d H:i:s')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function changeRedirect()
|
||||
{
|
||||
$provider = \Session::get('provider');
|
||||
$url = \Session::get($provider.'redirect');
|
||||
\Config::set("services.$provider.redirect", $url);
|
||||
}
|
||||
|
||||
public function setSession($provider, $redirect)
|
||||
{
|
||||
$url = url($redirect);
|
||||
\Session::set('provider', $provider);
|
||||
\Session::set($provider.'redirect', $url);
|
||||
$this->changeRedirect();
|
||||
}
|
||||
}
|
||||
|
@@ -51,9 +51,9 @@ class PasswordController extends Controller
|
||||
public function postEmail(Request $request)
|
||||
{
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$this->validate($request, ['email' => 'required|email']);
|
||||
$this->validate($request, ['email' => 'required']);
|
||||
\Event::fire('reset.password', []);
|
||||
$user = User::where('email', '=', $request->only('email'))->first();
|
||||
$user = User::where('email', '=', $request->only('email'))->orWhere('mobile', '=', $request->only('email'))->first();
|
||||
if (isset($user)) {
|
||||
$user1 = $user->email;
|
||||
//gen new code and pass
|
||||
@@ -66,11 +66,66 @@ class PasswordController extends Controller
|
||||
} else {
|
||||
$create_password_reset = \DB::table('password_resets')->insert(['email' => $user->email, 'token' => $code, 'created_at' => $date]);
|
||||
}
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user->user_name, 'email' => $user->email], $message = ['subject' => 'Your Password Reset Link', 'scenario' => 'reset-password'], $template_variables = ['user' => $user->first_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)]);
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user->user_name, 'email' => $user->email], $message = ['subject' => 'Your Password Reset Link', 'scenario' => 'reset-password'], $template_variables = ['user' => $user->first_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)], true);
|
||||
if ($user->mobile != '' && $user->mobile != null) {
|
||||
if ($user->first_name) {
|
||||
$name = $user->first_name;
|
||||
} else {
|
||||
$name = $user->user_name;
|
||||
}
|
||||
$value = [
|
||||
'url' => url('password/reset/'.$code),
|
||||
'name' => $name,
|
||||
'mobile' => $user->mobile,
|
||||
'code' => $user->country_code, ];
|
||||
\Event::fire('reset.password2', [$value]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('status', Lang::get('lang.we_have_e-mailed_your_password_reset_link'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', Lang::get("lang.we_can't_find_a_user_with_that_e-mail_address"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the given user's password.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function reset(Request $request)
|
||||
{
|
||||
$this->validate(
|
||||
$request,
|
||||
$this->getResetValidationRules(),
|
||||
$this->getResetValidationMessages(),
|
||||
$this->getResetValidationCustomAttributes()
|
||||
);
|
||||
$credentials = $this->getResetCredentials($request);
|
||||
// dd($credentials);
|
||||
$email = $credentials['email'];
|
||||
$password = $credentials['password'];
|
||||
$token = $credentials['token'];
|
||||
$response = 'fails';
|
||||
$password_tokens = \DB::table('password_resets')->where('email', '=', $email)->first();
|
||||
if ($password_tokens) {
|
||||
if ($password_tokens->token == $token) {
|
||||
$users = new User();
|
||||
$user = $users->where('email', $email)->first();
|
||||
if ($user) {
|
||||
$user->password = \Hash::make($password);
|
||||
$user->save();
|
||||
$response = 'success';
|
||||
} else {
|
||||
$response = 'fails';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($response == 'success') {
|
||||
return redirect('/auth/login')->with('status', Lang::get('lang.password-reset-successfully'));
|
||||
} else {
|
||||
return redirect('/home')->with('fails', Lang::get('lang.password-can-not-reset'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -68,7 +68,6 @@ class ClientTicketController extends Controller
|
||||
|
||||
$fromaddress = $user_cred->email;
|
||||
$fromname = $user_cred->user_name;
|
||||
$to = '';
|
||||
$phone = '';
|
||||
$phonecode = '';
|
||||
$mobile_number = '';
|
||||
@@ -85,9 +84,7 @@ class ClientTicketController extends Controller
|
||||
$ticket_status = null;
|
||||
$auto_response = 0;
|
||||
|
||||
$inline_attachment = null;
|
||||
|
||||
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $to, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $inline_attachment);
|
||||
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
|
||||
return \Redirect::back()->with('success1', Lang::get('lang.successfully_replied'));
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Client\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
|
||||
use App\Http\Controllers\Common\FileuploadController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\ClientRequest;
|
||||
@@ -12,9 +11,11 @@ use App\Model\helpdesk\Agent\Department;
|
||||
// models
|
||||
use App\Model\helpdesk\Form\Fields;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Ticket;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
@@ -61,6 +62,11 @@ class FormController extends Controller
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
return \Redirect::route('licence');
|
||||
}
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
if (!\Auth::check() && ($settings->status == 1 || $settings->status == '1')) {
|
||||
return redirect('auth/login')->with(['login_require' => 'Please login to your account for submitting a ticket', 'referer' => 'form']);
|
||||
}
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
if (System::first()->status == 1) {
|
||||
@@ -71,12 +77,8 @@ class FormController extends Controller
|
||||
} else {
|
||||
$phonecode = '';
|
||||
}
|
||||
$fileupload = new FileuploadController();
|
||||
$fileupload = $fileupload->file_upload_max_size();
|
||||
$max_size_in_bytes = $fileupload[0];
|
||||
$max_size_in_actual = $fileupload[1];
|
||||
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'max_size_in_bytes', 'max_size_in_actual'))->with('phonecode', $phonecode);
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory'))->with('phonecode', $phonecode);
|
||||
} else {
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
@@ -112,7 +114,7 @@ class FormController extends Controller
|
||||
$vals = explode(',', $type2);
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
|
||||
foreach ($vals as $val) {
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'"> '.$val.' ';
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'"> '.$form_data->value.' ';
|
||||
}
|
||||
echo '<br/>';
|
||||
} elseif ($form_data->type == 'textarea') {
|
||||
@@ -144,16 +146,26 @@ class FormController extends Controller
|
||||
*/
|
||||
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code)
|
||||
{
|
||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token');
|
||||
|
||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token', 'mobile', 'Code');
|
||||
$name = $request->input('Name');
|
||||
$phone = $request->input('Phone');
|
||||
$email = $request->input('Email');
|
||||
$to = '';
|
||||
if ($request->input('Email')) {
|
||||
if ($request->input('Email')) {
|
||||
$email = $request->input('Email');
|
||||
} else {
|
||||
$email = null;
|
||||
}
|
||||
} else {
|
||||
$email = null;
|
||||
}
|
||||
$subject = $request->input('Subject');
|
||||
$details = $request->input('Details');
|
||||
$phonecode = $request->input('Code');
|
||||
$mobile_number = $request->input('Mobile');
|
||||
if ($request->input('mobile')) {
|
||||
$mobile_number = $request->input('mobile');
|
||||
} else {
|
||||
$mobile_number = null;
|
||||
}
|
||||
$status = $ticket_settings->first()->status;
|
||||
$helptopic = $request->input('helptopic');
|
||||
$helpTopicObj = Help_topic::where('id', '=', $helptopic);
|
||||
@@ -164,7 +176,15 @@ class FormController extends Controller
|
||||
$department = Help_topic::where('id', '=', $defaultHelpTopicID)->value('department');
|
||||
}
|
||||
$sla = $ticket_settings->first()->sla;
|
||||
$priority = $ticket_settings->first()->priority;
|
||||
|
||||
// $priority = $ticket_settings->first()->priority;
|
||||
$default_priority = Ticket_Priority::where('is_default', '=', 1)->first();
|
||||
$user_priority = CommonSettings::where('id', '=', 6)->first();
|
||||
if ($user_priority->status == 0) {
|
||||
$priority = $default_priority->priority_id;
|
||||
} else {
|
||||
$priority = $request->input('priority');
|
||||
}
|
||||
$source = $ticket_source->where('name', '=', 'web')->first()->id;
|
||||
$attachments = $request->file('attachment');
|
||||
$collaborator = null;
|
||||
@@ -195,14 +215,8 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
// this param is used for inline attachments via email
|
||||
if (empty($attachments)) {
|
||||
$inline_attachment = $attachments;
|
||||
} else {
|
||||
$inline_attachment = null;
|
||||
}
|
||||
$result = $this->TicketWorkflowController->workflow($email, $name, $to, $subject, $details, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response, $inline_attachment);
|
||||
|
||||
$result = $this->TicketWorkflowController->workflow($email, $name, $subject, $details, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response);
|
||||
// dd($result);
|
||||
if ($result[1] == 1) {
|
||||
$ticketId = Tickets::where('ticket_number', '=', $result[0])->first();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $ticketId->id)->first();
|
||||
@@ -220,6 +234,8 @@ class FormController extends Controller
|
||||
}
|
||||
// dd($result);
|
||||
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is').' '.$result[0].'. '.Lang::get('lang.Please-save-this-for-future-reference'));
|
||||
} else {
|
||||
return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken'));
|
||||
}
|
||||
// dd($result);
|
||||
}
|
||||
@@ -245,7 +261,6 @@ class FormController extends Controller
|
||||
|
||||
$fromaddress = $user_cred->email;
|
||||
$fromname = $user_cred->user_name;
|
||||
$to = '';
|
||||
$phone = '';
|
||||
$phonecode = '';
|
||||
$mobile_number = '';
|
||||
@@ -262,7 +277,7 @@ class FormController extends Controller
|
||||
$ticket_status = null;
|
||||
$auto_response = 0;
|
||||
|
||||
$this->TicketWorkflowController->workflow($fromaddress, $to, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
|
||||
return \Redirect::back()->with('success1', Lang::get('lang.successfully_replied'));
|
||||
} else {
|
||||
|
@@ -6,26 +6,31 @@ namespace App\Http\Controllers\Client\helpdesk;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\OtpVerifyRequest;
|
||||
use App\Http\Requests\helpdesk\ProfilePassword;
|
||||
use App\Http\Requests\helpdesk\ProfileRequest;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
// models
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\Model\helpdesk\Utility\Otp;
|
||||
use App\User;
|
||||
use Auth;
|
||||
// classes
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Exception;
|
||||
use GeoIP;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Socialite;
|
||||
|
||||
/**
|
||||
* GuestController.
|
||||
@@ -47,19 +52,23 @@ class GuestController extends Controller
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile.
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getProfile(CountryCode $code)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
/**
|
||||
* Get profile.
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getProfile(CountryCode $code)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$status = $settings->status;
|
||||
|
||||
return view('themes.default1.client.helpdesk.profile', compact('user'))->with('phonecode', $phonecode->phonecode);
|
||||
}
|
||||
return view('themes.default1.client.helpdesk.profile', compact('user'))
|
||||
->with(['phonecode' => $phonecode->phonecode,
|
||||
'verify' => $status, ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save profile data.
|
||||
@@ -95,18 +104,29 @@ class GuestController extends Controller
|
||||
$user->profile_pic = $fileName;
|
||||
} else {
|
||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||
return redirect()->back()->with(['fails1' => Lang::get('lang.country-code-required-error'),
|
||||
'country_code' => 1, ])->withInput();
|
||||
return redirect()->back()->with(['fails1' => Lang::get('lang.country-code-required-error'),
|
||||
'country_code' => 1, ])->withInput();
|
||||
} else {
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
|
||||
if (!count($code)) {
|
||||
return redirect()->back()->with(['fails1' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'country_code' => 1, ])->withInput();
|
||||
return redirect()->back()->with(['fails1' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'country_code' => 1, ])->withInput();
|
||||
} else {
|
||||
$user->country_code = $request->input('country_code');
|
||||
}
|
||||
}
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
if ($request->get('mobile')) {
|
||||
$mobile = $request->get('mobile');
|
||||
} else {
|
||||
$mobile = null;
|
||||
}
|
||||
$check = $this->checkMobile($mobile);
|
||||
if ($check == true) {
|
||||
return redirect()->back()->with(['fails1' => Lang::get('lang.mobile-has-been-taken'), 'country_code' => 1])->withInput();
|
||||
}
|
||||
$user->fill($request->except('profile_pic', 'gender', 'mobile'));
|
||||
$user->mobile = $mobile;
|
||||
$user->save();
|
||||
|
||||
return redirect()->back()->with('success1', Lang::get('lang.profile_updated_sucessfully'));
|
||||
}
|
||||
@@ -115,6 +135,27 @@ class GuestController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@category fucntion to check if mobile number is unqique or not
|
||||
*
|
||||
*@param string $mobile
|
||||
*
|
||||
*@return bool true(if mobile exists in users table)/false (if mobile does not exist in user table)
|
||||
*/
|
||||
public function checkMobile($mobile)
|
||||
{
|
||||
if ($mobile) {
|
||||
$check = User::where('mobile', '=', $mobile)
|
||||
->where('id', '<>', \Auth::user()->id)
|
||||
->first();
|
||||
if (count($check) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Ticket page.
|
||||
*
|
||||
@@ -319,7 +360,6 @@ class GuestController extends Controller
|
||||
*/
|
||||
public function get_ticket_email($id, CommonSettings $common_settings)
|
||||
{
|
||||
$id1 = \Crypt::decrypt($id);
|
||||
$common_setting = $common_settings->select('status')
|
||||
->where('option_name', '=', 'user_set_ticket_status')
|
||||
->first();
|
||||
@@ -355,4 +395,172 @@ class GuestController extends Controller
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
public function resendOTP(OtpVerifyRequest $request)
|
||||
{
|
||||
if (\Schema::hasTable('sms')) {
|
||||
$sms = DB::table('sms')->get();
|
||||
if (count($sms) > 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return 'Plugin has not been setup successfully.';
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyOTP()
|
||||
{
|
||||
// dd(Input::all());
|
||||
// $user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))->first();
|
||||
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', Input::get('u_id'))
|
||||
->first();
|
||||
if ($otp != null) {
|
||||
$otp_length = strlen(Input::get('otp'));
|
||||
if (($otp_length == 6 && !preg_match('/[a-z]/i', Input::get('otp')))) {
|
||||
$otp2 = Hash::make(Input::get('otp'));
|
||||
$date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
|
||||
$date2 = date('Y-m-d h:i:sa');
|
||||
$time1 = new DateTime($date2);
|
||||
$time2 = new DateTime($date1);
|
||||
$interval = $time1->diff($time2);
|
||||
if ($interval->i > 10 || $interval->h > 0) {
|
||||
$message = Lang::get('lang.otp-expired');
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
if (Hash::check(Input::get('otp'), $otp->otp)) {
|
||||
Otp::where('user_id', '=', Input::get('u_id'))
|
||||
->update(['otp' => '']);
|
||||
// User::where('id', '=', $user->id)
|
||||
// ->update(['active' => 1]);
|
||||
// $this->openTicketAfterVerification($user->id);
|
||||
return 1;
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-invalid');
|
||||
|
||||
return $message;
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
public function sync()
|
||||
{
|
||||
try {
|
||||
$provider = $this->getProvider();
|
||||
$this->changeRedirect();
|
||||
$users = Socialite::driver($provider)->user();
|
||||
$this->forgetSession();
|
||||
$user['provider'] = $provider;
|
||||
$user['social_id'] = $users->id;
|
||||
$user['name'] = $users->name;
|
||||
$user['email'] = $users->email;
|
||||
$user['username'] = $users->nickname;
|
||||
$user['avatar'] = $users->avatar;
|
||||
|
||||
return redirect('client-profile')->with('success', 'Additional informations fetched');
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
|
||||
return redirect('client-profile')->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getProvider()
|
||||
{
|
||||
$provider = \Session::get('provider');
|
||||
|
||||
return $provider;
|
||||
}
|
||||
|
||||
public function changeRedirect()
|
||||
{
|
||||
$provider = \Session::get('provider');
|
||||
$url = \Session::get($provider.'redirect');
|
||||
\Config::set("services.$provider.redirect", $url);
|
||||
}
|
||||
|
||||
public function forgetSession()
|
||||
{
|
||||
$provider = $this->getProvider();
|
||||
\Session::forget('provider');
|
||||
\Session::forget($provider.'redirect');
|
||||
}
|
||||
|
||||
public function checkArray($key, $array)
|
||||
{
|
||||
$value = '';
|
||||
if (array_key_exists($key, $array)) {
|
||||
$value = $array[$key];
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function updateUser($user = [])
|
||||
{
|
||||
$userid = \Auth::user()->id;
|
||||
$useremail = \Auth::user()->email;
|
||||
$email = $this->checkArray('email', $user); //$user['email'];
|
||||
if ($email !== '' && $email !== $useremail) {
|
||||
throw new Exception('Sorry! your current email and '.ucfirst($user['provider']).' email is different so system can not sync');
|
||||
}
|
||||
$this->update($userid, $user);
|
||||
}
|
||||
|
||||
public function update($userid, $user, $provider)
|
||||
{
|
||||
$email = $this->checkArray('email', $user);
|
||||
$this->deleteUser($userid, $user, $provider);
|
||||
$this->insertAdditional($userid, $provider, $user);
|
||||
$this->changeEmail($email);
|
||||
}
|
||||
|
||||
public function deleteUser($userid, $user, $provider)
|
||||
{
|
||||
$info = new \App\UserAdditionalInfo();
|
||||
$infos = $info->where('owner', $userid)->where('service', $provider)->get();
|
||||
if ($infos->count() > 0 && count($user) > 0) {
|
||||
foreach ($infos as $key => $detail) {
|
||||
//if ($user[$key] !== $detail->$key) {
|
||||
$detail->delete();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function insertAdditional($id, $provider, $user = [])
|
||||
{
|
||||
$info = new \App\UserAdditionalInfo();
|
||||
if (count($user) > 0) {
|
||||
foreach ($user as $key => $value) {
|
||||
$info->create([
|
||||
'owner' => $id,
|
||||
'service' => $provider,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function changeEmail($email)
|
||||
{
|
||||
$user = \Auth::user();
|
||||
if ($user && $email && !$user->email) {
|
||||
$user->email = $email;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
// models
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Followup;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
@@ -316,4 +317,101 @@ class UnAuthController extends Controller
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@category function to change system's language
|
||||
*
|
||||
*@param string $lang //desired language's iso code
|
||||
*
|
||||
*@return response
|
||||
*/
|
||||
public static function changeLanguage($lang)
|
||||
{
|
||||
//if(Cache::has('language'))
|
||||
//{
|
||||
// return Cache::get('language');
|
||||
//} else return 'false';
|
||||
// Cache::put('language',$)
|
||||
$path = base_path('resources/lang'); // Path to check available language packages
|
||||
if (array_key_exists($lang, \Config::get('languages')) && in_array($lang, scandir($path))) {
|
||||
// dd(array_key_exists($lang, Config::get('languages')));
|
||||
// app()->setLocale($lang);
|
||||
|
||||
\Cache::forever('language', $lang);
|
||||
// dd(Cache::get('language'));
|
||||
// dd()
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Follow up tickets
|
||||
public function followup()
|
||||
{
|
||||
$followup = Followup::whereId('1')->first();
|
||||
$condition = $followup->condition;
|
||||
// dd($condition);
|
||||
|
||||
switch ($condition) {
|
||||
case 'everyMinute':
|
||||
$followup_set = ' + 1 minute';
|
||||
break;
|
||||
case 'everyFiveMinutes':
|
||||
$followup_set = ' + 5 minute';
|
||||
break;
|
||||
case 'everyTenMinutes':
|
||||
$followup_set = ' + 10 minute';
|
||||
break;
|
||||
case 'everyThirtyMinutes':
|
||||
$followup_set = ' + 30 minute';
|
||||
break;
|
||||
case 'hourly':
|
||||
$followup_set = ' + 1 hours';
|
||||
break;
|
||||
case 'daily':
|
||||
$followup_set = ' + 1 day';
|
||||
break;
|
||||
case 'weekly':
|
||||
$followup_set = ' + 7 day';
|
||||
break;
|
||||
case 'monthly':
|
||||
$followup_set = ' + 30 day';
|
||||
break;
|
||||
case 'yearly':
|
||||
$followup_set = ' + 365 day';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($followup->status = 1) {
|
||||
$tickets = Tickets::where('id', '>=', 1)->where('status', '!=', 5)->get();
|
||||
// dd( $tickets);
|
||||
// $tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->pluck('id');
|
||||
// dd( $tickets);
|
||||
// $id=1;
|
||||
foreach ($tickets as $ticket) {
|
||||
// $id=1;
|
||||
// $id++;
|
||||
// $ticket=Tickets::where('status', '!=', 5)->get();
|
||||
|
||||
// dd($ticket);
|
||||
// if($ticket != null){
|
||||
// dd('here');
|
||||
$ck = date('Y-m-d H:i:s', strtotime($ticket->updated_at.$followup_set));
|
||||
// dd($ck);
|
||||
$current_time = date('Y-m-d H:i:s');
|
||||
if ($current_time > $ck) {
|
||||
$ticket->follow_up = 1;
|
||||
$ticket->save();
|
||||
// Tickets::where('id', '=',$id)
|
||||
// ->update(['follow_up' => 1]);
|
||||
|
||||
// }
|
||||
}
|
||||
// if($id=2)
|
||||
// {dd($ticket);}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -95,7 +95,7 @@ class UserController extends Controller
|
||||
->orWhere('slug', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('description', 'LIKE', '%'.$search.'%')
|
||||
->paginate($pagination);
|
||||
$result->setPath('search');
|
||||
$result->setPath('search?s='.$search);
|
||||
$categorys = $category->get();
|
||||
|
||||
return view('themes.default1.client.kb.article-list.search', compact('categorys', 'result'));
|
||||
|
22
app/Http/Controllers/Common/ExcelController.php
Normal file
22
app/Http/Controllers/Common/ExcelController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Excel;
|
||||
use Exception;
|
||||
|
||||
class ExcelController extends Controller
|
||||
{
|
||||
public function export($filename, $data)
|
||||
{
|
||||
if (count($data) == 0) {
|
||||
throw new Exception('No data');
|
||||
}
|
||||
Excel::create($filename, function ($excel) use ($data) {
|
||||
$excel->sheet('sheet', function ($sheet) use ($data) {
|
||||
$sheet->fromArray($data);
|
||||
});
|
||||
})->export('xls');
|
||||
}
|
||||
}
|
@@ -9,9 +9,9 @@ class FileuploadController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// checking authentication
|
||||
// $this->middleware('auth');
|
||||
$this->middleware('auth');
|
||||
// checking if role is agent
|
||||
// $this->middleware('role.agent');
|
||||
$this->middleware('role.agent');
|
||||
}
|
||||
|
||||
// Returns a file size limit in bytes based on the PHP upload_max_filesize
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Api\v1\PushNotificationController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Notification\Notification;
|
||||
use App\Model\helpdesk\Notification\NotificationType;
|
||||
@@ -29,9 +28,8 @@ class NotificationController extends Controller
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(PushNotificationController $PushNotificationController)
|
||||
public function __construct()
|
||||
{
|
||||
$this->PushNotificationController = $PushNotificationController;
|
||||
$user = new User();
|
||||
$this->user = $user;
|
||||
// checking authentication
|
||||
@@ -144,6 +142,13 @@ class NotificationController extends Controller
|
||||
$notifications = UserNotification::join('notifications', 'user_notification.notification_id', '=', 'notifications.id')
|
||||
->join('notification_types', 'notifications.type_id', '=', 'notification_types.id')
|
||||
->where('user_notification.user_id', '=', \Auth::user()->id)
|
||||
->select('notification_types.id as id', 'notifications.id as notification_id',
|
||||
'user_notification.user_id as user_id', 'user_notification.is_read as is_read',
|
||||
'user_notification.created_at as created_at', 'user_notification.updated_at as updated_at', 'notifications.model_id as model_id',
|
||||
'notifications.userid_created as userid_created',
|
||||
'notifications.type_id as type_id', 'notification_types.message as message',
|
||||
'notification_types.type as type', 'notification_types.icon_class as icon_class')
|
||||
->orderBy('user_notification.created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
return $notifications;
|
||||
|
@@ -6,11 +6,12 @@ use App\Http\Controllers\Controller;
|
||||
use App\Model\Common\TemplateType;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Exception;
|
||||
use Mail;
|
||||
|
||||
class PhpMailController extends Controller
|
||||
{
|
||||
@@ -21,447 +22,6 @@ class PhpMailController extends Controller
|
||||
return $emails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sending emails from the system.
|
||||
*
|
||||
* @return Mail
|
||||
*/
|
||||
public function sendmail($from, $to, $message, $template_variables)
|
||||
{
|
||||
// try {
|
||||
// dd($from);
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
return $from_address;
|
||||
} else {
|
||||
// dd($from_address);
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = \Crypt::decrypt($from_address->password);
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
$protocol = $from_address->sending_protocol;
|
||||
|
||||
if (isset($to['email'])) {
|
||||
$recipants = $to['email'];
|
||||
} else {
|
||||
$recipants = null;
|
||||
}
|
||||
if (isset($to['name'])) {
|
||||
$recipantname = $to['name'];
|
||||
} else {
|
||||
$recipantname = null;
|
||||
}
|
||||
if (isset($to['cc'])) {
|
||||
$cc = $to['cc'];
|
||||
} else {
|
||||
$cc = null;
|
||||
}
|
||||
if (isset($to['bc'])) {
|
||||
$bc = $to['bc'];
|
||||
} else {
|
||||
$bc = null;
|
||||
}
|
||||
// if (isset($message['subject'])) {
|
||||
// $subject = $message['subject'];
|
||||
// } else {
|
||||
// $subject = null;
|
||||
// }
|
||||
if (isset($message['body'])) {
|
||||
$content = $message['body'];
|
||||
} else {
|
||||
$content = null;
|
||||
}
|
||||
if (isset($message['scenario'])) {
|
||||
$template = $message['scenario'];
|
||||
} else {
|
||||
$template = null;
|
||||
}
|
||||
if (isset($message['attachments'])) {
|
||||
$attachment = $message['attachments'];
|
||||
} else {
|
||||
$attachment = null;
|
||||
}
|
||||
|
||||
// Inline Attachments
|
||||
if (isset($message['add_embedded_image'])) {
|
||||
$add_embedded_images = $message['add_embedded_image'];
|
||||
} else {
|
||||
$add_embedded_images = null;
|
||||
}
|
||||
|
||||
// template variables
|
||||
if (Auth::user()) {
|
||||
$agent = Auth::user()->user_name;
|
||||
} else {
|
||||
$agent = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_agent_name'])) {
|
||||
$ticket_agent_name = $template_variables['ticket_agent_name'];
|
||||
} else {
|
||||
$ticket_agent_name = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_number'])) {
|
||||
$ticket_number = $template_variables['ticket_number'];
|
||||
} else {
|
||||
$ticket_number = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_client_name'])) {
|
||||
$ticket_client_name = $template_variables['ticket_client_name'];
|
||||
} else {
|
||||
$ticket_client_name = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_client_email'])) {
|
||||
$ticket_client_email = $template_variables['ticket_client_email'];
|
||||
} else {
|
||||
$ticket_client_email = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_body'])) {
|
||||
$ticket_body = $template_variables['ticket_body'];
|
||||
} else {
|
||||
$ticket_body = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_assigner'])) {
|
||||
$ticket_assigner = $template_variables['ticket_assigner'];
|
||||
} else {
|
||||
$ticket_assigner = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_link_with_number'])) {
|
||||
$ticket_link_with_number = $template_variables['ticket_link_with_number'];
|
||||
} else {
|
||||
$ticket_link_with_number = null;
|
||||
}
|
||||
if (isset($template_variables['system_from'])) {
|
||||
$system_from = $template_variables['system_from'];
|
||||
} else {
|
||||
$system_from = $this->company();
|
||||
}
|
||||
if (isset($template_variables['system_link'])) {
|
||||
$system_link = $template_variables['system_link'];
|
||||
} else {
|
||||
$system_link = url('/');
|
||||
}
|
||||
if (isset($template_variables['system_error'])) {
|
||||
$system_error = $template_variables['system_error'];
|
||||
} else {
|
||||
$system_error = null;
|
||||
}
|
||||
if (isset($template_variables['agent_sign'])) {
|
||||
$agent_sign = $template_variables['agent_sign'];
|
||||
} else {
|
||||
$agent_sign = null;
|
||||
}
|
||||
if (isset($template_variables['department_sign'])) {
|
||||
$department_sign = $template_variables['department_sign'];
|
||||
} else {
|
||||
$department_sign = null;
|
||||
}
|
||||
if (isset($template_variables['password_reset_link'])) {
|
||||
$password_reset_link = $template_variables['password_reset_link'];
|
||||
} else {
|
||||
$password_reset_link = null;
|
||||
}
|
||||
if (isset($template_variables['user_password'])) {
|
||||
$user_password = $template_variables['user_password'];
|
||||
} else {
|
||||
$user_password = null;
|
||||
}
|
||||
if (isset($template_variables['email_address'])) {
|
||||
$email_address = $template_variables['email_address'];
|
||||
} else {
|
||||
$email_address = null;
|
||||
}
|
||||
if (isset($template_variables['user'])) {
|
||||
$user = $template_variables['user'];
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
|
||||
// $system_link = url('/');
|
||||
|
||||
// $system_from = $this->company();
|
||||
|
||||
$mail = new \PHPMailer();
|
||||
|
||||
$status = \DB::table('settings_email')->first();
|
||||
|
||||
$path2 = \Config::get('view.paths');
|
||||
|
||||
// $directory = $path2[0].DIRECTORY_SEPARATOR.'emails'.DIRECTORY_SEPARATOR.$status->template.DIRECTORY_SEPARATOR;
|
||||
//
|
||||
// $handle = fopen($directory.$template.'.blade.php', 'r');
|
||||
// $contents = fread($handle, filesize($directory.$template.'.blade.php'));
|
||||
// fclose($handle);
|
||||
|
||||
$template = TemplateType::where('name', '=', $template)->first();
|
||||
|
||||
$set = \App\Model\Common\TemplateSet::where('name', '=', $status->template)->first();
|
||||
|
||||
if (isset($set['id'])) {
|
||||
$template_data = \App\Model\Common\Template::where('set_id', '=', $set->id)->where('type', '=', $template->id)->first();
|
||||
$contents = $template_data->message;
|
||||
if ($template_data->variable == 1) {
|
||||
if ($template_data->subject) {
|
||||
$subject = $template_data->subject;
|
||||
if ($ticket_number != null) {
|
||||
$subject = $subject.' [#'.$ticket_number.']';
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
}
|
||||
} else {
|
||||
$contents = null;
|
||||
$subject = null;
|
||||
}
|
||||
|
||||
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}'];
|
||||
|
||||
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link];
|
||||
|
||||
// dd($variables,$data,$contents);
|
||||
// $messagebody = str_replace($variables, $data, $contents);
|
||||
|
||||
foreach ($variables as $key => $variable) {
|
||||
$messagebody = str_replace($variables[$key], $data[$key], $contents);
|
||||
// dd($messagebody);
|
||||
|
||||
$contents = $messagebody;
|
||||
}
|
||||
|
||||
// dd($messagebody);
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
if ($protocol == 'smtp') {
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
$mail->setFrom($username, $fromname);
|
||||
} elseif ($protocol == 'mail') {
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
if ($username == $fromname) {
|
||||
$mail->setFrom($username);
|
||||
} else {
|
||||
$mail->setFrom($username, $fromname);
|
||||
}
|
||||
}
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
if ($cc != null) {
|
||||
foreach ($cc as $collaborator) {
|
||||
//mail to collaborators
|
||||
$collab_user_id = $collaborator->user_id;
|
||||
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
|
||||
$collab_email = $user_id_collab->email;
|
||||
$mail->addCC($collab_email);
|
||||
}
|
||||
}
|
||||
|
||||
if ($attachment != null) {
|
||||
$size = count($message['attachments']);
|
||||
$attach = $message['attachments'];
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$file_path = $attach[$i]->getRealPath();
|
||||
$file_name = $attach[$i]->getClientOriginalName();
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
}
|
||||
|
||||
// inline images embedded as attachments
|
||||
if ($add_embedded_images != null) {
|
||||
// dd($add_embedded_images);
|
||||
foreach ($add_embedded_images as $add_embedded_image) {
|
||||
if (isset($add_embedded_image->id)) {
|
||||
$cid = $add_embedded_image->id;
|
||||
} else {
|
||||
$cid = null;
|
||||
}
|
||||
if (isset($add_embedded_image->name)) {
|
||||
$file_name = $add_embedded_image->name;
|
||||
} else {
|
||||
$file_name = null;
|
||||
}
|
||||
if (isset($add_embedded_image->filePath)) {
|
||||
$file_path = $add_embedded_image->filePath;
|
||||
} else {
|
||||
$file_path = null;
|
||||
}
|
||||
if (isset($add_embedded_image->disposition)) {
|
||||
if ($add_embedded_image->disposition == 'INLINE') {
|
||||
$mail->AddEmbeddedImage($file_path, $cid, $file_name);
|
||||
} else {
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
} else {
|
||||
$file_path = $add_embedded_image->getRealPath();
|
||||
$file_name = $add_embedded_image->getClientOriginalName();
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mail->CharSet = 'utf8';
|
||||
$mail->Subject = $subject;
|
||||
if ($template == 'ticket-reply-agent') {
|
||||
$line = '---Reply above this line--- <br/><br/>';
|
||||
$body = $line.$messagebody;
|
||||
} else {
|
||||
$body = $messagebody;
|
||||
}
|
||||
$rtl = CommonSettings::where('option_name', '=', 'enable_rtl')->first();
|
||||
if ($rtl->option_value == 1) {
|
||||
$mail->ContentType = 'text/html';
|
||||
$body = '<html dir="rtl" xml:lang="ar" lang="ar"><head></head><body dir="rtl">'.$body.'</body></html>';
|
||||
} else {
|
||||
}
|
||||
$mail->Body = nl2br($body);
|
||||
|
||||
if (!$mail->send()) {
|
||||
return;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sending emails from the system.
|
||||
*
|
||||
* @return MailNotification
|
||||
*/
|
||||
public function sendEmail($from, $to, $message)
|
||||
{
|
||||
try {
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
return $from_address;
|
||||
} else {
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = \Crypt::decrypt($from_address->password);
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
$protocol = $from_address->sending_protocol;
|
||||
|
||||
if (isset($to['email'])) {
|
||||
$recipants = $to['email'];
|
||||
} else {
|
||||
$recipants = null;
|
||||
}
|
||||
if (isset($to['name'])) {
|
||||
$recipantname = $to['name'];
|
||||
} else {
|
||||
$recipantname = null;
|
||||
}
|
||||
if (isset($to['cc'])) {
|
||||
$cc = $to['cc'];
|
||||
} else {
|
||||
$cc = null;
|
||||
}
|
||||
if (isset($to['bc'])) {
|
||||
$bc = $to['bc'];
|
||||
} else {
|
||||
$bc = null;
|
||||
}
|
||||
if (isset($message['subject'])) {
|
||||
$subject = $message['subject'];
|
||||
} else {
|
||||
$subject = null;
|
||||
}
|
||||
if (isset($message['body'])) {
|
||||
$content = $message['body'];
|
||||
} else {
|
||||
$content = null;
|
||||
}
|
||||
if (isset($message['scenario'])) {
|
||||
$template = $message['scenario'];
|
||||
} else {
|
||||
$template = null;
|
||||
}
|
||||
if (isset($message['attachments'])) {
|
||||
$attachment = $message['attachments'];
|
||||
} else {
|
||||
$attachment = null;
|
||||
}
|
||||
|
||||
// template variables
|
||||
if (Auth::user()) {
|
||||
$agent = Auth::user()->user_name;
|
||||
} else {
|
||||
$agent = null;
|
||||
}
|
||||
|
||||
$system_link = url('/');
|
||||
|
||||
$system_from = $this->company();
|
||||
|
||||
$mail = new \PHPMailer();
|
||||
|
||||
$status = \DB::table('settings_email')->first();
|
||||
|
||||
// dd($messagebody);
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
if ($protocol == 'smtp') {
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
$mail->setFrom($username, $fromname);
|
||||
} elseif ($protocol == 'mail') {
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
if ($username == $fromname) {
|
||||
$mail->setFrom($username);
|
||||
} else {
|
||||
$mail->setFrom($username, $fromname);
|
||||
}
|
||||
}
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
// Name is optional
|
||||
// $mail->addReplyTo('sada059@gmail.com', 'Information');
|
||||
// Optional name
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
if ($cc != null) {
|
||||
foreach ($cc as $collaborator) {
|
||||
//mail to collaborators
|
||||
$collab_user_id = $collaborator->user_id;
|
||||
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
|
||||
$collab_email = $user_id_collab->email;
|
||||
$mail->addCC($collab_email);
|
||||
}
|
||||
}
|
||||
if ($attachment != null) {
|
||||
$size = count($message['attachments']);
|
||||
$attach = $message['attachments'];
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$file_path = $attach[$i]->getRealPath();
|
||||
$file_name = $attach[$i]->getClientOriginalName();
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
}
|
||||
$mail->CharSet = 'utf8';
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $content;
|
||||
if (!$mail->send()) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if ($e instanceof ErrorException) {
|
||||
return \Lang::get('lang.outgoing_email_failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetching comapny name to send mail.
|
||||
*
|
||||
@@ -501,4 +61,246 @@ class PhpMailController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function sendmail($from, $to, $message, $template_variables)
|
||||
{
|
||||
$this->setQueue();
|
||||
$job = new \App\Jobs\SendEmail($from, $to, $message, $template_variables);
|
||||
$dispatch = $this->dispatch($job);
|
||||
|
||||
return $dispatch;
|
||||
}
|
||||
|
||||
public function sendEmail($from, $to, $message, $template_variables)
|
||||
{
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
throw new Exception('Invalid Email Configuration');
|
||||
}
|
||||
|
||||
$this->setMailConfig($from_address);
|
||||
|
||||
$recipants = $this->checkElement('email', $to);
|
||||
$recipantname = $this->checkElement('name', $to);
|
||||
$cc = $this->checkElement('cc', $to);
|
||||
$bc = $this->checkElement('bc', $to);
|
||||
$subject = $this->checkElement('subject', $message);
|
||||
$content = $this->checkElement('body', $message);
|
||||
$template_type = $this->checkElement('scenario', $message);
|
||||
$attachment = $this->checkElement('attachments', $message);
|
||||
|
||||
$agent = null;
|
||||
// template variables
|
||||
if (Auth::user()) {
|
||||
$agent = Auth::user()->user_name;
|
||||
}
|
||||
$ticket_agent_name = $this->checkElement('ticket_agent_name', $template_variables);
|
||||
$ticket_number = $this->checkElement('ticket_number', $template_variables);
|
||||
$ticket_client_name = $this->checkElement('ticket_client_name', $template_variables);
|
||||
$ticket_client_email = $this->checkElement('ticket_client_email', $template_variables);
|
||||
$ticket_body = $this->checkElement('ticket_body', $template_variables);
|
||||
$ticket_assigner = $this->checkElement('ticket_assigner', $template_variables);
|
||||
$ticket_link_with_number = $this->checkElement('ticket_link_with_number', $template_variables);
|
||||
|
||||
$system_from = $this->checkElement('system_from', $template_variables);
|
||||
if ($system_from === '') {
|
||||
$system_from = $this->company();
|
||||
}
|
||||
$system_link = $this->checkElement('system_link', $template_variables);
|
||||
if ($system_link === '') {
|
||||
$system_link = url('/');
|
||||
}
|
||||
$system_error = $this->checkElement('system_error', $template_variables);
|
||||
$agent_sign = $this->checkElement('agent_sign', $template_variables);
|
||||
$department_sign = $this->checkElement('department_sign', $template_variables);
|
||||
$password_reset_link = $this->checkElement('password_reset_link', $template_variables);
|
||||
$user_password = $this->checkElement('user_password', $template_variables);
|
||||
|
||||
$email_address = $this->checkElement('email_address', $template_variables);
|
||||
$user = $this->checkElement('user', $template_variables);
|
||||
|
||||
|
||||
$status = \DB::table('settings_email')->first();
|
||||
|
||||
$template = TemplateType::where('name', '=', $template_type)->first();
|
||||
|
||||
$set = \App\Model\Common\TemplateSet::where('name', '=', $status->template)->first();
|
||||
if ($template) {
|
||||
if (isset($set['id'])) {
|
||||
$template_data = \App\Model\Common\Template::where('set_id', '=', $set->id)->where('type', '=', $template->id)->first();
|
||||
$contents = $template_data->message;
|
||||
if ($template_data->variable == 1) {
|
||||
if ($template_data->subject) {
|
||||
$subject = $template_data->subject;
|
||||
if ($ticket_number != null) {
|
||||
$subject = $subject.' [#'.$ticket_number.']';
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
}
|
||||
} else {
|
||||
$contents = null;
|
||||
$subject = null;
|
||||
}
|
||||
|
||||
|
||||
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}'];
|
||||
|
||||
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link];
|
||||
|
||||
foreach ($variables as $key => $variable) {
|
||||
$messagebody = str_replace($variables[$key], $data[$key], $contents);
|
||||
$contents = $messagebody;
|
||||
}
|
||||
|
||||
|
||||
if ($template_type == 'ticket-reply-agent') {
|
||||
$line = '---Reply above this line--- <br/><br/>';
|
||||
$content = $line.$messagebody;
|
||||
} else {
|
||||
$content = $messagebody;
|
||||
}
|
||||
}
|
||||
$send = $this->laravelMail($recipants, $recipantname, $subject, $content, $cc, $attachment);
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function setMailConfig($from_address)
|
||||
{
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = $from_address->password;
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
$protocol = $from_address->sending_protocol;
|
||||
$this->setServices($from_address->id, $protocol);
|
||||
if($protocol=='mail'){
|
||||
$username = "";
|
||||
$fromname="";
|
||||
$host="";
|
||||
$smtpsecure ="";
|
||||
$port="";
|
||||
}
|
||||
$configs = [
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $fromname],
|
||||
'password' => $password,
|
||||
'encryption' => $smtpsecure,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $protocol,
|
||||
];
|
||||
foreach ($configs as $key => $config) {
|
||||
if (is_array($config)) {
|
||||
foreach ($config as $from) {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
} else {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setServices($emailid, $protocol)
|
||||
{
|
||||
$service = new \App\Model\MailJob\FaveoMail();
|
||||
$services = $service->where('email_id', $emailid)->lists('value', 'key')->toArray();
|
||||
$controller = new \App\Http\Controllers\Admin\helpdesk\EmailsController();
|
||||
$controller->setServiceConfig($protocol, $services);
|
||||
}
|
||||
|
||||
public function checkElement($element, $array)
|
||||
{
|
||||
$value = '';
|
||||
if (is_array($array)) {
|
||||
if (array_key_exists($element, $array)) {
|
||||
$value = $array[$element];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function laravelMail($to, $toname, $subject, $data, $cc, $attach)
|
||||
{
|
||||
//dd($to, $toname, $subject, $data, $cc, $attach);
|
||||
//dd(\Config::get('mail'));
|
||||
//dd($attach);
|
||||
$mail = Mail::send('emails.mail', ['data' => $data], function ($m) use ($to, $subject, $toname, $cc, $attach) {
|
||||
$m->to($to, $toname)->subject($subject);
|
||||
|
||||
if ($cc != null) {
|
||||
foreach ($cc as $collaborator) {
|
||||
//mail to collaborators
|
||||
$collab_user_id = $collaborator->user_id;
|
||||
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
|
||||
$collab_email = $user_id_collab->email;
|
||||
$m->cc($collab_email);
|
||||
}
|
||||
}
|
||||
|
||||
// $mail->addBCC($bc);
|
||||
$size = count($attach);
|
||||
if ($size > 0) {
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
if (is_array($attach) && array_key_exists($i, $attach)) {
|
||||
$mode = 'normal';
|
||||
if (is_array($attach[$i]) && array_key_exists('mode', $attach[$i])) {
|
||||
$mode = $attach[$i]['mode'];
|
||||
}
|
||||
$file = $attach[$i]['file_path'];
|
||||
$name = $attach[$i]['file_name'];
|
||||
$mime = $attach[$i]['mime'];
|
||||
$this->attachmentMode($m, $file, $name, $mime, $mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (is_object($mail) || (is_object($mail) && $mail->getStatusCode() == 200)) {
|
||||
$mail = 1;
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
public function setQueue()
|
||||
{
|
||||
$short = 'database';
|
||||
$field = [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'expire' => 60,
|
||||
];
|
||||
$queue = new \App\Model\MailJob\QueueService();
|
||||
$active_queue = $queue->where('status', 1)->first();
|
||||
if ($active_queue) {
|
||||
$short = $active_queue->short_name;
|
||||
$fields = new \App\Model\MailJob\FaveoQueue();
|
||||
$field = $fields->where('service_id', $active_queue->id)->lists('value', 'key')->toArray();
|
||||
}
|
||||
$this->setQueueConfig($short, $field);
|
||||
}
|
||||
|
||||
public function setQueueConfig($short, $field)
|
||||
{
|
||||
\Config::set('queue.default', $short);
|
||||
foreach ($field as $key => $value) {
|
||||
\Config::set("queue.connections.$short.$key", $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function attachmentMode($message, $file, $name, $mime, $mode)
|
||||
{
|
||||
if ($mode == 'data') {
|
||||
return $message->attachData(base64_decode($file, true), $name, ['mime' => $mime]);
|
||||
}
|
||||
|
||||
return $message->attach($file, ['as' => $name, 'mime' => $mime]);
|
||||
}
|
||||
}
|
||||
|
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// Requests
|
||||
use App\User;
|
||||
// Models
|
||||
use FCM;
|
||||
// classes
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* **********************************************
|
||||
* PushNotificationController
|
||||
* **********************************************
|
||||
* This controller is used to send notification to FCM cloud which later will
|
||||
* foreward notification to Mobile Application.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PushNotificationController extends Controller
|
||||
{
|
||||
public function response($token, User $user)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get the fcm token from the api under a user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function fcmToken(Request $request, User $user)
|
||||
{
|
||||
}
|
||||
}
|
@@ -279,7 +279,7 @@ class SettingsController extends Controller
|
||||
|
||||
public function Plugins()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.settings.plugins');
|
||||
return view('themes.default1.admin.helpdesk.settings.plugins', ['info' => 1]);
|
||||
}
|
||||
|
||||
public function GetPlugin()
|
||||
@@ -406,7 +406,7 @@ class SettingsController extends Controller
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
chmod($app, 0644);
|
||||
$str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$line_i_am_looking_for = 187;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
@@ -578,7 +578,7 @@ class SettingsController extends Controller
|
||||
if (!$plug) {
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$line_i_am_looking_for = 187;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
@@ -592,7 +592,7 @@ class SettingsController extends Controller
|
||||
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$line_i_am_looking_for = 187;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
|
9
app/Http/Controllers/Common/Socialite.php
Normal file
9
app/Http/Controllers/Common/Socialite.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use Socialite;
|
||||
|
||||
class Socialite extends Socialite
|
||||
{
|
||||
}
|
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\TemplateSetRequest;
|
||||
use App\Model\Common\Template;
|
||||
use App\Model\Common\TemplateSet;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
|
@@ -24,6 +24,7 @@ use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use UnAuth;
|
||||
use View;
|
||||
|
||||
/**
|
||||
@@ -300,7 +301,10 @@ class InstallController extends Controller
|
||||
$timezone = $request->input('timezone');
|
||||
$date = $request->input('date');
|
||||
$datetime = $request->input('datetime');
|
||||
|
||||
$changed = UnAuth::changeLanguage($language);
|
||||
if (!$changed) {
|
||||
return \Redirect::back()->with('fails', 'Invalid language');
|
||||
}
|
||||
// checking requested timezone for the admin and system
|
||||
$timezones = Timezones::where('name', '=', $timezone)->first();
|
||||
if ($timezones == null) {
|
||||
@@ -370,10 +374,12 @@ class InstallController extends Controller
|
||||
$datacontent2 = File::get($app_url);
|
||||
$datacontent2 = str_replace('http://localhost', $link, $datacontent2);
|
||||
File::put($app_url, $datacontent2);
|
||||
$language = Cache::get('language');
|
||||
try {
|
||||
Cache::flush();
|
||||
|
||||
Artisan::call('key:generate');
|
||||
\Cache::forever('language', $language);
|
||||
|
||||
return View::make('themes/default1/installer/helpdesk/view6');
|
||||
} catch (Exception $e) {
|
||||
|
77
app/Http/Controllers/Job/MailController.php
Normal file
77
app/Http/Controllers/Job/MailController.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Job;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Form;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MailController extends Controller
|
||||
{
|
||||
public function serviceForm(Request $request)
|
||||
{
|
||||
$serviceid = $request->input('service');
|
||||
|
||||
$short_name = '';
|
||||
$mail_services = new \App\Model\MailJob\MailService();
|
||||
$mail_service = $mail_services->find($serviceid);
|
||||
if ($mail_service) {
|
||||
$short_name = $mail_service->short_name;
|
||||
}
|
||||
$form = $this->getServiceForm($short_name);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function form($label, $name, $class)
|
||||
{
|
||||
$mailid = \Input::get('emailid');
|
||||
if ($mailid) {
|
||||
$emails = new \App\Model\helpdesk\Email\Emails();
|
||||
$email = $emails->find($mailid);
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, $email->getExtraField($name), ['class' => 'form-control']).'</div>';
|
||||
} else {
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, null, ['class' => 'form-control']).'</div>';
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getServiceForm($short_name)
|
||||
{
|
||||
$form = '';
|
||||
try {
|
||||
switch ($short_name) {
|
||||
case 'smtp':
|
||||
return $form;
|
||||
case 'mail':
|
||||
return $form;
|
||||
case 'sendmail':
|
||||
return $form;
|
||||
case 'mailgun':
|
||||
$form .= "<div class='row'>".$this->form('Domain', 'domain', 'col-md-6 form-group');
|
||||
$form .= $this->form('Secret Key', 'secret', 'col-md-6 form-group').'</div>';
|
||||
|
||||
return $form;
|
||||
case 'mandrill':
|
||||
$form .= "<div class='row'>".$this->form('Secret Key', 'secret', 'col-md-6 form-group').'</div>';
|
||||
|
||||
return $form;
|
||||
case 'log':
|
||||
return $form;
|
||||
case 'ses':
|
||||
$form .= "<div class='row'>".$this->form('Key', 'key', 'col-md-6 form-group');
|
||||
$form .= $this->form('Secret Key', 'secret', 'col-md-6 form-group').$this->form('Region', 'region', 'col-md-6 form-group').'</div>';
|
||||
|
||||
return $form;
|
||||
default:
|
||||
return $form;
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
}
|
190
app/Http/Controllers/Job/QueueController.php
Normal file
190
app/Http/Controllers/Job/QueueController.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Job;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\Queue\QueueRequest;
|
||||
use App\Model\MailJob\FaveoQueue;
|
||||
use App\Model\MailJob\QueueService;
|
||||
use Exception;
|
||||
use Form;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class QueueController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$queue = new QueueService();
|
||||
$queues = $queue->select('id', 'name', 'status')->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.queue.index', compact('queues'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
try {
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($id);
|
||||
if (!$queue) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
}
|
||||
|
||||
return view('themes.default1.admin.helpdesk.queue.edit', compact('queue'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, QueueRequest $request)
|
||||
{
|
||||
try {
|
||||
$values = $request->except('_token');
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($id);
|
||||
if (!$queue) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
}
|
||||
$setting = new FaveoQueue();
|
||||
$settings = $setting->where('service_id', $id)->get();
|
||||
if ($settings->count() > 0) {
|
||||
foreach ($settings as $set) {
|
||||
$set->delete();
|
||||
}
|
||||
}
|
||||
if (count($values) > 0) {
|
||||
foreach ($values as $key => $value) {
|
||||
$setting->create([
|
||||
'service_id' => $id,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Updated');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function activate($id)
|
||||
{
|
||||
try {
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($id);
|
||||
$active_queue = $queues->where('status', 1)->first();
|
||||
if (!$queue) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
}
|
||||
if ($queue->isActivate() == false && $id != 1 && $id != 2) {
|
||||
throw new Exception("To activate $queue->name , Please configure it first");
|
||||
}
|
||||
if ($active_queue) {
|
||||
$active_queue->status = 0;
|
||||
$active_queue->save();
|
||||
}
|
||||
$queue->status = 1;
|
||||
$queue->save();
|
||||
|
||||
return redirect()->back()->with('success', 'Activated');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getForm(Request $request)
|
||||
{
|
||||
$queueid = $request->input('queueid');
|
||||
$form = $this->getFormById($queueid);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getShortNameById($queueid)
|
||||
{
|
||||
$short = '';
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($queueid);
|
||||
if ($queue) {
|
||||
$short = $queue->short_name;
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
public function getIdByShortName($short)
|
||||
{
|
||||
$id = '';
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->where('short_name', $short)->first();
|
||||
if ($queue) {
|
||||
$id = $queue->id;
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function getFormById($id)
|
||||
{
|
||||
$short = $this->getShortNameById($id);
|
||||
$form = '';
|
||||
switch ($short) {
|
||||
case 'beanstalkd':
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'beanstalkd');
|
||||
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group', 'localhost');
|
||||
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default');
|
||||
$form .= '</div>';
|
||||
|
||||
return $form;
|
||||
case 'sqs':
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'sqs');
|
||||
$form .= $this->form($short, 'Key', 'key', 'col-md-6 form-group', 'your-public-key');
|
||||
$form .= $this->form($short, 'Secret', 'secret', 'col-md-6 form-group', 'your-queue-url');
|
||||
$form .= $this->form($short, 'Region', 'region', 'col-md-6 form-group', 'us-east-1');
|
||||
$form .= '</div>';
|
||||
|
||||
return $form;
|
||||
case 'iron':
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'iron');
|
||||
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group', 'mq-aws-us-east-1.iron.io');
|
||||
$form .= $this->form($short, 'Token', 'token', 'col-md-6 form-group', 'your-token');
|
||||
$form .= $this->form($short, 'Project', 'project', 'col-md-6 form-group', 'your-project-id');
|
||||
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'your-queue-name');
|
||||
$form .= '</div>';
|
||||
|
||||
return $form;
|
||||
case 'redis':
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'redis');
|
||||
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default');
|
||||
$form .= '</div>';
|
||||
|
||||
return $form;
|
||||
default:
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
public function form($short, $label, $name, $class, $placeholder = '')
|
||||
{
|
||||
$queueid = $this->getIdByShortName($short);
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($queueid);
|
||||
if ($queue) {
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, $queue->getExtraField($name), ['class' => 'form-control', 'placeholder' => $placeholder]).'</div>';
|
||||
} else {
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, null, ['class' => 'form-control', 'placeholder' => $placeholder]).'</div>';
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
@@ -78,19 +78,21 @@ class LibraryController extends Controller
|
||||
{
|
||||
try {
|
||||
$encrypted = json_decode($encrypted);
|
||||
$sealed_data = $encrypted->seal;
|
||||
$envelope = $encrypted->envelope;
|
||||
$input = base64_decode($sealed_data);
|
||||
$einput = base64_decode($envelope);
|
||||
$path = storage_path('app'.DIRECTORY_SEPARATOR.'private.key');
|
||||
$key_content = file_get_contents($path);
|
||||
$private_key = openssl_get_privatekey($key_content);
|
||||
$plaintext = null;
|
||||
openssl_open($input, $plaintext, $einput, $private_key);
|
||||
if ($encrypted) {
|
||||
$sealed_data = $encrypted->seal;
|
||||
$envelope = $encrypted->envelope;
|
||||
$input = base64_decode($sealed_data);
|
||||
$einput = base64_decode($envelope);
|
||||
$path = storage_path('app'.DIRECTORY_SEPARATOR.'private.key');
|
||||
$key_content = file_get_contents($path);
|
||||
$private_key = openssl_get_privatekey($key_content);
|
||||
$plaintext = null;
|
||||
openssl_open($input, $plaintext, $einput, $private_key);
|
||||
|
||||
return $plaintext;
|
||||
return $plaintext;
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
// dd($ex);
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,9 @@ class Authenticate
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
$result = ['fails' => 'Unauthorized! Please login again'];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
} else {
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* CheckRole.
|
||||
@@ -25,6 +26,6 @@ class CheckRole
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return redirect('guest')->with('fails', 'You are not authorised');
|
||||
return redirect('guest')->with('fails', Lang::get('lang.not-autherised'));
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* CheckRoleAgent.
|
||||
@@ -25,6 +26,6 @@ class CheckRoleAgent
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return redirect('dashboard')->with('fails', 'You are not authorised');
|
||||
return redirect('dashboard')->with('fails', Lang::get('lang.not-autherised'));
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* CheckRoleUser.
|
||||
@@ -25,6 +26,6 @@ class CheckRoleUser
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return redirect('guest')->with('fails', 'You are not authorised');
|
||||
return redirect('guest')->with('fails', Lang::get('lang.not-autherised'));
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
|
||||
/**
|
||||
* AgentRequest.
|
||||
@@ -28,10 +29,15 @@ class AgentRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$check = $this->check(new CommonSettings());
|
||||
if ($check != 0) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
return [
|
||||
'user_name' => 'required|unique:users|max:30',
|
||||
'first_name' => 'required|max:30',
|
||||
'last_name' => 'required|max:30',
|
||||
// 'last_name' => 'required|max:30',
|
||||
'email' => 'required|unique:users',
|
||||
'active' => 'required',
|
||||
// 'account_status' => 'required',
|
||||
@@ -39,8 +45,42 @@ class AgentRequest extends Request
|
||||
'primary_department' => 'required',
|
||||
'agent_time_zone' => 'required',
|
||||
// 'phone_number' => 'phone:IN',
|
||||
// 'mobile' => 'phone:IN',
|
||||
'team' => 'required',
|
||||
'mobile' => 'unique:users',
|
||||
'team' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*@category Funcion to set rule if send opt is enabled
|
||||
*
|
||||
*@param object $settings (instance of Model common settings)
|
||||
*
|
||||
*@author manish.verma@ladybirdweb.com
|
||||
*
|
||||
*@return array|int
|
||||
*/
|
||||
public function check($settings)
|
||||
{
|
||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
if ($settings->status == '1' || $settings->status == 1) {
|
||||
return [
|
||||
'user_name' => 'required|unique:users|max:30',
|
||||
'first_name' => 'required|max:30',
|
||||
// 'last_name' => 'required|max:30',
|
||||
'email' => 'required|unique:users',
|
||||
'active' => 'required',
|
||||
// 'account_status' => 'required',
|
||||
'group' => 'required',
|
||||
'primary_department' => 'required',
|
||||
'agent_time_zone' => 'required',
|
||||
// 'phone_number' => 'phone:IN',
|
||||
// 'mobile' => 'phone:IN',
|
||||
'team' => 'required',
|
||||
'mobile' => 'required|unique:users',
|
||||
'country_code' => 'required',
|
||||
];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class AgentUpdate extends Request
|
||||
return [
|
||||
'user_name' => 'required|max:30|min:3|unique:users,user_name,'.$this->segment(2),
|
||||
'first_name' => 'required|max:30',
|
||||
'last_name' => 'required|max:30',
|
||||
// 'last_name' => 'required|max:30',
|
||||
'email' => 'required|email|unique:users,email,'.$this->segment(2),
|
||||
'active' => 'required',
|
||||
'role' => 'required',
|
||||
@@ -39,6 +39,7 @@ class AgentUpdate extends Request
|
||||
'primary_department' => 'required',
|
||||
'agent_time_zone' => 'required',
|
||||
'team' => 'required',
|
||||
'mobile' => 'unique:users,mobile,'.$this->segment(2),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
37
app/Http/Requests/helpdesk/ChangepasswordRequest.php
Normal file
37
app/Http/Requests/helpdesk/ChangepasswordRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* DiagnoRequest.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ChangepasswordRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'change_password' => 'required',
|
||||
// 'message' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
|
||||
/**
|
||||
* CompanyRequest.
|
||||
@@ -28,11 +29,133 @@ class ClientRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
$check = $this->check(new CommonSettings());
|
||||
if ($check != 0) {
|
||||
return $check;
|
||||
$custom_rule = $this->getCustomRule();
|
||||
$rules = array_merge($check, $custom_rule);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
$current_rule = [
|
||||
'Name' => 'required',
|
||||
'Email' => 'required|email',
|
||||
'Subject' => 'required',
|
||||
'Details' => 'required',
|
||||
];
|
||||
$custom_rule = $this->getCustomRule();
|
||||
$rules = array_merge($current_rule, $custom_rule);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getHelpTopic()
|
||||
{
|
||||
$help_topics = new \App\Model\helpdesk\Manage\Help_topic();
|
||||
$topic = $this->input('helptopic');
|
||||
$help_topic = $help_topics->where('id', $topic)->first();
|
||||
|
||||
return $help_topic;
|
||||
}
|
||||
|
||||
public function getCustomRule()
|
||||
{
|
||||
$custom_form = '';
|
||||
$help_topic = $this->getHelpTopic();
|
||||
if ($help_topic) {
|
||||
$custom_form = $help_topic->custom_form;
|
||||
}
|
||||
|
||||
return $this->getForm($custom_form);
|
||||
}
|
||||
|
||||
public function getForm($formid)
|
||||
{
|
||||
$id = '';
|
||||
$forms = new \App\Model\helpdesk\Form\Forms();
|
||||
$form = $forms->where('id', $formid)->first();
|
||||
if ($form) {
|
||||
$id = $form->id;
|
||||
}
|
||||
|
||||
return $this->getFields($id);
|
||||
}
|
||||
|
||||
public function getFields($formid)
|
||||
{
|
||||
$rules = [];
|
||||
$field = new \App\Model\helpdesk\Form\Fields();
|
||||
$fields = $field->where('forms_id', $formid)->get();
|
||||
if ($fields->count() > 0) {
|
||||
foreach ($fields as $fd) {
|
||||
if ($fd->required === '1') {
|
||||
$rules[str_replace(' ', '_', $fd->name)] = 'required';
|
||||
}
|
||||
$rules = array_merge($rules, $this->getChild($fd->id));
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getChild($fieldid)
|
||||
{
|
||||
$children = new \App\Model\helpdesk\Form\FieldValue();
|
||||
$childs = $children->where('field_id', $fieldid)->get();
|
||||
$rules = [];
|
||||
if ($childs->count() > 0) {
|
||||
foreach ($childs as $child) {
|
||||
$child_formid = $child->child_id;
|
||||
|
||||
return $this->getForm($child_formid);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
*@category Funcion to set rule if send opt is enabled
|
||||
*
|
||||
*@param object $settings (instance of Model common settings)
|
||||
*
|
||||
*@author manish.verma@ladybirdweb.com
|
||||
*
|
||||
*@return array|int
|
||||
*/
|
||||
public function check($settings)
|
||||
{
|
||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
if (($email_mandatory->status == 0 || $email_mandatory->status == '0')) {
|
||||
if (!\Auth::check()) {
|
||||
return [
|
||||
'Name' => 'required',
|
||||
'Email' => 'email',
|
||||
'Subject' => 'required',
|
||||
'Details' => 'required',
|
||||
'mobile' => 'required',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'Subject' => 'required',
|
||||
'Details' => 'required',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// public function purifyArray($array){
|
||||
// $purified = [];
|
||||
// foreach($array as $key=>$value){
|
||||
// if(!is_array($value)){
|
||||
// $purified[$key]="required";
|
||||
// }else{
|
||||
// $purified[] = $this->purifyArray($value);
|
||||
// }
|
||||
// }
|
||||
// return array_dot($purified);
|
||||
// }
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
|
||||
/**
|
||||
* CreateTicketRequest.
|
||||
@@ -21,6 +22,15 @@ class CreateTicketRequest extends Request
|
||||
return true;
|
||||
}
|
||||
|
||||
public function wantsJson()
|
||||
{
|
||||
if (in_array('api', $this->segments())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -28,8 +38,12 @@ class CreateTicketRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
$check = $this->check(new CommonSettings());
|
||||
if ($check != 0) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
return [
|
||||
'email' => 'required|email|max:60',
|
||||
'first_name' => 'required|min:3|max:40',
|
||||
'helptopic' => 'required',
|
||||
@@ -40,4 +54,69 @@ class CreateTicketRequest extends Request
|
||||
'priority' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*@category Funcion to set rule if send opt is enabled
|
||||
*
|
||||
*@param object $settings (instance of Model common settings)
|
||||
*
|
||||
*@author manish.verma@ladybirdweb.com
|
||||
*
|
||||
*@return array|int
|
||||
*/
|
||||
public function check($settings)
|
||||
{
|
||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
// dd($settings->status, $email_mandatory->status);
|
||||
if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
|
||||
return [
|
||||
'email' => 'required|email|max:60',
|
||||
'first_name' => 'required|min:3|max:40',
|
||||
'helptopic' => 'required',
|
||||
// 'dept' => 'required',
|
||||
'sla' => 'required',
|
||||
'subject' => 'required|min:5',
|
||||
'body' => 'required|min:10',
|
||||
'priority' => 'required',
|
||||
'code' => 'required',
|
||||
'mobile' => 'required',
|
||||
];
|
||||
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
|
||||
return 0;
|
||||
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
|
||||
$rule = $this->onlyMobleRequired();
|
||||
|
||||
return $rule;
|
||||
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
|
||||
$rule = $this->onlyMobleRequired();
|
||||
|
||||
return $rule;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@category function to make only moble required rule
|
||||
*
|
||||
*@param null
|
||||
*
|
||||
*@return array
|
||||
*/
|
||||
public function onlyMobleRequired()
|
||||
{
|
||||
return [
|
||||
'email' => 'email|max:60',
|
||||
'first_name' => 'required|min:3|max:40',
|
||||
'helptopic' => 'required',
|
||||
// 'dept' => 'required',
|
||||
'sla' => 'required',
|
||||
'subject' => 'required|min:5',
|
||||
'body' => 'required|min:10',
|
||||
'priority' => 'required',
|
||||
'code' => 'required',
|
||||
'mobile' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
48
app/Http/Requests/helpdesk/Job/TaskRequest.php
Normal file
48
app/Http/Requests/helpdesk/Job/TaskRequest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk\Job;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class TaskRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'fetching-commands' => 'required_if:email_fetching,1',
|
||||
'notification-commands' => 'required_if:notification_cron,1',
|
||||
'work-commands' => 'required_if:condition,1',
|
||||
'workflow-dailyAt' => 'required_if:work-commands,dailyAt',
|
||||
'notification-dailyAt' => 'required_if:notification-commands,dailyAt',
|
||||
'fetching-dailyAt' => 'required_if:fetching-commands,dailyAt',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'fetching-commands.required_if' => 'Please choose your Email Fetching timing',
|
||||
'notification-commands.required_if' => 'Please choose your Email Notification timing',
|
||||
'work-commands.required_if' => 'Please choose your Auto-close Workflow timing',
|
||||
'workflow-dailyAt.required_if' => 'Please enter the time for Auto-close Workflow timing',
|
||||
'notification-dailyAt.required_if' => 'Please enter the time for Email Notification timing',
|
||||
'fetching-dailyAt.required_if' => 'Please enter the time for Email Fetching timing',
|
||||
|
||||
];
|
||||
}
|
||||
}
|
80
app/Http/Requests/helpdesk/Mail/MailRequest.php
Normal file
80
app/Http/Requests/helpdesk/Mail/MailRequest.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk\Mail;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class MailRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$id = $this->segment(2);
|
||||
$email_address_rule = 'required|email|unique:emails';
|
||||
if ($id) {
|
||||
$email_address_rule = 'required|email|unique:emails,id,'.$id;
|
||||
}
|
||||
|
||||
|
||||
$rules = [
|
||||
'email_address' => $email_address_rule,
|
||||
'email_name' => 'required',
|
||||
'password' => 'required',
|
||||
'sending_protocol' => 'required_if:sending_status,on',
|
||||
];
|
||||
$driver = $this->input('sending_protocol');
|
||||
$driver_rules = $this->getDriver($driver);
|
||||
$rules = array_merge($rules, $driver_rules);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getDriver($serviceid)
|
||||
{
|
||||
$rules = [];
|
||||
$mail_services = new \App\Model\MailJob\MailService();
|
||||
$mail_service = $mail_services->find($serviceid);
|
||||
if ($mail_service) {
|
||||
$short = $mail_service->short_name;
|
||||
$rules = $this->getRules($short);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getRules($short)
|
||||
{
|
||||
$rules = [];
|
||||
switch ($short) {
|
||||
case 'mailgun':
|
||||
$rules = [
|
||||
'domain' => 'required',
|
||||
'secret' => 'required',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
case 'mandrill':
|
||||
$rules = [
|
||||
'secret' => 'required',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
default:
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
}
|
36
app/Http/Requests/helpdesk/OtpVerifyRequest.php
Normal file
36
app/Http/Requests/helpdesk/OtpVerifyRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* LoginRequest.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class OtpVerifyRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'email' => 'required',
|
||||
'mobile' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
47
app/Http/Requests/helpdesk/PriorityRequest.php
Normal file
47
app/Http/Requests/helpdesk/PriorityRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* BanlistRequest.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PriorityRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
|
||||
'priority' => 'required|max:10',
|
||||
'status' => 'required',
|
||||
'priority_desc' => 'required|max:255',
|
||||
'priority_color' => 'required',
|
||||
'ispublic' => 'required',
|
||||
'priority_successfully_updated' => 'priority successfully updated',
|
||||
'priority_successfully_created!!!' => 'priority successfully created',
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
}
|
@@ -31,6 +31,7 @@ class ProfileRequest extends Request
|
||||
return [
|
||||
'first_name' => 'required',
|
||||
'profile_pic' => 'mimes:png,jpeg',
|
||||
// 'mobile' => 'unique:users,mobile',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
43
app/Http/Requests/helpdesk/Queue/QueueRequest.php
Normal file
43
app/Http/Requests/helpdesk/Queue/QueueRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk\Queue;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class QueueRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$request = $this->except('_token');
|
||||
$rules = $this->setRule($request);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function setRule($request)
|
||||
{
|
||||
$rules = [];
|
||||
if (count($request) > 0) {
|
||||
foreach ($request as $key => $value) {
|
||||
$rules[$key] = 'required';
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
|
||||
/**
|
||||
* RegisterRequest.
|
||||
@@ -28,6 +29,11 @@ class RegisterRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$check = $this->check(new CommonSettings());
|
||||
if ($check != 0) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
return [
|
||||
'email' => 'required|max:50|email|unique:users',
|
||||
'full_name' => 'required',
|
||||
@@ -35,4 +41,43 @@ class RegisterRequest extends Request
|
||||
'password_confirmation' => 'required|same:password',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*@category Funcion to set rule if send opt is enabled
|
||||
*
|
||||
*@param object $settings (instance of Model common settings)
|
||||
*
|
||||
*@author manish.verma@ladybirdweb.com
|
||||
*
|
||||
*@return array|int
|
||||
*/
|
||||
public function check($settings)
|
||||
{
|
||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
// dd($settings->status, $email_mandatory->status);
|
||||
if ($settings->status == '0' || $settings->status == 0 && ($email_mandatory->status == 0 || $email_mandatory->status == '0')) {
|
||||
return 0;
|
||||
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == 1 || $email_mandatory->status == '1')) {
|
||||
return [
|
||||
'email' => 'required|max:50|email|unique:users',
|
||||
'full_name' => 'required',
|
||||
'password' => 'required|min:6',
|
||||
'password_confirmation' => 'required|same:password',
|
||||
'code' => 'required',
|
||||
'mobile' => 'required|unique:users',
|
||||
];
|
||||
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == 0 || $email_mandatory->status == '0')) {
|
||||
return [
|
||||
'email' => 'max:50|email|unique:users',
|
||||
'full_name' => 'required',
|
||||
'password' => 'required|min:6',
|
||||
'password_confirmation' => 'required|same:password',
|
||||
'code' => 'required',
|
||||
'mobile' => 'required|unique:users',
|
||||
];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
|
||||
/**
|
||||
* Sys_userRequest.
|
||||
@@ -28,10 +29,70 @@ class Sys_userRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$check = $this->check(new CommonSettings());
|
||||
if ($check != 0) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
return [
|
||||
'first_name' => 'required',
|
||||
'user_name' => 'required|min:3|unique:users,user_name',
|
||||
'email' => 'required|unique:users,email',
|
||||
'mobile' => 'unique:users',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*@category Funcion to set rule if send opt is enabled
|
||||
*
|
||||
*@param object $settings (instance of Model common settings)
|
||||
*
|
||||
*@author manish.verma@ladybirdweb.com
|
||||
*
|
||||
*@return array|int
|
||||
*/
|
||||
public function check($settings)
|
||||
{
|
||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
|
||||
return [
|
||||
'first_name' => 'required',
|
||||
'user_name' => 'required|min:3|unique:users,user_name',
|
||||
'email' => 'required|unique:users,email',
|
||||
'country_code' => 'required',
|
||||
'mobile' => 'required|unique:users',
|
||||
];
|
||||
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
|
||||
return 0;
|
||||
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
|
||||
$rule = $this->onlyMobleRequired();
|
||||
|
||||
return $rule;
|
||||
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
|
||||
$rule = $this->onlyMobleRequired();
|
||||
|
||||
return $rule;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@category function to make only moble required rule
|
||||
*
|
||||
*@param null
|
||||
*
|
||||
*@return array
|
||||
*/
|
||||
public function onlyMobleRequired()
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required',
|
||||
'user_name' => 'required|min:3|unique:users,user_name',
|
||||
'email' => 'unique:users,email',
|
||||
'country_code' => 'required',
|
||||
'mobile' => 'required|unique:users',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ class Sys_userUpdate extends Request
|
||||
'first_name' => 'required',
|
||||
'user_name' => 'required|min:3|unique:users,user_name,'.$this->segment(2),
|
||||
'email' => 'required|email|unique:users,email,'.$this->segment(2),
|
||||
'mobile' => 'unique:users,mobile,'.$this->segment(2),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
44
app/Http/helpers.php
Normal file
44
app/Http/helpers.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
function loging($context, $message, $level = 'error', $array = [])
|
||||
{
|
||||
\Log::$level($message.':-:-:-'.$context, $array);
|
||||
}
|
||||
|
||||
function checkArray($key, $array)
|
||||
{
|
||||
$value = '';
|
||||
if (array_key_exists($key, $array)) {
|
||||
$value = $array[$key];
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
function mime($type)
|
||||
{
|
||||
if ($type == 'jpg' ||
|
||||
$type == 'png' ||
|
||||
$type == 'PNG' ||
|
||||
$type == 'JPG' ||
|
||||
$type == 'jpeg' ||
|
||||
$type == 'JPEG' ||
|
||||
$type == 'gif' ||
|
||||
$type == 'GIF' ||
|
||||
$type == 'image/jpeg' ||
|
||||
$type == 'image/jpg' ||
|
||||
$type == 'image/gif' ||
|
||||
$type == 'application/octet-stream' ||
|
||||
$type == 'image/png' ||
|
||||
starts_with($type, 'image')) {
|
||||
return 'image';
|
||||
}
|
||||
}
|
||||
function removeUnderscore($string)
|
||||
{
|
||||
if (str_contains($string, '_') === true) {
|
||||
$string = str_replace('_', ' ', $string);
|
||||
}
|
||||
|
||||
return ucfirst($string);
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
@@ -13,15 +14,18 @@ Route::group(['middleware' => ['web']], function () {
|
||||
Route::group(['middleware' => 'update', 'middleware' => 'install'], function () {
|
||||
Route::controllers([
|
||||
'auth' => 'Auth\AuthController',
|
||||
// 'password' => 'Auth\PasswordController',
|
||||
]);
|
||||
});
|
||||
Route::controllers([
|
||||
'password' => 'Auth\PasswordController',
|
||||
]);
|
||||
|
||||
]);
|
||||
Route::get('social/login/redirect/{provider}/{redirect?}', ['uses' => 'Auth\AuthController@redirectToProvider', 'as' => 'social.login']);
|
||||
Route::get('social/login/{provider}', ['as' => 'social.login.callback', 'uses' => 'Auth\AuthController@handleProviderCallback']);
|
||||
Route::get('social-sync', ['as' => 'social.sync', 'uses' => 'Client\helpdesk\GuestController@sync']);
|
||||
});
|
||||
Route::get('account/activate/{token}', ['as' => 'account.activate', 'uses' => 'Auth\AuthController@accountActivate']);
|
||||
Route::get('getmail/{token}', 'Auth\AuthController@getMail');
|
||||
Route::get('verify-otp', ['as' => 'otp-verification', 'uses' => 'Auth\AuthController@getVerifyOTP']);
|
||||
Route::post('verify-otp', ['as' => 'otp-verification', 'uses' => 'Auth\AuthController@verifyOTP']);
|
||||
Route::post('resend/opt', ['as' => 'resend-otp', 'uses' => 'Auth\AuthController@resendOTP']);
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------------------------
|
||||
| Admin Routes
|
||||
@@ -86,6 +90,12 @@ Route::group(['middleware' => ['web']], function () {
|
||||
$breadcrumbs->parent('teams.index');
|
||||
$breadcrumbs->push(Lang::get('lang.edit'), url('teams/{teams}/edit'));
|
||||
});
|
||||
Route::get('/teams/show/{id}', ['as' => 'teams.show', 'uses' => 'Admin\helpdesk\TeamController@show']); /* Get Team View */
|
||||
Breadcrumbs::register('teams.show', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('teams.index');
|
||||
$breadcrumbs->push(Lang::get('lang.show'), url('teams/{teams}/show'));
|
||||
});
|
||||
Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpdesk\TeamController@getshow']);
|
||||
Route::resource('agents', 'Admin\helpdesk\AgentController'); // in agents module, for CRUD
|
||||
Breadcrumbs::register('agents.index', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
@@ -192,14 +202,15 @@ Route::group(['middleware' => ['web']], function () {
|
||||
$breadcrumbs->push(Lang::get('lang.edit'), url('sla/{sla}/edit'));
|
||||
});
|
||||
Route::resource('forms', 'Admin\helpdesk\FormController');
|
||||
Route::get('forms/add-child/{formid}', ['as' => 'forms.add.child', 'uses' => 'Admin\helpdesk\FormController@addChildForm']);
|
||||
Route::post('forms/field/{fieldid}/child', [
|
||||
'as' => 'forms.field.child',
|
||||
'uses' => 'Admin\helpdesk\FormController@addChild',
|
||||
]);
|
||||
]);
|
||||
Route::get('forms/render/child', [
|
||||
'as' => 'forms.field.child',
|
||||
'uses' => 'Admin\helpdesk\FormController@renderChild',
|
||||
]);
|
||||
]);
|
||||
Breadcrumbs::register('forms.index', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
$breadcrumbs->push(Lang::get('lang.forms'), route('forms.index'));
|
||||
@@ -216,6 +227,10 @@ Route::group(['middleware' => ['web']], function () {
|
||||
$breadcrumbs->parent('forms.index');
|
||||
$breadcrumbs->push(Lang::get('lang.view'), url('forms/{forms}'));
|
||||
});
|
||||
Breadcrumbs::register('forms.add.child', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('forms.index');
|
||||
$breadcrumbs->push('Add Child', url('forms/add-child/{forms}'));
|
||||
});
|
||||
Route::get('delete-forms/{id}', ['as' => 'forms.delete', 'uses' => 'Admin\helpdesk\FormController@delete']);
|
||||
//$router->model('id','getcompany');
|
||||
Route::get('job-scheduler', ['as' => 'get.job.scheder', 'uses' => 'Admin\helpdesk\SettingsController@getSchedular']); //to get ob scheduler form page
|
||||
@@ -450,6 +465,9 @@ Route::group(['middleware' => ['web']], function () {
|
||||
Route::get('user-agen1', 'Agent\helpdesk\DashboardController@userChartData');
|
||||
Route::post('user-chart-range', ['as' => 'post.user.chart', 'uses' => 'Agent\helpdesk\DashboardController@userChartData']);
|
||||
Route::resource('user', 'Agent\helpdesk\UserController'); /* User router is used to control the CRUD of user */
|
||||
Route::get('user-export', ['as' => 'user.export', 'uses' => 'Agent\helpdesk\UserController@getExportUser']); /* User router is used to control the CRUD of user */
|
||||
Route::post('user-export', ['as' => 'user.export.post', 'uses' => 'Agent\helpdesk\UserController@exportUser']); /* User router is used to control the CRUD of user */
|
||||
|
||||
Breadcrumbs::register('user.index', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('dashboard');
|
||||
$breadcrumbs->push(Lang::get('lang.user_directory'), route('user.index'));
|
||||
@@ -469,6 +487,7 @@ Route::group(['middleware' => ['web']], function () {
|
||||
Route::get('user-list', ['as' => 'user.list', 'uses' => 'Agent\helpdesk\UserController@user_list']);
|
||||
// Route::get('user/delete/{id}', ['as' => 'user.delete' , 'uses' => 'Agent\helpdesk\UserController@destroy']);
|
||||
Route::resource('organizations', 'Agent\helpdesk\OrganizationController'); /* organization router used to deal CRUD function of organization */
|
||||
Route::get('get-organization', ['as' => 'org.get.ajax', 'uses' => 'Agent\helpdesk\OrganizationController@getOrgAjax']);
|
||||
Breadcrumbs::register('organizations.index', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('dashboard');
|
||||
$breadcrumbs->push(Lang::get('lang.organizations'), route('organizations.index'));
|
||||
@@ -500,6 +519,10 @@ Route::group(['middleware' => ['web']], function () {
|
||||
$breadcrumbs->parent('profile');
|
||||
$breadcrumbs->push(Lang::get('lang.edit'), url('profile-edit'));
|
||||
});
|
||||
|
||||
Route::post('verify-number', ['as' => 'agent-verify-number', 'uses' => 'Agent\helpdesk\UserController@resendOTP']);
|
||||
Route::post('verify-number2', ['as' => 'post-agent-verify-number', 'uses' => 'Agent\helpdesk\UserController@verifyOTP']);
|
||||
|
||||
Route::patch('agent-profile', ['as' => 'agent-profile', 'uses' => 'Agent\helpdesk\UserController@postProfileedit']); /* User Profile Post */
|
||||
Route::patch('agent-profile-password/{id}', 'Agent\helpdesk\UserController@postProfilePassword'); /* Profile Password Post */
|
||||
Route::get('canned/list', ['as' => 'canned.list', 'uses' => 'Agent\helpdesk\CannedController@index']); /* Canned list */
|
||||
@@ -656,7 +679,20 @@ Route::group(['middleware' => ['web']], function () {
|
||||
Route::get('/get-closed-tickets/{id}', ['as' => 'get.dept.close', 'uses' => 'Agent\helpdesk\Ticket2Controller@getCloseTickets']);
|
||||
//in progress ticket of department
|
||||
Route::get('/get-under-process-tickets/{id}', ['as' => 'get.dept.inprocess', 'uses' => 'Agent\helpdesk\Ticket2Controller@getInProcessTickets']);
|
||||
|
||||
// route for graphical reporting
|
||||
Route::get('report', ['as' => 'report.index', 'uses' => 'Agent\helpdesk\ReportController@index']); /* To show dashboard pages */
|
||||
Breadcrumbs::register('report.index', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('dashboard');
|
||||
$breadcrumbs->push(Lang::get('lang.dashboard'), route('dashboard'));
|
||||
});
|
||||
// default route to get the data for the first time
|
||||
Route::get('help-topic-report', 'Agent\helpdesk\ReportController@chartdataHelptopic');
|
||||
// route to get the data on change
|
||||
Route::post('help-topic-report/{date1}/{date2}/{id}', ['as' => 'report.helptopic', 'uses' => 'Agent\helpdesk\ReportController@chartdataHelptopic']); /* To show dashboard pages */
|
||||
Route::post('help-topic-pdf', ['as' => 'help.topic.pdf', 'uses' => 'Agent\helpdesk\ReportController@helptopicPdf']);
|
||||
});
|
||||
|
||||
/*
|
||||
|------------------------------------------------------------------
|
||||
|Guest Routes
|
||||
@@ -683,7 +719,7 @@ Route::group(['middleware' => ['web']], function () {
|
||||
});
|
||||
|
||||
Route::post('postform/{id}', 'Client\helpdesk\FormController@postForm'); /* post the AJAX form for create a ticket by guest user */
|
||||
Route::post('postedform', 'Client\helpdesk\FormController@postedForm'); /* post the form to store the value */
|
||||
Route::post('postedform', ['as' => 'client.form.post', 'uses' => 'Client\helpdesk\FormController@postedForm']); /* post the form to store the value */
|
||||
Route::get('check', 'CheckController@getcheck'); //testing checkbox auto-populate
|
||||
Route::post('postcheck/{id}', 'CheckController@postcheck');
|
||||
Route::get('get-helptopic-form', 'Client\helpdesk\FormController@getCustomForm');
|
||||
@@ -728,6 +764,14 @@ Route::group(['middleware' => ['web']], function () {
|
||||
Route::patch('client-profile-edit', 'Client\helpdesk\GuestController@postProfile'); /* User Profile Post */
|
||||
Route::patch('client-profile-password', 'Client\helpdesk\GuestController@postProfilePassword'); /* Profile Password Post */
|
||||
Route::post('post/reply/{id}', ['as' => 'client.reply', 'uses' => 'Client\helpdesk\ClientTicketController@reply']);
|
||||
Route::post('verify-client-number', ['as' => 'client-verify-number', 'uses' => 'Client\helpdesk\GuestController@resendOTP']);
|
||||
Breadcrumbs::register('client-verify-number', function ($breadcrumbs) {
|
||||
$breadcrumbs->push('Profile', route('client-verify-number'));
|
||||
});
|
||||
Route::post('verify-client-number2', ['as' => 'post-client-verify-number', 'uses' => 'Client\helpdesk\GuestController@verifyOTP']);
|
||||
Breadcrumbs::register('post-client-verify-number', function ($breadcrumbs) {
|
||||
$breadcrumbs->push('My Profile', route('post-client-verify-number'));
|
||||
});
|
||||
});
|
||||
//====================================================================================
|
||||
Route::get('checkticket', 'Client\helpdesk\ClientTicketController@getCheckTicket'); /* Check your Ticket */
|
||||
@@ -744,7 +788,8 @@ Route::group(['middleware' => ['web']], function () {
|
||||
|
|
||||
*/
|
||||
Route::get('/serial', ['as' => 'serialkey', 'uses' => 'Installer\helpdesk\InstallController@serialkey']);
|
||||
Route::post('/CheckSerial/{id}', ['as' => 'CheckSerial', 'uses' => 'Installer\helpdesk\InstallController@PostSerialKey']);
|
||||
Route::post('/post-serial', ['as' => 'post.serialkey', 'uses' => 'Installer\helpdesk\InstallController@postSerialKeyToFaveo']);
|
||||
Route::post('/CheckSerial', ['as' => 'CheckSerial', 'uses' => 'Installer\helpdesk\InstallController@PostSerialKey']);
|
||||
Route::get('/JavaScript-disabled', ['as' => 'js-disabled', 'uses' => 'Installer\helpdesk\InstallController@jsDisabled']);
|
||||
Route::get('/step1', ['as' => 'licence', 'uses' => 'Installer\helpdesk\InstallController@licence']);
|
||||
Route::post('/step1post', ['as' => 'postlicence', 'uses' => 'Installer\helpdesk\InstallController@licencecheck']);
|
||||
@@ -996,8 +1041,8 @@ Route::group(['middleware' => ['web']], function () {
|
||||
// Route::patch('client-profile-edit',['as' => 'client-profile-edit', 'uses' => 'Client\kb\UserController@postClientProfile']);
|
||||
// Route::patch('client-profile-password/{id}',['as' => 'client-profile-password', 'uses' => 'Client\kb\UserController@postClientProfilePassword']);
|
||||
Route::get('/inbox/data', ['as' => 'api.inbox', 'uses' => 'Agent\helpdesk\TicketController@get_inbox']);
|
||||
Route::get('/report', 'HomeController@getreport');
|
||||
Route::get('/reportdata', 'HomeController@pushdata');
|
||||
// Route::get('/report', 'HomeController@getreport');
|
||||
// Route::get('/reportdata', 'HomeController@pushdata');
|
||||
/*
|
||||
* ================================================================================================
|
||||
* @version v1
|
||||
@@ -1094,7 +1139,7 @@ Route::group(['middleware' => ['web']], function () {
|
||||
/*
|
||||
* FCM token response
|
||||
*/
|
||||
Route::post('fcmtoken', ['as' => 'fcmtoken', 'uses' => 'Api\v1\PushNotificationController@fcmToken']);
|
||||
Route::post('fcmtoken', ['as' => 'fcmtoken', 'uses' => 'Common\PushNotificationController@fcmToken']);
|
||||
});
|
||||
/*
|
||||
* Update module
|
||||
@@ -1114,4 +1159,93 @@ Route::group(['middleware' => ['web']], function () {
|
||||
|
||||
|
||||
Route::get('test', ['as' => 'test', 'uses' => 'Common\PushNotificationController@response']);
|
||||
|
||||
Route::get('mail/config/service', ['as' => 'mail.config.service', 'uses' => 'Job\MailController@serviceForm']);
|
||||
/*
|
||||
* Queue
|
||||
*/
|
||||
Breadcrumbs::register('queue', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
$breadcrumbs->push(Lang::get('lang.queues'), route('queue'));
|
||||
});
|
||||
Route::get('queue', ['as' => 'queue', 'uses' => 'Job\QueueController@index']);
|
||||
Route::get('form/queue', ['as' => 'queue.form', 'uses' => 'Job\QueueController@getForm']);
|
||||
Breadcrumbs::register('queue.edit', function ($breadcrumbs) {
|
||||
$id = \Input::segment(2);
|
||||
$breadcrumbs->parent('queue');
|
||||
$breadcrumbs->push(Lang::get('lang.edit'), route('queue.edit', $id));
|
||||
});
|
||||
Route::get('queue/{id}', ['as' => 'queue.edit', 'uses' => 'Job\QueueController@edit']);
|
||||
Route::post('queue/{id}', ['as' => 'queue.update', 'uses' => 'Job\QueueController@update']);
|
||||
Route::get('queue/{id}/activate', ['as' => 'queue.activate', 'uses' => 'Job\QueueController@activate']);
|
||||
Route::get('get-ticket-number', ['as' => 'get.ticket.number', 'uses' => 'Admin\helpdesk\SettingsController@getTicketNumber']);
|
||||
Route::get('genereate-pdf/{threadid}', ['as' => 'thread.pdf', 'uses' => 'Agent\helpdesk\TicketController@pdfThread']);
|
||||
|
||||
/*
|
||||
* Url Settings
|
||||
*/
|
||||
Breadcrumbs::register('url', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
$breadcrumbs->push('URL', route('url.settings'));
|
||||
});
|
||||
Route::get('url/settings', ['as' => 'url.settings', 'uses' => 'Admin\helpdesk\UrlSettingController@settings']);
|
||||
Route::patch('url/settings', ['as' => 'url.settings.post', 'uses' => 'Admin\helpdesk\UrlSettingController@postSettings']);
|
||||
|
||||
/*
|
||||
* Social media settings
|
||||
*/
|
||||
Breadcrumbs::register('social', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
$breadcrumbs->push(Lang::get('lang.social-media'), route('social'));
|
||||
});
|
||||
Breadcrumbs::register('social.media', function ($breadcrumbs) {
|
||||
$id = \Input::segment(2);
|
||||
$breadcrumbs->parent('social');
|
||||
$breadcrumbs->push(Lang::get('lang.settings'), route('social.media', $id));
|
||||
});
|
||||
Route::get('social/media', ['as' => 'social', 'uses' => 'Admin\helpdesk\SocialMedia\SocialMediaController@index']);
|
||||
Route::get('social/media/{provider}', ['as' => 'social.media', 'uses' => 'Admin\helpdesk\SocialMedia\SocialMediaController@settings']);
|
||||
Route::post('social/media/{provider}', ['as' => 'social.media.post', 'uses' => 'Admin\helpdesk\SocialMedia\SocialMediaController@postSettings']);
|
||||
/*
|
||||
* Ticket_Priority Settings
|
||||
*/
|
||||
Route::get('ticket_priority', ['as' => 'priority.index', 'uses' => 'Admin\helpdesk\PriorityController@priorityIndex']);
|
||||
Route::post('user_ticket_priority', ['as' => 'user.priority.index', 'uses' => 'Admin\helpdesk\PriorityController@userPriorityIndex']);
|
||||
|
||||
Route::get('get_index', ['as' => 'priority.index1', 'uses' => 'Admin\helpdesk\PriorityController@priorityIndex1']);
|
||||
Breadcrumbs::register('priority.index', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
$breadcrumbs->push(Lang::get('Ticket Priority'), route('priority.index'));
|
||||
});
|
||||
Route::get('ticket_priority/create', ['as' => 'priority.create', 'uses' => 'Admin\helpdesk\PriorityController@priorityCreate']);
|
||||
Breadcrumbs::register('priority.create', function ($breadcrumbs) {
|
||||
$breadcrumbs->parent('setting');
|
||||
$breadcrumbs->push(Lang::get('Ticket Priority'), route('priority.index'));
|
||||
$breadcrumbs->push(Lang::get('lang.create'), route('priority.create'));
|
||||
});
|
||||
Route::post('ticket_priority/create1', ['as' => 'priority.create1', 'uses' => 'Admin\helpdesk\PriorityController@priorityCreate1']);
|
||||
Route::post('ticket_priority/edit1', ['as' => 'priority.edit1', 'uses' => 'Admin\helpdesk\PriorityController@priorityEdit1']);
|
||||
Route::get('ticket_priority/{ticket_priority}/edit', ['as' => 'priority.edit', 'uses' => 'Admin\helpdesk\PriorityController@priorityEdit']);
|
||||
Breadcrumbs::register('priority.edit', function ($breadcrumbs) {
|
||||
$breadcrumbs->push(Lang::get('Ticket Priority'), route('priority.index'));
|
||||
$breadcrumbs->push(Lang::get('Edit'), route('priority.index'));
|
||||
});
|
||||
Route::get('ticket_priority/{ticket_priority}/destroy', ['as' => 'priority.destroy', 'uses' => 'Admin\helpdesk\PriorityController@destroy']);
|
||||
// user---arindam
|
||||
Route::post('rolechangeadmin/{id}', ['as' => 'user.post.rolechangeadmin', 'uses' => 'Agent\helpdesk\UserController@changeRoleAdmin']);
|
||||
Route::post('rolechangeagent/{id}', ['as' => 'user.post.rolechangeagent', 'uses' => 'Agent\helpdesk\UserController@changeRoleAgent']);
|
||||
Route::post('rolechangeuser/{id}', ['as' => 'user.post.rolechangeuser', 'uses' => 'Agent\helpdesk\UserController@changeRoleUser']);
|
||||
Route::get('password', ['as' => 'user.changepassword', 'uses' => 'Agent\helpdesk\UserController@randomPassword']);
|
||||
Route::post('changepassword/{id}', ['as' => 'user.post.changepassword', 'uses' => 'Agent\helpdesk\UserController@randomPostPassword']);
|
||||
Route::post('delete/{id}', ['as' => 'user.post.delete', 'uses' => 'Agent\helpdesk\UserController@deleteAgent']);
|
||||
|
||||
//due today ticket
|
||||
Route::get('duetoday', ['as' => 'ticket.duetoday', 'uses' => 'Agent\helpdesk\TicketController@dueTodayTicketlist']);
|
||||
|
||||
// Route::post('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']);
|
||||
Route::get('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' => 'Agent\helpdesk\TicketController@getDueToday']); /* Get Open Ticket */
|
||||
// Breadcrumbs::register('open.ticket', function ($breadcrumbs) {
|
||||
// $breadcrumbs->parent('dashboard');
|
||||
// $breadcrumbs->push(Lang::get('lang.tickets') . ' > ' . Lang::get('lang.open'), route('open.ticket'));
|
||||
// });
|
||||
});
|
||||
|
@@ -3,29 +3,32 @@
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use Illuminate\Contracts\Bus\SelfHandling;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SendEmail extends Job implements ShouldQueue
|
||||
class SendEmail extends Job implements SelfHandling,ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
use InteractsWithQueue,SerializesModels;
|
||||
|
||||
|
||||
protected $from;
|
||||
protected $to;
|
||||
protected $message;
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($from, $to, $message)
|
||||
public function __construct($from, $to, $message, $template_variables = '')
|
||||
{
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
$this->message = $message;
|
||||
$this->template = $template_variables;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,6 +38,8 @@ class SendEmail extends Job implements ShouldQueue
|
||||
*/
|
||||
public function handle(PhpMailController $PhpMailController)
|
||||
{
|
||||
$PhpMailController->sendEmail($this->from, $this->to, $this->message);
|
||||
$p = $PhpMailController->sendEmail($this->from, $this->to, $this->message, $this->template);
|
||||
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
|
74
app/Model/MailJob/Condition.php
Normal file
74
app/Model/MailJob/Condition.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\MailJob;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Condition extends Model
|
||||
{
|
||||
protected $table = 'conditions';
|
||||
protected $fillable = ['job', 'value'];
|
||||
|
||||
public function getConditionValue($job)
|
||||
{
|
||||
$value = ['condition' => '', 'at' => ''];
|
||||
$condition = $this->where('job', $job)->first();
|
||||
if ($condition) {
|
||||
$condition_value = explode(',', $condition->value);
|
||||
$value = ['condition' => $condition_value, 'at' => ''];
|
||||
if (is_array($condition_value)) {
|
||||
$value = ['condition' => $this->checkArray(0, $condition_value), 'at' => $this->checkArray(1, $condition_value)];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function checkArray($key, $array)
|
||||
{
|
||||
$value = '';
|
||||
if (is_array($array)) {
|
||||
if (array_key_exists($key, $array)) {
|
||||
$value = $array[$key];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function checkActiveJob()
|
||||
{
|
||||
$result = ['fetching' => '', 'notification' => '', 'work' => '', 'message' => ''];
|
||||
$emails = new \App\Model\helpdesk\Settings\Email();
|
||||
$email = $emails->find(1);
|
||||
if ($email) {
|
||||
if ($email->email_fetching == 1) {
|
||||
$result['fetching'] = true;
|
||||
}
|
||||
if ($email->notification_cron == 1) {
|
||||
$result['notification'] = true;
|
||||
}
|
||||
}
|
||||
$works = new \App\Model\helpdesk\Workflow\WorkflowClose();
|
||||
$work = $works->find(1);
|
||||
//dd($work);
|
||||
if ($work) {
|
||||
if ($work->condition == 1) {
|
||||
$result['work'] = true;
|
||||
}
|
||||
}
|
||||
if (\Schema::hasTable('sms_notify_setting')) {
|
||||
$message = new \App\Plugins\SMS\Model\SmsNotify();
|
||||
$message = $message->select('status')->where('name', '=', 'open_ticket_nofification')->first();
|
||||
if ($message) {
|
||||
if ($message->status) {
|
||||
$result['message'] = true;
|
||||
} else {
|
||||
$result['message'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
11
app/Model/MailJob/FaveoMail.php
Normal file
11
app/Model/MailJob/FaveoMail.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\MailJob;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FaveoMail extends Model
|
||||
{
|
||||
protected $table = 'faveo_mails';
|
||||
protected $fillable = ['drive', 'key', 'value', 'email_id'];
|
||||
}
|
11
app/Model/MailJob/FaveoQueue.php
Normal file
11
app/Model/MailJob/FaveoQueue.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\MailJob;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FaveoQueue extends Model
|
||||
{
|
||||
protected $table = 'faveo_queues';
|
||||
protected $fillable = ['key', 'value', 'service_id'];
|
||||
}
|
11
app/Model/MailJob/MailService.php
Normal file
11
app/Model/MailJob/MailService.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\MailJob;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MailService extends Model
|
||||
{
|
||||
protected $table = 'mail_services';
|
||||
protected $fillable = ['name', 'short_name'];
|
||||
}
|
72
app/Model/MailJob/QueueService.php
Normal file
72
app/Model/MailJob/QueueService.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\MailJob;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class QueueService extends Model
|
||||
{
|
||||
protected $table = 'queue_services';
|
||||
protected $fillable = ['name', 'short_name', 'status'];
|
||||
|
||||
public function extraFieldRelation()
|
||||
{
|
||||
$related = "App\Model\MailJob\FaveoQueue";
|
||||
|
||||
return $this->hasMany($related, 'service_id');
|
||||
}
|
||||
|
||||
public function getExtraField($key)
|
||||
{
|
||||
$value = '';
|
||||
$setting = $this->extraFieldRelation()->where('key', $key)->first();
|
||||
if ($setting) {
|
||||
$value = $setting->value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
$name = $this->attributes['name'];
|
||||
$id = $this->attributes['id'];
|
||||
$html = '<a href='.url('queue/'.$id).'>'.$name.'</a>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
$status = $this->attributes['status'];
|
||||
$html = "<span style='color:red'>Inactive</span>";
|
||||
if ($status == 1) {
|
||||
$html = "<span style='color:green'>Active</span>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getAction()
|
||||
{
|
||||
$id = $this->attributes['id'];
|
||||
$status = $this->attributes['status'];
|
||||
$html = '<a href='.url('queue/'.$id.'/activate')." class='btn btn-primary'>Activate</a>";
|
||||
if ($status == 1) {
|
||||
$html = "<a href='#' class='btn btn-primary' disabled>Activate</a>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function isActivate()
|
||||
{
|
||||
$check = true;
|
||||
$settings = $this->extraFieldRelation()->get();
|
||||
if ($settings->count() == 0) {
|
||||
$check = false;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
}
|
@@ -7,5 +7,5 @@ use App\BaseModel;
|
||||
class Assign_team_agent extends BaseModel
|
||||
{
|
||||
protected $table = 'team_assign_agent';
|
||||
protected $fillable = ['id', 'team_id', 'agent_id'];
|
||||
protected $fillable = ['id', 'team_id', 'agent_id', 'updated_at', 'created_at'];
|
||||
}
|
||||
|
@@ -12,4 +12,27 @@ class Organization extends BaseModel
|
||||
|
||||
/* Define the fillable fields */
|
||||
protected $fillable = ['id', 'name', 'phone', 'website', 'address', 'head', 'internal_notes'];
|
||||
|
||||
public function userRelation()
|
||||
{
|
||||
$related = "App\Model\helpdesk\Agent_panel\User_org";
|
||||
|
||||
return $this->hasMany($related, 'org_id');
|
||||
}
|
||||
|
||||
public function getUserIds()
|
||||
{
|
||||
$user_relations = $this->userRelation()->lists('user_id')->toArray();
|
||||
|
||||
return $user_relations;
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
$user = new \App\User();
|
||||
$user_ids = $this->getUserIds();
|
||||
$users = $user->whereIn('id', $user_ids);
|
||||
|
||||
return $users;
|
||||
}
|
||||
}
|
||||
|
@@ -12,4 +12,13 @@ class User_org extends BaseModel
|
||||
|
||||
/* define fillable fields */
|
||||
protected $fillable = ['id', 'org_id', 'user_id'];
|
||||
|
||||
public function setOrgIdAttribute($value)
|
||||
{
|
||||
if ($value == '') {
|
||||
$this->attributes['org_id'] = null;
|
||||
} else {
|
||||
$this->attributes['org_id'] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,4 +14,62 @@ class Emails extends BaseModel
|
||||
'fetching_status', 'move_to_folder', 'delete_email', 'do_nothing',
|
||||
'sending_status', 'authentication', 'header_spoofing', 'imap_config',
|
||||
];
|
||||
|
||||
public function getCurrentDrive()
|
||||
{
|
||||
$drive = $this->attributes['sending_protocol'];
|
||||
$mailServices = new \App\Model\MailJob\MailService();
|
||||
$id = '';
|
||||
$mailService = $mailServices->where('short_name', $drive)->first();
|
||||
if ($mailService) {
|
||||
$id = $mailService->id;
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function getExtraField($key)
|
||||
{
|
||||
$value = '';
|
||||
$id = $this->attributes['id'];
|
||||
$services = new \App\Model\MailJob\FaveoMail();
|
||||
$service = $services->where('email_id', $id)->where('key', $key)->first();
|
||||
if ($service) {
|
||||
$value = $service->value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function extraFieldRelation()
|
||||
{
|
||||
$related = "App\Model\MailJob\FaveoMail";
|
||||
|
||||
return $this->hasMany($related, 'email_id');
|
||||
}
|
||||
|
||||
public function deleteExtraFields()
|
||||
{
|
||||
$fields = $this->extraFieldRelation()->get();
|
||||
if ($fields->count() > 0) {
|
||||
foreach ($fields as $field) {
|
||||
$field->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getPasswordAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
return \Crypt::decrypt($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->deleteExtraFields();
|
||||
parent::delete();
|
||||
}
|
||||
}
|
||||
|
@@ -7,5 +7,16 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class FieldValue extends Model
|
||||
{
|
||||
protected $table = 'field_values';
|
||||
protected $fillable = ['field_id', 'parent_id', 'field_key', 'field_value'];
|
||||
protected $fillable = ['field_id', 'child_id', 'field_key', 'field_value'];
|
||||
|
||||
public function childId()
|
||||
{
|
||||
$childid = '';
|
||||
$child = $this->attributes['child_id'];
|
||||
if ($child) {
|
||||
$childid = $this->attributes['child_id'];
|
||||
}
|
||||
|
||||
return $childid;
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,39 @@ class Fields extends BaseModel
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function valuesAsString()
|
||||
{
|
||||
$string = '';
|
||||
$values = $this->values()->lists('field_value')->toArray();
|
||||
if (count($values) > 0) {
|
||||
$string = implode(',', $values);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function requiredFieldForCheck()
|
||||
{
|
||||
$check = false;
|
||||
$required = $this->attributes['required'];
|
||||
if ($required === '1') {
|
||||
$check = true;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function nonRequiredFieldForCheck()
|
||||
{
|
||||
$check = false;
|
||||
$required = $this->attributes['required'];
|
||||
if ($required !== '1') {
|
||||
$check = true;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function deleteValues()
|
||||
{
|
||||
$values = $this->values()->get();
|
||||
@@ -41,6 +74,7 @@ class Fields extends BaseModel
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->deleteValues();
|
||||
parent::delete();
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user