<?php
$grafico01 = 
"
<style type=\"text/css\">
.diagrama {
  transform: scale(0.7 , 0.7);
  transform-origin: left;
}
.signal text {
    fill: #aaaaaa;
}
.signal text:hover {
    fill: #000000;
}
.note rect, .note path  {
    fill: #aaaaaa;
}
.title rect, .title path,
.actor rect, .actor path {
    fill: #aaaaaa
}
</style>
<SCRIPT src=\"js-sequence/js/raphael.js\" type=\"text/javascript\"></SCRIPT>
   
<SCRIPT src=\"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js\"></SCRIPT>
   
<SCRIPT src=\"js-sequence/js/jquery-2.0.3.min.js\" type=\"text/javascript\"></SCRIPT>
   
<SCRIPT src=\"js-sequence/js/copyright.js\" type=\"text/javascript\"></SCRIPT>
   
<SCRIPT src=\"js-sequence/js/diagram-grammar.js\" type=\"text/javascript\"></SCRIPT>
   
<SCRIPT src=\"js-sequence/js/jquery-plugin.js\" type=\"text/javascript\"></SCRIPT>
   
<SCRIPT src=\"js-sequence/js/daniel_700.font.js\" type=\"text/javascript\"></SCRIPT>
   
<SCRIPT src=\"js-sequence/js/sequence-diagram.js\" type=\"text/javascript\"></SCRIPT>
 
<DIV class=\"diagrama\">	";	
 
global $conn; 
$idClaveExpediente = $_SESSION['idClaveExpediente']; 
$grafico02 ="";
$strSQLExists1 = "SELECT e.`idCataEstado`, e.`CodigoEstado` FROM ct_estado e
WHERE e.`ClaveExpediente_idClaveExpediente` = $idClaveExpediente";
$rsExists1 = db_query($strSQLExists1,$conn);

$Estados_cnt = $rsExists1->num_rows;

while ($ESTADOS = db_fetch_array($rsExists1)) {

	$grafico02.= "participant ". wordwrap($ESTADOS["CodigoEstado"], 15, "\\n", true) ."\n";
}

$strSQLExists2 = "SELECT
e1.`CodigoEstado` EstadoOrigen,
t.`TituloMenu`,
e2.`CodigoEstado` EstadoFin
FROM
ct_est_tra et
join ct_tra_est te on (et.`CataTramite_idCataTramite`=te.`CataTramite_idCataTramite`)
join ct_tramite t on (et.`CataTramite_idCataTramite`=t.`idCataTramite`)
join ct_estado e1 on (et.`CataEstado_idCataEstado`=e1.`idCataEstado` and e1.`ClaveExpediente_idClaveExpediente` = $idClaveExpediente )
join ct_estado e2 on (te.`CataEstado_idCataEstado`=e2.`idCataEstado` and e2.`ClaveExpediente_idClaveExpediente` = $idClaveExpediente )";
$rsExists2 = db_query($strSQLExists2,$conn);

$Tramites_cnt = $rsExists2->num_rows;

while ($TRAMITE = db_fetch_array($rsExists2)) {

	$grafico02.= wordwrap($TRAMITE["EstadoOrigen"], 15, "\\n", true)."->".wordwrap($TRAMITE["EstadoFin"], 15, "\\n", true).":".wordwrap($TRAMITE["TituloMenu"], 25, "\\n", true)."\n";
}

$grafico03=
"</DIV> 
<SCRIPT>
        $(\".diagrama\").sequenceDiagram({theme: 'simple'});
 </SCRIPT>";
$value = $grafico01 . $grafico02 . $grafico03;
?>