Ganteng Doang Upload Shell Gak Bisa


Linux server.jmdstrack.com 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
/ home/ jmdstrac/ public_html/ devices/ src/

/home/jmdstrac/public_html/devices/src/CommonDCModelDropdown.php

<?php

/**
 * ---------------------------------------------------------------------
 *
 * GLPI - Gestionnaire Libre de Parc Informatique
 *
 * http://glpi-project.org
 *
 * @copyright 2015-2023 Teclib' and contributors.
 * @copyright 2003-2014 by the INDEPNET Development Team.
 * @licence   https://www.gnu.org/licenses/gpl-3.0.html
 *
 * ---------------------------------------------------------------------
 *
 * LICENSE
 *
 * This file is part of GLPI.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * ---------------------------------------------------------------------
 */

use Glpi\Features\AssetImage;

/// CommonDCModelDropdown class - dropdown for datacenter items models
abstract class CommonDCModelDropdown extends CommonDropdown
{
    use AssetImage;

    public $additional_fields_for_dictionnary = ['manufacturer'];


    public static function getFieldLabel()
    {
        return _n('Model', 'Models', 1);
    }

    /**
     * Return Additional Fields for this type
     *
     * @return array
     **/
    public function getAdditionalFields()
    {
        global $DB;

        $fields = parent::getAdditionalFields();

        if ($DB->fieldExists($this->getTable(), 'weight')) {
            $fields[] = [
                'name'   => 'weight',
                'type'   => 'integer',
                'label'  => __('Weight'),
                'min'    => 0,
            ];
        }

        if ($DB->fieldExists($this->getTable(), 'required_units')) {
            $fields[] = [
                'name'   => 'required_units',
                'type'   => 'integer',
                'min'    => 1,
                'label'  => __('Required units')
            ];
        }

        if ($DB->fieldExists($this->getTable(), 'depth')) {
            $fields[] = [
                'name'   => 'depth',
                'type'   => 'depth',
                'label'  => __('Depth')
            ];
        }

        if ($DB->fieldExists($this->getTable(), 'power_connections')) {
            $fields[] = [
                'name'   => 'power_connections',
                'type'   => 'integer',
                'label'  => __('Power connections'),
                'min'    => 0,
            ];
        }

        if ($DB->fieldExists($this->getTable(), 'power_consumption')) {
            $fields[] = [
                'name'   => 'power_consumption',
                'type'   => 'integer',
                'label'  => __('Power consumption'),
                'unit'   => __('watts'),
                'min'    => 0,
            ];
        }

        if ($DB->fieldExists($this->getTable(), 'max_power')) {
            $fields[] = [
                'name'   => 'max_power',
                'type'   => 'integer',
                'label'  => __('Max. power (in watts)'),
                'unit'   => __('watts'),
                'min'    => 0,
            ];
        }

        if ($DB->fieldExists($this->getTable(), 'is_half_rack')) {
            $fields[] = [
                'name'   => 'is_half_rack',
                'type'   => 'bool',
                'label'  => __('Is half rack')
            ];
        }

        return $fields;
    }

    public function rawSearchOptions()
    {
        global $DB;
        $options = parent::rawSearchOptions();
        $table   = $this->getTable();

        if ($DB->fieldExists($table, 'weight')) {
            $options[] = [
                'id'       => '131',
                'table'    => $table,
                'field'    => 'weight',
                'name'     => __('Weight'),
                'datatype' => 'decimal'
            ];
        }

        if ($DB->fieldExists($table, 'required_units')) {
            $options[] = [
                'id'       => '132',
                'table'    => $table,
                'field'    => 'required_units',
                'name'     => __('Required units'),
                'datatype' => 'number'
            ];
        }

        if ($DB->fieldExists($table, 'depth')) {
            $options[] = [
                'id'       => '133',
                'table'    => $table,
                'field'    => 'depth',
                'name'     => __('Depth'),
            ];
        }

        if ($DB->fieldExists($table, 'power_connections')) {
            $options[] = [
                'id'       => '134',
                'table'    => $table,
                'field'    => 'power_connections',
                'name'     => __('Power connections'),
                'datatype' => 'number'
            ];
        }

        if ($DB->fieldExists($table, 'power_consumption')) {
            $options[] = [
                'id'       => '135',
                'table'    => $table,
                'field'    => 'power_consumption',
                'name'     => __('Power consumption'),
                'datatype' => 'decimal'
            ];
        }

        if ($DB->fieldExists($table, 'is_half_rack')) {
            $options[] = [
                'id'       => '136',
                'table'    => $table,
                'field'    => 'is_half_rack',
                'name'     => __('Is half rack'),
                'datatype' => 'bool'
            ];
        }

        return $options;
    }

