Пример #1
0
 function getExpirationDate($contents)
 {
     $field = "Expiration Date";
     $searchfin = stristr($contents, $field);
     $maDateFin = substr($searchfin, 138, 10);
     $maDateFin = trim($maDateFin);
     $maDateFin = PluginManufacturersimportsPostImport::checkDate($maDateFin);
     return $maDateFin;
 }
Пример #2
0
 function getBuyDate($contents)
 {
     $maDate = substr($contents, 60, 10);
     $maDate = trim($maDate);
     $maDate = str_replace('/', '-', $maDate);
     $maDate = PluginManufacturersimportsPostImport::checkDate($maDate, true);
     if ($maDate != "0000-00-00") {
         list($jour, $mois, $annee) = explode('-', $maDate);
         $maDate = date("Y-m-d", mktime(0, 0, 0, $mois, $jour, $annee));
     }
     return $maDate;
 }
 function getExpirationDate($contents)
 {
     $expiration_date = NULL;
     //cut html
     if (strpos($contents, "upgrade_content")) {
         $contents = substr($contents, 0, strrpos($contents, "upgrade_content"));
     } else {
         $contents = substr($contents, 0, strpos($contents, "base_content2"));
     }
     //find dates in html content
     preg_match_all("/([0-9]{1,2}\\/[0-9]{1,2}\\/[0-9]{1,4})/s", $contents, $dates);
     if (isset($dates[0])) {
         // get last of found dates
         $expiration_date_raw = array_pop($dates[0]);
         //extract date parts
         preg_match("/([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{1,4})/", $expiration_date_raw, $expiration_date_parts);
         if (count($expiration_date_parts) === 4) {
             // forge final date
             $year = $expiration_date_parts[3];
             $month = $expiration_date_parts[1];
             $day = $expiration_date_parts[2];
             $expiration_date = "2" . str_pad($year, 3, "0", STR_PAD_LEFT) . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT) . " 00:00:00";
         }
     }
     return PluginManufacturersimportsPostImport::checkDate($expiration_date);
 }
Пример #4
0
 function getExpirationDate($contents)
 {
     $field = "End Date:";
     $searchend = self::strallpos($contents, $field);
     $dates = array();
     if ($searchend) {
         foreach ($searchend as $pos) {
             $date = substr($contents, $pos + 19, 10);
             $date = trim($date);
             $dates[] = $date;
         }
     }
     sort($dates);
     $values = array_values($dates);
     $output = end($values);
     $output = PluginManufacturersimportsPostImport::checkDate($output);
     return $output;
 }
Пример #5
0
 static function getInfos($serial, $field)
 {
     $output = "";
     $self = new self();
     $infos = $self->getInfo($serial);
     $infos = self::obj2array($infos);
     $dates = array();
     foreach ($infos['Asset'] as $line) {
         //Sometimes it happends on Windows that the array looks a little bit different
         //so check both cases
         if (isset($line['Entitlements']['EntitlementData']) || isset($line['EntitlementData'])) {
             if (isset($line['Entitlements']['EntitlementData'])) {
                 $tmp = $line['Entitlements']['EntitlementData'];
             } else {
                 $tmp = $line['EntitlementData'];
             }
             foreach ($tmp as $info) {
                 $dates[] = $info[$field];
             }
         }
     }
     $alldates = array();
     if (!empty($dates)) {
         foreach ($dates as $date) {
             $tab = explode("T", $date);
             $maDate = PluginManufacturersimportsPostImport::checkDate($tab[0]);
             $alldates[] = $maDate;
         }
     }
     if ($field == "StartDate") {
         $values = array_values($alldates);
         $output = end($values);
     } else {
         $output = array_shift($alldates);
     }
     return $output;
 }
Пример #6
0
You should have received a copy of the GNU General Public License
along with Manufacturersimports. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
$log = new PluginManufacturersimportsLog();
$config = new PluginManufacturersimportsConfig();
Html::header(_n('Suppliers import', 'Suppliers imports', 2, 'manufacturersimports'), $_SERVER['PHP_SELF'], "plugins", "manufacturersimports");
$config->checkGlobal("r");
if (isset($_POST["action"]) && isset($_POST["id"]) && isset($_POST["item"]) && count($_POST["item"])) {
    switch ($_POST["action"]) {
        case "import":
            PluginManufacturersimportsPostImport::massiveimport($_POST);
            break;
        case "reinit_once":
            foreach ($_POST["item"] as $key => $val) {
                if ($val == 1) {
                    $log->reinitializeImport($_POST["itemtype"], $key);
                }
            }
            Session::addMessageAfterRedirect(__('Operation successful'));
            Html::redirect($_SERVER['HTTP_REFERER'] . "?itemtype=" . $_POST["itemtype"] . "&manufacturers_id=" . $_POST["manufacturers_id"] . "&start=" . $_POST["start"] . "&imported=" . $_POST["imported"]);
            break;
    }
} else {
    echo "<div align='center'>";
    echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt=\"warning\"><br><br>";
    echo "<b>" . __('No selected element or badly defined operation') . "</b></div>";