Friday, July 3, 2015

what big data & why big data

Standard


Data:,Everyone has talking about  data  today than years ago, past year (before come large ware house).people they doesn't have about any idea  how can use people behaviors in to business decision & How can you make money with it? While the first step is to reveal the wants and needs hidden inside the data, the more important step is to convert those wants and needs into profitable services through algorithms .
 from past year peoples are try to communicate they are needed s using computer & smart platform so reason that , business had to convert to virtual environment from physical environment. in close example BBC said they have to  cut more than 1,000 jobs in 2015 frist quart .they said increasing number of people do not watch live television, most people are use social network & web site to get information.  so do not need to pay the licence fee.
Big data

 is high-volume, high-velocity and high-variety information assets that demand cost-effective, innovative forms of information processing for enhanced insight and decision making .

how big data architecture 




please watch this video i hope you can  get Understand the trends that have led to the Big Data opportunity.



 MapReduce






Email templat engine_laravel 5

Standard


this is the way end mail with Email Template Engine .save templates in database and replace some fields and send mail frist confige your laravel email config file mail.php

return [

 'driver' => env('MAIL_DRIVER', 'smtp'),
 'host' => env('MAIL_HOST', 'smtp.gmail.com'),
 'port' => env('MAIL_PORT', 587),
 'from' => ['address' => 'youremail@gmail.com', 'name' => 'name'],
 'encryption' => 'tls',
 'username' => env('MAIL_USERNAME'),
 'password' => env('MAIL_PASSWORD'),
 'sendmail' => '/usr/sbin/sendmail -bs',
 'pretend' => false,

];
.env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MyUsername@gmail.com
MAIL_PASSWORD=MyPassword

create data base & create email tempalte migration php artisan make:migration create_users_table upload migration file
class CreateEmailtemplateTable extends Migration {

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
        Schema::create('emailtemplate', function(Blueprint $table)
        {
            $table->increments('id');
            $table->string('name');
            $table->string('variables',255);
            $table->string('subject', 255);
            $table->longText('description');
            $table->timestamp('created_at');
            $table->enum('status', array('1', '0'));
        });
 }

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
  //
 }

}

OR you can upload sql file which on have in file in app\Http\Controllers.php add fuloowing function to accesss email sendig system throughout of you application IN CONTROLL.PHP
namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Mail;
use DB;
use Exception;

abstract class Controller extends BaseController {

 use DispatchesCommands, ValidatesRequests;



