Get KoolPHP UI with 30% OFF!

Email Button

Mowafag
Hey everybody,
How I can send selected rows by email ?
Best,
Posted Dec 18, 2015 Kool
Peter
Hi,
Could you please explain further your need? Please describe more detail your case of use.
Posted Dec 18, 2015 Kool
Mowafag
I'm looking for a way to select some rows then after click on “Email” button, pop-up appear for write recipient email address for sending selected rows to his/her inbox in HTML format.
Posted Dec 18, 2015 Kool
Anthony Amolochitis
I currently do something similar.
I use a custom column in the grid to build a jquery button.
I have a javascript on click event on the button that when clicked, calls a javascript function that does an ajax call to a server script that sends an email.
Here is the custom column. It can be any html, and any field from the sql query or array data source that you bind the grid to.
http://doc.koolphp.net/Controls/KoolGrid/PHP/GridCustomColumn/index.php
Posted Dec 18, 2015 Kool
Igor
Hi,
anthony, can you please post your code, im trying but with no succes for now.
Thank you.
Igor
Posted Apr 18, 2016 Kool
Anthony Amolochitis
First you need to make sure you have a grid custom column. Notice the button has a javascript onclick event called SendCustomerContactCredentials().
It takes in the contact id that will be emailed. Notice the class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only".
Those are jquery classes that give the button the look you are looking for. Make sure the libraries exist in your include on the html page.
function BuildSendCredentialsColumn()
    {
        $sendCredentials = '<div style="padding:4px;" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"'
            . ' onclick=SendCustomerContactCredentials({'. $this->field->contactid .'})>Send Login Info'
            . '</div>';
        
        $column = new gridcustomcolumn()              ;
        $column->DataField  = $this->field->contactid ;
        $column->Valign     = 'middle'          ;
        $column->HeaderText = ''                ;
        $column->Align      = 'left'            ;
        $column->ReadOnly   = true              ;
        $column->AllowSorting = false           ;
        $column->AllowFiltering = false         ;
        $column->ItemTemplate = $sendCredentials;
        $column->Width      = '65px;'          ;
        $this->KoolGrid->MasterTable->addcolumn($column) ;
    }

=========================================
Here are the callback functions called in javascript.
SendCustContactLoginCredentials() is a php function registered with the koolajax object.
That is the function that sends the email. I use mailgun to deliver the email, but you could just use the php built in mail() function to send one too.
Basically, once you get to your php script, you should be able to send the email.
/**
 * 
 * @param {type} contactId
 * @returns {undefined}
 */
