<?php
//  V4.10  RFR  20230714    command line befehl zum starten von syncs
require_once("sITpos_filialsystem.php");
//  V4.11  ALA  20230804    command line befehl zum starten der fehlenden Bons nach Shopify
require_once("shopify.php");

function usage()
{
    echo "falsches oder kein Kommando angegeben\n";
    echo "usage : run_sync_command.php <kommando>\n";
    echo "        <kommando> ....   downsync_produkte\n";
    echo "                          downsync_kunden\n";
    echo "                          upload_alle_tabellen\n";
	echo "                          send_not_sync_order_to_shopify\n";
	echo "                          send_not_sync_storno_order_to_shopiify\n";
    echo "         type=<full>|<incr>\n";
}

$full=false;
if ($argc > 2)
{
    for($i = 2; $i < $argc; $i++) {
        $parameter = $argv[$i];
        list($parameter, $value)=explode("=", $parameter, 2);
        echo "Parameter $i: $parameter  $value \n";
        switch ($parameter)
        {
            case "--type":
                switch ($value)
                {
                    case "full":
                        $full=true;
                        break;
                    case "incr":
                        $full=false;
                        echo "Full:".var_dump($full);
                    break;
                    default:
                        echo "Type muss full oder incr sein\n";
                        exit;
                    break;
                }    
            break;
            default:
                echo "Falscher Parameter $paramtet";
                usage();
                exit;
        }
    
    }
    
}
// ************ Abfrage wenn es command line ist

if (isset($argv[1])) 
{
    $kommando =$argv[1];
    switch ($kommando) 
    {
        case "downsync_produkte":
            syncProducts($full);
            break;
        case "downsync_kunden":
            sync_von_Zentralsystem($full);
            break;
        case "downsync_kunden_limits":
            syncKundenLimits($full);
            break;
        case "upload_alle_tabellen":
            upsync($full);
            break;
		case "send_not_sync_order_to_shopify":
            send_order_to_shopify();
            break;		
		case "send_not_sync_storno_order_to_shopiify":
            send_not_sync_storno_order_to_shopiify();
            break;	
        default: 
            usage();
    }
}
else 
{
    usage();
}
	// ************* Ende command line parameter

?>