You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2006-07-25 12:35:35

jpolanco
Member
Registered: 2006-07-06
Posts: 14

OCS linkage with serial number?

I've using the last GLPI version from the tarball to integrate OCS 1.0RC3. This new release is awesome!

I have inventoried my company computers introducing them at GLPI by hand. So I have named them as i thought appropiated.


The problem came when I noticed that i can just link the computers through the computer name.It would be much better for me if i could link them using the serial number inventoried at OCS. Can it be possible or do i have to change the code to get that?

Thanks in advance

Offline

#2 2006-07-25 15:14:12

MoYo
GLPI - Lead
From: Poitiers
Registered: 2004-09-13
Posts: 14,513
Website

Re: OCS linkage with serial number?

you must modify the code.
But if you have few computers you could make it by hand it will be faster.


MoYo - Julien Dombre - Association INDEPNET
Contribute to GLPI :    Support     Contribute     References     Freshmeat

Offline

#3 2006-07-28 08:56:34

jpolanco
Member
Registered: 2006-07-06
Posts: 14

Re: OCS linkage with serial number?

Hello,

I am writing to ask for help about the issue that i posted above. I need to change the way that the OCS/GLPI
integration is done. I would like to do the integration though the serial number of the computer. This is because i work at a testing company where every computer has to be loaded with different images during the execution of the test cases. So it would be much better to do the inventory without having into account the computer´s name, better with the serial number.

I know I have to change some parts of the code, but i am not quite sure what these parts are. I have been reading some part of the code and noticed that the involved file is ocsng.function.php (ocsShowNewComputer, ocsUpdate....). I don´t know if there are other  parts that i am not having into account. I would thank you if someone could tell me what other parts (functions, files...) take part on the importation process and which changes i should make.

Hope someone can help me

Thanks and great job!..

Offline

#4 2006-07-28 08:59:30

jpolanco
Member
Registered: 2006-07-06
Posts: 14

Re: OCS linkage with serial number?

I forgot a thing, i am using GLPI 0.68RC3

Offline

#5 2006-07-28 10:17:11

jpolanco
Member
Registered: 2006-07-06
Posts: 14

Re: OCS linkage with serial number?

I finally got it, just change the function ocsShowNewComputer in ocsng.function.php. I modified a few things, if someone is interested let me know

Offline

#6 2006-07-28 12:11:53

JMD
GLPI - Lead
Registered: 2004-09-13
Posts: 9,180
Website

Re: OCS linkage with serial number?

You could put your diff here, if you want.


JMD / Jean-Mathieu Doléans - Glpi-project.org - Association Indepnet
Apportez votre pierre au  projet GLPI   : Soutenir

Offline

#7 2006-07-28 13:28:14

jpolanco
Member
Registered: 2006-07-06
Posts: 14

Re: OCS linkage with serial number?

The changes are marked with ##, it is working to me with no problems

file ocsng.function.php:

