Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
tool per sceta di alloggi in nuovo fabbricato - alloggi_ancora_open.php

alloggi_ancora_open.php

Caricato da:
Scarica il programma completo

  1. <?php
  2.   /*
  3.     carica il file csv che deriva da excel con i millesimi, le superfici, i costi e le assegnazioni
  4.       esempio:
  5.       n.; piano;descrizione;                      Sup.lorda;Sup.comm;Mm_virtuali;millesimi_10000;Ripart.spesa;8000;  preass;      prenot;   data
  6.       A01;primo;abitazione corpo A int. 1;67,46;     67,46;   176,676;    112,39;         247.258,00; 89912; xxxxxx   ;         ;
  7.       $k[][0];$k[][1];$k[][2]            ;$k[][3]; $k[][4]; $k[][5]  ;   $k[][6];         $k[][7] ;  $k[][8]; $k[][9]  ; $k[][10]; $k[][11]
  8.  
  9.     crea una tabella di 6 colonne dove le colonne 1 - 3 - 5 sono i caseggiato A, B, C (le colonne 2-4-6 sono distanziatori)
  10.     ogni riga è un piano (dal più alto al più basso (da 6 a 1)
  11.     i piani normalmente hanno 4 alloggi - se al piano ci sono due alloggi il riempimento ne tiene conto per l'opportuno riempimento)
  12.     in ogni riga/colonna che corrisponde al piano viene inserito  il numero alloggio e il colore indica se l'alloggio e' gia' assegnato o disponibile
  13.  
  14.     con mouseover sulla riga/colonna nella textarea all'interno della form screen (a destra) vengonoi riportati i dati dell'alloggio
  15.                                      lo schama dell'alloggio e la sua posizione nel piano.
  16.     per fare cio' si utilizzano la  funzione javascript showT() alla quale si passano i dati relativi all'alloggio.
  17.  
  18.  
  19.  
  20.  ** load_tabbed_file ( string filepath )
  21.  ** Loads a file with content separated by ; (-> array)
  22.  */
  23.  
  24.  //echo "inizio \n";
  25.  // load descrizione alloggi
  26.  
  27.  
  28.  $fat_items = load_tabbed_file("../alloggi_dati_mm/ancora_tabelle millesimi_2009_10_01.csv");
  29.  // now $fat_items is ordered
  30.  
  31.  // create keyed array $elenco from monodimensional flat array $fat_items
  32.  $elenco = array();
  33.  foreach($fat_items as $rrr)
  34.  {
  35.  
  36.               $elenco[$rrr[0]] = $rrr;
  37.  }
  38.  
  39.  $debug = 0;
  40.  if ($debug == 1){
  41.    print_r($elenco);
  42.    die("fine per debug");
  43.  }
  44.  /***************************************************
  45.  //  for test we can create result of loaded data
  46.  
  47.  if (file_exists("ancora_tabelle millesimi_2009_10_01.txt")) unlink("ancora_tabelle millesimi_2009_10_01.txt");
  48.  //rename("ancora_tabelle millesimi_2009_10_01.csv", "ancora_tabelle millesimi_2009_10_01.bbb");
  49.  //echo "loaded \n";
  50.  
  51.  save_elenco_fatture("ancora_tabelle millesimi_2009_10_01.txt");
  52. ****************************************************/
  53.  
  54.  // create html   alloggi.html ... ( if we don't use php - we can use this html created page)
  55.  // crea header
  56.  $fo = fopen("alloggi.html", "w+");
  57.  $oo = '<html><head>
  58. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  59. <title> Mappa alloggi Ancora coop Unitaria    </title>
  60. <meta name="DESCRIPTION" content="tool scelta alloggi - mouse over ">
  61. <meta name="KEYWORDS" content="Unitaria, SantaMargheritaLigure, Tigullio, appartamenti liberi, assegnati, javascript, examples, source, code, forms, games">
  62. <meta name="AUTHOR" content="gianni rossini"> ' ;
  63.  
  64.  fwrite ($fo,$oo);
  65.  echo $oo;
  66.   $oo = '
  67.  
  68. <script type="text/JavaScript">
  69. <!--
  70. // Courtesy of SimplytheBest.net (http://simplythebest.net/info/dhtml_scripts.html)
  71. function Message0()
  72. {
  73. document.screen.message.value = "info sugli alloggi - scegli con il mouse";
  74. document.getElementById(\'imp\').setAttribute(\'src\',\'../image_alloggi/00.jpg\');
  75. }
  76.  
  77. //-->
  78. </script> ';
  79.    fwrite ($fo,$oo);  echo $oo;
  80.  
  81.  $oo='
  82. <script language="JavaScript" type="text/JavaScript">
  83. <!--
  84. function showT(q, casa, descrizione, piano, costo, dimensione,mappa ){
  85.  //alert(\'../\image_alloggi/\'+\'casa\'+q+\'.jpg\')
  86.  document.getElementById(\'ima\').setAttribute(\'src\',\'../\image_alloggi/\'+mappa+\'.jpg\');
  87.  document.getElementById(\'imp\').setAttribute(\'src\',\'../\image_alloggi/\'+casa+q+\'.jpg\');
  88.  document.screen.message.value = "casa " + casa + " piano "+ piano + " interno " + q  + "\n costo €." + costo +"\n mq." + dimensione +"\n" + descrizione;
  89. }
  90. //-->
  91. </script>
  92.  
  93. </head> ';
  94.  fwrite ($fo,$oo); echo $oo;
  95.  $oo= '
  96. <body>
  97. <center>
  98. <font size="6">
  99. <b>
  100. Mappa assegnazione alloggi Ancora
  101. </b>
  102. </font>
  103. <br>
  104. <br>
  105. <font color="#b22222" size="5">
  106. Mouseover Information Table
  107. </font>
  108. <br>
  109. Author:
  110. <a href="http://digilander.libero.it/magiainformatica/">ma.gi.a. informatica di rossini </a>
  111. </center>
  112. <br>
  113. <div align="center">
  114. <TABLE border=0 cellPadding=3 cellSpacing=0 width = 450>
  115. <TBODY>';
  116.  
  117.  fwrite ($fo,$oo); echo $oo;
  118.  
  119.  $oo = '        <TR align=middle>
  120.  
  121.                 <TD bgcolor="#B1BFC5">
  122.                         <TABLE border=0 cellPadding=0 cellSpacing=0>
  123.                         <tr align=middle>
  124.                                 <td width= "100" >
  125.                                          casa A <br>(1/3 camere)
  126.                                 </td>
  127.  
  128.                                 <td width= "100" >
  129.                                          casa B <br>(2 camere)
  130.                                 </td>
  131.  
  132.                                 <td width= "100" >
  133.                                          casa C <br>(2 camere)
  134.                                 </td>
  135.                         </tr>
  136.                         </table>
  137.                         <table border=1 cellPadding=0 cellSpacing=0>  ';
  138.  fwrite ($fo,$oo); echo $oo;
  139.  
  140.  $caseggiati[0]='A';
  141.  $caseggiati[1]='B';
  142.  $caseggiati[2]='C';
  143.  
  144.  $piani[1]=4;
  145.  $piani[2]=4;
  146.  $piani[3]=4;
  147.  $piani[4]=4;
  148.  $piani[5]=4;
  149.  $piani[6]=2;
  150.  
  151.  $mappa[0][2] ="quattro_img_rosso";
  152.  $mappa[0][1] ="quattro_img_rosso";
  153.  $mappa[0][0] ="quattro_img_verde";
  154.  
  155.  $mappa[1][2] ="uno_img_rosso";
  156.  $mappa[1][1] ="uno_img_rosso";
  157.  $mappa[1][0] ="uno_img_verde";
  158.  
  159.  $mappa[2][2] ="due_img_rosso";
  160.  $mappa[2][1] ="due_img_rosso";
  161.  $mappa[2][0] ="due_img_verde";
  162.  
  163.  $mappa[3][2] ="tre_img_rosso";
  164.  $mappa[3][1] ="tre_img_rosso";
  165.  $mappa[3][0] ="tre_img_verde";
  166.  
  167.  $mappa_attico[0][2] ="atticodue_img_rosso";
  168.  $mappa_attico[0][1] ="atticodue_img_rosso";
  169.  $mappa_attico[0][0] ="atticodue_img_verde";
  170.  
  171.  $mappa_attico[1][2] ="atticouno_img_rosso";
  172.  $mappa_attico[1][1] ="atticouno_img_rosso";
  173.  $mappa_attico[1][0] ="atticouno_img_verde";
  174.  
  175.  $assegn_att_dx[0] = "../image_alloggi/verde_dx_attico.jpg";
  176.  $assegn_att_dx[1] = "../image_alloggi/rosso_dx_attico.jpg";
  177.  $assegn_att_dx[2] = "../image_alloggi/giallo_dx_attico.jpg";
  178.  $assegn_att_sx[0] = "../image_alloggi/verde_sx_attico.jpg";
  179.  $assegn_att_sx[1] = "../image_alloggi/rosso_sx_attico.jpg";
  180.  $assegn_att_sx[2] = "../image_alloggi/giallo_sx_attico.jpg";
  181.  
  182.  $assegn[0] = "../image_alloggi/rosso.jpg";
  183.  $assegn[1] = "../image_alloggi/verde.jpg";
  184.  $assegn[2] = "../image_alloggi/verde.jpg";
  185.  
  186.  $assegnbgcolor[0] = "#009800";  //sfondo verde
  187.  $assegnbgcolor[1] = "#980000";  //sfondo rosso
  188.  $assegnbgcolor[2] = "#989800";  //sfondo giallo
  189.  
  190.  //echo "piani: " . count($piani) . " caseggiati: " .count($caseggiati)   . "\r\n";
  191.  $ii= 23;
  192.  // piani 6-5-4-3-2-1-
  193.  for ($p = count($piani); $p >= 1; $p-- )
  194.  {
  195.  
  196.         $oo = "\n".'                    <tr> '."\n". '<!-- piano '.  $p . ' attico --> '. "\n";
  197.         fwrite ($fo,$oo); echo $oo;
  198.      // caseggiati A-B-C
  199.         for ($cas = 0 ; $cas < count($caseggiati) ; $cas ++)
  200.         {
  201.                 // alloggi piano 1-2-3-4  oppure attico 1-2
  202.         for ($pcas = $piani[$p]; $pcas >= 1; $pcas--)
  203.                 {
  204.                         // prepara sfondo e testo in funzione del piano e della casa   - $k formato A01 - $kimg formato A1
  205.                         //echo "casa ".$caseggiati[$cas]. " piano ". $p . " num.app x piano " . $piani[$p] . " app.num ".  ($ii - $pcas ).  "\n";
  206.                         $k = sprintf('%s%02d', $caseggiati[$cas],($ii - $pcas ));
  207.                         $kimg = sprintf('%s%d', $caseggiati[$cas],($ii - $pcas ));
  208.  
  209.                         // test assegnazione se assegnato $ass = 1 else $ass = 0
  210.                         //echo  "k = $k " .  $elenco[$k][2] . " ass.a ".  $elenco[$k][9] . "\n";
  211.  
  212.                     $elenco[$k][9] = trim ($elenco[$k][9]);
  213.                     if (strlen($elenco[$k][9]) > 0)
  214.                     {
  215.                        $ass=1;
  216.                          if (isset($_SERVER['REDIRECT_REMOTE_USER']) and
  217.                              ($_SERVER['REDIRECT_REMOTE_USER'] == 'magia' or $_SERVER['REDIRECT_REMOTE_USER'] == 'ccel'))
  218.                            $elenco[$k][2] .= "\\n ass.a ". $elenco[$k][9];
  219.                          else
  220.                            $elenco[$k][2] .= "\\n ass.a *****";
  221.                     }
  222.                     else{
  223.                           if ((isset($elenco[$k][10])) and (strlen($elenco[$k][10]) > 0))
  224.                           {
  225.                            $ass=2;
  226.                            if (isset($_SERVER['REDIRECT_REMOTE_USER']) and
  227.                                       ($_SERVER['REDIRECT_REMOTE_USER'] == 'magia' or $_SERVER['REDIRECT_REMOTE_USER'] == 'ccel'))
  228.                              {
  229.                                   $elenco[$k][2] .= "\\n pren.da ". $elenco[$k][10];
  230.                                  if (isset($elenco[$k][11]))
  231.                                  {
  232.                                    $elenco[$k][11] = trim ($elenco[$k][11]);
  233.                                    $finoa = str_replace("/","-",$elenco[$k][11]);
  234.                                    $elenco[$k][2] .= " fino al " .$finoa;
  235.                                  }
  236.  
  237.                              }
  238.                              else
  239.                                 $elenco[$k][2] .= "\\n ass.a *****";
  240.                           }
  241.                           else
  242.                             $ass=0;
  243.                          //$elenco[$k][9] = "";
  244.                     }
  245.  
  246.  
  247.                     // test se attico (attico solo 2 app per piano)
  248.                      if ($piani[$p] < 4)
  249.                     {
  250.                        $mp =($ii - $pcas )%2;
  251.                        $oo = "\n".' <td colspan = "2"> '."\n";
  252.   // <a href="navigation.html" onmouseover=" showT(22,'A','Attico', 6, '550', '140' ); return true" onmouseout="Message0();return true"><img border="0" src="infotable_files/verde_sx_attico.jpg" alt="Navigation and Menu scripts" width="50" height="29"></a>
  253.  
  254.                           $oo.= '<a href="../image_alloggi/'.$kimg.'.jpg"
  255.                                 onmouseover=" showT('. ($ii - $pcas ).',\''.$caseggiati[$cas].'\',\''.$elenco[$k][2].'\','. $p.', \''.$elenco[$k][7].'\', \''.$elenco[$k][4].'\' , \''.$mappa_attico[$mp][$ass] .'\'); return true"
  256.                                    onmouseout="Message0();return true">'."\n";
  257.                           // test se attico destro o sinistro
  258.                           if(($ii - $pcas )%2 == 0 )
  259.                              $oo.=  '<img border="0" src="' . $assegn_att_dx[$ass] .'" alt="Navigation and Menu scripts" width="50" height="29"></a>';
  260.  
  261.                  else
  262.                     $oo.=  '<img border="0" src="' . $assegn_att_sx[$ass] .'" alt="Navigation and Menu scripts" width="50" height="29"></a>';
  263.  
  264.                           $oo.= "\n". ' </td> '. "\n";
  265.                         }
  266.                         else // piano normale
  267.                         {
  268.                           $mp =($ii - $pcas )%4;
  269.  
  270.                           $oo = "\n". '  <td width="24" height="29" bgcolor="'. $assegnbgcolor[$ass] . '"  > ';
  271.   // <a href="navigation.html" onmouseover=" showT(22,'A','Attico', 6, '550', '140' ); return true" onmouseout="Message0();return true">                                <img border="0" src="infotable_files/verde_sx_attico.jpg" alt="Navigation and Menu scripts" width="50" height="29"></a>
  272.                           $oo.= '<a style="text-decoration:none" href="../image_alloggi/'.$kimg.'.jpg"
  273.                                onmouseover=" showT('. ($ii - $pcas ).',\''.$caseggiati[$cas].'\',\''.$elenco[$k][2].'\','. $p.', \''.$elenco[$k][7].'\', \''.$elenco[$k][4].'\' , \''.$mappa[$mp][$ass] .'\' ); return true"
  274.                                onmouseout="Message0();return true">'."\n";
  275.  
  276.                          // $oo.= '<img border="0" src="' . $assegn[$ass] .'" alt="Navigation and Menu scripts" width="24" height="29"></a>';
  277.                 $oo .= '<font size = -2 color = "black" >'. $k .'</font></a>';
  278.                           $oo.= "\n".' </td>'. "\n" ;
  279.                         }
  280.                         fwrite ($fo,$oo); echo $oo;
  281.  
  282.                     $lastnumapp=$ii - $pcas +1;
  283.                 }
  284.                 if ($piani[$p] < 4)
  285.                   $oo = '<td width = "40" bgcolor="#B1BFC5"></td>'. "\n";
  286.                 else
  287.                    $oo = ' <td width = "40" bgcolor="#B1BFC5"></td> ' . "\n";
  288.          fwrite ($fo,$oo); echo $oo;
  289.         }
  290.         $ii =   $lastnumapp-$piani[$p];
  291.      //echo  $lastnumapp ."\n";
  292.      $oo = '                    </tr> ' ;
  293.         fwrite ($fo,$oo); echo $oo;
  294.  }
  295.  
  296.  $oo='</TABLE> <br>sfondo rosso  assegnati <br> sfondo giallo prenotati <br> sfondo verde liberi
  297.                 </td>
  298.         <td width = "20" > </td>
  299.         <td>
  300.    <TABLE border=0 cellPadding=0 cellSpacing=0 width = 460 >
  301.         <TR align=top >
  302.         <td>
  303.                 <img id="imp" src="../image_alloggi/00.jpg" width="250" height="250">
  304.         </td>
  305.         <td>
  306.                 <img src="../image_alloggi/pianta.jpg" border="0" width="200" height="150"><br>
  307.                 <img id="ima" src="../image_alloggi/piano_img.jpg" border="1" width="100" height="100">
  308.         </td>
  309.         </tr>
  310.         <tr>
  311.         <TD colspan = "2" >
  312.      <FORM action="" method=post name=screen>
  313.           <TEXTAREA cols=50 name=message readOnly rows=5 style="background-color: #E6F2FF" wrap=on> info sugli alloggi - scegli con il mouse
  314.           </TEXTAREA>
  315.         </FORM>
  316.         </TD>
  317.         </TR>
  318.    </table>
  319. </tr></table>
  320.  
  321. </div>
  322. <br>
  323. </body>
  324. </html>' ;
  325.  fwrite ($fo,$oo); echo $oo;
  326.  
  327.  
  328.  fclose($fo);
  329.  include "../log/eklog.php" ;
  330.  //echo "done \n";
  331.  // end
  332.  
  333.  
  334.  /*
  335.  ** save_tabbed_file ( string filepath )
  336.  ** save array fat_items ordinato per numero fatture
  337.  */
  338.  function save_elenco_fatture($filename){
  339.      global $fat_items;
  340.      //print_r( $fat_items);
  341.      $fp = fopen($filename, "w+");
  342.      foreach ($fat_items as $t){
  343.          //$rec = explode(";",$t);
  344.          //echo "t[11] is =  $t[11]\n";
  345.          $rec = "$t[0];$t[1];$t[2];$t[3];$t[4];$t[5];$t[6];$t[7];$t[8]";
  346.          //echo $rec."\n\r";
  347.          fwrite($fp, $rec);
  348.      }
  349.      fclose($fp);
  350.  }
  351.  
  352.  /*
  353.  ** load_tabbed_file ( string filepath )
  354.  ** Loads a file with content seperated by tabs (-> array)
  355.  */
  356.  
  357.  function load_tabbed_file($filename){
  358.  
  359.      $output = array();
  360.      $i = 0;
  361.      if (file_exists($filename)){
  362.  
  363.          $lines = file($filename);
  364.  
  365.          for ($x=0; $x < count($lines); $x++){
  366.  
  367.              $line = trim($lines[$x]);
  368.              $line = rtrim($lines[$x],";");
  369.             // echo $line. "\n\r";
  370.  
  371.              if (substr($line,0,5) != ";;;;;"){
  372.  
  373.                 // if (substr($lines[$x],-1,1)  != ";")
  374.                 //    $lines[$x] += ";";
  375.                 // $lines[$x] = str_replace("\t", "    ", $lines[$x]);
  376.                 // $lines[$x] = preg_replace("/[ ]{4,}/", "    ", $lines[$x]);
  377.  //              $res = explode("    ", $lines[$x]);
  378.                 $line[$x] = rtrim($lines[$x],";");
  379.  
  380.                 $res = explode(";", $lines[$x]);
  381.                 //echo $res[0]."-".$res[1]."-".$res[2]."-".$res[3]."-".$res[4]."-".$res[5]."-".$res[6]."-".$res[7]."-".$res[8]."-".$res[9]. "\n\r";
  382.                            //   $res = trim_array($res);
  383.                 // extract numero fattura
  384.                 //$numfat=substr( $lines[$x],9,10);
  385.                 // echo $numfat."\n";
  386.                 // $output[$numfat] =  $lines[$x];
  387.                 $output[]= $res;
  388.               //  $output[] =array($res[0],$res[1], $res[2],$res[3],$res[10]);
  389.                 //ksort($output);
  390.  
  391.                 $i++;
  392.  
  393.              }
  394.  
  395.          }
  396.          // sort multidimension array on column 1 (numero fattura)
  397.         // print_r($output);
  398.          foreach($output as $rrr)
  399.               $sortAux[]= $rrr[0];
  400.          array_multisort( $sortAux,SORT_DESC, $output) ;
  401.         // print_r($output);
  402.      }
  403.  
  404.      return $output;
  405.  
  406.  }
  407.  
  408.  
  409.  ?>