/** 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; }
/** 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; }