[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-ocs/sources/www/ -> ajout_maj.php (source)

   1  <?php
   2  //====================================================================================
   3  // OCS INVENTORY REPORTS
   4  // Copyleft Pierre LEMMET 2005
   5  // Web: http://ocsinventory.sourceforge.net
   6  //
   7  // This code is open source and may be copied and modified as long as the source
   8  // code is always made freely available.
   9  // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
  10  //====================================================================================
  11  //Modified on 11/25/2005
  12      
  13  if (isset($_GET['action'])) {
  14      $action = $_GET['action'];
  15  }
  16  
  17  if (isset($_POST['action_form'])) {
  18      $action_form = $_POST['action_form'];
  19  }
  20  
  21  function MAJ_Inventory($systemid)
  22  {
  23      $queryAcc = "SELECT * FROM accountinfo WHERE hardware_id=$systemid";
  24      $resultAcc = mysql_query($queryAcc, $_SESSION["readServer"])  or die(mysql_error($_SESSION["readServer"]));
  25      $item=mysql_fetch_array($resultAcc,MYSQL_ASSOC);
  26      foreach ($item as $k => $v) {
  27          $lesCol[] = $k;
  28      }
  29      
  30      $requeteSQL = "UPDATE accountinfo SET ";
  31      $indexType=0;
  32      foreach ($_POST as $kp => $vp) {        
  33          if(!in_array($kp,$lesCol))
  34              continue;
  35          $indexType++;    
  36          
  37          if(mysql_field_type($resultAcc,$indexType)=="date") {
  38              if($vp)
  39                  $vp = dateToMysql($vp);            
  40          }
  41          
  42          $requeteSQL.="$kp='$vp',";        
  43      }
  44      
  45      $requeteSQL = substr($requeteSQL,0,strlen($requeteSQL)-1);
  46      $requeteSQL.=" WHERE hardware_id=$systemid";
  47      // Exécution de la requête SQL
  48      if( lock($systemid) ) {
  49          $resultat = mysql_query( $requeteSQL, $_SESSION["writeServer"] );
  50          unlock($systemid);
  51      }
  52      else
  53          errlock();
  54          
  55      return;
  56  }
  57  
  58  if ($action_form == 'modifier')
  59  {    
  60      $systemid = $_POST["systemid"];
  61      MAJ_Inventory($systemid);    
  62      echo "<script language='javascript'>\n";
  63      echo "\twindow.open(\"./machine.php?sessid=".session_id()."&systemid=$systemid&state='MAJ'\", \"_self\");\n";
  64      echo "</script>\n";
  65  }
  66  
  67  echo "<table class='Items' width='100%' border='0' cellpadding='4'>";
  68  echo "<tr>";
  69  echo "<td valign='center' align='left' width='100%'><b>".$l->g(56)."</b></font></td>";
  70  echo "</tr>";
  71  echo "</table>";
  72  
  73  $queryAcInf = "SELECT * FROM accountinfo WHERE hardware_id=$systemid";
  74  $resultAcInf = mysql_query($queryAcInf, $_SESSION["readServer"] ) or die(mysql_error($_SESSION["readServer"]));
  75  $item=mysql_fetch_array($resultAcInf,MYSQL_ASSOC);
  76  
  77  //********************************************************************
  78  //*                       FORMULAIRE DE SAISIE                         *
  79  //********************************************************************
  80  echo "<form method='POST' name='Ajout_MAJ' action='machine.php'>\n";
  81  echo "<table width='100%' border='0' bgcolor='#C7D9F5' cellpadding='4' style='border: solid thin; border-color:#A1B1F9'>\n";
  82  $indexType = -1;
  83  foreach ($item as $k=>$v) {
  84      $indexType++;
  85      $kaff = $k;
  86      if($k == "DEVICEID" || $k == "UNITID" || $k == "HARDWARE_ID")
  87          continue;
  88      if($k == "TAG")
  89          $kaff = TAG_LBL;
  90      
  91      if(mysql_field_type($resultAcInf,$indexType)=="date")
  92          echo "<tr bgcolor='#FFFFFF'><td align='right'><b>$kaff:</b></font></td><td>
  93          <input READONLY ".dateOnClick($k)." type='text' tabindex='5' name='$k' id='$k' value='".dateFromMysql($v)."'>".datePick($k).
  94          "&nbsp;&nbsp;</td></tr>\n";
  95      else
  96          echo "<tr bgcolor='#F2F2F2'><td align='right'><b>$kaff:</b></font></td><td><input type='text' tabindex='1' name='$k' value='$v'></td></tr>\n";
  97  }
  98  
  99  // les dates
 100  echo "</table><br>\n";
 101  echo "<table class='Items' width='100%' border='0' cellpadding='4'>";
 102  echo "<tr><td align='center' colspan='2'>\n";
 103  echo "<input onmouseover=\"this.style.background='#FFFFFF';\" onmouseout=\"this.style.background='#C7D9F5'\" class='bouton' type='submit' value='".$l->g(114)."' $event_mouse>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
 104  echo "<input onmouseover=\"this.style.background='#FFFFFF';\" onmouseout=\"this.style.background='#C7D9F5'\" class='bouton' type='button' value='   ".$l->g(113)."   ' onClick='window.open(\"./machine.php?sessid=".session_id()."&systemid=$systemid\", \"_self\");' $event_mouse>\n";
 105  echo "<input type='hidden' name='sessid' value='".session_id()."'>";
 106  echo "<input type='hidden' name='systemid' value='".$systemid."'>";
 107  echo "</td></tr>\n";
 108  echo "</table>\n";
 109  
 110  if ($action == "ajouter_donnees")
 111  {
 112      echo "<input type='hidden' name='action_form' value='ajouter'>\n";
 113  }
 114  elseif ($action == "MAJ_donnees")
 115  {
 116      echo "<input type='hidden' name='action_form' value='modifier'>\n";
 117  }
 118  
 119  echo "<input type='hidden' name='systemid' value='$systemid'>\n";
 120  echo "</form>\n";
 121  echo "</body>";
 122  echo "</html>";
 123  ?>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1