function SendCustomerContactCredentials(contactId)
{
    turnOffCustomerContactEdit = true ;
    
    var response = confirm("Are you sure you want to send these credentials?");
    if ( response == true ) 
    {
        koolajax.callback( SendCustContactLoginCredentials(contactId) , OnDoneSendCustomerContactCredentials );
    } 
}
function OnDoneSendCustomerContactCredentials( result )
{
    window.alert( result.message ) ; 
    turnOffCustomerContactEdit = false ;
}
Posted Apr 18, 2016 Kool
Igor
Hi,
i have try to implement your code but its not working. I think that this chunk is questionable:
function BuildSendCredentialsColumn()
    {
        $sendCredentials = '<div style="padding:4px;" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"'
            . ' onclick=SendCustomerContactCredentials({'. $this->field->oib .'})>Send Login Info'
            . '</div>';

- onclick is not passing value in to $this i think, and grid custom column is not created.
....
<?php echo $koolajax->Render();?>
//callback functions here
<?php echo $grid->Render();?>
Posted Apr 22, 2016 Kool
Anthony Amolochitis
Make sure you are pulling the field in your sql statement, or array datasource, for your grid.
Field named "oib" needs to be a row in the mysql result.
Posted Apr 22, 2016 Kool
Igor
	$ds->SelectCommand = 'SELECT  id_tvrtke, klijent, god_prihod, zaposlenih, oib ...FROM import';

Can you please explain this line of code ( as i understand value from mysql query(oib) is passed to field and then to $this), what is "field"? :
[code]({'. $this->field->oib .'})[code]
thank you,
Igor
Posted Apr 22, 2016 , edited Apr 22, 2016 Kool
Anthony Amolochitis
Is the page live? Put the url to it.
Posted Apr 22, 2016 Kool
Igor
page is working ok, http://www.apartments-makarska.com.hr/2/index.php
link is ok, but when you click on it it will produce error, copy and paste will work
first button (test)
igor
123
Posted Apr 22, 2016 , edited Apr 22, 2016 Kool
Anthony Amolochitis
Your field names from the mysql query should be encapsulated in the curly brackets.
Example : {FieldName}
So in the php code block below that adds a custom column to my grid, the field name is contactId.
So the button string will output as such.
<div style="padding:4px;" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"' onclick="SendCustomerContactCredentials(1)">Send Login Info'</div>
function BuildSendCredentialsColumn()
    {
        $sendCredentials = '<div style="padding:4px;" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"'
            . ' onclick=SendCustomerContactCredentials({'. $this->field->contactid .'})>Send Login Info'
            . '</div>';
        
        $column = new gridcustomcolumn()              ;
        $column->DataField  = $this->field->contactid ;
        $column->Valign     = 'middle'          ;
        $column->HeaderText = ''                ;
        $column->Align      = 'left'            ;
        $column->ReadOnly   = true              ;
        $column->AllowSorting = false           ;
        $column->AllowFiltering = false         ;
        $column->ItemTemplate = $sendCredentials;
        $column->Width      = '65px;'          ;
        $this->KoolGrid->MasterTable->addcolumn($column) ;
    }

Which outputs the following grid column below in the image.

But first you need to add the custom column to the grid with the template html to display.
Posted Apr 22, 2016 Kool
Igor
Hi, Anthony could you please check my code obviously missing something
i can't get it to work, firebug gives me this error: ReferenceError: $SendCredentials is not defined
<?php
    require "KoolPHPSuite/KoolControls/KoolAjax/koolajax.php"; //KoolGrid requires KoolAjax to make ajax call.
    require "KoolPHPSuite/KoolControls/KoolGrid/koolgrid.php";
	require "KoolPHPSuite/KoolControls/KoolCalendar/koolcalendar.php";
	require "KoolPHPSuite/KoolControls/KoolGrid/ext/datasources/PDODataSource.php";
	//PDO
	$DB_TYPE = 'mysql'; //Type of database<br>
	$DB_HOST = 'localhost'; //Host name<br>
	$DB_USER = '***'; //Host Username<br>
	$DB_PASS = '***'; //Host Password<br>
	$DB_NAME = '***'; //Database name<br><br>
   // Initiate Grid 1 ///////////////////////////////////////////////////////////////////////////
		 //PDODataSource
    $ds = new PDODataSource(new PDO ("$DB_TYPE:host=$DB_HOST; dbname=$DB_NAME; charset=utf8;", $DB_USER, $DB_PASS));
			$ds->SelectCommand = 'select * from klijent
					WHERE username= "'.$_SESSION['login_user'].'"
					AND analitika = 1';
	// $ds->DeleteCommand = 'delete from klijent where id="@id" AND username= "'.$_SESSION['login_user'].'"';
	
	$ds->UpdateCommand = 'update klijent 
						SET 
						id_tvrtke="@id_tvrtke",
						klijent="@klijent",						 					
						aktivnost="@aktivnost",
						opis_aktivnosti="@opis_aktivnosti",
						distr="@distr", 
						struja="@struja", 
						strDtmDo="@strDtmDo", 
						kategorijaStruja="@kategorijaStruja", 
						plnDtmDo="@plnDtmDo", 
						kategorijaPlin="@kategorijaPlin", 
						strucna_napomena="@strucna_napomena"
						WHERE id_tvrtke="@id_tvrtke" 
						AND username= "'.$_SESSION['login_user'].'"';	
	mysql_query("SET NAMES 'utf8'");
	mysql_query("SET CHARACTER_SET 'utf8'");
	// $ds->InsertCommand = 'INSERT INTO klijent(id, klijent, distr, struja, strDtmDo, kategorijaStruja, plnDtmDo, kategorijaPlin, aktivnost, strucna_napomena, username) values ("@id", "@klijent", "@distr", "@struja", "@strDtmDo", "@kategorijaStruja", "@plnDtmDo", "@kategorijaPlin", "@aktivnost", "@strucna_napomena", "'.$_SESSION['login_user'].'")';		
	// $ds_history = new MySQLDataSource($db_con);	
	$ds_history = new PDODataSource(new PDO ("$DB_TYPE:host=$DB_HOST; dbname=$DB_NAME; charset=utf8;", $DB_USER, $DB_PASS));
	$ds_history->SelectCommand ='SELECT 
									@curRow := @curRow + 1 AS RBroj,
										  distr AS distributer,
										  klijent,
										  struja AS struja_tvrtka,
										  DATE_FORMAT(strDtmDo, "%d.%m.%Y") AS struja_vrijedi_do,
										  kategorijaStruja AS struja_kategorija,
										  DATE_FORMAT(plnDtmDo, "%d.%m.%Y")  AS plin_vrijedi_do,
										  kategorijaPlin AS plin_kategorija,
										  strucna_napomena,
										  opis_aktivnosti,
										  timex AS zadnja_promjena,
										  username AS Agent										 
									FROM    za_raditiHist 
									JOIN    (SELECT @curRow := 0) r
									ORDER BY zadnja_promjena DESC';
									
	$ds_history->UpdateCommand = 'update za_raditiHist 
						SET 					
						WHERE id_tvrtke="@id_tvrtke" 
						AND username= "'.$_SESSION['login_user'].'"';	
	$table_order_detail = new GridTableView(); 	
	$table_order_detail->Width = "100%";	
	$table_order_detail->DataSource = $ds_history;	
	$table_order_detail->AddRelationField("klijent","klijent");	
	$table_order_detail->AllowSorting = true;
	$table_order_detail->AutoGenerateColumns = true;
	$table_order_detail->DisableAutoGenerateDataFields = "RBroj, klijent";
	$table_order_detail->AllowScrolling = true;
	$table_order_detail->Height = "400px";
	//Initiate Grid
    $grid = new KoolGrid("grid");
	$grid->CharSet = "UTF-8";
	$grid->Align = "center";
	$grid->ColumnAlign  = "center";
	$grid->Localization->Load("KoolPHPSuite/KoolControls/KoolGrid/localization/hr.xml");
    $grid->scriptFolder = "KoolPHPSuite/KoolControls/KoolGrid";//Set script folder
    $grid->DataSource = $ds;
    $grid->AjaxEnabled = true;
    $grid->AutoGenerateColumns = true;
    $grid->MasterTable->Pager = new GridPrevNextAndNumericPager();
	$grid->MasterTable->Pager->Position = "top";//Show both pager
	$grid->MasterTable->ShowFunctionPanel = true;
	$grid->MasterTable->FunctionPanel->Position = "top";
    $grid->Width = "100%";
    $grid->ColumnWrap = true;
	$grid->AllowInserting = true;
	$grid->AllowGrouping = false;
	$grid->AllowSorting = true;
	$grid->AllowEditing = true;
	$grid->AllowDeleting = true;
	$grid->AllowResizing = true;
	$grid->AllowSelecting = true;
	$grid->AllowFiltering = true;//Enable filtering for all rows
    $grid->styleFolder="default";
	$grid->MasterTable->Pager = new GridPrevNextAndNumericPager();
	$grid->MasterTable->Pager->Position = "top";//Show both pager
	$grid->MasterTable->EditSettings->Mode = "Inline";//"Inline" is default value;
	$grid->MasterTable->InsertSettings->HeaderCaption = "Unesi novog korisnika";
	$grid->FilterOptions  = array("No_Filter","Contain");
	//Insert Settings
	$grid->MasterTable->InsertSettings->Mode = "Form";
	$grid->MasterTable->InsertSettings->ColumnNumber = 5;	
	$grid->MasterTable->InsertSettings->InputFocus = "BlurGrid";
	$grid->MasterTable->InsertSettings->HeaderCaption = "Insert New Row";
	$grid->MasterTable->FunctionPanel->InsertButtonText = "Dodaj";
	$grid->MasterTable->FunctionPanel->RefreshButtonText = "Osvježi";
	$grid->MasterTable->Pager->PageSize = 50;
	$grid->DisableAutoGenerateDataFields = "id_tvrtke, klijent, 
							god_prihod, 
							zaposlenih, 
							oib, 
							djelatnost, 
							telefon, 
							mobitel, 
							fax, 
							osobniEmail, 
							javniEmail, 
							zupanija, 
							post_broj, 
							mjesto, 
							adresa, 
							kontakt, 
							sljedece_zvanje_PLIN, 
							sljedece_zvanje_STRUJA, 
							stanje, 
							tsKodKupca,
							rezerviran_do_adnet, 
							datum_slanja_ponude, 
							datum_unosa_adnet, 
							napomena, 
							aktivnost, 
							opis_aktivnosti, 
							stari_naziv_baze, 
							strDtmDo, plnDtmDo, datum_unosa, username, struja, distr, strucna_napomena, kategorijaPlin, kategorijaStruja, analitika";
		//Show Function Panel
	$grid->MasterTable->Pager->Position = "topbottom";//Show both pager
	// $grid->MasterTable->Pager->Position = "top";//Show both pager
	$grid->MasterTable->ShowFunctionPanel = false;
	$grid->MasterTable->FunctionPanel->Position = "top";
	//update/delete
	$column = new GridEditDeleteColumn();
	$column->HeaderText = ""; 
	$column->DeleteButtonText = "";
	$column->EditButtonText = "Izmjeni";
	$column->ConfirmButtonText = "Potvrdi - ";
	$column->CancelButtonText = "Odustani";
	$column->Width = "100px";
	$column->Align = "center";
	$grid->MasterTable->AddColumn($column);
	$column = new GridDropDownColumn();
	$column->HeaderStyle->Align = "center";
	$column->CssClass = "blueColor";
	// $column->ReadOnly = true;
	$column->Sort=1;
    $column->DataField = "klijent";
    $column->HeaderText = "klijent";
	$column->Width = "100px";
    $result = mysql_query('select klijent from klijent 
							where username= "'.$_SESSION['login_user'].'" 
							AND aktivnost =1
							order by klijent asc
							');
    while($row=mysql_fetch_assoc($result))
    {
       $column->AddItem($row["klijent"],$row["klijent"]);
	 }
	$grid->MasterTable->AddColumn($column);
	// Plin - distribucijsko područje
	$column = new GridDropDownColumn();
	$column->HeaderStyle->Align = "center";
    $column->DataField = "distr";
    $column->HeaderText = "distributer";
	// $column->AllowFiltering = true;
    $result = mysql_query('select * from distribucijska_podrucja order by distr');
    while($row=mysql_fetch_assoc($result))
		{
		  $column->AddItem($row["distr"],$row["distr"]);
		}
	$grid->MasterTable->AddColumn($column);	
	$column = new GridDropDownColumn();
	$column->HeaderStyle->Align = "center";
    $column->DataField = "kategorijaPlin";
    $column->HeaderText = "plin_kategorija";
    $result = mysql_query('select * from plin_kategorija order by kategorijaPlin');
    while($row=mysql_fetch_assoc($result))
    {
       $column->AddItem($row["kategorijaPlin"],$row["kategorijaPlin"]);
	 }
	$grid->MasterTable->AddColumn($column);
	
	$column = new GridDateTimeColumn();
	$column->DataField = "plnDtmDo";
	$column->HeaderText = "plin vrijedi do";
	$column->FormatString = "d.m.Y";
	$column->Align = "center";
	$column->AllowFiltering = false;
	$column->Picker = new KoolDatePicker();
	$column->Picker->scriptFolder = "KoolPHPSuite/KoolControls/KoolCalendar";
	$column->Picker->styleFolder = "default";	
	$column->Picker->DateFormat = "d.m.Y";
	$grid->MasterTable->AddColumn($column);
	$column = new GridDropDownColumn();
	$column->HeaderStyle->Align = "center";
    $column->DataField = "struja";
    $column->HeaderText = "struja_tvrtka";
    $result = mysql_query('select struja from distrib_podrucja_s');
    while($row=mysql_fetch_assoc($result))
		{
		   $column->AddItem($row["struja"],$row["struja"]);
		 }
	$grid->MasterTable->AddColumn($column);
	$column = new GridDateTimeColumn();
	$column->DataField = "strDtmDo";
	$column->HeaderText = "struja vrijedi do";
	$column->FormatString = "d.m.Y";
	$column->Align = "center";
	$column->Picker = new KoolDatePicker();
	$column->AllowFiltering = false;
	$column->Picker->scriptFolder = "KoolPHPSuite/KoolControls/KoolCalendar";
	$column->Picker->styleFolder = "sunset";	
	$column->Picker->DateFormat = "d.m.Y";
	$grid->MasterTable->AddColumn($column);
	$column = new GridDropDownColumn();
	$column->HeaderStyle->Align = "center";
    $column->DataField = "kategorijaStruja";
    $column->HeaderText = "struja_kategorija";
	$column->Align = "center";
	$column->AllowGrouping = true;
    $result3 = mysql_query('select kategorijaStruja from struja_kategorija order by kategorijaStruja');
    while($row3=mysql_fetch_assoc($result3))
    {
       $column->AddItem($row3["kategorijaStruja"],$row3["kategorijaStruja"]);
	 }
	$grid->MasterTable->AddColumn($column);
	$column = new GridBoundColumn();//GridBoundColumn is inherited from GridColumn
	$column->DataField = "strucna_napomena";
	$column->HeaderText = "strucna_napomena";
	$grid->MasterTable->AddColumn($column);
	$column = new GridBooleanColumn();
	$column->DataField = "aktivnost";
	$column->HeaderText = "a/n";
	$column->UseCheckBox = true;
	$column->Width = "50px";
	$column->AllowFiltering = false;
	$grid->MasterTable->AddColumn($column);
	$column = new GridDropDownColumn();
	$column->DataField = "opis_aktivnosti";
	$column->HeaderText = "opis aktivnosti";
	// $column->Sort=-1;
	$column->AddItem("novi");
	$column->AddItem("aktivan");
	$column->AddItem("u najmu");
	$column->AddItem("u blokadi");
	$column->AddItem("predstečajna");
	$column->AddItem("odbio ponudu");
	$column->AddItem("NEĆE, kategorički");
	$column->AddItem("ne želim ga više raditi");
	$column->AddItem("ugovoren");
	$column->AddItem("ostalo");
	$column->AddItem("u stečaju, brisan");
	$column->AddItem("zauzet u adnetu");
	$column->AddItem("javna nabava");
	$column->AddItem("radi kolega");
	$column->AddItem("mali potrošać (do 1500kWh/mj.)");	
	$grid->MasterTable->AddColumn($column);
	
	//email
		function BuildSendCredentialsColumn()
			{
				$sendCredentials = '<div style="padding:4px;" class="button"'
					. ' onclick=SendCustomerContactCredentials({'. $this->Field->oib .'})>Send Login Info'
					. '</div>';			
				
	$column = new GridCustomColumn();
	$column->DataField  = $this->Field->oib ;
	$column->Valign     = 'middle';
	$column->HeaderText = 'Email';
	$column->Align      = 'left';
	$column->ReadOnly   = true;
	$column->AllowSorting = false;
	$column->AllowFiltering = false;
	$column->ItemTemplate = $sendCredentials;
	$column->Width      = '65px;';
	$this->KoolGrid->MasterTable->AddColumn($column);
	
			}	
//end email
	$grid->MasterTable->DataSource = $ds;	
	$grid->MasterTable->AutoGenerateExpandColumn = true;	
	$grid->MasterTable->AutoGenerateColumns = true;	
	$grid->MasterTable->AddDetailTable($table_order_detail);	
	$grid->MasterTable->ShowGroupPanel = false; //Show Group Panel
	$grid->ClientSettings->ClientEvents["OnRowSelect"] = "Handle_OnRowSelect";
	$grid->Process();
?>		
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<!--meta http-equiv="Content-Type" content="text/html" /--> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
}
.blueColor
	{
		background-color:#99ccff;
	}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<title>Analitika</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
</head>
<div id="left-content">
	<div class="content-middle">	
   <body>
       <form id="form1" method="post">
	   <script type="text/javascript">
			function SendCustomerContactCredentials(oib)
				{
					turnOffCustomerContactEdit = true ;
					
					var response = confirm("Are you sure you want to send these credentials?");
					if ( response == true ) 
					{
						koolajax.callback( SendCustomerContactCredentials(oib), OnDoneSendCustomerContactCredentials );
					} 
				}
		function OnDoneSendCustomerContactCredentials( result )
				{
					window.alert( result.message ) ; 
					turnOffCustomerContactEdit = false ;
				}
		</script>
          <?php echo $koolajax->Render();?>
		   <div id="res" style="padding-top:10px; padding-bottom:10px;"></div>
		  <?php echo $grid->Render();?>  
		 </form>
	</div>				
</div>
</body>
</html> 

Tnx in advance
Igor
Posted Jan 21, 2017 Kool
Anthony Amolochitis
Looks like you are missing your server side function that the javascript is to post to.
Ajax script will do a POST to the url where the php backend script is located including the parameters needed to properly send the email.
After the php script executes, echo a message back so the javascript can handle the echo output and provide a response to the client.
Posted Jan 23, 2017 Kool
Igor
Hi,
when i put grid custom column between curly brackets that column does not show in grid, is that normal because i don't have server side function or?
// email 
function BuildSendCredentialsColumn()
    {
        $sendCredentials = '<div style="padding:4px;" class="button"'
         . ' onclick=SendCustomerContactCredentials({'. $this->field->id_tvrtke .'})>email'
	                              . '</div>';
        $column = new GridCustomColumn();
        $column->DataField  = $this->field->id_tvrtke ;
	$column->Valign     = 'middle';
        $column->HeaderText = 'Email';
        $column->Align      = 'left';
        $column->ReadOnly   = true;
        $column->AllowSorting = false;
        $column->AllowFiltering = false;
        $column->ItemTemplate = $sendCredentials;
        $column->Width      = '65px;';
        $this->KoolGrid->MasterTable->AddColumn($column);
    }	
	// end email

im trying to figure it out this ss function, i messing around with this 3 snippets:
	// #1
			$("SendCustContactLoginCredentials").click(function(){
		        $.post("email.php", function(data, status){
                         alert("Data: " + data + "\nStatus: " + status);
                           });
                             }); 
	// #2   
			 $.ajax({
			 type: "POST",
			url: "email.php",
			data: $(form1).serialize(),
			success: function(){
			$('.success').fadeIn(1000);
			}
		});
     // #3
	                                        $(function () {    
						  $("#form1").submit(function () { 
							var form_data = $(this).serialize(); 
							$.ajax({
							  type: "POST", 
							  url: "email.php", 
							  data: form_data,
							  success: function () {
								alert("It's OK!");
							  }
							});
						  }); 
					});

am i on the rigth way? :)
Posted Jan 24, 2017 , edited Jan 24, 2017 Kool
Anthony Amolochitis
1. Write a php file dedicated to sending the email.
Example php file below
<?php
$id = $_POST['myid'];
// gather your data to email here.
// send the email here
echo 'results of your process' ;
die();
?>

