Hello there ,
This is my first post here, Iām not used to write english so I apologize in advance
My SuiteCRM version is: 7.11.15
I was doing a āMass Update/Bulk Actionā button for custom CVS export in Meetings List View.
I started seeing sugar_3.js (jssource/src_files/include/javascript/ā¦) to understand better whatās happening.
When I was finishing my tests I found an āerrorā, when I clicked the select all with a custom EntryPoint, my php wasnāt getting data.
My solution was modify sugar_3.js and change line:
sugarListView.prototype.check_entire_list = function (form, field, value, list_count) {
ā¦
form.elements[i].checked = value;
form.elements[i].disabled = true;
ā¦
for
sugarListView.prototype.check_entire_list = function (form, field, value, list_count) {
ā¦
form.elements[i].click();
form.elements[i].disabled = true;
ā¦
I donāt know if Iām misunderstanding some concepts about building EntryPoints ā¦
Here is my custom EntryPoint code:
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
//Check form inputs
$array_meetings_id = array();
if( isset($_POST['uid']) ) {
$uid = $_POST['uid'];
$seperator = ",";
if( strpos($uid, $seperator)===false ) { $array_meetings_id[] = $uid; }
else { $array_meetings_id = explode($seperator, $uid); }
}
// Obtain full name from list of contacts
function get_full_name_contact($contactIds) {
$return_txt = "";
for ($i=0; $i < count($contactIds); $i++) {
$contactBean = BeanFactory::getBean('Contacts',$contactIds[$i]);
$return_txt .= " - ". $contactBean->first_name ." ". $contactBean->last_name;
}
return $return_txt;
}
// var to appended content
$csv_content = '';
// GET MEETING INFO
for ($j=0; $j < count($array_meetings_id); $j++) {
$id_meeting = $array_meetings_id[$j];
$meetingBean = BeanFactory::getBean('Meetings',$id_meeting);
$meetingName = $meetingBean->name;
// GET CONTACT INFO
$meetingBean->load_relationship('contacts');
$contactIds = $meetingBean->contacts->get();
$meetingContacts = get_full_name_contact($contactIds);
$meetingAccount = $meetingBean->parent_name;
$meetingAssigned = $meetingBean->assigned_user_name;
$meetingDate_start = $meetingBean->date_start;
$meetingDuration = $meetingBean->duration_hours . "h " . $meetingBean->duration_minutes . "m";
$meetingDescription = $meetingBean->description;
$meetingData_entered = $meetingBean->date_entered;
$meetingStatus = $meetingBean->status;
$csv_content .= "\n".$id_meeting .';'. $meetingName .';'. $meetingContacts .';'. $meetingAccount .';'. $meetingAssigned .';'. $meetingDate_start .';'. $meetingDuration .';'. $meetingDescription .';'. $meetingData_entered .';'. $meetingStatus;
}
// FILE OPTIONS
$file_name = 'mettings';
$pathCSV = "tempFiles/".$file_name.".csv";
$file_header = "MeetingID;Meeting;Contact;Client;Assigned to;Date;Duration;Description;CreationDate;Status";
$filte_text = $file_header . $csv_content;
if( isset($_POST['uid']) ) {
// Gen CSV
$file_meeting = fopen( $pathCSV, "w" ) or die("Unable to open file response!");
fwrite($file_meeting, $filte_text);
fclose($file_meeting);
// Download CSV
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename='.$file_name.'.csv; charset=utf-8');
header('Pragma: no-cache');
header('Content-Length: ' . filesize($pathCSV));
readfile($pathCSV);
// Delete CSV from server
unlink($pathCSV);
}
Iām not sure if Iām doing it right by changing that sugar_3.js file.
With that change in sugar_3.js my code works and the rest of SuiteCRM seems to work fine too.
What do you think?
Thx