Example #1
0
/** Function to get Secondary columns for an advanced filter
 *  This function accepts The module as an argument
 *  This generate columns of the secondary module for the advanced filter 
 *  It returns a HTML string of combo values
 */
function getSecondaryColumns_AdvFilterHTML($module, $selected = "")
{
    global $ITS4YouReports;
    global $app_list_strings;
    global $current_language;
    if ($module != "") {
        $secmodule = explode(":", $module);
        for ($i = 0; $i < count($secmodule); $i++) {
            $modulename = vtlib_getModuleNameById($secmodule[$i]);
            $mod_strings = return_module_language($current_language, $modulename);
            if (vtlib_isModuleActive($modulename)) {
                $block_listed = array();
                foreach ($ITS4YouReports->module_list[$modulename] as $key => $value) {
                    if (isset($ITS4YouReports->sec_module_columnslist[$modulename][$key]) && !$block_listed[$key]) {
                        $block_listed[$key] = true;
                        $shtml .= "<optgroup label=\"" . $app_list_strings['moduleList'][$modulename] . " " . getTranslatedString($key) . "\" class=\"select\" style=\"border:none\">";
                        foreach ($ITS4YouReports->sec_module_columnslist[$modulename][$key] as $field => $fieldlabel) {
                            if (isset($mod_strings[$fieldlabel])) {
                                if ($selected == $field) {
                                    $shtml .= "<option selected value=\"" . $field . "\">" . $mod_strings[$fieldlabel] . "</option>";
                                } else {
                                    $shtml .= "<option value=\"" . $field . "\">" . $mod_strings[$fieldlabel] . "</option>";
                                }
                            } else {
                                if ($selected == $field) {
                                    $shtml .= "<option selected value=\"" . $field . "\">" . $fieldlabel . "</option>";
                                } else {
                                    $shtml .= "<option value=\"" . $field . "\">" . $fieldlabel . "</option>";
                                }
                            }
                        }
                        $shtml .= "</optgroup>";
                    }
                }
            }
        }
    }
    return $shtml;
}
Example #2
0
 public function getInventoryJoinSQL(&$join_array, &$columns_array)
 {
     require_once 'modules/ITS4YouReports/ITS4YouReports.php';
     $fieldid_alias = "";
     if ($this->params["fieldid"] != "") {
         $fieldid_alias = "_" . $this->params["fieldid"];
     }
     $formodule = $this->params["formodule"];
     $oth_as = "_" . $formodule;
     // show("oldo ui 10 intentory join",$formodule,$this->params);
     $uirelmodule = vtlib_getModuleNameById($formodule);
     // show("oldo ui 10 intentory join2",$uirelmodule);
     $related_focus = CRMEntity::getInstance($uirelmodule);
     $field_case = $this->getJoinSQL_UI10($join_array, $columns_array, $uirelmodule);
     // show("oldo ui 10 intentory join000",$join_array,"oldo ui 10 intentory join000 POST");
     $join_array[" vtiger_inventoryproductrel AS vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . " "]["joincol"] = "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".id";
     $join_array[" vtiger_inventoryproductrel AS vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . " "]["using"] = $related_focus->table_name . $fieldid_alias . "." . $related_focus->table_index;
     $join_array[" vtiger_products AS vtiger_products_inv" . $oth_as . $fieldid_alias . " "]["joincol"] = "vtiger_products_inv" . $oth_as . $fieldid_alias . ".productid";
     $join_array[" vtiger_products AS vtiger_products_inv" . $oth_as . $fieldid_alias . " "]["using"] = "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".productid";
     $join_array[" vtiger_crmentity AS vtiger_crmentity_products_inv" . $oth_as . $fieldid_alias . " "]["joincol"] = "vtiger_crmentity_products_inv" . $oth_as . $fieldid_alias . ".crmid";
     $join_array[" vtiger_crmentity AS vtiger_crmentity_products_inv" . $oth_as . $fieldid_alias . " "]["using"] = "vtiger_products_inv" . $oth_as . $fieldid_alias . ".productid AND vtiger_crmentity_products_inv" . $oth_as . $fieldid_alias . ".deleted=0 ";
     $join_array[" vtiger_service AS vtiger_service_inv" . $oth_as . $fieldid_alias . " "]["joincol"] = "vtiger_service_inv" . $oth_as . $fieldid_alias . ".serviceid";
     $join_array[" vtiger_service AS vtiger_service_inv" . $oth_as . $fieldid_alias . " "]["using"] = "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".productid";
     $join_array[" vtiger_crmentity AS vtiger_crmentity_service_inv" . $oth_as . $fieldid_alias . " "]["joincol"] = "vtiger_crmentity_service_inv" . $oth_as . $fieldid_alias . ".crmid";
     $join_array[" vtiger_crmentity AS vtiger_crmentity_service_inv" . $oth_as . $fieldid_alias . " "]["using"] = "vtiger_service_inv" . $oth_as . $fieldid_alias . ".serviceid AND vtiger_crmentity_service_inv" . $oth_as . $fieldid_alias . ".deleted=0 ";
     $column_tablename = "vtiger_inventoryproductrel";
     if ($this->params["columnname"] != "") {
         $column_tablename_alias = $this->params["tablename"];
         if ($column_tablename_alias == "vtiger_crmentity") {
             $column_tablename_alias = $column_tablename . "_" . strtolower($this->params["fieldmodule"]) . "_inv";
         }
         $fld_cond = $this->getInventoryColumnFldCond($this->params["columnname"], $column_tablename_alias, $oth_as . $fieldid_alias);
         $columns_array_value = $this->getColumnsArrayValue($fld_cond, $oth_as . $fieldid_alias);
         $fld_alias = $this->params["columnname"] . $fieldid_alias;
         if (!in_array(" vtiger_inventoryproductrel" . $fieldid_alias . ".lineitem_id AS lineitem_id" . $fieldid_alias . " ", $columns_array)) {
             $columns_array[] = " vtiger_inventoryproductrel" . $fieldid_alias . ".lineitem_id AS lineitem_id" . $fieldid_alias . " ";
         }
         if ($using_tablename != "" && $using_columnname != "") {
             $columns_array[] = " {$using_tablename}.{$using_columnname} AS record_id" . $fieldid_alias . " ";
         }
         $columns_array[] = $columns_array_value;
         $columns_array[$this->params["fld_string"]]["fld_alias"] = $fld_alias;
         $columns_array[$this->params["fld_string"]]["fld_sql_str"] = $columns_array_value;
         $columns_array[$this->params["fld_string"]]["fld_cond"] = $fld_cond;
         $columns_array["uitype_{$fld_alias}"] = $this->params["field_uitype"];
         $columns_array[$fld_alias] = $this->params["fld_string"];
     }
     /*
     ITS4YouReports::sshow("6-".$this->params["columnname"]);
             if ($this->params["columnname"] == 'discount') {
                 $fld_cond = " CASE WHEN (" . "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".discount_amount != '') THEN " . "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".discount_amount else ROUND((" . "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".listprice * " . "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".quantity * (" . "vtiger_inventoryproductrel" . $oth_as . $fieldid_alias . ".discount_percent/100)),3) END ";
                 $columns_array_value = $fld_cond . " AS '" . $this->params["columnname"] . $oth_as . $fieldid_alias . "'";
             } elseif ($this->params["columnname"] == "prodname") {
                 $fld_cond = " CASE WHEN (vtiger_products_inv" . $oth_as . $fieldid_alias . ".productname IS NOT NULL) THEN vtiger_products_inv" . $oth_as . $fieldid_alias . ".productname ELSE vtiger_service_inv" . $oth_as . $fieldid_alias . ".servicename END ";
                 $columns_array_value = $fld_cond . " AS prodname" . $oth_as . $fieldid_alias . " ";
             } else {
                 // $fld_cond = "vtiger_inventoryproductrel".$oth_as.$fieldid_alias.".".$this->params["columnname"];
                 $fld_cond = $this->params["columnname"];
                 $columns_array_value = $fld_cond . " AS " . $this->params["columnname"] . $oth_as . $fieldid_alias;
             }
             $fld_alias = $this->params["columnname"] . $oth_as . $fieldid_alias;
             
             if(!in_array(" vtiger_inventoryproductrel" . $fieldid_alias . ".lineitem_id AS lineitem_id" . $fieldid_alias . " ",$columns_array)){
                 $columns_array[] = " vtiger_inventoryproductrel" . $fieldid_alias . ".lineitem_id AS lineitem_id" . $fieldid_alias . " ";
             }
             if($using_tablename!="" && $using_columnname!=""){
                 $columns_array[] = " $using_tablename.$using_columnname AS record_id" . $fieldid_alias . " ";
             }
             $columns_array[] = $columns_array_value;
             $columns_array[$this->params["fld_string"]]["fld_alias"] = $fld_alias;
             $columns_array[$this->params["fld_string"]]["fld_sql_str"] = $columns_array_value;
             $columns_array[$this->params["fld_string"]]["fld_cond"] = $fld_cond;
             $columns_array["uitype_$fld_alias"] = $this->params["field_uitype"];
             $columns_array[$fld_alias] = $this->params["fld_string"];
     */
     return;
 }
Example #3
0
 /**	function used to get the list of activities which are related to the Quotes
  *	@param int $id - quote id
  *	@return array - return an array which will be returned from the function GetRelatedList
  */
 function get_activities($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_activities(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/Activity.php";
     $other = new Activity();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     $button .= '<input type="hidden" name="activity_mode">';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\";this.form.return_module.value=\"{$this_module}\";this.form.activity_mode.value=\"Task\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "'>&nbsp;";
         }
     }
     $query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid where vtiger_seactivityrel.crmid=" . $id . " and vtiger_crmentity.deleted=0 and activitytype='Task' and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Deferred')";
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_activities method ...");
     return $return_value;
 }
Example #4
0
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall)
  */
 function get_osstimecontrol($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_osstimecontrol(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $record = Vtiger_Record_Model::getInstanceById($id);
     $userId = $record->get('assigned_user_id');
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     if ($actions && getFieldVisibilityPermission($related_module, $current_user->id, 'parent_id', 'readwrite') == '0') {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'>&nbsp;";
         }
     }
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name, vtiger_users.id,\n\t\t\t\tvtiger_osstimecontrol.name, vtiger_osstimecontrol.osstimecontrolid as crmid, vtiger_osstimecontrol.osstimecontrol_status, vtiger_osstimecontrol.payment,\n\t\t\t\tvtiger_osstimecontrol.osstimecontrol_no, vtiger_osstimecontrol.date_start, vtiger_osstimecontrol.due_date, vtiger_osstimecontrol.time_end, vtiger_osstimecontrol.sum_time, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime\n\t\t\t\tFROM vtiger_osstimecontrol\n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_osstimecontrol.osstimecontrolid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tWHERE  vtiger_crmentity.deleted = 0 AND vtiger_crmentity.`smownerid`= " . $userId;
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_osstimecontrol method ...");
     return $return_value;
 }
Example #5
0
 /**	function used to get the list of pricebooks which are related to the service
  *	@param int $id - service id
  *	@return array - array which will be returned from the function GetRelatedList
  */
 function get_service_pricebooks($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $currentModule, $log, $singlepane_view, $mod_strings;
     $log->debug("Entering get_service_pricebooks(" . $id . ") method ...");
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     checkFileAccessForInclusion("modules/{$related_module}/{$related_module}.php");
     require_once "modules/{$related_module}/{$related_module}.php";
     $focus = new $related_module();
     $singular_modname = vtlib_toSingular($related_module);
     if ($singlepane_view == 'true') {
         $returnset = "&return_module={$currentModule}&return_action=DetailView&return_id={$id}";
     } else {
         $returnset = "&return_module={$currentModule}&return_action=CallRelatedList&return_id={$id}";
     }
     $button = '';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes' && isPermitted($currentModule, 'EditView', $id) == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_TO') . " " . getTranslatedString($related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"AddServiceToPriceBooks\";this.form.module.value=\"{$currentModule}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_TO') . " " . getTranslatedString($singular_modname) . "'>&nbsp;";
         }
     }
     $query = "SELECT vtiger_crmentity.crmid,\n\t\t\tvtiger_pricebook.*,\n\t\t\tvtiger_pricebookproductrel.productid as prodid\n\t\t\tFROM vtiger_pricebook\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid\n\t\t\tINNER JOIN vtiger_pricebookproductrel\n\t\t\t\tON vtiger_pricebookproductrel.pricebookid = vtiger_pricebook.pricebookid\n\t\t\tWHERE vtiger_crmentity.deleted = 0\n\t\t\tAND vtiger_pricebookproductrel.productid = " . $id;
     $log->debug("Exiting get_product_pricebooks method ...");
     $return_value = GetRelatedList($currentModule, $related_module, $focus, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_service_pricebooks method ...");
     return $return_value;
 }
