lenovo.class.php

lenovo.class.php - Penflame, 07/25/2014 01:59 PM

Download (3.81 KB)

 
1
<?php
2
/*
3
 * @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $
4
 -------------------------------------------------------------------------
5
 Manufacturersimports plugin for GLPI
6
 Copyright (C) 2003-2011 by the Manufacturersimports Development Team.
7

8
 https://forge.indepnet.net/projects/manufacturersimports
9
 -------------------------------------------------------------------------
10

11
 LICENSE
12

13
 This file is part of Manufacturersimports.
14

15
 Manufacturersimports is free software; you can redistribute it and/or modify
16
 it under the terms of the GNU General Public License as published by
17
 the Free Software Foundation; either version 2 of the License, or
18
 (at your option) any later version.
19

20
 Manufacturersimports is distributed in the hope that it will be useful,
21
 but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 GNU General Public License for more details.
24

25
 You should have received a copy of the GNU General Public License
26
 along with Manufacturersimports. If not, see <http://www.gnu.org/licenses/>.
27
 --------------------------------------------------------------------------
28
 */
29

    
30
if (!defined('GLPI_ROOT')) {
31
    die("Sorry. You can't access directly to this file");
32
}
33

    
34
class PluginManufacturersimportsLenovo extends PluginManufacturersimportsManufacturer {
35

    
36
   function showCheckbox($ID,$sel,$otherSerial=false) {
37

    
38
      return "<input type='checkbox' name='item[".$ID."]' value='1' $sel>";
39

    
40
   }
41

    
42
   function showItemTitle($output_type,$header_num) {
43

    
44
      return Search::showHeaderItem($output_type,__('Model number', 'manufacturersimports'),$header_num);
45

    
46
   }
47

    
48
   function showDocTitle($output_type,$header_num) {
49

    
50
      return Search::showHeaderItem($output_type,_n('Associated document', 'Associated documents', 2),$header_num);
51

    
52
   }
53

    
54
   function showItem($output_type,$otherSerial,$item_num,$row_num) {
55

    
56
      return Search::showItem($output_type,$otherSerial,$item_num,$row_num);
57
   }
58

    
59
   function getSearchField() {
60

    
61
      $field = "Start Date:";
62

    
63
      return $field;
64
   }
65

    
66
   function getSupplierInfo($compSerial=null, $otherserial=null) {
67

    
68
      $info["name"]="Lenovo";
69
      $info["supplier_url"] = "https://csp.lenovo.com/ibapp/il/WarrantyStatus.jsp?";
70
      $info["url"] = $info["supplier_url"]."serial=".$compSerial."&sysMachType=".$otherserial."&btnSubmit";
71

    
72
      return $info;
73
   }
74
   
75
   static function strallpos($haystack,$needle,$offset = 0){
76
       $result = array();
77
       for($i = $offset; $i<strlen($haystack); $i++){
78
           $pos = strpos($haystack,$needle,$i);
79
           if($pos !== FALSE){
80
               $offset =  $pos;
81
               if($offset >= $i){
82
                   $i = $offset;
83
                   $result[] = $offset;
84
               }
85
           }
86
       }
87
       return $result;
88
   }
89
   
90
   function getBuyDate($contents) {
91
      
92
      $field = "Start Date:";
93

    
94
      $searchbegin = self::strallpos($contents, $field);
95
      
96
      $dates = array();
97
      
98
      if($searchbegin) {
99
         foreach($searchbegin as $pos) {
100
             
101
            $date = substr($contents, $pos+21, 12);
102
            $dates[]=$date;
103

    
104
         }
105
      }
106
      sort($dates);
107
      $output = array_shift($dates);
108

    
109
      $output = PluginManufacturersimportsPostImport::checkDate($output);
110

    
111
      return $output;
112
   }
113

    
114
   function getExpirationDate($contents) {
115

    
116
      $field = "End Date:";
117

    
118
      $searchend = self::strallpos($contents, $field);
119

    
120
      $dates = array();
121
      
122
      if($searchend) {
123
         foreach($searchend as $pos) {
124
            $date = substr($contents, $pos+19,10);
125
            $date = trim($date);
126
            $dates[]=$date;
127
         }
128
      }
129
      sort($dates);
130
      
131
      $values = array_values($dates);
132
      $output = end($values);
133
      
134
      $output = PluginManufacturersimportsPostImport::checkDate($output);
135
      
136
      return $output;
137
   }
138
}
139

    
140
?>