*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/*!\file
 * \brief show the detail of a document and let you modify it
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
require_once NOALYSS_INCLUDE . '/class_database.php';
require_once NOALYSS_INCLUDE . '/class_dossier.php';
require_once NOALYSS_INCLUDE . '/class_document_modele.php';
/* 1. Check security */
$cn = new Database(dossier::id());
/* 2. find the document */
$doc = new Document_Modele($cn, $id);
/* 3. display it */
$doc->load();
ob_start();
require NOALYSS_INCLUDE . '/template/modele_document.php';
$html = ob_get_contents();
ob_end_clean();
$html = escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>mod_doc</ctl>
<code>{$html}</code>
</data>
EOF;
 /**
  * \brief generate the document and add it to the action
  * \param md_id is the id of the document_modele
  * \param $p_array contains normally the $_POST
  */
 function generate_document($md_id, $p_array)
 {
     $doc = new Document($this->db);
     $mod = new Document_Modele($this->db, $md_id);
     $mod->load();
     $doc->f_id = $this->f_id_dest;
     $doc->md_id = $md_id;
     $doc->ag_id = $this->ag_id;
     $doc->Generate($p_array);
 }