diff --git a/plugins/admin/systems/class_glpiManufacturer.inc b/plugins/admin/systems/class_glpiManufacturer.inc
index aeedaa4d2ddc07d2098f576214f4c810be8b8359..e0a9cfa9a2e3d584908dbfc00609ed0ffdb0a392 100644 (file)
class glpiManufacturer extends plugin
{
class glpiManufacturer extends plugin
{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* attribute list for save action */
var $ignore_account= TRUE;
var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email");
/* attribute list for save action */
var $ignore_account= TRUE;
var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email");
var $email ="";
var $ID =-1;
var $email ="";
var $ID =-1;
- function glpiManufacturer($config, $dn= NULL)
+ function glpiManufacturer($config, $dn= NULL, $parent= NULL)
{
{
- plugin::plugin ($config, $dn);
+ plugin::plugin ($config, $dn, $parent);
$this->ui = get_userinfo();
}
function execute()
{
$this->ui = get_userinfo();
}
function execute()
{
+ plugin::execute();
$smarty = get_smarty();
$display = "";
$smarty = get_smarty();
$display = "";
+ /* Remove enterprise from db */
if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
- $this->parent->handle->removeEnterprisesType($_POST['manufacturer']);
+
+ $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']);
+ if(count($tmp)){
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names));
+ }else{
+ $this->parent->handle->removeEnterprise($_POST['manufacturer']);
+ }
}
}
+ /* Add new Manufactuer : Open dialog with empty fields */
if(isset($_POST['add_manu'])){
$this->editMode = true;
$this->Edit_Add = "add";
if(isset($_POST['add_manu'])){
$this->editMode = true;
$this->Edit_Add = "add";
}
}
}
}
+ /* Edit existing manuatctuerer data */
if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
$this->editMode = true;
$this->Edit_Add = "edit";
if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
$this->editMode = true;
$this->Edit_Add = "edit";
$this->ID = $_POST['manufacturer'];
}
$this->ID = $_POST['manufacturer'];
}
+ /* close Dialog without saving */
if(isset($_POST['close_manufacturer'])){
$this->editMode=false;
}
if(isset($_POST['close_manufacturer'])){
$this->editMode=false;
}
+ /* close dialog an save all changes / adds */
if(isset($_POST['save_manufacturer'])){
if(isset($_POST['save_manufacturer'])){
-
$tmp = array();
foreach($this->attributes as $attrs){
$tmp[$attrs]=$this->$attrs;
$tmp = array();
foreach($this->attributes as $attrs){
$tmp[$attrs]=$this->$attrs;
$allok = false;
}
$allok = false;
}
+ $attr = $this->parent->handle->getEnterprises();
+
+ if($this->ID == -1 ){
+ if(in_array($tmp['name'],$attr)){
+ $allok = false;
+ print_red(_("Specified name is already in use, please choose another one."));
+ }
+ }else{
+ unset($attr[$this->ID]);
+ if(in_array($tmp['name'],$attr)){
+ $allok = false;
+ print_red(_("Specified name is already in use, please choose another one."));
+ }
+ }
+
+ /* all checks are ok , so save changes */
if($allok){
if($this->Edit_Add == "add"){
if($allok){
if($this->Edit_Add == "add"){
- $this->parent->handle->addEnterprisesType($tmp);
+ $this->parent->handle->addEnterprise($tmp);
$this->editMode=false;
}else{
$this->editMode=false;
}else{
- $this->parent->handle->updateEnterprisesType($tmp,$this->ID);
+ $this->parent->handle->updateEnterprise($tmp,$this->ID);
$this->editMode=false;
}
}
}
$this->editMode=false;
}
}
}
+ /* As long as this war is true, we have to display the edit dialog */
if($this->editMode == true){
$this->save_object();
foreach($this->attributes as $attrs){
if($this->editMode == true){
$this->save_object();
foreach($this->attributes as $attrs){
}
}
- $smarty->assign("Manus", $this->parent->handle->getEnterprisesTypes());
- $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprisesTypes()));
+ $smarty->assign("Manus", $this->parent->handle->getEnterprises());
+ $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises()));
$display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
return($display);
}
$display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
return($display);
}
{
foreach($this->attributes as $attr){
if(isset($_POST[$attr])){
{
foreach($this->attributes as $attr){
if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
+ $this->$attr = stripslashes($_POST[$attr]);
}
}
}
}
}
}