$iFilteredTotal = $module_object->getNumRows(); } else { $iFilteredTotal = $iTotal; } $qry = $qry . $security_where . $where . $order_by . $limit; if (count($query_params) > 0) { $module_object->query($qry, $query_params); } else { $module_object->query($qry); } $output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array()); if ($module_object->getNumRows() > 0) { $pkey = $module_object->primary_key; while ($module_object->next()) { $row = array(); foreach ($fields_info as $fields => $info) { $fieldobject = 'FieldType' . $info["field_type"]; $row[] = $do_crmfields->display_field_value($module_object->{$fields}, $info["field_type"], $fieldobject, $module_object, $mid, false); } $action_links = ''; $action_links .= '<a href="/cpanel/modules/' . $m . '/detail?sqrecord=' . $module_object->{$pkey} . '">' . _('detail') . '</a>'; if ($action_links != '') { $row[] = $action_links; } if ($action_links == '') { $row[] = ''; } $output["aaData"][] = $row; } } echo json_encode($output);
} elseif ($info["field_type"] == 151) { $val = $fieldobject::display_value(1, $do_report->events_related_to_idmodule, $do_report->events_related_to_value, false); } elseif ($info["field_type"] == 165) { $val = $fieldobject::display_value($do_report->product_tax_values); } elseif ($info["field_type"] == 141) { $field_name = $report_modules["primary"]["module_name"] . "_" . 'org_name_141'; $val = $fieldobject::display_value('', $do_report->{$field_name}, false); } elseif ($info["field_type"] == 142) { $field_name = $report_modules["primary"]["module_name"] . "_" . 'cnt_name_142'; $val = $fieldobject::display_value('', $do_report->{$field_name}, false); } elseif ($info["field_type"] == 143) { $val = $fieldobject::display_value('', $do_report->contact_name, false); } elseif ($info["field_type"] == 160) { $val = $fieldobject::display_value('', $do_report->vendor_name, false); } else { $val = $do_crmfields->display_field_value($do_report->{$info}["field_name"], $info["field_type"], $fieldobject, $this, $info["idmodule"], false); } } else { if ($info["field_type"] == 131) { if ($info["field_name"] == 'idorganization') { $field_name = $report_modules["secondary"]["module_name"] . "_" . 'org_name'; $val = $fieldobject::display_value($do_report->{$field_name}, $do_report->{$field_name}, false); } elseif ($info["field_name"] == 'member_of') { $val = $fieldobject::display_value($do_report->organization_member_of, $do_report->organization_member_of, false); } } elseif ($info["field_type"] == 130) { $val = $fieldobject::display_value($do_report->contact_report_to, $do_report->contact_report_to, false); } elseif ($info["field_type"] == 133) { $field_name = $report_modules["secondary"]["module_name"] . "_" . 'potential_name_133'; $val = $fieldobject::display_value('', $do_report->{$field_name}, false); } elseif ($info["field_type"] == 150) {
/** * function to export list data as PDF * @param string $file_name * @param array $fields_info * @param integer $module_id * Library used for PDF generation is tcpdf http://www.tcpdf.org/ * @see http://www.tcpdf.org/performances.php */ public function export_detail_data_pdf($module, $module_id, $record_id) { $do_crmfields = new CRMFields(); $do_block = new Block(); $do_block->get_block_by_module($module_id); $module_obj = new $module(); $module_obj->getId($record_id); if ($module_obj->getNumRows() > 0) { $do_crmfields = new CRMFields(); include_once THIRD_PARTY_LIB_PATH . "/mpdf/mpdf.php"; $pdf = new mPDF(); $do_crm_entity = new CRMEntity(); $entity_identity = $do_crm_entity->get_entity_identifier($record_id, $module, $module_obj); $html = ''; $html .= '<div style="float:left"><h3>' . $entity_identity . '</h3></div><div style="clear:both;"></div>'; while ($do_block->next()) { $html .= ' <table cellspacing="0" cellpadding="1" border="1" width="800px;"> <tbody> <tr style="background-color:#eeeeee;line-height:100%;"> <td colspan="4" height="35"><b>' . $do_block->block_label . '</b></td> </tr>'; $do_crmfields->get_form_fields_information($do_block->idblock, $module_id); $num_fields = $do_crmfields->getNumRows(); $tot_count = 0; while ($do_crmfields->next()) { $fieldobject = 'FieldType' . $do_crmfields->field_type; $fields_count++; $tot_count++; if ($tot_count == 1 || $tot_count % 2 != 0) { $html .= '<tr>'; } $html .= '<td style="background-color:#FDFFBD;width:25%;" height="20">' . $do_crmfields->field_label . '</td>'; $fld_name = $do_crmfields->field_name; $field_value = ''; if ($do_crmfields->field_type == 12) { $field_value = $fieldobject::display_value($module_obj->{$fld_name}, 'l'); } elseif ($do_crmfields->field_type == 11) { $field_value = $fieldobject::display_value($module_obj->{$fld_name}, $module, $sqcrm_record_id, $fld_name, true); } else { $field_value = $do_crmfields->display_field_value($module_obj->{$fld_name}, $do_crmfields->field_type, $fieldobject, $module_obj, $module_id, false); } $html .= '<td height="20" style="width:25%;">' . $field_value . '</td>'; if ($tot_count != 1 && $tot_count % 2 == 0) { $html .= '</tr>'; } if ($num_fields == $tot_count && $tot_count % 2 != 0) { $html .= ' <td style="background-color:#FDFFBD;width:25%" height="20"> </td> <td height="20" style="width:25%"> </td> </tr>'; } } $html .= '</tbody></table>'; $html .= '<br>'; } $pdf->WriteHTML($html); $pdf->Output($module . '_' . $record_id . '.pdf', 'D'); exit; } }
/** * function to export list data as PDF * @param string $file_name * @param array $fields_info * @param integer $module_id * Library used for PDF generation is tcpdf http://www.tcpdf.org/ * @see http://www.tcpdf.org/performances.php */ public function export_to_pdf($file_name, $fields_info, $module_id) { if ($this->getNumRows() > 0) { $do_crmfields = new CRMFields(); include_once THIRD_PARTY_LIB_PATH . "/tcpdf/tcpdf.php"; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set font $pdf->SetFont('helvetica', '', 8); // add a page $pdf->AddPage(); $header = '<table><tr>'; foreach ($fields_info as $field => $info) { $header .= '<td><b>' . $info["field_label"] . '</b></td>'; } $header .= '</tr>'; $pdf->writeHTML($header, true, false, false, false, ''); while ($this->next()) { $data_row = '<table><tr>'; foreach ($fields_info as $fields => $info) { $fieldobject = 'FieldType' . $info["field_type"]; $val = $do_crmfields->display_field_value($this->{$fields}, $info["field_type"], $fieldobject, $this, $module_id, false); $data_row .= '<td>' . $val . '</td>'; } $data_row .= '</tr></table>'; $pdf->writeHTML($data_row, true, false, false, false, ''); } $pdf->writeHTML('</table>', true, false, false, false, ''); $pdf->Output($file_name . '.pdf', 'I'); exit; } }
/** * function to display the list data in datatable * the object for the viewing module must be set before the function call and all other member variables * @param integer $module_id * @param boolean $popup * @param string $primary_key * @see listdata.php, listdata_popup.php * The param $primary_key is used for a special purpose. When we use to view the related information we send * the primary key value since if we see some related data for a module and if we do not send the primary key name * then the primary key will be used from the module instead of related modules * EX: if we want to see the related Contacts for a Prospect then we must send the primary key name 'idcontacts' * else it will take 'idpotential' as the primary key value. The query will not get the idpotentials since it will * run on Contacts and we do not want potential information on related tab. * @see listdata_related.php */ public function display_data($module_id, $popup = false, $primary_key = '') { $do_crmfields = new CRMFields(); $object = $this->get_ds_object(); $module_info = $_SESSION["do_module"]->get_modules_with_full_info(); $module_name = $module_info[$module_id]["name"]; //Get the list query from the object $qry = $object->getSqlQuery(); //security where condition $security_where = $this->get_ds_list_security(); $group_by = ''; if (property_exists($object, "list_query_group_by") === true && $object->list_query_group_by != '') { $group_by = " group by " . $object->list_query_group_by; } //echo $qry.$security_where.$group_by;exit; if ($object->get_list_tot_rows() == 0) { if (count($this->get_ds_additional_query_param()) > 0) { //echo '<br />1 '.$qry.$security_where.$this->get_ds_additional_where().$group_by ; $this->query($qry . $security_where . $this->get_ds_additional_where() . $group_by, $this->get_ds_additional_query_param()); } elseif (strlen($this->get_ds_additional_where()) > 3) { //echo '<br />2 '.$qry.$security_where.$this->get_ds_additional_where().$group_by ; $this->query($qry . $security_where . $this->get_ds_additional_where() . $group_by); } else { //echo '<br />3 '.$qry.$security_where.$group_by ; $this->query($qry . $security_where . $group_by); } //Get the total number of records $iTotal = $this->getNumRows(); $object->set_list_tot_rows($iTotal); } else { $iTotal = $object->get_list_tot_rows(); } if ($this->get_ds_where_cond() != '') { if ($object->get_list_tot_rows() == 0) { if (strlen($this->get_ds_additional_where()) > 3) { //echo '<br />11 '.$qry.$security_where.$this->get_ds_additional_where().$this->get_ds_where_cond().$group_by ; $this->query($qry . $security_where . $this->get_ds_additional_where() . $this->get_ds_where_cond() . $group_by, $this->get_ds_search_params()); } else { //echo '<br />12 '.$qry.$security_where.$this->get_ds_where_cond().$group_by ; $this->query($qry . $security_where . $this->get_ds_where_cond() . $group_by, $this->get_ds_search_params()); } //Get the total number of records $iTotal = $this->getNumRows(); $object->set_list_tot_rows($iTotal); } else { $iTotal = $object->get_list_tot_rows(); } } else { if (strlen($this->get_ds_additional_where()) > 3) { //print_r($this->get_ds_search_params()); //echo '<br />13 '.$qry.$security_where.$this->get_ds_additional_where().$group_by; $this->query($qry . $security_where . $this->get_ds_additional_where() . $group_by, $this->get_ds_search_params()); } else { //echo '<br />14 '.$qry.$security_where.$group_by; $this->query($qry . $security_where . $group_by); } //Get the total number of records $iTotal = $this->getNumRows(); $object->set_list_tot_rows($iTotal); } // Get the query limit and then add to the query $limit = ''; $sql_start = $this->get_ds_sql_start(); $sql_max = $this->get_ds_sql_max(); if ($sql_start != '' && $sql_max != -1) { $limit = " LIMIT " . $sql_start . ", " . $sql_max; } // Get order by and then add to the query if ($this->get_ds_order_by() != '') { $order_by = " " . $this->get_ds_order_by(); } else { if ($object->get_default_order_by() != "") { $order_by = " order by " . $object->get_default_order_by(); } } // Get the where condition for the filter $where = ''; if (strlen($this->get_ds_additional_where()) > 3) { $where .= $this->get_ds_additional_where(); } if ($this->get_ds_where_cond() != '') { $where .= $this->get_ds_where_cond(); } //The following part is ugly and we need something on Radria Core to use SELECT FOUND_ROWS() if ($this->get_ds_where_cond() != '') { if (count($this->get_ds_search_params()) > 0) { $this->query($qry . $security_where . $where . $group_by, $this->get_ds_search_params()); } else { $this->query($qry . $security_where . $where . $group_by); } $iFilteredTotal = $this->getNumRows(); } else { $iFilteredTotal = $iTotal; } //And finally execute the query $qry = $qry . $security_where . $where . $group_by . $order_by . $limit; if (count($this->get_ds_search_params()) > 0) { $this->query($qry, $this->get_ds_search_params()); } else { $this->query($qry); } $output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array()); $edit = false; $delete = false; $detail = false; if ($this->get_ds_show_edit_link() === true && $popup === false && $_SESSION["do_crm_action_permission"]->action_permitted('edit', $module_id) === true) { $edit = true; } if ($this->get_ds_show_delete_link() === true && $popup === false && $_SESSION["do_crm_action_permission"]->action_permitted('delete', $module_id) === true) { $delete = true; } if ($this->get_ds_show_detail_link() === true && $popup === false && $_SESSION["do_crm_action_permission"]->action_permitted('view', $module_id) === true) { $detail = true; } if ($this->getNumRows() > 0) { $fields_info = $this->get_ds_fields_info(); if ($primary_key == '') { $pkey = $object->primary_key; } else { $pkey = $primary_key; } while ($this->next()) { $row = array(); if ($this->get_ds_show_record_selector() === true) { if ($popup === true) { $retrun_fields = $object->popup_selection_return_field; $retrun_field_list = explode(",", $retrun_fields); $retrun_field = ''; $cnt_return_fields = 0; foreach ($retrun_field_list as $retrun_fields) { if ($cnt_return_fields > 0) { $retrun_field .= ' '; } $retrun_field .= $this->{$retrun_fields}; $cnt_return_fields++; } //$retrun_field if (isset($_GET["special_field"]) && $_GET["special_field"] == 'yes') { $special_field = $_GET["special_field"]; $special_field_name = $_GET["special_field_name"]; $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_selected_special(\'chk_popup' . $this->{$pkey} . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">'; } elseif ($_REQUEST["line_item"] == 'yes') { $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_line_item(\'chk_popup' . $this->{$pkey} . '\',\'' . $module_name . '\',\'' . $_REQUEST["line_level"] . '\');" value="' . $this->{$pkey} . '">'; } elseif (isset($_REQUEST["copy_org_address"]) && $_REQUEST["copy_org_address"] == 'yes') { $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_copy_org_addr(\'chk_popup' . $this->{$pkey} . '\',\'' . $_REQUEST["target_module"] . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">'; } elseif (isset($_REQUEST['copy_cnt_address']) && $_REQUEST['copy_cnt_address'] == 'yes') { $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return copy_cnt_address(\'chk_popup' . $this->{$pkey} . '\',\'' . $_REQUEST["target_module"] . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">'; } else { $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_selected(\'chk_popup' . $this->{$pkey} . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">'; } } else { if ($module_id == 7 && $this->{$pkey} == 1) { $chk_input = '<input type="hidden" name="chk[]" value="' . $this->{$pkey} . '">'; } else { $chk_input = '<input type="checkbox" class="sel_record" name="chk[]" value="' . $this->{$pkey} . '">'; } } $row[] = $chk_input; } else { $chk_input = '<input type="hidden" name="chk[]" value="' . $this->{$pkey} . '">'; $row[] = $chk_input; } foreach ($fields_info as $fields => $info) { $fieldobject = 'FieldType' . $info["field_type"]; $row[] = $do_crmfields->display_field_value($this->{$fields}, $info["field_type"], $fieldobject, $this, $module_id); } $action_links = ''; if ($detail === true) { if ($action_links != '') { $action_links .= ' | '; } $action_links .= '<a href="/modules/' . $module_name . '/detail?sqrecord=' . $this->{$pkey} . '">' . _('detail') . '</a>'; } if ($edit === true) { if ($action_links != '') { $action_links .= ' | '; } $action_links .= '<a href="/modules/' . $module_name . '/edit?sqrecord=' . $this->{$pkey} . '">' . _('edit') . '</a> '; } if ($delete === true) { if ($module_id == 7) { if ($this->{$pkey} != 1) { // admin user delete is not allowed if ($action_links != '') { $action_links .= ' | '; } $action_links .= '<a class="delete_entity_user" id="' . $this->{$pkey} . '" href="#">' . _('delete') . '</a>'; } } else { if ($action_links != '') { $action_links .= ' | '; } $action_links .= '<a class="delete_entity" id="' . $this->{$pkey} . '" href="#">' . _('delete') . '</a>'; } } if ($action_links != '') { $row[] = $action_links; } if ($action_links == '') { $row[] = ''; } $output["aaData"][] = $row; } } echo json_encode($output); }