'bblier', 'pass' => 'maarch', 'timeout' => '600');
$wsdl = new SOAP_WSDL('http://127.0.0.1/maarch/ws_server.php?WSDL', $proxy, false);
$client = $wsdl->getProxy();
session_start();
if (isset($_REQUEST['view']) || !empty($_REQUEST['viewID'])) {
/*********************** view Maarch document ***********************/
if (!empty($_REQUEST['viewID'])) {
$viewID = $_REQUEST['viewID'];
$viewID = ((int)$viewID);
//echo 'La facture d\'ID '.$viewID.' n\'existe pas !Retour ';
$fileContentArray = array();
$fileContentArray = $client->viewResource( $viewID, 'res_x', 'adr_x', true);
if($fileContentArray->status == "ok") {
$fileContent = base64_decode($fileContentArray->file_content);
$Fnm = $fileContentArray->tmp_path.DIRECTORY_SEPARATOR.rand()."_".md5($fileContent).".".strtolower($fileContentArray->ext);
$inF = fopen($Fnm, "w");
fwrite($inF, $fileContent);
fclose($inF);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: ".strtolower($fileContentArray->mime_type));
header("Content-Disposition: inline; filename=".basename('maarch.'.strtolower($fileContentArray->ext)).";");
header("Content-Transfer-Encoding: binary");
readfile($Fnm);
exit();
/*
var_dump($fileContentArray);
exit;
*/
}
else {
echo $fileContentArray->error;
}
}
else {
if (isset($_SESSION['lang'])) {
if ($_SESSION['lang'] == 'fr') {
$idLang = 'ID de la facture';
$consulterLang = 'Consulter';
}
elseif ($_SESSION['lang'] == 'en') {
$idLang = 'Invoice ID';
$consulterLang = 'Consult';
}
}
else {
$idLang='Invoice ID';
$consulterLang= 'Consult';
}
echo '
';
}
}
elseif (isset($_REQUEST['store']) || (!empty($_REQUEST['custom_t3Form']) && !empty($FILES['fileForm']) && !empty($_REQUEST['subjectForm']))) {
if (!empty($_REQUEST['custom_t3Form']) && !empty($_FILES['fileForm']) && !empty($_REQUEST['subjectForm'])) {
$file = $_FILES['fileForm']['tmp_name'];
$fileContent = file_get_contents($file, FILE_BINARY);
$encodedContent = base64_encode($fileContent);
$aujourdhui = date('Y-m-d H:i:s');
$custom_t3Form = $_REQUEST['custom_t3Form'];
$data = array();
array_push($data, array('column' => 'destination', 'value' => 'DRH', 'type' => 'string'));
array_push($data, array('column' => 'custom_t3', 'value' => $custom_t3Form, 'type' => 'string'));
array_push($data, array('column' => 'doc_date', 'value' => $aujourdhui, 'type' => 'string'));
array_push($data, array('column' => 'type_id', 'value' => '70', 'type' => 'string'));
array_push($data, array('column' => 'subject', 'value' => $_REQUEST['subjectForm'], 'type' => 'string'));
$collID = 'res_coll';
$table = 'res_x';
$fileFormat = 'pdf';
$status = 'NEW';
$fileStoreResource = array();
$fileStoreResource = $client->storeResource ( $encodedContent, $data, $collID, $table, $fileFormat, $status);
echo $fileStoreResource;
exit;
}
else {
if (isset($_SESSION['lang'])) {
if ($_SESSION['lang'] == 'fr') {
$objetLang = 'Objet';
$paysLang = 'Pays';
$ajouterLang = 'Ajouter';
}
elseif ($_SESSION['lang'] == 'en') {
$objetLang = 'Subject';
$paysLang = 'Country';
$ajouterLang = 'Add';
}
}
else {
$objetLang='Subject';
$paysLang = 'Country';
$ajouterLang = 'Add';
}
echo '';
}
}
elseif (isset($_REQUEST['search']) || (!empty($_REQUEST['country']) && !empty($_REQUEST['docDate_jour']) && !empty($_REQUEST['docDate_mois']) && !empty($_REQUEST['docDate_annee']))) {
if (!empty($_REQUEST['country']) && !empty($_REQUEST['docDate_jour']) && !empty($_REQUEST['docDate_mois']) && !empty($_REQUEST['docDate_annee'])) {
$docDateForm = $_REQUEST['docDate_annee'].'-'.$_REQUEST['docDate_mois'].'-'.$_REQUEST['docDate_jour'];
$countryForm = $_REQUEST['country'];
$searchParamsForm = array("countryForm" => $countryForm, "docDateForm" => $docDateForm);
//$searchResource = array();
$searchResource = $client->Demo_searchResources( $searchParamsForm );
$searchResult = '';
$searchResult .= '';
if (isset($_SESSION['lang'])) {
if ($_SESSION['lang'] == 'fr') {
$searchResult .= 'Liste des factures dont le pays est "'.$_REQUEST['country'].'" et la date de versement est plus récente que "'.$docDateForm.'"
';
}
elseif ($_SESSION['lang'] == 'en') {
$searchResult .= 'Invoices list where country is "'.$_REQUEST['country'].'" and adding date is newer than "'.$docDateForm.'"
';
}
}
else {
$searchResult .= 'Invoices list where country is "'.$_REQUEST['country'].'" and adding date is newer than "'.$docDateForm.'"
';
}
$searchResult .= '
ID Objet Date ';
$cpt1=0;
$arrayResource1 = ((array)$searchResource);
$cptMax1 = (count($arrayResource1[value]) - 1);
while ($cpt1 <= $cptMax1) {
$modulo = $cpt1%2;
if ($modulo == 0) {
$bgcolor = '#A1B6FF';
}
else {
$bgcolor = '#5665A7';
}
$result[$cpt1] = ((array)$arrayResource1[value][$cpt1]);
$searchResult .= '';
$searchResult .= ''.$result[$cpt1][resid].' ';
$searchResult .= ''.$result[$cpt1][subject].' ';
$searchResult .= ''.$result[$cpt1][docdate].' ';
$searchResult .= ' ';
$cpt1++;
}
$searchResult .= '
';
$searchResult .= '
';
}
else {
$cptjour = 1;
$jour = '';
while ($cptjour <= 31) {
$cptjourFormat = $cptjour;
if ($cptjour == date('d')) {
$selectedjour = ' selected';
}
else {
$selectedjour = '';
}
if ($cptjour < 10) {
$cptjourFormat = '0'.$cptjour;
}
else {
$cptjourFormat = $cptjour;
}
$jour .= ''.$cptjourFormat;
$cptjour++;
}
$cptmois = 1;
$mois = '';
while ($cptmois <= 12) {
$cptmoisFormat = $cptmois;
if ($cptmois == date('m')) {
$selectedmois = ' selected';
}
else {
$selectedmois = '';
}
if ($cptmoisFormat < 10) {
$cptmoisFormat = '0'.$cptmois;
}
else {
$cptmoisFormat = $cptmois;
}
$mois .= ' '.$cptmoisFormat;
$cptmois++;
}
if (isset($_SESSION['lang'])) {
if ($_SESSION['lang']=='fr') {
$paysLang = 'Pays';
$depuisLang = 'Depuis le';
}
elseif ($_SESSION['lang']=='en') {
$paysLang= 'Country';
$depuisLang = 'Since';
}
}
else {
$paysLang = 'Country';
$depuisLang = 'Since';
}
echo '';
}
}
else {
if (isset($_SESSION['lang'])) {
if ($_SESSION['lang'] == 'fr') {
echo 'Bienvenue sur le tutoriel de démonstration de web services Maarch.'
. ' Pour commencer, verser une facture depuis le menu à droite';
}
elseif ($_SESSION['lang'] == 'en') {
echo 'Welcome on the web services demonstration tutorial of Maarch.'
. ' Start by adding an invoice from the menu on the right';
}
}
else {
echo 'Welcome on the web services demonstration tutorial of Maarch.'
. ' Start by adding an invoice from the menu on the right';
}
}
?>