Beispiel #1
0
 /**
  * Create query to export the records.
  */
 function create_export_query($where)
 {
     global $current_user;
     $thismodule = $_REQUEST['module'];
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery($thismodule, "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list}, vtiger_users.user_name AS user_name \n\t\t\t\tFROM vtiger_crmentity INNER JOIN {$this->table_name} ON vtiger_crmentity.crmid={$this->table_name}.{$this->table_index}";
     if (!empty($this->customFieldTable)) {
         $query .= " INNER JOIN " . $this->customFieldTable[0] . " ON " . $this->customFieldTable[0] . '.' . $this->customFieldTable[1] . " = {$this->table_name}.{$this->table_index}";
     }
     $query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
     $query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
     $linkedModulesQuery = $this->db->pquery("SELECT distinct fieldname, columnname, relmodule FROM vtiger_field" . " INNER JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid" . " WHERE uitype='10' AND vtiger_fieldmodulerel.module=?", array($thismodule));
     $linkedFieldsCount = $this->db->num_rows($linkedModulesQuery);
     $rel_mods[$this->table_name] = 1;
     for ($i = 0; $i < $linkedFieldsCount; $i++) {
         $related_module = $this->db->query_result($linkedModulesQuery, $i, 'relmodule');
         $fieldname = $this->db->query_result($linkedModulesQuery, $i, 'fieldname');
         $columnname = $this->db->query_result($linkedModulesQuery, $i, 'columnname');
         $other = CRMEntity::getInstance($related_module);
         vtlib_setup_modulevars($related_module, $other);
         if ($rel_mods[$other->table_name]) {
             $rel_mods[$other->table_name] = $rel_mods[$other->table_name] + 1;
             $alias = $other->table_name . $rel_mods[$other->table_name];
             $query_append = "as {$alias}";
         } else {
             $alias = $other->table_name;
             $query_append = '';
             $rel_mods[$other->table_name] = 1;
         }
         $query .= " LEFT JOIN {$other->table_name} {$query_append} ON {$alias}.{$other->table_index} = {$this->table_name}.{$columnname}";
     }
     $query .= $this->getNonAdminAccessControlQuery($thismodule, $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != '') {
         $query .= " WHERE ({$where}) AND {$where_auto}";
     } else {
         $query .= " WHERE {$where_auto}";
     }
     return $query;
 }
Beispiel #2
0
 /** Function to export the lead records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Leads Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Leads", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT {$fields_list},case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name\n\t\t\t\tFROM " . $this->entity_table . "\n\t\t\t\tINNER JOIN vtiger_leaddetails ON vtiger_crmentity.crmid=vtiger_leaddetails.leadid\n\t\t\t\tLEFT JOIN vtiger_leadsubdetails ON vtiger_leaddetails.leadid = vtiger_leadsubdetails.leadsubscriptionid\n\t\t\t\tLEFT JOIN vtiger_leadaddress ON vtiger_leaddetails.leadid=vtiger_leadaddress.leadaddressid\n\t\t\t\tLEFT JOIN vtiger_leadscf ON vtiger_leadscf.leadid=vtiger_leaddetails.leadid\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
     $query .= $this->getNonAdminAccessControlQuery('Leads', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0 AND vtiger_leaddetails.converted =0";
     if ($where != "") {
         $query .= " where ({$where}) AND " . $where_auto;
     } else {
         $query .= " where " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #3
0
 /** Function to export the account records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Accounts Query.
  */
 function create_export_query($where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Accounts", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list},case 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 " . $this->entity_table . "\n\t\t\t\tINNER JOIN vtiger_account\n\t\t\t\t\tON vtiger_account.accountid = vtiger_crmentity.crmid\n\t\t\t\tLEFT JOIN vtiger_accountbillads\n\t\t\t\t\tON vtiger_accountbillads.accountaddressid = vtiger_account.accountid\n\t\t\t\tLEFT JOIN vtiger_accountshipads\n\t\t\t\t\tON vtiger_accountshipads.accountaddressid = vtiger_account.accountid\n\t\t\t\tLEFT JOIN vtiger_accountscf\n\t\t\t\t\tON vtiger_accountscf.accountid = vtiger_account.accountid\n\t                        LEFT JOIN vtiger_groups\n                        \t        ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid and vtiger_users.status = 'Active'\n\t\t\t\tLEFT JOIN vtiger_account vtiger_account2\n\t\t\t\t\tON vtiger_account2.accountid = vtiger_account.parentid\n\t\t\t\t";
     //vtiger_account2 is added to get the Member of account
     $query .= $this->getNonAdminAccessControlQuery('Accounts', $current_user);
     $where_auto = " vtiger_crmentity.deleted = 0 ";
     if ($where != "") {
         $query .= " WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= " WHERE " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #4
0
 /**	function used to get the export query for product
  *	@param reference $where - reference of the where variable which will be added with the query
  *	@return string $query - return the query which will give the list of products to export
  */
 function create_export_query($where)
 {
     global $log;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Products", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list} FROM " . $this->table_name . "\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_products.productid \n\t\t\tLEFT JOIN vtiger_productcf\n\t\t\t\tON vtiger_products.productid = vtiger_productcf.productid\n\t\t\tINNER JOIN vtiger_users\n\t\t\t\tON vtiger_users.id=vtiger_products.handler \n\n\t\t\tLEFT JOIN vtiger_vendor\n\t\t\t\tON vtiger_vendor.vendorid = vtiger_products.vendor_id\n\t\t\tWHERE vtiger_crmentity.deleted = 0 and vtiger_users.status = 'Active'";
     if ($where != "") {
         $query .= " AND ({$where}) ";
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #5
0
 /**
  * Create query to export the records.
  */
 function create_export_query($where)
 {
     global $current_user;
     $thismodule = $_REQUEST['module'];
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery($thismodule, "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list}, vtiger_users.user_name AS user_name \n\t\t\t\t\tFROM vtiger_crmentity INNER JOIN {$this->table_name} ON vtiger_crmentity.crmid={$this->table_name}.{$this->table_index}";
     if (!empty($this->customFieldTable)) {
         $query .= " INNER JOIN " . $this->customFieldTable[0] . " ON " . $this->customFieldTable[0] . '.' . $this->customFieldTable[1] . " = {$this->table_name}.{$this->table_index}";
     }
     $query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
     $query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
     $linkedModulesQuery = $this->db->pquery("SELECT distinct fieldname, columnname, relmodule FROM vtiger_field" . " INNER JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid" . " WHERE uitype='10' AND vtiger_fieldmodulerel.module=?", array($thismodule));
     $linkedFieldsCount = $this->db->num_rows($linkedModulesQuery);
     for ($i = 0; $i < $linkedFieldsCount; $i++) {
         $related_module = $this->db->query_result($linkedModulesQuery, $i, 'relmodule');
         $fieldname = $this->db->query_result($linkedModulesQuery, $i, 'fieldname');
         $columnname = $this->db->query_result($linkedModulesQuery, $i, 'columnname');
         $other = CRMEntity::getInstance($related_module);
         vtlib_setup_modulevars($related_module, $other);
         $query .= " LEFT JOIN {$other->table_name} ON {$other->table_name}.{$other->table_index} = {$this->table_name}.{$columnname}";
     }
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != '') {
         $query .= " WHERE ({$where}) AND {$where_auto}";
     } else {
         $query .= " WHERE {$where_auto}";
     }
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     // Security Check for Field Access
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[7] == 3) {
         //Added security check to get the permitted records only
         $query = $query . " " . getListViewSecurityParameter($thismodule);
     }
     return $query;
 }
Beispiel #6
0
 /**
  * Create query to export the records.
  */
 function create_export_query($where)
 {
     global $current_user;
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery('OSSMailView', "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list}, vtiger_users.user_name AS user_name\n\t\t\t\t\tFROM vtiger_crmentity INNER JOIN {$this->table_name} ON vtiger_crmentity.crmid={$this->table_name}.{$this->table_index}";
     if (!empty($this->customFieldTable)) {
         $query .= " INNER JOIN " . $this->customFieldTable[0] . " ON " . $this->customFieldTable[0] . '.' . $this->customFieldTable[1] . " = {$this->table_name}.{$this->table_index}";
     }
     $query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
     $query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != '') {
         $query .= " WHERE ({$where}) AND {$where_auto}";
     } else {
         $query .= " WHERE {$where_auto}";
     }
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     // Security Check for Field Access
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[getTabid('OSSMailView')] == 3) {
         //Added security check to get the permitted records only
         $query = $query . " " . getListViewSecurityParameter($thismodule);
     }
     return $query;
 }
Beispiel #7
0
 /**
  * Create query to export the records.
  */
 function create_export_query($where)
 {
     global $current_user;
     $thismodule = $_REQUEST['module'];
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery($thismodule, "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list}\n\t\t\t\t\tFROM vtiger_crmentity INNER JOIN {$this->table_name} ON vtiger_crmentity.crmid={$this->table_name}.{$this->table_index}";
     if (!empty($this->customFieldTable)) {
         $query .= " INNER JOIN " . $this->customFieldTable[0] . " ON " . $this->customFieldTable[0] . '.' . $this->customFieldTable[1] . " = {$this->table_name}.{$this->table_index}";
     }
     $query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
     $query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id AND vtiger_users.status='Active'";
     $query .= $this->getNonAdminAccessControlQuery('Services', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != '') {
         $query .= " WHERE ({$where}) AND {$where_auto}";
     } else {
         $query .= " WHERE {$where_auto}";
     }
     return $query;
 }
Beispiel #8
0
 /** Function to export the ticket records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Tickets Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("HelpDesk", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     //Ticket changes--5198
     $fields_list = str_replace(",vtiger_ticketcomments.comments as 'Add Comment'", ' ', $fields_list);
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT {$fields_list},case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name\n\t\t\tFROM " . $this->entity_table . "\n\t\t\tINNER JOIN vtiger_troubletickets ON vtiger_troubletickets.ticketid =vtiger_crmentity.crmid\n\t\t\tLEFT JOIN vtiger_crmentity vtiger_crmentityRelatedTo ON vtiger_crmentityRelatedTo.crmid = vtiger_troubletickets.parent_id\n\t\t\tLEFT JOIN vtiger_account ON vtiger_account.accountid = vtiger_troubletickets.parent_id\n\t\t\tLEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid = vtiger_troubletickets.parent_id\n\t\t\tLEFT JOIN vtiger_ticketcf ON vtiger_ticketcf.ticketid=vtiger_troubletickets.ticketid\n\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid and vtiger_users.status='Active'\n\t\t\tLEFT JOIN vtiger_seattachmentsrel ON vtiger_seattachmentsrel.crmid =vtiger_troubletickets.ticketid\n\t\t\tLEFT JOIN vtiger_attachments ON vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid\n\t\t\tLEFT JOIN vtiger_products ON vtiger_products.productid=vtiger_troubletickets.product_id";
     $query .= getNonAdminAccessControlQuery('HelpDesk', $current_user);
     $where_auto = " vtiger_crmentity.deleted = 0 ";
     if ($where != "") {
         $query .= " WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= " WHERE " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #9
0
 /**	function used to get the export query for product
  *	@param reference $where - reference of the where variable which will be added with the query
  *	@return string $query - return the query which will give the list of products to export
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Products", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list} FROM " . $this->table_name . "\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_products.productid\n\t\t\tLEFT JOIN vtiger_productcf\n\t\t\t\tON vtiger_products.productid = vtiger_productcf.productid\n\t\t\tLEFT JOIN vtiger_vendor\n\t\t\t\tON vtiger_vendor.vendorid = vtiger_products.vendor_id";
     $query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
     $query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id AND vtiger_users.status='Active'";
     $query .= $this->getNonAdminAccessControlQuery('Products', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != '') {
         $query .= " WHERE ({$where}) AND {$where_auto}";
     } else {
         $query .= " WHERE {$where_auto}";
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #10
0
 /** Function to export the account records in CSV Format
  * @param reference variable - order by is passed when the query is executed
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Accounts Query.
  */
 function create_export_query(&$order_by, &$where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $order_by . "," . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Accounts", "detail_view");
     global $mod_strings;
     global $current_language;
     if (empty($mod_strings)) {
         $mod_strings = return_module_language($current_language, "Accounts");
     }
     $fields_list = getFieldsListFromQuery($sql, $mod_strings);
     $query = "SELECT {$fields_list} FROM ec_account\n\t\t\t\tLEFT JOIN ec_users\n\t\t\t\t\tON ec_account.smownerid = ec_users.id\n\t\t\t\tLEFT JOIN ec_users as ucreator\n\t\t\t\t\tON ec_account.smcreatorid = ucreator.id ";
     $where_auto = " ec_account.deleted = 0 ";
     if ($where != "") {
         $query .= "WHERE ({$where})  AND " . $where_auto;
     } else {
         $query .= "WHERE " . $where_auto;
     }
     $query .= " and ucreator.id=" . $_SESSION['authenticated_user_id'] . " ";
     if (!empty($order_by)) {
         $query .= " ORDER BY {$order_by}";
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #11
0
 /** Function to export the notes in CSV Format
  * @param reference variable - order by is passed when the query is executed
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Notes Query.
  */
 function create_export_query(&$order_by, &$where)
 {
     global $log;
     $log->debug("Entering create_export_query(" . $order_by . "," . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Notes", "detail_view");
     global $mod_strings;
     global $current_language;
     if (empty($mod_strings)) {
         $mod_strings = return_module_language($current_language, "Notes");
     }
     $fields_list = getFieldsListFromQuery($sql, $mod_strings);
     $query = "SELECT {$fields_list} FROM ec_notes\n\t\t\t\tLEFT JOIN ec_contactdetails\n\t\t\t\t\tON ec_notes.contact_id=ec_contactdetails.contactid\n\t\t\t\tLEFT JOIN ec_account\n\t\t\t\t\tON ec_notes.accountid=ec_account.accountid\n\t\t\t\tLEFT JOIN ec_users\n\t\t\t\t\tON ec_notes.smownerid = ec_users.id\n\t\t\t\tLEFT JOIN ec_users as ucreator\n\t\t\t\t\tON ec_notes.smcreatorid = ucreator.id\n\t\t\t\tWHERE ec_notes.deleted=0 " . $where;
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #12
0
 /** Function to export the lead records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export OSSCosts Query.
  */
 function create_export_query($where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("OSSCosts", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $fields_list .= getInventoryFieldsForExport($this->table_name);
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT {$fields_list} FROM " . $this->entity_table . "\n\t\t\t\tINNER JOIN vtiger_osscosts ON vtiger_osscosts.osscostsid = vtiger_crmentity.crmid\n\t\t\t\tLEFT JOIN vtiger_osscostscf ON vtiger_osscostscf.osscostsid = vtiger_osscosts.osscostsid\n\t\t\t\tLEFT JOIN vtiger_inventoryproductrel ON vtiger_inventoryproductrel.id = vtiger_osscosts.osscostsid\n\t\t\t\tLEFT JOIN vtiger_products ON vtiger_products.productid = vtiger_inventoryproductrel.productid\n\t\t\t\tLEFT JOIN vtiger_service ON vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\t\tLEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid = vtiger_osscosts.relategid\n\t\t\t\tLEFT JOIN vtiger_osscosts ON vtiger_osscosts.osscostsid = vtiger_osscosts.relategid\n\t\t\t\tLEFT JOIN vtiger_vendor ON vtiger_vendor.vendorid = vtiger_osscosts.relategid\n\t\t\t\tLEFT JOIN vtiger_potential ON vtiger_potential.potentialid = vtiger_osscosts.potentialid\n\t\t\t\tLEFT JOIN vtiger_project ON vtiger_project.projectid = vtiger_osscosts.projectid\n\t\t\t\tLEFT JOIN vtiger_troubletickets ON vtiger_troubletickets.ticketid = vtiger_osscosts.ticketid\n\t\t\t\tLEFT JOIN vtiger_currency_info ON vtiger_currency_info.id = vtiger_osscosts.currency_id\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
     $query .= $this->getNonAdminAccessControlQuery('OSSCosts', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != "") {
         $query .= " where ({$where}) AND " . $where_auto;
     } else {
         $query .= " where " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
 /** Function to export the contact records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Contacts Query.
  */
 function create_export_query($where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Contacts", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT vtiger_contactdetails.salutation as 'Salutation',{$fields_list},case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name \n                                FROM vtiger_contactdetails\n                                inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid\n                                LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id and vtiger_users.status='Active' \n                                LEFT JOIN vtiger_account on vtiger_contactdetails.accountid=vtiger_account.accountid\n\t\t\t\tleft join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid\n\t\t\t\tleft join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid=vtiger_contactdetails.contactid\n\t\t\t        left join vtiger_contactscf on vtiger_contactscf.contactid=vtiger_contactdetails.contactid\n\t\t\t        left join vtiger_customerdetails on vtiger_customerdetails.customerid=vtiger_contactdetails.contactid\n\t                        LEFT JOIN vtiger_groups\n                        \t        ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_contactdetails vtiger_contactdetails2\n\t\t\t\t\tON vtiger_contactdetails2.contactid = vtiger_contactdetails.reportsto";
     $where_auto = " vtiger_crmentity.deleted = 0 ";
     if ($where != "") {
         $query .= "  WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= "  WHERE " . $where_auto;
     }
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     //we should add security check when the user has Private Access
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[4] == 3) {
         //Added security check to get the permitted records only
         $query = $query . " " . getListViewSecurityParameter("Contacts");
     }
     $log->info("Export Query Constructed Successfully");
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #14
0
	/**
	 * Create query to export the records.
	 */
	function create_export_query($where)
	{
		global $current_user;

		include("include/utils/ExportUtils.php");

		//To get the Permitted fields query and the permitted fields list
		$sql = getPermittedFieldsQuery('Services', "detail_view");

		$fields_list = getFieldsListFromQuery($sql);

		$query = "SELECT $fields_list
					FROM vtiger_crmentity INNER JOIN $this->table_name ON vtiger_crmentity.crmid=$this->table_name.$this->table_index";

		if(!empty($this->customFieldTable)) {
			$query .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
				      " = $this->table_name.$this->table_index";
		}

		$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
		$query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id AND vtiger_users.status='Active'";
		$query .= $this->getNonAdminAccessControlQuery('Services',$current_user);
		$where_auto = " vtiger_crmentity.deleted=0";

		if($where != '') $query .= " WHERE ($where) AND $where_auto";
		else $query .= " WHERE $where_auto";

		return $query;
	}
Beispiel #15
0
 /** Function to export the vendors in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Vendors Query.
  */
 function create_export_query($where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Vendors", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list} FROM " . $this->entity_table . "\n                                INNER JOIN vtiger_vendor\n                                        ON vtiger_crmentity.crmid = vtiger_vendor.vendorid\n                                LEFT JOIN vtiger_vendorcf\n                                        ON vtiger_vendorcf.vendorid=vtiger_vendor.vendorid\n                                LEFT JOIN vtiger_seattachmentsrel\n                                        ON vtiger_vendor.vendorid=vtiger_seattachmentsrel.crmid\n                                LEFT JOIN vtiger_attachments\n                                ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n                                LEFT JOIN vtiger_users\n                                        ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'\n                                ";
     $where_auto = " vtiger_crmentity.deleted = 0 ";
     if ($where != "") {
         $query .= "  WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= "  WHERE " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #16
0
	/** Function to export the account records in CSV Format
	 * @param reference variable - where condition is passed when the query is executed
	 * Returns Export Accounts Query.
	 */
	function create_export_query($where)
	{
		$log = vglobal('log');
		$current_user = vglobal('current_user');
		$log->debug("Entering create_export_query(" . $where . ") method ...");

		include("include/utils/ExportUtils.php");

		//To get the Permitted fields query and the permitted fields list
		$sql = getPermittedFieldsQuery("Accounts", "detail_view");
		$fields_list = getFieldsListFromQuery($sql);

		$query = "SELECT $fields_list,case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
	       			FROM " . $this->entity_table . "
				INNER JOIN vtiger_account
					ON vtiger_account.accountid = vtiger_crmentity.crmid
				LEFT JOIN vtiger_accountaddress
					ON vtiger_accountaddress.accountaddressid = vtiger_account.accountid
				LEFT JOIN vtiger_accountscf
					ON vtiger_accountscf.accountid = vtiger_account.accountid
	                        LEFT JOIN vtiger_groups
                        	        ON vtiger_groups.groupid = vtiger_crmentity.smownerid
				LEFT JOIN vtiger_users
					ON vtiger_users.id = vtiger_crmentity.smownerid and vtiger_users.status = 'Active'
				LEFT JOIN vtiger_account vtiger_account2
					ON vtiger_account2.accountid = vtiger_account.parentid
				"; //vtiger_account2 is added to get the Member of account

		$query .= $this->getNonAdminAccessControlQuery('Accounts', $current_user);
		$where_auto = " vtiger_crmentity.deleted = 0 ";

		if ($where != "")
			$query .= " WHERE ($where) AND " . $where_auto;
		else
			$query .= " WHERE " . $where_auto;

		$log->debug("Exiting create_export_query method ...");
		return $query;
	}
Beispiel #17
0
 /**	function used to get the export query for product
  *	@param reference &$order_by - reference of the order by variable which will be added with the query
  *	@param reference &$where - reference of the where variable which will be added with the query
  *	@return string $query - return the query which will give the list of products to export
  */
 function create_export_query(&$order_by, &$where)
 {
     global $log;
     $log->debug("Entering create_export_query(" . $order_by . "," . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Products", "detail_view");
     global $mod_strings;
     global $current_language;
     if (empty($mod_strings)) {
         $mod_strings = return_module_language($current_language, "Products");
     }
     $fields_list = getFieldsListFromQuery($sql, $mod_strings);
     $query = "SELECT {$fields_list} FROM " . $this->table_name . "\n\t\t\tLEFT JOIN ec_seproductsrel\n\t\t\t\tON ec_seproductsrel.productid = ec_products.productid\n\n\t\t\tLEFT JOIN ec_users as ucreator\n\t\t\t\t\tON ec_products.smcreatorid = ucreator.id\n\t\t\tLEFT JOIN ec_vendor\n\t\t\t\tON ec_vendor.vendorid = ec_products.vendor_id\n\t\t\tWHERE ec_products.deleted = 0 ";
     //ProductRelatedToLead, Account and Potential tables are added to get the Related to field
     if ($where != "") {
         $query .= " AND ({$where}) ";
     }
     if (!empty($order_by)) {
         $query .= " ORDER BY {$order_by}";
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #18
0
 /** Function to export the notes in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Documents Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Documents", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT {$fields_list}, case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name" . " FROM vtiger_notes\n\t\t\t\tinner join vtiger_crmentity\n\t\t\t\t\ton vtiger_crmentity.crmid=vtiger_notes.notesid\n\t\t\t\tLEFT JOIN `vtiger_trees_templates_data` on vtiger_notes.folderid=`vtiger_trees_templates_data`.tree\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id " . " LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid ";
     $query .= getNonAdminAccessControlQuery('Documents', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != "") {
         $query .= "  WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= "  WHERE " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #19
0
 /** Function to export the notes in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Documents Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Documents", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list}, foldername, filename,\n\t\t\t\t\tconcat(path,vtiger_attachments.attachmentsid,'_',filename) as storagename,\n\t\t\t\t\tconcat(account_no,' ',accountname) as account, concat(contact_no,' ',firstname,' ',lastname) as contact\n\t\t\t\tFROM vtiger_notes\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_notes.notesid\n\t\t\t\tleft join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_notes.notesid\n\t\t\t\tleft join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid\n\t\t\t\tLEFT JOIN vtiger_attachmentsfolder on vtiger_notes.folderid=vtiger_attachmentsfolder.folderid\n\t\t\t\tLEFT JOIN vtiger_senotesrel ON vtiger_senotesrel.notesid=vtiger_notes.notesid\n\t\t\t\tLEFT JOIN vtiger_account ON vtiger_account.accountid=vtiger_senotesrel.crmid\n\t\t\t\tLEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid=vtiger_senotesrel.crmid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid ";
     $query .= getNonAdminAccessControlQuery('Documents', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != "") {
         $query .= " WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= " WHERE " . $where_auto;
     }
     $query .= ' group by vtiger_notes.notesid';
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #20
0
 /** Function to export the contact records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Contacts Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Contacts", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT vtiger_contactdetails.salutation as 'Salutation',{$fields_list},case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name\n\t\t\tFROM vtiger_contactdetails\n\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid\n\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id and vtiger_users.status='Active'\n\t\t\tLEFT JOIN vtiger_account on vtiger_contactdetails.accountid=vtiger_account.accountid\n\t\t\tleft join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid\n\t\t\tleft join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid=vtiger_contactdetails.contactid\n\t\t\tleft join vtiger_contactscf on vtiger_contactscf.contactid=vtiger_contactdetails.contactid\n\t\t\tleft join vtiger_customerdetails on vtiger_customerdetails.customerid=vtiger_contactdetails.contactid\n\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_contactdetails vtiger_contactdetails2 ON vtiger_contactdetails2.contactid = vtiger_contactdetails.reportsto";
     $query .= getNonAdminAccessControlQuery('Contacts', $current_user);
     $where_auto = " vtiger_crmentity.deleted = 0 ";
     if ($where != "") {
         $query .= " WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= " WHERE " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #21
0
    /**
     * Create query to export the records.
     */
    function create_export_query($where)
    {
		global $current_user;

		include("include/utils/ExportUtils.php");

		//To get the Permitted fields query and the permitted fields list
		$sql = getPermittedFieldsQuery('ProjectTask', "detail_view");

		$fields_list = getFieldsListFromQuery($sql);

		$query = "SELECT $fields_list, vtiger_users.user_name AS user_name
					FROM vtiger_crmentity INNER JOIN $this->table_name ON vtiger_crmentity.crmid=$this->table_name.$this->table_index";

		if(!empty($this->customFieldTable)) {
			$query .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
				      " = $this->table_name.$this->table_index";
		}

		$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
		$query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";

		$linkedModulesQuery = $this->db->pquery("SELECT distinct fieldname, columnname, relmodule FROM vtiger_field" .
				" INNER JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid" .
				" WHERE uitype='10' AND vtiger_fieldmodulerel.module=?", array($thismodule));
		$linkedFieldsCount = $this->db->num_rows($linkedModulesQuery);

		for($i=0; $i<$linkedFieldsCount; $i++) {
			$related_module = $this->db->query_result($linkedModulesQuery, $i, 'relmodule');
			$fieldname = $this->db->query_result($linkedModulesQuery, $i, 'fieldname');
			$columnname = $this->db->query_result($linkedModulesQuery, $i, 'columnname');

			$other = CRMEntity::getInstance($related_module);
			vtlib_setup_modulevars($related_module, $other);

			$query .= " LEFT JOIN $other->table_name ON $other->table_name.$other->table_index = $this->table_name.$columnname";
		}

		$query .= $this->getNonAdminAccessControlQuery($thismodule,$current_user);
		$where_auto = " vtiger_crmentity.deleted=0";

		if($where != '') $query .= " WHERE ($where) AND $where_auto";
		else $query .= " WHERE $where_auto";

		return $query;
    }
Beispiel #22
0
 /** Function to export the Opportunities records in CSV Format
  * @param reference variable - order by is passed when the query is executed
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Potentials Query.
  */
 function create_export_query($where)
 {
     $log = vglobal('log');
     $current_user = vglobal('current_user');
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Potentials", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT {$fields_list},case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name\n\t\t\t\tFROM vtiger_potential\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id\n\t\t\t\tLEFT JOIN vtiger_account on vtiger_potential.related_to=vtiger_account.accountid\n\t\t\t\tLEFT JOIN vtiger_potentialscf on vtiger_potentialscf.potentialid=vtiger_potential.potentialid\n                LEFT JOIN vtiger_groups\n        \t        ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_campaign\n\t\t\t\t\tON vtiger_campaign.campaignid = vtiger_potential.campaignid";
     $query .= $this->getNonAdminAccessControlQuery('Potentials', $current_user);
     $where_auto = "  vtiger_crmentity.deleted = 0 ";
     if ($where != "") {
         $query .= "  WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= "  WHERE " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
 /** Function to export the account records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Accounts Query.
  */
 function create_export_query($where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Accounts", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list},case 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 " . $this->entity_table . "\n\t\t\t\tINNER JOIN vtiger_account\n\t\t\t\t\tON vtiger_account.accountid = vtiger_crmentity.crmid\n\t\t\t\tLEFT JOIN vtiger_accountbillads\n\t\t\t\t\tON vtiger_accountbillads.accountaddressid = vtiger_account.accountid\n\t\t\t\tLEFT JOIN vtiger_accountshipads\n\t\t\t\t\tON vtiger_accountshipads.accountaddressid = vtiger_account.accountid\n\t\t\t\tLEFT JOIN vtiger_accountscf\n\t\t\t\t\tON vtiger_accountscf.accountid = vtiger_account.accountid\n\t                        LEFT JOIN vtiger_groups\n                        \t        ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid and vtiger_users.status = 'Active'\n\t\t\t\tLEFT JOIN vtiger_account vtiger_account2 \n\t\t\t\t\tON vtiger_account2.accountid = vtiger_account.parentid\n\t\t\t\t";
     //vtiger_account2 is added to get the Member of account
     $where_auto = " vtiger_crmentity.deleted = 0 ";
     if ($where != "") {
         $query .= " WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= " WHERE " . $where_auto;
     }
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     //we should add security check when the user has Private Access
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3) {
         //Added security check to get the permitted records only
         $query = $query . " " . getListViewSecurityParameter("Accounts");
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #24
0
 /**
  * Returns a list of the Emails to be exported
  */
 function create_export_query(&$order_by, &$where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $order_by . "," . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Emails", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list} FROM vtiger_activity \n\t\t\tINNER JOIN vtiger_crmentity \n\t\t\t\tON vtiger_crmentity.crmid=vtiger_activity.activityid \n\t\t\tLEFT JOIN vtiger_users\n\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_seactivityrel\n\t\t\t\tON vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_contactdetails\n\t\t\t\tON vtiger_contactdetails.contactid = vtiger_seactivityrel.crmid\n\t\t\tLEFT JOIN vtiger_cntactivityrel\n\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tAND vtiger_cntactivityrel.contactid = vtiger_cntactivityrel.contactid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_salesmanactivityrel\n\t\t\t\tON vtiger_salesmanactivityrel.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_emaildetails\n\t\t\t\tON vtiger_emaildetails.emailid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_seattachmentsrel \n\t\t\t\tON vtiger_activity.activityid=vtiger_seattachmentsrel.crmid \n\t\t\tLEFT JOIN vtiger_attachments \n\t\t\t\tON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid";
     $query .= getNonAdminAccessControlQuery('Emails', $current_user);
     $query .= "WHERE vtiger_activity.activitytype='Emails' AND vtiger_crmentity.deleted=0 ";
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
 /** Function to export the notes in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Documents Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Documents", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list}, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name" . " FROM vtiger_notes\n\t\t\t\tinner join vtiger_crmentity \n\t\t\t\t\ton vtiger_crmentity.crmid=vtiger_notes.notesid \n\t\t\t\tLEFT JOIN vtiger_attachmentsfolder on vtiger_notes.folderid=vtiger_attachmentsfolder.folderid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id " . " LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid ";
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != "") {
         $query .= "  WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= "  WHERE " . $where_auto;
     }
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     //we should add security check when the user has Private Access
     $tabid = getTabid("Documents");
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tabid] == 3) {
         //Added security check to get the permitted records only
         $query = $query . " " . getListViewSecurityParameter("Documents");
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #26
0
 /** Function to export the lead records in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Invoice Query.
  */
 function create_export_query($where)
 {
     $log = vglobal('log');
     $current_user = vglobal('current_user');
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Invoice", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $fields_list .= getInventoryFieldsForExport($this->table_name);
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT {$fields_list} FROM " . $this->entity_table . "\n\t\t\t\tINNER JOIN vtiger_invoice ON vtiger_invoice.invoiceid = vtiger_crmentity.crmid\n\t\t\t\tLEFT JOIN vtiger_invoicecf ON vtiger_invoicecf.invoiceid = vtiger_invoice.invoiceid\n\t\t\t\tLEFT JOIN vtiger_salesorder ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid\n\t\t\t\tLEFT JOIN vtiger_invoiceaddress ON vtiger_invoiceaddress.invoiceaddressid = vtiger_invoice.invoiceid\n\t\t\t\tLEFT JOIN vtiger_inventoryproductrel ON vtiger_inventoryproductrel.id = vtiger_invoice.invoiceid\n\t\t\t\tLEFT JOIN vtiger_products ON vtiger_products.productid = vtiger_inventoryproductrel.productid\n\t\t\t\tLEFT JOIN vtiger_service ON vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\t\tLEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid = vtiger_invoice.contactid\n\t\t\t\tLEFT JOIN vtiger_account ON vtiger_account.accountid = vtiger_invoice.accountid\n\t\t\t\tLEFT JOIN vtiger_currency_info ON vtiger_currency_info.id = vtiger_invoice.currency_id\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
     $query .= $this->getNonAdminAccessControlQuery('Invoice', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != "") {
         $query .= " where ({$where}) AND " . $where_auto;
     } else {
         $query .= " where " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
Beispiel #27
0
 /**
  * Returns a list of the Emails to be exported
  */
 function create_export_query(&$order_by, &$where)
 {
     global $log;
     global $current_user;
     $log->debug("Entering create_export_query(" . $order_by . "," . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Emails", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list} FROM vtiger_activity \n\t\t\tINNER JOIN vtiger_crmentity \n\t\t\t\tON vtiger_crmentity.crmid=vtiger_activity.activityid \n\t\t\tLEFT JOIN vtiger_users\n\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_seactivityrel\n\t\t\t\tON vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_contactdetails\n\t\t\t\tON vtiger_contactdetails.contactid = vtiger_seactivityrel.crmid\n\t\t\tLEFT JOIN vtiger_cntactivityrel\n\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tAND vtiger_cntactivityrel.contactid = vtiger_cntactivityrel.contactid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_salesmanactivityrel\n\t\t\t\tON vtiger_salesmanactivityrel.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_emaildetails\n\t\t\t\tON vtiger_emaildetails.emailid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_seattachmentsrel \n\t\t\t\tON vtiger_activity.activityid=vtiger_seattachmentsrel.crmid \n\t\t\tLEFT JOIN vtiger_attachments \n\t\t\t\tON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid \n\t\t\tWHERE vtiger_activity.activitytype='Emails' AND vtiger_crmentity.deleted=0 ";
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     //we should add security check when the user has Private Access
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) {
         $sec_parameter = getListViewSecurityParameter("Emails");
         $query .= $sec_parameter;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }