function _inventory_baseEdit($FH, $mode) { $username = $FH->getArrayOrPostValue("uid"); $d = new DivForModule(_T("Entity right", "inventory"), "#DDF"); $entities = getLocationAll(['min' => 0, 'filters' => array()]); $default_user_locations = array("1"); $f = new Table(); $d->push($f); if ($mode == 'edit') { $user_locations = getLocationsForUser($username); if (!count($user_locations)) { $user_locations = $default_user_locations; } } else { $user_locations = $default_user_locations; } $entities_select = new SelectItem("entitie[]"); $entity_val = array(); $entity_list = array(); foreach ($entities['data'] as $entity) { $entity_list[$entity['id']] = $entity['Labelval']; $entity_val[$entity['id']] = $entity['id']; } $entities_select->setElements($entity_list); $entities_select->setElementsVal($entity_val); $entity_valT = array(); foreach ($user_locations as $attr) { $fields = array($entities_select, new inventorybuttonTpl2('removeLine', _T('Remove', 'inventory'), 'removeLine', _T('Remove entity for user', 'inventory') . " : [" . $username . "]")); $values = array(strval($attr), ''); $f->add(new TrFormElement(_T('Entity right', 'inventory'), new multifieldTpl($fields)), array("value" => $values, "required" => True)); } // Add line button $addEntityRightBtn = new inventorybuttonTpl2('addLine', _T('Add entity right', 'inventory'), '', _T('Add entity right for user', 'inventory') . " : [" . $username . "]"); $addEntityRightBtn->setClass('btnPrimary'); $f->add(new TrFormElement('', $addEntityRightBtn), array()); print <<<EOF <script type="text/javascript"> jQuery(function(){ modelLine = jQuery('.removeLine:first').parents('tr:first').clone(); // Remove line button jQuery('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); else jQuery('#entitie option[value="1"]').prop('selected', true); }); // Add line button jQuery('#addLine').click(function(){ var newline = modelLine.clone().insertBefore(jQuery(this).parents('tr:first')); newline.find('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); }); }); }); </script> EOF; return $d; }
* * MMC 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 MMC; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once "modules/inventory/includes/xmlrpc.php"; require_once "modules/inventory/includes/addentityrule.inc.php"; require "modules/base/computers/localSidebar.php"; require "graph/navbar.inc.php"; $params1 = array('min' => 0, 'filters' => array()); $entity = getLocationAll($params1); function locationtoid($entity, $valeur) { foreach ($entity['data'] as $val) { if ($val['Label'] == $valeur) { return $val['id']; } } } $entityroot = $entity['data'][0]['Label']; $entityidroot = 1; //echo $entityroot; $operatorType = operatorTagAll(); if (isset($_GET["start"])) { $start = $_GET["start"]; } else {
*/ require_once "modules/inventory/includes/xmlrpc.php"; require_once "modules/update/includes/utils.inc.php"; echo "<br/><br/>"; global $conf; $maxperpage = $conf["global"]["maxperpage"]; if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } $params = array('min' => $start, 'max' => $start + $maxperpage, 'filters' => ''); if (isset($_GET["filter"]) && $_GET["filter"]) { $params['filters'] = $_GET["filter"]; } extract(getLocationAll($params)); // Listinfo params $listinfoParams = array(); foreach ($data as $key => $row) { $listinfoParams[] = array('id' => $row['id'], 'Label' => $row['Label'], 'Labelval' => $row['Labelval'], 'parentId' => $row['parentId']); } if (!$count || $count <= 0) { print _T('No entry found', 'inventory'); return; } $cols = listInfoFriendly($data); $n = new OptimizedListInfos($cols['Labelval'], _T('Entity name', 'inventory'), ''); $n->first_elt_padding = '0'; $n->setParamInfo($listinfoParams); $n->setItemCount($count); $n->setNavBar(new AjaxNavBar($count, $status));
require "modules/base/computers/localSidebar.php"; require "graph/navbar.inc.php"; $params = array('min' => 0, 'filters' => array()); //Receiving form data if (isset($_POST['name'], $_POST['parent'])) { //Le champ name ne doit pas contenir d'espaces ni de virgules ni de slash (/) '^[a-zA-Z0-9]{3,64}$' createLocation($_POST['name'], $_POST['parent']); if (!isXMLRPCError()) { header('location: main.php?module=base&submod=computers&action=entityList&filter=' . $_POST['name']); } } $p = new PageGenerator(_T("Add entity", 'inventory')); $p->setSideMenu($sidemenu); $p->display(); $f = new ValidatingForm(); $f->push(new Table()); $f->add(new TrFormElement(_T('Name', 'inventory'), new InputTpl('name')), array("value" => $profile['profilename'], "required" => True)); $entities_select = new SelectItem("parent"); $entities = getLocationAll($params); $entity_val = array(); $entity_list = array(); foreach ($entities['data'] as $entity) { $entity_list[$entity['id']] = $entity['Labelval']; $entity_val[$entity['id']] = $entity['id']; } $entities_select->setElements($entity_list); $entities_select->setElementsVal($entity_val); $f->add(new TrFormElement(_T('Parent entity', 'inventory'), $entities_select), array("value" => 1, "required" => True)); $f->pop(); $f->addValidateButton("bconfirm"); $f->display();