/**
  * Modify User POST
  */
 function modcontact_title()
 {
     $clang = Yii::app()->lang;
     // old Details
     $contact_title_id = (int) Yii::app()->request->getPost("contact_title_id");
     $contact_title_name = flattenText(Yii::app()->request->getPost("contact_title_name"));
     $IsActive = flattenText(Yii::app()->request->getPost("IsActive"));
     //New Name
     $c_title_name = flattenText(Yii::app()->request->getPost("c_title_name"));
     $addsummary = '';
     $aViewUrls = array();
     $is_Active = 0;
     if ($IsActive) {
         $is_Active = 1;
     }
     $sresult = Contact_title::model()->findAllByAttributes(array('contact_title_id' => $contact_title_id));
     $sresultcount = count($sresult);
     if (Permission::model()->hasGlobalPermission('superadmin', 'read') || $sresultcount > 0 && Permission::model()->hasGlobalPermission('contacts', 'update')) {
         if ($c_title_name == '') {
             $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing Contact Title"), $clang->gT("Could not modify Contact Title."), "warningheader", $clang->gT("Contact Title  name not be empty."), $this->getController()->createUrl('admin/contact_title/sa/modifycontact_title'), $clang->gT("Back"), array('contact_title_id' => $contact_title_id));
         } elseif (Contact_title::model()->findByAttributes(array('contact_title_name' => $c_title_name, 'IsActive' => $is_Active))) {
             $aViewUrls['message'] = array('title' => $clang->gT("Failed to add Contact Title"), 'message' => $clang->gT("The Contact Title already exists."), 'class' => 'warningheader');
         } else {
             $oRecord = Contact_title::model()->findByPk($contact_title_id);
             $oRecord->contact_title_name = $this->escape($c_title_name);
             $oRecord->IsActive = $this->escape($is_Active);
             $uresult = $oRecord->save();
             // store result of save in uresult
             if ($uresult) {
                 // When saved successfully
                 Yii::app()->setFlashMessage($clang->gT("Contact title updated successfully"));
                 $this->getController()->redirect(array("admin/contact_title/index"));
             } else {
                 //Saving the user failed for some reason, message about email is not helpful here
                 // Username and/or email adress already exists.
                 $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing contact title"), $clang->gT("Could not modify contact title."), 'warningheader');
             }
         }
     } else {
         Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error');
         $this->getController()->redirect(array("admin/index"));
     }
     $this->_renderWrappedTemplate('contacts/contact_title', $aViewUrls);
 }
        echo '<br/>';
    }
    ?>
            </td>
            <td>
                <?php 
    $titleselected = explode(',', $mrw['contact_title_id']);
    $tsel = array_combine($test, $titleselected);
    foreach ($ctypelist as $ky => $val) {
        $selectedtitle = array();
        foreach ($tsel as $kye => $vle) {
            if ($ky == $kye) {
                $selectedtitle[] = $vle;
            }
        }
        $title = Contact_title::model()->findAll(array('order' => 'contact_title_name'));
        $titlelist = CHtml::listData($title, 'contact_title_id', 'contact_title_name');
        echo CHtml::dropDownList($val, $selectedtitle, $titlelist, array('prompt' => 'Select ' . $val . ' title', 'name' => $val, 'id' => 'Title_' . $ky, 'required' => true));
        echo '<br/>';
    }
    ?>
            </td>
        </tr>
        <tr>
            <td align="right" style="text-align: right;display: none">
                <label for='IsListProvider'><?php 
    $clang->eT("IsListProvider : ");
    ?>
</label>
            </td>
            <td style="display: none">
?>
        </td>
        <td align="right" style="display: none">
            <?php 
$ctypes = Company_type::model()->findAll(array('select' => 'concat(company_type_id,"__", company_type) as company_type_id , company_type_name', 'condition' => "company_type != 'O' AND IsTitle = '1'"));
$ctypeslist = CHtml::listData($ctypes, 'company_type_id', 'company_type_name');
foreach ($ctypeslist as $key => $value) {
    echo "<label id='titlelabel_" . $key . "'>Company Title for " . $value . "* : </label>";
    echo '<br/>';
}
?>
        </td>
        <td style="display: none">
            <?php 
foreach ($ctypeslist as $ky => $val) {
    $title = Contact_title::model()->findAll();
    $titlelist = CHtml::listData($title, 'contact_title_id', 'contact_title_name');
    echo CHtml::dropDownList($val, '', $titlelist, array('prompt' => 'Select ' . $val . ' title', 'name' => $val, 'id' => 'Title_' . $ky));
    echo '<br/>';
}
?>
        </td>
    </tr>
    <tr>
        <td align="right" style="text-align: right;display: none">
            <label for='IsListProvider'><?php 
$clang->eT("IsListProvider : ");
?>
</label>
        </td>
        <td style="display: none">