diff --git a/core/trunk/core/class/resources_controler.php b/core/trunk/core/class/resources_controler.php
index e7c64c940b4d46b5d1c9e2338d1c7f878cf2efaa..3a111ee103b62c9719e80747a0b99262c27e8732 100755
--- a/core/trunk/core/class/resources_controler.php
+++ b/core/trunk/core/class/resources_controler.php
@@ -94,6 +94,7 @@ class resources_controler
             $status,
             $fileFormat
         );
+        unlink($Fnm);
         //var_dump($data);exit;
         $resId = $resource->load_into_db(
             $table, 
@@ -112,6 +113,7 @@ class resources_controler
         $statusFound = false;
         $typistFound = false;
         $typeIdFound = false;
+        $toAddressFound = false;
         for ($i=0;$i<count($data);$i++) {
             if (strtoupper($data[$i]['column']) == strtoupper('status')) {
                 $statusFound = true;
@@ -122,6 +124,22 @@ class resources_controler
             if (strtoupper($data[$i]['column']) == strtoupper('type_id')) {
                 $typeIdFound = true;
             }
+            if (strtoupper($data[$i]['column']) == strtoupper('custom_t10')) {
+                require_once 'core/class/class_db.php';
+                $dbQuery = new dbquery();
+                $dbQuery->connect();
+                $mail = array();
+                $theString = str_replace(">", "", $data[$i]['value']);
+                $mail = explode("<", $theString);
+                $queryUser = "select user_id from users where mail = "
+                    . "'" . $dbQuery->protect_string_db($mail[count($mail) -1]) . "'";
+                $dbQuery->query($queryUser);
+                $userIdFound = $dbQuery->fetch_object();
+                if (!empty($userIdFound->user_id)) {
+                    $toAddressFound = true;
+                    $destUser = $userIdFound->user_id;
+                }
+            }
         }
         if (!$typistFound) {
             array_push(
@@ -153,6 +171,16 @@ class resources_controler
                 )
             );
         }
+        if ($toAddressFound) {
+            array_push(
+                $data,
+                array(
+                    'column' => 'dest_user',
+                    'value' => $destUser,
+                    'type' => 'string',
+                )
+            );
+        }
         array_push(
             $data,
             array(
@@ -187,41 +215,248 @@ class resources_controler
         );
         return $data;
     }
-	
-	function Demo_searchResources($searchParams)
-	{
-		$whereClause = '';
-		if ($searchParams->countryForm <> '') {
-			$whereClause .= " custom_t3 = '" . $searchParams->countryForm . "' and ";
-		}
-		if ($searchParams->docDateForm <> '') {
-			$whereClause .= " doc_date >= '" . $searchParams->docDateForm . "'";
-		}
-		$listResult = array();
-		try {
-			$db = new dbquery();
-			$db->connect();
-			$cpt = 0;
-			$db->query("select * from res_x where " . $whereClause . " ORDER BY res_id ASC");
-			if ($db->nb_result() > 0) {
-				while ($line = $db->fetch_object()) {
-					$listResult[$cpt]['resid'] = $line->res_id;
-					$listResult[$cpt]['subject'] = $line->subject;
-					$listResult[$cpt]['docdate'] = $line->doc_date;
-					$cpt++;
-				}
-			} else {
-				$error = _NO_DOC_OR_NO_RIGHTS;
-			}
-		} catch (Exception $e) {
-			$fault = new SOAP_Fault($e->getMessage(), '1');
-			return $fault->message();
-		}
-		$return = array(
-			'status' => 'ok',
-			'value' => $listResult,
-			'error' => $error,
-		);
-		return $return;
-	}
+    
+    #####################################
+    ## Web Service de versement de données issue du gros scanner
+    #####################################
+    public function storeAttachmentResource($resId, $collId, $encodedContent, $fileFormat, $fileName)
+    {
+        require_once 'core/class/class_request.php';
+        require_once 'core/class/class_resource.php';
+        require_once 'core/class/docservers_controler.php';
+        require_once 'core/class/class_security.php';
+        $sec = new security();
+        $table = $sec->retrieve_table_from_coll($collId);
+        $db = new request();
+        $db->connect();
+        $query = 'select res_id from ' . $table . ' where res_id = '
+               . $resId;
+        $db->query($query);
+        if ($db->nb_result() == 0) {
+            $status = 'ko';
+            $error .= 'res_id inexistant';
+        } else {
+            $fileContent = base64_decode($encodedContent);
+            $tmpFileName = 'tmp_file_ws_'
+                 . rand() . "_" . md5($fileContent) 
+                 . "." . strtolower($fileFormat);
+            $Fnm = $_SESSION['config']['tmppath'] . $tmpFileName; 
+            $inF = fopen($Fnm, "w");
+            fwrite($inF, $fileContent);
+            fclose($inF);
+            $docserverControler = new docservers_controler();
+            $docserver = $docserverControler->getDocserverToInsert(
+               $collId
+            );
+            if (empty($docserver)) {
+                $status = 'ko';
+                $error = _DOCSERVER_ERROR . ' : '
+                    . _NO_AVAILABLE_DOCSERVER . ". " . _MORE_INFOS . ".";
+            } else {
+                $newSize = $docserverControler->checkSize(
+                    $docserver, $_SESSION['upfile']['size']
+                );
+                if ($newSize == 0) {
+                    $status = 'ko';
+                    $error = _DOCSERVER_ERROR . ' : '
+                        . _NOT_ENOUGH_DISK_SPACE . ". " . _MORE_INFOS . ".";
+                } else {
+                    $fileInfos = array(
+                        "tmpDir"      => $_SESSION['config']['tmppath'],
+                        "size"        => filesize($Fnm),
+                        "format"      => strtolower($fileFormat),
+                        "tmpFileName" => $tmpFileName,
+                    );
+                    $storeResult = array();
+                    $storeResult = $docserverControler->storeResourceOnDocserver(
+                        $collId, $fileInfos
+                    );
+                    if (isset($storeResult['error']) && $storeResult['error'] <> '') {
+                        $status = 'ko';
+                        $error = $storeResult['error'];
+                    } else {
+                        unlink($Fnm);
+                        $resAttach = new resource();
+                        $_SESSION['data'] = array();
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "typist",
+                                'value' => $_SESSION['user']['UserId'],
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "format",
+                                'value' => strtolower($fileFormat),
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "docserver_id",
+                                'value' => $storeResult['docserver_id'],
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "status",
+                                'value' => 'NEW',
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "offset_doc",
+                                'value' => ' ',
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "logical_adr",
+                                'value' => ' ',
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "title",
+                                'value' => strtolower($fileName),
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "coll_id",
+                                'value' => $collId,
+                                'type' => "string",
+                            )
+                        );
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "res_id_master",
+                                'value' => $resId,
+                                'type' => "integer",
+                            )
+                        );
+                        if ($_SESSION['origin'] == "scan") {
+                            array_push(
+                                $_SESSION['data'],
+                                array(
+                                    'column' => "scan_user",
+                                    'value' => $_SESSION['user']['UserId'],
+                                    'type' => "string",
+                                )
+                            );
+                            array_push(
+                                $_SESSION['data'],
+                                array(
+                                    'column' => "scan_date",
+                                    'value' => $req->current_datetime(),
+                                    'type' => "function",
+                                )
+                            );
+                        }
+                        array_push(
+                            $_SESSION['data'],
+                            array(
+                                'column' => "type_id",
+                                'value' => 0,
+                                'type' => "int",
+                            )
+                        );
+                        $id = $resAttach->load_into_db(
+                            'res_attachments',
+                            $storeResult['destination_dir'],
+                            $storeResult['file_destination_name'] ,
+                            $storeResult['path_template'],
+                            $storeResult['docserver_id'], $_SESSION['data'],
+                            $_SESSION['config']['databasetype']
+                        );
+                        if ($id == false) {
+                            $status = 'ko';
+                            $error = $resAttach->get_error();
+                        } else {
+                            $status = 'ok';
+                            if ($_SESSION['history']['attachadd'] == "true") {
+                                $users = new history();
+                                $view = $sec->retrieve_view_from_coll_id(
+                                    $collId
+                                );
+                                $users->add(
+                                    $view, $resId, "ADD", 'attachadd',
+                                    ucfirst(_DOC_NUM) . $id . ' '
+                                    . _NEW_ATTACH_ADDED . ' ' . _TO_MASTER_DOCUMENT
+                                    . $resId,
+                                    $_SESSION['config']['databasetype'],
+                                    'apps'
+                                );
+                                $users->add(
+                                    RES_ATTACHMENTS_TABLE, $id, "ADD",'attachadd',
+                                    _NEW_ATTACH_ADDED . " (" . $fileName
+                                    . ") ",
+                                    $_SESSION['config']['databasetype'],
+                                    'attachments'
+                                );
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        $returnArray = array(
+            'status' => $status,
+            'value' => $id,
+            'error' => $error,
+        );
+        return $returnArray;
+    }
+    
+    function Demo_searchResources($searchParams)
+    {
+        $whereClause = '';
+        if ($searchParams->countryForm <> '') {
+            $whereClause .= " custom_t3 = '" . $searchParams->countryForm . "' and ";
+        }
+        if ($searchParams->docDateForm <> '') {
+            $whereClause .= " doc_date >= '" . $searchParams->docDateForm . "'";
+        }
+        $listResult = array();
+        try {
+            $db = new dbquery();
+            $db->connect();
+            $cpt = 0;
+            $db->query("select * from res_x where " . $whereClause . " ORDER BY res_id ASC");
+            if ($db->nb_result() > 0) {
+                while ($line = $db->fetch_object()) {
+                    $listResult[$cpt]['resid'] = $line->res_id;
+                    $listResult[$cpt]['subject'] = $line->subject;
+                    $listResult[$cpt]['docdate'] = $line->doc_date;
+                    $cpt++;
+                }
+            } else {
+                $error = _NO_DOC_OR_NO_RIGHTS;
+            }
+        } catch (Exception $e) {
+            $fault = new SOAP_Fault($e->getMessage(), '1');
+            return $fault->message();
+        }
+        $return = array(
+            'status' => 'ok',
+            'value' => $listResult,
+            'error' => $error,
+        );
+        return $return;
+    }
 }
diff --git a/core/trunk/core/class/ws.php b/core/trunk/core/class/ws.php
index 7244f997c5307abc0e61f347989bdc57a5444fdd..bde47e3e42a9baa74f59fc51ff3c21d702be943f 100755
--- a/core/trunk/core/class/ws.php
+++ b/core/trunk/core/class/ws.php
@@ -203,33 +203,45 @@ $SOAP_dispatch_map['storeResource'] = array(
     'method' => "core#resources::storeResource",
 );
 
+$SOAP_dispatch_map['storeAttachmentResource'] = array(
+    'in'  => array(
+        'resId' => 'integer',
+        'collId' => 'string',
+        'encodedContent' => 'string',
+        'fileFormat' => 'string',
+        'fileName' => 'string',
+),
+    'out' => array('out' => '{urn:MySoapServer}returnArray'),
+    'method' => "core#resources::storeAttachmentResource",
+);
+
 $SOAP_typedef['searchParams'] = array(
-	'country' => 'string',
-	'docDate' => 'date',
+    'country' => 'string',
+    'docDate' => 'date',
 );
 
 $SOAP_typedef['listOfResources'] = array(
-	'resid' => 'long',
-	'identifier' => 'string',
-	'contactName' => 'string',
-	'country' => 'integer',
-	'amount' => 'string',
-	'customer' => 'string',
-	'docDate' => 'string',
+    'resid' => 'long',
+    'identifier' => 'string',
+    'contactName' => 'string',
+    'country' => 'integer',
+    'amount' => 'string',
+    'customer' => 'string',
+    'docDate' => 'string',
 );
 
 $SOAP_typedef['docListReturnArray'] = array(
-	'status'=>'string',
-	'value'=>'{urn:MySoapServer}listOfResources',
-	'error'=>'string',
+    'status'=>'string',
+    'value'=>'{urn:MySoapServer}listOfResources',
+    'error'=>'string',
 );
 
 $SOAP_dispatch_map['Demo_searchResources'] = array(
-	'in' => array(
-		'searchParams' => '{urn:MySoapServer}searchParams',
-	),
-	'out' => array(
-		'out' => '{urn:MySoapServer}docListReturnArray',
-	),
-	'method' => "core#resources::Demo_searchResources",
-);
\ No newline at end of file
+    'in' => array(
+        'searchParams' => '{urn:MySoapServer}searchParams',
+    ),
+    'out' => array(
+        'out' => '{urn:MySoapServer}docListReturnArray',
+    ),
+    'method' => "core#resources::Demo_searchResources",
+);
diff --git a/core/trunk/core/docservers_tools.php b/core/trunk/core/docservers_tools.php
index 64ef03b8fe3b5afdf99b8596e151e651645d106c..19e75cf247b4cbcd448143d020b00f06846bd81b 100644
--- a/core/trunk/core/docservers_tools.php
+++ b/core/trunk/core/docservers_tools.php
@@ -72,9 +72,10 @@ function Ds_copyOnDocserver(
         $docserverSourceFingerprint
     );
     if ($fingerprintControl['status'] == 'ko') {
-		$storeInfos = array('error' => $fingerprintControl['error']);
-		return $storeInfos;
-	}
+        $storeInfos = array('error' => $fingerprintControl['error']);
+        return $storeInfos;
+    }
+
     /*$ofile = fopen($destinationDir.$fileDestinationName, 'r');
     if (Ds_isCompleteFile($ofile)) {
         fclose($ofile);
@@ -549,6 +550,13 @@ function Ds_isFileTypeAllowed($filePath)
         $filePath
     );
     $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
+    if ($ext == 'html' && $mimeType == "text/plain") {
+        $arrayReturn = array(
+            'status' => true,
+            'mime_type' => "text/html",
+        );
+        return $arrayReturn;
+    }
     if (file_exists($_SESSION['config']['corepath'] . 'custom'
         . DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']
         . DIRECTORY_SEPARATOR
@@ -578,9 +586,10 @@ function Ds_isFileTypeAllowed($filePath)
     $type_state = false;
     for ($i=0;$i<count($ext_list);$i++) {
         if (
-			$ext_list[$i]['mime'] == $mimeType 
-			&& strtolower($ext_list[$i]['name']) == $ext
-		) {
+            $ext_list[$i]['mime'] == $mimeType 
+            && strtolower($ext_list[$i]['name']) == $ext
+        ) {
+
             $type_state = true;
             break;
         }