Html::createProgressBar PHP Method

createProgressBar() static public method

Create a Dynamic Progress Bar
static public createProgressBar ( $msg = " " ) : nothing
$msg initial message (under the bar) (default ' ')
return nothing
    static function createProgressBar($msg = " ")
    {
        $options = array('create' => true);
        if ($msg != " ") {
            $options['message'] = $msg;
        }
        self::progressBar('doaction_progress', $options);
    }

Usage Example

 static function uninstall($type, $model_id, $tab_ids, $location)
 {
     global $UNINSTALL_DIRECT_CONNECTIONS_TYPE;
     //Get the model
     $model = new PluginUninstallModel();
     $model->getConfig($model_id);
     //Then destroy all the connexions
     $transfer = new Transfer();
     $transfer->getFromDB($model->fields["transfers_id"]);
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'><tr><th>" . __('Uninstall', 'uninstall') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>";
     $count = 0;
     $tot = count($tab_ids[$type]);
     Html::createProgressBar(__('Please wait, uninstallation is running...', 'uninstall'));
     foreach ($tab_ids[$type] as $id => $value) {
         $count++;
         $item = new $type();
         $item->getFromDB($id);
         //First clean object and change location and status if needed
         $entity = $item->fields["entities_id"];
         $input = array();
         $input["id"] = $id;
         $input["entities_id"] = $entity;
         $fields = array();
         //Hook to perform actions before item is being uninstalled
         $item->fields['_uninstall_event'] = $model->getID();
         $item->fields['_action'] = 'uninstall';
         Plugin::doHook("plugin_uninstall_before", $item);
         //--------------------//
         //Direct connections //
         //------------------//
         if (in_array($type, $UNINSTALL_DIRECT_CONNECTIONS_TYPE)) {
             $conn = new Computer_Item();
             $conn->deleteByCriteria(array('computers_id' => $id), true);
         }
         //--------------------//
         //-- Common fields --//
         //------------------//
         //RAZ contact and contactnumber
         if ($item->isField('contact') && $model->fields["raz_contact"] == 1) {
             $fields["contact"] = '';
             if ($item->isField('contact_num')) {
                 $fields["contact_num"] = '';
             }
         }
         //RAZ user
         if ($model->fields["raz_user"] == 1 && $item->isField('users_id')) {
             $fields["users_id"] = 0;
         }
         //RAZ status
         if ($model->fields["states_id"] > 0 && $item->isField('states_id')) {
             $fields["states_id"] = $model->fields["states_id"];
         }
         //RAZ machine's name
         if ($item->isField('name') && $model->fields["raz_name"] == 1) {
             $fields["name"] = '';
         }
         if ($item->isField('locations_id')) {
             if ($location == '') {
                 $location = 0;
             }
             switch ($location) {
                 case -1:
                     break;
                 default:
                     $fields["locations_id"] = $location;
                     break;
             }
         }
         if ($item->isField('groups_id')) {
             $nbgroup = countElementsInTableForEntity("glpi_groups", $entity, "`id`='" . $item->fields['groups_id'] . "'");
             if ($model->fields["groups_id"] > -1 && $nbgroup == 1) {
                 // If a new group is defined and if the group is accessible in the object's entity
                 $fields["groups_id"] = $model->fields["groups_id"];
             }
         }
         //------------------------------//
         //-- Computer specific fields --//
         //------------------------------//
         if ($type == 'Computer') {
             //RAZ all OS related informations
             if ($model->fields["raz_os"] == 1) {
                 $fields["operatingsystems_id"] = 0;
                 $fields["operatingsystemversions_id"] = 0;
                 $fields["operatingsystemservicepacks_id"] = 0;
                 $fields["os_licenseid"] = '';
                 $fields["os_license_number"] = '';
                 $fields["autoupdatesystems_id"] = 0;
             }
             $plug = new Plugin();
             if ($plug->isActivated('ocsinventoryng')) {
                 if ($item->fields["is_dynamic"] && ($model->fields["remove_from_ocs"] || $model->fields["delete_ocs_link"])) {
                     $input["is_dynamic"] = 0;
                 }
             }
             if ($item->isField('domains_id') && $model->fields["raz_domain"]) {
                 $fields["domains_id"] = 0;
             }
             //RAZ network
             if ($item->isField('networks_id') && $model->fields["raz_network"] == 1) {
                 $fields["networks_id"] = 0;
             }
         }
         //RAZ IPs from all the network cards
         if ($model->fields["raz_ip"] == 1) {
             self::razPortInfos($type, $id);
             // For NetworkEquiment
             if ($item->isField('ip')) {
                 $fields['ip'] = '';
             }
             if ($item->isField('mac')) {
                 $fields['mac'] = '';
             }
         }
         foreach ($fields as $name => $value) {
             if (!($item->getField($name) != NOT_AVAILABLE) || $item->getField($name) != $value) {
                 $input[$name] = $value;
             }
         }
         $item->dohistory = true;
         $item->update($input);
         if ($model->fields["raz_budget"] == 1) {
             $infocom_id = self::getInfocomPresentForDevice($type, $id);
             if ($infocom_id > 0) {
                 $infocom = new InfoCom();
                 $tmp["id"] = $infocom_id;
                 $tmp["budgets_id"] = 0;
                 $infocom->dohistory = false;
                 $infocom->update($tmp);
             }
         }
         //Delete machine from glpi_ocs_link
         if ($type == 'Computer') {
             //Delete computer's volumes
             self::purgeComputerVolumes($id);
             if ($model->fields["raz_history"] == 1) {
                 //Delete history related to software
                 self::deleteHistory($id, false);
             } else {
                 if ($model->fields["raz_soft_history"] == 1) {
                     //Delete history related to software
                     self::deleteHistory($id, true);
                 }
             }
             $plug = new Plugin();
             if ($plug->isActivated('ocsinventoryng')) {
                 //Delete computer from OCS
                 if ($model->fields["remove_from_ocs"] == 1) {
                     self::deleteComputerInOCSByGlpiID($id);
                 }
                 //Delete link in glpi_ocs_link
                 if ($model->fields["delete_ocs_link"] || $model->fields["remove_from_ocs"]) {
                     self::deleteOcsLink($id);
                 }
             }
             //Should never happend that transfer_id = 0, but just in case
             if ($model->fields["transfers_id"] > 0) {
                 $transfer->moveItems(array($type => array($id => $id)), $entity, $transfer->fields);
             }
         }
         if ($model->fields['raz_fusioninventory'] == 1) {
             self::deleteFusionInventoryLink($type, $id);
         }
         //Plugin hook after uninstall
         Plugin::doHook("plugin_uninstall_after", $item);
         Html::changeProgressBarPosition($count, $tot + 1);
     }
     //Add line in machine's history to say that machine was uninstalled
     self::addUninstallLog($type, $id);
     Html::changeProgressBarPosition($count, $tot, __('Uninstallation successful', 'uninstall'));
     echo "</td></tr>";
     echo "</table></div>";
 }
All Usage Examples Of Html::createProgressBar
Html