<?php
include_once('connect.php');
include_once('functions.php');
include_once('modules/payment/payment.classes.php');
echo date('Y-m-d H:i:s', time()-4*60*60);
// $payment = new Payment("1737");
// $payment->SendPaymentEmail();
// $invoice = new Invoic;e("2556");
// $invoice->sendEmail();

//sendEstimate("10812");
//$customer = new Customer("10012");
//$customer->SendCollectionsEmail();

//$customer->transferARToLoss();


function generateUPC(){
	$item = new Item("%", "BUL", "38888");


	$upc = $item->getUPC("1");
	$originalUPC = $upc;

	$upc = substr($upc,0, strlen($upc)-1);
	if(strlen($upc) == 11){
		$upc = "0" . $upc;
	}
	$upc = "2" . $upc;
	$i = 0;
	$sum = 0;
	for($i = strlen($upc)-1; $i >= 0; $i--){
		//echo $upc[$i];
		if($i % 2 == 0){
			$sum += $upc[$i]*3;
		}else{
			$sum += $upc[$i];
		}

	}
	if(round($sum,-1) > $sum){
		$tenth = round($sum,-1);
	}else{
		$tenth = round($sum,-1)+10;
	}
	$check = $tenth-$sum;

	echo "Item:" . $item->SKU . "<br>";
	echo "Original UPC: " . $originalUPC;
	echo "<br>";
	echo "<br>Master Carton Code (ITF-14): " . $upc . $check;


}


//sendEstimate('10254');
//sendOrder("2191");
?>

<?php
/**
 * Author: Abu Ashraf Masnun
 * URL: http://masnun.me
 */
 /*
class WorkerThreads extends Thread
{
    private $workerId;

    public function __construct($id)
    {
        $this->workerId = $id;
    }

    public function run()
    {
        sleep(rand(0, 3));
        echo "Worker {$this->workerId} ran" . PHP_EOL;
    }
}

// Worker pool
$workers = [];

// Initialize and start the threads
foreach (range(0, 5) as $i) {
    $workers[$i] = new WorkerThreads($i);
    $workers[$i]->start();
}

// Let the threads come back
foreach (range(0, 5) as $i) {
    $workers[$i]->join();
}
*/
 //var_dump(sendEstimate(10028));



?>