Example #6
0
 /**
  * Function to get Contact related vendors.
  * @param  integer   $id      - contactid
  * returns related vendor records in array format
  */
 function get_vendors($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_vendors(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'>&nbsp;";
         }
     }
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\t\tvtiger_crmentity.crmid, vtiger_vendor.*, vtiger_vendorcf.*\n\t\t\t\tfrom vtiger_vendor inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_vendor.vendorid\n\t\t\t\tINNER JOIN vtiger_vendorcontactrel on vtiger_vendorcontactrel.vendorid=vtiger_vendor.vendorid\n\t\t\t\tLEFT JOIN vtiger_vendorcf on vtiger_vendorcf.vendorid=vtiger_vendor.vendorid\n\t\t\t\tLEFT JOIN vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid\n\t\t\t\tWHERE vtiger_crmentity.deleted=0 and vtiger_vendorcontactrel.contactid=" . $id;
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_vendors method ...");
     return $return_value;
 }
 /** Function to unlink an entity with given Id from another entity */
 function unlinkRelationship($id, $return_module, $return_id)
 {
     global $log, $currentModule;
     if ($return_module == 'Accounts') {
         $focus = new $return_module();
         $entityIds = $focus->getRelatedContactsIds($return_id);
         array_push($entityIds, $return_id);
         $entityIds = implode(',', $entityIds);
         $return_modules = "'Accounts','Contacts'";
     } else {
         $entityIds = $return_id;
         $return_modules = "'" . $return_module . "'";
     }
     $query = 'DELETE FROM vtiger_crmentityrel WHERE (relcrmid=' . $id . ' AND module IN (' . $return_modules . ') AND crmid IN (' . $entityIds . ')) OR (crmid=' . $id . ' AND relmodule IN (' . $return_modules . ') AND relcrmid IN (' . $entityIds . '))';
     $this->db->pquery($query, array());
     $sql = 'SELECT tabid, tablename, columnname FROM vtiger_field WHERE fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE module=? AND relmodule IN (' . $return_modules . '))';
     $fieldRes = $this->db->pquery($sql, array($currentModule));
     $numOfFields = $this->db->num_rows($fieldRes);
     for ($i = 0; $i < $numOfFields; $i++) {
         $tabId = $this->db->query_result($fieldRes, $i, 'tabid');
         $tableName = $this->db->query_result($fieldRes, $i, 'tablename');
         $columnName = $this->db->query_result($fieldRes, $i, 'columnname');
         $relatedModule = vtlib_getModuleNameById($tabId);
         $focusObj = CRMEntity::getInstance($relatedModule);
         $updateQuery = "UPDATE {$tableName} SET {$columnName}=? WHERE {$columnName} IN ({$entityIds}) AND {$focusObj->table_index}=?";
         $updateParams = array(null, $id);
         $this->db->pquery($updateQuery, $updateParams);
     }
 }
Example #8
0
 /**
  * Function to get Campaign related Activities
  * @param  integer   $id      - campaignid
  * returns related activities record in array format
  */
 function get_activities($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_activities(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/Activity.php";
     $other = new Activity();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     $button .= '<input type="hidden" name="activity_mode">';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             if (getFieldVisibilityPermission('Calendar', $current_user->id, 'parent_id', 'readwrite') == '0') {
                 $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EventEditView\";this.form.module.value=\"Calendar4You\";this.form.return_module.value=\"{$this_module}\";this.form.activity_mode.value=\"Task\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "'>&nbsp;";
             }
             if (getFieldVisibilityPermission('Events', $current_user->id, 'parent_id', 'readwrite') == '0') {
                 $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EventEditView\";this.form.module.value=\"Calendar4You\";this.form.return_module.value=\"{$this_module}\";this.form.activity_mode.value=\"Events\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('LBL_EVENT', $related_module) . "'>";
             }
         }
     }
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT vtiger_contactdetails.lastname,\n\t\t\tvtiger_contactdetails.firstname,\n\t\t\tvtiger_contactdetails.contactid,\n\t\t\tvtiger_activity.*,\n\t\t\tvtiger_seactivityrel.*,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid,\n\t\t\tvtiger_crmentity.modifiedtime,\n\t\t\tCASE when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\tvtiger_recurringevents.recurringtype\n\t\t\tFROM vtiger_activity\n\t\t\tINNER JOIN vtiger_seactivityrel\n\t\t\t\tON vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid=vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_cntactivityrel\n\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_contactdetails\n\t\t\t\tON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid\n\t\t\tLEFT JOIN vtiger_users\n\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\tLEFT OUTER JOIN vtiger_recurringevents\n\t\t\t\tON vtiger_recurringevents.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_seactivityrel.crmid=" . $id . "\n\t\t\tAND vtiger_crmentity.deleted = 0\n\t\t\tAND (activitytype = 'Task'\n\t\t\t\tOR activitytype !='Emails')";
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_activities method ...");
     return $return_value;
 }
    $ITS4YouReports->getSecModuleColumnsList($secondarymodule);
    $available_modules[] = array("id" => $ITS4YouReports->primarymoduleid, "name" => $modulename_lbl, "checked" => "checked");
    foreach ($secondarymodule_arr as $key => $value) {
        $available_modules[] = array("id" => $value["id"], "name" => $value["name"], "checked" => "");
    }
    $AV_M = Zend_JSON::encode($available_modules);
    $step5_result .= $AV_M . "(!A#V_M@M_M#A!)";
}
/*$SumOptions2 = getSecondaryColumns($SumOptions2,$secondarymodule,$ITS4YouReports);
foreach ($SumOptions2 as $key=>$value) {
	$SPSumOptions[$key]=$value;
}*/
$BLOCK1 = "";
foreach ($SPSumOptions as $module_key => $SumOptions) {
    $BLOCK2 = "";
    $r_modulename = vtlib_getModuleNameById($module_key);
    $r_modulename_lbl = getTranslatedString($r_modulename, $r_modulename);
    foreach ($SumOptions as $SumOptions_key => $SumOptions_value) {
        foreach ($SumOptions_value as $optgroup => $optionsdata) {
            if ($BLOCK2 != "") {
                $BLOCK2 .= "(|@!@|)";
            }
            $BLOCK2 .= $optgroup;
            $BLOCK2 .= "(|@|)";
            $BLOCK2 .= Zend_JSON::encode($optionsdata);
        }
        $BLOCK1 .= $module_key . "(!#_ID@ID_#!)" . $r_modulename_lbl . "(!#_ID@ID_#!)" . $BLOCK2;
    }
}
$step5_result .= $BLOCK1;
echo $step5_result;
 /**
  * Default (generic) function to handle the dependents list for the module.
  * NOTE: UI type '10' is used to stored the references to other modules for a given record.
  * These dependent records can be retrieved through this function.
  * For eg: A trouble ticket can be related to an Account or a Contact.
  * From a given Contact/Account if we need to fetch all such dependent trouble tickets, get_dependents_list function can be used.
  */
 function get_dependents_list($id, $cur_tab_id, $relTabId, $actions = false)
 {
     $app_strings = vglobal('app_strings');
     $current_user = vglobal('current_user');
     $singlepane_view = vglobal('singlepane_view');
     $currentModule = vtlib_getModuleNameById($cur_tab_id);
     $relatedModule = vtlib_getModuleNameById($relTabId);
     $other = CRMEntity::getInstance($relatedModule);
     // Some standard module class doesn't have required variables
     // that are used in the query, they are defined in this generic API
     vtlib_setup_modulevars($currentModule, $this);
     vtlib_setup_modulevars($relatedModule, $other);
     $singular_modname = 'SINGLE_' . $relatedModule;
     $button = '';
     $row = [];
     // To make the edit or del link actions to return back to same view.
     if ($singlepane_view == 'true') {
         $returnset = "&return_module={$currentModule}&return_action=DetailView&return_id={$id}";
     } else {
         $returnset = "&return_module={$currentModule}&return_action=CallRelatedList&return_id={$id}";
     }
     $return_value = null;
     $dependentFieldSql = $this->db->pquery('SELECT tabid, fieldname, columnname FROM vtiger_field WHERE uitype = 10 AND' . ' fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)', [$currentModule, $relatedModule]);
     if ($dependentFieldSql->rowCount()) {
         $row = $this->db->getRow($dependentFieldSql);
     } else {
         $depProcessFieldSql = $this->db->pquery('SELECT fieldname AS `name`, fieldid AS id, fieldlabel AS label, columnname AS `column`, tablename AS `table`, vtiger_field.*  FROM vtiger_field WHERE `uitype` IN (66,67,68) AND `tabid` = ?;', [$relTabId]);
         while ($rowProc = $this->db->getRow($depProcessFieldSql)) {
             $className = Vtiger_Loader::getComponentClassName('Model', 'Field', $relatedModule);
             $fieldModel = new $className();
             foreach ($rowProc as $properName => $propertyValue) {
                 $fieldModel->{$properName} = $propertyValue;
             }
             $moduleList = $fieldModel->getUITypeModel()->getReferenceList();
             if (in_array($currentModule, $moduleList)) {
                 $row = $rowProc;
                 break;
             }
         }
     }
     if (!empty($row)) {
         $dependentColumn = $row['columnname'];
         $dependentField = $row['fieldname'];
         $button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">';
         $button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">';
         if ($actions) {
             if (is_string($actions)) {
                 $actions = explode(',', strtoupper($actions));
             }
             if (in_array('ADD', $actions) && isPermitted($relatedModule, 1, '') == 'yes' && getFieldVisibilityPermission($relatedModule, $current_user->id, $dependentField, 'readwrite') == '0') {
                 $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $relatedModule) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$relatedModule}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $relatedModule) . "'>&nbsp;";
             }
         }
         $query = "SELECT vtiger_crmentity.*, {$other->table_name}.*";
         $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
         $query .= ", CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name";
         $more_relation = '';
         if (!empty($other->related_tables)) {
             foreach ($other->related_tables as $tname => $relmap) {
                 $query .= ", {$tname}.*";
                 // Setup the default JOIN conditions if not specified
                 if (empty($relmap[1])) {
                     $relmap[1] = $other->table_name;
                 }
                 if (empty($relmap[2])) {
                     $relmap[2] = $relmap[0];
                 }
                 $more_relation .= " LEFT JOIN {$tname} ON {$tname}.{$relmap['0']} = {$relmap['1']}.{$relmap['2']}";
             }
         }
         $query .= " FROM {$other->table_name}";
         $query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = {$other->table_name}.{$other->table_index}";
         $query .= " INNER  JOIN {$this->table_name}   ON {$this->table_name}.{$this->table_index} = {$other->table_name}.{$dependentColumn}";
         $query .= $more_relation;
         $query .= " LEFT  JOIN vtiger_users        ON vtiger_users.id = vtiger_crmentity.smownerid";
         $query .= " LEFT  JOIN vtiger_groups       ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
         $query .= " WHERE vtiger_crmentity.deleted = 0 AND {$this->table_name}.{$this->table_index} = {$id}";
         $return_value = GetRelatedList($currentModule, $relatedModule, $other, $query, $button, $returnset);
     }
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     return $return_value;
 }