2. Use your koolajax to do the ajax post because it is much simpler.
Example Javascript
<script type="text/javascript">
function SendCredentials(MyIdValue)
{
  var PhpOutPutResults = koolajax.load("http://locationToUrl.php?myid=" + MyIdValue ) ; 
  alert(PhpOutPutResults ); 
}
</script>

Step 3. Call the Javascript Function with the appropriate ID.
These are the basic Steps. I'm not sure what is wrong with your code because I am not debugging it. Build a simple test program to test using this so you may learn how to do it first, then apply the knowledge to your grid. It works exactly the same. It will then become easy. If you want to use the Jquery ajax call, that is fine to, but it is just more libraries.
Hope this helps.
Posted Jan 24, 2017 Kool
Igor
Thank you very very much Anthony, i will try to solve this with this examples.
Posted Jan 24, 2017 Kool
Igor
Hi,
finnaly i solved this!
1.
	//pictures
				
	$column = new GridImageColumn();
	$column->DataField = "pictures";
	$column->HeaderText = "pictures";
	$column->Width = '65px;';
	$column->ImageFolder = "";
	$column->CssClass = "my_image_css";
	$grid->MasterTable->AddColumn($column);
	//end pictures
	//email
	
		 $sendCredentials = '<div style="padding:4px;" class="button"' . ' onclick=sendEmail({id_tvrtke})> Email'. '</div>';
			$column = new GridCustomColumn();
			$column->DataField  = 'id_tvrtke' ;
			$column->Valign     = 'middle';
			$column->HeaderText = 'Email';
			$column->Align      = 'left';
			$column->ReadOnly   = true;
			$column->AllowSorting = false;
			$column->AllowFiltering = false;
			$column->ItemTemplate = $sendCredentials;
			$column->Width      = '65px;';
			$grid->MasterTable->AddColumn($column);
	// end email

