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/kanvakanva.com/public_html/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Cronjob extends CI_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 24 hours...
			// Getting the value of old date + 24 hours, 86400 seconds == 24 hrs
			$reminder_date = strtotime($order->order_date) + 86400;

			if ($reminder_date < $current_date) {
				//means that order date has exceed 24 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('*')->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 48 hours...
			// Getting the value of old date + 24 hours, 172800 seconds == 48 hrs
			$expired_date = strtotime($order->order_date) + 172800;

			if ($expired_date < $current_date) {

				//means that order date has exceed 48 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 purchased quantity
					$purchased_quantity = $item->quantity;

					//get size id from product size
					$this->db->select('id_product_size')->from('product_size')->where('product_size', $item->size);
					$size_id = (int) $this->db->get()->row()->id_product_size;

					//get current stock
					$this->db->select('stock')->from('stocks')->where('size_id', $size_id)->where('product_id', $item->item_id);
					$current_stock = $this->db->get()->row()->stock;
					
					$data = array(
						'stock' => $current_stock + $purchased_quantity,
					);

					$this->db->where('size_id', $size_id);
					$this->db->where('product_id', $item->item_id);
					$this->db->update('stocks', $data);
				}

				//get website logo 
				$this->db->select('logo')->from('configuration')->where('id_configuration', 1);
				$data['logo'] = $this->db->get()->row()->logo;  
				
				$config['protocol'] = 'smtp';
				$config['smtp_host'] = 'ssl://smtp.gmail.com'; //change this
				$config['smtp_port'] = '465';
				$config['smtp_user'] = 'info@kanvakanva.com'; //change this
				$config['smtp_pass'] = 'Akunk4nva'; //change this
				$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->load->library('email');
				$this->email->initialize($config); 

				$data['customer'] = $this->customer_m->get_customer($order->customer_id);

				$data['order'] = $order;

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

				$this->email->from('info@kanvakanva.com', $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)...
		
	}

	public function send_rating(){
		$today = date('Y-m-d');

		$this->db->select('a.orders_id,a.item_id,a.item_name,c.name,c.email,d.alias,d.image1')->from('orders_detail a')
		->join('orders b','a.orders_id=b.id_orders')
		->join('customers c','b.customer_id=c.id_customers')
		->join('products d','a.item_id=d.id_products')
		
		//->where('b.id_orders in (2517, 2515)')
		//->limit('1');

		->where('b.send_mail_rating', 0)
		->where('b.send_date is not null')
		->where("DATE_ADD(date(b.send_date), INTERVAL 3 DAY) = '$today'");
		
		//->where("date(b.order_date) >= '2022-01-15' and date(b.order_date) < '2022-01-21'")
		//->limit('1');
		//->where('a.orders_id', 2460); 
		$product = $this->db->get()->result();

		foreach($product as $row){
			
			//get website logo 
			$this->db->select('logo')->from('configuration')->where('id_configuration', 1);
			$data['logo'] = $this->db->get()->row()->logo;  
			
			$config['protocol'] = 'smtp';
			$config['smtp_host'] = 'ssl://smtp.gmail.com'; //change this
			$config['smtp_port'] = '465';
			$config['smtp_user'] = 'info@kanvakanva.com'; //change this
			$config['smtp_pass'] = 'Akunk4nva'; //change this
			$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->load->library('email');
			$this->email->initialize($config); 

			$data['customer'] = ucwords(strtolower($row->name));
			$data['orders_id'] = $row->orders_id;
			$data['item_id'] = $row->item_id;
			$data['item_name'] = $row->item_name;
			$data['alias'] = $row->alias;
			$data['image'] = $row->image1;

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

			$this->email->from('info@kanvakanva.com', $data['emails']->website_name);
			$this->email->to($row->email);
			$this->email->subject('Please review your recent purchases at Kanva'); 
			$email = $this->load->view('email/rating', $data, TRUE);
			$this->email->message($email);	 
			$this->email->send();  
			//----end send email

			//$this->load->view('email/rating', $data);

		}

	}

	function send_mail_payment(){
		$order_id = '2584';

		$this->db->select('b.email')->from('orders a')
		->join('customers b','a.customer_id=b.id_customers')
		->where('a.id_orders', $order_id);
		
		$order_data = $this->db->get()->row();
		//$email_customer = $order_data->email;
		$email_customer = 'ahmadmuflih1@gmail.com';
		
		$data['carrier'] = 'jne';
		$data['code_carrier'] = 'jne_reguler';
		$data['carrier_name'] = 'JNE REG';

		$payment_type = 'bank transfer';

		$this->insert_new_order($payment_type);

		//----SEND EMAIL TO CUSTOMER (BANK TRANSFER)
		$data['bank'] = $this->configuration_m->get_bank();
		$data['title'] = 'Bank Transfer';

		//get website logo
		$this->db
			->select('logo')
			->from('configuration')
			->where('id_configuration', 1);
		$data['logo'] = $this->db->get()->row()->logo;

		//get order detail and customer detail
		$data['order'] = $this->order_m->get_order(
			$order_id
		);
		$data['order_details'] = $this->order_detail_m->get_orders_detail(
			$order_id
		);

		//get vouchers detail
		if ($this->session->userdata('chosen_voucher_code')) {
			$data['chosen_voucher_code'] = $this->session->userdata(
			'chosen_voucher_code'
			);
			$data['chosen_voucher_type'] = $this->session->userdata(
			'chosen_voucher_type'
			);
			$data['chosen_voucher_discount'] = $this->session->userdata(
			'chosen_voucher_discount'
			);
		}

		//get shippng fee total
		$data['carrier_name'] = $this->session->userdata('carrier_name');
		$data['total_shipping_fee'] = $this->session->userdata(
			'total_shipping_fee'
		);

		$config['protocol'] = 'smtp';
		$config['smtp_host'] = 'ssl://smtp.gmail.com'; //change this
		$config['smtp_port'] = '465';
		$config['smtp_user'] = 'info@kanvakanva.com'; //change this
		$config['smtp_pass'] = 'Akunk4nva'; //change this
		$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->load->library('email');
		$this->email->initialize($config);

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

		//$this->email->from($data['emails']->from_email, $data['emails']->website_name);
		$this->email->from('info@kanvakanva.com', $data['emails']->website_name);

		$this->email->to($email_customer);
		$this->email->cc($data['emails']->from_email);
		$this->email->subject('Order Notification');

		$email = $this->load->view('email/bank_transfer', $data, true);
		$this->email->message($email);
		$email_sent_status = $this->email->send();

		if(!$email_sent_status) {
			echo $this->email->print_debugger();
	   	}
	}


}

https://t.me/RX1948 - 2025