Example #11
0
 function getColumns(Vtiger_Request $request, $is_sum = false)
 {
     $BLOCK0 = $BLOCK1 = $BLOCK2 = "";
     $selectedmodule = $request->get("selectedmodule");
     $SumOptions = array();
     $secondarymodule = '';
     $secondarymodules = array();
     $record = $request->get('record');
     $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record);
     $primarymodule = $reportModel->getPrimaryModule();
     $primarymoduleid = $reportModel->getPrimaryModuleId();
     $modulename_prefix = "";
     if ($selectedmodule != $primarymoduleid && $selectedmodule != "") {
         $modulename = $selectedmodule;
         $reportModel->getSecModuleColumnsList($modulename);
         $module_array["id"] = $modulename;
         $modulename_arr = explode("x", $modulename);
         $modulename_id = $modulename_arr[0];
         if ($modulename_arr[1] != "") {
             $modulename_prefix = $modulename_arr[1];
         }
     } else {
         $module_array["module"] = $primarymodule;
         $module_array["id"] = $primarymoduleid;
         $modulename = $module_array["module"];
         $modulename_lbl = vtranslate($modulename, $modulename);
         $availModules[$module_array["id"]] = $modulename_lbl;
         $modulename_id = $module_array["id"];
     }
     $relmod_arr = explode("x", $modulename);
     if (is_numeric($relmod_arr[0])) {
         $stabid = $relmod_arr[0];
         $smodule = vtlib_getModuleNameById($stabid);
     }
     if ($is_sum) {
         $SPSumOptions[$module_array["id"]][$modulename_id] = sgetSummariesOptions($modulename);
     } else {
         if ($selectedmodule != $primarymoduleid && $selectedmodule != "") {
             $SPSumOptions[$modulename] = $reportModel->getSecondaryColumns(array(), $modulename);
         } else {
             $SPSumOptions[$module_array["id"]][$modulename_id] = $reportModel->getPrimaryColumns(array(), $modulename, true);
         }
     }
     $step5_result = "";
     if ($selectedmodule != $primarymoduleid && $selectedmodule == "") {
         $secondarymodule_arr = $reportModel->getReportRelatedModules($module_array["id"]);
         $reportModel->getSecModuleColumnsList($secondarymodule);
         $available_modules[] = array("id" => $primarymoduleid, "name" => $modulename_lbl, "checked" => "checked");
         foreach ($secondarymodule_arr as $key => $value) {
             $available_modules[] = array("id" => $value["id"], "name" => $value["name"], "checked" => "");
         }
         $AV_M = Zend_JSON::encode($available_modules);
         $step5_result .= $AV_M . "(!A#V_M@M_M#A!)";
     }
     $BLOCK1 = "";
     foreach ($SPSumOptions as $module_key => $SumOptions) {
         $BLOCK2 = "";
         $r_modulename = vtlib_getModuleNameById($module_key);
         $r_modulename_lbl = vtranslate($r_modulename, $r_modulename);
         foreach ($SumOptions as $SumOptions_key => $SumOptions_value) {
             foreach ($SumOptions_value as $optgroup => $optionsdata) {
                 if ($BLOCK2 != "") {
                     $BLOCK2 .= "(|@!@|)";
                 }
                 $BLOCK2 .= $optgroup;
                 $BLOCK2 .= "(|@|)";
                 $BLOCK2 .= Zend_JSON::encode($optionsdata);
             }
             $BLOCK1 .= $module_key . "(!#_ID@ID_#!)" . $r_modulename_lbl . "(!#_ID@ID_#!)" . $BLOCK2;
         }
     }
     $step5_result .= $BLOCK1;
     echo $step5_result;
 }
Example #12
0
    function get_ventas_list($id, $cur_tab_id, $rel_tab_id, $actions = false)
    {
        global $adb;
        $this_module = $currentModule;
        $related_module = vtlib_getModuleNameById($rel_tab_id);
        require_once "modules/{$related_module}/{$related_module}.php";
        $other = new $related_module();
        vtlib_setup_modulevars($related_module, $other);
        $singular_modname = vtlib_toSingular($related_module);
        $parenttab = getParentTab();
        if ($singlepane_view == 'true') {
            $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
        } else {
            $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
        }
        $button = '';
        $button .= '<input type="hidden" name="email_directing_module"><input type="hidden" name="record">';
        $sql = "SELECT registrodeventasid FROM vtiger_registrodepagos WHERE registrodepagosid = ?";
        $result = $adb->pquery($sql, array($id));
        $row = $adb->fetchByAssoc($result);
        $ventaid = $row["registrodeventasid"];
        $query = 'SELECT vtiger_crmentity.crmid,vtiger_registrodeventas.contacto, vtiger_registrodeventas.registrodeventastype, vtiger_crmentity.smownerid, vtiger_registrodeventas.registrodeventasname FROM vtiger_registrodeventas INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_registrodeventas.registrodeventasid INNER JOIN vtiger_crmentityrel ON (vtiger_crmentityrel.relcrmid = vtiger_crmentity.crmid OR vtiger_crmentityrel.crmid = vtiger_crmentity.crmid) LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid  WHERE vtiger_crmentity.deleted = 0 AND (vtiger_crmentityrel.crmid = ' . $ventaid . ' OR vtiger_crmentityrel.relcrmid = ' . $ventaid . ')  
';
        //var_dump($query); exit;
        $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
        return $return_value;
    }
