semana.php
Go to the documentation of this file.00001 <?php
00002 ini_set( "display_errors", "On" );
00003 error_reporting( E_ALL | E_STRICT );
00004 class DatabaseConnection
00005 {
00010 protected static $objInstance;
00011
00016 protected $objConnection;
00017
00022 public static function getInstance()
00023 {
00024 if( self::$objInstance == null )
00025 {
00026 self::$objInstance = new DatabaseConnection();
00027 }
00028 return self::$objInstance;
00029 }
00030
00031 public function __construct()
00032 {
00033 $this->objConnection = new PDO(
00034 'mysql:host=127.0.0.1;dbname=semana-de-extensao;charset=UTF-8',
00035 'root',
00036 '123456'
00037 );
00038 $this->objConnection->beginTransaction();
00039 }
00040
00041 public function __destruct()
00042 {
00043 $this->objConnection->commit();
00044 }
00045
00051 public function run( $strSql , $arrParams = array() )
00052 {
00053 $objPrepare = $this->objConnection->prepare( $strSql );
00054 $objPrepare->execute( $arrParams );
00055 $arrResult = $objPrepare->fetchAll();
00056 return $arrResult;
00057 }
00058 }
00059
00060 class DrawFlow
00061 {
00062 protected $arrStates;
00063 protected $arrLines;
00064
00065 public function getStates()
00066 {
00067 if( $this->arrStates == null )
00068 {
00069 $strSql = "select * from tb_situacao_atividade order by id_situacao_atividade ";
00070 $this->arrStates = DatabaseConnection::getInstance()->run( $strSql );
00071 }
00072 return $this->arrStates;
00073 }
00074
00075
00076 public function getLines()
00077 {
00078 if( $this->arrLines == null )
00079 {
00080 $strSql = "select * from tb_acao_em_atividade order by id_acao_em_atividade ";
00081 $this->arrLines = DatabaseConnection::getInstance()->run( $strSql );
00082 }
00083 return $this->arrLines;
00084 }
00085
00086 }
00087
00088 $objDrawFlow = new DrawFlow();
00089 ?>
00090 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
00091 <html>
00092 <head>
00093 <title></title>
00094 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
00095 <script type="text/javascript" src="../phpjs/php.js" ></script>
00096 <script type="text/javascript" src="./autoLoad/jsAutoLoad.js.php?deep=0" ></script>
00097 <script type="text/javascript" >
00098 window.autoload.loadPrototype();
00099 </script>
00100 <style>
00101 *
00102 {
00103 padding: 0;
00104 margin: 0;
00105 border: none;
00106 }
00107 canvas
00108 {
00109 border-style: solid;
00110 border-color: black;
00111 border-width: 1px;
00112 }
00113 #abc
00114 {
00115 margin-left:0px;
00116 margin-top:0px;
00117 }
00118 </style>
00119 </head>
00120 <body>
00121 <div>
00122 <canvas id="abc">
00123 </canvas>
00124 </div>
00125 <script type="text/javascript" charset="utf-8">
00126 var objBox = new autoload.newCanvasBoxStateDiagram( "abc" , document.body.clientWidth - 10, document.body.clientHeight - 10 );
00127 window.box = objBox;
00128 window.box.dblZoom = 0.3;
00129 window.box.width = window.box.defaultWidth / window.box.dblZoom;
00130 window.box.height = window.box.defaultHeight / window.box.dblZoom;
00131 function addStateElement( strStateName , color )
00132 {
00133 var objStateElement = new autoload.newCanvasBoxState();
00134 objStateElement.objBehavior = new autoload.newCanvasBoxMagneticBehavior( objStateElement );
00135
00136 objStateElement.x = rand( window.box.width );
00137 objStateElement.y = rand( window.box.height );
00138 objStateElement.strStateName = strStateName;
00139 objStateElement.drawFixed( false );
00140 if( color )
00141 {
00142 objStateElement.fillColor = color;
00143 objStateElement.fixedColor = color;
00144 objStateElement.defaultColor = color;
00145 }
00146 else
00147 {
00148 objStateElement.fillColor = "orange";
00149 objStateElement.fixedColor = "#66AAff";
00150 }
00151 window.box.addElement( objStateElement );
00152 return objStateElement;
00153 }
00154
00155 function addEvent( objFrom , objTo , strName )
00156 {
00157 strName = str_replace( " " , "\n" , strName );
00158 var objEvent = addStateElement( strName , "#DDFFDD" );
00159 addLine( objFrom , objEvent );
00160 addLine( objEvent , objTo );
00161
00162 }
00163
00164 function addLine( objFrom , objTo , strName , color )
00165 {
00166 if( objFrom == undefined || objTo == undefined )
00167 {
00168 return;
00169 }
00170
00171 var objLine = new autoload.newCanvasBoxStateLink( objFrom , objTo );
00172 objLine.strName = strName;
00173
00174 objLine.objBehavior = new autoload.newCanvasBoxElasticConnectorBehavior( objLine );
00175
00176 objLine.x = ( objFrom.x + objTo.x ) / 2;
00177 objLine.y = ( objFrom.y + objTo.y ) / 2;
00178 if( color )
00179 {
00180 objLine.color = color;
00181 }
00182 window.box.addElement( objLine );
00183 return objLine;
00184 }
00185 var arrStates = new Object();
00186 <?php foreach( $objDrawFlow->getStates() as $intPos => $objState ): ?>
00187 var objState = addStateElement("<?php print utf8_encode( $objState['txt_nome_situacao_atividade'] ) ?>");
00188 arrStates[ <?php print $objState[ 'id_situacao_atividade'] ?> ] = objState;
00189 <?php endforeach ?>
00190 <?php foreach( $objDrawFlow->getLines() as $intPos => $objLine): ?>
00191 addEvent(
00192 arrStates[ <?php print (integer)$objLine[ 'id_situacao_atividade_antes' ] ?> ] ,
00193 arrStates[ <?php print (integer)$objLine[ 'id_situacao_atividade_depois' ] ?> ] ,
00194 '<?php print utf8_encode( $objLine[ 'txt_nome_acao_em_atividade' ] ) ?>'
00195 );
00196
00197 <?php endforeach ?>
00198 </script>
00199 </body>
00200 </html>