diff --git a/application/config/development/routes.php b/application/config/development/routes.php index 1b45740..af85792 100644 --- a/application/config/development/routes.php +++ b/application/config/development/routes.php @@ -49,6 +49,7 @@ | Examples: my-controller/index -> my_controller/index | my-controller/my-method -> my_controller/my_method */ -$route['default_controller'] = 'welcome'; +// $route['default_controller'] = 'welcome'; +$route['default_controller'] = 'Auth'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; diff --git a/application/config/production/autoload.php b/application/config/production/autoload.php index 367fa04..79ae9a6 100644 --- a/application/config/production/autoload.php +++ b/application/config/production/autoload.php @@ -58,7 +58,7 @@ | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array('email'); +$autoload['libraries'] = array('session','database','email'); /* | ------------------------------------------------------------------- @@ -89,8 +89,7 @@ | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array('url', 'mail'); - +$autoload['helper'] = array('url','custom','mail', 'data'); /* | ------------------------------------------------------------------- | Auto-load Config files @@ -132,4 +131,4 @@ | | $autoload['model'] = array('first_model' => 'first'); */ -$autoload['model'] = array(); +$autoload['model'] = array('auth/auth_model'); diff --git a/application/config/production/config.php b/application/config/production/config.php index 7966477..cd332be 100644 --- a/application/config/production/config.php +++ b/application/config/production/config.php @@ -23,7 +23,9 @@ | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = 'https://localhost/CodeIgniter-HMVC'; +$base = "http://".$_SERVER['HTTP_HOST']; +$base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); +$config['base_url'] = $base; /* |-------------------------------------------------------------------------- @@ -223,7 +225,7 @@ | your log files will fill up very fast. | */ -$config['log_threshold'] = 0; +$config['log_threshold'] = 4; // Logs all possible error levels /* |-------------------------------------------------------------------------- diff --git a/application/config/production/database.php b/application/config/production/database.php index 0088ef1..68a7062 100644 --- a/application/config/production/database.php +++ b/application/config/production/database.php @@ -71,6 +71,7 @@ | the query builder class. */ $active_group = 'default'; +$active_group = 'testingDB'; $query_builder = TRUE; $db['default'] = array( @@ -94,3 +95,25 @@ 'failover' => array(), 'save_queries' => TRUE ); + +$db['testingDB'] = array( + 'dsn' => '', + 'hostname' => '119.18.54.85', + 'username' => 'venbaehn_ams', + 'password' => 'L;nD7Z@f)1ZT', + 'database' => 'venbaehn_ams', + 'dbdriver' => 'mysqli', + 'dbprefix' => '', + 'pconnect' => FALSE, + 'db_debug' => (ENVIRONMENT !== 'production'), + 'cache_on' => FALSE, + 'cachedir' => '', + 'char_set' => 'utf8', + 'dbcollat' => 'utf8_general_ci', + 'swap_pre' => '', + 'encrypt' => FALSE, + 'compress' => FALSE, + 'stricton' => FALSE, + 'failover' => array(), + 'save_queries' => TRUE +); \ No newline at end of file diff --git a/application/config/production/routes.php b/application/config/production/routes.php index 1b45740..de53028 100644 --- a/application/config/production/routes.php +++ b/application/config/production/routes.php @@ -49,6 +49,10 @@ | Examples: my-controller/index -> my_controller/index | my-controller/my-method -> my_controller/my_method */ -$route['default_controller'] = 'welcome'; +// $route['default_controller'] = 'welcome'; +// $route['default_controller'] = 'Auth'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; +$route['default_controller'] = 'Auth'; +$route['logout'] = 'Auth/logout'; +$route['login'] = 'Auth'; diff --git a/application/config/testing/config.php b/application/config/testing/config.php index ce5cb39..0fec71e 100644 --- a/application/config/testing/config.php +++ b/application/config/testing/config.php @@ -102,8 +102,7 @@ | setting this variable to TRUE (boolean). See the user guide for details. | */ -$config['enable_hooks'] = TRUE; - +$config['enable_hooks'] = FALSE; /* |-------------------------------------------------------------------------- | Class Extension Prefix @@ -225,7 +224,7 @@ | your log files will fill up very fast. | */ -$config['log_threshold'] = 4; +$config['log_threshold'] = 0; /* |-------------------------------------------------------------------------- @@ -273,7 +272,7 @@ | codes to set your own date formatting | */ -$config['log_date_format'] = 'd-m-m H:i:s'; +$config['log_date_format'] = 'Y-m-d H:i:s'; /* |-------------------------------------------------------------------------- @@ -450,7 +449,7 @@ | 'csrf_regenerate' = Regenerate token on every submission | 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks */ -$config['csrf_protection'] = TRUE; +$config['csrf_protection'] = FALSE; $config['csrf_token_name'] = 'csrf_test_name'; $config['csrf_cookie_name'] = 'csrf_cookie_name'; $config['csrf_expire'] = 7200; diff --git a/application/config/testing/routes.php b/application/config/testing/routes.php index f00df48..107640e 100644 --- a/application/config/testing/routes.php +++ b/application/config/testing/routes.php @@ -49,7 +49,8 @@ | Examples: my-controller/index -> my_controller/index | my-controller/my-method -> my_controller/my_method */ -$route['default_controller'] = 'Backend'; +// $route['default_controller'] = 'Backend'; +$route['default_controller'] = 'Auth'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; diff --git a/application/helpers/mail_helper.php b/application/helpers/mail_helper.php index 158ab07..65fb189 100644 --- a/application/helpers/mail_helper.php +++ b/application/helpers/mail_helper.php @@ -5,104 +5,100 @@ if (!function_exists('send_emails')) { -function send_emails($to, $subject, $body, $aliasName = '', $cc = null, $bcc = null, $receipt = null) -{ + function send_emails($to, $subject, $body, $aliasName = '', $cc = null, $bcc = null, $receipt = null) + { - log_message('info', 'send_mail_helper_loadded'); - log_message('info', 'Receiptent mail - '.$to.' - subject - '.$subject.' - body - '.$body); - log_message('info', 'Sender mail '.business()->sender_mail); + log_message('error', 'Fns send_emails - helper_loaded'); + log_message('error', 'Receiptent mail - ' . $to . ' - subject - ' . $subject . ' - body - ' . $body); + log_message('error', 'Sender mail ' . business()->sender_mail); - try { - $mailer = new PHPMailer(true); - log_message('info', 'phpmailer loaded'); + try { + $mailer = new PHPMailer(true); + log_message('error', 'phpmailer loaded'); - $mailer->isSMTP(); - $mailer->CharSet = 'utf-8'; - $mailer->Host= 'mail.venbait.in'; - $mailer->SMTPSecure = 'ssl'; - $mailer->SMTPAuth =true; - $mailer->SMTPDebug =false; - $mailer->Username='bbone@venbait.in'; - $mailer->Password='xk!L(N_-R#};'; - $mailer->Port=465; - $mailer->setFrom(business()->sender_mail, $aliasName); - $mailer->addAddress($to); + $mailer->isSMTP(); + $mailer->CharSet = 'utf-8'; + $mailer->Host = business()->mail_hostname; + $mailer->SMTPSecure = business()->mail_security; + $mailer->SMTPAuth = true; + $mailer->SMTPDebug = false; + $mailer->Username = business()->mail_username; + $mailer->Password = business()->mail_password; + $mailer->Port = business()->mail_port_no; + $mailer->setFrom(business()->sender_mail, $aliasName); + $mailer->addAddress($to); - // Add CC recipients - // if ($cc !== null) { - // if (is_array($cc)) { - // foreach ($cc as $ccRecipient) { - // $mailer->addCC($ccRecipient); - // } - // } else { - // $mailer->addCC($cc); - // } - // } + // Add CC recipients + // if ($cc !== null) { + // if (is_array($cc)) { + // foreach ($cc as $ccRecipient) { + // $mailer->addCC($ccRecipient); + // } + // } else { + // $mailer->addCC($cc); + // } + // } - // Add BCC recipients - // if ($bcc !== null) { - // if (is_array($bcc)) { - // foreach ($bcc as $bccRecipient) { - // $mailer->addBCC($bccRecipient); - // } - // } else { - // $mailer->addBCC($bcc); - // } - // } + // Add BCC recipients + // if ($bcc !== null) { + // if (is_array($bcc)) { + // foreach ($bcc as $bccRecipient) { + // $mailer->addBCC($bccRecipient); + // } + // } else { + // $mailer->addBCC($bcc); + // } + // } - $mailer->Subject=$subject; + $mailer->Subject = $subject; - $mailer->isHTML(true); - $mailer->Body=$body; + $mailer->isHTML(true); + $mailer->Body = $body; - $attachmentPath = '/path/to/your/attachment/' . $receipt; + $attachmentPath = '/path/to/your/attachment/' . $receipt; - if (file_exists($attachmentPath)) { - $mailer->addAttachment($attachmentPath); + if (file_exists($attachmentPath)) { + $mailer->addAttachment($attachmentPath); + } + + if ($mailer->send()) { + log_message('error', 'Email sent successfully'); + } else { + throw new \Exception('Email sending failed.'); + } + } catch (\Exception $e) { + log_message('error', 'Error mail noy send: ' . $mailer->ErrorInfo); + log_message('error', 'Email Error = ' . $e->getMessage()); } - - $mailer->send(); - log_message('info', 'success : mail sendsuccessfully'); return true; - - - } catch (Exception $e) { - log_message('info', 'Error mail noy send: '.$mailer->ErrorInfo); - return 'Error: ' . $mailer->ErrorInfo; - - } } - - -} - if (!function_exists('send_emails_forgot_password')) { function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc = null, $bcc = null, $receipt = null) { - log_message('info', 'send_mail_helper_loadded'); - log_message('info', 'Receiptent mail - '.$to.' - subject - '.$subject.' - body - '.$body); - log_message('info', 'Sender mail '.business()->sender_mail); + log_message('error', 'send_mail_helper_loadded'); + log_message('error', 'Receiptent mail - ' . $to . ' - subject - ' . $subject . ' - body - ' . $body); + log_message('error', 'Sender mail ' . business()->sender_mail); try { $mailer = new PHPMailer(true); - log_message('info', 'phpmailer loaded'); + log_message('error', 'phpmailer loaded'); $mailer->isSMTP(); $mailer->CharSet = 'utf-8'; - $mailer->Host='smtp.sendgrid.net'; - $mailer->SMTPSecure = 'tls'; - $mailer->SMTPAuth =true; - $mailer->SMTPDebug = 2; - $mailer->Username='apikey'; - $mailer->Password='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'; - $mailer->Port='587'; - $mailer->setFrom('no-reply@tripapprovaltool.com'); + $mailer->Host = business()->mail_hostname; + $mailer->SMTPSecure = business()->mail_security; + $mailer->SMTPAuth = true; + $mailer->SMTPDebug = false; + $mailer->Username = business()->mail_username; + $mailer->Password = business()->mail_password; + $mailer->Port = business()->mail_port_no; + $mailer->setFrom(business()->sender_mail, $aliasName); $mailer->addAddress($to); // Add CC recipients @@ -127,9 +123,9 @@ function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc } } - $mailer->Subject=$subject; + $mailer->Subject = $subject; $mailer->isHTML(true); - $mailer->Body=$body; + $mailer->Body = $body; $attachmentPath = '/path/to/your/attachment/' . $receipt; @@ -137,21 +133,20 @@ function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc $mailer->addAttachment($attachmentPath); } - $mailer->send(); + if ($mailer->send()) { + log_message('error', 'Email sent successfully'); + } else { + throw new \Exception('Email sending failed.'); + } - return true; - log_message('info', 'success : mail sendsuccessfully'); - - } catch (Exception $e) { - - return 'Error: ' . $mailer->ErrorInfo; - log_message('info', 'Error : '.$mailer->ErrorInfo); + // return true; + // log_message('error', 'success : mail send successfully'); + } catch (\Exception $e) { + // return 'Error: ' . $mailer->Errorerror; + log_message('error', 'Error mail noy send: ' . $mailer->ErrorInfo); + log_message('error', 'Email Error = ' . $e->getMessage()); } + return true; } - - - - } - -?> +} diff --git a/application/modules/Leave/controllers/Leave.php b/application/modules/Leave/controllers/Leave.php index 2d83512..52db4bf 100644 --- a/application/modules/Leave/controllers/Leave.php +++ b/application/modules/Leave/controllers/Leave.php @@ -65,6 +65,15 @@ public function leaveList() } public function leave_list_report() + { + $business_id = user()->business_id; + $leave_list = $this->Leave_model->get_all_leave_data($business_id); + $this->layout->set('leave_list', $leave_list); + $this->layout->buffer('main_content', 'Leave/leave_list_report'); + $this->layout->render('Employee_Layout'); + } + + public function leave_list_report_exist() { $business_id = user()->business_id; $leave_list = $this->Leave_model->get_all_leave(user()->business_id); @@ -87,6 +96,7 @@ public function leave_list_report() } } + $result = array_values($resultArray); // echo json_encode( $result, JSON_PRETTY_PRINT);die; $this->layout->set('leave_list', $result); @@ -187,8 +197,8 @@ public function createLeave() $table="leave_list"; $perm_data['perm_date_new'] = date("Y-m-d", strtotime( $this->input->post('perm_date_new') )); - $create_permission = $this->MY_Model->insert($perm_data,$table); - + $create_permission = $this->MY_Model->insert($perm_data,$table); + // $create_permission = 221; //for notification if($create_permission){ $code = 'LEAVE_PERMISSION'; @@ -197,7 +207,8 @@ public function createLeave() } $this->session->set_flashdata('Success', '1'); - redirect('Leave/LeaveHistory'); + + redirect('Leave/LeaveHistory'); } //end of permission diff --git a/application/modules/Leave/models/Leave_model.php b/application/modules/Leave/models/Leave_model.php index 6760aa9..58b34e6 100644 --- a/application/modules/Leave/models/Leave_model.php +++ b/application/modules/Leave/models/Leave_model.php @@ -19,14 +19,57 @@ public function get_all_leave($business_id) } + + + public function get_all_leave_data($business_id) { + $this->db->select(" + A.id, A.emp_id, A.approved_by, A.business_id, A.is_active, A.from_date_new, A.to_date_new, + A.perm_date_new, A.from_time, A.to_time, U1.name as emp_name, U2.name as approve_by_name, l.type as leave_type, l.code as leave_code, + IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new) AS final_date, + MONTH(IF(A.from_date_new IS NOT NULL, A.from_date_new, A.perm_date_new)) AS final_date_month, + YEAR(IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new)) as final_date_year, + GROUP_CONCAT( + CASE + WHEN A.from_date_new IS NOT NULL THEN CONCAT(' (',A.from_date_new, ' to ', A.to_date_new,') ') + ELSE '' + END + ) AS date_range, + SUM(A.no_of_days) AS total_no_of_days, + GROUP_CONCAT( + CASE + WHEN A.perm_date_new IS NOT NULL AND UPPER(l.code) = 'PERMISSION' THEN CONCAT( + DATE_FORMAT(A.perm_date_new, '%d-%m-%Y'), + ' ', + A.from_time, + ' - ', + A.to_time) + ELSE '' + END + ) AS permission_range + "); + $this->db->from('leave_list A'); + $this->db->join('users U1', 'U1.id = A.emp_id', 'LEFT'); + $this->db->join('users U2', 'U2.id = A.approved_by', 'LEFT'); + $this->db->join('leave_master l', 'l.id = A.type', 'LEFT'); + $this->db->where('A.business_id', $business_id); + $this->db->where('A.is_active', 1); + $this->db->where('A.approved_by !=', ''); + $this->db->group_by('A.emp_id, A.type, MONTH(IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new)), YEAR(IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new))'); + $this->db->order_by('A.id', 'DESC'); + $query = $this->db->get(); + return $query->result(); + // print_r($this->db->last_query());die; + } + public function get_leave_with_emp_name($business_id) { - $this->db->select('A.* ,U1.name as emp_name, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby'); + $this->db->select('A.* ,U1.name as emp_name, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby,l.type as leave_type,l.code as leave_code'); $this->db->from('leave_list A'); $this->db->join('users U1', 'U1.id = A.emp_id', 'left'); $this->db->join('users U2', 'U2.id = A.approved_by', 'left'); $this->db->join('users U3', 'U3.id = A.declined_by', 'left'); $this->db->join('users U4', 'U4.id = A.risedby', 'left'); + $this->db->join('leave_master l', 'l.id = A.type', 'LEFT'); $this->db->where('A.business_id', $business_id); $this->db->order_by('A.id','DESC'); $this->db->where('A.is_active', 1); diff --git a/application/modules/Leave/views/leave_list.php b/application/modules/Leave/views/leave_list.php index 295870d..fa9824d 100644 --- a/application/modules/Leave/views/leave_list.php +++ b/application/modules/Leave/views/leave_list.php @@ -69,27 +69,40 @@
$value) { ?> - $type) { ?> - id === $value->type ) { ?>