Example #13
0
    public function getSelectedValuesToSmarty($smarty_obj = "", $step_name = "")
    {
        if ($smarty_obj != "" && $step_name != "") {
            global $app_strings;
            global $mod_strings;
            global $default_charset;
            global $current_language;
            global $image_path;
            global $theme;
            $theme_path = "themes/" . $theme . "/";
            $image_path = $theme_path . "images/";
            $smarty_obj->assign("THEME", $theme_path);
            $smarty_obj->assign("IMAGE_PATH", $image_path);
            $adb = PEARDatabase::getInstance();
            $get_all_steps = "all";
            if (isset($_REQUEST["record"]) && $_REQUEST['record'] != '') {
                $recordid = vtlib_purify($_REQUEST["record"]);
            } else {
                $recordid = "";
            }
            $smarty_obj->assign("RECORDID", $recordid);
            $smarty_obj->assign("DISPLAY_FILTER_HEADER", false);
            if (in_array($step_name, array("ReportsStep1"))) {
                if (isset($_REQUEST["reportname"]) && $_REQUEST["reportname"] != "") {
                    $reportname = htmlspecialchars(vtlib_purify($_REQUEST["reportname"]));
                } else {
                    $reportname = $this->reportinformations["reports4youname"];
                }
                $smarty_obj->assign("REPORTNAME", $reportname);
                if (isset($_REQUEST["reportdesc"]) && $_REQUEST["reportdesc"] != "") {
                    $reportdesc = htmlspecialchars(vtlib_purify($_REQUEST["reportdesc"]));
                } else {
                    $reportdesc = $this->reportinformations["reportdesc"];
                }
                $smarty_obj->assign("REPORTDESC", $reportdesc);
                $smarty_obj->assign("REP_MODULE", $this->reportinformations["primarymodule"]);
                $smarty_obj->assign("PRIMARYMODULES", $this->getPrimaryModules());
                $smarty_obj->assign("REP_FOLDERS", $this->getReportFolders());
                if (isset($this->primarymodule) && $this->primarymodule != '') {
                    $rel_modules = $this->getReportRelatedModules($this->primarymoduleid);
                    foreach ($rel_modules as $key => $relmodule) {
                        $restricted_modules .= $relmodule['id'] . ":";
                    }
                    $smarty_obj->assign("REL_MODULES_STR", trim($restricted_modules, ":"));
                    $smarty_obj->assign("RELATEDMODULES", $rel_modules);
                }
                $smarty_obj->assign("FOLDERID", vtlib_purify($_REQUEST['folder']));
            }
            if (in_array($step_name, array("ReportsStep2", $get_all_steps))) {
                if (isset($this->primarymodule) && $this->primarymodule != '') {
                    $rel_modules = $this->getReportRelatedModules($this->primarymoduleid);
                    foreach ($rel_modules as $key => $relmodule) {
                        $restricted_modules .= $relmodule['id'] . ":";
                    }
                    $smarty_obj->assign("REL_MODULES_STR", trim($restricted_modules, ":"));
                    $smarty_obj->assign("RELATEDMODULES", $rel_modules);
                }
            }
            if (in_array($step_name, array("ReportGrouping", $get_all_steps))) {
                // TIMELINE COLUMNS DEFINITION CHANGED New Code 13.5.2014 11:58
                // ITS4YOU-CR SlOl | 13.5.2014 11:53
                if (isset($_REQUEST["primarymodule"]) && $_REQUEST["primarymodule"] != "") {
                    $primary_moduleid = $_REQUEST["primarymodule"];
                    $primary_module = vtlib_getModuleNameById($_REQUEST["primarymodule"]);
                    if (vtlib_isModuleActive($primary_module)) {
                        $primary_df_arr = getPrimaryTLStdFilter($primary_module, $this);
                    }
                } else {
                    $primary_module = $this->primarymodule;
                    $primary_moduleid = $this->primarymoduleid;
                    $primary_df_arr = getPrimaryTLStdFilter($primary_module, $this);
                }
                $date_options = array();
                if (!empty($primary_df_arr)) {
                    foreach ($primary_df_arr as $val_arr) {
                        foreach ($val_arr as $val_dtls) {
                            $date_options[] = $val_dtls["value"];
                        }
                    }
                }
                $date_options_json = Zend_JSON::encode($date_options);
                $smarty_obj->assign("date_options_json", $date_options_json);
                $timelinecolumn = $this->getTimeLineColumnHTML();
                $smarty_obj->assign("timelinecolumn", $timelinecolumn);
                // ITS4YOU-END 13.5.2014 11:53
                if (isset($_REQUEST["record"]) && $_REQUEST['record'] != '') {
                    $reportid = vtlib_purify($_REQUEST["record"]);
                    $secondarymodule = '';
                    $secondarymodules = array();
                    if (!empty($this->related_modules[$primary_module])) {
                        foreach ($this->related_modules[$primary_module] as $key => $value) {
                            if (isset($_REQUEST["secondarymodule_" . $value])) {
                                $secondarymodules[] = vtlib_purify($_REQUEST["secondarymodule_" . $value]);
                            }
                        }
                    }
                    if ($primary_moduleid == getTabid('Invoice')) {
                        $secondarymodules[] = getTabid('Products');
                        $secondarymodules[] = getTabid('Services');
                    }
                    $secondarymodule = implode(":", $secondarymodules);
                    if ($secondarymodule != '') {
                        $this->secondarymodules .= $secondarymodule;
                    }
                    if (isset($_REQUEST["summaries_limit"])) {
                        $summaries_limit = vtlib_purify($_REQUEST["summaries_limit"]);
                    } else {
                        $summaries_limit = $this->reportinformations["summaries_limit"];
                    }
                } else {
                    $secondarymodule = '';
                    $secondarymodules = array();
                    $this->getPriModuleColumnsList($primary_module);
                    foreach ($this->secondarymodules as $key => $secmodid) {
                        $this->getSecModuleColumnsList(vtlib_getModuleNameById($secmodid));
                    }
                    $summaries_limit = "20";
                }
                $smarty_obj->assign("SUMMARIES_MAX_LIMIT", $summaries_limit);
                for ($tc_i = 1; $tc_i < 4; $tc_i++) {
                    $timelinecol = $selected_timeline_column = "";
                    if (isset($_REQUEST["group{$tc_i}"]) && $_REQUEST["group{$tc_i}"] != "" && $step_name != "ReportGrouping") {
                        $group = vtlib_purify($_REQUEST["group{$tc_i}"]);
                        if (isset($_REQUEST["timeline_column{$tc_i}"]) && $_REQUEST["timeline_column{$tc_i}"] != "") {
                            $selected_timeline_column = vtlib_purify($_REQUEST["timeline_column{$tc_i}"]);
                        }
                    } else {
                        $group = $this->reportinformations["Group{$tc_i}"];
                        $selected_timeline_column = $this->reportinformations["timeline_columnstr{$tc_i}"];
                    }
                    if (isset($selected_timeline_column) && !in_array($selected_timeline_column, array("", "none", "@vlv@"))) {
                        $timelinecol = $this->getTimeLineColumnHTML($tc_i, $selected_timeline_column);
                        $smarty_obj->assign("timelinecolumn" . $tc_i . "_html", $timelinecol);
                    }
                    $RG_BLOCK = getPrimaryColumns_GroupingHTML($primary_module, $group, $this);
                    $smarty_obj->assign("RG_BLOCK{$tc_i}", $RG_BLOCK);
                    if ($tc_i > 1) {
                        if (isset($_REQUEST["timeline_type{$tc_i}"]) && $_REQUEST["timeline_type{$tc_i}"] != "") {
                            $timeline_type = vtlib_purify($_REQUEST["timeline_type{$tc_i}"]);
                        } else {
                            $timeline_type = $this->reportinformations["timeline_type{$tc_i}"];
                        }
                        $smarty_obj->assign("timeline_type{$tc_i}", $timeline_type);
                    }
                }
                for ($sci = 1; $sci < 4; $sci++) {
                    if (isset($_REQUEST["sort" . $sci]) && $_REQUEST["sort" . $sci] != "") {
                        $sortorder = vtlib_purify($_REQUEST["sort" . $sci]);
                    } else {
                        $sortorder = $this->reportinformations["Sort" . $sci];
                    }
                    $sa = $sd = "";
                    if ($sortorder != "Descending") {
                        $sa = "checked";
                    } else {
                        $sd = "checked";
                    }
                    $shtml = '<input type="radio" id="Sort' . $sci . 'a" name="Sort' . $sci . '" value="Ascending" ' . $sa . '>' . vtranslate('Ascending') . ' &nbsp; 
				              <input type="radio" id="Sort' . $sci . 'd" name="Sort' . $sci . '" value="Descending" ' . $sd . '>' . vtranslate('Descending');
                    $smarty_obj->assign("ASCDESC" . $sci, $shtml);
                }
                // ITS4YOU-CR SlOl 5. 3. 2014 14:50:45 SUMMARIES START
                $module_id = $primary_moduleid;
                $modulename_prefix = "";
                $module_array["module"] = $primary_module;
                $module_array["id"] = $module_id;
                $selectedmodule = $module_array["id"];
                $modulename = $module_array["module"];
                $modulename_lbl = vtranslate($modulename, $modulename);
                $availModules[$module_array["id"]] = $modulename_lbl;
                $modulename_id = $module_array["id"];
                if (isset($selectedmodule)) {
                    $secondarymodule_arr = $this->getReportRelatedModules($module_array["id"]);
                    $this->getSecModuleColumnsList($selectedmodule);
                    $RG_BLOCK4 = sgetSummariesHTMLOptions($module_array["id"], $module_id);
                    $available_modules[] = array("id" => $module_id, "name" => $modulename_lbl, "checked" => "checked");
                    foreach ($secondarymodule_arr as $key => $value) {
                        $exploded_mid = explode("x", $value["id"]);
                        if (strtolower($exploded_mid[1]) != "mif") {
                            $available_modules[] = array("id" => $value["id"], "name" => "- " . $value["name"], "checked" => "");
                        }
                    }
                    $smarty_obj->assign("RG_BLOCK4", $RG_BLOCK4);
                }
                $smarty_obj->assign("SummariesModules", $available_modules);
                $SumOptions = sgetSummariesOptions($selectedmodule);
                if (empty($SumOptions)) {
                    $SumOptions = vtranslate("NO_SUMMARIES_COLUMNS", $this->currentModule);
                }
                $SPSumOptions[$module_array["id"]][$module_array["id"]] = $SumOptions;
                $smarty_obj->assign("SUMOPTIONS", $SPSumOptions);
                if (isset($_REQUEST["selectedSummariesString"])) {
                    $selectedSummariesString = vtlib_purify($_REQUEST["selectedSummariesString"]);
                    $selectedSummariesArr = explode(";", $selectedSummariesString);
                    $summaries_orderby = vtlib_purify($_REQUEST["summaries_orderby"]);
                    $RG_BLOCK6 = sgetSelectedSummariesHTMLOptions($selectedSummariesArr, $summaries_orderby);
                } else {
                    if (!empty($this->reportinformations["summaries_columns"])) {
                        foreach ($this->reportinformations["summaries_columns"] as $key => $summaries_columns_arr) {
                            $selectedSummariesArr[] = $summaries_columns_arr["columnname"];
                        }
                    }
                    $selectedSummariesString = implode(";", $selectedSummariesString);
                    $summaries_orderby = "";
                    if (isset($this->reportinformations["summaries_orderby_columns"][0]) && $this->reportinformations["summaries_orderby_columns"][0] != "") {
                        $summaries_orderby = $this->reportinformations["summaries_orderby_columns"][0];
                    }
                    $RG_BLOCK6 = sgetSelectedSummariesHTMLOptions($selectedSummariesArr, $summaries_orderby);
                }
                // sum_group_columns for group filters start
                $sm_arr = sgetSelectedSummariesOptions($selectedSummariesArr);
                $sm_str = "";
                foreach ($sm_arr as $key => $opt_arr) {
                    if ($sm_str != "") {
                        $sm_str .= "(|@!@|)";
                    }
                    $sm_str .= $opt_arr["value"] . "(|@|)" . $opt_arr["text"];
                }
                $smarty_obj->assign("sum_group_columns", $sm_str);
                // sum_group_columns for group filters end
                $smarty_obj->assign("selectedSummariesString", $selectedSummariesString);
                $smarty_obj->assign("RG_BLOCK6", $RG_BLOCK6);
                $RG_BLOCKx2 = array();
                $all_fields_str = "";
                foreach ($SPSumOptions as $module_key => $SumOptions) {
                    $RG_BLOCKx2 = "";
                    $r_modulename = vtlib_getModuleNameById($module_key);
                    $r_modulename_lbl = vtranslate($r_modulename, $r_modulename);
                    foreach ($SumOptions as $SumOptions_key => $SumOptions_value) {
                        if (is_array($SumOptions_value)) {
                            foreach ($SumOptions_value as $optgroup => $optionsdata) {
                                if ($RG_BLOCKx2 != "") {
                                    $RG_BLOCKx2 .= "(|@!@|)";
                                }
                                $RG_BLOCKx2 .= $optgroup;
                                $RG_BLOCKx2 .= "(|@|)";
                                $RG_BLOCKx2 .= Zend_JSON::encode($optionsdata);
                            }
                        } else {
                            $RG_BLOCKx2 .= $SumOptions_value;
                            $RG_BLOCKx2 .= "(|@|)";
                            $optionsdata[] = array("value" => "none", "text" => vtranslate("LBL_NONE", $this->currentModule));
                            $RG_BLOCKx2 .= Zend_JSON::encode($optionsdata);
                        }
                        $all_fields_str .= $module_key . "(!#_ID@ID_#!)" . $r_modulename_lbl . "(!#_ID@ID_#!)" . $RG_BLOCKx2;
                    }
                }
                $smarty_obj->assign("ALL_FIELDS_STRING", $all_fields_str);
                // ITS4YOU-END 5. 3. 2014 14:50:47  SUMMARIES END
                if (isset($_REQUEST["summaries_orderby"]) && $_REQUEST["summaries_orderby"] != "" && isset($_REQUEST["summaries_orderby_type"]) && $_REQUEST["summaries_orderby_type"] != "") {
                    $summaries_orderby = vtlib_purify($_REQUEST["summaries_orderby"]);
                    $summaries_orderby_type = vtlib_purify($_REQUEST["summaries_orderby_type"]);
                } elseif (isset($this->reportinformations["summaries_orderby_columns"]) && !empty($this->reportinformations["summaries_orderby_columns"])) {
                    $summaries_orderby = $this->reportinformations["summaries_orderby_columns"][0]["column"];
                    $summaries_orderby_type = $this->reportinformations["summaries_orderby_columns"][0]["type"];
                } else {
                    $summaries_orderby = "none";
                    $summaries_orderby_type = "ASC";
                }
                $smarty_obj->assign("summaries_orderby", $summaries_orderby);
                $smarty_obj->assign("summaries_orderby_type", $summaries_orderby_type);
            }
            if (in_array($step_name, array("ReportColumns", $get_all_steps))) {
                if (isset($_REQUEST["record"]) && $_REQUEST['record'] != '') {
                    $RC_BLOCK1 = getPrimaryColumnsHTML($this->primarymodule);
                    $secondarymodule = '';
                    $secondarymodules = array();
                    if (!empty($this->related_modules[$this->primarymodule])) {
                        foreach ($this->related_modules[$this->primarymodule] as $key => $value) {
                            if (isset($_REQUEST["secondarymodule_" . $value])) {
                                $secondarymodules[] = $_REQUEST["secondarymodule_" . $value];
                            }
                        }
                    }
                    $secondarymodule = implode(":", $secondarymodules);
                    $RC_BLOCK2 = $this->getSelectedColumnsList($this->selected_columns_list_arr);
                    $smarty_obj->assign("RC_BLOCK1", $RC_BLOCK1);
                    $smarty_obj->assign("RC_BLOCK2", $RC_BLOCK2);
                    $sreportsortsql = "SELECT columnname, sortorder FROM  its4you_reports4you_sortcol WHERE reportid =? AND sortcolid = 4";
                    $result_sort = $adb->pquery($sreportsortsql, array($recordid));
                    $num_rows = $adb->num_rows($result_sort);
                    if ($num_rows > 0) {
                        $columnname = $adb->query_result($result_sort, 0, "columnname");
                        $sortorder = $adb->query_result($result_sort, 0, "sortorder");
                        $RC_BLOCK3 = $this->getSelectedColumnsList($this->selected_columns_list_arr, $columnname);
                    } else {
                        $RC_BLOCK3 = $RC_BLOCK2;
                    }
                    $smarty_obj->assign("RC_BLOCK3", $RC_BLOCK3);
                    $this->secmodule = $secondarymodule;
                    $RC_BLOCK4 = "";
                    $RC_BLOCK4 = getSecondaryColumnsHTML($this->relatedmodulesstring, $this);
                    $smarty_obj->assign("RC_BLOCK4", $RC_BLOCK4);
                } else {
                    $primarymodule = vtlib_purify($_REQUEST["primarymodule"]);
                    $RC_BLOCK1 = getPrimaryColumnsHTML($primarymodule);
                    if (!empty($this->related_modules[$primarymodule])) {
                        foreach ($this->related_modules[$primarymodule] as $key => $value) {
                            $RC_BLOCK1 .= getSecondaryColumnsHTML($_REQUEST["secondarymodule_" . $value], $this);
                        }
                    }
                    $smarty_obj->assign("RC_BLOCK1", $RC_BLOCK1);
                    $this->reportinformations["columns_limit"] = "20";
                }
                $smarty_obj->assign("MAX_LIMIT", $this->reportinformations["columns_limit"]);
                if ($sortorder != "DESC") {
                    $shtml = '<input type="radio" name="SortOrderColumn" value="ASC" checked>' . vtranslate('Ascending') . ' &nbsp; 
								<input type="radio" name="SortOrderColumn" value="DESC">' . vtranslate('Descending');
                } else {
                    $shtml = '<input type="radio" name="SortOrderColumn" value="ASC">' . vtranslate('Ascending') . ' &nbsp; 
								<input type="radio" name="SortOrderColumn" value="DESC" checked>' . vtranslate('Descending');
                }
                $smarty_obj->assign("COLUMNASCDESC", $shtml);
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="DAYS" checked>' . $mod_strings['TL_DAYS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="WEEK" >' . $mod_strings['TL_WEEKS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="MONTH" >' . $mod_strings['TL_MONTHS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="YEAR" >' . $mod_strings['TL_YEARS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="QUARTER" >' . $mod_strings['TL_QUARTERS'] . ' ';
                $smarty_obj->assign("TIMELINE_FIELDS", $timelinecolumns);
                // ITS4YOU-CR SlOl  19. 2. 2014 16:30:20
                $SPSumOptions = $availModules = array();
                $RC_BLOCK0 = "";
                $smarty_obj->assign("availModules", $availModules);
                $smarty_obj->assign("ALL_FIELDS_STRING", $RC_BLOCK0);
                // ITS4YOU-END 19. 2. 2014 16:30:23
                $smarty_obj->assign("currentModule", $this->currentModule);
            }
            if (in_array($step_name, array("ReportColumnsTotal", $get_all_steps))) {
                $Objects = array();
                $curl_array = array();
                if (isset($_REQUEST["curl"])) {
                    $curl = vtlib_purify($_REQUEST["curl"]);
                    $curl_array = explode('$_@_$', $curl);
                    $selectedColumnsString = str_replace("@AMPKO@", "&", $_REQUEST["selectedColumnsStr"]);
                    $R_Objects = explode("<_@!@_>", $selectedColumnsString);
                } else {
                    $curl_array = $this->getSelectedColumnsToTotal($this->record);
                    $curl = implode('$_@_$', $curl_array);
                    $selectedColumnsString = str_replace("@AMPKO@", "&", $this->reportinformations["selectedColumnsString"]);
                    $R_Objects = explode(";", $selectedColumnsString);
                }
                $smarty_obj->assign("CURL", $curl);
                $Objects = sgetNewColumnstoTotalHTMLScript($R_Objects);
                $this->columnssummary = $Objects;
                $CT_BLOCK1 = $this->sgetNewColumntoTotalSelected($recordid, $R_Objects, $curl_array);
                $smarty_obj->assign("CT_BLOCK1", $CT_BLOCK1);
                //added to avoid displaying "No data avaiable to total" when using related modules in report.
                $rows_count = 0;
                $rows_count = count($CT_BLOCK1);
                $smarty_obj->assign("ROWS_COUNT", $rows_count);
            }
            if (in_array($step_name, array("ReportLabels", $get_all_steps))) {
                // selected labels from url
                $lbl_url_string = html_entity_decode(vtlib_purify($_REQUEST["lblurl"]), ENT_QUOTES, $default_charset);
                if ($lbl_url_string != "") {
                    $lbl_url_arr = explode('$_@_$', $lbl_url_string);
                    foreach ($lbl_url_arr as $key => $lbl_value) {
                        if (strpos($lbl_value, 'hidden_') === false) {
                            if (strpos($lbl_value, '_SC_lLbLl_') !== false) {
                                $temp = explode('_SC_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = trim($temp_lbls[0]);
                                $lbl_value = trim($temp_lbls[1]);
                                $lbl_url_selected["SC"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_SM_lLbLl_') !== false) {
                                $temp = explode('_SM_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = trim($temp_lbls[0]);
                                $lbl_value = trim($temp_lbls[1]);
                                $lbl_url_selected["SM"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_CT_lLbLl_') !== false) {
                                $temp = explode('_CT_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = trim($temp_lbls[0]);
                                $lbl_value = trim($temp_lbls[1]);
                                $lbl_url_selected["CT"][$lbl_key] = $lbl_value;
                            }
                        }
                    }
                }
                // COLUMNS labeltype SC
                if (isset($_REQUEST["selectedColumnsStr"]) && $_REQUEST["selectedColumnsStr"] != "") {
                    $selectedColumnsString = vtlib_purify($_REQUEST["selectedColumnsStr"]);
                    $selectedColumnsString = html_entity_decode($selectedColumnsString, ENT_QUOTES, $default_charset);
                    $selected_columns_array = explode("<_@!@_>", $selectedColumnsString);
                    $decode_labels = true;
                } else {
                    $selectedColumnsString = html_entity_decode($this->reportinformations["selectedColumnsString"], ENT_QUOTES, $default_charset);
                    $selected_columns_array = explode(";", $selectedColumnsString);
                    $decode_labels = false;
                }
                $labels_html["SC"] = $this->getLabelsHTML($selected_columns_array, "SC", $lbl_url_selected, $decode_labels);
                // SUMMARIES labeltype SM
                $selectedSummariesString = vtlib_purify($_REQUEST["selectedSummariesString"]);
                if ($selectedSummariesString != "") {
                    $selectedSummaries_array = explode(";", trim($selectedSummariesString, ";"));
                } else {
                    foreach ($this->reportinformations["summaries_columns"] as $key => $sum_arr) {
                        $selectedSummaries_array[] = $sum_arr["columnname"];
                    }
                }
                $labels_html["SM"] = $this->getLabelsHTML($selectedSummaries_array, "SM", $lbl_url_selected, $decode_labels);
                $smarty_obj->assign("labels_html", $labels_html);
                $smarty_obj->assign("LABELS", $curl);
                //added to avoid displaying "No data avaiable to total" when using related modules in report.
                $rows_count = count($labels_html);
                foreach ($labels_html as $key => $labels_type_arr) {
                    $rows_count += count($labels_type_arr);
                }
                $smarty_obj->assign("ROWS_COUNT", $rows_count);
            }
            if (in_array($step_name, array("ReportFilters", $get_all_steps))) {
                require_once 'modules/ITS4YouReports/FilterUtils.php';
                if (isset($_REQUEST["primarymodule"]) && $_REQUEST["primarymodule"] != "") {
                    $primary_moduleid = $_REQUEST["primarymodule"];
                    $primary_module = vtlib_getModuleNameById($_REQUEST["primarymodule"]);
                } else {
                    $primary_module = $this->primarymodule;
                    $primary_moduleid = $this->primarymoduleid;
                }
                // NEW ADVANCE FILTERS START
                $this->getGroupFilterList($this->record);
                $this->getAdvancedFilterList($this->record);
                $this->getSummariesFilterList($this->record);
                $sel_fields = Zend_Json::encode($this->adv_sel_fields);
                $smarty_obj->assign("SEL_FIELDS", $sel_fields);
                if (isset($_REQUEST["reload"])) {
                    $criteria_groups = $this->getRequestCriteria($sel_fields);
                } else {
                    $criteria_groups = $this->advft_criteria;
                }
                $smarty_obj->assign("CRITERIA_GROUPS", $criteria_groups);
                $smarty_obj->assign("EMPTY_CRITERIA_GROUPS", empty($criteria_groups));
                $smarty_obj->assign("SUMMARIES_CRITERIA", $this->summaries_criteria);
                $FILTER_OPTION = getAdvCriteriaHTML();
                $smarty_obj->assign("FOPTION", $FILTER_OPTION);
                $COLUMNS_BLOCK_JSON = $this->getAdvanceFilterOptionsJSON($primary_module);
                $smarty_obj->assign("COLUMNS_BLOCK", $COLUMNS_BLOCK);
                if ($mode != "ajax") {
                    echo "<textarea style='display:none;' id='filter_columns'>" . $COLUMNS_BLOCK_JSON . "</textarea>";
                    $smarty_obj->assign("filter_columns", $COLUMNS_BLOCK_JSON);
                    $sel_fields = Zend_Json::encode($this->adv_sel_fields);
                    $smarty_obj->assign("SEL_FIELDS", $sel_fields);
                    global $default_charset;
                    $std_filter_columns = $this->getStdFilterColumns();
                    $std_filter_columns_js = implode("<%jsstdjs%>", $std_filter_columns);
                    $std_filter_columns_js = html_entity_decode($std_filter_columns_js, ENT_QUOTES, $default_charset);
                    $smarty_obj->assign("std_filter_columns", $std_filter_columns_js);
                    $std_filter_criteria = Zend_Json::encode($this->Date_Filter_Values);
                    $smarty_obj->assign("std_filter_criteria", $std_filter_criteria);
                }
                $rel_fields = $this->adv_rel_fields;
                $smarty_obj->assign("REL_FIELDS", Zend_Json::encode($rel_fields));
                // NEW ADVANCE FILTERS END
                $BLOCKJS = $this->getCriteriaJS();
                $smarty_obj->assign("BLOCKJS_STD", $BLOCKJS);
            }
            if (in_array($step_name, array("ReportSharing", $get_all_steps))) {
                $roleid = $this->current_user->column_fields['roleid'];
                $user_array = getRoleAndSubordinateUsers($roleid);
                $userIdStr = "";
                $userNameStr = "";
                $m = 0;
                foreach ($user_array as $userid => $username) {
                    if ($userid != $this->current_user->id) {
                        if ($m != 0) {
                            $userIdStr .= ",";
                            $userNameStr .= ",";
                        }
                        $userIdStr .= "'" . $userid . "'";
                        $userNameStr .= "'" . escape_single_quotes(decode_html($username)) . "'";
                        $m++;
                    }
                }
                require_once 'include/utils/GetUserGroups.php';
                // ITS4YOU-UP SlOl 26. 4. 2013 9:47:59
                $template_owners = get_user_array(false);
                if (isset($this->reportinformations["owner"]) && $this->reportinformations["owner"] != "") {
                    $selected_owner = $this->reportinformations["owner"];
                } else {
                    $selected_owner = $this->current_user->id;
                }
                $smarty_obj->assign("TEMPLATE_OWNERS", $template_owners);
                $owner = isset($_REQUEST['template_owner']) && $_REQUEST['template_owner'] != '' ? $_REQUEST['template_owner'] : $selected_owner;
                $smarty_obj->assign("TEMPLATE_OWNER", $owner);
                $sharing_types = array("public" => vtranslate("PUBLIC_FILTER"), "private" => vtranslate("PRIVATE_FILTER"), "share" => vtranslate("SHARE_FILTER"));
                $smarty_obj->assign("SHARINGTYPES", $sharing_types);
                $sharingtype = "public";
                if (isset($_REQUEST['sharing']) && $_REQUEST['sharing'] != '') {
                    $sharingtype = $_REQUEST['sharing'];
                } elseif (isset($this->reportinformations["sharingtype"]) && $this->reportinformations["sharingtype"] != "") {
                    $sharingtype = $this->reportinformations["sharingtype"];
                }
                $smarty_obj->assign("SHARINGTYPE", $sharingtype);
                $cmod = return_specified_module_language($current_language, "Settings");
                $smarty_obj->assign("CMOD", $cmod);
                $sharingMemberArray = array();
                if (isset($_REQUEST['sharingSelectedColumns']) && $_REQUEST['sharingSelectedColumns'] != '') {
                    $sharingMemberArray = explode("|", trim($_REQUEST['sharingSelectedColumns'], "|"));
                } elseif (isset($this->reportinformations["members_array"]) && !empty($this->reportinformations["members_array"])) {
                    $sharingMemberArray = $this->reportinformations["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":
                                    $memberName = fetchGroupName($shareId);
                                    $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;
                        }
                    }
                    $smarty_obj->assign("MEMBER", array_chunk($outputMemberArr, 2));
                }
                // ITS4YOU-END
                $userGroups = new GetUserGroups();
                $userGroups->getAllUserGroups($this->current_user->id);
                $user_groups = $userGroups->user_groups;
                $groupIdStr = "";
                $groupNameStr = "";
                $l = 0;
                foreach ($user_groups as $i => $grpid) {
                    $grp_details = getGroupDetails($grpid);
                    if ($l != 0) {
                        $groupIdStr .= ",";
                        $groupNameStr .= ",";
                    }
                    $groupIdStr .= "'" . $grp_details[0] . "'";
                    $groupNameStr .= "'" . escape_single_quotes(decode_html($grp_details[1])) . "'";
                    $l++;
                }
                $visiblecriteria = getVisibleCriteria();
                $smarty_obj->assign("VISIBLECRITERIA", $visiblecriteria);
                $smarty_obj->assign("GROUPNAMESTR", $groupNameStr);
                $smarty_obj->assign("USERNAMESTR", $userNameStr);
                $smarty_obj->assign("GROUPIDSTR", $groupIdStr);
                $smarty_obj->assign("USERIDSTR", $userIdStr);
            }
            if (in_array($step_name, array("ReportScheduler", $get_all_steps))) {
                // SEE ReportScheduler.php for this step for a reason of problem with incomplemete ReportScheduler object
            }
            if (in_array($step_name, array("ReportGraphs", $get_all_steps))) {
                if (isset($_REQUEST["chart_type"]) && $_REQUEST["chart_type"] != "" && $_REQUEST["chart_type"] != "none") {
                    $selected_chart_type = vtlib_purify($_REQUEST["chart_type"]);
                } else {
                    $selected_chart_type = $this->reportinformations["charts"]["charttype"];
                }
                $smarty_obj->assign("IMAGE_PATH", $chart_type);
                if (isset($_REQUEST["data_series"]) && $_REQUEST["data_series"] != "" && $_REQUEST["data_series"] != "none") {
                    $selected_data_series = vtlib_purify($_REQUEST["data_series"]);
                } else {
                    $selected_data_series = $this->reportinformations["charts"]["dataseries"];
                }
                if (isset($_REQUEST["charttitle"]) && $_REQUEST["charttitle"] != "") {
                    $selected_charttitle = htmlspecialchars(vtlib_purify($_REQUEST["charttitle"]));
                } else {
                    $selected_charttitle = $this->reportinformations["charts"]["charttitle"];
                }
                $chart_type["horizontal"] = array("value" => vtranslate("LBL_CHART_horizontal", $this->currentModule), "selected" => $selected_chart_type == "horizontal" ? "selected" : "");
                $chart_type["vertical"] = array("value" => vtranslate("LBL_CHART_vertical", $this->currentModule), "selected" => $selected_chart_type == "vertical" ? "selected" : "");
                $chart_type["linechart"] = array("value" => vtranslate("LBL_CHART_linechart", $this->currentModule), "selected" => $selected_chart_type == "linechart" ? "selected" : "");
                $chart_type["pie"] = array("value" => vtranslate("LBL_CHART_pie", $this->currentModule), "selected" => $selected_chart_type == "pie" ? "selected" : "");
                $chart_type["pie3d"] = array("value" => vtranslate("LBL_CHART_pie3D", $this->currentModule), "selected" => $selected_chart_type == "pie3d" ? "selected" : "");
                $chart_type["funnel"] = array("value" => vtranslate("LBL_CHART_funnel", $this->currentModule), "selected" => $selected_chart_type == "funnel" ? "selected" : "");
                $smarty_obj->assign("CHART_TYPE", $chart_type);
                // selected labels from url
                if (isset($_REQUEST["lblurl"])) {
                    global $default_charset;
                    $lbl_url_string = html_entity_decode(vtlib_purify($_REQUEST["lblurl"]), ENT_QUOTES, $default_charset);
                }
                $lbl_url_string = str_replace("@AMPKO@", "&", $lbl_url_string);
                if ($lbl_url_string != "") {
                    $lbl_url_arr = explode('$_@_$', $lbl_url_string);
                    foreach ($lbl_url_arr as $key => $lbl_value) {
                        if (strpos($lbl_value, 'hidden_') === false) {
                            if (strpos($lbl_value, '_SC_lLbLl_') !== false) {
                                $temp = explode('_SC_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = $temp_lbls[0];
                                $lbl_value = $temp_lbls[1];
                                $lbl_url_selected["SC"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_SM_lLbLl_') !== false) {
                                $temp = explode('_SM_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = $temp_lbls[0];
                                $lbl_value = $temp_lbls[1];
                                $lbl_url_selected["SM"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_CT_lLbLl_') !== false) {
                                $temp = explode('_CT_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = $temp_lbls[0];
                                $lbl_value = $temp_lbls[1];
                                $lbl_url_selected["CT"][$lbl_key] = $lbl_value;
                            }
                        }
                    }
                }
                $selectedSummariesString = vtlib_purify($_REQUEST["selectedSummariesString"]);
                if ($selectedSummariesString != "") {
                    $selectedSummariesArray = explode(";", $selectedSummariesString);
                    if (!empty($selectedSummariesArray)) {
                        foreach ($selectedSummariesArray as $column_str) {
                            if ($column_str != "") {
                                if (isset($lbl_url_selected["SM"][$column_str]) && $lbl_url_selected["SM"][$column_str] != "") {
                                    $column_lbl = $lbl_url_selected["SM"][$column_str];
                                } else {
                                    $column_str_arr = explode(":", $column_str);
                                    $translate_arr = explode("_", $column_str_arr[2]);
                                    $translate_module = $translate_arr[0];
                                    unset($translate_arr[0]);
                                    $translate_str = implode("_", $translate_arr);
                                    $translate_mod_str = return_module_language($current_language, $translate_module);
                                    if (isset($translate_mod_str[$translate_str])) {
                                        $column_lbl = $translate_mod_str[$translate_str];
                                    } else {
                                        $column_lbl = $translate_str;
                                    }
                                }
                                $data_series[$column_str] = array("value" => $column_lbl, "selected" => $column_str == $selected_data_series ? "selected" : "");
                            }
                        }
                    }
                }
                if (empty($data_series) && $selected_data_series != "") {
                    $column_lbl = $this->getColumnStr_Label($selected_data_series, "SM");
                    $data_series[$selected_data_series] = array("value" => $column_lbl, "selected" => "selected");
                }
                $smarty_obj->assign("DATA_SERIES", $data_series);
                $smarty_obj->assign("CHART_TITLE", $selected_charttitle);
            }
            return $smarty_obj;
        }
    }
Example #14
0
 case 'step7':
     include "modules/ITS4YouReports/ReportLabels.php";
     break;
 case 'step8':
     /*if($_REQUEST["record"]!=""){
     			include("modules/ITS4YouReports/ReportFilters.php");
     		}else{*/
     $BLOCK_R = '';
     $BLOCK1 = "";
     $BLOCK2 = '';
     $Options = array();
     $secondarymodule = '';
     $secondarymodules = array();
     $ITS4YouReports = ITS4YouReports::getStoredITS4YouReport();
     $primarymodule_id = vtlib_purify($_REQUEST["primarymodule"]);
     $primarymodule = vtlib_getModuleNameById($primarymodule_id);
     $reportid = $ITS4YouReports->record;
     $BLOCK1 = $ITS4YouReports->getAdvanceFilterOptionsJSON($primarymodule);
     $BLOCK_R .= $BLOCK1;
     // ITS4YOU-CR SlOl 21. 3. 2014 10:20:17 summaries columns for frouping filters start
     $selectedSummariesString = vtlib_purify($_REQUEST["selectedSummariesString"]);
     $selectedSummariesArr = explode(";", $selectedSummariesString);
     $sm_arr = sgetSelectedSummariesOptions($selectedSummariesArr);
     $sm_str = "";
     foreach ($sm_arr as $key => $opt_arr) {
         if ($sm_str != "") {
             $sm_str .= "(|@!@|)";
         }
         $sm_str .= $opt_arr["value"] . "(|@|)" . $opt_arr["text"];
     }
     $BLOCK_S = $sm_str;
Example #15
0
$report_column->assign("APP", $app_strings);
$report_column->assign("IMAGE_PATH", $image_path);
$report_column->assign("THEME_PATH", $theme_path);
// ITS4YOU-CR SlOl 10. 9. 2013 16:13:47
$LBL_INFORMATIONS_4YOU = getTranslatedString("LBL_STEP10_INFO", $currentModule);
$report_column->assign("LBL_INFORMATIONS_4YOU", $LBL_INFORMATIONS_4YOU);
// ITS4YOU-END 10. 9. 2013 16:13:50
$recordid = "";
if (isset($_REQUEST["record"]) && $_REQUEST['record'] != '') {
    $recordid = vtlib_purify($_REQUEST["record"]);
}
$oReport = new ITS4YouReports();
$R_Objects = array();
if (isset($_REQUEST["selectedColumnsStr"])) {
    $R_Objects = explode("<_@!@_>", $_REQUEST["selectedColumnsStr"]);
    $r_p_module = vtlib_getModuleNameById(vtlib_purify($_REQUEST["primarymodule"]));
    $quick_columns_arraySelected = array();
    $qf_to_go = explode('$_@_$', vtlib_purify($_REQUEST["qf_to_go"]));
    foreach ($qf_to_go as $key => $qf_to_go_str) {
        $quick_columns_arraySelected[] = trim($qf_to_go_str, "qf:");
    }
} else {
    $sarray = $oReport->getSelectedColumnListArray($recordid);
    foreach ($sarray as $key => $scarray) {
        $R_Objects[] = $scarray["fieldcolname"];
    }
    $r_p_module = $oReport->primarymodule;
}
foreach ($R_Objects as $column_str) {
    $column_arr = explode(":", $column_str);
    $last_key = count($column_arr) - 1;
Example #16
0
 /** Returns a list of the associated emails
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
  * All Rights Reserved..
  * Contributor(s): ______________________________________..
  */
 function get_emails($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_emails(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     $button .= '<input type="hidden" name="email_directing_module"><input type="hidden" name="record">';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' accessyKey='F' class='crmbutton small create' onclick='fnvshobj(this,\"sendmail_cont\");sendmail(\"{$this_module}\",{$id});' type='button' name='button' value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'></td>";
         }
     }
     $userNameSql = getSqlForNameInDisplayFormat(array('f' => 'vtiger_users.first_name', 'l' => 'vtiger_users.last_name'));
     $query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\tvtiger_activity.activityid, vtiger_activity.subject,\n\t\t\tvtiger_activity.activitytype, vtiger_crmentity.modifiedtime,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_activity.date_start, vtiger_seactivityrel.crmid as parent_id \n\t\t\tFROM vtiger_activity, vtiger_seactivityrel, vtiger_vendor, vtiger_users, vtiger_crmentity\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid=vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tAND vtiger_vendor.vendorid = vtiger_seactivityrel.crmid\n\t\t\t\tAND vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t\tAND vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\t\t\tAND vtiger_vendor.vendorid = " . $id . "\n\t\t\t\tAND vtiger_activity.activitytype='Emails'\n\t\t\t\tAND vtiger_crmentity.deleted = 0";
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_emails method ...");
     return $return_value;
 }
Example #17
0
	/**
	 * Function to handle the related list for the module.
	 * NOTE: Vtiger_Module::setRelatedList sets reference to this function in vtiger_relatedlists table
	 * if function name is not explicitly specified.
	 */
	function get_related_list($id, $cur_tab_id, $rel_tab_id, $actions = false)
	{
		global $currentModule, $app_strings, $singlepane_view;

		$current_module = vtlib_getModuleNameById($cur_tab_id);
		$related_module = vtlib_getModuleNameById($rel_tab_id);
		$other = CRMEntity::getInstance($related_module);

		// Some standard module class doesn't have required variables
		// that are used in the query, they are defined in this generic API
		vtlib_setup_modulevars($current_module, $this);
		vtlib_setup_modulevars($related_module, $other);

		$singular_modname = 'SINGLE_' . $related_module;

		$button = '';
		if ($actions) {
			if (is_string($actions))
				$actions = explode(',', strtoupper($actions));
			if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
				$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' " .
					" type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$current_module&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\"" .
					" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module, $related_module) . "'>&nbsp;";
			}
			if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
				$button .= "<input type='hidden' name='createmode' id='createmode' value='link' />" .
					"<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" .
					" onclick='this.form.action.value=\"EditView\";this.form.module.value=\"$related_module\"' type='submit' name='button'" .
					" value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "'>&nbsp;";
			}
		}

		// To make the edit or del link actions to return back to same view.
		if ($singlepane_view == 'true') {
			$returnset = "&return_module=$current_module&return_action=DetailView&return_id=$id";
		} else {
			$returnset = "&return_module=$current_module&return_action=CallRelatedList&return_id=$id";
		}

		$more_relation = '';
		if (!empty($other->related_tables)) {
			foreach ($other->related_tables as $tname => $relmap) {
				$query .= ", $tname.*";

				// Setup the default JOIN conditions if not specified
				if (empty($relmap[1]))
					$relmap[1] = $other->table_name;
				if (empty($relmap[2]))
					$relmap[2] = $relmap[0];
				$more_relation .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]";
			}
		}

		$entityIds = $this->getRelatedContactsIds();
		array_push($entityIds, $id);
		$entityIds = implode(',', $entityIds);

		$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');

		$query = "SELECT vtiger_crmentity.*, $other->table_name.*,
				CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN $userNameSql ELSE vtiger_groups.groupname END AS user_name FROM $other->table_name
				INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $other->table_name.$other->table_index
				INNER JOIN vtiger_crmentityrel ON (vtiger_crmentityrel.relcrmid = vtiger_crmentity.crmid OR vtiger_crmentityrel.crmid = vtiger_crmentity.crmid)
				$more_relation
				LEFT  JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
				LEFT  JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid
				WHERE vtiger_crmentity.deleted = 0 AND (vtiger_crmentityrel.crmid IN (" . $entityIds . ") OR vtiger_crmentityrel.relcrmid IN (" . $entityIds . "))";

		$return_value = GetRelatedList($current_module, $related_module, $other, $query, $button, $returnset);

		if ($return_value == null)
			$return_value = Array();
		$return_value['CUSTOM_BUTTON'] = $button;

		return $return_value;
	}
Example #18
0
 /**
  * Function to get Potential related SalesOrder
  * @param  integer   $id  - potentialid
  * returns related SalesOrder record in array format
  */
 function get_salesorder($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_salesorder(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     if ($actions && getFieldVisibilityPermission($related_module, $current_user->id, 'potential_id', 'readwrite') == '0') {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'>&nbsp;";
         }
     }
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename\n\t\t\t, vtiger_account.accountname, vtiger_potential.potentialname,case when\n\t\t\t(vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname\n\t\t\tend as user_name from vtiger_salesorder\n\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid\n\t\t\tleft outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid\n\t\t\tleft outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid\n\t\t\tleft outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid\n\t\t\tleft join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid\n            LEFT JOIN vtiger_salesordercf ON vtiger_salesordercf.salesorderid = vtiger_salesorder.salesorderid\n            LEFT JOIN vtiger_invoice_recurring_info ON vtiger_invoice_recurring_info.start_period = vtiger_salesorder.salesorderid\n\t\t\tLEFT JOIN vtiger_sobillads ON vtiger_sobillads.sobilladdressid = vtiger_salesorder.salesorderid\n\t\t\tLEFT JOIN vtiger_soshipads ON vtiger_soshipads.soshipaddressid = vtiger_salesorder.salesorderid\n\t\t\tleft join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = " . $id;
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_salesorder method ...");
     return $return_value;
 }
Example #19
0
 public static function ReportFiltersAjax(Vtiger_Request $request)
 {
     $BLOCK_R = $BLOCK1 = $BLOCK2 = '';
     $Options = array();
     $secondarymodule = '';
     $secondarymodules = array();
     $record = $request->get('record');
     $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record);
     $primary_moduleid = $request->get("primarymodule");
     $primary_module = vtlib_getModuleNameById($primary_moduleid);
     //$reportModel->report->init_list_for_module($primary_module);
     $related_modules = $reportModel->getReportRelatedModulesList();
     if (!empty($related_modules[$primary_module])) {
         foreach ($related_modules[$primary_module] as $key => $value) {
             $exploded_mid = explode("x", $value["id"]);
             if (strtolower($exploded_mid[1]) != "mif") {
                 $secondarymodules[] = $value["id"];
             }
         }
     }
     $Options = $reportModel->getPrimaryColumns($Options, $primary_module, true);
     // $Options = array_merge(array(vtranslate("LBL_NONE")=>array("0"=>array("value"=>"","text"=>vtranslate("LBL_NONE"),))), $p_options);
     $secondarymodules_str = implode(":", $secondarymodules);
     $reportModel->getSecModuleColumnsList($secondarymodules_str);
     $Options_sec = $reportModel->getSecondaryColumns(array(), $secondarymodules_str);
     foreach ($Options_sec as $moduleid => $sec_options) {
         $Options = array_merge($Options, $sec_options);
     }
     // ITS4YOU-CR SlOl 16. 9. 2015 10:49:04 OTHER COLUMNS
     if ($request->has("selectedColumnsStr") && $request->get("selectedColumnsStr") != "") {
         $selectedColumnsStr = $request->get("selectedColumnsStr");
         $selectedColumnsStringDecoded = html_entity_decode($selectedColumnsStr, ENT_QUOTES, $default_charset);
         $selectedColumns_arr = explode("<_@!@_>", $selectedColumnsStringDecoded);
     } else {
         $selectedColumnsStr = $reportModel->report->reportinformations["selectedColumnsString"];
         $selectedColumnsStringDecoded = html_entity_decode($selectedColumnsStr, ENT_QUOTES, $default_charset);
         $selectedColumns_arr = explode(";", $selectedColumnsStringDecoded);
     }
     if (!empty($selectedColumns_arr)) {
         $opt_label = vtranslate("LBL_Filter_SelectedColumnsGroup", "ITS4YouReports");
         foreach ($selectedColumns_arr as $sc_key => $sc_col_str) {
             if ($sc_col_str != "") {
                 $in_options = false;
                 foreach ($Options as $opt_group => $opt_array) {
                     if ($reportModel->report->in_multiarray($sc_col_str, $opt_array, "value") === true) {
                         $in_options = true;
                         continue;
                     }
                 }
                 if ($in_options) {
                     continue;
                 } else {
                     $Options[$opt_label][] = array("value" => $sc_col_str, "text" => $reportModel->report->getColumnStr_Label($sc_col_str));
                 }
             }
         }
     }
     // ITS4YOU-END
     foreach ($Options as $optgroup => $optionsdata) {
         if ($BLOCK1 != "") {
             $BLOCK1 .= "(|@!@|)";
         }
         $BLOCK1 .= $optgroup;
         $BLOCK1 .= "(|@|)";
         $BLOCK1 .= Zend_JSON::encode($optionsdata);
     }
     $BLOCK_R .= $BLOCK1;
     // ITS4YOU-CR SlOl 21. 3. 2014 10:20:17 summaries columns for frouping filters start
     $selectedSummariesString = $request->get("selectedSummariesString");
     $selectedSummariesArr = explode(";", $selectedSummariesString);
     $sm_arr = sgetSelectedSummariesOptions($selectedSummariesArr);
     $sm_str = "";
     foreach ($sm_arr as $key => $opt_arr) {
         if ($sm_str != "") {
             $sm_str .= "(|@!@|)";
         }
         $sm_str .= $opt_arr["value"] . "(|@|)" . $opt_arr["text"];
     }
     $BLOCK_S = $sm_str;
     $BLOCK_R .= "__BLOCKS__" . $BLOCK_S;
     $Report_Informations = $reportModel->getReportInformations();
     if (isset($Report_Informations["advft_criteria"]) && $Report_Informations["advft_criteria"] != "") {
         $advft_criteria = $Report_Informations["advft_criteria"];
     } else {
         $advft_criteria = "";
     }
     $BLOCK_R .= "__ADVFTCRI__" . Zend_JSON::encode($advft_criteria);
     $adv_sel_fields = $reportModel->getAdvSelFields();
     $sel_fields = Zend_Json::encode($adv_sel_fields);
     $BLOCK_R .= "__ADVFTCRI__" . $sel_fields;
     $default_charset = vglobal("default_charset");
     $std_filter_columns = $reportModel->getStdFilterColumns();
     $std_filter_columns_js = implode("<%jsstdjs%>", $std_filter_columns);
     $std_filter_columns_js = html_entity_decode($std_filter_columns_js, ENT_QUOTES, $default_charset);
     $BLOCK_R .= "__ADVFTCRI__" . $std_filter_columns_js;
     return $BLOCK_R;
 }
Example #20
0
 /**
  * Function to get Account related Products 
  * @param  integer   $id      - accountid
  * returns related Products record in array format
  */
 function get_products($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_products(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'>&nbsp;";
         }
     }
     $query = "SELECT vtiger_products.productid, vtiger_products.productname,\n\t\t\tvtiger_products.productcode, vtiger_products.commissionrate,\n\t\t\tvtiger_products.qty_per_unit, vtiger_products.unit_price,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid\n\t\t\tFROM vtiger_products\n\t\t\tINNER JOIN vtiger_seproductsrel ON vtiger_products.productid = vtiger_seproductsrel.productid and vtiger_seproductsrel.setype='Accounts'\n\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid\n\t\t\tINNER JOIN vtiger_account ON vtiger_account.accountid = vtiger_seproductsrel.crmid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_account.accountid = {$id}";
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_products method ...");
     return $return_value;
 }
Example #21
0
 /**
  * Function to get Product's related Products
  * @param  integer   $id      - productid
  * returns related Products record in array format
  */
 function get_services($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     $log = vglobal('log');
     $current_user = vglobal('current_user');
     $singlepane_view = vglobal('singlepane_view');
     $currentModule = vglobal('currentModule');
     $log->debug("Entering get_products(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     if ($actions && $this->ismember_check() === 0) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input type='hidden' name='createmode' id='createmode' value='link' />" . "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'>&nbsp;";
         }
     }
     $query = "SELECT vtiger_service.serviceid, vtiger_service.servicename,\n\t\t\tvtiger_service.service_no, vtiger_service.commissionrate,\n\t\t\tvtiger_service.service_usageunit, vtiger_service.unit_price,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid\n\t\t\tFROM vtiger_service\n\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_service.serviceid\n\t\t\tINNER JOIN vtiger_servicecf\n\t\t\t\tON vtiger_service.serviceid = vtiger_servicecf.serviceid\n\t\t\tLEFT JOIN vtiger_crmentityrel ON vtiger_crmentityrel.relcrmid = vtiger_service.serviceid AND vtiger_crmentityrel.module='Services'\n\t\t\tLEFT JOIN vtiger_users\n\t\t\t\tON vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_crmentityrel.crmid = {$id} ";
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_products method ...");
     return $return_value;
 }
Example #22
0
/** Function to get the HTML strings for the secondary  standard filters
 * @ param $module : Type String
 * @ param $selected : Type String(optional)
 *  This Returns a HTML combo srings for the secondary modules
 */
function getITSSecondaryStdFilterHTML($ITS4YouReports, $module = '', $selected = "")
{
    global $app_list_strings;
    global $current_language;
    $ITS4YouReports->oCustomView = new CustomView();
    $shtml = "";
    if ($module != "") {
        $secmodule = explode(":", $module);
        for ($i = 0; $i < count($secmodule); $i++) {
            $mod_arr = explode("x", $secmodule[$i]);
            $moduleid = $mod_arr[0];
            $secmodulename = vtlib_getModuleNameById($moduleid);
            $fieldidstr = "";
            if (isset($mod_arr[1]) && $mod_arr[1] != "") {
                $fieldidstr = ":" . $mod_arr[1];
            }
            $result = $ITS4YouReports->oCustomView->getStdCriteriaByModule($secmodulename);
            $mod_strings = return_module_language($current_language, $secmodulename);
            if (isset($result)) {
                foreach ($result as $key => $value) {
                    if (isset($mod_strings[$value])) {
                        if ($key == $selected) {
                            $shtml .= "<option selected value=\"" . $key . "\">" . getTranslatedString($secmodulename, $secmodulename) . " - " . getTranslatedString($value, $secmodulename) . "</option>";
                        } else {
                            $shtml .= "<option value=\"" . $key . "\">" . getTranslatedString($secmodulename, $secmodulename) . " - " . getTranslatedString($value, $secmodulename) . "</option>";
                        }
                    } else {
                        if ($key == $selected) {
                            $shtml .= "<option selected value=\"" . $key . "\">" . getTranslatedString($secmodulename, $secmodulename) . " - " . $value . "</option>";
                        } else {
                            $shtml .= "<option value=\"" . $key . "\">" . getTranslatedString($secmodulename, $secmodulename) . " - " . $value . "</option>";
                        }
                    }
                }
            }
        }
    }
    return $shtml;
}
 /**
  * Default (generic) function to handle the dependents list for the module.
  * NOTE: UI type '10' is used to stored the references to other modules for a given record.
  * These dependent records can be retrieved through this function.
  * For eg: A trouble ticket can be related to an Account or a Contact.
  * From a given Contact/Account if we need to fetch all such dependent trouble tickets, get_dependents_list function can be used.
  */
 function get_dependents_list($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $currentModule, $app_strings, $singlepane_view, $current_user;
     $parenttab = getParentTab();
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     $other = CRMEntity::getInstance($related_module);
     // Some standard module class doesn't have required variables
     // that are used in the query, they are defined in this generic API
     vtlib_setup_modulevars($currentModule, $this);
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = 'SINGLE_' . $related_module;
     $button = '';
     // To make the edit or del link actions to return back to same view.
     if ($singlepane_view == 'true') {
         $returnset = "&return_module={$currentModule}&return_action=DetailView&return_id={$id}";
     } else {
         $returnset = "&return_module={$currentModule}&return_action=CallRelatedList&return_id={$id}";
     }
     $return_value = null;
     $dependentFieldSql = $this->db->pquery("SELECT tabid, fieldname, columnname FROM vtiger_field WHERE uitype='10' AND" . " fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)", array($currentModule, $related_module));
     $numOfFields = $this->db->num_rows($dependentFieldSql);
     if ($numOfFields > 0) {
         $dependentColumn = $this->db->query_result($dependentFieldSql, 0, 'columnname');
         $dependentField = $this->db->query_result($dependentFieldSql, 0, 'fieldname');
         $button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">';
         $button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">';
         if ($actions) {
             if (is_string($actions)) {
                 $actions = explode(',', strtoupper($actions));
             }
             if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes' && getFieldVisibilityPermission($related_module, $current_user->id, $dependentField, 'readwrite') == '0') {
                 $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "'>&nbsp;";
             }
         }
         $query = "SELECT vtiger_crmentity.*, {$other->table_name}.*";
         $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
         $query .= ", CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name";
         $more_relation = '';
         if (!empty($other->related_tables)) {
             foreach ($other->related_tables as $tname => $relmap) {
                 $query .= ", {$tname}.*";
                 // Setup the default JOIN conditions if not specified
                 if (empty($relmap[1])) {
                     $relmap[1] = $other->table_name;
                 }
                 if (empty($relmap[2])) {
                     $relmap[2] = $relmap[0];
                 }
                 $more_relation .= " LEFT JOIN {$tname} ON {$tname}.{$relmap['0']} = {$relmap['1']}.{$relmap['2']}";
             }
         }
         $query .= " FROM {$other->table_name}";
         $query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = {$other->table_name}.{$other->table_index}";
         $query .= " INNER  JOIN {$this->table_name}   ON {$this->table_name}.{$this->table_index} = {$other->table_name}.{$dependentColumn}";
         $query .= $more_relation;
         $query .= " LEFT  JOIN vtiger_users        ON vtiger_users.id = vtiger_crmentity.smownerid";
         $query .= " LEFT  JOIN vtiger_groups       ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
         $query .= " WHERE vtiger_crmentity.deleted = 0 AND {$this->table_name}.{$this->table_index} = {$id}";
         $return_value = GetRelatedList($currentModule, $related_module, $other, $query, $button, $returnset);
     }
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     return $return_value;
 }
Example #24
0
 function getSecondaryColumnsHTML($module)
 {
     if ($module != "") {
         $secmodule = explode(":", $module);
         for ($i = 0; $i < count($secmodule); $i++) {
             $modulename = vtlib_getModuleNameById($secmodule[$i]);
             if (vtlib_isModuleActive($modulename)) {
                 $block_listed = array();
                 $modulename_lang = vtranslate($modulename, $modulename);
                 foreach ($this->report->module_list[$modulename] as $key => $value) {
                     if (isset($this->report->sec_module_columnslist[$modulename][$value]) && !$block_listed[$value]) {
                         $block_listed[$value] = true;
                         $shtml .= "<optgroup label=\"" . $modulename_lang . " " . vtranslate($value) . "\" class=\"select\" style=\"border:none\">";
                         foreach ($this->report->sec_module_columnslist[$modulename][$value] as $field => $fieldlabel) {
                             $shtml .= "<option value=\"" . $field . "\">" . vtranslate($fieldlabel, $modulename) . "</option>";
                         }
                         $shtml .= "</optgroup>";
                     }
                 }
             }
         }
     }
     return $shtml;
 }
Example #25
0
 function get_emails($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     $log = vglobal('log');
     $current_user = vglobal('current_user');
     $singlepane_view = vglobal('singlepane_view');
     $currentModule = vglobal('currentModule');
     $log->debug("Entering get_emails(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     $button .= '<input type="hidden" name="email_directing_module"><input type="hidden" name="record">';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' accessyKey='F' class='crmbutton small create' onclick='fnvshobj(this,\"sendmail_cont\");sendmail(\"{$this_module}\",{$id});' type='button' name='button' value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'></td>";
         }
     }
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT vtiger_ossmailview.*, vtiger_crmentity.modifiedtime, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name FROM vtiger_ossmailview \n\t\t\tINNER JOIN vtiger_ossmailview_relation ON vtiger_ossmailview_relation.ossmailviewid = vtiger_ossmailview.ossmailviewid\n\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_ossmailview.ossmailviewid \n\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid \n\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id\n\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_ossmailview_relation.crmid = " . $id . " ";
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_emails method ...");
     return $return_value;
 }
Example #26
0
 function getColumnsTotal($reportid)
 {
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getColumnsTotal");
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getColumnsTotal");
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getColumnsTotal");
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getColumnsTotal");
     // Have we initialized it already?
     if (isset($this->_columnstotallist) && $this->_columnstotallist !== false) {
         return $this->_columnstotallist;
     }
     $adb = PEARDatabase::getInstance();
     global $current_user;
     $query = "SELECT * FROM its4you_reports4you_modules WHERE reportmodulesid =?";
     $res = $adb->pquery($query, array($reportid));
     $modrow = $adb->fetch_array($res);
     $premod = $modrow["primarymodule"];
     $premod_name = vtlib_getModuleNameById($premod);
     $secmod = $modrow["secondarymodules"];
     $coltotalsql = "SELECT its4you_reports4you_summary.* FROM its4you_reports4you";
     $coltotalsql .= " INNER JOIN its4you_reports4you_summary on its4you_reports4you.reports4youid = its4you_reports4you_summary.reportsummaryid";
     $coltotalsql .= " WHERE its4you_reports4you.reports4youid =?";
     $result = $adb->pquery($coltotalsql, array($reportid));
     while ($coltotalrow = $adb->fetch_array($result)) {
         $fieldcolname = $coltotalrow["columnname"];
         if ($fieldcolname != "none") {
             $fieldlist = explode(":", $fieldcolname);
             $field_tablename = $fieldlist[1];
             $field_columnname = $fieldlist[2];
             $mod_query = $adb->pquery("SELECT distinct(tabid) AS tabid FROM vtiger_field WHERE tablename = ? AND columnname=?", array($fieldlist[1], $fieldlist[2]));
             if ($adb->num_rows($mod_query) > 0) {
                 $module_name = getTabName($adb->query_result($mod_query, 0, 'tabid'));
                 $fieldlabel = trim($fieldlist[3]);
                 if ($module_name) {
                     $field_columnalias = $module_name . "_" . $fieldlist[3];
                 } else {
                     $field_columnalias = $module_name . "_" . $fieldlist[3];
                 }
             }
             //$field_columnalias = $fieldlist[3];
             $field_permitted = false;
             if (CheckColumnPermission($field_tablename, $field_columnname, $premod) != "false") {
                 $field_permitted = true;
             } else {
                 $mod_s = split(":", $secmod);
                 // $premod_name = vtlib_getModuleNameById($premod);
                 foreach ($mod_s as $key) {
                     $mod_arr = explode("x", $key);
                     $mod = $mod_arr[0];
                     $mod_name = vtlib_getModuleNameById($mod);
                     if (CheckColumnPermission($field_tablename, $field_columnname, $mod_name) != "false") {
                         $field_permitted = true;
                     }
                 }
             }
             if ($field_permitted == true) {
                 $field = $field_tablename . "." . $field_columnname;
                 if ($field_tablename == 'vtiger_products' && $field_columnname == 'unit_price') {
                     // Query needs to be rebuild to get the value in user preferred currency. [innerProduct and actual_unit_price are table and column alias.]
                     $field = " innerProduct.actual_unit_price";
                 }
                 if ($field_tablename == 'vtiger_service' && $field_columnname == 'unit_price') {
                     // Query needs to be rebuild to get the value in user preferred currency. [innerProduct and actual_unit_price are table and column alias.]
                     $field = " innerService.actual_unit_price";
                 }
                 if (($field_tablename == 'vtiger_invoice' || $field_tablename == 'vtiger_quotes' || $field_tablename == 'vtiger_purchaseorder' || $field_tablename == 'vtiger_salesorder') && ($field_columnname == 'total' || $field_columnname == 'subtotal' || $field_columnname == 'discount_amount' || $field_columnname == 's_h_amount')) {
                     $field = " {$field_tablename}.{$field_columnname}/{$field_tablename}.conversion_rate ";
                 }
                 //ITS4YouReports::sshow($fieldlist);
                 if ($fieldlist[4] == 2) {
                     $stdfilterlist[$fieldcolname] = "sum({$field}) '" . $field_columnalias . "'";
                 }
                 if ($fieldlist[4] == 3) {
                     //Fixed average calculation issue due to NULL values ie., when we use avg() function, NULL values will be ignored.to avoid this we use (sum/count) to find average.
                     //$stdfilterlist[$fieldcolname] = "avg(".$fieldlist[1].".".$fieldlist[2].") '".$fieldlist[3]."'";
                     $stdfilterlist[$fieldcolname] = "(sum({$field})/count(*)) '" . $field_columnalias . "'";
                 }
                 if ($fieldlist[4] == 4) {
                     $stdfilterlist[$fieldcolname] = "min({$field}) '" . $field_columnalias . "'";
                 }
                 if ($fieldlist[4] == 5) {
                     $stdfilterlist[$fieldcolname] = "max({$field}) '" . $field_columnalias . "'";
                 }
             }
         }
     }
     // Save the information
     $this->_columnstotallist = $stdfilterlist;
     return $stdfilterlist;
 }
Example #27
0
 function get_project_mail($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $currentModule, $app_strings, $singlepane_view;
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     $other = CRMEntity::getInstance($related_module);
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $button = '';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input type='hidden' name='createmode' id='createmode' value='link' />" . "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'>&nbsp;";
         }
     }
     if ($singlepane_view == 'true') {
         $returnset = "&return_module={$this_module}&return_action=DetailView&return_id={$id}";
     } else {
         $returnset = "&return_module={$this_module}&return_action=CallRelatedList&return_id={$id}";
     }
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\t\tvtiger_crmentity.*, vtiger_project.*, vtiger_projectcf.*\n\t\t\t\tFROM vtiger_project\n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_project.projectid\n\t\t\t\tLEFT JOIN vtiger_projectcf ON vtiger_projectcf.projectid = vtiger_project.projectid\n\t\t\t\tLEFT JOIN vtiger_ossmailview_project ON vtiger_ossmailview_project.crmid = vtiger_project.projectid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_ossmailview_project.ossmailviewid = '{$id}'";
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     return $return_value;
 }
Example #28
0
 static function get_payments($module, $id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_contacts(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     if ($singlepane_view == 'true') {
         $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
     } else {
         $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
     }
     $button = '';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
         if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('SINGLE_Accounting', 'Accounting') . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('SINGLE_Accounting', 'Accounting') . "'>&nbsp;";
         }
     }
     if ($module == "Invoice") {
         $rel_tabla = "vtiger_invoice";
         $rel_id = "invoiceid";
         $acc_rel_field = "accountingrelated2";
     } else {
         if ($module == "SalesOrder") {
             $rel_tabla = "vtiger_salesorder";
             $rel_id = "salesorderid";
             $acc_rel_field = "accountingrelated2";
         } else {
             if ($module == "PurchaseOrder") {
                 $rel_tabla = "vtiger_purchaseorder";
                 $rel_id = "purchaseorderid";
                 $acc_rel_field = "accountingrelated2";
             } else {
                 if ($module == "Accounts") {
                     $rel_tabla = "vtiger_account";
                     $rel_id = "accountid";
                     $acc_rel_field = "accountingrelated1";
                 } else {
                     if ($module == "Contacts") {
                         $rel_tabla = "vtiger_contactdetails";
                         $rel_id = "contactid";
                         $acc_rel_field = "accountingrelated1";
                     } else {
                         if ($module == "Vendors") {
                             $rel_tabla = "vtiger_vendor";
                             $rel_id = "vendorid";
                             $acc_rel_field = "accountingrelated1";
                         } else {
                             if ($module == "Project") {
                                 $rel_tabla = "vtiger_project";
                                 $rel_id = "projectid";
                                 $acc_rel_field = "accountingrelated1";
                             } else {
                                 if ($module == "Potentials") {
                                     $rel_tabla = "vtiger_potential";
                                     $rel_id = "potentialid";
                                     $acc_rel_field = "accountingrelated1";
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $query = "SELECT vtiger_accounting.*,\n\t\t\t\tvtiger_crmentity.crmid,\n\t                        vtiger_crmentity.smownerid,\n\t\t\t\tvtiger_accounting.paymentref,\n\t\t\t\tcase when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name\n\t\t\t\tFROM vtiger_accounting\n\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_crmentity.crmid = vtiger_accounting.accountingid\n\t\t\t\tLEFT JOIN " . $rel_tabla . "\n\t\t\t\t\tON " . $rel_tabla . "." . $rel_id . " = vtiger_accounting.accountingid\n\t\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_crmentity.smownerid = vtiger_users.id\n\t\t\t\tWHERE vtiger_crmentity.deleted = 0\n\t\t\t\tAND vtiger_accounting." . $acc_rel_field . " = " . $id;
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if (($module == "Invoice" || $module == "PurchaseOrder" || $module == "SalesOrder") && count($return_value['entries']) > 0) {
         $button = "";
     }
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_contacts method ...");
     return $return_value;
 }
Example #29
0
 /**
  * Function to get Activity related Contacts
  * @param  integer   $id      - activityid
  * returns related Contacts record in array format
  */
 function get_contacts($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     global $log, $singlepane_view, $currentModule, $current_user;
     $log->debug("Entering get_contacts(" . $id . ") method ...");
     $this_module = $currentModule;
     $related_module = vtlib_getModuleNameById($rel_tab_id);
     require_once "modules/{$related_module}/{$related_module}.php";
     $other = new $related_module();
     vtlib_setup_modulevars($related_module, $other);
     $singular_modname = vtlib_toSingular($related_module);
     $parenttab = getParentTab();
     $returnset = '&return_module=' . $this_module . '&return_action=DetailView&activity_mode=Events&return_id=' . $id;
     $search_string = '';
     $button = '';
     if ($actions) {
         if (is_string($actions)) {
             $actions = explode(',', strtoupper($actions));
         }
         if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
             $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}{$search_string}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
         }
     }
     $query = 'select vtiger_users.user_name,vtiger_contactdetails.accountid,vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_contactdetails.department, vtiger_contactdetails.title, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid=vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid where vtiger_cntactivityrel.activityid=' . $id . ' and vtiger_crmentity.deleted=0';
     $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
     if ($return_value == null) {
         $return_value = array();
     }
     $return_value['CUSTOM_BUTTON'] = $button;
     $log->debug("Exiting get_contacts method ...");
     return $return_value;
 }
Example #30
0
    /**	function used to get the services which are related to the pricebook
     *	@param int $id - pricebook id
     *      @return array - return an array which will be returned from the function getPriceBookRelatedServices
     **/
    function get_pricebook_services($id, $cur_tab_id, $rel_tab_id, $actions = false)
    {
        $log = vglobal('log');
        $current_user = vglobal('current_user');
        $singlepane_view = vglobal('singlepane_view');
        $currentModule = vglobal('currentModule');
        $log->debug("Entering get_pricebook_services(" . $id . ") method ...");
        $this_module = $currentModule;
        $related_module = vtlib_getModuleNameById($rel_tab_id);
        require_once "modules/{$related_module}/{$related_module}.php";
        $other = new $related_module();
        vtlib_setup_modulevars($related_module, $other);
        $singular_modname = vtlib_toSingular($related_module);
        if ($singlepane_view == 'true') {
            $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
        } else {
            $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
        }
        $button = '';
        if ($actions) {
            if (is_string($actions)) {
                $actions = explode(',', strtoupper($actions));
            }
            if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
                $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='submit' name='button' onclick=\"this.form.action.value='AddServicesToPriceBook';this.form.module.value='{$related_module}';this.form.return_module.value='{$currentModule}';this.form.return_action.value='PriceBookDetailView'\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'>&nbsp;";
            }
        }
        $query = 'SELECT vtiger_service.serviceid, vtiger_service.servicename, vtiger_service.commissionrate,
					vtiger_service.qty_per_unit, vtiger_service.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
					vtiger_pricebookproductrel.listprice
			FROM vtiger_service
			INNER JOIN vtiger_pricebookproductrel on vtiger_service.serviceid = vtiger_pricebookproductrel.productid
			INNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_service.serviceid
			INNER JOIN vtiger_pricebook on vtiger_pricebook.pricebookid = vtiger_pricebookproductrel.pricebookid
			LEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid
			LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid ' . getNonAdminAccessControlQuery($related_module, $current_user) . '
			WHERE vtiger_pricebook.pricebookid = ' . $id . ' and vtiger_crmentity.deleted = 0';
        $this->retrieve_entity_info($id, $this_module);
        $return_value = $other->getPriceBookRelatedServices($query, $this, $returnset);
        if ($return_value == null) {
            $return_value = array();
        }
        $return_value['CUSTOM_BUTTON'] = $button;
        $log->debug("Exiting get_pricebook_services method ...");
        return $return_value;
    }