Subversion Repositories computer_asset_manager_v1

Rev

Rev 99 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
99 rodolico 1
<?php
2
   include_once( '../../header.php' );
3
   include_once( './functions.php' );
4
   include_once( '../../includes/functions.php' );
5
 
6
?>
7
 
8
<?xml version="1.0" encoding="utf-8"?>
9
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
10
<html xmlns="http://www.w3.org/1999/xhtml">
11
   <head>
12
     <title>Daily Data - Computer Asset Management Program</title>
13
     <link rel="stylesheet" type="text/css" href="../../camp.css">
14
   </head>
15
   <body>
16
      <?php include_once('../../menu.php'); ?>
17
      <div id="content">
18
      <?php 
19
         if ( isset( $_POST["submit"] ) ) {
20
            include_once( 'csvImporter.php' );
21
            $filename = tempnam( '/tmp', 'blk' );
22
            if ( move_uploaded_file( $_FILES["fileToUpload"]["tmp_name"], $filename ) ) {
23
               print "<p>Loading Data</p>\n";
24
               //$data = file( $filename,  FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES  );
25
               $data = file_get_contents( $filename );
26
               print"<pre>"; print_r( $_REQUEST ); print "</pre>";
27
               $data = parseTabDelimFile (
28
                              $data,
100 rodolico 29
                              isset( $_REQUEST['createattribute'] ),
30
                              isset( $_REQUEST['createdevice'] ),
99 rodolico 31
                              cleanInput( $_REQUEST['device_id'] ),
32
                              cleanInput( $_REQUEST['site_id'] ),
33
                              cleanInput( $_REQUEST['client_id'] )
34
                           );
35
               print"<pre>"; print_r( $data ); print "</pre>";
36
            } else {
37
               print "<p>Error: move_uploaded_file failed to move to $filename</p>";
38
            }
39
            //unlink( $filename );
40
         } else {
41
      ?>
42
    <h4>Upload a File</h4>
43
    <p>Max size: <?php print maxUploadFileSize(); ?></p>
44
   <p>Choose default device, site and client if your spreadsheet does not have those columns, or they are unpopulated</p>
45
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
46
    <input type='hidden' name='referer' value='<?php print $_SERVER['HTTP_REFERER']; ?>' />
47
    <input type='hidden' name='file_id' value='<?php print $oldValues['file_id']; ?>' />
48
    <table>
49
       <tr>
50
          <td>
51
             Default Device
52
          </td>
53
          <td>
54
             <select name='device_id' >
55
                <option value='0'>------------</option>
56
                <?php print queryToSelect( getAllDevices(), $oldValues['device_id'] ); ?>
57
             </select>
58
          </td>
59
       </tr>
60
       <tr>
61
          <td>
62
             Default Site
63
          </td>
64
          <td>
65
             <select name='site_id' >
66
                <option value='0'>------------</option>
67
                <?php print queryToSelect( getSites(), $oldValues['site_id'] ); ?>
68
             </select>
69
          </td>
70
       </tr>
71
       <tr>
72
          <td>
73
             Default Client
74
          </td>
75
          <td>
76
             <select name='client_id' >
77
                <option value='0'>------------</option>
78
                <?php print queryToSelect(getClients(), $oldValues['client_id'] ); ?>
79
             </select>
80
          </td>
81
       </tr>
82
        <tr>
83
          <td>
84
             Choose File
85
          </td>
86
          <td>
87
             <input name="fileToUpload" type="file" />
88
          </td>
89
       </tr>
90
      <tr>
91
         <td>Create device if not found</td>
92
         <td> <input type="checkbox" name="createdevice" value="createdevice"></td>
93
      </tr>
94
      <tr>
95
         <td>Create attributes if not found</td>
96
         <td> <input type="checkbox" name="createattribute" value="createattribute"></td>
97
      </tr>
98
       <tr>
99
          <td colspan='2' align="center">
100
               <input type="submit" value="Upload CSV" name="submit">
101
         </td>
102
       </tr>
103
   </table>
104
   </form>
105
        <h4>
106
            Bulk Upload Attributes File
107
         </h4>
108
         <p>
109
            Here you can upload a CSV (tab delimited) containing attributes and values. The first line of the file must be the
110
            column headers. Each following line will contain the values.
111
         </p>
112
         <p>
113
            <a href="<?php print dirname($_SERVER['SCRIPT_NAME']) . '/device_attribute_master.csv'; ?>">Get master csv file</a>.
114
            This contains all attributes as of 2020-01-15. Just delete any lines/columns you do not use.
115
         </p>
116
         <table border='1'>
117
            <tr>
118
               <th>Header Name</th>
119
               <th>Field Contents</th>
120
            </tr>
121
            <tr>
122
               <td><b>value</b></td>
123
               <td>The value to be placed in the attribute table for this device. May not contain line returns</td>
124
            </tr>
125
            <tr>
126
               <td><b>attribute</b></td>
127
               <td>The name of the attribute exactly as found in the attrib table</td>
128
            </tr>
129
            <tr>
130
               <td><b>attrib_id</b></td>
131
               <td>The index of the attribute from the attrib table</td>
132
            </tr>
133
            <tr>
134
               <td>device</td>
135
               <td>The name of the device exactly as found in the device table</td>
136
            </tr>
137
            <tr>
138
               <td>device_id</td>
139
               <td>The index of the device from the device table</td>
140
            </tr>
141
            <tr>
142
               <td>site</td>
143
               <td>The name of the site exactly as found in the site table</td>
144
            </tr>
145
            <tr>
146
               <td>site_id</td>
147
               <td>The index of the site from the site table</td>
148
            </tr>
149
            <tr>
150
               <td>client</td>
151
               <td>The name of the client exactly as found in the client table</td>
152
            </tr>
153
            <tr>
154
               <td>site_id</td>
155
               <td>The index of the client from the client table</td>
156
            </tr>
157
            <tr>
158
               <td>replace_existing</td>
159
               <td>If set to non-zero, device attributes which already exist will be updated<br />if empty or set to 0, a new row will always be created</td>
160
            </tr>
161
         </table>
162
         <p><b>Bolded items are required</b>, however you may choose either attribute or attrib_id (or both)</p>
163
      <?php } ?>
164
      </div>
165
   </body>
166
</html>
167