Example #1
1
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Modelo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Modelo'])) {
         $model->attributes = $_POST['Modelo'];
         if ($model->save()) {
             if (!empty($_POST['yt1'])) {
                 Yii::app()->user->setFlash('modelo-created', "¡El modelo <b><i>&quot;{$model->name}&quot;</i></b> fue creado exitosamente!");
                 //$this->redirect(array('create'));
                 $modelSaved = $model;
                 $model = new Modelo();
                 $model->equipment_type_id = $modelSaved->equipment_type_id;
                 $model->brand_id = $modelSaved->brand_id;
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     if (EquipmentType::model()->count('active = 1') == 0 && Brand::model()->count('active = 1') == 0) {
         throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . ' y ' . CHtml::link('crear una Marca', array('brand/create')) . '.');
     } else {
         if (EquipmentType::model()->count('active = 1') == 0) {
             throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . '.');
         } else {
             if (Brand::model()->count('active = 1') == 0) {
                 throw new CHttpException('', 'Primero debe ' . CHtml::link('crear una Marca', array('brand/create')) . '.');
             } else {
                 $this->render('create', array('model' => $model));
             }
         }
     }
 }
 /**
  * @throws EquipmentTypeIDMissingException
  */
 public static function change_location()
 {
     if ($_GET['id']) {
         if ($_GET['nextpage'] == 1) {
             $page_1_passed = true;
         } else {
             $page_1_passed = false;
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("equipment/admin/equipment_type/change_location.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             $location_array = Location::list_entries();
             $result = array();
             $counter = 1;
             $location = new Location($value);
             $result[0]['value'] = 0;
             $result[0]['content'] = "none";
             foreach ($location_array as $key => $value) {
                 $location = new Location($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $location->get_name(true);
                 $counter++;
             }
             $template->set_var("option", $result);
             $template->output();
         } else {
             $equipment_type = new EquipmentType($_GET['id']);
             $paramquery = $_GET;
             $paramquery['action'] = "detail";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             if ($equipment_type->set_location_id($_POST['location'])) {
                 Common_IO::step_proceed($params, "Equipment Type", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Equipment Type", "Operation Failed", null);
             }
         }
     } else {
         throw new EquipmentTypeIDMissingException();
     }
 }
Example #3
0
echo $form->labelEx($model, 'service_type_id');
?>
		<?php 
echo $form->dropDownList($model, 'service_type_id', CHtml::listData(ServiceType::model()->findAll(array('condition' => 'active = 1', 'order' => 'name')), 'id', 'name'), array('prompt' => 'Seleccionar'));
?>
		<?php 
echo $form->error($model, 'service_type_id');
?>
	</div>

        <div class="row">
		<?php 
echo $form->labelEx($model, 'equipment_type_id');
?>
		<?php 
echo $form->dropDownList($model, 'equipment_type_id', CHtml::listData(EquipmentType::model()->findAll(array('condition' => 'active=1')), 'id', 'type'), array('prompt' => 'Seleccionar'));
?>
		<?php 
echo $form->error($model, 'service_type_id');
?>
	</div>

        
	<div class="row">
		<?php 
echo $form->labelEx($model, 'activity');
?>
		<?php 
echo $form->textField($model, 'activity', array('size' => 60, 'maxlength' => 100));
?>
		<?php 
Example #4
0
 /**
  * @see ItemListenerInterface::get_item_object_name()
  * @return string
  */
 public final function get_item_object_name()
 {
     if ($this->equipment_id and $this->equipment) {
         $equipment_type = new EquipmentType($this->equipment->get_type_id());
         return $equipment_type->get_name();
     } else {
         return null;
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = EquipmentType::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #6
0
//						$("#Order_contact_id").children().remove();
//						$("#Order_contact_id").append( new Option("Seleccionar"));
//						$("#Order_payment_type_id > option[value=]").attr("selected","selected");
					}')));
?>
		<?php 
echo $form->error($model, 'payment_type_id');
?>
	</div>
	
	<div class="row">
		<?php 
echo $form->labelEx($model, 'equipment_type_id');
?>
		<?php 
echo $form->dropDownList($model, 'equipment_type_id', CHtml::listData(EquipmentType::model()->findAll(array('condition' => 'active=1', 'order' => 'type')), 'id', 'type'), array('prompt' => 'Seleccionar', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('order/brandsFromEquipment'), 'data' => array('Order[equipment_type_id]' => 'js:this.value'), 'success' => 'js:function(dataType){
						jsonObject = JSON.parse(dataType);
						
						$("#Order_brand_id").children().remove();
						$("#Order_brand_id").append( new Option("Seleccionar", 0));
                                                        
						for(i=0; i< jsonObject.brands_options.length; i++){
							$("#Order_brand_id").append( new Option(
								jsonObject.brands_options[i].name,
								jsonObject.brands_options[i].id
							));
						}
						
						$("#Order_model_id").children().remove();
						$("#Order_model_id").append( new Option("Seleccionar", 0));
						
Example #7
0
 /**
  * @param string $get_array
  * @param string $type_array
  * @param string $category_array
  * @return string
  */
 public static function add_as_item_window($get_array, $type_array, $category_array)
 {
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($type_array) {
         $type_array = unserialize($type_array);
     }
     if ($category_array) {
         $category_array = unserialize($category_array);
     }
     $template = new HTMLTemplate("equipment/add_item_window.html");
     $equipment_array = EquipmentType::list_entries();
     $result = array();
     $hit_array = array();
     $counter = 0;
     if (is_array($type_array) and count($type_array) >= 1) {
         if (is_array($equipment_array) and count($equipment_array) >= 1) {
             foreach ($equipment_array as $key => $value) {
                 if (in_array($value, $type_array) or $value <= 3) {
                     $equipment_type = new EquipmentType($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['disabled'] = "";
                     $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")";
                     $counter++;
                     array_push($hit_array, $value);
                 }
             }
         }
         if (is_array($category_array) and count($category_array) >= 1) {
             foreach ($category_array as $key => $value) {
                 $equipment_cat_array = EquipmentType::list_entries_by_cat_id($value);
                 if (is_array($equipment_cat_array) and count($equipment_cat_array) >= 1) {
                     foreach ($equipment_cat_array as $key => $value) {
                         if (!in_array($value, $hit_array)) {
                             $equipment_type = new EquipmentType($value);
                             $result[$counter]['value'] = $value;
                             $result[$counter]['disabled'] = "";
                             $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")";
                             $counter++;
                             array_push($hit_array, $value);
                         }
                     }
                 }
             }
         }
     } else {
         if (is_array($category_array) and count($category_array) >= 1) {
             foreach ($category_array as $key => $value) {
                 $equipment_cat_array = EquipmentType::list_entries_by_cat_id($value);
                 if (is_array($equipment_cat_array) and count($equipment_cat_array) >= 1) {
                     if (!in_array(1, $equipment_cat_array)) {
                         $equipment_cat_array[] = 1;
                     }
                     if (!in_array(2, $equipment_cat_array)) {
                         $equipment_cat_array[] = 2;
                     }
                     if (!in_array(3, $equipment_cat_array)) {
                         $equipment_cat_array[] = 3;
                     }
                     foreach ($equipment_cat_array as $key => $value) {
                         if (!in_array($value, $hit_array)) {
                             $equipment_type = new EquipmentType($value);
                             $result[$counter]['value'] = $value;
                             $result[$counter]['disabled'] = "";
                             $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")";
                             $counter++;
                             array_push($hit_array, $value);
                         }
                     }
                 }
             }
         } else {
             if (is_array($equipment_array) and count($equipment_array) >= 1) {
                 foreach ($equipment_array as $key => $value) {
                     $equipment_type = new EquipmentType($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['disabled'] = "";
                     $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")";
                     $counter++;
                 }
             }
         }
     }
     if ($counter == 0) {
         $result[0]['value'] = "0";
         $result[0]['disabled'] = "disabled='disabled'";
         $result[0]['content'] = "NO EQUIPMENT FOUND!";
     }
     $template->set_var("select", $result);
     if ($_GET['parent'] and is_numeric($_GET['parent_id'])) {
         $array['container'] = "#EquipmentItemAddWindow" . $_GET['parent_key'] . "-" . $_GET['parent_id'] . "-" . $_GET['key'];
         $container_value_select = "EquipmentItemAddValueField" . $_GET['parent_key'] . "-" . $_GET['parent_id'] . "-" . $_GET['key'];
     } else {
         $array['container'] = "#EquipmentItemAddWindow" . $_GET['key'];
         $container_value_select = "EquipmentItemAddValueField" . $_GET['key'];
     }
     $template->set_var("container_value_select_id", $container_value_select);
     $array['continue_caption'] = "Add";
     $array['cancel_caption'] = "Cancel";
     $array['content_caption'] = "Add Equipment";
     $array['height'] = 350;
     $array['width'] = 400;
     $array['content'] = $template->get_string();
     $continue_handler_template = new JSTemplate("equipment/js/add_item_window.js");
     $continue_handler_template->set_var("session_id", $_GET['session_id']);
     $continue_handler_template->set_var("get_array", $get_array);
     $continue_handler_template->set_var("container_id", $array['container']);
     $continue_handler_template->set_var("container_value_select_id", $container_value_select);
     $array['continue_handler'] = $continue_handler_template->get_string();
     return json_encode($array);
 }
Example #8
0
 /**
  * @throws EquipmentTypeIDMissingException
  */
 public static function type_detail($type_id, $owner_id)
 {
     if (is_numeric($type_id)) {
         $equipment_type = new EquipmentType($type_id);
         $equipment_owner = new User($owner_id);
         $template = new HTMLTemplate("equipment/detail.html");
         $template->set_var("name", $equipment_type->get_name());
         $template->set_var("category", $equipment_type->get_cat_name());
         if ($equipment_type->get_location_id() == null) {
             $template->set_var("location", "<span class='italic'>none</span>");
         } else {
             $location = new Location($equipment_type->get_location_id());
             $template->set_var("location", $location->get_name(true));
         }
         $template->set_var("owner", $equipment_owner->get_full_name(false));
         if ($equipment_type->get_description()) {
             $template->set_var("description", $equipment_type->get_description());
         } else {
             $template->set_var("description", "<span class='italic'>none</span>");
         }
         $user_array = $equipment_type->list_users();
         $user_content_array = array();
         $counter = 0;
         if (is_array($user_array) and count($user_array) >= 1) {
             foreach ($user_array as $key => $value) {
                 $user = new User($value);
                 $user_content_array[$counter]['username'] = $user->get_username();
                 $user_content_array[$counter]['fullname'] = $user->get_full_name(false);
                 $counter++;
             }
             $template->set_var("no_user", false);
         } else {
             $template->set_var("no_user", true);
         }
         $template->set_var("user", $user_content_array);
         $ou_array = $equipment_type->list_organisation_units();
         $ou_content_array = array();
         $counter = 0;
         if (is_array($ou_array) and count($ou_array) >= 1) {
             foreach ($ou_array as $key => $value) {
                 $organisation_unit = new OrganisationUnit($value);
                 $ou_content_array[$counter]['name'] = $organisation_unit->get_name();
                 $counter++;
             }
             $template->set_var("no_ou", false);
         } else {
             $template->set_var("no_ou", true);
         }
         $template->set_var("ou", $ou_content_array);
         $template->output();
     } else {
         throw new EquipmentTypeIDMissingException();
     }
 }
Example #9
0
 /**
  * @see EquipmentCatInterface::delete()
  * @return bool
  */
 public function delete()
 {
     if ($this->equipment_cat_id and $this->equipment_cat) {
         if ($this->get_children() != null) {
             return false;
         } else {
             $equipment_type_array = EquipmentType::list_entries_by_cat_id($this->equipment_cat_id);
             if (!is_array($equipment_type_array)) {
                 return $this->equipment_cat->delete();
             } else {
                 if (count($equipment_type_array) == 0) {
                     return $this->equipment_cat->delete();
                 } else {
                     return false;
                 }
             }
         }
     } else {
         return false;
     }
 }
Example #10
0
 /**
  * Datos relevantes para el equipo entrante.
  */
 public function getTipoEquipo()
 {
     return $ModelEquipos = EquipmentType::model()->findAll('active = 1');
 }
Example #11
0
<?php

$this->breadcrumbs = array('Tipos de equipo' => array('index'), $model->type);
$this->menu = array(array('label' => 'Listar tipos de equipo', 'url' => array('index')), array('label' => 'Crear tipo de equipo', 'url' => array('create')), array('label' => 'Actualizar tipo de equipo', 'url' => array('update', 'id' => $model->id)), array('label' => 'Desactivar tipo de equipo', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => '¿Esta seguro que desea eliminar este elemento?'), 'visible' => $model->active == 1), array('label' => 'Activar tipo de equipo', 'url' => '#', 'linkOptions' => array('submit' => array('activate', 'id' => $model->id), 'confirm' => '¿Esta seguro que desea activar este elemento?'), 'visible' => $model->active == 0), array('label' => 'Administrar tipos de equipo', 'url' => array('admin')));
?>

<h1>Tipo de equipo: <?php 
echo $model->type;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'type', array('name' => 'Activo', 'type' => 'raw', 'value' => EquipmentType::getActive($model->active)))));