Esempio n. 1
0
 function getSearchParams($stage, $assignedto, $dates)
 {
     $listSearchParams = array();
     $conditions = array();
     array_push($conditions, array("sales_stage", "e", $stage));
     if ($assignedto == '') {
         $currenUserModel = Users_Record_Model::getCurrentUserModel();
         $assignedto = $currenUserModel->getId();
     }
     if ($assignedto != 'all') {
         $ownerType = vtws_getOwnerType($assignedto);
         if ($ownerType == 'Users') {
             array_push($conditions, array("assigned_user_id", "e", getUserFullName($assignedto)));
         } else {
             $groupName = getGroupName($assignedto);
             $groupName = $groupName[0];
             array_push($conditions, array("assigned_user_id", "e", $groupName));
         }
     }
     if (!empty($dates)) {
         array_push($conditions, array("closingdate", "bw", $dates['start'] . ',' . $dates['end']));
     }
     $listSearchParams[] = $conditions;
     return '&search_params=' . json_encode($listSearchParams);
 }
Esempio n. 2
0
function getRequestedToData()
{
    $mail_data = array();
    $mail_data['user_id'] = $_REQUEST["task_assigned_user_id"];
    $mail_data['subject'] = $_REQUEST['task_subject'];
    $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus'];
    $mail_data['activity_mode'] = $_REQUEST['activity_mode'];
    $mail_data['taskpriority'] = $_REQUEST['taskpriority'];
    $mail_data['relatedto'] = $_REQUEST['task_parent_name'];
    $mail_data['contact_name'] = $_REQUEST['task_contact_name'];
    $mail_data['description'] = $_REQUEST['task_description'];
    $mail_data['assign_type'] = $_REQUEST['task_assigntype'];
    $mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']);
    $mail_data['mode'] = $_REQUEST['task_mode'];
    $startTime = $_REQUEST['task_time_start'];
    $date = new DateTimeField($_REQUEST['task_date_start'] . " " . $startTime);
    $endTime = $_REQUEST['task_time_end'];
    $endDate = new DateTimeField($_REQUEST['task_due_date'] . " " . $startTime);
    $startTime = $date->getDisplayTime();
    $endTime = $endDate->getDisplayTime();
    $value = getaddEventPopupTime($startTime, $endTime, '24');
    $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
    $mail_data['st_date_time'] = $date->getDisplayDateTimeValue();
    $mail_data['end_date_time'] = $endDate->getDisplayDate();
    return $mail_data;
}
function CustomerCommentFromPortal($entityData)
{
    $adb = PearDatabase::getInstance();
    $data = $entityData->getData();
    $customerWSId = $data['customer'];
    $relatedToWSId = $data['related_to'];
    $relatedToId = explode('x', $relatedToWSId);
    $moduleName = getSalesEntityType($relatedToId[1]);
    if ($moduleName == 'HelpDesk' && !empty($customerWSId)) {
        $ownerIdInfo = getRecordOwnerId($relatedToId[1]);
        if (!empty($ownerIdInfo['Users'])) {
            $ownerId = $ownerIdInfo['Users'];
            $ownerName = getOwnerName($ownerId);
            $toEmail = getUserEmailId('id', $ownerId);
        }
        if (!empty($ownerIdInfo['Groups'])) {
            $ownerId = $ownerIdInfo['Groups'];
            $groupInfo = getGroupName($ownerId);
            $ownerName = $groupInfo[0];
            $toEmail = implode(',', getDefaultAssigneeEmailIds($ownerId));
        }
        $subject = getTranslatedString('LBL_RESPONDTO_TICKETID', $moduleName) . "##" . $relatedToId[1] . "## " . getTranslatedString('LBL_CUSTOMER_PORTAL', $moduleName);
        $contents = getTranslatedString('Dear', $moduleName) . " " . $ownerName . "," . "<br><br>" . getTranslatedString('LBL_CUSTOMER_COMMENTS', $moduleName) . "<br><br>\n\t\t\t\t\t<b>" . $data['commentcontent'] . "</b><br><br>" . getTranslatedString('LBL_RESPOND', $moduleName) . "<br><br>" . getTranslatedString('LBL_REGARDS', $moduleName) . "<br>" . getTranslatedString('LBL_SUPPORT_ADMIN', $moduleName);
        $customerId = explode('x', $customerWSId);
        $result = $adb->pquery("SELECT email FROM vtiger_contactdetails WHERE contactid=?", array($customerId[0]));
        $fromEmail = $adb->query_result($result, 0, 'email');
        send_mail('HelpDesk', $toEmail, '', $fromEmail, $subject, $contents);
    }
}
 function getGroups($currentUserModel, $moduleName)
 {
     $groups = $currentUserModel->getAccessibleGroupForModule($moduleName);
     $groupIds = array_keys($groups);
     $groupsList = array();
     $groupsWSId = Mobile_WS_Utils::getEntityModuleWSId('Groups');
     foreach ($groupIds as $groupId) {
         $groupName = getGroupName($groupId);
         $groupsList[] = array('value' => $groupsWSId . 'x' . $groupId, 'label' => $groupName[0]);
     }
     return $groupsList;
 }
Esempio n. 5
0
 function getContent()
 {
     $result_content = '<div class="panel panel-default" style="padding: 15px; margin-top: 20px">
             <ol class="breadcrumb">
                 <li><a href="/do/admin">Home</a></li>
                 <li class="active">Users</li>
             </ol>
         <legend>Панель управления <small>Пользователи</small></legend>
         <table class="table table-striped table-condensed">
               <thead>
               <tr>
                   <th>ID</th>
                   <th>Username</th>
                   <th>Дата регистрации</th>
                   <th>Группа (уровень)</th>
                   <th>Действия</th>                                          
               </tr>
           </thead>   
           <tbody>
             ';
     global $bd;
     $res = $bd->query("SELECT * FROM users");
     $rows = $res->fetch_assoc();
     if ($res->num_rows == 0) {
         // Кто попадет в этот if - получит миллион
         $result_content .= '<div class="alert alert-warning" role="alert">Нет пользователей для вывода!</div>';
     }
     do {
         //$result_content .= '<tr>
         //        <td>'.$rows['id'].'</td>
         //        <td>'.$rows['title'].'</td>
         //        <td>'.$this->ClearStringHTML($rows['description']).'</td>
         //        <td class="text-center"><a class="btn btn-info btn-xs" href="/do/editnews/'.$rows['id'].'"><span class="glyphicon glyphicon-edit"></span> Edit</a> <a href="/do/delnews/'.$rows['id'].'" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span> Del</a></td>
         //    </tr>';
         $groupName = getGroupName($rows['login'], $bd);
         $result_content .= '<tr>
                 <td>' . $rows['id'] . '</td>
                 <td>' . $rows['login'] . '</td>
                 <td>' . $rows['date'] . '</td>
                 <td>' . $groupName . ' (' . $rows['group'] . ')</td>
                 <td class="text-center"><a class="btn btn-info btn-xs" href="/do/edituser/' . $rows['id'] . '"><span class="glyphicon glyphicon-edit"></span> Edit</a> <a href="/do/deluser/' . $rows['id'] . '" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span> Del</a></td>                                      
             </tr>';
     } while ($rows = $res->fetch_assoc());
     $result_content .= '</tbody></table></div>';
     return $result_content;
 }
function HelpDesk_notifyOnPortalTicketComment($entityData)
{
    $adb = PearDatabase::getInstance();
    $moduleName = $entityData->getModuleName();
    $wsId = $entityData->getId();
    $parts = explode('x', $wsId);
    $entityId = $parts[1];
    $ownerIdInfo = getRecordOwnerId($entityId);
    if (!empty($ownerIdInfo['Users'])) {
        $ownerId = $ownerIdInfo['Users'];
        $ownerName = getOwnerName($ownerId);
        $to_email = getUserEmailId('id', $ownerId);
    }
    if (!empty($ownerIdInfo['Groups'])) {
        $ownerId = $ownerIdInfo['Groups'];
        $groupInfo = getGroupName($ownerId);
        $ownerName = $groupInfo[0];
        $to_email = implode(',', getDefaultAssigneeEmailIds($ownerId));
    }
    $wsParentId = $entityData->get('contact_id');
    $parentIdParts = explode('x', $wsParentId);
    $parentId = $parentIdParts[1];
    $entityDelta = new VTEntityDelta();
    $oldComments = $entityDelta->getOldValue($entityData->getModuleName(), $entityId, 'comments');
    $newComments = $entityDelta->getCurrentValue($entityData->getModuleName(), $entityId, 'comments');
    $commentDiff = str_replace($oldComments, '', $newComments);
    $latestComment = strip_tags($commentDiff);
    //send mail to the assigned to user when customer add comment
    // SalesPlatform.ru begin
    $subject = getTranslatedString('LBL_RESPONDTO_TICKETID', $moduleName) . " " . $entityData->get('ticket_no') . " " . getTranslatedString('LBL_CUSTOMER_PORTAL', $moduleName);
    //$subject = getTranslatedString('LBL_RESPONDTO_TICKETID', $moduleName)."##". $entityId."##". getTranslatedString('LBL_CUSTOMER_PORTAL', $moduleName);
    // SalesPlatform.ru end
    $contents = getTranslatedString('Dear', $moduleName) . " " . $ownerName . "," . "<br><br>" . getTranslatedString('LBL_CUSTOMER_COMMENTS', $moduleName) . "<br><br>\n\t\t\t\t\t\t<b>" . $latestComment . "</b><br><br>" . getTranslatedString('LBL_RESPOND', $moduleName) . "<br><br>" . getTranslatedString('LBL_REGARDS', $moduleName) . "<br>" . getTranslatedString('LBL_SUPPORT_ADMIN', $moduleName);
    //get the contact email id who creates the ticket from portal and use this email as from email id in email
    $result = $adb->pquery("SELECT lastname, firstname, email FROM vtiger_contactdetails WHERE contactid=?", array($parentId));
    $customername = $adb->query_result($result, 0, 'firstname') . ' ' . $adb->query_result($result, 0, 'lastname');
    $customername = decode_html($customername);
    //Fix to display the original UTF-8 characters in sendername instead of ascii characters
    $from_email = $adb->query_result($result, 0, 'email');
    send_mail('HelpDesk', $to_email, '', $from_email, $subject, $contents);
}
 public static function generateRecipientOption($type, $value, $name = '')
 {
     switch ($type) {
         case "users":
             if (empty($name)) {
                 $name = getUserFullName($value);
             }
             $optionName = 'User::' . addslashes(decode_html($name));
             $optionValue = 'users::' . $value;
             break;
         case "groups":
             if (empty($name)) {
                 $groupInfo = getGroupName($value);
                 $name = $groupInfo[0];
             }
             $optionName = 'Group::' . addslashes(decode_html($name));
             $optionValue = 'groups::' . $value;
             break;
         case "roles":
             if (empty($name)) {
                 $name = getRoleName($value);
             }
             $optionName = 'Roles::' . addslashes(decode_html($name));
             $optionValue = 'roles::' . $value;
             break;
         case "rs":
             if (empty($name)) {
                 $name = getRoleName($value);
             }
             $optionName = 'RoleAndSubordinates::' . addslashes(decode_html($name));
             $optionValue = 'rs::' . $value;
             break;
     }
     return '<option value="' . $optionValue . '">' . $optionName . '</option>';
 }
Esempio n. 8
0
 public function getInviteUserMailData()
 {
     $adb = PearDatabase::getInstance();
     $return_id = $this->getId();
     $cont_qry = "select * from vtiger_cntactivityrel where activityid=?";
     $cont_res = $adb->pquery($cont_qry, array($return_id));
     $noofrows = $adb->num_rows($cont_res);
     $cont_id = array();
     if ($noofrows > 0) {
         for ($i = 0; $i < $noofrows; $i++) {
             $cont_id[] = $adb->query_result($cont_res, $i, "contactid");
         }
     }
     $cont_name = '';
     foreach ($cont_id as $key => $id) {
         if ($id != '') {
             $contact_name = Vtiger_Util_Helper::getRecordName($id);
             $cont_name .= $contact_name . ', ';
         }
     }
     $parentId = $this->get('parent_id');
     $parentName = '';
     if ($parentId != '') {
         $parentName = Vtiger_Util_Helper::getRecordName($parentId);
     }
     $cont_name = trim($cont_name, ', ');
     $mail_data = array();
     $mail_data['user_id'] = $this->get('assigned_user_id');
     $mail_data['subject'] = $this->get('subject');
     $moduleName = $this->getModuleName();
     $mail_data['status'] = $moduleName == 'Calendar' ? $this->get('taskstatus') : $this->get('eventstatus');
     $mail_data['activity_mode'] = $moduleName == 'Calendar' ? 'Task' : 'Events';
     $mail_data['taskpriority'] = $this->get('taskpriority');
     $mail_data['relatedto'] = $parentName;
     $mail_data['contact_name'] = $cont_name;
     $mail_data['description'] = $this->get('description');
     $mail_data['assign_type'] = $this->get('assigntype');
     $mail_data['group_name'] = getGroupName($this->get('assigned_user_id'));
     $mail_data['mode'] = $this->get('mode');
     //TODO : remove dependency on request;
     $value = getaddEventPopupTime($_REQUEST['time_start'], $_REQUEST['time_end'], '24');
     $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
     if ($_REQUEST['activity_mode'] != 'Task') {
         $end_hour = $value['endhour'] . ':' . $value['endmin'] . '' . $value['endfmt'];
     }
     $startDate = new DateTimeField($_REQUEST['date_start'] . " " . $start_hour);
     $endDate = new DateTimeField($_REQUEST['due_date'] . " " . $end_hour);
     $mail_data['st_date_time'] = $startDate->getDBInsertDateTimeValue();
     $mail_data['end_date_time'] = $endDate->getDBInsertDateTimeValue();
     $mail_data['location'] = $this->get('location');
     return $mail_data;
 }
Esempio n. 9
0
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar2" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
      </button>
    </div><!--/.navbar-header -->
    <p class="weekSelector-text">Your Picks for <?php 
echo "{$this_season_year} {$this_season_type} Week {$this_week}";
?>
</p>
    <div id="navbar2" class="navbar-collapse collapse weekSelector">
     <ul class="nav navbar-nav weekSelector">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php 
echo getGroupName($db, $this_group_id);
?>
 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li class="dropdown-header">Groups</li>
            <?php 
$groups = getGroups($db, $this_user_id);
foreach ($groups as $group) {
    echo '<li><a href="' . $THIS_PAGE . '?group_id=' . $group['group_id'] . '&season_year=' . $this_season_year . '&season_type=' . $this_season_type . '&week=' . $this_week . '">' . $group['group_name'] . '</a></li>';
}
?>
      
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php 
Esempio n. 10
0
								<?php 
            echo $warning;
            ?>
								<img src="<?php 
            echo ADMIN_URL;
            ?>
/images/modify_16.png" border="0" alt="Modify" /> 
								<img src="<?php 
            echo WB_URL . $slide['image'];
            ?>
" style="height:30px;"/>
							</a>
						</td>
						<td>
							<?php 
            echo getGroupName($slide['group_id']);
            ?>
						</td>
						<td>
							<b><?php 
            if ($slide['active'] == 1) {
                echo '<span style="color: green;">' . $WB_TEXT['YES'] . '</span>';
            } else {
                echo '<span style="color: red;">' . $WB_TEXT['NO'] . '</span>';
            }
            ?>
</b>
						</td>
						<td>
							<a href="javascript: confirm_link('<?php 
            echo $TEXT['ARE_YOU_SURE'];