2.
	   	   	<script type="text/javascript">							
				 function sendEmail(content)
						{
							// alert();
							$.ajax(
							{
								type:"POST",
								url:"email_with_query.php", 
								data: {id_tvrtke: content}, 
								success:function()
								{
									alert("Information about " + content + " is send!");
								}
							});
							return false;
						}
			</script>

3.
email_with_query.php
    <?php
        // header("Content-type: text/plain");
    // OPEN DATABASE
        define('DB_HOST','localhost');
        define('DB_USER','***');
        define('DB_PASS','***');
        define('DB_NAME','***');
        mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Connetion to database failed!");
        mysql_select_db(DB_NAME); 
        email();
        function email(){
	     $result = mysql_query("SELECT * FROM klijent WHERE id_tvrtke='{$_POST[id_tvrtke]}'");
            $mail_to = "******@yahoo.com";	
     	while ($row = mysql_fetch_array($result)){
            
	echo $id_tvrtke = $row["id_tvrtke"];
        echo $klijent=$row["klijent"];
        echo $distr=$row["distr"];
	echo $struja = $row["struja"];
        echo $strDtmDo=$row["strDtmDo"];
        echo $kategorijaStruja=$row["kategorijaStruja"];
        echo $plnDtmDo=$row["plnDtmDo"];
        echo $kategorijaPlin=$row["kategorijaPlin"];
	echo $strucna_napomena=$row["strucna_napomena"];
        echo $pictures=$row["pictures"];
            if (!empty($mail_to)){
               sendEmail($mail_to,$id_tvrtke, $klijent, $distr, $struja, $strDtmDo,$kategorijaStruja, $plnDtmDo, $kategorijaPlin, $strucna_napomena, $pictures);
            }
		}
		}
    // SEND EMAIL
       function sendEmail($mail_to,$id_tvrtke, $klijent, $distr, $struja, $strDtmDo,$kategorijaStruja, $plnDtmDo, $kategorijaPlin, $strucna_napomena, $pictures) 
            {
            $mail_to ="$mail_to";
            //$href ="http://yourpage.com/pictures/";
            $id_tvrtke ="$id_tvrtke";
            $klijent = "$klijent";
            $distr = "$distr";
            $struja = "$struja";
            $strDtmDo = "$strDtmDo";
	    $kategorijaStruja = "$kategorijaStruja";
	   $plnDtmDo = "$plnDtmDo";
	   $kategorijaPlin = "$kategorijaPlin";
	   $strucna_napomena = "$strucna_napomena";
           $pictures = "<a href=$href$pictures>$pictures</a>";
           
           $from    = "farkz@farkz.com";
               //begin of HTML message
        $message = "<html>
				<body bgcolor=\"#FFFFFF\">
					<table border='' style='border-collapse: collapse; border-bottom-width: 0px; border-right-width: 0px;'>
						 <tr style='background-color: #99ccff;'>
								<th>Klijent:</th>
								<th>Distributer:</th>
								<th>Struja:</th>
								<th>strDtmDo:</th>
								<th>KategorijaStruja:</th>
								<th>plnDtmDo:</th>
								<th>kategorijaPlin:</th>
								<th>strucna_napomena:</th>
								<th>aktivnost:</th>
								<th>opis_aktivnosti:</th>
                                                                <th>pictures:</th>
						</tr>
						<tr>
								<td>$id_tvrtke</td>
								<td>$klijent</td>
								<td>$distr</td>
								<td>$struja</td>
								<td>$strDtmDo</td>
								<td>$kategorijaStruja</td>
								<td>$plnDtmDo</td>
								<td>$kategorijaPlin</td>
								<td>$strucna_napomena</td>	
                                                                <td>$pictures</td>
						</tr>
					</table>
				</body>
			</html>";
       //end of message 
            $headers = 'From: '.$from."\r\n" .
            'Reply-To:'.$_POST['email']."\r\n" .
            "Content-Type: text/html; charset=iso-8859-1\n".
            'X-Mailer: PHP/' . phpversion();
            mail($mail_to, "farkZ", $message, $headers);
        }
    ?> 

update: i put new GridImageColumn in phpfile and update email_with_query.php file with fields for picture.
here is how it looks in email
Posted Jan 28, 2017 , edited Oct 19, 2017 Kool -
Anthony Amolochitis
Good job!
Posted Jan 28, 2017 Kool
Igor
Anthony, thanks again for helpful hints!
:)
Posted Jan 28, 2017 Kool
Anthony Amolochitis
Anytime Igor.
Just so you know, as you keep using the grid, you'll find that the custom templates are completely flexible. Koolgrid as less barriers as I keep using it. Currently, every barrier I have found in the past using it has been eliminated due to the custom insert, edit, and custom column templates. Utilizing its built in javascript methods in conjunction makes the koolgrid not even seem like a grid, but just a koolcustom form with any design I want.
Take it easy man
Posted Jan 28, 2017 Kool