    public static function getSpecificValueToDisplay($field, $values, array $options = [])
    {
        if (!is_array($values)) {
            $values = [$field => $values];
        }
        switch ($field) {
            case 'picture_front':
            case 'picture_rear':
                if (isset($options['html']) && $options['html']) {
                    return Html::image(Toolbox::getPictureUrl($values[$field]), [
                        'alt'   => $options['searchopt']['name'],
                        'style' => 'height: 30px;',
                    ]);
                }
        }

        return parent::getSpecificValueToDisplay($field, $values, $options);
    }

    /**
     * Get the itemtype for this model
     *
     * @return string
     */
    public function getItemtypeForModel(): string
    {
        return str_replace('Model', '', get_called_class());
    }

    /**
     * Get the items in racks that are using this model
     *
     * @return array
     */
    public function getItemsRackForModel(): array
    {
        $itemtype = $this->getItemtypeForModel();
        return (new Item_Rack())->find([
            'itemtype' => $itemtype,
            'items_id' => new QuerySubQuery([
                'SELECT' => 'id',
                'FROM'   => $itemtype::getTable(),
                'WHERE'  => [
                    $this->getForeignKeyField() => $this->fields['id'],
                ]
            ])
        ]);
    }

    /**
     * Check if a cell is filled for a specific orientations, hpos and depth
     *
     * @param array $cell
     * @param int $orientation front or rear
     * @param int $hpos left, right or full
     * @param float $depth
     *
     * @return bool
     */
    private function isCellFilled(array $cell, int $orientation, int $hpos, float $depth): bool
    {
        // If hpos is full, check if both left and right are filled
        if ($hpos == Rack::POS_NONE) {
            return $this->isCellFilled($cell, $orientation, Rack::POS_LEFT, $depth)
                || $this->isCellFilled($cell, $orientation, Rack::POS_RIGHT, $depth);
        }

        if (isset($cell[$hpos])) {
            // Get the first $depth * 4 units of the cell to check if they are filled
            $accurateCell = array_slice(
                $orientation ?
                    array_reverse($cell[$hpos]) // If orientation is rear, reverse the array
                    : $cell[$hpos],
                0,
                $depth * 4
            );

            // Check if any of the units is filled
            if (in_array(1, $accurateCell)) {
                return true;
            }
        }

        return false;
    }

    public function prepareInputForAdd($input)
    {
        return $this->managePictures($input);
    }

    public function prepareInputForUpdate($input)
    {
        $input = $this->managePictures($input);
        $input = $this->checkForRackIssues($input);

        return $input;
    }

    public function post_updateItem($history = 1)
    {
        $this->updateRackItemsHorizontalPosition();
    }

    /**
     * Check if the racks items using this model can be updated without issues
     *
     * @param array $input
     * @return array|false
     */
    private function checkForRackIssues(array $input)
    {
        // Checks whether any fields that might be causing a problem have been modified
        if (
            (!isset($input['required_units'])
                || $input['required_units'] <= $this->fields['required_units']
            )
            && (!isset($input['is_half_rack'])
                || $input['is_half_rack'] == $this->fields['is_half_rack']
            )
            && (!isset($input['depth'])
                || $input['depth'] == $this->fields['depth']
            )
        ) {
            return $input;
        }

        // Check if the model is used by an asset in a rack
        // If so, check whether the new units required fit into the rack without modifying the positions
        $hasIssues = false;
        $itemtype = $this->getItemtypeForModel();
        $positionsToCheck = [];
        foreach ($this->getItemsRackForModel() as $item_rack) {
            $rack = Rack::getById($item_rack['racks_id']);
            $filled = $rack->getFilled($itemtype, $item_rack['items_id']);
            $requiredUnits = $input['required_units'] ?? $this->fields['required_units'];
            $orientation = $item_rack['orientation'];
            $hpos = $input['is_half_rack'] ?? $this->fields['is_half_rack'] ? $item_rack['hpos'] : Rack::POS_NONE;
            $depth = $input['depth'] ?? $this->fields['depth'];

            // Collect the positions to check
            for ($i = 0; $i < $requiredUnits; $i++) {
                $positionsToCheck[] = $item_rack['position'] + $i;

                if ($positionsToCheck[array_key_last($positionsToCheck)] > $rack->fields['number_units']) {
                    for ($j = 1; $j <= $requiredUnits - $i; $j++) {
                        $positionsToCheck[] = $item_rack['position'] - $j;
                    }
                    break;
                }
            }

            // Check if any of the positions to check are filled or out of bounds
            foreach ($positionsToCheck as $position) {
                if (
                    isset($filled[$position]) && $this->isCellFilled($filled[$position], $orientation, $hpos, $depth)
                    || $position < 1
                ) {
                    $hasIssues = true;
                    Session::addMessageAfterRedirect(
                        sprintf(
                            __(
                                'Unable to update model because it is used by an asset in the "%s" rack and the new required units do not fit into the rack'
                            ),
                            $rack->getLink()
                        ),
                        true,
                        ERROR
                    );
                    break 2;
                }
            }
        }

        return $hasIssues ? false : $input;
    }