Esempio n. 11
0
function getRequestData($return_id)
{
    global $adb;
    $cont_qry = "select * from vtiger_cntactivityrel where activityid=?";
    $cont_res = $adb->pquery($cont_qry, array($return_id));
    $noofrows = $adb->num_rows($cont_res);
    $cont_id = array();
    if ($noofrows > 0) {
        for ($i = 0; $i < $noofrows; $i++) {
            $cont_id[] = $adb->query_result($cont_res, $i, "contactid");
        }
    }
    $cont_name = '';
    foreach ($cont_id as $key => $id) {
        if ($id != '') {
            $displayValueArray = getEntityName('Contacts', $id);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $field_value) {
                    $contact_name = $field_value;
                }
            }
            $cont_name .= $contact_name . ', ';
        }
    }
    $cont_name = trim($cont_name, ', ');
    $mail_data = array();
    $mail_data['user_id'] = $_REQUEST['assigned_user_id'];
    $mail_data['subject'] = $_REQUEST['subject'];
    $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus'];
    $mail_data['activity_mode'] = $_REQUEST['activity_mode'];
    $mail_data['taskpriority'] = $_REQUEST['taskpriority'];
    $mail_data['relatedto'] = $_REQUEST['parent_name'];
    $mail_data['contact_name'] = $cont_name;
    $mail_data['description'] = $_REQUEST['description'];
    $mail_data['assign_type'] = $_REQUEST['assigntype'];
    $mail_data['group_name'] = getGroupName($_REQUEST['assigned_group_id']);
    $mail_data['mode'] = $_REQUEST['mode'];
    $value = getaddEventPopupTime($_REQUEST['time_start'], $_REQUEST['time_end'], '24');
    $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
    if ($_REQUEST['activity_mode'] != 'Task') {
        $end_hour = $value['endhour'] . ':' . $value['endmin'] . '' . $value['endfmt'];
    }
    $startDate = new DateTimeField($_REQUEST['date_start'] . " " . $start_hour);
    $endDate = new DateTimeField($_REQUEST['due_date'] . " " . $end_hour);
    $mail_data['st_date_time'] = $startDate->getDBInsertDateTimeValue();
    $mail_data['end_date_time'] = $endDate->getDBInsertDateTimeValue();
    $mail_data['location'] = vtlib_purify($_REQUEST['location']);
    return $mail_data;
}
}
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/project:view', $context);
$PAGE->set_url('/mod/project/workload_distribution.php', array('id' => $cm->id));
$PAGE->set_title($course->shortname . ': ' . $project->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_activity_record($project);
$options = empty($project->displayoptions) ? array() : unserialize($project->displayoptions);
/// Check to see if groups are being used here
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string('Workload Distribution'), 2);
echo $OUTPUT->heading(format_string(getGroupName($currentgroup)), 4);
//$html = "<img src='pix\\".$history_summary->method.".png' width='16px' heigh='16px' />  ".userdate($history_summary->date)."<br /><br />";
$member_rank = RankMembersTasksDistribution($currentgroup);
//echo AlertMembersTasksDistribution($member_rank);
arsort($member_rank);
//Order the Rank by number of hours
//Get the total number of hours based on each student
$total_hours = array_sum($member_rank);
if ($total_hours > 0) {
    $equal_hours = $total_hours / count($member_rank);
    $html = "Individual Recommended Hours: " . round($equal_hours, 2) . " Hours<br /><br />";
    //If large variance occurs, display column for table
    if (AlertWorkloadDistribution($currentgroup)) {
        $html .= "<table style='border:1px solid black;'><tr style='background-color:lightgrey;'><th>Member</th><th>Assigned Hours</th><th>% of Workload</th><th>Variance</th></tr>";
    } else {
        $html .= "<table style='border:1px solid black;'><tr style='background-color:lightgrey;'><th>Member</th><th>Assigned Hours</th><th>% of Workload</th><th></th></tr>";
Esempio n. 13
0
      <?php 
    renderGroupList($db, $group, $groupLeader);
    ?>

      <?php 
    if ($groupLeader == 1) {
        ?>
        <a class="button right" href="#" onclick="alert('Group leader cant leave the group - set someone else as leader first.');">Leave Group</a>
      <?php 
    } else {
        ?>
        <a class="button right" href="/?page=group&amp;action=remove&amp;user=<?php 
        echo $userId;
        ?>
" onclick="return confirm('Leave <?php 
        echo getGroupName($group, $db);
        ?>
?')">Leave Group</a>
      <?php 
    }
    ?>
      <a class="button left" href="/">Back Home</a>
      <?php 
}
// end if
?>
    </div>
    <?php 
include 'footer.php';
?>
  </main>
Esempio n. 14
0
 public function getAssignedTo($scannerId, $ruleId)
 {
     $db = PearDatabase::getInstance();
     $result = $db->pquery("SELECT assigned_to FROM vtiger_mailscanner_rules WHERE scannerid = ? AND ruleid = ?", array($scannerId, $ruleId));
     $id = $db->query_result($result, 0, 'assigned_to');
     if (empty($id)) {
         global $current_user;
         $id = $current_user->id;
     }
     $assignedUserName = getUserFullName($id);
     if (empty($assignedUserName)) {
         $groupInfo = getGroupName($id);
         $assignedUserName = $groupInfo[0];
     }
     return array($id, $assignedUserName);
 }
Esempio n. 15
0
/** To get the converted record values which have to be display in duplicates merging tpl*/
function getRecordValues($id_array, $module)
{
    global $adb, $current_user;
    global $app_strings;
    global $mod_strings;
    $tabid = getTabid($module);
    $query = "select fieldname,fieldlabel from ec_field where tabid=" . $tabid . " and fieldname  not in ('createdtime','modifiedtime')";
    $result = $adb->query($query);
    $no_rows = $adb->num_rows($result);
    for ($i = 0; $i < $no_rows; $i++) {
        $fld_name = $adb->query_result($result, $i, "fieldname");
        if (getFieldVisibilityPermission($module, $current_user->id, $fld_name) == '0') {
            $fld_array[] = $fld_name;
        }
    }
    $js_arr = $fld_array;
    $focus = new $module();
    if (isset($id_array) && $id_array != '') {
        foreach ($id_array as $value) {
            $focus->id = $value;
            $focus->retrieve_entity_info($value, $module);
            $field_values[] = $focus->column_fields;
        }
    }
    $tabid = getTabid($module);
    $query = "select fieldname,uitype,fieldlabel from ec_field where tabid=" . $tabid . " and fieldname not in ('createdtime','modifiedtime','lastcontacttime')";
    $result = $adb->query($query);
    $no_rows = $adb->num_rows($result);
    $labl_array = array();
    $value_pair = array();
    $c = 0;
    for ($i = 0; $i < $no_rows; $i++) {
        $fld_name = $adb->query_result($result, $i, "fieldname");
        $fld_label = $adb->query_result($result, $i, "fieldlabel");
        if (isset($mod_strings[$fld_label])) {
            $fld_label = $mod_strings[$fld_label];
        }
        $ui_type = $adb->query_result($result, $i, "uitype");
        if (getFieldVisibilityPermission($module, $current_user->id, $fld_name) == '0') {
            $record_values[$c][$fld_label] = array();
            $ui_value[] = $ui_type;
            for ($j = 0; $j < count($field_values); $j++) {
                if ($ui_type == 56) {
                    if ($field_values[$j][$fld_name] == 0) {
                        $value_pair['disp_value'] = $app_strings['no'];
                    } else {
                        $value_pair['disp_value'] = $app_strings['yes'];
                    }
                } elseif ($ui_type == 51 || $ui_type == 50) {
                    $account_id = $field_values[$j][$fld_name];
                    $account_name = getAccountName($account_id);
                    $value_pair['disp_value'] = $account_name;
                } elseif ($ui_type == 53) {
                    $user_id = $field_values[$j][$fld_name];
                    $username = getUserName($user_id);
                    $group_info = getGroupName($field_values[$j]['record_id'], $module);
                    $groupname = $group_info[0];
                    $groupid = $group_info[1];
                    if ($user_id != 0) {
                        $value_pair['disp_value'] = $username;
                    } else {
                        $value_pair['disp_value'] = $groupname;
                    }
                } elseif ($ui_type == 57) {
                    $contact_id = $field_values[$j][$fld_name];
                    if ($contact_id != '') {
                        $contactname = getContactName($contact_id);
                    }
                    $value_pair['disp_value'] = $contactname;
                } elseif ($ui_type == 75 || $ui_type == 81) {
                    $vendor_id = $field_values[$j][$fld_name];
                    if ($vendor_id != '') {
                        $vendor_name = getVendorName($vendor_id);
                    }
                    $value_pair['disp_value'] = $vendor_name;
                } elseif ($ui_type == 52) {
                    $user_id = $field_values[$j][$fld_name];
                    $user_name = getUserName($user_id);
                    $value_pair['disp_value'] = $user_name;
                } elseif ($ui_type == 68) {
                    $parent_id = $field_values[$j][$fld_name];
                    $value_pair['disp_value'] = getAccountName($parent_id);
                    if ($value_pair['disp_value'] == '' || $value_pair['disp_value'] == NULL) {
                        $value_pair['disp_value'] = getContactName($parent_id);
                    }
                } elseif ($ui_type == 59) {
                    $product_name = getProductName($field_values[$j][$fld_name]);
                    if ($product_name != '') {
                        $value_pair['disp_value'] = $product_name;
                    } else {
                        $value_pair['disp_value'] = '';
                    }
                } elseif ($ui_type == 58) {
                    $campaign_name = getCampaignName($field_values[$j][$fld_name]);
                    if ($campaign_name != '') {
                        $value_pair['disp_value'] = $campaign_name;
                    } else {
                        $value_pair['disp_value'] = '';
                    }
                } else {
                    $value_pair['disp_value'] = $field_values[$j][$fld_name];
                }
                $value_pair['org_value'] = $field_values[$j][$fld_name];
                array_push($record_values[$c][$fld_label], $value_pair);
            }
            $c++;
        }
    }
    $parent_array[0] = $record_values;
    $parent_array[1] = $js_arr;
    $parent_array[2] = $fld_array;
    return $parent_array;
}
Esempio n. 16
0
          </span></div>
        <?php 
                    }
                    ?>
        <div class="section-blog">
          <div class="section">Раздел:</div>
          <?php 
                    seo_start();
                    ?>
          <div class="small"> <a href="<?php 
                    echo getFriendlyURL("blog_group", $theme['id_gr']);
                    echo $theme['t'] ? "?t=prof" : "";
                    ?>
">
            <?php 
                    echo getGroupName($theme['id_gr'], $theme['t']);
                    ?>
            </a> </div>
        </div>
        <?php 
                    echo seo_end();
                    ?>
        <div class="commline">
          <?php 
                    if (!$mod && $theme['deleted']) {
                        ?>
          <a href="/blogs/viewgroup.php?id=<?php 
                        echo $theme['id'];
                        ?>
&amp;action=restore&page=<?php 
                        echo $page;
Esempio n. 17
0
 ********************************************************************************/
global $app_strings, $mod_strings, $current_language, $currentModule, $theme, $current_user, $adb, $log;
require_once 'Smarty_setup.php';
require_once 'modules/Webforms/Webforms.php';
require_once 'modules/Webforms/model/WebformsModel.php';
require_once 'modules/Webforms/model/WebformsFieldModel.php';
require_once 'include/utils/CommonUtils.php';
Webforms::checkAdminAccess($current_user);
if (isset($_REQUEST['id'])) {
    $webformModel = Webforms_Model::retrieveWithId($_REQUEST['id']);
    $webform = new Webforms();
    $smarty = new vtigerCRM_Smarty();
    $category = getParentTab();
    $username = getUserFullName($webformModel->getOwnerId());
    if (empty($username)) {
        list($username) = getGroupName($webformModel->getOwnerId());
    }
    $smarty->assign('WEBFORMMODEL', $webformModel);
    $smarty->assign('WEBFORM', $webform);
    $smarty->assign('OWNER', $username);
    $smarty->assign('THEME', $theme);
    $smarty->assign('MOD', $mod_strings);
    $smarty->assign('APP', $app_strings);
    $smarty->assign('MODULE', $currentModule);
    $smarty->assign('CATEGORY', $category);
    $smarty->assign('IMAGE_PATH', "themes/{$theme}/images/");
    $smarty->assign('WEBFORMFIELDS', Webforms::getFieldInfos($webformModel->getTargetModule()));
    $smarty->assign('ACTIONPATH', $site_URL . '/modules/Webforms/capture.php');
    $smarty->assign('LANGUAGE', $current_language);
    $smarty->display(vtlib_getModuleTemplate($currentModule, 'DetailView.tpl'));
}
Esempio n. 18
0
 function out()
 {
     $groupId = $_GET['id'];
     $userId = $this->mid;
     if (!empty($groupId) && !empty($userId)) {
         $dao = D('GroupMember');
         $user = $dao->find("userId='{$userId}' and groupId='{$groupId}'");
         if ($user->level == 2) {
             $this->error("管理员不能直接退出群!", -1);
         }
         if ($dao->delete("userId='{$userId}' and groupId='{$groupId}'")) {
             /* add_user_feed */
             $feedTitle = "退出了群:<a href=\"/Group/show/id/{$groupId}\">" . getGroupName($groupId) . "</a>";
             $this->addUserFeed($userId, 'out', 'group', $groupId, $feedTitle);
             /* /add_user_feed */
             $this->success("操作成功,你已退出该圈子。", 1);
         } else {
             $this->error("系统错误!请稍后再试。", 0);
         }
     } else {
         $this->error("操作错误!请登陆后选择要退出的办公圈。");
     }
 }
Esempio n. 19
0
 public function getReportHeaderInfo($noofrows = 0)
 {
     $final_return = $return = $return_name = $return_val = "";
     $return_arr = $col_order_arr = $summ_order_arr = array();
     $colspan = 2;
     global $default_charset;
     if (isset($this->reportinformations["reports4youid"]) && $this->reportinformations["reports4youid"] != "") {
         /*
          if (isset($this->reportinformations["reports4youid"]) && $this->reportinformations["reports4youid"] != "") {
          $return_val = $this->reportinformations["reports4youname"];
          } else {
          $return_val = vtranslate("LBL_REPORT_NAME", $this->currentModule);
          }
          $return_arr["reportname"] =  array("val"=>$return_val,"colspan"=>$colspan);
         */
         $return_val = "<b>" . vtranslate("LBL_Module", $this->currentModule) . ": </b>";
         $primarymodule_id = $this->reportinformations["primarymodule"];
         $primarymodule = vtlib_getModuleNameById($primarymodule_id);
         $return_val .= vtranslate($primarymodule, $primarymodule);
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_TOTAL", $this->currentModule) . ": </b><span id='_reportrun_total'>{$noofrows}</span> " . vtranslate("LBL_RECORDS", "ITS4YouReports");
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_TEMPLATE_OWNER", $this->currentModule) . ": </b>";
         $return_val .= getUserFullName($this->reportinformations["owner"]);
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_GroupBy", $this->currentModule) . ": </b>";
         for ($gi = 1; $gi < 4; $gi++) {
             if (isset($this->reportinformations["Group{$gi}"]) && $this->reportinformations["Group{$gi}"] != "" && $this->reportinformations["Group{$gi}"] != "none") {
                 $group_col_info = array();
                 // columns visibility control !!!!!!
                 if ($this->getColumnVisibilityPerm($this->reportinformations["Group{$gi}"]) == 0) {
                     $gp_column_lbl = $this->getColumnStr_Label($this->reportinformations["Group{$gi}"], "SC");
                     $group_col_info[] = $gp_column_lbl;
                     $group_col_info[] = vtranslate($this->reportinformations["Sort{$gi}"]);
                     if (isset($this->reportinformations["timeline_columnstr{$gi}"]) && $this->reportinformations["timeline_columnstr{$gi}"] != "" && $this->reportinformations["timeline_columnstr{$gi}"] != "@vlv@") {
                         $tr_arr = explode("@vlv@", $this->reportinformations["timeline_columnstr{$gi}"]);
                         $tl_option = "TL_" . $tr_arr[1];
                         $group_col_info[] = vtranslate("LBL_BY", $this->currentModule);
                         $group_col_info[] = vtranslate($tl_option, $this->currentModule);
                     }
                     $group_cols[] = implode(" ", $group_col_info);
                 }
             }
         }
         if (empty($group_cols)) {
             $group_cols[] = vtranslate("LBL_NONE", $this->currentModule);
         }
         $return_val .= implode(", ", $group_cols);
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_Sharing", $this->currentModule) . ": </b>";
         if (isset($this->reportinformations["sharingtype"]) && $this->reportinformations["sharingtype"] != "") {
             $sharingtype = vtranslate($this->reportinformations["sharingtype"]);
         }
         $sharing_with = "";
         if ($this->reportinformations["sharingtype"] == "share") {
             $sharingMemberArray = $this->reportinformations["members_array"];
             $sharingMemberArray = array_unique($sharingMemberArray);
             if (count($sharingMemberArray) > 0) {
                 $outputMemberArr = array();
                 foreach ($sharingMemberArray as $setype => $shareIdArr) {
                     $shareIdArr = explode("::", $shareIdArr);
                     $shareIdArray[$shareIdArr[0]] = $shareIdArr[1];
                     foreach ($shareIdArray as $shareType => $shareId) {
                         switch ($shareType) {
                             case "groups":
                                 $groupName_array = getGroupName($shareId);
                                 $memberName = $groupName_array[0];
                                 $memberDisplay = "Group::";
                                 break;
                             case "roles":
                                 $memberName = getRoleName($shareId);
                                 $memberDisplay = "Roles::";
                                 break;
                             case "rs":
                                 $memberName = getRoleName($shareId);
                                 $memberDisplay = "RoleAndSubordinates::";
                                 break;
                             case "users":
                                 $memberName = getUserName($shareId);
                                 $memberDisplay = "User::";
                                 break;
                         }
                         // $outputMemberArr[] = $shareType."::".$shareId;
                         $outputMemberArr[] = $memberDisplay . $memberName;
                     }
                 }
                 $outputMemberArr = array_unique($outputMemberArr);
             }
             if (!empty($outputMemberArr)) {
                 $sharing_with = " (" . implode(", ", $outputMemberArr) . ")";
             }
         }
         $return_val .= $sharingtype . $sharing_with;
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_Schedule", $this->currentModule) . ": </b>";
         $adb = PearDatabase::getInstance();
         require_once 'modules/ITS4YouReports/ScheduledReports4You.php';
         $scheduledReport = new ITS4YouScheduledReport($adb, $this->current_user, $this->record);
         $scheduledReport->getReportScheduleInfo();
         $is_scheduled = $scheduledReport->isScheduled;
         $schedule_info = "";
         $scheduled_arr = array(1 => "HOURLY", 2 => "DAILY", 3 => "WEEKLY", 4 => "BIWEEKLY", 5 => "MONTHLY", 6 => "ANNUALLY");
         if ($is_scheduled) {
             $schtypeid = $scheduledReport->scheduledInterval["scheduletype"];
             // $schedule_info_arr[] = vtranslate("LBL_SCHEDULE_EMAIL", $this->currentModule);
             $schedulerFormatArr = explode(";", $scheduledReport->scheduledFormat);
             if (!empty($schedulerFormatArr)) {
                 foreach ($schedulerFormatArr as $format_str) {
                     $translated_schedulerFormat[] = vtranslate($format_str, $this->currentModule);
                 }
             }
             // $schedule_info_arr[] = $scheduledReport->scheduledFormat;
             $schedule_info_arr[] = implode(", ", $translated_schedulerFormat);
             $schedule_info_arr[] = vtranslate($scheduled_arr[$schtypeid], $this->currentModule);
             $schtime = $scheduledReport->scheduledInterval['time'];
             $schday = $scheduledReport->scheduledInterval['day'];
             $schweek = $scheduledReport->scheduledInterval['day'];
             $schmonth = $scheduledReport->scheduledInterval['month'];
             $WEEKDAY_STRINGS = vtranslate("WEEKDAY_STRINGS", $this->currentModule);
             $MONTH_STRINGS = vtranslate("MONTH_STRINGS", $this->currentModule);
             switch ($schtypeid) {
                 case 1:
                     $schedule_info_arr[] = vtranslate("LBL_SCH_AT", $this->currentModule) . " {$schtime}";
                     break;
                 case 2:
                     $schedule_info_arr[] = vtranslate("LBL_SCH_AT", $this->currentModule) . " {$schtime}";
                     break;
                 case 3:
                     $schedule_info_arr[] = vtranslate("LBL_SCH_ON", $this->currentModule) . " " . $WEEKDAY_STRINGS[$schday];
                     $schedule_info_arr[] = vtranslate("LBL_SCH_AT", $this->currentModule) . " {$schtime}";
                     break;
                 case 4:
                     $schedule_info_arr[] = vtranslate("LBL_SCH_ON", $this->currentModule) . " " . $WEEKDAY_STRINGS[$schday];
                     $schedule_info_arr[] = vtranslate("LBL_SCH_AT", $this->currentModule) . " {$schtime}";
                     break;
                 case 5:
                     $schedule_info_arr[] = vtranslate("LBL_SCH_ON", $this->currentModule) . " {$schday}. " . vtranslate("LBL_SCHEDULE_EMAIL_DAY", $this->currentModule);
                     $schedule_info_arr[] = vtranslate("LBL_SCH_AT", $this->currentModule) . " {$schtime}";
                     break;
                 case 6:
                     $schedule_info_arr[] = vtranslate("LBL_SCH_IN", $this->currentModule) . " " . $MONTH_STRINGS[$schmonth];
                     $schedule_info_arr[] = vtranslate("LBL_SCH_ON", $this->currentModule) . " {$schday}. " . vtranslate("LBL_SCHEDULE_EMAIL_DAY", $this->currentModule);
                     $schedule_info_arr[] = vtranslate("LBL_SCH_AT", $this->currentModule) . " {$schtime}";
                     break;
             }
             $schedule_info = implode(" ", $schedule_info_arr);
         } else {
             $schedule_info = vtranslate("LBL_NONE", $this->currentModule);
         }
         $return_val .= $schedule_info;
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_LIMIT", $this->currentModule) . ": </b>";
         if (!empty($this->reportinformations["summaries_columns"])) {
             $return_val .= vtranslate("LBL_Summaries", $this->currentModule) . " ";
             if (isset($this->reportinformations["summaries_limit"]) && $this->reportinformations["summaries_limit"] != "0") {
                 $summ_limit_str = $this->reportinformations["summaries_limit"] . " " . vtranslate("LBL_RECORDS", $this->currentModule);
             } else {
                 $summ_limit_str = vtranslate("LBL_ALL", $this->currentModule) . " " . strtolower(vtranslate("LBL_RECORDS", $this->currentModule));
             }
             $return_val .= $summ_limit_str;
             if ($this->reportinformations["selectedColumnsString"] != "") {
                 $return_val .= ", " . vtranslate("LBL_Details", $this->currentModule) . " ";
             }
         }
         if ($this->reportinformations["selectedColumnsString"] != "") {
             if (isset($this->reportinformations["columns_limit"]) && $this->reportinformations["columns_limit"] != "0") {
                 $limit_str = $this->reportinformations["columns_limit"] . " " . vtranslate("LBL_RECORDS", $this->currentModule);
             } else {
                 $limit_str = vtranslate("LBL_ALL", $this->currentModule) . " " . strtolower(vtranslate("LBL_RECORDS", $this->currentModule));
             }
             $return_val .= $limit_str;
         }
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_CHART_INFO", $this->currentModule) . ": </b>";
         $ch_column_populated = false;
         $new_ch_info = $n_ch_info = $ch_column_str = "";
         if (!empty($this->reportinformations["charts"])) {
             foreach ($this->reportinformations["charts"] as $chi => $ch_array) {
                 $ch_type = $ch_array["charttype"];
                 if ($ch_column_populated != true) {
                     if ($ch_array["x_group"] == "group1") {
                         $ch_column_lbl = GenerateObj::getHeaderLabel($this->record, "SC", "", $this->reportinformations["Group1"]);
                         if (is_array($ch_column_lbl) && $ch_column_lbl["lbl"] != "") {
                             $ch_column_lbl = $ch_column_lbl["lbl"];
                         }
                         $ch_column[] = $ch_column_lbl;
                     } elseif ($ch_array["x_group"] == "group2") {
                         $ch_column_lbl = GenerateObj::getHeaderLabel($this->record, "SC", "", $this->reportinformations["Group1"]);
                         if (is_array($ch_column_lbl) && $ch_column_lbl["lbl"] != "") {
                             $ch_column_lbl = $ch_column_lbl["lbl"];
                         }
                         $ch_column[] = $ch_column_lbl;
                         $ch_column_lbl = GenerateObj::getHeaderLabel($this->record, "SC", "", $this->reportinformations["Group1"]);
                         if (is_array($ch_column_lbl) && $ch_column_lbl["lbl"] != "") {
                             $ch_column_lbl = $ch_column_lbl["lbl"];
                         }
                         $ch_column[] = $ch_column_lbl;
                     }
                     $ch_column_str = implode(", ", $ch_column);
                     $ch_column_populated = true;
                 }
                 $ch_dataseries = GenerateObj::getHeaderLabel($this->record, "SM", "", $ch_array["dataseries"]);
                 if (is_array($ch_dataseries) && $ch_dataseries["lbl"] != "") {
                     $ch_dataseries = $ch_dataseries["lbl"];
                 }
                 $n_ch_info[] = vtranslate("LBL_CHART_{$ch_type}", $this->currentModule) . " " . vtranslate("LBL_CHART", $this->currentModule) . " ({$ch_dataseries})";
             }
             $new_ch_info = vtranslate("LBL_CHART_DataSeries", $this->currentModule) . " " . $ch_column_str . " [" . implode(", ", $n_ch_info) . "]";
         } else {
             $new_ch_info = " <small><i>(" . vtranslate("LBL_NO_CHARTS", $this->currentModule) . ")</i></small>";
         }
         $return_val .= $new_ch_info;
         /*
          if(isset($this->reportinformations["charts"]) && $this->reportinformations["charts"]["charttype"]=="" && isset($this->reportinformations["charts"]["dataseries"]) && $this->reportinformations["charts"]["dataseries"]!=""){
          $ch_info = " <small><i>(".vtranslate("LBL_NO_CHARTS", $this->currentModule).")</i></small>";
          }elseif(isset($this->reportinformations["Group1"]) && $this->reportinformations["Group1"]!="none" && isset($this->reportinformations["charts"]) && $this->reportinformations["charts"]["charttype"]!="none" && isset($this->reportinformations["charts"]["dataseries"]) && $this->reportinformations["charts"]["dataseries"]!=""){
          // columns visibility control !!!!!!
          if($this->getColumnVisibilityPerm($this->reportinformations["Group1"])==0 && $this->getColumnVisibilityPerm($this->reportinformations["charts"]["dataseries"])==0){
          $ch_column = GenerateObj::getHeaderLabel($this->record,"SC","",$this->reportinformations["Group1"]);
          if(is_array($ch_column) && $ch_column["lbl"]!=""){
          $ch_column = $ch_column["lbl"];
          }
          $ch_dataseries = GenerateObj::getHeaderLabel($this->record,"SM","",$this->reportinformations["charts"]["dataseries"]);
          if(is_array($ch_dataseries) && $ch_dataseries["lbl"]!=""){
          $ch_dataseries = $ch_dataseries["lbl"];
          }
          $ch_type = $this->reportinformations["charts"]["charttype"];
          $ch_info = vtranslate("LBL_CHART_$ch_type", $this->currentModule)." ".vtranslate("LBL_CHART", $this->currentModule)." ($ch_column, $ch_dataseries)";
          }
          }else{
          $ch_info = " <small><i>(".vtranslate("LBL_CHARE", $this->currentModule)." ".vtranslate("LBL_IGNORED", $this->currentModule)."!)</i></small>";
          }
          $return_val .= $ch_info;
         */
         $return_arr[] = array("val" => $return_val, "colspan" => "");
         $return_val = "<b>" . vtranslate("LBL_Columns", $this->currentModule) . ": </b>";
         $col_order_str = "";
         if (isset($this->reportinformations["selectedColumnsString"]) && $this->reportinformations["selectedColumnsString"] != "") {
             $selected_column_string = $this->reportinformations["selectedColumnsString"];
             $selected_column_array = explode(";", html_entity_decode($selected_column_string, ENT_QUOTES, $default_charset));
             if (!empty($selected_column_array)) {
                 foreach ($selected_column_array as $column_str) {
                     if ($column_str != "" && $column_str != "none") {
                         // columns visibility control !!!!!!
                         if ($this->getColumnVisibilityPerm($column_str) == 0) {
                             $column_lbl = $this->getColumnStr_Label($column_str, "SC");
                             $columns[] = $column_lbl;
                         }
                     }
                 }
             }
             if (isset($this->reportinformations["SortByColumn"]) && $this->reportinformations["SortByColumn"] != "none") {
                 $col_order_arr[] = vtranslate("LBL_SORT_FIELD", $this->currentModule);
                 $col_order_column = $this->getColumnStr_Label($this->reportinformations["SortByColumn"], "SC");
                 $col_order_arr[] = $col_order_column;
                 if ($this->reportinformations["SortOrderColumn"] == "DESC") {
                     $col_order_arr[] = vtranslate("Descending");
                 } else {
                     $col_order_arr[] = vtranslate("Ascending");
                 }
                 $col_order_str = implode(" ", $col_order_arr);
             }
         }
         if (empty($columns)) {
             $columns[] = vtranslate("LBL_NONE", $this->currentModule);
         }
         $return_val .= implode(", ", $columns);
         if ($this->reportinformations["timeline_type2"] == "cols" || $this->reportinformations["timeline_type3"] == "cols") {
             $return_val .= " <small><i>(" . vtranslate("LBL_NOT_A", $this->currentModule) . " " . vtranslate("LBL_IGNORED", $this->currentModule) . "!)</i></small>";
         }
         if ($col_order_str != "") {
             $return_val .= " ({$col_order_str})";
         }
         $return_arr[] = array("val" => $return_val, "colspan" => "2");
         $return_val = "<b>" . vtranslate("LBL_SummariesColumns", $this->currentModule) . ": </b>";
         $summ_order_str = "";
         if (isset($this->reportinformations["summaries_columns"]) && !empty($this->reportinformations["summaries_columns"])) {
             foreach ($this->reportinformations["summaries_columns"] as $column_arr) {
                 $column_str = $column_arr["columnname"];
                 // columns visibility control !!!!!!
                 if ($this->getColumnVisibilityPerm($column_str) == 0) {
                     $sm_column_lbl = $this->getColumnStr_Label($column_str, "SM");
                     $summaries_columns[] = $sm_column_lbl;
                 }
             }
             if (isset($this->reportinformations["summaries_orderby_columns"]) && !empty($this->reportinformations["summaries_orderby_columns"])) {
                 if ($this->reportinformations["summaries_orderby_columns"][0]["column"] != "none") {
                     $summ_order_arr[] = vtranslate("LBL_SORT_FIELD", $this->currentModule);
                     $summ_order_column = $this->getColumnStr_Label($this->reportinformations["summaries_orderby_columns"][0]["column"], "SM");
                     $summ_order_arr[] = $summ_order_column;
                     if ($this->reportinformations["summaries_orderby_columns"][0]["type"] == "DESC") {
                         $summ_order_arr[] = vtranslate("Descending");
                     } else {
                         $summ_order_arr[] = vtranslate("Ascending");
                     }
                     $summ_order_str = implode(" ", $summ_order_arr);
                 }
             }
         }
         if (empty($summaries_columns)) {
             $summaries_columns[] = vtranslate("LBL_NONE", $this->currentModule);
         }
         $return_val .= implode(", ", $summaries_columns);
         if ($summ_order_str != "") {
             $return_val .= " ({$summ_order_str})";
         }
         $return_arr[] = array("val" => $return_val, "colspan" => "2");
         $return_val = "<b>" . vtranslate("LBL_Filters", $this->currentModule) . ": </b>";
         $std_filter_columns = $this->getStdFilterColumns();
         if (isset($_REQUEST["reload"])) {
             $tmp = $this->getAdvanceFilterOptionsJSON($this->primarymodule);
             $criteria_columns = $this->getRequestCriteria($this->adv_sel_fields);
             if (!empty($criteria_columns)) {
                 if (isset($_REQUEST["reload"])) {
                     foreach ($criteria_columns as $group_id => $group_arr) {
                         $criteria_columns = $group_arr["columns"];
                         if (!empty($criteria_columns)) {
                             foreach ($criteria_columns as $criteria_groups_arr) {
                                 if ($criteria_groups_arr["columnname"] != "") {
                                     // columns visibility control !!!!!!
                                     if ($this->getColumnVisibilityPerm($criteria_groups_arr["columnname"]) == 0) {
                                         $column_condition = "";
                                         if ($criteria_groups_arr["column_condition"] != "") {
                                             $column_condition = $criteria_groups_arr["column_condition"];
                                         }
                                         if (in_array($criteria_groups_arr["columnname"], $std_filter_columns)) {
                                             $comparator = $criteria_groups_arr["comparator"];
                                             $comparator_val = $this->Date_Filter_Values[$comparator];
                                             $comparator_info = vtranslate($comparator_val, $this->currentModule);
                                             if ($comparator == "custom") {
                                                 $comparator_info_arr = explode("<;@STDV@;>", html_entity_decode(trim($criteria_groups_arr["value"]), ENT_QUOTES, $default_charset));
                                                 if ($comparator_info_arr[0] != "" && $comparator_info_arr[1] != "") {
                                                     $comparator_info .= vtranslate("BETWEEN", $this->currentModule) . " ";
                                                     $comparator_info .= $comparator_info_arr[0] . " ";
                                                     $comparator_info .= vtranslate("LBL_AND", $this->currentModule) . " ";
                                                     $comparator_info .= $comparator_info_arr[1];
                                                 } elseif ($comparator_info_arr[0] != "") {
                                                     $comparator_info .= vtranslate("LBL_IS", $this->currentModule) . " ";
                                                     $comparator_info .= $comparator_info_arr[0];
                                                 } elseif ($comparator_info_arr[1] != "") {
                                                     $comparator_info .= vtranslate("LBL_IS", $this->currentModule) . " ";
                                                     $comparator_info .= $comparator_info_arr[1];
                                                 }
                                             }
                                             $criteria_info_value = "";
                                         } else {
                                             $comparator = self::$adv_filter_options[$criteria_groups_arr["comparator"]];
                                             $comparator_info = vtranslate($comparator, $this->currentModule);
                                             $criteria_info_value = $criteria_groups_arr["value"];
                                         }
                                         $ft_column_lbl = $this->getColumnStr_Label($criteria_groups_arr["columnname"]);
                                         $condition_info = $ft_column_lbl . " " . $comparator_info . " " . $criteria_info_value . " " . $column_condition;
                                         $conditions_arr[$group_id][] = $condition_info;
                                     }
                                 }
                             }
                         }
                         $group_conditions[$group_id] = $group_arr["condition"];
                     }
                 }
             }
         } else {
             $criteria_columns = $this->reportinformations["advft_criteria"];
             $criteria_groups = $this->reportinformations["advft_criteria_groups"];
             if (!empty($criteria_groups) && !empty($criteria_columns)) {
                 foreach ($criteria_groups as $criteria_groups_arr) {
                     $group_id = $criteria_groups_arr["groupid"];
                     $group_condition = $criteria_groups_arr["group_condition"];
                     $group_conditions[$group_id] = $group_condition;
                 }
                 foreach ($criteria_columns as $criteria_groups_arr) {
                     if ($criteria_groups_arr["columnname"] != "") {
                         // filter columns and values visibility control !!!!!! start
                         if ($this->getColumnVisibilityPerm($criteria_groups_arr["columnname"]) == 0) {
                             if (array_key_exists($criteria_groups_arr["columnname"], $this->adv_sel_fields)) {
                                 $this->getColumnValuesVisibilityPerm($criteria_groups_arr["value"], $this->adv_sel_fields[$criteria_groups_arr["columnname"]]);
                             }
                         }
                         // filter columns and values visibility control !!!!!! end
                         $column_condition = "";
                         if ($criteria_groups_arr["column_condition"] != "") {
                             $column_condition = $criteria_groups_arr["column_condition"];
                         }
                         if (in_array($criteria_groups_arr["columnname"], $std_filter_columns)) {
                             $comparator = $criteria_groups_arr["comparator"];
                             $comparator_val = $this->Date_Filter_Values[$comparator];
                             $comparator_info = vtranslate($comparator_val, $this->currentModule);
                             if ($comparator == "custom") {
                                 $comparator_info_arr = explode("<;@STDV@;>", html_entity_decode(trim($criteria_groups_arr["value"]), ENT_QUOTES, $default_charset));
                                 if ($comparator_info_arr[0] != "" && $comparator_info_arr[1] != "") {
                                     $comparator_info .= vtranslate("BETWEEN", $this->currentModule) . " ";
                                     $comparator_info .= $comparator_info_arr[0] . " ";
                                     $comparator_info .= vtranslate("LBL_AND", $this->currentModule) . " ";
                                     $comparator_info .= $comparator_info_arr[1];
                                 } elseif ($comparator_info_arr[0] != "") {
                                     $comparator_info .= vtranslate("LBL_IS", $this->currentModule) . " ";
                                     $comparator_info .= $comparator_info_arr[0];
                                 } elseif ($comparator_info_arr[1] != "") {
                                     $comparator_info .= vtranslate("LBL_IS", $this->currentModule) . " ";
                                     $comparator_info .= $comparator_info_arr[1];
                                 }
                             }
                             $criteria_info_value = "";
                         } else {
                             $comparator = self::$adv_filter_options[$criteria_groups_arr["comparator"]];
                             $comparator_info = vtranslate($comparator, $this->currentModule);
                             $criteria_info_value = $criteria_groups_arr["value"];
                         }
                         $ft_column_lbl = $this->getColumnStr_Label($criteria_groups_arr["columnname"]);
                         $conditions_arr[$criteria_groups_arr["groupid"]][] = $ft_column_lbl . " " . $comparator_info . " " . $criteria_info_value . " " . $column_condition;
                     }
                 }
             }
         }
         $filters_str = "";
         if (!empty($group_conditions)) {
             foreach ($group_conditions as $g_condition_id => $g_condition) {
                 if (isset($conditions_arr[$g_condition_id]) && !empty($conditions_arr[$g_condition_id])) {
                     $filters_str .= " (" . trim(implode(" ", $conditions_arr[$g_condition_id])) . ") ";
                     if ($g_condition != "") {
                         $filters_str .= " " . vtranslate($g_condition, $this->currentModule) . " ";
                     }
                 }
             }
         }
         if ($filters_str == "") {
             $filters_str .= vtranslate("LBL_NONE", $this->currentModule);
         }
         $return_val .= $filters_str;
         $return_arr[] = array("val" => $return_val, "colspan" => "2");
         $td_i = 0;
         foreach ($return_arr as $ra_key => $ra_arr) {
             if (isset($ra_arr["colspan"]) && $ra_arr["colspan"] != "") {
                 $ra_colspan = $ra_arr["colspan"];
             } else {
                 $ra_colspan = 1;
             }
             $ra_val = $ra_arr["val"];
             if ($ra_key === "reportname") {
                 $return_name .= "<tr>";
                 $return_name .= "<td colspan='{$ra_colspan}' class='rpt4youGrpHeadInfoText' width='100%' style='border:0px;'>";
                 $return_name .= "{$ra_val}";
                 $return_name .= "</td>";
                 $return_name .= "</tr>";
             } else {
                 if ($td_i == 0) {
                     $return .= "<tr>";
                 }
                 $return .= "<td colspan='{$ra_colspan}' class='rpt4youGrpHeadInfo' style='text-align:left;padding-left:20px;width:50%;'>";
                 $return .= $ra_val;
                 $return .= "</td>";
                 $td_i += $ra_colspan;
                 if ($td_i == $colspan) {
                     $return .= "</tr>";
                     $td_i = 0;
                 }
             }
             /* $ra_val = $ra_arr["val"];
                if(isset($ra_arr["colspan"]) && $ra_arr["colspan"]!=""){
                $ra_colspan = $ra_arr["colspan"];
                }else{
                $ra_colspan = 1;
                }
                if($td_i==0){
                $return .= "<tr>";
                }
                if(is_numeric($ra_key)){
                $return .= "<td colspan='$ra_colspan' class='rpt4youGrpHeadInfo' style='text-align:left;padding-left:10px;width:50%;'>";
                }else{
                $return .= "<td colspan='$ra_colspan' class='rpt4youGrpHeadInfo' style='text-align:center;font-size:25px;width:100%;'>";
                }
                $return .= $ra_val;
                $return .= "</td>";
                $td_i += $ra_colspan;
                if($td_i==$colspan){
                $return .= "</tr>";
                $td_i = 0;
                } */
         }
         //$final_return = "<table class='rpt4youTableText' style='margin-top:1em;' width='100%'>";
         $final_return = "<table class='rpt4youTableText' width='100%'>";
         $final_return .= $return_name;
         $final_return .= "</table>";
         $final_return .= "<table width='100%' ><tr><td align='center'>";
         $final_return .= "<table class='rpt4youTable' width='98%'>";
         $final_return .= $return;
         $final_return .= "</table>";
         $final_return .= "</td></tr></table>";
         // ITS4YOU-UP SlOl 4. 12. 2014 13:56:43
         // ADD PAGE BREAK AFTER HEADER INFO disabled - remove // to enable it please
         // $final_return .= "<div style='page-break-after:always'></div>";
     }
     return $final_return;
 }
Esempio n. 20
0
<?php

$bd = db::getObject();
?>

        <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Профиль <?php 
echo $_COOKIE['emc-login'];
echo ' (' . getGroupName($_COOKIE['emc-login'], $bd) . ')';
?>
</h3>
            </div>
			   <div class="panel-body">
              <img src="/engine/templates/<?php 
echo $tpl_name;
?>
/skin.png" class="pull-left top5 imgCom img-rounded img-responsive" width="90">&nbsp;&nbsp;&nbsp;&nbsp;
              <a href="">Профиль</a>
              <br>&nbsp;&nbsp;&nbsp;&nbsp;
              <a href="">ЛК</a>
              <br>&nbsp;&nbsp;&nbsp;&nbsp;
              <a href="">Магазин Блоков</a>
              <br>&nbsp;&nbsp;&nbsp;&nbsp;
              <?php 
if (getGroupNumber($_COOKIE['emc-login'], $bd) == 9) {
    ?>
 
              <a href="/do/admin">Admin-панель</a><br>&nbsp;&nbsp;&nbsp;&nbsp; 
              <?php 
}
        echo "";
    } else {
        foreach ($__LIST__ as $key => $vo) {
            $mod = $i % 2;
            ++$i;
            ?>
<tr><td><?php 
            echo $i;
            ?>
</td>
				<td><?php 
            echo $vo['name'];
            ?>
</td>
				<td><?php 
            echo getGroupName($vo['pid']);
            ?>
</td>
				<td><?php 
            echo getStatus($vo['status']);
            ?>
</td>
				<td><?php 
            echo $vo['remark'];
            ?>
</td>
				<td><?php 
            echo toDate($vo['create_time']);
            ?>
</td>
				<td><?php 
Esempio n. 22
0
/** This function returns the vtiger_field details for a given vtiger_fieldname.
 * Param $uitype - UI type of the vtiger_field
 * Param $fieldname - Form vtiger_field name
 * Param $fieldlabel - Form vtiger_field label name
 * Param $maxlength - maximum length of the vtiger_field
 * Param $col_fields - array contains the vtiger_fieldname and values
 * Param $generatedtype - Field generated type (default is 1)
 * Param $module_name - module name
 * Return type is an array
 */
function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $typeofdata = null)
{
    global $log, $app_strings;
    $log->debug("Entering getOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $maxlength . "," . $col_fields . "," . $generatedtype . "," . $module_name . ") method ...");
    global $adb, $log, $default_charset;
    global $theme;
    global $mod_strings;
    global $app_strings;
    global $current_user;
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $fieldlabel = from_html($fieldlabel);
    $fieldvalue = array();
    $final_arr = array();
    $value = $col_fields[$fieldname];
    $custfld = '';
    $ui_type[] = $uitype;
    $editview_fldname[] = $fieldname;
    // vtlib customization: Related type field
    if ($uitype == '10') {
        global $adb;
        $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid=
			(SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2))', array($fieldname, $module_name));
        $entityTypes = array();
        $parent_id = $value;
        for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) {
            $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule');
        }
        if (!empty($value)) {
            $valueType = getSalesEntityType($value);
            $displayValueArray = getEntityName($valueType, $value);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
        } else {
            $displayValue = '';
            $valueType = '';
            $value = '';
        }
        $editview_label[] = array('options' => $entityTypes, 'selected' => $valueType, 'displaylabel' => getTranslatedString($fieldlabel, $module_name));
        $fieldvalue[] = array('displayvalue' => $displayValue, 'entityid' => $parent_id);
    } else {
        if ($uitype == 5 || $uitype == 6 || $uitype == 23) {
            $log->info("uitype is " . $uitype);
            if ($value == '') {
                //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469)
                if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14) {
                    $disp_value = getNewDisplayDate();
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) {
                    $curr_time = date('H:i', strtotime('+5 minutes'));
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    $curr_time = date('H:i', strtotime('+10 minutes'));
                }
                //Added to display the Contact - Support End Date as one year future instead of
                //today's date -- 30-11-2005
                if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') {
                    $addyear = strtotime("+1 year");
                    $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear));
                } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') {
                    $disp_value = '';
                }
            } else {
                if ($uitype == 6) {
                    if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name == 'Calendar')) {
                        $curr_time = $col_fields['time_start'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+5 minutes'));
                    }
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    if ($col_fields['time_end'] != '') {
                        $curr_time = $col_fields['time_end'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+10 minutes'));
                    }
                }
                $disp_value = getValidDisplayDate($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            if (!empty($curr_time)) {
                if (($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 || $uitype == 6)) {
                    $curr_time = DateTimeField::convertToUserTimeZone($curr_time);
                    $curr_time = $curr_time->format('H:i');
                }
            }
            $fieldvalue[] = array($disp_value => $curr_time);
            if ($uitype == 5 || $uitype == 23) {
                if ($module_name == 'Events' && $uitype == 23) {
                    $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
                } else {
                    $fieldvalue[] = array($date_format => $current_user->date_format);
                }
            } else {
                $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
            }
        } elseif ($uitype == 16) {
            require_once 'modules/PickList/PickListUtils.php';
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid";
            $params = array();
            $pickListResult = $adb->pquery($pick_query, $params);
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $pickcount = 0;
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $value = decode_html($value);
                $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname)));
                if ($value == trim($pickListValue)) {
                    $chk_val = "selected";
                    $pickcount++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                    $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                } else {
                    $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                }
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 15 || $uitype == 33) {
            require_once 'modules/PickList/PickListUtils.php';
            $roleid = $current_user->roleid;
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            $valueArr = explode("|##|", $value);
            $pickcount = 0;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), array_map("trim", $valueArr))) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $options;
        } elseif ($uitype == 17) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 85) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 14) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 19 || $uitype == 20) {
            if (isset($_REQUEST['body'])) {
                $value = $_REQUEST['body'];
            }
            if ($fieldname == 'terms_conditions') {
                //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,)
                $value = $col_fields['terms_conditions'];
                //if the value is empty then only we should get the default Terms and Conditions
                if ($value == '' && $mode != 'edit') {
                    $value = getTermsandConditions();
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 21 || $uitype == 24) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 22) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 52 || $uitype == 77) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            global $current_user;
            if ($value != '') {
                $assigned_user_id = $value;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if ($uitype == 52) {
                $combo_lbl_name = 'assigned_user_id';
            } elseif ($uitype == 77) {
                $combo_lbl_name = 'assigned_user_id1';
            }
            //Control will come here only for Products - Handler and Quotes - Inventory Manager
            if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            $fieldvalue[] = $users_combo;
        } elseif ($uitype == 53) {
            global $noof_group_rows;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            //Security Checks
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $result = get_current_user_access_groups($module_name);
            } else {
                $result = get_group_options();
            }
            if ($result) {
                $nameArray = $adb->fetch_array($result);
            }
            if ($value != '' && $value != 0) {
                $assigned_user_id = $value;
            } else {
                if ($value == '0') {
                    if (isset($col_fields['assigned_group_info']) && $col_fields['assigned_group_info'] != '') {
                        $selected_groupname = $col_fields['assigned_group_info'];
                    } else {
                        $record = $col_fields["record_id"];
                        $module = $col_fields["record_module"];
                        $selected_groupname = getGroupName($record, $module);
                    }
                } else {
                    $assigned_user_id = $current_user->id;
                }
            }
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            if ($noof_group_rows != 0) {
                if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
                } else {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
                }
            }
            $fieldvalue[] = $users_combo;
            $fieldvalue[] = $groups_combo;
        } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) {
            if ($_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') {
                if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                    $value = $_REQUEST['account_id'];
                }
            }
            if ($value != '') {
                $account_name = getAccountName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $account_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 54) {
            $options = array();
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_groups";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "name");
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 55 || $uitype == 255) {
            require_once 'modules/PickList/PickListUtils.php';
            if ($uitype == 255) {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'firstname', 'readwrite');
            }
            if ($uitype == 255 && $fieldpermission == '0') {
                $fieldvalue[] = '';
            } else {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'salutationtype', 'readwrite');
                if ($fieldpermission == '0') {
                    $roleid = $current_user->roleid;
                    $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb);
                    $pickcount = 0;
                    $salt_value = $col_fields["salutationtype"];
                    foreach ($picklistValues as $order => $pickListValue) {
                        if ($salt_value == trim($pickListValue)) {
                            $chk_val = "selected";
                            $pickcount++;
                        } else {
                            $chk_val = '';
                        }
                        if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                            $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                        } else {
                            $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                        }
                    }
                    if ($pickcount == 0 && $salt_value != '') {
                        $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $salt_value, 'selected');
                    }
                    $fieldvalue[] = $options;
                } else {
                    $fieldvalue[] = '';
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 59) {
            if ($_REQUEST['module'] == 'HelpDesk') {
                if (isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') {
                    $value = $_REQUEST['product_id'];
                }
            } elseif (isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $product_name = getProductName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $product_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 63) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($value == '') {
                $value = 1;
            }
            $options = array();
            $pick_query = "select * from vtiger_duration_minutes order by sortorderid";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            $salt_value = $col_fields["duration_minutes"];
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "duration_minutes");
                if ($salt_value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[$pickListValue] = $chk_val;
            }
            $fieldvalue[] = $value;
            $fieldvalue[] = $options;
        } elseif ($uitype == 64) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            $fieldvalue[] = $value;
        } elseif ($uitype == 156) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 56) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 57) {
            if ($value != '') {
                $displayValueArray = getEntityName('Contacts', $value);
                if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $field_value) {
                        $contact_name = $field_value;
                    }
                }
            } elseif (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') {
                if ($_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) {
                    $contact_name = '';
                } else {
                    $value = $_REQUEST['contact_id'];
                    $displayValueArray = getEntityName('Contacts', $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                }
            }
            //Checking for contacts duplicate
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $contact_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 58) {
            if ($value != '') {
                $campaign_name = getCampaignName($value);
            } elseif (isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') {
                if ($_REQUEST['module'] == 'Campaigns' && ($fieldname = 'campaignid')) {
                    $campaign_name = '';
                } else {
                    $value = $_REQUEST['campaignid'];
                    $campaign_name = getCampaignName($value);
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $campaign_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 61) {
            if ($value != '') {
                $assigned_user_id = $value;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if ($module_name == 'Emails' && $col_fields['record_id'] != '') {
                $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
                //to fix the issue in mail attachment on forwarding mails
                if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                    global $att_id_list;
                }
                for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) {
                    $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid');
                    if ($attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                        if ($attachmentsname != '') {
                            $fieldvalue[$attachmentid] = '[ ' . $attachmentsname . ' ]';
                        }
                        if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                            $att_id_list .= $attachmentid . ';';
                        }
                    }
                }
            } else {
                if ($col_fields['record_id'] != '') {
                    $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                    if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                    }
                }
                if ($value != '') {
                    $filename = ' [ ' . $value . ' ]';
                }
                if ($filename != '') {
                    $fieldvalue[] = $filename;
                }
                if ($value != '') {
                    $fieldvalue[] = $value;
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 28) {
            if ($col_fields['record_id'] != '') {
                $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                    $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                    $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                }
            }
            if ($value != '' && $module_name != 'Documents') {
                $filename = ' [ ' . $value . ' ]';
            } elseif ($value != '' && $module_name == 'Documents') {
                $filename = $value;
            }
            if ($filename != '') {
                $fieldvalue[] = $filename;
            }
            if ($value != '') {
                $fieldvalue[] = $value;
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 69) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($col_fields['record_id'] != "") {
                //This query is for Products only
                if ($module_name == 'Products') {
                    $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name ,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?';
                } else {
                    $query = "select vtiger_attachments.*,vtiger_crmentity.setype from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype='Contacts Image' and vtiger_seattachmentsrel.crmid=?";
                }
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid');
                    //decode_html  - added to handle UTF-8   characters in file names
                    //urlencode    - added to handle special characters like #, %, etc.,
                    $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name')));
                    $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name'));
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
                if (is_array($image_array)) {
                    for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                        $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr] . $image_id_array[$img_itr] . "_", "orgname" => $image_orgname_array[$img_itr]);
                    }
                } else {
                    $fieldvalue[] = '';
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 62) {
            if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
            }
            if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                $parent_module = "Accounts";
                $value = $_REQUEST['account_id'];
            }
            if ($parent_module != 'Contacts') {
                if ($parent_module == "Leads") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $lead_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } elseif ($parent_module == "Potentials") {
                    $sql = "select * from  vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "potentialname");
                    $potential_selected = "selected";
                } elseif ($parent_module == "Products") {
                    $sql = "select * from  vtiger_products where productid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "productname");
                    $product_selected = "selected";
                } elseif ($parent_module == "PurchaseOrder") {
                    $sql = "select * from  vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $porder_selected = "selected";
                } elseif ($parent_module == "SalesOrder") {
                    $sql = "select * from  vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $sorder_selected = "selected";
                } elseif ($parent_module == "Invoice") {
                    $sql = "select * from  vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $invoice_selected = "selected";
                } elseif ($parent_module == "Quotes") {
                    $sql = "select * from  vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $quote_selected = "selected";
                } elseif ($parent_module == "HelpDesk") {
                    $sql = "select * from  vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "title");
                    $ticket_selected = "selected";
                }
            }
            $editview_label[] = array($app_strings['COMBO_LEADS'], $app_strings['COMBO_ACCOUNTS'], $app_strings['COMBO_POTENTIALS'], $app_strings['COMBO_PRODUCTS'], $app_strings['COMBO_INVOICES'], $app_strings['COMBO_PORDER'], $app_strings['COMBO_SORDER'], $app_strings['COMBO_QUOTES'], $app_strings['COMBO_HELPDESK']);
            $editview_label[] = array($lead_selected, $account_selected, $potential_selected, $product_selected, $invoice_selected, $porder_selected, $sorder_selected, $quote_selected, $ticket_selected);
            $editview_label[] = array("Leads&action=Popup", "Accounts&action=Popup", "Potentials&action=Popup", "Products&action=Popup", "Invoice&action=Popup", "PurchaseOrder&action=Popup", "SalesOrder&action=Popup", "Quotes&action=Popup", "HelpDesk&action=Popup");
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 66) {
            if (!empty($_REQUEST['parent_id'])) {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if (!empty($value)) {
                $parent_module = getSalesEntityType($value);
                if ($parent_module != "Contacts") {
                    $entity_names = getEntityName($parent_module, $value);
                    $parent_name = $entity_names[$value];
                    $fieldvalue[] = $parent_name;
                    $fieldvalue[] = $value;
                }
            }
            // Check for vtiger_activity type if task orders to be added in select option
            $act_mode = $_REQUEST['activity_mode'];
            $parentModulesList = array('Leads' => $app_strings['COMBO_LEADS'], 'Accounts' => $app_strings['COMBO_ACCOUNTS'], 'Potentials' => $app_strings['COMBO_POTENTIALS'], 'HelpDesk' => $app_strings['COMBO_HELPDESK'], 'Campaigns' => $app_strings['COMBO_CAMPAIGNS']);
            if ($act_mode == "Task") {
                $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES'];
                $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER'];
                $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER'];
                $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES'];
            }
            $parentModuleNames = array_keys($parentModulesList);
            $parentModuleLabels = array_values($parentModulesList);
            $editview_label[0] = $parentModuleLabels;
            $editview_label[1] = array_fill(0, count($parentModulesList), '');
            $selectedModuleIndex = array_search($parent_module, $parentModuleNames);
            if ($selectedModuleIndex > -1) {
                $editview_label[1][$selectedModuleIndex] = 'selected';
            }
            $parentModulePopupUrl = array();
            foreach ($parentModuleNames as $parentModule) {
                $parentModulePopupUrl[] = $parentModule . '&action=Popup';
            }
            $editview_label[2] = $parentModulePopupUrl;
        } elseif ($uitype == 357) {
            $pmodule = $_REQUEST['pmodule'];
            if (empty($pmodule)) {
                $pmodule = $_REQUEST['par_module'];
            }
            if ($pmodule == 'Contacts') {
                $contact_selected = 'selected';
            } elseif ($pmodule == 'Accounts') {
                $account_selected = 'selected';
            } elseif ($pmodule == 'Leads') {
                $lead_selected = 'selected';
            } elseif ($pmodule == 'Vendors') {
                $vendor_selected = 'selected';
            } elseif ($pmodule == 'Users') {
                $user_selected = 'selected';
            }
            if (isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') {
                $parent_id = $_REQUEST['emailids'];
                $parent_name = '';
                $myids = explode("|", $parent_id);
                for ($i = 0; $i < count($myids) - 1; $i++) {
                    $realid = explode("@", $myids[$i]);
                    $entityid = $realid[0];
                    $nemail = count($realid);
                    if ($pmodule == 'Accounts') {
                        require_once 'modules/Accounts/Accounts.php';
                        $myfocus = new Accounts();
                        $myfocus->retrieve_entity_info($entityid, "Accounts");
                        $fullname = br2nl($myfocus->column_fields['accountname']);
                        $account_selected = 'selected';
                    } elseif ($pmodule == 'Contacts') {
                        require_once 'modules/Contacts/Contacts.php';
                        $myfocus = new Contacts();
                        $myfocus->retrieve_entity_info($entityid, "Contacts");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $contact_selected = 'selected';
                    } elseif ($pmodule == 'Leads') {
                        require_once 'modules/Leads/Leads.php';
                        $myfocus = new Leads();
                        $myfocus->retrieve_entity_info($entityid, "Leads");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $lead_selected = 'selected';
                    }
                    for ($j = 1; $j < $nemail; $j++) {
                        $querystr = 'select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)';
                        $result = $adb->pquery($querystr, array($realid[$j]));
                        $temp = $adb->query_result($result, 0, 'columnname');
                        $temp1 = br2nl($myfocus->column_fields[$temp]);
                        //Modified to display the entities in red which don't have email id
                        if (!empty($temp_parent_name) && strlen($temp_parent_name) > 150) {
                            $parent_name .= '<br>';
                            $temp_parent_name = '';
                        }
                        if ($temp1 != '') {
                            $parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                            $temp_parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                        } else {
                            $parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                            $temp_parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                        }
                    }
                }
            } else {
                if ($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL) {
                    $parent_name = '';
                    $parent_id = '';
                    $myemailid = $_REQUEST['record'];
                    $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
                    $myresult = $adb->pquery($mysql, array($myemailid));
                    $mycount = $adb->num_rows($myresult);
                    if ($mycount > 0) {
                        for ($i = 0; $i < $mycount; $i++) {
                            $mycrmid = $adb->query_result($myresult, $i, 'crmid');
                            $parent_module = getSalesEntityType($mycrmid);
                            if ($parent_module == "Leads") {
                                $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Leads");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $lead_selected = 'selected';
                            } elseif ($parent_module == "Contacts") {
                                $sql = "select * from  vtiger_contactdetails where contactid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Contacts");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $contact_selected = 'selected';
                            } elseif ($parent_module == "Accounts") {
                                $sql = "select * from  vtiger_account where accountid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "accountname");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $account_selected = 'selected';
                            } elseif ($parent_module == "Users") {
                                $sql = "select user_name,email1 from vtiger_users where id=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "user_name");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $user_selected = 'selected';
                            } elseif ($parent_module == "Vendors") {
                                $sql = "select * from  vtiger_vendor where vendorid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $vendor_name = $adb->query_result($result, 0, "vendorname");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $vendor_name . '<' . $myemail . '>; ';
                                $vendor_selected = 'selected';
                            }
                        }
                    }
                }
                $custfld .= '<td width="20%" class="dataLabel">' . $app_strings['To'] . '&nbsp;</td>';
                $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="' . $parent_id . '"><textarea readonly name="parent_name" cols="70" rows="2">' . $parent_name . '</textarea>&nbsp;<select name="parent_type" >';
                $custfld .= '<OPTION value="Contacts" selected>' . $app_strings['COMBO_CONTACTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Accounts" >' . $app_strings['COMBO_ACCOUNTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Leads" >' . $app_strings['COMBO_LEADS'] . '</OPTION>';
                $custfld .= '<OPTION value="Vendors" >' . $app_strings['COMBO_VENDORS'] . '</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'>&nbsp;<input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>';
                $editview_label[] = array('Contacts' => $contact_selected, 'Accounts' => $account_selected, 'Vendors' => $vendor_selected, 'Leads' => $lead_selected, 'Users' => $user_selected);
                $fieldvalue[] = $parent_name;
                $fieldvalue[] = $parent_id;
            }
        } elseif ($uitype == 68) {
            if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Contacts") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $contact_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } else {
                    $parent_name = "";
                    $value = "";
                }
            }
            $editview_label[] = array($app_strings['COMBO_CONTACTS'], $app_strings['COMBO_ACCOUNTS']);
            $editview_label[] = array($contact_selected, $account_selected);
            $editview_label[] = array("Contacts", "Accounts");
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 71 || $uitype == 72) {
            $currencyField = new CurrencyField($value);
            // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
            if ($col_fields['record_id'] != '' && $uitype == 72) {
                if ($fieldname == 'unit_price') {
                    $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module_name));
                    $currencySymbol = $rate_symbol['symbol'];
                } else {
                    $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
                    $currencySymbol = $currency_info['currency_symbol'];
                }
                $fieldvalue[] = $currencyField->getDisplayValue(null, true);
            } else {
                $fieldvalue[] = $currencyField->getDisplayValue();
                $currencySymbol = $currencyField->getCurrencySymbol();
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name) . ': (' . $currencySymbol . ')';
        } elseif ($uitype == 75 || $uitype == 81) {
            if ($value != '') {
                $vendor_name = getVendorName($value);
            } elseif (isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') {
                $value = $_REQUEST['vendor_id'];
                $vendor_name = getVendorName($value);
            }
            $pop_type = 'specific';
            if ($uitype == 81) {
                $pop_type = 'specific_vendor_address';
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $vendor_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 76) {
            if ($value != '') {
                $potential_name = getPotentialName($value);
            } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') {
                $value = $_REQUEST['potental_id'];
                $potential_name = getPotentialName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $potential_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 78) {
            if ($value != '') {
                $quote_name = getQuoteName($value);
            } elseif (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') {
                $value = $_REQUEST['quote_id'];
                $potential_name = getQuoteName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $quote_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 79) {
            if ($value != '') {
                $purchaseorder_name = getPoName($value);
            } elseif (isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') {
                $value = $_REQUEST['purchaseorder_id'];
                $purchaseorder_name = getPoName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $purchaseorder_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 80) {
            if ($value != '') {
                $salesorder_name = getSoName($value);
            } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') {
                $value = $_REQUEST['salesorder_id'];
                $salesorder_name = getSoName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $salesorder_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 30) {
            $rem_days = 0;
            $rem_hrs = 0;
            $rem_min = 0;
            if ($value != '') {
                $SET_REM = "CHECKED";
            }
            $rem_days = floor($col_fields[$fieldname] / (24 * 60));
            $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60);
            $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $day_options = getReminderSelectOption(0, 31, 'remdays', $rem_days);
            $hr_options = getReminderSelectOption(0, 23, 'remhrs', $rem_hrs);
            $min_options = getReminderSelectOption(1, 59, 'remmin', $rem_min);
            $fieldvalue[] = array(array(0, 32, 'remdays', getTranslatedString('LBL_DAYS'), $rem_days), array(0, 24, 'remhrs', getTranslatedString('LBL_HOURS'), $rem_hrs), array(1, 60, 'remmin', getTranslatedString('LBL_MINUTES') . '&nbsp;&nbsp;' . getTranslatedString('LBL_BEFORE_EVENT'), $rem_min));
            $fieldvalue[] = array($SET_REM, getTranslatedString('LBL_YES'), getTranslatedString('LBL_NO'));
            $SET_REM = '';
        } elseif ($uitype == 115) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname);
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname));
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 116 || $uitype == 117) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name');
                $currency_id = $adb->query_result($pickListResult, $j, 'id');
                if ($value == $currency_id) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[$currency_id] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 98) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = getRoleName($value);
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 105) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if (isset($col_fields['record_id']) && $col_fields['record_id'] != '') {
                $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?";
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_array[] = $adb->query_result($result_image, $image_iter, 'name');
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
            }
            if (is_array($image_array)) {
                for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                    $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr]);
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 101) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = getOwnerName($value);
            $fieldvalue[] = $value;
        } elseif ($uitype == 26) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $folderid = $col_fields['folderid'];
            $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?';
            $res = $adb->pquery($foldername_query, array($folderid));
            $foldername = $adb->query_result($res, 0, 'foldername');
            if ($foldername != '' && $folderid != '') {
                $fldr_name[$folderid] = $foldername;
            }
            $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername";
            $res = $adb->pquery($sql, array());
            for ($i = 0; $i < $adb->num_rows($res); $i++) {
                $fid = $adb->query_result($res, $i, "folderid");
                $fldr_name[$fid] = $adb->query_result($res, $i, "foldername");
            }
            $fieldvalue[] = $fldr_name;
        } elseif ($uitype == 27) {
            if ($value == 'E') {
                $external_selected = "selected";
                $filename = $col_fields['filename'];
            } else {
                $internal_selected = "selected";
                $filename = $col_fields['filename'];
            }
            $editview_label[] = array(getTranslatedString('Internal'), getTranslatedString('External'));
            $editview_label[] = array($internal_selected, $external_selected);
            $editview_label[] = array("I", "E");
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $filename;
        } elseif ($uitype == '31') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $themeList = get_themes();
            foreach ($themeList as $theme) {
                if ($current_user->theme == $theme) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($theme), $theme, $selected);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == '32') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $languageList = Vtiger_Language::getAll();
            foreach ($languageList as $prefix => $label) {
                if ($current_user->language == $prefix) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($label), $prefix, $selected);
            }
            $fieldvalue[] = $options;
        } else {
            //Added condition to set the subject if click Reply All from web mail
            if ($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') {
                $value = $_REQUEST['mg_subject'];
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($fieldname == 'fileversion') {
                if (empty($value)) {
                    $value = '';
                } else {
                    $fieldvalue[] = $value;
                }
            } else {
                $fieldvalue[] = $value;
            }
        }
    }
    // Mike Crowe Mod --------------------------------------------------------force numerics right justified.
    if (!preg_match("/id=/i", $custfld)) {
        $custfld = preg_replace("/<input/iS", "<input id='{$fieldname}' ", $custfld);
    }
    if (in_array($uitype, array(71, 72, 7, 9, 90))) {
        $custfld = preg_replace("/<input/iS", "<input align=right ", $custfld);
    }
    $final_arr[] = $ui_type;
    $final_arr[] = $editview_label;
    $final_arr[] = $editview_fldname;
    $final_arr[] = $fieldvalue;
    $type_of_data = explode('~', $typeofdata);
    $final_arr[] = $type_of_data[1];
    $log->debug("Exiting getOutputHtml method ...");
    return $final_arr;
}
Esempio n. 23
0
 public static function ReportSharing(Vtiger_Request $request, $viewer)
 {
     $moduleName = $request->getModule();
     $record = $request->get('record');
     $R_Data = $request->getAll();
     $viewer->assign("MODULE", $moduleName);
     $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record);
     $primary_module = $reportModel->getPrimaryModule();
     $primary_moduleid = $reportModel->getPrimaryModuleId();
     $current_user = Users_Record_Model::getCurrentUserModel();
     //$Report_Informations = $reportModel->getReportInformations();
     $Report_Informations = $reportModel->report->reportinformations;
     $LBL_INFORMATIONS_4YOU = vtranslate("LBL_STEP8_INFO", $moduleName);
     $viewer->assign("LBL_INFORMATIONS_4YOU", $LBL_INFORMATIONS_4YOU);
     //require_once('include/utils/GetUserGroups.php');
     // ITS4YOU-UP SlOl 26. 4. 2013 9:47:59
     $template_owners = get_user_array(false);
     if (isset($Report_Informations["owner"]) && $Report_Informations["owner"] != "") {
         $selected_owner = $Report_Informations["owner"];
     } else {
         $selected_owner = $current_user->id;
     }
     $viewer->assign("TEMPLATE_OWNERS", $template_owners);
     $owner = isset($R_Data['template_owner']) && $R_Data['template_owner'] != '' ? $R_Data['template_owner'] : $selected_owner;
     $viewer->assign("TEMPLATE_OWNER", $owner);
     $sharing_types = array("public" => vtranslate("PUBLIC_FILTER", $moduleName), "private" => vtranslate("PRIVATE_FILTER", $moduleName), "share" => vtranslate("SHARE_FILTER", $moduleName));
     $viewer->assign("SHARINGTYPES", $sharing_types);
     if ($request->get('reporttype') == "custom_report") {
         $sharingtype = "private";
     } else {
         $sharingtype = "public";
     }
     if (isset($R_Data['sharing']) && $R_Data['sharing'] != '') {
         $sharingtype = $R_Data['sharing'];
     } elseif (isset($Report_Informations["sharing"]) && $Report_Informations["sharing"] != "") {
         $sharingtype = $Report_Informations["sharing"];
     }
     $viewer->assign("SHARINGTYPE", $sharingtype);
     //$cmod = return_specified_module_language($current_language, "Settings");
     //$viewer->assign("CMOD", $cmod);
     $sharingMemberArray = array();
     if (isset($R_Data['sharingSelectedColumns']) && $R_Data['sharingSelectedColumns'] != '') {
         $sharingMemberArray = explode("|", trim($R_Data['sharingSelectedColumns'], "|"));
     } elseif (isset($Report_Informations["members_array"]) && !empty($Report_Informations["members_array"])) {
         $sharingMemberArray = $Report_Informations["members_array"];
     }
     $sharingMemberArray = array_unique($sharingMemberArray);
     if (count($sharingMemberArray) > 0) {
         $outputMemberArr = array();
         foreach ($sharingMemberArray as $setype => $shareIdArr) {
             $shareIdArr = explode("::", $shareIdArr);
             $shareIdArray = array();
             $shareIdArray[$shareIdArr[0]] = $shareIdArr[1];
             foreach ($shareIdArray as $shareType => $shareId) {
                 switch ($shareType) {
                     case "groups":
                         $groupArray = getGroupName($shareId);
                         $memberName = $groupArray[0];
                         $memberDisplay = "Group::";
                         break;
                     case "roles":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "Roles::";
                         break;
                     case "rs":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "RoleAndSubordinates::";
                         break;
                     case "users":
                         $memberName = getUserFullName($shareId);
                         $memberDisplay = "User::";
                         break;
                 }
                 $outputMemberArr[] = $shareType . "::" . $shareId;
                 $outputMemberArr[] = $memberDisplay . $memberName;
             }
         }
         $viewer->assign("MEMBER", array_chunk($outputMemberArr, 2));
     }
     // ITS4YOU-END
     //Constructing the Role Array
     $roleDetails = getAllRoleDetails();
     $i = 0;
     $roleIdStr = "";
     $roleNameStr = "";
     $userIdStr = "";
     $userNameStr = "";
     $grpIdStr = "";
     $grpNameStr = "";
     foreach ($roleDetails as $roleId => $roleInfo) {
         if ($i != 0) {
             if ($i != 1) {
                 $roleIdStr .= ", ";
                 $roleNameStr .= ", ";
             }
             $roleName = $roleInfo[0];
             $roleIdStr .= "'" . $roleId . "'";
             $roleNameStr .= "'" . addslashes(decode_html($roleName)) . "'";
         }
         $i++;
     }
     //Constructing the User Array
     $l = 0;
     $userDetails = getAllUserName();
     foreach ($userDetails as $userId => $userInfo) {
         if ($l != 0) {
             $userIdStr .= ", ";
             $userNameStr .= ", ";
         }
         $userIdStr .= "'" . $userId . "'";
         $userNameStr .= "'" . $userInfo . "'";
         $l++;
     }
     //Constructing the Group Array
     $parentGroupArray = array();
     $m = 0;
     $grpDetails = getAllGroupName();
     foreach ($grpDetails as $grpId => $grpName) {
         if (!in_array($grpId, $parentGroupArray)) {
             if ($m != 0) {
                 $grpIdStr .= ", ";
                 $grpNameStr .= ", ";
             }
             $grpIdStr .= "'" . $grpId . "'";
             $grpNameStr .= "'" . addslashes(decode_html($grpName)) . "'";
             $m++;
         }
     }
     $viewer->assign("ROLEIDSTR", $roleIdStr);
     $viewer->assign("ROLENAMESTR", $roleNameStr);
     $viewer->assign("USERIDSTR", $userIdStr);
     $viewer->assign("USERNAMESTR", $userNameStr);
     $viewer->assign("GROUPIDSTR", $grpIdStr);
     $viewer->assign("GROUPNAMESTR", $grpNameStr);
     $visiblecriteria = $reportModel->getVisibleCriteria();
     $viewer->assign("VISIBLECRITERIA", $visiblecriteria);
     return $viewer->view('ReportSharing.tpl', $moduleName, true);
 }