    public function sendemail($emil_template='',$mailsubject='',$email_variable='')
    {

//get data record using tempalte name

        $gettemplate=  $this->mailtemplate($emil_template);

//      deploy deta stringobject array
        $all_detail = [] ;
        foreach ($gettemplate[0] as $kay=>$tempalte_detail)
        {
            $all_detail[]=$tempalte_detail;
        }

//        get template description in to variable by channa
                  $description=$all_detail[4];

  //   send $description $description to VariableReplaceArray by channa
       $variable_replace_message= $this->VariableReplaceArray($email_variable,$description);

//     if controller subject is    get subject of email from default template
        if(empty($mailsubject))
            {
               $mailsubject=$all_detail[3];
            }

//get reciver name & email
        $receiver_name=$email_variable['{to_fname}'].' '.$email_variable['{to_lname}'];
        $receiver_email=$email_variable['{to_email}'];
//        echo '
'.print_r($receiver_email,1).'
'; // die(); Mail::send('email_tempate.user_template', ['mail_content' => $variable_replace_message], function($sendmail)use ($mailsubject,$receiver_name,$receiver_email) { $sendmail->to($receiver_email, $receiver_name); $sendmail->cc('noreply@gmail.com'); $sendmail->subject($mailsubject); }); return ; } // get email template from data table public function mailtemplate($getname) { // get email template $gettemplate = DB::table('emailtemplate')->where('name',$getname)->get(); //trigger exception in a "try" block for email template try { if(empty($gettemplate)) { //If the exception is thrown, this text will not be shown echo 'this title not available in email template table '; } } //catch exception catch(Exception $e) { echo 'Message: ' .$e->getMessage(); } return $gettemplate; } //VariableReplaceArray by channa public function VariableReplaceArray($email_variable,$description) { $getvariableArray=array_keys($email_variable); $replacevariableArray=array_values($email_variable); $variable_repalsement= str_replace($getvariableArray,$replacevariableArray,$description); return $variable_repalsement; } }
this is add your controller fuction which you create for send email
public function index()
 {

        $emil_template='user registration tempalate'; // template name  which need to send
        $mailsubject=""; //if user template default email subject kaeep this empty
        $message= 'this is the way end mail with Email Template Engine .save templates in database and replace some fields and send mail
        frist confige your laravel email config file mail.php';
//
        $email_variable=array(
            '{to_fname}'=>'channa',// receiver frist name
            '{to_lname}'=>'bandaara',//receiver last name
            '{to_email}'=>'channasmcs@gmail.com', //receiver email
            '{link}'=>'https://www.channasmcs.blogspot.com',// link if you send
            '{message}'=>$message, // message
        );
//        get this on sendemail function
        self::sendemail($emil_template,$mailsubject,$email_variable);


 }
$email_variable mean i define commen variable for repalce sender & reciever detail this method will easy becouse when we create template body like this (see sql file)
hello {to_fname} {to_lname} 



you have message


{message}



click this link {link}



thnank you
create folder resources\views email_template & create template layout file i make user.php this bring email body

  
    
HELLO GUYS channa make your work easy please comment see my blog for more
{!! $mail_content !!}
mail ot put

i hope this will help for advance develiopment 


get sample project from GIT-HUB

thank you

Wednesday, June 24, 2015

laravel 5 ajax POST

Standard

hi guys here is basic AJAX POST on laravel 5 i hope this will help for your advance project

 thank you


Route::group(['prefix' => 'ajax'], function() {

    Route::get('/ajax', 'AjaxController@ajax');
    Route::post('/ajaxpost', 'AjaxController@ajaxpost');

});
 
<pre class="java" name="code">
             <input id="name" name="name" type="text" value="hello channa" />
             <input id="__token" name="__token" type="hidden" value="uAVNLARzB2zKp2hJElHXNRGSGLJ0gwqibXyqRXci" />

             <input class="submit" id="submit" type="submit" />

           
<div id="loadingmessage" style="display: none;">
<img src="loading.gif" />                                                                            
  </div>
<div id="my_div">
</div>
<script>

        $('#submit').click(function(){
        $('#loadingmessage').show();  // show the loading message.
        $.ajax({
            type: "POST",
            url: "http://localhost/bitbuckt/public/staff/ajaxpost",
            dataType: "html",
            data: { "_token" : "uAVNLARzB2zKp2hJElHXNRGSGLJ0gwqibXyqRXci" },
            success: function( response) {
              $('#my_div').html(response);
              $('#loadingmessage').hide(); // hide the loading message
     
            }
          });

        });

        </script>

</pre>
create view form under resources -&gt; view -&gt; ajax -&gt;ajax.blade.php
i passed _token key with data

create response action on AjaxController
 

    public  function ajaxpost()
    {

        print_r('data response ');
    } public  function ajax()
    {
        return view('staff.ajax');
    }

 

Thursday, March 5, 2015

print div contain using JS

Standard




 


text area for print

Wednesday, March 4, 2015

calculate the difference between two dates using PHP?

Standard
You can use strtotime() to convert two dates to unix time and then calculate the number of seconds between them. From this it's rather easy to calculate different time periods


            $date1 = "2015-03-08";
            $date2 = date("Y-m-d");

            $diff = abs(strtotime($date2) - strtotime($date1));

            $years = floor($diff / (365*60*60*24));
            $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
            $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
            printf("%d years, %d months, %d days\n", $years, $months, $days);
            printf(" %d months, %d days Days Ago\n", $months, $days);
            printf("%d Days Ago\n",  $days);

Tuesday, February 24, 2015

mouseover popup box YII griview

Standard
YII Drid cell with a javascript/css content box that pops up upon mouseover.





<! --- Style ------- >


<! ---- Java script ----->



add this on YII drid view

array( 'header'=>' User', 'value' => ' " ".CHtml::link($data->user->username,array("user/admin/view/id/".$data->UserId))."
Email : ".$data->user->email."
Telephone : ".$data->user->Telephone."
" ', 'name'=>'UserId', 'filter'=>FALSE, 'type'=>'raw', ),


 

Wednesday, February 18, 2015

add custom ajax YII

Standard
This article will help you to understand the power of jQuery (library of JavaScript functions) with simple this on view page
     
Click me
Change me
on controller
public function actionajax()
	{
       echo'hello is me !';
	}

Tuesday, February 10, 2015

Get a Facebook API Access Token That Never Expires

Standard
I’ve been working on a few scripts that performed some minor data collection using the Facebook Graph API as a data source. Ideally, I wanted this script to be able to run several times a day automatically, however Facebook grants access tokens that expire after 1-2 hours. Since I’m the only one that is going to run this script, I only needed access to my Facebook data and I didn’t want to have to re-authenticate every few hours. Luckily, Facebook provides a permission parameter to get a “long-lived” access token from Oauth called offline_access!

https://graph.facebook.com/oauth/access_token?
client_id=_APP_ID_&
client_secret=_APP_SECRET_&
grant_type=fb_exchange_token
&fb_exchange_token=_ACCESS_TOKEN_ON_STEP_4_


Thursday, February 5, 2015

Tuesday, January 27, 2015

change the color of scrollbars

Standard


add this in your style .css  to change the color of the scrollbars on my pages in Internet Explorer and Firefox

::-webkit-scrollbar {
width: 12px;
height: 4px;
background: rgba(111, 78, 78, 0.35);
}
::-webkit-scrollbar-thumb {
background-color: rgba(145, 36, 66, 0.99);
-webkit-border-radius: 1ex;
}

Wednesday, January 21, 2015

Add Ajax in Grid view YII

Standard


Here is simple example to how create  Ajax link on YII CGridview


array(
        'name'='Attribute name',
        'header'='Attribute title',
        'value'='CHtml::ajaxLink(
            "link",
             array("url/action"),
              array(
              "update"="#Ajaxvenu",
                 "type"="POST",
                     "data" =; array(
                     "POST[atttribute]" = $data->atttributename,

                       ),                              
                   ),

 )',

// view this 

Tuesday, December 30, 2014

Remove index.php from url YII

Standard



create .htaccess under www-->yiisitename 

add following code on .htaccess


Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

http://localhost/sitename/index.php   - default yii url

http://localhost/sitename/  - now run like this

Wednesday, December 17, 2014

datetime - How to Minus & pluse two dates in php

Standard

How do I return the  date as pulse & Minus?

add days


 
                    $date=date_create(date("Y-m-d"));
                    date_add($date,date_interval_create_from_date_string("10 days"));
                    echo date_format($date,"Y-m-d"); 
Minus days
 
                   $mydate = date("Y-m-d");

$lastday = strtotime("-1 days", strtotime($mydate));

echo date("Y-m-d", $lastday);

Tuesday, December 16, 2014

create CSV report in DB data YII

Standard

hi guys this is my testing code about yii  CSV report i created data table name as deal  and i created Deal control & crud

this is my data table



CREATE TABLE IF NOT EXISTS `deals` (
  `DealId` int(11) NOT NULL AUTO_INCREMENT,
  `DealName` varchar(255) NOT NULL,
  `Dealdescription` text NOT NULL,
  `Price` int(11) NOT NULL,
  `Discount` float NOT NULL,
  `StartingDate` varchar(50) NOT NULL,
  `EndingDate` varchar(50) NOT NULL,
  `DealCategory` varchar(45) NOT NULL,
  `DriverId` int(11) NOT NULL,
  `CreateDate` datetime NOT NULL,
  `ModifiedDate` datetime NOT NULL,
  `Status` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`DealId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

this is my report funtion in deal controller


condition = "DealId=".$DealId;
                                    $models=  Deals::model()->findAll($criteria);
                                   // echo '
'.  print_r($models,1).'
'; // die(); // Pick a filename and destination directory for the file // Remember that the folder where you want to write the file has to be writable $filename =Yii::getPathOfAlias('webroot').'/report/'.$DealId.'_report_by_'.$DealId.".csv"; // Actually create the file // The w+ parameter will wipe out and overwrite any existing file with the same name $handle = fopen($filename, 'w+'); // Write the spreadsheet column titles / labels fputcsv($handle, array( 'Dea lId', 'Deal Name', 'Deal description', 'Price', 'Discount', 'Start Date', 'EndDate', 'Deal Category', 'Driver Name', 'Status', )); foreach($models as $row) { fputcsv($handle, array ( $row['DealId'], $row['DealName'], $row['Dealdescription'], $row['Price'], $row['Discount'], $row['StartingDate'], $row['EndingDate'], $row['DealCategory'], $row['DriverId'], $row['Status'], )); } // Finish writing the file fclose($handle); $this->redirect(Yii::app()->getBaseUrl(true).'/report/'.$DealId.'_report_by_'.$DealId.'.csv', array('target'=>'_blank')); } $this->render('report',array( 'report'=>$report, )); } }
then i add report.php in view deal folder
add following code in report.php
actionReport(1);

?>
now you can get csv file

thank

Monday, December 8, 2014

YII ACCESS RULES from data base

Standard

this is represent haw add user access for specific users in to page

i have 2 table 

  1. 1.user table
  2. 2.user level table

user table


CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(20) NOT NULL,
  `password` varchar(128) NOT NULL,
  `email` varchar(128) NOT NULL,
  `Telephone` varchar(12) NOT NULL,
  `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ModifiedDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `lastvisit_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `superuser` int(1) NOT NULL DEFAULT '0',
  `UserLevel` int(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`),
  UNIQUE KEY `email` (`email`),
  KEY `status` (`status`),
  KEY `superuser` (`superuser`)
);

Userlevel table

CREATE TABLE IF NOT EXISTS `userlevels` (
  `UserLevelId` int(11) NOT NULL AUTO_INCREMENT,
  `UserLevels` varchar(45) DEFAULT NULL,
  `CreateDate` datetime NOT NULL,
  `ModifiedDate` datetime NOT NULL,
  `Status` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`UserLevelId`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `userlevels`
--

INSERT INTO `userlevels` (`UserLevelId`, `UserLevels`, `CreateDate`, `ModifiedDate`, `Status`) VALUES
(0, 'Guest', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0'),
(1, 'Admin', '2014-06-16 09:10:23', '0000-00-00 00:00:00', '1'),
(2, 'Staff', '2014-12-10 00:00:00', '0000-00-00 00:00:00', '1');

i created Userrule.php file under protect -> components folder


class Userrule extends CWebModule
{
 

 static private $_getaccess;
        
        public static function getAccess($userlevel) {
            
            if(is_array($userlevel))
                {
                 if (!self::$_getaccess) 
                 {
                $criteria = new CDbCriteria;
               $criteria->addInCondition('UserLevel',$userlevel,true); 


//                $criteria->params = array(':userlevel' => $userlevel);
                //Apply To Model
                $usernames = Users::model()->findAll($criteria);
//                echo '
'.  print_r($usernames,1).'
'; // die(); $Access_name = array(); foreach ($usernames as $username) array_push($Access_name,$username->username); self::$_getaccess = $Access_name; } return self::$_getaccess; } else { if (!self::$_getaccess) { $criteria = new CDbCriteria; $criteria->condition = 'UserLevel='.$userlevel; //Apply To Model $usernames = Users::model()->findAll($criteria); $Access_name = array(); foreach ($usernames as $username) array_push($Access_name,$username->username); self::$_getaccess = $Access_name; } return self::$_getaccess; } } }

in above param function  define which user should be access

now you can call this function  in to accessRules() in every controller & add which user level will be access


public function accessRules()
 {
  return array(
   array('allow',  // allow all users to perform 'index' and 'view' actions
    'actions'=>array('index','view'),
    'users'=>  Userrule::getAccess(array(0,1,6)),//send as array
   ),
                        array('allow',  // allow all users to perform 'index' and 'view' actions
    'actions'=>array('create'),
//    'users'=>  Userrule::getAccess(1),
                                'users'=>  Userrule::getAccess(array(1,6)),//send as array
//                            'users'=>array('admin','channa'),
   ),
   array('allow', // allow admin user to perform 'admin' and 'delete' actions
//    'actions'=>array('admin','delete'),
    'actions'=>array('delete','update'),
                            'users'=>  Userrule::getAccess(1),//send as variable
   ),
   array('deny',  // deny all users
    'users'=>array('*'),
   ),
  );
 }

sd

Friday, December 5, 2014

Yii User access rules

Standard



this for YII USER MODULE
Load and store the user's data every time a page is requested. To do this, modify the Controller class as follows:
i added this on  compound controller becouse  All controller classes for this application should extend from this base class.





          public function isGuest() {
            $user=User::model()->active()->findbyPk(Yii::app()->user->id);
//            print_r($user->superuser);
            if($user->superuser==0)
            {throw new CHttpException(403, 'You have no permission to view this content');}
           
            return UserModule::isAdmin();
        }

add this expression for all accessRules

 public function accessRules()
 {
            return array(

            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                        'actions'=>array('index','view','delete', 'admin'),
                        'expression'=> $this->isAdmin(),
                        ),
                       
            );
 }



Thursday, December 4, 2014

YII Send Email & get Template content from database Part -2

Standard



i created template folder on view & create file name as user_registation.php


sample email template by channa smcs

add add this site controll In code comment u can get basic undestand about what i did

public function actionEmail()
 { 
//            echo '
'.(print_r($_POST,1)).'
'; if(isset($_POST)) { // get data on variable by channa $variables=array( '{fname}'=>'channa', '{lname}'=>'bandara', '{email}'=>'channasmcs@gmail.com', '{dob}'=>'1989-01-01', '{password}'=>'thisiamy password', ); // get template using template name by channa $templatedata= self::getemailtemple('User Registration Template') ;// function in controller(configuration) // get template data in to variable by channa $description=$templatedata->description; $subject=$templatedata->subject; // send $description $description to VariableReplaceArray by channa $emailbody= $this->VariableReplaceArray($description, $variables) ; //function in controller(configuration) // send email detail to templte using renderPartial by channa $emailbodydetail=array( 'emailbodydetail'=>$emailbody, ); // send message detail to template by channa $messageUser = $this->renderPartial('/template/user_register',$emailbodydetail,true); // set up email configuration by channa $name = 'channa'; $email = 'hellochannasmcs@gmail.com'; $Telephone = '0715977097'; $to = 'hellochannasmcs@hotmail.com'; $subject = $subject; $messageAdmin = "Deal Admin"; self::email($name, $email, $subject, $messageUser); self::email($name, $email, $subject, $messageAdmin, TRUE); // // echo '
'.(print_r($messageUser,1)).'
'; // echo '
'.(print_r($messageAdmin,1)).'
'; } // $this->renderPartial('/template/view'); $this->render('email'); } }
i added  this on controoler file in configuration folder


//        get email template from database by channa
         public static function getemailtemple($temppalatename) {
            
             return $templatedetail=  Emailtemplate::model()->find("name='".$temppalatename."'");
            
        }
  // repalce variable syntex related with initialz input by channa
        
                public function VariableReplaceArray($message,$variables) 
                {
//                    print_r($variable);
                    
                     $getvariableArray=array_keys($variables);
                     $replacevariableArray=array_values($variables);
                     return str_replace($getvariableArray,$replacevariableArray,$message);
                }
        

YII Send Email & get Template content from database Part -1

Standard


in priviouse blog  make send user email & admin email .
in this blog i coding sent email using email template  & get email content from data base .

1.create email template table to insert email data




CREATE TABLE IF NOT EXISTS `emailtemplate` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(55) NOT NULL,
  `variables` varchar(255) NOT NULL,
  `subject` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `status` enum('1','0') NOT NULL DEFAULT '1' COMMENT '0=inactive,1=active',
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
);

then  i created back end data manage option in my web site back end ..pretty cool



insert data like this 



INSERT INTO `emailtemplate` (`id`, `name`, `variables`, `subject`, `description`, `status`) VALUES
(1, 'User Registration Template', '{fname},{lname},{email},{dob}{password}', 'User Registration', '\r\n Thank You Regiter With Us ....

\r\n\r\n After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.

\r\n
\r\n Your name : {fname} {lname}
\r\n
\r\n Email : {email}
\r\n
\r\n DOB: {dob}
\r\n
\r\n Password: {password}
\r\n
\r\n Thank you
\r\n
\r\n Stream line staff
\r\n', '1');
now back end look like this


i initialize variable for uni q detail variable is static & we can use it globally

                   please see        Part -2



send email YII

Standard



In this tutorial, how to send user email & admin email .most developers are doesn't like  use extension i think that is good because that extension may be  have unnecessary things we need .but extension  is very helpful for reduce our coding time  .for this complete mr. gayan senjeewa  help  & i really appreciate for that .thanks 

here code

i used to controller file on components folder because.All controller classes for this application should extend from this base class.

this is main email sending function .add this on  controller 



 
//Controller in confuguration
 public static function email($userName, $userEmail, $subject, $message, $toAdmin = FALSE, $isCC = FALSE) {
            $subject='=?UTF-8?B?'.base64_encode($subject).'?=';
            $to = '';
            $from = '';
            $cc = '';
            
            if ($toAdmin) {
                $to = 'admin@mail.com';//admin Email
                $from = 'supportemail@mail.com'; //support user email for 

                
            } else {
                $to = $userEmail;
                $from =  'admin@mail.com';//admin Email
            }
            
            if($isCC) {
                $headers="From: <{$from}>\r\n".
                        "Cc: {$from}\r\n".
                        "Reply-To: {$from}\r\n".
                        "MIME-Version: 1.0\r\n".
                        "Content-Transfer-Encoding: 8bit\r\n".
                        "Content-Type: text/html; charset=ISO-8859-1\r\n";
            } else {
                $headers="From: <{$from}>\r\n".
                        "Reply-To: {$from}\r\n".
                        "MIME-Version: 1.0\r\n".
                        "Content-Transfer-Encoding: 8bit\r\n".
                        "Content-Type: text/html; charset=ISO-8859-1\r\n";
            }
            
            return mail($to, $subject,$message,$headers);
        }

i update actionContact funtion


 public function actionContact()
 {
  $model=new ContactForm;
  if(isset($_POST['ContactForm']))
  {

//   $model->attributes=$_POST['ContactForm'];
   if($model->validate())
   {
//    $name='=?UTF-8?B?'.base64_encode($model->name).'?=';
//    $subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';
//    $headers="From: $name <{$model->email}>\r\n".
//     "Reply-To: {$model->email}\r\n".
//     "MIME-Version: 1.0\r\n".
//     "Content-Type: text/plain; charset=UTF-8";
//
//    mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers);
//    
                $name = $model->name;
                $email = $model->email;
                $Telephone = '0715977097';
                $to = 'admin@mail.com';
                $subject = $model->subject;
                    
                $messageUser = "Thank you for contacting us";
                      
                $messageAdmin = "
                Deal Admin,   
                
                you have email from   $model->name from $model->email
        
                $model->body
                thank you
                    
                ";
                self::email($name, $email, $subject, $messageUser);//send mail to user
                self::email($name, $email, $subject, $messageAdmin, TRUE);//send mail to admin  
    Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
    $this->refresh();
   }
  }
  $this->render('contact',array('model'=>$model));
 }

Monday, December 1, 2014

get image on Gridview YII

Standard




in this  you can call image view on YII grid view


<!--
 

 widget('zii.widgets.grid.CGridView', array( 
                'id'=>'modelname-grid',
                'dataProvider'=>$media->search(),
                'filter'=>$media,
                'columns'=>array(
//          'id',
                        array(       
                                    'name'=>'url',
                                    'header'=>'url ',
                                    'value'=>'CHtml::image(Yii::app()->request->baseUrl."/images/media/".$data->url,
                                     "",
                                     array(\'width\'=>100, \'height\'=>60))',
                                     'type'=>'raw',
                                ),
  'name',
  'createdate',
                        array(
                                'class'=>'CButtonColumn',
                                'template'=>'{delete}',
                        ),
                ),
        )); ?>





Thursday, November 27, 2014

Yii Gridview CButton style

Standard




This  code shows about how to add a custom button with your own icon for your CGridView of Yii framework.“view”, “update”, “delete” button and it have corresponding actions. We can change it using CButtonColumn properties.




 widget('zii.widgets.grid.CGridView', array(
                'id'=>'modelname-grid',
                'dataProvider'=>$model->search(),
                'filter'=>$model,
                'columns'=>array(
          'rowname1',
  'rowname2',  
                        array(
                                'class'=>'CButtonColumn',
                                'template'=>'{view}{update}{delete}',
                            'deleteButtonImageUrl' => Yii::app()->theme->baseUrl .'/images/'.'close-button.png',
                            'deleteButtonOptions'=>array(
                                    'class'=>'delete_class',
                                    'id'=>'delete_id',
                                    ),
                            'updateButtonImageUrl' => Yii::app()->theme->baseUrl .'/images/'.'edit-button.png',
                            'updateButtonOptions'=>array(
                                    'class'=>'update_class',
                                    'id'=>'update_id',
                                    ),
                            'viewButtonImageUrl' => Yii::app()->theme->baseUrl .'/images/'.'view-button.png',
                            'viewButtonOptions'=>array(
                                    'class'=>'view_class',
                                    'id'=>'view_id',
                                    ),

                        ),
                ),
        )); ?>


 

if you want add this in YII framework follow this

open \CButtonColumn.php

..\yii\framework\zii\widgets\grid\CButtonColumn.php

defult code[line 215] function initDefaultButtons()

 


protected function initDefaultButtons()
 {
  if($this->viewButtonLabel===null)
   $this->viewButtonLabel=Yii::t('zii','View');
  if($this->updateButtonLabel===null)
   $this->updateButtonLabel=Yii::t('zii','Update');
  if($this->deleteButtonLabel===null)
   $this->deleteButtonLabel=Yii::t('zii','Delete');
  if($this->viewButtonImageUrl===null)
   $this->viewButtonImageUrl=$this->grid->baseScriptUrl.'/view.png';
  if($this->updateButtonImageUrl===null)
   $this->updateButtonImageUrl=$this->grid->baseScriptUrl.'/update.png';
  if($this->deleteButtonImageUrl===null)
   $this->deleteButtonImageUrl=$this->grid->baseScriptUrl.'/delete.png';
   
   
}   


 


update code function initDefaultButtons()

 


protected function initDefaultButtons()
 {
  if($this->viewButtonLabel===null)
   $this->viewButtonLabel=Yii::t('zii','View');
  if($this->updateButtonLabel===null)
   $this->updateButtonLabel=Yii::t('zii','Update');
  if($this->deleteButtonLabel===null)
   $this->deleteButtonLabel=Yii::t('zii','Delete');
  if($this->viewButtonImageUrl===null)
   $this->viewButtonImageUrl=Yii::app()->theme->baseUrl .'/images/'.'view-button.png';                
  if($this->updateButtonImageUrl===null)
   $this->updateButtonImageUrl=Yii::app()->theme->baseUrl .'/images/'.'edit-button.png';
  if($this->deleteButtonImageUrl===null)
   $this->deleteButtonImageUrl=Yii::app()->theme->baseUrl .'/images/'.'close-button.png';
   
   
}   



Sharp AQUOS Android Smartphone

Standard


Sharp Corporation collaborated with frog's team of designers and technologists to create “Feel UX”, a new Android smartphone experience that is easy to use, highly personalized, and visually stunning.










STUNNING 3D REALISM ON SCREENThe AQUOS Phone's parallax barrier system—which imitates the parallax difference between our right and left eye—enables the display of vivid three-dimensional HD images without the need for glasses. The phone recognises if content is 2D or 3D at playback, and adjusts accordingly. You can even convert 2D images into 3D, and vice versa, simply by switching the parallax barrier on or off.


Experience a new level of brilliance with Sharp's 4.2-inch LCD and ProPix image processor—technology derived from our line of AQUOS TVs. Boasting 540 x 960p qHD resolution—a quarter that of full 1920 x 1080p HD—the wide screen gives greater dynamic impact to movies and gameplay.
You'll no longer need to zoom in when browsing the internet, with the LCD's outstanding resolution making small text easier to read.




Software features
Some of the Aquos Crystal's unique software features include a gesture motion called "Clip Now." In addition to holding the bottom volume key and power button to take a screenshot, users can swipe the top edge of the display and save screenshots into a Clip Now image folder.














Get Country of IP Address with PHP

Standard





I'm trying to put together a PHP script that I can query from any web browser and it returns the Country of the IP address that accessed the PHP script


There are various web APIs that will do this for you. Here's an example using http://ipinfo.io:


          $ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
echo $details;

  








 Here's an example using http://www.geoplugin.net/json.gp





$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip={$ip}"));
echo $details;

      







Wednesday, November 26, 2014

YII Add Loading IMAGE on ajex

Standard



beginWidget('CActiveForm', array(
                                        'id'=>'listings-getdata_Ajax',                                    
                                        'enableAjaxValidation'=>FALSE,
                                )); ?>
             
                   params['Radius'],
                             array(
                               'ajax'=>array(
                                 'type'=>'POST',
                                  'url'=>CController::createUrl('listings/getdata_Ajax'),                            
                                    'update'=>'#getdata',
                                   'data' => array(
                                        'Getdata[radius]'=>'js:this.value',
                                        'Getdata[city]'=>$model->PhysicalCity,
                                             )
                                     ),
                                    'class'=>'form-control input-sm',
                                     'empty'=>'Select Province',
                                    'required'=>TRUE,
                                     )
                                    );
                        ?>
                        clientScript->registerScript('loaderScript', '
                             $("#loader")
                             .hide()
                             .ajaxStart(function() {
                                 $(this).show();
                             })
                             .ajaxStop(function() {
                                 $(this).hide();
                             });', CClientScript::POS_END);
                         ?>

                    theme->baseUrl.'/images/loader.gif', '', array('id' => 'loader', 'style' => ''));?>
             


 public function actionGetdata_Ajax()
             
 {
      echo 'hello';
        }
             

      

create div stick to top when scrolled

Standard
There are times when you would want to display a DIV bar at the top of the page when your scrolls on the page top or down  and it should go back to its original position when the user scrolls back up.
jQuery code:

/ executed when the viewr scrolls the page.
$(window).scroll(function(e) {
    // Get the position of the location where the scroller starts.
    var scroller_anchor = $(".scroller_anchor").offset().top;
     
    // Check if the user has scrolled and the current position is after the scroller start location and if its not already fixed at the top
    if ($(this).scrollTop() >= scroller_anchor && $('.scroller').css('position') != 'fixed')
    {    // Change the CSS of the scroller to hilight it and fix it at the top of the screen.
        $('.scroller').css({
            'background': '#CCC',
            'border': '1px solid #000',
            'position': 'fixed',
            'top': '0px'
        });
        // Changing the height of the scroller anchor to that of scroller so that there is no change in the overall height of the page.
        $('.scroller_anchor').css('height', '50px');
    }
    else if ($(this).scrollTop() < scroller_anchor && $('.scroller').css('position') != 'relative')
    {    // If the user has scrolled back to the location above the scroller anchor place it back into the content.
         
        // Change the height of the scroller anchor to 0 and now we will be adding the scroller back to the content.
        $('.scroller_anchor').css('height', '0px');
         
        // Change the CSS and put it back to its original position.
        $('.scroller').css({
            'background': '#FFF',
            'border': '1px solid #CCC',
            'position': 'relative'
        });
    }
});

             

      
HTML Code:
What if drugs were legal? Could you imagine what it would do to our society? Well according to John E. LeMoult, a lawyer with twenty years of experience on the subject, feels we should at least consider it. I would like to comment on his article "Legalize Drugs" in the June 15, 1984, issue of the New York Times. I disagree with LeMoult's idea of legalizing drugs to cut the cost of crime.
This is the scrollable bar
What if drugs were legal? Could you imagine what it would do to our society? Well according to John E. LeMoult, a lawyer with twenty years of experience on the subject, feels we should at least consider it. I would like to comment on his article "Legalize Drugs" in the June 15, 1984, issue of the New York Times. I disagree with LeMoult's idea of legalizing drugs to cut the cost of crime.
CSSCode:

.container{font-size:14px; margin:0 auto; width:960px}
.test_content{margin:10px 0;}
.scroller_anchor{height:0px; margin:0; padding:0;}

.scroller{background:#FFF; border:1px solid #CCC; margin:0 0 10px; z-index:100; height:50px; font-size:18px; font-weight:bold; text-align:center; width:960px;}