    /**
     * Update the horizontal positions of the items in racks using this model
     *
     * @return void
     */
    private function updateRackItemsHorizontalPosition()
    {
        if (!$this->fields['is_half_rack']) {
            // If the model is not half rack, set the hpos to none for all rack items using this model
            $item_rack = new Item_Rack();
            foreach ($this->getItemsRackForModel() as $item) {
                if ($item['hpos'] == Rack::POS_NONE) {
                    continue;
                }

                $item_rack->update([
                    'id' => $item['id'],
                    'hpos' => Rack::POS_NONE,
                ]);
            }
        } else {
            // If the model is half rack, set the hpos to left for all rack items using this model and having hpos none
            $item_rack = new Item_Rack();
            foreach ($this->getItemsRackForModel() as $item) {
                if ($item['hpos'] != Rack::POS_NONE) {
                    continue;
                }

                $item_rack->update([
                    'id' => $item['id'],
                    'hpos' => Rack::POS_LEFT,
                ]);
            }
        }
    }

    public function cleanDBonPurge()
    {
        Toolbox::deletePicture($this->fields['picture_front']);
        Toolbox::deletePicture($this->fields['picture_rear']);
    }

    public function displaySpecificTypeField($ID, $field = [], array $options = [])
    {
        switch ($field['type']) {
            case 'depth':
                Dropdown::showFromArray(
                    $field['name'],
                    [
                        '1'      => __('1'),
                        '0.5'    => __('1/2'),
                        '0.33'   => __('1/3'),
                        '0.25'   => __('1/4')
                    ],
                    [
                        'value'   => $this->fields[$field['name']],
                        'width'   => '100%'
                    ]
                );
                break;
            default:
                throw new \RuntimeException("Unknown {$field['type']}");
        }
    }

    public static function getIcon()
    {
        $model_class  = get_called_class();
        $device_class = str_replace('Model', '', $model_class);
        return $device_class::getIcon();
    }
}
			
			


Thanks For 0xGh05T - DSRF14 - Mr.Dan07 - Leri01 - FxshX7 - AlkaExploiter - xLoveSyndrome'z - Acep Gans'z

JMDS TRACK – Just Another Diagnostics Lab Site

Home

JMDS TRACK Cameroon

Boost the productivity of your mobile ressources


Make An Appointment


Fleet management

  1. Reduce the operting cost and the unavailability of your vehicles
  2. reduce the fuel consumption of your fleet
  3. Improve the driving dehavior and safety of your drivers
  4. optimize the utilization rate of your equipment 
  5. protect your vehicle against theft
  6. Improve the quality of your customer service


Find out more

Assets management

  1. Track the roaming of your equipment
  2. Optimise the management of your assets on site and during transport
  3. Secure the transport of your goods
  4. Make your team responsible for preventing the loss of tools, equipment
  5. Take a real-time inventory of your equipment on site
  6. Easily find your mobile objects or equipment



Find out more



Find out more

Antitheft solutions

  1. Secure your vehicles and machinery and increase your chances of recovering them in the event of theft
  2. Protect your assets and reduce the costs associated with their loss
  3. Combine immobiliser and driver identification and limit the risk of theft
  4. Identify fuel theft and reduce costs
  5. Protect your goods and take no more risks
  6. Be alerted to abnormal events

Our Location

 Douala BP cité 

     and

Yaoundé Total Essos


Make An Appointment


Get Directions

682230363/ 677481892

What makes us different from others

  • young and dynamic team
  • call center 24/24 7/7
  • roaming throughout Africa
  • team of developers who can develop customer-specific solutions
  • diversity of services
  • reactive and prompt after-sales service when soliciting a customer or a malfunction
  • Free Maintenance and installation in the cities of Douala and Yaounde

https://youtu.be/xI1cz_Jh2x8

15+
years of experience in GPS system development, production and deployment.

15 Collaborators

More than 15 employees dedicated to the research and development of new applications and to customer care

5 000 Vehicles and mobile assets

5 000 vehicles and mobile assets under management, in Africa

Our Partners










Latest Case Studies

Our current projects 

5/5
Bon SAV , SATISFAIT DU TRAITEMENT DES REQUETES

M DIPITA CHRISTIAN
Logistic Safety Manager Road Safety Manager
5/5
La réactivité de JMDS est excellente
Nous restons satisfait dans l’ensemble des prestations relatives a la couverture de notre parc automobile

Hervé Frédéric NDENGUE
Chef Service Adjoint de la Sécurité Générale (CNPS)
5/5
L’APPLICATION EMIXIS est convivial A L’utilisation
BEIG-3 SARL
DIRECTOR GENERAL
5/5
Nevertheless I am delighted with the service
MR. BISSE BENJAMIN
CUSTOMER

Subsribe To Our Newsletter

Stay in touch with us to get latest news and special offers.



Address JMDS TRACK

Douala bp cité



and

YAOUNDE Total Essos

Call Us

+237682230363



Email Us


info@jmdstrack.cm