public function getAllHeaders($search_params = array())
 {
     $hinfo = new ITS4YouReports_List_Header();
     $hinfo->set("search_params", ITS4YouReports_List_Header::getSearchParamsArray($search_params));
     $return = $hinfo->getAllHeaderInfo();
     return $return;
 }
Exemplo n.º 2
0
 /**
  * Function to get the list view header
  * @return <Array> - List of Vtiger_Field_Model instances
  */
 public function getListViewHeaders()
 {
     require_once 'modules/ITS4YouReports/models/ITS4YouReportsListHeader.php';
     //ini_set("display_errors",1);error_reporting(63);
     $newLists = new ITS4YouReports_List_Header();
     $getAllHeaderInfo = $newLists->getAllHeaders($this->get("search_params"));
     return $getAllHeaderInfo;
 }
Exemplo n.º 3
0
 /** Function to get the Reports inside each modules
  *  This function accepts the folderid
  *  This Generates the Reports under each Reports module
  *  This Returns a HTML sring
  */
 function sgetRptsforFldr($rpt_fldr_id, $paramsList = false, $search_params = array())
 {
     $srptdetails = "";
     $adb = PearDatabase::getInstance();
     global $mod_strings;
     $returndata = array();
     if (!isset($this->current_user)) {
         global $current_user;
         $this->current_user = $current_user;
     }
     require_once 'include/utils/UserInfoUtil.php';
     /*
      $sql = "SELECT reports4youid, reports4youname, primarymodule, reporttype, its4you_reports4you.description,  folderid, foldername, owner, vtiger_tab.tablabel as tablabel, IF(its4you_reports4you_userstatus.sequence IS NOT NULL,its4you_reports4you_userstatus.sequence,1) AS sequence, IF(its4you_reports4you_scheduled_reports.reportid IS NOT NULL,1,0) AS scheduling
      FROM its4you_reports4you
      INNER JOIN its4you_reports4you_modules ON its4you_reports4you_modules.reportmodulesid = its4you_reports4you.reports4youid
      INNER JOIN its4you_reports4you_folder USING(folderid)
      INNER JOIN vtiger_tab ON vtiger_tab.tabid = its4you_reports4you_modules.primarymodule
      INNER JOIN its4you_reports4you_settings ON its4you_reports4you_settings.reportid = its4you_reports4you.reports4youid
      LEFT JOIN its4you_reports4you_userstatus ON its4you_reports4you.reports4youid = its4you_reports4you_userstatus.reportid
      LEFT JOIN its4you_reports4you_scheduled_reports ON its4you_reports4you.reports4youid = its4you_reports4you_scheduled_reports.reportid
      WHERE its4you_reports4you.deleted=0 ";
     */
     $sql = "SELECT DISTINCT reports4youid, reports4youname, primarymodule, reporttype, its4you_reports4you.description,  folderid, foldername, owner, vtiger_tab.tablabel as tablabel, IF(its4you_reports4you_userstatus.sequence IS NOT NULL,its4you_reports4you_userstatus.sequence,1) AS sequence, IF(its4you_reports4you_scheduled_reports.reportid IS NOT NULL,1,0) AS scheduling \n\t\t\t\tFROM its4you_reports4you \n\t\t\t\tLEFT JOIN its4you_reports4you_modules ON its4you_reports4you_modules.reportmodulesid = its4you_reports4you.reports4youid \n\t\t\t\tINNER JOIN its4you_reports4you_folder USING(folderid) \n\t\t\t\tLEFT JOIN vtiger_tab ON vtiger_tab.tabid = its4you_reports4you_modules.primarymodule \n                INNER JOIN its4you_reports4you_settings ON its4you_reports4you_settings.reportid = its4you_reports4you.reports4youid \n                LEFT JOIN its4you_reports4you_userstatus ON its4you_reports4you.reports4youid = its4you_reports4you_userstatus.reportid \n                LEFT JOIN its4you_reports4you_scheduled_reports ON its4you_reports4you.reports4youid = its4you_reports4you_scheduled_reports.reportid \n\t\t\t\tWHERE its4you_reports4you.deleted=0 ";
     $params = array();
     // If information is required only for specific report folder?
     if ($rpt_fldr_id !== false) {
         $sql .= " AND its4you_reports4you_folder.folderid=?";
         $params[] = $rpt_fldr_id;
     }
     // reportname -> reports4youname
     // reporttype -> reporttype
     // tablabel -> vtiger_tab.name
     // foldername -> foldername
     // owner -> its4you_reports4you_settings.owner
     // description -> description
     //ini_set("display_errors",1);error_reporting(63);
     if (!empty($search_params)) {
         $searchArray = ITS4YouReports_List_Header::getSearchParamsArray($search_params);
         foreach ($searchArray as $headerColumn => $searchValue) {
             $hinfo = new ITS4YouReports_List_Header($headerColumn);
             $search_sql_array[] = $hinfo->getHeaderColumnSql($headerColumn, $searchValue);
         }
         if (!empty($search_sql_array)) {
             $search_sql = implode(" AND ", $search_sql_array);
             $sql .= " AND {$search_sql} ";
         }
     }
     $user_privileges_path = 'user_privileges/user_privileges_' . $this->current_user->id . '.php';
     if (file_exists($user_privileges_path)) {
         require $user_privileges_path;
     }
     require_once 'include/utils/GetUserGroups.php';
     $userGroups = new GetUserGroups();
     $userGroups->getAllUserGroups($this->current_user->id);
     $user_groups = $userGroups->user_groups;
     if (!empty($user_groups) && $is_admin == false) {
         $user_group_query = " (shareid IN (" . generateQuestionMarks($user_groups) . ") AND setype='groups') OR";
         array_push($params, $user_groups);
     }
     // BF Roles FIX S
     if (isset($this->current_user->column_fields['roleid']) && $is_admin == false) {
         $user_group_query .= " (reports4youid IN (SELECT reports4youid FROM its4you_reports4you_sharing WHERE shareid = ? ) AND setype='roles') OR";
         array_push($params, $this->current_user->column_fields['roleid']);
     }
     // BF Roles FIX E
     $non_admin_query = " its4you_reports4you.reports4youid IN (SELECT reports4youid from its4you_reports4you_sharing WHERE {$user_group_query} (shareid=? AND setype='users'))";
     if ($is_admin == false) {
         $sql .= " and ( (" . $non_admin_query . ") or its4you_reports4you_settings.sharingtype='Public' or its4you_reports4you_settings.owner = ? or its4you_reports4you_settings.owner in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '" . $current_user_parent_role_seq . "::%'))";
         array_push($params, $this->current_user->id);
         array_push($params, $this->current_user->id);
     }
     if ($paramsList) {
         $startIndex = $paramsList['startIndex'];
         $pageLimit = $paramsList['pageLimit'];
         $orderBy = $paramsList['orderBy'];
         $sortBy = $paramsList['sortBy'];
         if ($orderBy) {
             $sql .= " ORDER BY {$orderBy} {$sortBy}";
         } else {
             $sql .= " ORDER BY its4you_reports4you.reports4youid DESC ";
         }
         $sql .= " LIMIT {$startIndex}, {$pageLimit}";
     }
     $query = $adb->pquery("select userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '" . $current_user_parent_role_seq . "::%'", array());
     $subordinate_users = array();
     for ($i = 0; $i < $adb->num_rows($query); $i++) {
         $subordinate_users[] = $adb->query_result($query, $i, 'userid');
     }
     //ITS4YouReports::sshow("<br/><br/><br/><br/><br/>");
     //$adb->setDebug(true);
     $result = $adb->pquery($sql, $params);
     //$adb->setDebug(false);
     $report = $adb->fetch_array($result);
     if (count($report) > 0) {
         do {
             $report_details = array();
             // $report_details ['customizable'] = $report["customizable"];
             $report_details['reportid'] = $report["reports4youid"];
             $report_details['primarymodule'] = $report["primarymodule"];
             $report_details['tablabel'] = $report["tablabel"];
             $report_details['owner'] = getUserFullName($report["owner"]);
             $report_details['foldername'] = $report["foldername"];
             // $report_details ['state'] = $report["state"];
             $reporttype = $report["reporttype"];
             $report_details['reporttype'] = vtranslate($reporttype, "ITS4YouReports");
             $report_details['state'] = "SAVED";
             $report_details['description'] = $report["description"];
             $reports4youname = $report["reports4youname"];
             if ($report["scheduling"] == "1") {
                 $reports4youname .= '&nbsp;<image src="modules/ITS4YouReports/img/Cron.png" style="vertical-align: middle;height:15px;" />';
             }
             $report_details['reportname'] = $reports4youname;
             $report_details['sharingtype'] = $report["sharingtype"];
             if ($reporttype == "custom_report") {
                 if ($is_admin == true) {
                     $report_details['editable'] = 'false';
                 } else {
                     $report_details['editable'] = 'false';
                 }
             } elseif ($is_admin == true || in_array($this->current_user->id, $subordinate_users) || $report["owner"] == $this->current_user->id) {
                 $report_details['editable'] = 'true';
             } else {
                 $report_details['editable'] = 'false';
             }
             $primarymodule = vtlib_getModuleNameById($report["primarymodule"]);
             if ($reporttype == "custom_report" || isPermitted($primarymodule, 'index') == "yes") {
                 if ($rpt_fldr_id !== false) {
                     $returndata[$report["folderid"]][] = $report_details;
                 } else {
                     $returndata[][] = $report_details;
                 }
             }
         } while ($report = $adb->fetch_array($result));
     }
     //echo "<pre><br/><br/><br/><br/><br/><br/>";print_r($returndata);echo "</pre>";
     if ($rpt_fldr_id !== false) {
         $returndata = $returndata[$rpt_fldr_id];
     }
     return $returndata;
 }