Menu

Modify file not reflect any change on server

2013-12-06
2013-12-06
  • Pankaj khurana

    Pankaj khurana - 2013-12-06

    Hello Sir,

    I have made some modification in /var/WWW/web/env-production/model.itop-incident.mgmt-itil.php changes done in file show reflects in local linux or in window but when module goes to server then it does not show reflect modification.please help me to shot out problem...

    Thanks & regards
    Pankaj

    File code:-

    <?php
    //
    // File generated by ... on the 2013-05-30T08:05:23+0200
    // Please do not edit manually
    //

    /*
    * Classes and menus for itop-incident-mgmt-itil (version 2.0.0)
    * * @author iTop compiler
    * @license http://opensource.org/licenses/AGPL-3.0
    /

    /*
    * Persistent classes for a CMDB
    * * @copyright Copyright (C) 2010-2012 Combodo SARL
    * @license http://opensource.org/licenses/AGPL-3.0
    /
    class Incident extends Ticket
    {
    public static function Init()
    {
    $aParams = array
    (
    'category' => 'bizmodel,searchable,requestmgmt',
    'key_type' => 'autoincrement',
    'name_attcode' => 'ref',
    'state_attcode' => 'status',
    'reconc_keys' => array('ref'),
    'db_table' => 'ticket_incident',
    'db_key_field' => 'id',
    'db_finalclass_field' => '',
    'icon' => utils::GetAbsoluteUrlModulesRoot().'itop-incident-mgmt-itil/images/incident.png',
    'order_by_default' => array('ref' => false),
    );
    include('../conf/production/config-itop.php');

    $username=$MySettings['db_user'];
    $password=$MySettings['db_pwd'];
    $db_name=$MySettings['db_name'];
    $con=mysqli_connect("localhost",$username,$password,$db_name) or die();
    if(isset($_SESSION['auth_user']))
    {
    $name=$_SESSION['auth_user'];
    }

        MetaModel::Init_Params($aParams);
    
        MetaModel::Init_InheritAttributes();
           $sStimulus = utils::ReadParam('stimulus', '');
    

    $operation = utils::ReadParam('operation', '');
    $sclass = utils::ReadParam('class', '');

    // $class = utils::ReadParam('class', '');
    // echo"ccccccccccccccccc". $class;
    if($sclass =="UserRequest")
    {
    $classtable= "ticket_request";
    }
    elseif ($sclass =="Incident")
    {
    $classtable= "ticket_incident";
    }

    $row2=array();
    $row1=array();
    $ids = utils::ReadParam('id', '');
    //echo"Service id".$ids;
    $a_ss='none';
    if(($sStimulus=='ev_assign'))
    {
    if(($ids) && isset($classtable) )
    {
    $resn=mysqli_query($con,"SELECT service_id from $classtable where id=$ids");
    $rown = mysqli_fetch_array($resn);
    // $a_ss1=$rown[0];
    // echo "Service id".$a_ss1;
    $resn1=mysqli_query($con,"SELECT auto_assignement from service where id=$rown[0]");
    $rown1 = mysqli_fetch_array($resn1);
    $a_ss=$rown1[0];
    // echo"Auto Assignment".$a_ss;
    / if($con)
    {
    echo "I am here";
    }else
    {
    echo"i am not here";
    }
    /
    }
    }
    /
    if(isset($a_ss))
    {
    echo"pppppppppppppppppppppppppppppppppppppppppppppppppppppp". $a_ss ;
    }
    /
    MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum("new,assigned,pending,escalated_tto,escalated_ttr,resolved,closed"), "display_style"=>'list', "sql"=>'status', "default_value"=>'new', "is_null_allowed"=>false, "depends_on"=>array())));
    MetaModel::Init_AddAttribute(new AttributeEnum("impact", array("allowed_values"=>new ValueSetEnum("1,2,3"), "display_style"=>'list', "sql"=>'impact', "default_value"=>'1', "is_null_allowed"=>false, "depends_on"=>array())));
    MetaModel::Init_AddAttribute(new AttributeEnum("priority", array("allowed_values"=>new ValueSetEnum("1,2,3,4"), "display_style"=>'list', "sql"=>'priority', "default_value"=>'4', "is_null_allowed"=>false, "depends_on"=>array())));
    MetaModel::Init_AddAttribute(new AttributeEnum("urgency", array("allowed_values"=>new ValueSetEnum("1,2,3,4"), "display_style"=>'list', "sql"=>'urgency', "default_value"=>'4', "is_null_allowed"=>false, "depends_on"=>array())));
    MetaModel::Init_AddAttribute(new AttributeEnum("origin", array("allowed_values"=>new ValueSetEnum("mail,phone,portal,monitoring"), "display_style"=>'list', "sql"=>'origin', "default_value"=>'phone', "is_null_allowed"=>true, "depends_on"=>array())));

    //MetaModel::Init_AddAttribute(new AttributeExternalKey("approver_id", array("targetclass"=>'Person', "allowed_values"=>new ValueSetObjects("SELECT Person AS p JOIN lnkApprovalToTicket AS l1 ON l1.contact_id=p.id WHERE l1.ticket_id = :this->id"), "sql"=>'approver_id', "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('org_id'))));
    // MetaModel::Init_AddAttribute(new AttributeExternalField("approver_email", array("allowed_values"=>null, "extkey_attcode"=>'approver_id', "target_attcode"=>'email')));

        MetaModel::Init_AddAttribute(new AttributeExternalKey("service_id", array("targetclass"=>'Service', "allowed_values"=>new ValueSetObjects("SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :this->org_id"), "sql"=>'service_id', "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('org_id'))));
        MetaModel::Init_AddAttribute(new AttributeExternalField("service_name", array("allowed_values"=>null, "extkey_attcode"=>'service_id', "target_attcode"=>'name')));
        MetaModel::Init_AddAttribute(new AttributeExternalKey("servicesubcategory_id", array("targetclass"=>'ServiceSubcategory', "allowed_values"=>new ValueSetObjects("SELECT ServiceSubcategory WHERE service_id = :this->service_id AND request_type = 'incident'"), "sql"=>'servicesubcategory_id', "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('service_id'))));
        MetaModel::Init_AddAttribute(new AttributeExternalField("servicesubcategory_name", array("allowed_values"=>null, "extkey_attcode"=>'servicesubcategory_id', "target_attcode"=>'name')));
    
    
        MetaModel::Init_AddAttribute(new AttributeEnum("escalation_flag", array("allowed_values"=>new ValueSetEnum("yes,no"), "display_style"=>'list', "sql"=>'escalation_flag', "default_value"=>'no', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeString("escalation_reason", array("allowed_values"=>null, "sql"=>'escalation_reason', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeDateTime("assignment_date", array("allowed_values"=>null, "sql"=>'assignment_date', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeDateTime("resolution_date", array("allowed_values"=>null, "sql"=>'resolution_date', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeDateTime("last_pending_date", array("allowed_values"=>null, "sql"=>'last_pending_date', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeStopWatch("cumulatedpending", array("states"=>array("pending"), "goal_computing"=>'DefaultMetricComputer', "working_time_computing"=>'EnhancedSLAComputation', "thresholds"=>array())));
        MetaModel::Init_AddAttribute(new AttributeStopWatch("tto", array("states"=>array("new", "escalated_tto"), "goal_computing"=>'ResponseTicketTTO', "working_time_computing"=>'EnhancedSLAComputation', "thresholds"=>array(75 => array('percent' => 75, 'actions' => array()), 100 => array('percent' => 100, 'actions' => array(array('verb' => 'ApplyStimulus', 'params' => array("ev_timeout"))))))));
        MetaModel::Init_AddAttribute(new AttributeStopWatch("ttr", array("states"=>array("new", "escalated_tto", "assigned", "escalated_ttr"), "goal_computing"=>'ResponseTicketTTR', "working_time_computing"=>'EnhancedSLAComputation', "thresholds"=>array(75 => array('percent' => 75, 'actions' => array()), 100 => array('percent' => 100, 'actions' => array(array('verb' => 'ApplyStimulus', 'params' => array("ev_timeout"))))))));
        MetaModel::Init_AddAttribute(new AttributeSubItem("tto_escalation_deadline", array("target_attcode"=>'tto', "item_code"=>'100_deadline')));
        MetaModel::Init_AddAttribute(new AttributeSubItem("sla_tto_passed", array("target_attcode"=>'tto', "item_code"=>'100_passed')));
        MetaModel::Init_AddAttribute(new AttributeSubItem("sla_tto_over", array("target_attcode"=>'tto', "item_code"=>'100_overrun')));
        MetaModel::Init_AddAttribute(new AttributeSubItem("ttr_escalation_deadline", array("target_attcode"=>'ttr', "item_code"=>'100_deadline')));
        MetaModel::Init_AddAttribute(new AttributeSubItem("sla_ttr_passed", array("target_attcode"=>'ttr', "item_code"=>'100_passed')));
        MetaModel::Init_AddAttribute(new AttributeSubItem("sla_ttr_over", array("target_attcode"=>'ttr', "item_code"=>'100_overrun')));
        MetaModel::Init_AddAttribute(new AttributeDuration("time_spent", array("allowed_values"=>null, "sql"=>'time_spent', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeEnum("resolution_code", array("allowed_values"=>new ValueSetEnum("assistance,other,software patch,training,hardware repair,system update,bug fixed"), "display_style"=>'list', "sql"=>'resolution_code', "default_value"=>'assistance', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeText("solution", array("allowed_values"=>null, "sql"=>'solution', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeText("pending_reason", array("allowed_values"=>null, "sql"=>'pending_reason', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_incident_id", array("targetclass"=>'Incident', "allowed_values"=>new ValueSetObjects("SELECT Incident WHERE id != :this->id AND status NOT IN ('resolved','closed')"), "sql"=>'parent_incident_id', "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeExternalField("parent_incident_ref", array("allowed_values"=>null, "extkey_attcode"=>'parent_incident_id', "target_attcode"=>'ref')));
        MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_problem_id", array("targetclass"=>'Problem', "allowed_values"=>new ValueSetObjects("SELECT Problem WHERE status != \"closed\""), "sql"=>'parent_problem_id', "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeExternalField("parent_problem_ref", array("allowed_values"=>null, "extkey_attcode"=>'parent_problem_id', "target_attcode"=>'ref')));
        MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_change_id", array("targetclass"=>'Change', "allowed_values"=>new ValueSetObjects("SELECT Change WHERE status != \"closed\""), "sql"=>'parent_change_id', "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeExternalField("parent_change_ref", array("allowed_values"=>null, "extkey_attcode"=>'parent_change_id', "target_attcode"=>'ref')));
        MetaModel::Init_AddAttribute(new AttributeLinkedSet("related_request_list", array("linked_class"=>'UserRequest', "ext_key_to_me"=>'parent_incident_id', "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "edit_mode"=>LINKSET_EDITMODE_NONE, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeLinkedSet("child_incidents_list", array("linked_class"=>'Incident', "ext_key_to_me"=>'parent_incident_id', "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "edit_mode"=>LINKSET_EDITMODE_NONE, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeCaseLog("public_log", array("allowed_values"=>null, "sql"=>'public_log', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeEnum("user_satisfaction", array("allowed_values"=>new ValueSetEnum("1,2,3,4"), "display_style"=>'list', "sql"=>'user_satisfaction', "default_value"=>'1', "is_null_allowed"=>true, "depends_on"=>array())));
        MetaModel::Init_AddAttribute(new AttributeText("user_comment", array("allowed_values"=>null, "sql"=>'user_commment', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
    
        // Lifecycle (status attribute: status)
        //
        MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_assign", array()));
        MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_reassign", array()));
        MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_pending", array()));
        MetaModel::Init_DefineStimulus(new StimulusInternal("ev_timeout", array()));
        MetaModel::Init_DefineStimulus(new StimulusInternal("ev_autoresolve", array()));
        MetaModel::Init_DefineStimulus(new StimulusInternal("ev_autoclose", array()));
        MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_resolve", array()));
        MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_close", array()));
        MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_reopen", array()));
        MetaModel::Init_DefineState(
            "new",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'caller_id' => OPT_ATT_MANDATORY,
                    'team_id' => OPT_ATT_HIDDEN,
                    'agent_id' => OPT_ATT_HIDDEN,
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                    'escalation_flag' => OPT_ATT_HIDDEN,
                    'escalation_reason' => OPT_ATT_HIDDEN,
                    'assignment_date' => OPT_ATT_HIDDEN,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_tto_passed' => OPT_ATT_HIDDEN,
                    'sla_tto_over' => OPT_ATT_HIDDEN,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );
        MetaModel::Init_DefineTransition("new", "ev_assign", array("target_state"=>"assigned", "actions"=>array('SetAssignedDate'), "user_restriction"=>null));
        MetaModel::Init_DefineTransition("new", "ev_timeout", array("target_state"=>"escalated_tto", "actions"=>array(), "user_restriction"=>null));
        MetaModel::Init_DefineTransition("new", "ev_autoresolve", array("target_state"=>"resolved", "actions"=>array('SetResolveDate', 'resolveChilds'), "user_restriction"=>null));
        MetaModel::Init_DefineState(
            "escalated_tto",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'caller_id' => OPT_ATT_MANDATORY,
                    'agent_id' => OPT_ATT_HIDDEN,
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                    'escalation_flag' => OPT_ATT_HIDDEN,
                    'escalation_reason' => OPT_ATT_HIDDEN,
                    'assignment_date' => OPT_ATT_HIDDEN,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_tto_passed' => OPT_ATT_HIDDEN,
                    'sla_tto_over' => OPT_ATT_HIDDEN,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );  
        MetaModel::Init_DefineTransition("escalated_tto", "ev_assign", array("target_state"=>"assigned", "actions"=>array('SetAssignedDate'), "user_restriction"=>null));
       //  $ids = utils::ReadParam('id', '');
    
         /*    MetaModel::Init_DefineState(
            "assigned",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'team_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
                    'agent_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                    'assignment_date' => OPT_ATT_READONLY,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_tto_passed' => OPT_ATT_READONLY,
                    'sla_tto_over' => OPT_ATT_READONLY,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );
        */
    

    // echo"I am here--------------------".$a_ss;

      // $a_ss='none';
    
    
    //  if(($sStimulus=='ev_assign'))
    

    // {

    if($a_ss=="no")
    {
    MetaModel::Init_DefineState(
    "assigned",
    array(
    "attribute_inherit" => '',
    "attribute_list" => array(
    'ref' => OPT_ATT_READONLY,
    'org_id' => OPT_ATT_MANDATORY,
    'team_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'agent_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'priority' => OPT_ATT_READONLY,
    'start_date' => OPT_ATT_READONLY,
    'last_update' => OPT_ATT_READONLY,
    'close_date' => OPT_ATT_HIDDEN,
    // 'request_type' => OPT_ATT_READONLY,
    // 'approvers' => OPT_ATT_READONLY,
    'assignment_date' => OPT_ATT_READONLY,
    'resolution_date' => OPT_ATT_HIDDEN,
    'last_pending_date' => OPT_ATT_HIDDEN,
    'time_spent' => OPT_ATT_HIDDEN,
    'resolution_code' => OPT_ATT_HIDDEN,
    'solution' => OPT_ATT_HIDDEN,
    'pending_reason' => OPT_ATT_HIDDEN,
    'user_satisfaction' => OPT_ATT_HIDDEN,
    'user_comment' => OPT_ATT_HIDDEN,
    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_tto_passed' => OPT_ATT_READONLY,
    'sla_tto_over' => OPT_ATT_READONLY,
    'sla_ttr_passed' => OPT_ATT_HIDDEN,
    'ttr_escalation_deadline' => OPT_ATT_READONLY,
    'sla_ttr_over' => OPT_ATT_HIDDEN,
    ),
    )
    );
    }

    elseif($a_ss=="yes")
    {
              MetaModel::Init_DefineState(
            "assigned",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'team_id' => OPT_ATT_READONLY, 
                    'agent_id' => OPT_ATT_READONLY, 
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                   // 'request_type' => OPT_ATT_READONLY,
                //    'approvers' => OPT_ATT_READONLY,
                    'assignment_date' => OPT_ATT_READONLY,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_tto_passed' => OPT_ATT_READONLY,
                    'sla_tto_over' => OPT_ATT_READONLY,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );  
    }
    elseif($a_ss=="none")
    {
         MetaModel::Init_DefineState(
            "assigned",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'team_id' => OPT_ATT_READONLY,         
                    'agent_id' => OPT_ATT_READONLY,     
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                    //'request_type' => OPT_ATT_READONLY,
                 //   'approvers' => OPT_ATT_READONLY,
                    'assignment_date' => OPT_ATT_READONLY,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_tto_passed' => OPT_ATT_READONLY,
                    'sla_tto_over' => OPT_ATT_READONLY,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );
    }
    /*
      if($a_ss=="no")
        {
    
            echo"---------------------------------------------------------------------------";
        MetaModel::Init_DefineState(
            "assigned",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'team_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
                    'agent_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                    'assignment_date' => OPT_ATT_READONLY,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_tto_passed' => OPT_ATT_READONLY,
                    'sla_tto_over' => OPT_ATT_READONLY,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );
        }
        elseif($a_ss1=="yes")
        {
          MetaModel::Init_DefineState(
            "assigned",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'team_id' => OPT_ATT_READONLY,
                    'agent_id' => OPT_ATT_READONLY,
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                    'assignment_date' => OPT_ATT_READONLY,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_tto_passed' => OPT_ATT_READONLY,
                    'sla_tto_over' => OPT_ATT_READONLY,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );  
        }
         elseif($a_ss1=="none")
        {
          MetaModel::Init_DefineState(
            "assigned",
            array(
                "attribute_inherit" => '',
                "attribute_list" => array(
                    'ref' => OPT_ATT_READONLY,
                    'org_id' => OPT_ATT_MANDATORY,
                    'team_id' => OPT_ATT_READONLY,
                    'agent_id' => OPT_ATT_READONLY,
                    'priority' => OPT_ATT_READONLY,
                    'start_date' => OPT_ATT_READONLY,
                    'last_update' => OPT_ATT_READONLY,
                    'close_date' => OPT_ATT_HIDDEN,
                    'assignment_date' => OPT_ATT_READONLY,
                    'resolution_date' => OPT_ATT_HIDDEN,
                    'last_pending_date' => OPT_ATT_HIDDEN,
                    'time_spent' => OPT_ATT_HIDDEN,
                    'resolution_code' => OPT_ATT_HIDDEN,
                    'solution' => OPT_ATT_HIDDEN,
                    'pending_reason' => OPT_ATT_HIDDEN,
                    'user_satisfaction' => OPT_ATT_HIDDEN,
                    'user_comment' => OPT_ATT_HIDDEN,
                    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
                    'sla_tto_passed' => OPT_ATT_READONLY,
                    'sla_tto_over' => OPT_ATT_READONLY,
                    'sla_ttr_passed' => OPT_ATT_HIDDEN,
                    'ttr_escalation_deadline' => OPT_ATT_READONLY,
                    'sla_ttr_over' => OPT_ATT_HIDDEN,
                ),
            )
        );  
        }  
          */
    

    / }
    else
    {
    MetaModel::Init_DefineState(
    "assigned",
    array(
    "attribute_inherit" => '',
    "attribute_list" => array(
    'ref' => OPT_ATT_READONLY,
    'org_id' => OPT_ATT_MANDATORY,
    'team_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'agent_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'priority' => OPT_ATT_READONLY,
    'start_date' => OPT_ATT_READONLY,
    'last_update' => OPT_ATT_READONLY,
    'close_date' => OPT_ATT_HIDDEN,
    'assignment_date' => OPT_ATT_READONLY,
    'resolution_date' => OPT_ATT_HIDDEN,
    'last_pending_date' => OPT_ATT_HIDDEN,
    'time_spent' => OPT_ATT_HIDDEN,
    'resolution_code' => OPT_ATT_HIDDEN,
    'solution' => OPT_ATT_HIDDEN,
    'pending_reason' => OPT_ATT_HIDDEN,
    'user_satisfaction' => OPT_ATT_HIDDEN,
    'user_comment' => OPT_ATT_HIDDEN,
    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_tto_passed' => OPT_ATT_READONLY,
    'sla_tto_over' => OPT_ATT_READONLY,
    'sla_ttr_passed' => OPT_ATT_HIDDEN,
    'ttr_escalation_deadline' => OPT_ATT_READONLY,
    'sla_ttr_over' => OPT_ATT_HIDDEN,
    ),
    )
    );
    }
    /
    MetaModel::Init_DefineTransition("assigned", "ev_pending", array("target_state"=>"pending", "actions"=>array('SetLastPendingDate'), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("assigned", "ev_resolve", array("target_state"=>"resolved", "actions"=>array('SetResolveDate', 'resolveChilds'), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("assigned", "ev_reassign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("assigned", "ev_timeout", array("target_state"=>"escalated_ttr", "actions"=>array(), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("assigned", "ev_autoresolve", array("target_state"=>"resolved", "actions"=>array('SetResolveDate', 'resolveChilds'), "user_restriction"=>null));
    MetaModel::Init_DefineState(
    "escalated_ttr",
    array(
    "attribute_inherit" => '',
    "attribute_list" => array(
    'ref' => OPT_ATT_READONLY,
    'org_id' => OPT_ATT_MANDATORY,
    'team_id' => OPT_ATT_MANDATORY,
    'agent_id' => OPT_ATT_MANDATORY,
    'priority' => OPT_ATT_READONLY,
    'start_date' => OPT_ATT_READONLY,
    'last_update' => OPT_ATT_READONLY,
    'close_date' => OPT_ATT_HIDDEN,
    'assignment_date' => OPT_ATT_READONLY,
    'resolution_date' => OPT_ATT_HIDDEN,
    'last_pending_date' => OPT_ATT_HIDDEN,
    'time_spent' => OPT_ATT_HIDDEN,
    'resolution_code' => OPT_ATT_HIDDEN,
    'solution' => OPT_ATT_HIDDEN,
    'pending_reason' => OPT_ATT_HIDDEN,
    'user_satisfaction' => OPT_ATT_HIDDEN,
    'user_comment' => OPT_ATT_HIDDEN,
    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_tto_passed' => OPT_ATT_READONLY,
    'sla_tto_over' => OPT_ATT_READONLY,
    'sla_ttr_passed' => OPT_ATT_HIDDEN,
    'ttr_escalation_deadline' => OPT_ATT_READONLY,
    'sla_ttr_over' => OPT_ATT_HIDDEN,
    ),
    )
    );
    MetaModel::Init_DefineTransition("escalated_ttr", "ev_pending", array("target_state"=>"pending", "actions"=>array('SetLastPendingDate'), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("escalated_ttr", "ev_resolve", array("target_state"=>"resolved", "actions"=>array('SetResolveDate', 'resolveChilds'), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("escalated_ttr", "ev_reassign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("escalated_ttr", "ev_autoresolve", array("target_state"=>"resolved", "actions"=>array('SetResolveDate', 'resolveChilds'), "user_restriction"=>null));
    MetaModel::Init_DefineState(
    "pending",
    array(
    "attribute_inherit" => '',
    "attribute_list" => array(
    'ref' => OPT_ATT_READONLY,
    'org_id' => OPT_ATT_MANDATORY,
    'team_id' => OPT_ATT_MANDATORY,
    'agent_id' => OPT_ATT_MANDATORY,
    'priority' => OPT_ATT_READONLY,
    'start_date' => OPT_ATT_READONLY,
    'last_update' => OPT_ATT_READONLY,
    'close_date' => OPT_ATT_HIDDEN,
    'assignment_date' => OPT_ATT_READONLY,
    'resolution_date' => OPT_ATT_HIDDEN,
    'last_pending_date' => OPT_ATT_READONLY,
    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
    'ttr_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_tto_passed' => OPT_ATT_HIDDEN,
    'sla_tto_over' => OPT_ATT_HIDDEN,
    'sla_ttr_passed' => OPT_ATT_HIDDEN,
    'sla_ttr_over' => OPT_ATT_HIDDEN,
    'time_spent' => OPT_ATT_HIDDEN,
    'resolution_code' => OPT_ATT_HIDDEN,
    'solution' => OPT_ATT_HIDDEN,
    'pending_reason' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'user_satisfaction' => OPT_ATT_HIDDEN,
    'user_comment' => OPT_ATT_HIDDEN,
    ),
    )
    );
    MetaModel::Init_DefineTransition("pending", "ev_assign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("pending", "ev_autoresolve", array("target_state"=>"resolved", "actions"=>array('SetResolveDate', 'resolveChilds'), "user_restriction"=>null));
    MetaModel::Init_DefineState(
    "resolved",
    array(
    "attribute_inherit" => '',
    "attribute_list" => array(
    'ref' => OPT_ATT_READONLY,
    'org_id' => OPT_ATT_READONLY,
    'caller_id' => OPT_ATT_READONLY,
    'origin' => OPT_ATT_READONLY,
    'team_id' => OPT_ATT_READONLY,
    'agent_id' => OPT_ATT_READONLY,
    'start_date' => OPT_ATT_READONLY,
    'last_update' => OPT_ATT_READONLY,
    'impact' => OPT_ATT_READONLY,
    'urgency' => OPT_ATT_READONLY,
    'priority' => OPT_ATT_READONLY,
    'close_date' => OPT_ATT_HIDDEN,
    'service_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'servicesubcategory_id' => OPT_ATT_MUSTPROMPT,
    'escalation_flag' => OPT_ATT_READONLY,
    'escalation_reason' => OPT_ATT_READONLY,
    'assignment_date' => OPT_ATT_READONLY,
    'resolution_date' => OPT_ATT_READONLY,
    'last_pending_date' => OPT_ATT_HIDDEN,
    'time_spent' => OPT_ATT_READONLY,
    'resolution_code' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'solution' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT,
    'pending_reason' => OPT_ATT_READONLY,
    'user_satisfaction' => OPT_ATT_HIDDEN,
    'user_comment' => OPT_ATT_HIDDEN,
    'parent_incident_id' => OPT_ATT_READONLY,
    'parent_change_id' => OPT_ATT_READONLY,
    'parent_problem_id' => OPT_ATT_READONLY,
    'title' => OPT_ATT_READONLY,
    'description' => OPT_ATT_READONLY,
    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_tto_passed' => OPT_ATT_READONLY,
    'sla_tto_over' => OPT_ATT_READONLY,
    'sla_ttr_passed' => OPT_ATT_READONLY,
    'ttr_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_ttr_over' => OPT_ATT_READONLY,
    ),
    )
    );
    MetaModel::Init_DefineTransition("resolved", "ev_close", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("resolved", "ev_reopen", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
    MetaModel::Init_DefineTransition("resolved", "ev_autoresolve", array("target_state"=>"resolved", "actions"=>array('SetResolveDate', 'resolveChilds'), "user_restriction"=>null));
    MetaModel::Init_DefineState(
    "closed",
    array(
    "attribute_inherit" => '',
    "attribute_list" => array(
    'ref' => OPT_ATT_READONLY,
    'org_id' => OPT_ATT_READONLY,
    'caller_id' => OPT_ATT_READONLY,
    'origin' => OPT_ATT_READONLY,
    'team_id' => OPT_ATT_READONLY,
    'agent_id' => OPT_ATT_READONLY,
    'start_date' => OPT_ATT_READONLY,
    'last_update' => OPT_ATT_READONLY,
    'private_log' => OPT_ATT_READONLY,
    'impact' => OPT_ATT_READONLY,
    'urgency' => OPT_ATT_READONLY,
    'priority' => OPT_ATT_READONLY,
    'service_id' => OPT_ATT_READONLY,
    'servicesubcategory_id' => OPT_ATT_READONLY,
    'escalation_flag' => OPT_ATT_READONLY,
    'escalation_reason' => OPT_ATT_READONLY,
    'assignment_date' => OPT_ATT_READONLY,
    'resolution_date' => OPT_ATT_READONLY,
    'close_date' => OPT_ATT_READONLY,
    'last_pending_date' => OPT_ATT_HIDDEN,
    'time_spent' => OPT_ATT_READONLY,
    'resolution_code' => OPT_ATT_READONLY,
    'solution' => OPT_ATT_READONLY,
    'pending_reason' => OPT_ATT_READONLY,
    'public_log' => OPT_ATT_READONLY,
    'user_satisfaction' => OPT_ATT_MUSTPROMPT,
    'user_comment' => OPT_ATT_MUSTPROMPT,
    'pending_reason' => OPT_ATT_READONLY,
    'parent_incident_id' => OPT_ATT_READONLY,
    'parent_change_id' => OPT_ATT_READONLY,
    'parent_problem_id' => OPT_ATT_READONLY,
    'title' => OPT_ATT_READONLY,
    'description' => OPT_ATT_READONLY,
    'tto_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_tto_passed' => OPT_ATT_READONLY,
    'sla_tto_over' => OPT_ATT_READONLY,
    'sla_ttr_passed' => OPT_ATT_READONLY,
    'ttr_escalation_deadline' => OPT_ATT_HIDDEN,
    'sla_ttr_over' => OPT_ATT_READONLY,
    ),
    )
    );

        MetaModel::Init_SetZListItems('details', array (
    

    0 => 'functionalcis_list',
    1 => 'contacts_list',
    2 => 'child_incidents_list',
    3 => 'related_request_list',
    4 => 'workorders_list',
    'col:col1' =>
    array (
    'fieldset:Ticket:baseinfo' =>
    array (
    0 => 'org_id',
    1 => 'caller_id',
    2 => 'status',
    3 => 'origin',
    4 => 'title',
    5 => 'description',
    ),
    'fieldset:Ticket:moreinfo' =>
    array (
    0 => 'service_id',
    1 => 'servicesubcategory_id',
    2 => 'escalation_flag',
    3 => 'escalation_reason',
    4 => 'pending_reason',

    ),
    

    ),
    'col:col2' =>
    array (
    'fieldset:Ticket:Type' =>
    array (
    0 => 'impact',
    1 => 'urgency',
    2 => 'priority',
    ),
    'fieldset:Ticket:contact' =>
    array (
    0 => 'team_id',
    1 => 'agent_id',
    ),
    'fieldset:Ticket:date' =>
    array (
    0 => 'start_date',
    1 => 'last_update',
    2 => 'assignment_date',
    3 => 'tto_escalation_deadline',
    4 => 'ttr_escalation_deadline',
    5 => 'last_pending_date',
    6 => 'resolution_date',
    7 => 'close_date',
    ),
    ),
    'col:col3' =>
    array (
    'fieldset:Relations' =>
    array (
    0 => 'parent_incident_id',
    1 => 'parent_problem_id',
    2 => 'parent_change_id',
    ),
    'fieldset:Ticket:resolution' =>
    array (
    0 => 'resolution_code',
    1 => 'solution',
    2 => 'time_spent',
    3 => 'user_satisfaction',
    4 => 'user_comment',
    ),
    'fieldset:Ticket:SLA' =>
    array (
    0 => 'sla_tto_passed',
    1 => 'sla_tto_over',
    2 => 'sla_ttr_passed',
    3 => 'sla_ttr_over',
    ),
    ),
    ));
    MetaModel::Init_SetZListItems('standard_search', array (
    0 => 'ref',
    1 => 'org_id',
    2 => 'title',
    3 => 'description',
    4 => 'start_date',
    5 => 'end_date',
    6 => 'resolution_date',
    7 => 'close_date',
    8 => 'status',
    9 => 'caller_id',
    10 => 'origin',
    11 => 'impact',
    12 => 'urgency',
    13 => 'priority',
    14 => 'service_id',
    15 => 'servicesubcategory_id',
    16 => 'team_id',
    17 => 'agent_id',
    18 => 'escalation_flag',
    19 => 'resolution_code',
    20 => 'user_satisfaction',
    21 => 'sla_tto_passed',
    22 => 'sla_ttr_passed',

    ));
    MetaModel::Init_SetZListItems('list', array (
    0 => 'title',
    1 => 'org_id',
    2 => 'caller_id',
    3 => 'start_date',
    4 => 'status',
    5 => 'agent_id',
    ));

    }
    
    
    
    public function SetAssignedDate($sStimulusCode)
    {
        $this->Set('assignment_date', time());
        return true;
    }
    
    
    public function SetLastPendingDate($sStimulusCode)
    {
        $this->Set('last_pending_date', time());
        return true;
    }
    
    
    public function SetResolveDate($sStimulusCode)
    {
        $this->Set('resolution_date', time());
                $iTimeSpent = time() - AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
        $this->Set('time_spent', $iTimeSpent);
        return true;
    }
    
    
    public function SetClosureDate($sStimulusCode)
    {
        $this->Set('close_date', time());
        return true;
    }
    
    /** Compute the priority of the ticket based on its impact and urgency
         * @return integer The priority of the ticket 1(high) .. 3(low)
         */
        public function ComputePriority()
        {
                // priority[impact][urgency]
                $aPriorities = array(
                        // single person
                        1 => array(
                                        1 => 1,
                                        2 => 1,
                                        3 => 2,
                                        4 => 4,
                        ),
                        // a group
                        2 => array(
                                1 => 1,
                                2 => 2,
                                3 => 3,
                                4 => 4,
                        ),
                        // a departement!
                        3 => array(
                                        1 => 2,
                                        2 => 3,
                                        3 => 3,
                                        4 => 4,
                        ),
                );
                $iPriority = $aPriorities[(int)$this->Get('impact')][(int)$this->Get('urgency')];
                return $iPriority;              
        }
    
    
    public function ComputeValues()
    {
    
        // Compute the priority of the ticket
        $this->Set('priority', $this->ComputePriority());
    
        $sCurrRef = $this->Get('ref');
        if (strlen($sCurrRef) == 0)
        {
            $iKey = $this->GetKey();
            if ($iKey < 0)
            {
                // Object not yet in the Database
                $iKey = MetaModel::GetNextKey(get_class($this));
            }
            $sName = sprintf('I-%06d', $iKey);
            $this->Set('ref', $sName);
        }
    
        return parent::ComputeValues();
    }
    
    
    function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
    {
        parent::DisplayBareRelations($oPage, $bEditMode);
    
        if (!$bEditMode)
        {
            if (MetaModel::IsValidClass('KnownError'))
            {
                //Search for known errors
                $oPage->SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList'));
                $iTicketID = $this->GetKey();;
                $oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
                $iNumberKE=$oKnownErrorSet->count();
                if ($iNumberKE > 0)
                {
                    $oPage->SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
                }
                else
                {
                    $oPage->SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList'));    
                }            
                self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
            }
        }
    }
    
    /**
     * Get the icon representing this object
     * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
     * @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file
     */
    public function GetIcon($bImgTag = true)
    {
        $sStatus = $this->Get('status');
        switch($this->GetState())
        {
    
            case 'escalated_tto':
            case 'escalated_ttr':
            $sIcon = self::MakeIconFromName('incident-escalated.png');
            break;
    
            case 'resolved':
            case 'closed':
            $sIcon = self::MakeIconFromName('incident-closed.png');
            break;
    
            case 'new':
            case 'approved':
            $sIcon = self::MakeIconFromName('user-request.png');
            $iEscalationDeadline = $this->Get('tto_escalation_deadline');
            if ($iEscalationDeadline != null)
            {
                // A SLA is running
                $iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
    
                $ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
                if ($ratio <= 0)
                {
                    $sIcon = self::MakeIconFromName('incident-escalated.png');
                }
                else if ($ratio <= 0.25)
                {
                    $sIcon = self::MakeIconFromName('incident-deadline.png');
                }
            }
            break;
    
            case 'assigned':
            $sIcon = self::MakeIconFromName('user-request.png');
            $iEscalationDeadline = $this->Get('ttr_escalation_deadline');
            if ($iEscalationDeadline != null)
            {
                // A SLA is running
                $iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
                $ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
                if ($ratio <= 0)
                {
                    $sIcon = self::MakeIconFromName('incident-escalated.png');
                }
                else if ($ratio <= 0.25)
                {
                    $sIcon = self::MakeIconFromName('incident-deadline.png');
                }
            }
            break;
    
    
    
    
    
    
            default:
            $sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
        }
        return $sIcon;
    }
    
    
    protected static function MakeIconFromName($sIconName, $bImgTag = true)
    {
        $sIcon = '';
        if ($sIconName != '')
        {
            $sPath = '../env-'.utils::GetCurrentEnvironment().'/itop-incident-mgmt-itil/images/'.$sIconName;
            if ($bImgTag)
            {
                $sIcon = "<img src=\"$sPath\" style=\"vertical-align:middle;\"/>";
            }
            else
            {
                $sIcon  = $sPath;
            }
        }
        return $sIcon;
    }
    
    
    public function GetHilightClass()
    {
        $sHilightClass = '';
        switch($this->GetState())
        {
            case 'new':
            case 'approved':
            $iEscalationDeadline  = $this->Get('tto_escalation_deadline');
            if ($iEscalationDeadline != null)
            {
                // A SLA is running
                $iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
                $ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
                if ($ratio <= 0)
                {
                    $sHilightClass = HILIGHT_CLASS_CRITICAL;
                }
                else if ($ratio <= 0.25)
                {
                    $sHilightClass = HILIGHT_CLASS_WARNING;
                }
            }
            break;
    
            case 'assigned':
            $iEscalationDeadline = $this->Get('ttr_escalation_deadline');
            if ($iEscalationDeadline != null)
            {
                // A SLA is running
                $iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
                $ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
                if ($ratio <= 0)
                {
                    $sHilightClass = HILIGHT_CLASS_CRITICAL;
                }
                else if ($ratio <= 0.25)
                {
                    $sHilightClass = HILIGHT_CLASS_WARNING;
                }
            }
            break;
    
            case 'escalated_tto':
            case 'escalated_ttr':
            $sHilightClass = HILIGHT_CLASS_CRITICAL;
            break;
        }
        return $sHilightClass;
    }
    
    
    public function resolveChilds($sStimulusCode)
    {
    
        $oMyChange = MetaModel::NewObject("CMDBChange");
        $oMyChange->Set("date", time());
        $sUserString = CMDBChange::GetCurrentUserName();
        $oMyChange->Set("userinfo", $sUserString."(automatic resolution)");
        $iChangeId = $oMyChange->DBInsert();
        $sOQL = "SELECT UserRequest WHERE parent_request_id=:ticket";
        $oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
                        array(),
                        array(
                            'ticket' => $this->GetKey(),
                            )
                        );
        //automatically resolve child requests
        while($oRequest = $oChildRequestSet->Fetch())
        {
            if ( $oRequest->Get('status') != 'resolved')
            {
                $oRequest->set('servicesubcategory_id',$this->Get('servicesubcategory_id'));
                $oRequest->set('service_id',$this->Get('service_id'));        
                $oRequest->set('team_id',$this->Get('team_id'));
                $oRequest->set('agent_id',$this->Get('agent_id'));    
                $oRequest->set('resolution_code',$this->Get('resolution_code'));
                $oRequest->set('solution','Automatically resolved by incident:[[Incident:'.$this->Get('ref').']]');
                $oRequest->ApplyStimulus('ev_autoresolve');
                $oRequest->DBUpdateTracked($oMyChange);
            }
        }
    
        //automatically resolve child incidents
        $sOQL = "SELECT Incident WHERE parent_incident_id=:ticket";
        $oChildIncidentSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
                        array(),
                        array(
                            'ticket' => $this->GetKey(),
                            )
                        );
        while($oIncident = $oChildIncidentSet->Fetch())
        {
            if ( $oIncident->Get('status') != 'resolved')
            {
                $oIncident->set('servicesubcategory_id',$this->Get('servicesubcategory_id'));
                $oIncident->set('service_id',$this->Get('service_id'));        
                $oIncident->set('team_id',$this->Get('team_id'));
                $oIncident->set('agent_id',$this->Get('agent_id'));    
                $oIncident->set('resolution_code',$this->Get('resolution_code'));
                $oIncident->set('solution','Automatically resolved by incident:[[Incident:'.$this->Get('ref').']]');
                $oIncident->ApplyStimulus('ev_autoresolve');
                $oIncident->DBUpdateTracked($oMyChange);
            }
        }
        return true;
    
    }
    
    
    public function UpdateChildRequestLog()
    {
        $sLogPublic = utils::ReadPostedParam('attr_public_log', null,false,'raw_data');
        if ( $sLogPublic != null)
        {
            $oMyChange = MetaModel::NewObject("CMDBChange");
            $oMyChange->Set("date", time());
            $sUserString = CMDBChange::GetCurrentUserName();
            $oMyChange->Set("userinfo", $sUserString."(automatic update)");
            $iChangeId = $oMyChange->DBInsert();
            $sOQL = "SELECT UserRequest WHERE parent_incident_id=:ticket";
            $oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
                            array(),
                            array(
                                'ticket' => $this->GetKey(),
                                )
                            );
            while($oRequest = $oChildRequestSet->Fetch())
            {
                $oRequest->set('public_log',$sLogPublic);
                $oRequest->DBUpdateTracked($oMyChange);
            }
    
        }
        $sLogPrivate = utils::ReadPostedParam('attr_private_log', null,false,'raw_data');
        if ( $sLogPrivate != null)
        {
            $oMyChange = MetaModel::NewObject("CMDBChange");
            $oMyChange->Set("date", time());
            $sUserString = CMDBChange::GetCurrentUserName();
            $oMyChange->Set("userinfo", $sUserString."(automatic update)");
            $iChangeId = $oMyChange->DBInsert();
            $sOQL = "SELECT UserRequest WHERE parent_incident_id=:ticket";
            $oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
                            array(),
                            array(
                                'ticket' => $this->GetKey(),
                                )
                            );
            while($oRequest = $oChildRequestSet->Fetch())
            {
                $oRequest->set('private_log',$sLogPrivate);
                $oRequest->DBUpdateTracked($oMyChange);
            }
        }
        return true;
    
    }
    
    
    public function UpdateChildIncidentLog()
    {
        $sLogPublic = utils::ReadPostedParam('attr_public_log', null,false,'raw_data');
        if ( $sLogPublic != null)
        {
            $oMyChange = MetaModel::NewObject("CMDBChange");
            $oMyChange->Set("date", time());
            $sUserString = CMDBChange::GetCurrentUserName();
            $oMyChange->Set("userinfo", $sUserString."(automatic update)");
            $iChangeId = $oMyChange->DBInsert();
            $sOQL = "SELECT Incident WHERE parent_incident_id=:ticket";
            $oChildIncidentSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
                            array(),
                            array(
                                'ticket' => $this->GetKey(),
                                )
                            );
            while($oIncident = $oChildIncidentSet->Fetch())
            {
                $oIncident->set('public_log',$sLogPublic);
                $oIncident->DBUpdateTracked($oMyChange);
            }
    
        }
        $sLogPrivate = utils::ReadPostedParam('attr_private_log', null,false,'raw_data');
        if ( $sLogPrivate != null)
        {
            $oMyChange = MetaModel::NewObject("CMDBChange");
            $oMyChange->Set("date", time());
            $sUserString = CMDBChange::GetCurrentUserName();
            $oMyChange->Set("userinfo", $sUserString."(automatic update)");
            $iChangeId = $oMyChange->DBInsert();
            $sOQL = "SELECT Incident WHERE parent_incident_id=:ticket";
            $oChildIncidentSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
                            array(),
                            array(
                                'ticket' => $this->GetKey(),
                                )
                            );
            while($oIncident = $oChildIncidentSet->Fetch())
            {
                $oIncident->set('private_log',$sLogPrivate);
                $oIncident->DBUpdateTracked($oMyChange);
            }
        }
        return true;
    
    }
    
    
    public function ComputeImpactedItems()
    {    
        $oToNotify = $this->Get('contacts_list');
    
        $oToImpact = $this->Get('functionalcis_list');
    
        $oImpactedInfras = DBObjectSet::FromLinkSet($this, 'functionalcis_list', 'functionalci_id');
    
        $aComputed = $oImpactedInfras->GetRelatedObjects('impacts', 10);
    
        if (isset($aComputed['FunctionalCI']) && is_array($aComputed['FunctionalCI']))
        {
            foreach($aComputed['FunctionalCI'] as $iKey => $oObject)
            {
                $oNewLink = new lnkFunctionalCIToTicket();
                $oNewLink->Set('functionalci_id', $iKey);
                $oNewLink->Set('impact', 'potentially impacted (automatically computed)');
                $oToImpact->AddObject($oNewLink);
            }
        }
        if (isset($aComputed['Contact']) && is_array($aComputed['Contact']))
        {
            foreach($aComputed['Contact'] as $iKey => $oObject)
            {
                $oNewLink = new lnkContactToTicket();
                $oNewLink->Set('contact_id', $iKey);
                $oNewLink->Set('role', 'contact automatically computed');
                $oToNotify->AddObject($oNewLink);
            }
        }
    
        parent::OnInsert();
    }
    
    
    protected function OnInsert()
    
    {
        $this->ComputeImpactedItems();
        $this->Set('last_update', time());
        $this->Set('start_date', time());
    }
    
    
    protected function OnUpdate()
    {
        $this->Set('last_update', time());
        $this->UpdateChildRequestLog();
        $this->UpdateChildIncidentLog();
    }
    

    }
    //
    // Menus
    //
    $comp_menus['IncidentManagement'] = new MenuGroup('IncidentManagement', 35);
    $comp_menus['Incident:Overview'] = new DashboardMenuNode('Incident:Overview', dirname(FILE).'/overview.xml', $comp_menus['IncidentManagement']->GetIndex(), 0);
    $comp_menus['NewIncident'] = new NewObjectMenuNode('NewIncident', 'Incident', $comp_menus['IncidentManagement']->GetIndex(), 1);
    $comp_menus['SearchIncidents'] = new SearchMenuNode('SearchIncidents', 'Incident', $comp_menus['IncidentManagement']->GetIndex(), 2);
    $comp_menus['Incident:Shortcuts'] = new TemplateMenuNode('Incident:Shortcuts', '', $comp_menus['IncidentManagement']->GetIndex(), 3);
    $comp_menus['Incident:MyIncidents'] = new OQLMenuNode('Incident:MyIncidents', "SELECT Incident WHERE agent_id = :current_contact_id AND status NOT IN (\"closed\",\"resolved\")", $comp_menus['Incident:Shortcuts']->GetIndex(), 0, false);
    $comp_menus['Incident:MyIncidents']->SetParameters(array('auto_reload' => "fast"));
    $comp_menus['Incident:EscalatedIncidents'] = new OQLMenuNode('Incident:EscalatedIncidents', "SELECT Incident WHERE status IN (\"escalated_tto\", \"escalated_ttr\") OR escalation_flag=\"yes\"", $comp_menus['Incident:Shortcuts']->GetIndex(), 1, false);
    $comp_menus['Incident:EscalatedIncidents']->SetParameters(array('auto_reload' => "fast"));
    $comp_menus['Incident:OpenIncidents'] = new OQLMenuNode('Incident:OpenIncidents', "SELECT Incident WHERE status NOT IN (\"closed\")", $comp_menus['Incident:Shortcuts']->GetIndex(), 2, true);
    $comp_menus['Incident:OpenIncidents']->SetParameters(array('auto_reload' => "fast"));

     
  • Denis

    Denis - 2013-12-06

    Hello Pankaj,

    When making modifications to the data model, make sure that you make them in the "datamodels" directory, since the content of the "env-production" folder is re-created by the setup upon each installation/upgrade.

    The purpose of the different folders is explained here: http://www.combodo.com/wiki/doku.php?id=customization:start

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.