#!/usr/bin/php -q
<?php
## IrigaNetworks
## ~~~~~~~~~~~~~
##
##

## ----------------------------------------------------------------------------------------------------
## Fonction usage()
## ----------------------------------------------------------------------------------------------------
function	usage()
{
	global $Script;

	echo "$Script
COMMANDES :
	--buildSignataires	: Construction de la structure JSON de description des signataires de documents

PARAMETRES :
	[--debug=<string>]	: 0=pas de debug, 1=niveau1, 2=niveau2

phpVersion : ".phpversion()."\n";
	exit(1);
}

	## ----------------------------------------------------------------------------------------------------
	## Fonction main()
	## ----------------------------------------------------------------------------------------------------

	## ----------------------------------------------------------------------------------------------------
	## Décodage des paramètres d'appel
	## ----------------------------------------------------------------------------------------------------
	$Script		= basename($_SERVER['argv'][0]);

	$params		= array();
	$paramsTxt	= "";
	$mode		= "";
	for ($i=1; $i<$_SERVER['argc']; $i++) {
		$paramsTxt	.= " ".$_SERVER['argv'][$i];

		if (preg_match("@^--(buildSignataires)$@", $_SERVER['argv'][$i], $regs))	{ $mode			= $regs[1]; continue; }

		if (preg_match("@^--debug=(.*)$@", $_SERVER['argv'][$i], $regs))		{ $params['debug']	= rtrim($regs[1]); continue; }

		echo "Paramètre inconnu :".$_SERVER['argv'][$i]."\n";
		usage();
	}

	if (!$mode)			{ $mode			= "buildSignataires"; }
	if (isset($params['debug']) && $params['debug']) {
		echo "## $Script $paramsTxt\n";
	}
		
	if (!in_array($mode, array("buildSignataires"))) {
		echo "## $Script commande $mode inconnu\n";
		usage();
	}

	#------------------------------------------------------------------------------------------------------------
	if ($mode == "buildSignataires") {
	#------------------------------------------------------------------------------------------------------------
		echo "## $Script : mode=$mode debug=$debug\n";

		$seals	= array(
			"recipientId"	=> "1",
			"routingOrder"	=> "1",
			"recipientSignatureProviders" => array(
				(object) array(
					'sealDocumentsWithTabsOnly' => true,
					/* opérationnel: Amar2 :  'sealName'	=> 'd68b3aa9-8c8a-3b65-837d-5e8d50ce503d', */
					/* test: Cachet DEMO : 'sealName'	=> 'a8b64453-1ac6-9964-1f40-4db8f06bab93', */
					'sealName'    => 'a8b64453-1ac6-9964-1f40-4db8f06bab93',
				),
			),
			"tabs"		=> (object) array(
				'signHereTabs'	=> array(
					(object) array(
						'anchorString'		=> 's1_cachet',
						'anchorUnits'		=> 'mms',
						'anchorXOffset'	=> "0",
						'anchorYOffset'	=> "0",
						'anchorHorizontalAlignment'	=> 'left',
					),
				),
			),
		);
		echo "## $Script : api_signature_modeles_docs.seals=".json_encode($seals)." \n";

		$signataires	= array(
			"1"	=> array(
				"fixedSigner"	=> 0,
				"recipientId"	=> "2",
				"routingOrder"	=> "3",
				"first_name"	=> "prenom",
				"last_name"	=> "nom",
				"email"		=> "emailHec",
				"locale"		=> "langue",
				"tabs"		=> (object) array(
					'signHereTabs'	=> array(
						(object) array(
							'anchorString'		=> 's2_signHere',
							'anchorUnits'		=> 'mms',
							'anchorXOffset'	=> "2",
							'anchorYOffset'	=> "2",
							'anchorHorizontalAlignment'	=> 'left',
						),
					),
					'firstNameTabs'	=> array(
						(object) array(
							'anchorString'		=> 's2_firstName',
							'anchorUnits'		=> 'mms',
							'anchorXOffset'	=> "0",
							'anchorYOffset'	=> "0",
							'bold'			=> 'true',
							'font'			=> 'TimesNewRoman',
							'fontSize'		=> 'Size12',
							'anchorHorizontalAlignment'	=> 'left'
						)
					),
					'lastNameTabs'	=> array(
						(object) array(
							'anchorString'		=> 's2_lastName',
							'anchorUnits'		=> 'mms',
							'anchorXOffset'	=> "0",
							'anchorYOffset'	=> "0",
							'bold'			=> 'true',
							'font'			=> 'TimesNewRoman',
							'fontSize'		=> 'Size12',
							'anchorHorizontalAlignment'	=> 'left'
						),
					),
					'fullNameTabs'	=> array(
						(object) array(
							'anchorString'		=> 's2_fullName',
							'anchorUnits'		=> 'mms',
							'anchorXOffset'	=> "0",
							'anchorYOffset'	=> "0",
							'bold'			=> 'true',
							'font'			=> 'TimesNewRoman',
							'fontSize'		=> 'Size12',
							'anchorHorizontalAlignment'	=> 'left'
						),
					),
					'initialHereTabs'	=> array(
						(object) array(
							'anchorString'		=> 's2_initialHere',
							'anchorUnits'		=> 'mms',
							'anchorXOffset'	=> "0",
							'anchorYOffset'	=> "0",
							'anchorHorizontalAlignment'	=> 'left'
						),
					)
				)
			),
		);
		echo "## $Script : api_signature_modeles_docs.signataires=".json_encode($signataires)." \n";

		exit(0);
	}

	exit(0);

# ================================
# Local variables:
# tab-width: 5
# End:
# vim: set ts=5 sw=5:
?>