Esempio n. 24
0
    if ($total_days == 0) {
        $time_done = 0;
    } else {
        $time_done = round($days_in / $total_days * 100, 0);
    }
    if ($time_done > $sorted_group) {
        //If more time has been completed then group progress, bad standing alert
        $progress_bar_colour = "#f00";
        //Red
    } else {
        //Otherwise more work has been done than time, good standing alert
        $progress_bar_colour = "#0f0";
        //Green
    }
    if ($key == $currentgroup) {
        //If the student viewing page is in the group, bold their name.
        $html .= "<tr><td><b>" . getGroupName($key) . "<b></td><td>";
    } else {
        //Otherwise, just display the group name
        $html .= "<tr><td>" . getGroupName($key) . "</td><td>";
    }
    $html .= '<div style="border: solid 1px;width: 300px;height: 10px;">';
    $html .= '<div style="background-color:' . $progress_bar_colour . ';width:' . $sorted_group . '%; height:10px;">&nbsp;</div>';
    //Green Progress bar to indicate complete
    $html .= '<div style="position: relative;top:-10px;text-align:center;font-size:10px;font-weight:bold;">Progress: ' . $sorted_group . '% </div>';
}
$html .= "</table>";
$content = $html;
echo $OUTPUT->box($content, "generalbox center clearfix");
add_to_log($course->id, 'project', 'view', 'group_compare.php?id=' . $cmid, $p);
echo $OUTPUT->footer();
if ($ajaxaction == "DETAILVIEW") {
    $crmid = $_REQUEST["recordid"];
    $tablename = $_REQUEST["tableName"];
    $fieldname = $_REQUEST["fldName"];
    $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]);
    if ($crmid != "") {
        $modObj->retrieve_entity_info($crmid, "HelpDesk");
        //Added to avoid the comment save, when we edit other fields through ajax edit
        if ($fieldname != 'comments') {
            $modObj->column_fields['comments'] = '';
        }
        $modObj->column_fields[$fieldname] = $fieldvalue;
        $modObj->id = $crmid;
        $modObj->mode = "edit";
        //Added to construct the update log for Ticket history
        $assigned_group_name = getGroupName($_REQUEST['assigned_group_id']);
        $assigntype = $_REQUEST['assigntype'];
        $fldvalue = $modObj->constructUpdateLog($modObj, $modObj->mode, $assigned_group_name, $assigntype);
        $fldvalue = from_html($fldvalue, $modObj->mode == 'edit' ? true : false);
        $modObj->save("HelpDesk");
        global $mod_strings;
        if ($fieldname == "solution" || $fieldname == "comments" || $fieldname == "assigned_user_id" || $fieldname == "ticketstatus" && $fieldvalue == $mod_strings['Closed']) {
            require_once 'modules/Emails/mail.php';
            $user_emailid = getUserEmailId('id', $modObj->column_fields['assigned_user_id']);
            $subject = $modObj->column_fields['ticket_no'] . ' [ ' . $mod_strings['LBL_TICKET_ID'] . ' : ' . $modObj->id . ' ] Re : ' . $modObj->column_fields['ticket_title'];
            $parent_id = $modObj->column_fields['parent_id'];
            if (!empty($parent_id) && $parent_id != 0) {
                $parent_module = getSalesEntityType($parent_id);
                if ($parent_module == 'Contacts') {
                    $result = $adb->pquery("select * from vtiger_contactdetails where contactid=?", array($parent_id));
                    $emailoptout = $adb->query_result($result, 0, 'emailoptout');
Esempio n. 26
0
 function replaceModuleFields($content, $fields, $module, $recordid)
 {
     $db = PearDatabase::getInstance();
     require_once 'include/utils/CommonUtils.php';
     require_once 'include/fields/CurrencyField.php';
     require_once 'include/utils/utils.php';
     $userLang = Users_Record_Model::getCurrentUserModel()->get('language');
     include "languages/" . $userLang . "/OSSPdf.php";
     #################################################################################
     $ui_datefields = array('70', '5', '23');
     #################################################################################
     $ui_currfields = array('71', '72', '7');
     #################################################################################
     $uitypelist = array('10', '58', '51', '57', '68', '59', '75', '80', '76', '73', '81', '78');
     $uitype2module = array('58' => 'Campaigns', '51' => 'Accounts', '57' => 'Contacts', '68' => 'Accounts;Contacts', '59' => 'Products', '75' => 'Vendors', '80' => 'SalesOrder', '76' => 'Potentials', '73' => 'Accounts', '81' => 'Vendors', '78' => 'Quotes');
     #################################################################################
     if ($module == 'Activity') {
         $wynik = $db->query("select tabid,name from vtiger_tab where name='Calendar'", true);
     } else {
         $wynik = $db->query("select tabid,name from vtiger_tab where name='{$module}'", true);
     }
     $moduleid = $db->query_result($wynik, 0, "tabid");
     foreach ($fields as $key => $field) {
         $pobierz_pola = $db->query("select fieldid,fieldlabel, uitype from vtiger_field where fieldname='{$key}' and tabid='{$moduleid}'", true);
         $label = $db->query_result($pobierz_pola, 0, "fieldlabel");
         $field_uitype = $db->query_result($pobierz_pola, 0, "uitype");
         $fieldid = $db->query_result($pobierz_pola, 0, "fieldid");
         ################################################
         if (in_array($field_uitype, $ui_datefields)) {
             $field = getValidDisplayDate($field);
         }
         ################################################
         if (in_array($field_uitype, $ui_currfields)) {
             $currfield = new CurrencyField($field);
             $field = $currfield->getDisplayValue();
         }
         ////////////////////
         /// For fields that are related it is required to download an appropriate name instead of related record’s ID
         if (in_array($field_uitype, $uitypelist)) {
             if ($field != 0) {
                 $singleid = getSalesEntityType($field);
                 $newvalue = $db->query("select tablename, entityidfield,fieldname from vtiger_entityname where modulename = '{$singleid}'", true);
                 $tablename = $db->query_result($newvalue, 0, "tablename");
                 $fieldname = $db->query_result($newvalue, 0, "fieldname");
                 $fieldnames = explode(',', $fieldname);
                 $tableid = $db->query_result($newvalue, 0, "entityidfield");
                 $newvalue2 = $db->query("select {$fieldname} from {$tablename} where {$tableid} = '{$field}'", true);
                 $field = "";
                 foreach ($fieldnames as $partname) {
                     $field .= $db->query_result($newvalue2, 0, $partname) . " ";
                 }
             }
         }
         /// For user fields
         if ($field_uitype == 53 || $field_uitype == 52) {
             $robocza = getUserName($field);
             if ($robocza == "") {
                 $robocza = getGroupName($field)[0];
             }
             $field = $robocza;
         }
         /// For field with folder name
         /* if( $field_uitype == 26 ) {
         	  $new_value = $db->query( "select foldername from vtiger_attachmentsfolder where folderid = '$field'", true );
         	  $field = $db->query_result( $new_value, 0, "foldername" );
         	  } */
         if ($field_uitype == 27) {
             if ($field == 'I') {
                 $field = getTranslatedString('Internal', $module);
             } elseif ($field == 'E') {
                 $field = getTranslatedString('External', $module);
             }
         }
         /// For field with language
         if ($field_uitype == 32) {
             $name = '%' . $field . '%';
             $new_value = $db->query("select name from vtiger_language where prefix like '{$name}'", true);
             $field = $db->query_result($new_value, 0, "name");
         }
         /// For field with role in organization
         if ($field_uitype == 98) {
             $new_value = $db->query("select rolename from vtiger_role where roleid = '{$field}'", true);
             $field = $db->query_result($new_value, 0, "rolename");
         }
         if ($field_uitype == 117) {
             $new_value = $db->query("select currency_code from vtiger_currency_info where id = '{$field}'", true);
             $field = $db->query_result($new_value, 0, "currency_code");
         }
         /// For user’s image
         if ($field_uitype == 105) {
             if ($field != "") {
                 $sql = "SELECT CONCAT(vtiger_attachments.path,vtiger_users.imagename) AS sciezka FROM vtiger_attachments\n                    INNER JOIN vtiger_salesmanattachmentsrel ON ( vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid )\n                    INNER JOIN vtiger_users ON ( vtiger_users.id = vtiger_salesmanattachmentsrel.smid )\n                      WHERE vtiger_salesmanattachmentsrel.smid = '{$recordid}'";
                 $pobierz_zdjecie = $db->query($sql, true);
                 if ($db->num_rows($pobierz_zdjecie) > 0) {
                     $field = '<img src="' . $db->query_result($pobierz_zdjecie, 0, "sciezka") . '"></img>';
                 }
             }
         }
         /// For checkbox type fields
         if ($field_uitype == 56) {
             if ($field == 1) {
                 $field = getTranslatedString('yes', "OSSPdf");
             } elseif ($field == 0) {
                 $field = getTranslatedString('no', "OSSPdf");
             }
         }
         if ($field_uitype == 10 && is_numeric($field)) {
             if ($field != 0) {
                 $field = Vtiger_Functions::getCRMRecordLabel($field);
             } elseif ($field == 0) {
                 $field = '';
             }
         }
         if ($field_uitype == 69) {
             $recordModel = Vtiger_Record_Model::getInstanceById($recordid, $module);
             $details = $recordModel->getImageDetails();
             if (is_array($details[0])) {
                 $field = $details[0]['path'] . '_' . $details[0]['orgname'];
             } else {
                 $field = '';
             }
         }
         /// For fields with VAT for products
         if ($field_uitype == 83) {
             $pobierz_tax = $db->query("select * from vtiger_producttaxrel where productid = '{$recordid}'", true);
             for ($i = 0; $i < $db->num_rows($pobierz_tax); $i++) {
                 $taxid = $db->query_result($pobierz_tax, $i, "taxid");
                 $taxvalue = $db->query_result($pobierz_tax, $i, "taxpercentage");
                 if ($taxid == 1) {
                     $field .= getTranslatedString('LBL_VAT') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%';
                 } elseif ($taxid == 2) {
                     $field .= getTranslatedString('LBL_SALES') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%';
                 } elseif ($taxid == 3) {
                     $field .= getTranslatedString('LBL_SERVICE') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%';
                 }
                 $field .= '<br/>';
             }
         }
         /// For selection lists
         if ($field_uitype == 15 || $field_uitype == 16 || $field_uitype == 55 && $fieldname == 'salutationtype') {
             if ($module == 'Activity') {
                 $field = getTranslatedString($field, "Calendar");
             } else {
                 $field = getTranslatedString($field, $module);
             }
         }
         if ($field_uitype == 19) {
             $field = htmlspecialchars_decode($field);
         }
         $content = str_replace("#{$key}#", nl2br($field), $content);
         if ($module == 'Activity') {
             $content = str_replace("#label_{$key}#", getTranslatedString($label, "Calendar"), $content);
         } else {
             $content = str_replace("#label_{$key}#", getTranslatedString($label, $module), $content);
         }
         if ($field_uitype == 33) {
             $content = str_replace('|##|', ',', $content);
         }
     }
     return $content;
 }
Esempio n. 27
0
 function getFieldDisplayValue($moduleName, $recordId, $fieldInstance, $value)
 {
     global $current_user;
     $adb = PearDatabase::getInstance();
     $fieldName = $fieldInstance->getFieldName();
     $uitype = $fieldInstance->getUIType();
     if ($moduleName == 'Documents') {
         if ($fieldName == 'filesize') {
             $filesize = $value;
             if (empty($fieldsize)) {
                 $value = '--';
             } elseif ($filesize < 1024) {
                 $value = $filesize . ' B';
             } elseif ($filesize > 1024 && $filesize < 1048576) {
                 $value = round($filesize / 1024, 2) . ' KB';
             } else {
                 if ($filesize > 1048576) {
                     $value = round($filesize / (1024 * 1024), 2) . ' MB';
                 }
             }
         }
         if ($fieldName == 'filestatus') {
             if ($value == 1) {
                 $value = getTranslatedString('yes', $moduleName);
             } elseif ($value == 0) {
                 $value = getTranslatedString('no', $moduleName);
             } else {
                 $value = '--';
             }
         }
         if ($fieldName == 'filetype') {
             if ($value == 1) {
                 $value = getTranslatedString('yes', $moduleName);
             } elseif ($value == 0) {
                 $value = getTranslatedString('no', $moduleName);
             } else {
                 $value = '--';
             }
         }
     }
     if ($fieldInstance->getUIType() == '27') {
         if ($value == 'I') {
             $value = getTranslatedString('LBL_INTERNAL', $moduleName);
         } elseif ($value == 'E') {
             $value = getTranslatedString('LBL_EXTERNAL', $moduleName);
         } else {
             $value = ' --';
         }
     }
     if ($fieldInstance->getFieldDataType() == 'picklist') {
         $isRoleBased = vtws_isRoleBasedPicklist($fieldName);
         if ($isRoleBased && ($fieldName != 'activitytype' || $value != 'Task')) {
             $accessiblePicklistValues = getAssignedPicklistValues($fieldName, $current_user->roleid, $adb);
             if (!empty($value) && !is_admin($current_user) && !in_array($value, $accessiblePicklistValues)) {
                 $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $moduleName) . "</font>";
             } else {
                 $value = getTranslatedString($value, $moduleName);
             }
         } else {
             $value = getTranslatedString($value, $moduleName);
         }
     }
     if ($fieldInstance->getFieldDataType() == 'date' || $fieldInstance->getFieldDataType() == 'datetime' || $fieldInstance->getFieldDataType() == 'time') {
         if ($value != '' && $value != '0000-00-00') {
             $date = new DateTimeField($value);
             if ($fieldInstance->getFieldDataType() == 'date') {
                 $value = $date->getDisplayDate();
             }
             if ($fieldInstance->getFieldDataType() == 'datetime') {
                 $value = $date->getDisplayDateTimeValue();
             }
             if ($fieldInstance->getFieldDataType() == 'time') {
                 $value = $date->getDisplayTime();
             }
         } else {
             $value = '';
         }
     }
     if ($fieldInstance->getFieldDataType() == 'currency') {
         if ($value != '' && $value != 0) {
             if ($fieldInstance->getUIType() == 72) {
                 if ($fieldName == 'unit_price') {
                     $currencyId = getProductBaseCurrency($recordId, $moduleName);
                     $cursym_convrate = getCurrencySymbolandCRate($currencyId);
                     $currencySymbol = $cursym_convrate['symbol'];
                 } else {
                     $currencyInfo = getInventoryCurrencyInfo($moduleName, $recordId);
                     $currencySymbol = $currencyInfo['currency_symbol'];
                 }
                 $currencyValue = CurrencyField::convertToUserFormat($value, null, true);
                 $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol);
             } else {
                 $currencyField = new CurrencyField($value);
                 $value = $currencyField->getDisplayValueWithSymbol();
             }
         }
     }
     if ($fieldInstance->getFieldDataType() == 'url') {
         $matchPattern = "^[\\w]+:\\/\\/^";
         preg_match($matchPattern, $value, $matches);
         if (!empty($matches[0])) {
             $value = '<a href="' . $value . '" target="_blank">' . $value . '</a>';
         } else {
             $value = '<a href="http://' . $value . '" target="_blank">' . $value . '</a>';
         }
     }
     if ($fieldInstance->getFieldDataType() == 'boolean') {
         if ($value == 1) {
             $value = getTranslatedString('yes', $moduleName);
         } elseif ($value == 0) {
             $value = getTranslatedString('no', $moduleName);
         } else {
             $value = '--';
         }
     }
     if ($fieldInstance->getFieldDataType() == 'multipicklist') {
         $value = $value != "" ? str_replace(' |##| ', ', ', $value) : "";
         $isRoleBased = vtws_isRoleBasedPicklist($fieldName);
         if (!is_admin($current_user) && $value != '' && $isRoleBased) {
             $accessiblePicklistValues = getAssignedPicklistValues($fieldName, $current_user->roleid, $adb);
             $valueArray = $value != "" ? explode(', ', $value) : array();
             $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $moduleName) . "</font>";
             $tmpArray = array();
             foreach ($valueArray as $index => $val) {
                 if (!in_array(trim($val), $accessiblePicklistValues)) {
                     $tmpArray[] = $notaccess;
                 } else {
                     $tmpArray[] = $val;
                 }
             }
             $value = implode(', ', $tmpArray);
         }
     }
     if ($fieldInstance->getFieldDataType() == 'reference') {
         if (!empty($value)) {
             $referenceList = $fieldInstance->getReferenceList();
             if (count($referenceList) > 0) {
                 $firstReferenceModule = $referenceList[0];
                 if ($firstReferenceModule == 'Users') {
                     $value = getUserFullName($value);
                 } elseif ($firstReferenceModule == 'DocumentFolders') {
                     $wsFolderId = vtws_getWebserviceEntityId('DocumentFolders', $value);
                     $value = vtws_getName($wsFolderId, $current_user);
                 } elseif ($firstReferenceModule == 'Currency') {
                     $value = getCurrencyName($value);
                 } else {
                     $referenceModule = getSalesEntityType($value);
                     $entityNames = getEntityName($referenceModule, array($value));
                     $value = $entityNames[$value];
                 }
             } else {
                 $value = '--';
             }
         } else {
             $value = '--';
         }
     }
     if ($fieldInstance->getFieldDataType() == 'owner') {
         $ownerName = trim(getUserFullName($value));
         if (empty($ownerName)) {
             $ownerInfo = getGroupName($value);
             $ownerName = $ownerInfo[0];
         }
         $value = $ownerName;
     }
     return $value;
 }
Esempio n. 28
0
 public function process(Vtiger_Request $request)
 {
     PDFMaker_Debugger_Model::GetInstance()->Init();
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     $viewer = $this->getViewer($request);
     if ($request->has('templateid') && !$request->isEmpty('templateid')) {
         $templateid = $request->get('templateid');
         $pdftemplateResult = $PDFMaker->GetEditViewData($templateid);
         $select_module = $pdftemplateResult["module"];
         $select_format = $pdftemplateResult["format"];
         $select_orientation = $pdftemplateResult["orientation"];
         $nameOfFile = $pdftemplateResult["file_name"];
         $is_portal = $pdftemplateResult["is_portal"];
         $is_listview = $pdftemplateResult["is_listview"];
         $is_active = $pdftemplateResult["is_active"];
         $is_default = $pdftemplateResult["is_default"];
         $order = $pdftemplateResult["order"];
         $owner = $pdftemplateResult["owner"];
         $sharingtype = $pdftemplateResult["sharingtype"];
         $sharingMemberArray = $PDFMaker->GetSharingMemberArray($templateid);
         $disp_header = $pdftemplateResult["disp_header"];
         $disp_footer = $pdftemplateResult["disp_footer"];
         if (!$pdftemplateResult["permissions"]["edit"]) {
             $PDFMaker->DieDuePermission();
         }
     } else {
         $templateid = "";
         if ($request->has("return_module") && !$request->isEmpty("return_module")) {
             $select_module = $request->get("return_module");
         } else {
             $select_module = "";
         }
         $select_format = "A4";
         $select_orientation = "portrait";
         //$select_encoding = "utf-8";
         $nameOfFile = "";
         $is_portal = "0";
         $is_listview = "0";
         $is_active = "1";
         $is_default = "0";
         $order = "1";
         $owner = $cu_model->id;
         $sharingtype = "public";
         $sharingMemberArray = array();
         $disp_header = "3";
         $disp_footer = "7";
         $PDFMaker->CheckTemplatePermissions($select_module, $templateid);
     }
     if ($PDFMaker->GetVersionType() == "professional") {
         $type = "professional";
     } else {
         $type = "basic";
     }
     $viewer->assign("TYPE", $type);
     if ($request->has("isDuplicate") && $request->get("isDuplicate") == "true") {
         $viewer->assign("FILENAME", "");
         $viewer->assign("DUPLICATE_FILENAME", $pdftemplateResult["filename"]);
     } else {
         $viewer->assign("FILENAME", $pdftemplateResult["filename"]);
     }
     $viewer->assign("DESCRIPTION", $pdftemplateResult["description"]);
     if (!$request->has("isDuplicate") or $request->has("isDuplicate") && $request->get("isDuplicate") != "true") {
         $viewer->assign("SAVETEMPLATEID", $templateid);
     }
     if ($templateid != "") {
         $viewer->assign("EMODE", "edit");
     }
     $viewer->assign("TEMPLATEID", $templateid);
     $viewer->assign("MODULENAME", vtranslate($select_module, $select_module));
     $viewer->assign("SELECTMODULE", $select_module);
     $viewer->assign("BODY", $pdftemplateResult["body"]);
     $cu_model = Users_Record_Model::getCurrentUserModel();
     $this->cu_language = $cu_model->get('language');
     $viewer->assign("THEME", $theme);
     $viewer->assign("IMAGE_PATH", $image_path);
     $app_strings_big = Vtiger_Language_Handler::getModuleStringsFromFile($this->cu_language);
     $app_strings = $app_strings_big['languageStrings'];
     $viewer->assign("APP", $app_strings);
     $viewer->assign("PARENTTAB", getParentTab());
     $modArr = $PDFMaker->GetAllModules();
     $Modulenames = $modArr[0];
     $ModuleIDS = $modArr[1];
     $viewer->assign("MODULENAMES", $Modulenames);
     // ******************************************   Company and User information: **********************************
     $CUI_BLOCKS["Account"] = vtranslate("LBL_COMPANY_INFO", 'PDFMaker');
     $CUI_BLOCKS["Assigned"] = vtranslate("LBL_USER_INFO", 'PDFMaker');
     $CUI_BLOCKS["Logged"] = vtranslate("LBL_LOGGED_USER_INFO", 'PDFMaker');
     $viewer->assign("CUI_BLOCKS", $CUI_BLOCKS);
     $adb = PearDatabase::getInstance();
     $sql = "SELECT * FROM vtiger_organizationdetails";
     $result = $adb->pquery($sql, array());
     $organization_logoname = decode_html($adb->query_result($result, 0, 'logoname'));
     $organization_header = decode_html($adb->query_result($result, 0, 'headername'));
     $organization_stamp_signature = $adb->query_result($result, 0, 'stamp_signature');
     global $site_URL;
     $path = $site_URL . "/test/logo/";
     if (isset($organization_logoname)) {
         $organization_logo_img = "<img src=\"" . $path . $organization_logoname . "\">";
         $viewer->assign("COMPANYLOGO", $organization_logo_img);
     }
     if (isset($organization_stamp_signature)) {
         $organization_stamp_signature_img = "<img src=\"" . $path . $organization_stamp_signature . "\">";
         $viewer->assign("COMPANY_STAMP_SIGNATURE", $organization_stamp_signature_img);
     }
     if (isset($organization_header)) {
         $organization_header_img = "<img src=\"" . $path . $organization_header . "\">";
         $viewer->assign("COMPANY_HEADER_SIGNATURE", $organization_header_img);
     }
     $Acc_Info = array('' => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "COMPANY_NAME" => vtranslate("LBL_COMPANY_NAME", 'PDFMaker'), "COMPANY_LOGO" => vtranslate("LBL_COMPANY_LOGO", 'PDFMaker'), "COMPANY_ADDRESS" => vtranslate("LBL_COMPANY_ADDRESS", 'PDFMaker'), "COMPANY_CITY" => vtranslate("LBL_COMPANY_CITY", 'PDFMaker'), "COMPANY_STATE" => vtranslate("LBL_COMPANY_STATE", 'PDFMaker'), "COMPANY_ZIP" => vtranslate("LBL_COMPANY_ZIP", 'PDFMaker'), "COMPANY_COUNTRY" => vtranslate("LBL_COMPANY_COUNTRY", 'PDFMaker'), "COMPANY_PHONE" => vtranslate("LBL_COMPANY_PHONE", "PDFMaker"), "COMPANY_FAX" => vtranslate("LBL_COMPANY_FAX", 'PDFMaker'), "COMPANY_WEBSITE" => vtranslate("LBL_COMPANY_WEBSITE", 'PDFMaker'));
     $viewer->assign("ACCOUNTINFORMATIONS", $Acc_Info);
     if (getTabId('MultiCompany4you') && vtlib_isModuleActive('MultiCompany4you')) {
         $MultiAcc_info = array('' => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "MULTICOMPANY_COMPANYNAME" => vtranslate("LBL_COMPANY_NAME", 'MultiCompany4you'), "MULTICOMPANY_STREET" => vtranslate("Street", 'MultiCompany4you'), "MULTICOMPANY_CITY" => vtranslate("City", 'MultiCompany4you'), "MULTICOMPANY_CODE" => vtranslate("Code", 'MultiCompany4you'), "MULTICOMPANY_STATE" => vtranslate("State", 'MultiCompany4you'), "MULTICOMPANY_COUNTRY" => vtranslate("Country", 'MultiCompany4you'), "MULTICOMPANY_PHONE" => vtranslate("phone", 'MultiCompany4you'), "MULTICOMPANY_FAX" => vtranslate("Fax", 'MultiCompany4you'), "MULTICOMPANY_EMAIL" => vtranslate("email", 'MultiCompany4you'), "MULTICOMPANY_WEBSITE" => vtranslate("Website", 'MultiCompany4you'), "MULTICOMPANY_LOGO" => vtranslate("Logo", 'MultiCompany4you'), "MULTICOMPANY_STAMP" => vtranslate("Stamp", 'MultiCompany4you'), "MULTICOMPANY_BANKNAME" => vtranslate("BankName", 'MultiCompany4you'), "MULTICOMPANY_BANKACCOUNTNO" => vtranslate("BankAccountNo", 'MultiCompany4you'), "MULTICOMPANY_IBAN" => vtranslate("IBAN", 'MultiCompany4you'), "MULTICOMPANY_SWIFT" => vtranslate("SWIFT", 'MultiCompany4you'), "MULTICOMPANY_REGISTRATIONNO" => vtranslate("RegistrationNo", 'MultiCompany4you'), "MULTICOMPANY_VATNO" => vtranslate("VATNo", 'MultiCompany4you'), "MULTICOMPANY_TAXID" => vtranslate("TaxId", 'MultiCompany4you'), "MULTICOMPANY_ADDITIONALINFORMATIONS" => vtranslate("AdditionalInformations", 'MultiCompany4you'));
         $viewer->assign("MULTICOMPANYINFORMATIONS", $MultiAcc_info);
         $viewer->assign("LBL_MULTICOMPANY", vtranslate('MultiCompany', 'MultiCompany4you'));
     }
     $sql_user_block = "SELECT blockid, blocklabel FROM vtiger_blocks WHERE tabid = ? ORDER BY sequence ASC";
     $res_user_block = $adb->pquery($sql_user_block, array('29'));
     $user_block_info_arr = array();
     while ($row_user_block = $adb->fetch_array($res_user_block)) {
         $sql_user_field = "SELECT fieldid, uitype FROM vtiger_field WHERE block = ? and (displaytype != ? OR uitype = ?) ORDER BY sequence ASC";
         $res_user_field = $adb->pquery($sql_user_field, array($row_user_block['blockid'], '3', '55'));
         $num_user_field = $adb->num_rows($res_user_field);
         if ($num_user_field > 0) {
             $user_field_id_array = array();
             while ($row_user_field = $adb->fetch_array($res_user_field)) {
                 $user_field_id_array[] = $row_user_field['fieldid'];
             }
             $user_block_info_arr[$row_user_block['blocklabel']] = $user_field_id_array;
         }
     }
     $user_mod_strings = $this->getModuleLanguageArray("Users");
     $b = 0;
     foreach ($user_block_info_arr as $block_label => $block_fields) {
         $b++;
         if (isset($user_mod_strings[$block_label]) and $user_mod_strings[$block_label] != "") {
             $optgroup_value = $user_mod_strings[$block_label];
         } else {
             $optgroup_value = vtranslate($block_label, 'PDFMaker');
         }
         if (count($block_fields) > 0) {
             $sql1 = "SELECT * FROM vtiger_field WHERE fieldid IN (" . generateQuestionMarks($block_fields) . ")";
             $result1 = $adb->pquery($sql1, $block_fields);
             while ($row1 = $adb->fetchByAssoc($result1)) {
                 $fieldname = $row1['fieldname'];
                 $fieldlabel = $row1['fieldlabel'];
                 $option_key = strtoupper("Users" . "_" . $fieldname);
                 if (isset($current_mod_strings[$fieldlabel]) and $current_mod_strings[$fieldlabel] != "") {
                     $option_value = $current_mod_strings[$fieldlabel];
                 } elseif (isset($app_strings[$fieldlabel]) and $app_strings[$fieldlabel] != "") {
                     $option_value = $app_strings[$fieldlabel];
                 } else {
                     $option_value = $fieldlabel;
                 }
                 $User_Info[$optgroup_value][$option_key] = $option_value;
                 $Logged_User_Info[$optgroup_value]["R_" . $option_key] = $option_value;
             }
         }
         //variable RECORD ID added
         if ($b == 1) {
             $option_value = "Record ID";
             $option_key = strtoupper("USERS_CRMID");
             $User_Info[$optgroup_value][$option_key] = $option_value;
             $Logged_User_Info[$optgroup_value]["R_" . $option_key] = $option_value;
         }
         //end
     }
     // ****************************************** END: Company and User information **********************************
     $viewer->assign("USERINFORMATIONS", $User_Info);
     $viewer->assign("LOGGEDUSERINFORMATION", $Logged_User_Info);
     $Invterandcon = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "TERMS_AND_CONDITIONS" => vtranslate("LBL_TERMS_AND_CONDITIONS", 'PDFMaker'));
     $viewer->assign("INVENTORYTERMSANDCONDITIONS", $Invterandcon);
     //custom functions
     $customFunctions = $this->getCustomFunctionsList();
     $viewer->assign("CUSTOM_FUNCTIONS", $customFunctions);
     //labels
     $global_lang_labels = @array_flip($app_strings);
     $global_lang_labels = @array_flip($global_lang_labels);
     asort($global_lang_labels);
     $viewer->assign("GLOBAL_LANG_LABELS", $global_lang_labels);
     $module_lang_labels = array();
     if ($select_module != "") {
         $mod_lang = $this->getModuleLanguageArray($select_module);
         $module_lang_labels = @array_flip($mod_lang);
         $module_lang_labels = @array_flip($module_lang_labels);
         asort($module_lang_labels);
     } else {
         $module_lang_labels[""] = vtranslate("LBL_SELECT_MODULE_FIELD", 'PDFMaker');
     }
     $viewer->assign("MODULE_LANG_LABELS", $module_lang_labels);
     list($custom_labels, $languages) = $PDFMaker->GetCustomLabels();
     $currLangId = "";
     foreach ($languages as $langId => $langVal) {
         if ($langVal["prefix"] == $current_language) {
             $currLangId = $langId;
             break;
         }
     }
     $vcustom_labels = array();
     if (count($custom_labels) > 0) {
         foreach ($custom_labels as $oLbl) {
             $currLangVal = $oLbl->GetLangValue($currLangId);
             if ($currLangVal == "") {
                 $currLangVal = $oLbl->GetFirstNonEmptyValue();
             }
             $vcustom_labels[$oLbl->GetKey()] = $currLangVal;
         }
         asort($vcustom_labels);
     } else {
         $vcustom_labels = vtranslate("LBL_SELECT_MODULE_FIELD", 'PDFMaker');
     }
     $viewer->assign("CUSTOM_LANG_LABELS", $vcustom_labels);
     $Header_Footer_Strings = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "PAGE" => $app_strings["Page"], "PAGES" => $app_strings["Pages"]);
     $viewer->assign("HEADER_FOOTER_STRINGS", $Header_Footer_Strings);
     //PDF FORMAT SETTINGS
     $Formats = array("A3" => "A3", "A4" => "A4", "A5" => "A5", "A6" => "A6", "Letter" => "Letter", "Legal" => "Legal", "Custom" => "Custom");
     // ITS4YOU VlZa
     $viewer->assign("FORMATS", $Formats);
     if (strpos($select_format, ";") > 0) {
         $tmpArr = explode(";", $select_format);
         $select_format = "Custom";
         $custom_format["width"] = $tmpArr[0];
         $custom_format["height"] = $tmpArr[1];
         $viewer->assign("CUSTOM_FORMAT", $custom_format);
     }
     $viewer->assign("SELECT_FORMAT", $select_format);
     //PDF ORIENTATION SETTINGS
     $Orientations = array("portrait" => vtranslate("portrait", 'PDFMaker'), "landscape" => vtranslate("landscape", 'PDFMaker'));
     $viewer->assign("ORIENTATIONS", $Orientations);
     $viewer->assign("SELECT_ORIENTATION", $select_orientation);
     //PDF STATUS SETTINGS
     $Status = array("1" => $app_strings["Active"], "0" => vtranslate("Inactive", 'PDFMaker'));
     $viewer->assign("STATUS", $Status);
     $viewer->assign("IS_ACTIVE", $is_active);
     if ($is_active == "0") {
         $viewer->assign("IS_DEFAULT_DV_CHECKED", 'disabled="disabled"');
         $viewer->assign("IS_DEFAULT_LV_CHECKED", 'disabled="disabled"');
     } elseif ($is_default > 0) {
         $is_default_bin = str_pad(base_convert($is_default, 10, 2), 2, "0", STR_PAD_LEFT);
         $is_default_lv = substr($is_default_bin, 0, 1);
         $is_default_dv = substr($is_default_bin, 1, 1);
         if ($is_default_lv == "1") {
             $viewer->assign("IS_DEFAULT_LV_CHECKED", 'checked="checked"');
         }
         if ($is_default_dv == "1") {
             $viewer->assign("IS_DEFAULT_DV_CHECKED", 'checked="checked"');
         }
     }
     $viewer->assign("ORDER", $order);
     if ($is_portal == "1") {
         $viewer->assign("IS_PORTAL_CHECKED", 'checked="checked"');
     }
     if ($is_listview == "1") {
         $viewer->assign("IS_LISTVIEW_CHECKED", 'checked="checked"');
     }
     //PDF MARGIN SETTINGS
     if ($request->has("templateid") && !$request->isEmpty("templateid")) {
         $Margins = array("top" => $pdftemplateResult["margin_top"], "bottom" => $pdftemplateResult["margin_bottom"], "left" => $pdftemplateResult["margin_left"], "right" => $pdftemplateResult["margin_right"]);
         $Decimals = array("point" => $pdftemplateResult["decimal_point"], "decimals" => $pdftemplateResult["decimals"], "thousands" => $pdftemplateResult["thousands_separator"] != "sp" ? $pdftemplateResult["thousands_separator"] : " ");
     } else {
         $Margins = array("top" => "2", "bottom" => "2", "left" => "2", "right" => "2");
         $Decimals = array("point" => ",", "decimals" => "2", "thousands" => " ");
     }
     $viewer->assign("MARGINS", $Margins);
     $viewer->assign("DECIMALS", $Decimals);
     //PDF HEADER / FOOTER
     $header = "";
     $footer = "";
     if ($request->has("templateid") && !$request->isEmpty("templateid")) {
         $header = $pdftemplateResult["header"];
         $footer = $pdftemplateResult["footer"];
     }
     $viewer->assign("HEADER", $header);
     $viewer->assign("FOOTER", $footer);
     $hfVariables = array("##PAGE##" => vtranslate("LBL_CURRENT_PAGE", 'PDFMaker'), "##PAGES##" => vtranslate("LBL_ALL_PAGES", 'PDFMaker'), "##PAGE##/##PAGES##" => vtranslate("LBL_PAGE_PAGES", 'PDFMaker'));
     $viewer->assign("HEAD_FOOT_VARS", $hfVariables);
     $dateVariables = array("##DD.MM.YYYY##" => vtranslate("LBL_DATE_DD.MM.YYYY", 'PDFMaker'), "##DD-MM-YYYY##" => vtranslate("LBL_DATE_DD-MM-YYYY", 'PDFMaker'), "##MM-DD-YYYY##" => vtranslate("LBL_DATE_MM-DD-YYYY", 'PDFMaker'), "##YYYY-MM-DD##" => vtranslate("LBL_DATE_YYYY-MM-DD", 'PDFMaker'));
     $viewer->assign("DATE_VARS", $dateVariables);
     //PDF FILENAME FIELDS
     $filenameFields = array("#TEMPLATE_NAME#" => vtranslate("LBL_PDF_NAME", 'PDFMaker'), "#DD-MM-YYYY#" => vtranslate("LBL_CURDATE_DD-MM-YYYY", 'PDFMaker'), "#MM-DD-YYYY#" => vtranslate("LBL_CURDATE_MM-DD-YYYY", 'PDFMaker'), "#YYYY-MM-DD#" => vtranslate("LBL_CURDATE_YYYY-MM-DD", 'PDFMaker'));
     $viewer->assign("FILENAME_FIELDS", $filenameFields);
     $viewer->assign("NAME_OF_FILE", $nameOfFile);
     //Sharing
     $template_owners = get_user_array(false);
     $viewer->assign("TEMPLATE_OWNERS", $template_owners);
     $viewer->assign("TEMPLATE_OWNER", $owner);
     $sharing_types = array("public" => vtranslate("PUBLIC_FILTER", 'PDFMaker'), "private" => vtranslate("PRIVATE_FILTER", 'PDFMaker'), "share" => vtranslate("SHARE_FILTER", 'PDFMaker'));
     $viewer->assign("SHARINGTYPES", $sharing_types);
     $viewer->assign("SHARINGTYPE", $sharingtype);
     $cmod = $this->getModuleLanguageArray("Settings");
     //$cmod = return_specified_module_language($current_language, "Settings");
     $viewer->assign("CMOD", $cmod);
     //Constructing the Role Array
     $roleDetails = getAllRoleDetails();
     $i = 0;
     $roleIdStr = "";
     $roleNameStr = "";
     $userIdStr = "";
     $userNameStr = "";
     $grpIdStr = "";
     $grpNameStr = "";
     foreach ($roleDetails as $roleId => $roleInfo) {
         if ($i != 0) {
             if ($i != 1) {
                 $roleIdStr .= ", ";
                 $roleNameStr .= ", ";
             }
             $roleName = $roleInfo[0];
             $roleIdStr .= "'" . $roleId . "'";
             $roleNameStr .= "'" . addslashes(decode_html($roleName)) . "'";
         }
         $i++;
     }
     //Constructing the User Array
     $l = 0;
     $userDetails = getAllUserName();
     foreach ($userDetails as $userId => $userInfo) {
         if ($l != 0) {
             $userIdStr .= ", ";
             $userNameStr .= ", ";
         }
         $userIdStr .= "'" . $userId . "'";
         $userNameStr .= "'" . $userInfo . "'";
         $l++;
     }
     //Constructing the Group Array
     $parentGroupArray = array();
     $m = 0;
     $grpDetails = getAllGroupName();
     foreach ($grpDetails as $grpId => $grpName) {
         if (!in_array($grpId, $parentGroupArray)) {
             if ($m != 0) {
                 $grpIdStr .= ", ";
                 $grpNameStr .= ", ";
             }
             $grpIdStr .= "'" . $grpId . "'";
             $grpNameStr .= "'" . addslashes(decode_html($grpName)) . "'";
             $m++;
         }
     }
     $viewer->assign("ROLEIDSTR", $roleIdStr);
     $viewer->assign("ROLENAMESTR", $roleNameStr);
     $viewer->assign("USERIDSTR", $userIdStr);
     $viewer->assign("USERNAMESTR", $userNameStr);
     $viewer->assign("GROUPIDSTR", $grpIdStr);
     $viewer->assign("GROUPNAMESTR", $grpNameStr);
     if (count($sharingMemberArray) > 0) {
         $outputMemberArr = array();
         foreach ($sharingMemberArray as $setype => $shareIdArr) {
             foreach ($shareIdArr as $shareId) {
                 switch ($setype) {
                     case "groups":
                         $groupInfo = getGroupName($shareId);
                         $memberName = $groupInfo[0];
                         $memberDisplay = "Group::";
                         break;
                     case "roles":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "Roles::";
                         break;
                     case "rs":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "RoleAndSubordinates::";
                         break;
                     case "users":
                         $memberName = getUserName($shareId);
                         $memberDisplay = "User::";
                         break;
                 }
                 $outputMemberArr[] = $setype . "::" . $shareId;
                 $outputMemberArr[] = $memberDisplay . $memberName;
             }
         }
         $viewer->assign("MEMBER", array_chunk($outputMemberArr, 2));
     }
     //Ignored picklist values
     $pvsql = "SELECT value FROM vtiger_pdfmaker_ignorepicklistvalues";
     $pvresult = $adb->pquery($pvsql, array());
     $pvvalues = "";
     while ($pvrow = $adb->fetchByAssoc($pvresult)) {
         $pvvalues .= $pvrow["value"] . ", ";
     }
     $viewer->assign("IGNORE_PICKLIST_VALUES", rtrim($pvvalues, ", "));
     $More_Fields = array("CURRENCYNAME" => vtranslate("LBL_CURRENCY_NAME", 'PDFMaker'), "CURRENCYSYMBOL" => vtranslate("LBL_CURRENCY_SYMBOL", 'PDFMaker'), "CURRENCYCODE" => vtranslate("LBL_CURRENCY_CODE", 'PDFMaker'), "TOTALWITHOUTVAT" => vtranslate("LBL_VARIABLE_SUMWITHOUTVAT", 'PDFMaker'), "TOTALDISCOUNT" => vtranslate("LBL_VARIABLE_TOTALDISCOUNT", 'PDFMaker'), "TOTALDISCOUNTPERCENT" => vtranslate("LBL_VARIABLE_TOTALDISCOUNT_PERCENT", 'PDFMaker'), "TOTALAFTERDISCOUNT" => vtranslate("LBL_VARIABLE_TOTALAFTERDISCOUNT", 'PDFMaker'), "VAT" => vtranslate("LBL_VARIABLE_VAT", 'PDFMaker'), "VATPERCENT" => vtranslate("LBL_VARIABLE_VAT_PERCENT", 'PDFMaker'), "VATBLOCK" => vtranslate("LBL_VARIABLE_VAT_BLOCK", 'PDFMaker'), "TOTALWITHVAT" => vtranslate("LBL_VARIABLE_SUMWITHVAT", 'PDFMaker'), "SHTAXTOTAL" => vtranslate("LBL_SHTAXTOTAL", 'PDFMaker'), "SHTAXAMOUNT" => vtranslate("LBL_SHTAXAMOUNT", 'PDFMaker'), "ADJUSTMENT" => vtranslate("LBL_ADJUSTMENT", 'PDFMaker'), "TOTAL" => vtranslate("LBL_VARIABLE_TOTALSUM", 'PDFMaker'));
     //formatable VATBLOCK content
     $vatblock_table = '<table border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse;">
             		<tr>
                         <td>' . $app_strings["Name"] . '</td>
                         <td>' . vtranslate("LBL_VATBLOCK_VAT_PERCENT", 'PDFMaker') . '</td>
                         <td>' . vtranslate("LBL_VATBLOCK_SUM", 'PDFMaker') . '</td>
                         <td>' . vtranslate("LBL_VATBLOCK_VAT_VALUE", 'PDFMaker') . '</td>
                     </tr>
             		<tr>
                         <td colspan="4">#VATBLOCK_START#</td>
                     </tr>
             		<tr>
             			<td>$VATBLOCK_LABEL$</td>
             			<td>$VATBLOCK_VALUE$</td>
             			<td>$VATBLOCK_NETTO$</td>
             			<td>$VATBLOCK_VAT$</td>
             		</tr>
             		<tr>
                         <td colspan="4">#VATBLOCK_END#</td>
                     </tr>
                 </table>';
     $vatblock_table = str_replace(array("\r\n", "\r", "\n", "\t"), "", $vatblock_table);
     $vatblock_table = ereg_replace(" {2,}", ' ', $vatblock_table);
     $viewer->assign("VATBLOCK_TABLE", $vatblock_table);
     $ModCommentsModules = array();
     /*
             $ModComments = is_numeric(getTabId("ModComments"));
             if ($ModComments == true) {
                 $sql = "SELECT relmodule FROM vtiger_fieldmodulerel WHERE module='ModComments' AND relmodule != 'ModComments'";
                 $result = $adb->pquery($sql,array());
                 while ($row = $adb->fetchByAssoc($result))
                     $ModCommentsModules[$row["relmodule"]] = $row["relmodule"];
             }
     */
     foreach ($ModuleIDS as $module => $module_id) {
         $this->getModuleFields($module, $module_id);
     }
     //Permissions are taken into consideration when dealing with realted modules
     $AllowedRelMods = array();
     if (count($this->All_Related_Modules) > 0) {
         foreach ($this->All_Related_Modules as $Mod => $RelMods) {
             foreach ($RelMods as $RelModKey => $RelMod) {
                 $RelModName = $RelMod[2];
                 if (isPermitted($RelModName, '') == "yes") {
                     $AllowedRelMods[$Mod][$RelModKey] = $RelMod;
                 }
             }
         }
     }
     $this->All_Related_Modules = $AllowedRelMods;
     // Fix of emtpy selectbox in case of selected module does not have any related modules
     foreach ($Modulenames as $key => $value) {
         if (!isset($this->All_Related_Modules[$key])) {
             $this->All_Related_Modules[$key] = array();
         }
     }
     $viewer->assign("ALL_RELATED_MODULES", $this->All_Related_Modules);
     if ($select_module != "" && count($this->All_Related_Modules[$select_module]) > 0) {
         foreach ($this->All_Related_Modules[$select_module] as $RelModArr) {
             $Related_Modules[$RelModArr[2] . "|" . $RelModArr[0]] = vtranslate($RelModArr[2]) . " (" . $RelModArr[1] . ")";
         }
     }
     $viewer->assign("RELATED_MODULES", $Related_Modules);
     $tacModules = array();
     $tac4you = is_numeric(getTabId("Tac4you"));
     if ($tac4you == true) {
         $sql = "SELECT tac4you_module FROM vtiger_tac4you_module WHERE presence = ?";
         $result = $adb->pquery($sql, array('1'));
         while ($row = $adb->fetchByAssoc($result)) {
             $tacModules[$row["tac4you_module"]] = $row["tac4you_module"];
         }
     }
     $desc4youModules = array();
     $desc4you = is_numeric(getTabId("Descriptions4you"));
     if ($desc4you == true) {
         $sql = "SELECT b.name FROM vtiger_links AS a INNER JOIN vtiger_tab AS b USING (tabid) WHERE linktype = ? AND linkurl = ?";
         $result = $adb->pquery($sql, array('DETAILVIEWWIDGET', 'block://ModDescriptions4you:modules/Descriptions4you/ModDescriptions4you.php'));
         while ($row = $adb->fetchByAssoc($result)) {
             $desc4youModules[$row["name"]] = $row["name"];
         }
     }
     $Settings_Profiles_Record_Model = new Settings_Profiles_Record_Model();
     foreach ($this->ModuleFields as $module => $Blocks) {
         $Optgroupts = array();
         $current_mod_strings = $this->getModuleLanguageArray($module);
         $moduleModel = Vtiger_Module_Model::getInstance($module);
         $b = 0;
         if ($module == 'Calendar') {
             $b++;
             $Optgroupts[] = '"' . vtranslate('Calendar') . '","' . $b . '"';
             $Convert_ModuleFields['Calendar|1'] .= ',"Record ID","CALENDAR_CRMID"';
             $SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"] = "Record ID";
             $EventModel = Vtiger_Module_Model::getInstance('Events');
         }
         foreach ($Blocks as $block_label => $block_fields) {
             $b++;
             $Options = array();
             if ($block_label != "TEMP_MODCOMMENTS_BLOCK") {
                 $optgroup_value = vtranslate($block_label, $module);
                 if ($optgroup_value == $block_label) {
                     $optgroup_value = vtranslate($block_label, 'PDFMaker');
                 }
             } else {
                 $optgroup_value = vtranslate("LBL_MODCOMMENTS_INFORMATION", 'PDFMaker');
             }
             $Optgroupts[] = '"' . $optgroup_value . '","' . $b . '"';
             if (count($block_fields) > 0) {
                 $sql1 = "SELECT * FROM vtiger_field WHERE fieldid IN (" . generateQuestionMarks($block_fields) . ")";
                 $result1 = $adb->pquery($sql1, $block_fields);
                 while ($row1 = $adb->fetchByAssoc($result1)) {
                     $fieldname = $row1['fieldname'];
                     $fieldlabel = $row1['fieldlabel'];
                     $fieldModel = Vtiger_Field_Model::getInstance($fieldname, $moduleModel);
                     if (!$fieldModel || !$fieldModel->getPermissions('readonly')) {
                         if ($module == 'Calendar') {
                             $eventFieldModel = Vtiger_Field_Model::getInstance($fieldname, $EventModel);
                             if (!$eventFieldModel || !$eventFieldModel->getPermissions('readonly')) {
                                 continue;
                             }
                         } else {
                             continue;
                         }
                     }
                     $option_key = strtoupper($module . "_" . $fieldname);
                     if (isset($current_mod_strings[$fieldlabel]) and $current_mod_strings[$fieldlabel] != "") {
                         $option_value = $current_mod_strings[$fieldlabel];
                     } elseif (isset($app_strings[$fieldlabel]) and $app_strings[$fieldlabel] != "") {
                         $option_value = $app_strings[$fieldlabel];
                     } else {
                         $option_value = $fieldlabel;
                     }
                     $option_value = nl2br($option_value);
                     if ($module == 'Calendar') {
                         if ($option_key == 'CALENDAR_ACTIVITYTYPE' || $option_key == 'CALENDAR_DUE_DATE') {
                             $Convert_ModuleFields['Calendar|1'] .= ',"' . $option_value . '","' . $option_key . '"';
                             $SelectModuleFields['Calendar'][vtranslate('Calendar')][$option_key] = $option_value;
                             continue;
                         } elseif (!isset($Existing_ModuleFields[$option_key])) {
                             $Existing_ModuleFields[$option_key] = $optgroup_value;
                         } else {
                             $Convert_ModuleFields['Calendar|1'] .= ',"' . $option_value . '","' . $option_key . '"';
                             $SelectModuleFields['Calendar'][vtranslate('Calendar')][$option_key] = $option_value;
                             $Unset_Module_Fields[] = '"' . $option_value . '","' . $option_key . '"';
                             unset($SelectModuleFields['Calendar'][$Existing_ModuleFields[$option_key]][$option_key]);
                             continue;
                         }
                     }
                     $Options[] = '"' . $option_value . '","' . $option_key . '"';
                     $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
                 }
             }
             //variable RECORD ID added
             if ($b == 1) {
                 $option_value = "Record ID";
                 $option_key = strtoupper($module . "_CRMID");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
                 $option_value = vtranslate('Created Time') . ' (' . vtranslate('Due Date & Time') . ')';
                 $option_key = strtoupper($module . "_CREATEDTIME_DATETIME");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
                 $option_value = vtranslate('Modified Time') . ' (' . vtranslate('Due Date & Time') . ')';
                 $option_key = strtoupper($module . "_MODIFIEDTIME_DATETIME");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             //end
             if ($block_label == "LBL_TERMS_INFORMATION" && isset($tacModules[$module])) {
                 $option_value = vtranslate("LBL_TAC4YOU", 'PDFMaker');
                 $option_key = strtoupper($module . "_TAC4YOU");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             if ($block_label == "LBL_DESCRIPTION_INFORMATION" && isset($desc4youModules[$module])) {
                 $option_value = vtranslate("LBL_DESC4YOU", 'PDFMaker');
                 $option_key = strtoupper($module . "_DESC4YOU");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             //ModComments support
             if ($block_label == "TEMP_MODCOMMENTS_BLOCK" && in_array($module, $ModCommentsModules) == true) {
                 $option_value = vtranslate("LBL_MODCOMMENTS", 'PDFMaker');
                 $option_key = strtoupper($module . "_MODCOMMENTS");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             $Convert_RelatedModuleFields[$module . "|" . $b] = implode(",", $Options);
             $OptionsRelMod = array();
             if (($block_label == "LBL_DETAILS_BLOCK" || $block_label == "LBL_ITEM_DETAILS") && ($module == "Quotes" || $module == "Invoice" || $module == "SalesOrder" || $module == "PurchaseOrder" || $module == "Issuecards" || $module == "Receiptcards" || $module == "Creditnote" || $module == "StornoInvoice")) {
                 $Set_More_Fields = $More_Fields;
                 if ($module == "Invoice") {
                     $Set_More_Fields[strtoupper($module) . "_RECEIVED"] = vtranslate("Received", $module);
                 }
                 if ($module == "Invoice" || $module == "PurchaseOrder") {
                     $Set_More_Fields[strtoupper($module) . "_BALANCE"] = vtranslate("Balance", $module);
                 }
                 foreach ($Set_More_Fields as $variable => $variable_name) {
                     $variable_key = strtoupper($variable);
                     $Options[] = '"' . $variable_name . '","' . $variable_key . '"';
                     $SelectModuleFields[$module][$optgroup_value][$variable_key] = $variable_name;
                     if ($variable_key != "VATBLOCK") {
                         $OptionsRelMod[] = '"' . $variable_name . '","' . strtoupper($module) . '_' . $variable_key . '"';
                     }
                 }
             }
             //this concatenation is because of need to have extra Details block in Inventory modules which are as related modules
             $Convert_RelatedModuleFields[$module . "|" . $b] .= implode(',', $OptionsRelMod);
             $Convert_ModuleFields[$module . "|" . $b] = implode(",", $Options);
         }
         if ($module == 'Calendar') {
             $Convert_ModuleFields['Calendar|1'] = str_replace(',"Record ID","CALENDAR_CRMID",', "", $Convert_ModuleFields['Calendar|1']);
             $Convert_ModuleFields['Calendar|1'] .= ',"Record ID","CALENDAR_CRMID"';
             unset($SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"]);
             $SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"] = "Record ID";
         }
         $Convert_ModuleBlocks[$module] = implode(",", $Optgroupts);
     }
     foreach ($Convert_ModuleFields as $cmf_key => $cmf_value) {
         if (substr($cmf_key, 0, 9) == 'Calendar|' && $cmf_key != 'Calendar|1') {
             foreach ($Unset_Module_Fields as $to_unset) {
                 $cmf_value = str_replace($to_unset, '', $cmf_value);
                 $cmf_value = str_replace(",,", ',', $cmf_value);
                 $Convert_ModuleFields[$cmf_key] = trim($cmf_value, ',');
             }
         }
     }
     $viewer->assign("MODULE_BLOCKS", $Convert_ModuleBlocks);
     $viewer->assign("RELATED_MODULE_FIELDS", $Convert_RelatedModuleFields);
     $viewer->assign("MODULE_FIELDS", $Convert_ModuleFields);
     //Product block fields start
     // Product bloc templates
     $sql = "SELECT * FROM vtiger_pdfmaker_productbloc_tpl";
     $result = $adb->pquery($sql, array());
     $Productbloc_tpl[""] = vtranslate("LBL_PLS_SELECT", 'PDFMaker');
     while ($row = $adb->fetchByAssoc($result)) {
         $Productbloc_tpl[$row["body"]] = $row["name"];
     }
     $viewer->assign("PRODUCT_BLOC_TPL", $Productbloc_tpl);
     $ProductBlockFields = $PDFMaker->GetProductBlockFields($select_module);
     foreach ($ProductBlockFields as $viewer_key => $pbFields) {
         $viewer->assign($viewer_key, $pbFields);
     }
     //Product block fields end
     //Related block postprocessing
     $Related_Blocks = $PDFMaker->GetRelatedBlocks($select_module);
     $viewer->assign("RELATED_BLOCKS", $Related_Blocks);
     //Related blocks end
     if ($templateid != "" || $select_module != "") {
         $viewer->assign("SELECT_MODULE_FIELD", $SelectModuleFields[$select_module]);
         $smf_filename = $SelectModuleFields[$select_module];
         if ($select_module == "Invoice" || $select_module == "Quotes" || $select_module == "SalesOrder" || $select_module == "PurchaseOrder" || $select_module == "Issuecards" || $select_module == "Receiptcards" || $select_module == "Creditnote" || $select_module == "StornoInvoice") {
             unset($smf_filename["Details"]);
         }
         $viewer->assign("SELECT_MODULE_FIELD_FILENAME", $smf_filename);
     }
     // header / footer display settings
     $disp_optionsArr = array("DH_FIRST", "DH_OTHER");
     $disp_header_bin = str_pad(base_convert($disp_header, 10, 2), 2, "0", STR_PAD_LEFT);
     for ($i = 0; $i < count($disp_optionsArr); $i++) {
         if (substr($disp_header_bin, $i, 1) == "1") {
             $viewer->assign($disp_optionsArr[$i], 'checked="checked"');
         }
     }
     if ($disp_header == "3") {
         $viewer->assign("DH_ALL", 'checked="checked"');
     }
     $disp_optionsArr = array("DF_FIRST", "DF_LAST", "DF_OTHER");
     $disp_footer_bin = str_pad(base_convert($disp_footer, 10, 2), 3, "0", STR_PAD_LEFT);
     for ($i = 0; $i < count($disp_optionsArr); $i++) {
         if (substr($disp_footer_bin, $i, 1) == "1") {
             $viewer->assign($disp_optionsArr[$i], 'checked="checked"');
         }
     }
     if ($disp_footer == "7") {
         $viewer->assign("DF_ALL", 'checked="checked"');
     }
     $ListView_Block = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "LISTVIEWBLOCK_START" => vtranslate("LBL_ARTICLE_START", 'PDFMaker'), "LISTVIEWBLOCK_END" => vtranslate("LBL_ARTICLE_END", 'PDFMaker'), "CRIDX" => vtranslate("LBL_COUNTER", 'PDFMaker'));
     $viewer->assign("LISTVIEW_BLOCK_TPL", $ListView_Block);
     $version_type = ucfirst($PDFMaker->GetVersionType());
     $viewer->assign("VERSION", $version_type . " " . PDFMaker_Version_Helper::$version);
     $category = getParentTab();
     $viewer->assign("CATEGORY", $category);
     $viewer->view('Edit.tpl', 'PDFMaker');
 }