function ocsShowNewComputer($check,$start,$tolinked=0){
global $db,$dbocs,$dbocs2,$lang,$HTMLRel,$cfg_glpi;

if (!haveRight("ocsng","w")) return false;

$cfg_ocs=getOcsConf(1);

$WHERE="";
if (!empty($cfg_ocs["tag_limit"])){
        $splitter=explode("$",$cfg_ocs["tag_limit"]);
        if (count($splitter)){
                $WHERE="WHERE TAG='".$splitter[0]."' ";
                for ($i=1;$i<count($splitter);$i++)
                        $WHERE.=" OR TAG='".$splitter[$i]."' ";
        }
}


## $query_ocs = "select hardware.*, accountinfo.TAG AS TAG, bios.SSN AS SERIAL from (hardware INNER JOIN    accountinfo ON (hardware.ID = accountinfo.HARDWARE_ID)) INNER JOIN bios ON (hardware.ID =           bios.HARDWARE_ID) $WHERE order by hardware.NAME";
$result_ocs = $dbocs->query($query_ocs);
// Existing OCS - GLPI link
$query_glpi = "select * from glpi_ocs_link";
$result_glpi = $db->query($query_glpi);

// Computers existing in GLPI
## $query_glpi_comp = "select ID,name,serial from glpi_computers where deleted = 'N' AND is_template='0'";
$result_glpi_comp = $db->query($query_glpi_comp);

if ($dbocs->numrows($result_ocs)>0){

        // Get all hardware from OCS DB
        $hardware=array();
        while($data=$dbocs->fetch_array($result_ocs)){
                $data=clean_cross_side_scripting_deep(addslashes_deep($data));
                $hardware[$data["DEVICEID"]]["date"]=$data["LASTDATE"];
                $hardware[$data["DEVICEID"]]["name"]=$data["NAME"];
                $hardware[$data["DEVICEID"]]["TAG"]=$data["TAG"];
         ##   $hardware[$data["DEVICEID"]]["serial"]=$data["SERIAL"];
        }
        // Get all links between glpi and OCS
        $already_linked=array();
         }
        }
        // Get all existing computers name in GLPI
        $computer_names=array();
        if ($db->numrows($result_glpi_comp)>0){
                while($data=$dbocs->fetch_array($result_glpi_comp)){
                       ## $computer_names[$data["serial"]]=$data["ID"];
                }
        }

        // Clean $hardware from already linked element
        if (count($already_linked)>0){
                foreach ($already_linked as $ID => $date){
                        if (isset($hardware[$ID])&&isset($already_linked[$ID]))
                        unset($hardware[$ID]);
                }
        }

        if ($tolinked&&count($hardware)){
echo "<div align='center'><strong>".$lang["ocsng"][22]."</strong></div>";
        }

        echo "<div align='center'>";
        if (($numrows=count($hardware))>0){

                $parameters="check=$check";
                printPager($start,$numrows,$_SERVER["PHP_SELF"],$parameters);

                // delete end
                array_splice($hardware,$start+$cfg_glpi["list_limit"]);
                // delete begin
                if ($start>0)
                array_splice($hardware,0,$start);

                echo "<form method='post' name='ocsng_form' id='ocsng_form' action='".$_SERVER["PHP_SELF"]."'>";
                if ($tolinked==0)
echo "<a href='".$_SERVER["PHP_SELF"]."?check=all&amp;start=$start' onclick= \"if ( markAllRows('ocsng_form') ) return false;\">".$lang["buttons"][18]."</a>&nbsp;/&nbsp;<a href='".$_SERVER["PHP_SELF"]."?check=none&amp;start=$start' onclick= \"if ( unMarkAllRows('ocsng_form') ) return false;\">".$lang["buttons"][19]."</a>";


                echo "<table class='tab_cadre'>";
                echo  ##"<tr><th>".$lang["ocsng"][5]."</th><th>SERIAL</th><th>".$lang["common"][27]."</th><th>TAG</th><th>&nbsp;</th></tr>";

                echo "<tr class='tab_bg_1'><td colspan='4' align='center'>";
                echo "<input class='submit' type='submit' name='import_ok' value='".$lang["buttons"][37]."'>";
                echo "</td></tr>";


                foreach ($hardware as $ID => $tab){
                        echo "<tr ##class='tab_bg_2'><td>".$tab["name"]."</td><td>".$tab["serial"]."</td><td>".$tab["date"]."</td><td>".$tab["TAG"]."</td><td>";


if ($tolinked==0)
                        echo "<input type='checkbox' name='toimport[$ID]' ".($check=="all"?"checked":"").">";
                        else {
                               ## if (isset($computer_names[$tab["serial"]]))
                                     ##   dropdownValue("glpi_computers","tolink[$ID]",$computer_names[$tab["serial"]]);
                                else
                                        dropdown("glpi_computers","tolink[$ID]");
                        }
                        echo "</td></tr>";

                }
                echo "<tr class='tab_bg_1'><td colspan='4' align='center'>";
                echo "<input class='submit' type='submit' name='import_ok' value='".$lang["buttons"][37]."'>";
                echo "</td></tr>";
                echo "</table>";
                echo "</form>";
  printPager($start,$numrows,$_SERVER["PHP_SELF"],$parameters);

        } else echo "<strong>".$lang["ocsng"][9]."</strong>";

        echo "</div>";

} else echo "<div align='center'><strong>".$lang["ocsng"][9]."</strong></div>";
}

Offline

#8 2006-07-28 13:51:48

JMD
GLPI - Lead
Registered: 2004-09-13
Posts: 9,180
Website

Re: OCS linkage with serial number?

Thanks for the others users


JMD / Jean-Mathieu Doléans - Glpi-project.org - Association Indepnet
Apportez votre pierre au  projet GLPI   : Soutenir

Offline

Board footer

Powered by FluxBB