Thursday, 13 February 2020

Sesssion Message display in codeigniter

<div class="clearfix"></div>

<?php echo ($this->session->flashdata('msg')?$this->session->flashdata('msg'):'')?>


Alert Message HTML  :  https://getbootstrap.com/docs/4.0/components/alerts/
<div class="alert alert-primary" role="alert">
  This is a primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
  This is a secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
  This is a success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
  This is a danger alert—check it out!
</div>
<div class="alert alert-warning" role="alert">
  This is a warning alert—check it out!
</div>
<div class="alert alert-info" role="alert">
  This is a info alert—check it out!
</div>
<div class="alert alert-light" role="alert">
  This is a light alert—check it out!
</div>
<div class="alert alert-dark" role="alert">
  This is a dark alert—check it out!
</div>

Form tag in codeigniter

<?php echo form_open('administration/Home/addSettingCode',array("id"=>"myform","class"=>"form-horizontal form-label-left","enctype"=>"multipart/form-data"));?>
 <input type="hidden" name="id" value="<?php echo (isset($settingData->id) && $settingData->id!=''?$settingData->id:'')?>">
 <input type="hidden" name="old_path" value="<?php echo (isset($settingData->logo) && $settingData->logo!=''?$settingData->logo:'')?>">



<div class="col-md-12">
                                                <div class="position-relative form-group">
                                                  <label for="examplePassword" class=""><span class="text-danger">*</span> About Us </label>
 <script src="//cdn.ckeditor.com/4.4.7/full/ckeditor.js"></script>
                                                                  <textarea rows="5" name="s8" id="s8" class="form-control" placeholder="Enter About Us" required><?php echo (isset($settingData->s8) && $settingData->s8!=''?$settingData->s8:'')?></textarea>
                                             <script>
                                                CKEDITOR.replace('s8', {
                                                  // Define the toolbar groups as it is a more accessible solution.
                                                  toolbarGroups: [{
                                                      "name": "basicstyles",
                                                      "groups": ["basicstyles"]
                                                    },
                                                    {
                                                      "name": "links",
                                                      "groups": ["links"]
                                                    },
                                                    {
                                                      "name": "paragraph",
                                                      "groups": ["list", "blocks"]
                                                    },
                                                    {
                                                      "name": "styles",
                                                      "groups": ["styles"]
                                                    }
                                                 
                                                  ],
                                                  // Remove the redundant buttons from toolbar groups defined above.
                                                  removeButtons: 'Underline,Strike,Subscript,Superscript,Anchor,Styles,Specialchar'
                                                });
                                              </script>

                                                </div>
                                            </div>



  <?php echo form_close();?>

Tuesday, 11 February 2020

Export Mysql Data to CSV File in Codeigniter

Controllers :

public function exportCSV(){
     
        $myData = $this->Home_model->getexportCSV();

        // file name
        $filename = 'User_Data'.date('Ymd').'.csv';
        header("Content-Description: File Transfer");
        header("Content-Disposition: attachment; filename=$filename");
        header("Content-Type: application/csv; ");

        // file creation
        $file = fopen('php://output', 'w');

        $header = array("Mobile","Name");
        fputcsv($file, $header);

        foreach ($myData as $line){
            fputcsv($file,array($line->mobile,$line->name));
        }

        fclose($file);
        exit;
    }




Model :


public function getexportCSV(){
$sql=$this->db->query(" SELECT * FROM  `user`   ");
return $sql->result();

}

Saturday, 8 February 2020

date format jquery datepicker

<!------ date picker ]  -------->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
var jq = jQuery.noConflict();

jq(function() {

jq(".datepic").datepicker({

dateFormat: "yy-mm-dd",

yearRange: '1950:2050',

changeMonth: true,

changeYear: true
});

});
</script>
<!------ date picker ]  -------->

sms api set in codeigniter

CONSTANTS.PHP

/* custom development */
define('SMS_URL','http://sms.xxxxxxx.in/submitsms.jsp?');
define('SMS_USER','xxxxxxxxx');
define('SMS_KEY','xxxxxxx');
define('SMS_SENDER_ID','xxxxxxx');
define('SMS_SUPPORT_NO','1234567891');

/* custom development */


controller 

if($insertCheck=='1'){
$this->session->set_flashdata('msg', '<p class="alert alert-success">Your request has been sent successfully.</p>');

/* sms */
$mobile = SMS_SUPPORT_NO;
$message = "New Suggestion/Problem Received\n
Name : ".$this->input->post('name')."
Mobile : ".$this->input->post('mobile')."
Ward No :  ".$this->input->post('ward')."
\n\n:: Apna Roopangarh ::";
$this->Home_model->SendUnicodeSms($mobile,$message);

$mobile_user = $this->input->post('mobile');
$message_user = "आपकी शिकायत / सुझाव हमें प्राप्त हो गए हैं
\nजल्द ही हम आपसे संपर्क करेंगे
\nग्राम पंचायत रुपनगढ़";
$this->Home_model->SendUnicodeSms($mobile_user,$message_user);
/* sms */

}

Models

public function SendSms($mobiles,$message){

 
$key=SMS_KEY;  //   
$user=SMS_USER;    //
$senderid = SMS_SENDER_ID;

/*  sms */
$ch = curl_init();                    // initiate curl
$url = SMS_URL; // where you want to post data
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);  // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&key=$key&mobile=$mobiles&message=$message&senderid=$senderid&accusage=1"); // NTFSMS , INFOSM, ROZGAR,define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
//curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Accept-Language: hi;q=0.5"));
$output = curl_exec ($ch); // execute
//echo $status = curl_getinfo($ch);
//print_r($output);
curl_close ($ch); // close curl handle
//var_dump($output); // show output
/*   sms  */


             
}


public function SendUnicodeSms($mobiles,$message){

 
$key=SMS_KEY;  //   
$user=SMS_USER;    //
$senderid = SMS_SENDER_ID;


$ch = curl_init();  // initiate curl
$url = SMS_URL; // where you want to post data
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);  // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&key=$key&mobile=$mobiles&message=$message&senderid=$senderid&accusage=1&unicode=1"); // NTFSMS , INFOSM, ROZGAR,define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
//curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Accept-Language: hi;q=0.5"));
$output = curl_exec ($ch); // execute
//echo $status = curl_getinfo($ch);
//print_r($output);
curl_close ($ch); // close curl handle
//var_dump($output); // show output



             
}

Thursday, 6 February 2020

Email Format php



         $to = $_POST['admin_email'];  // jaha email jayega
         $subject = $_POST['admin_name']." : Contact";  // email subject

  $message = "<h1>".$_POST['admin_name']." : Contact </h1>";
  $message .= "<b>Name : ".$_POST['name']."</b><br/>";
  $message .= "<b>Mobile : ".$_POST['mobile']."</b><br/>";
  $message .= "<b>Email : ".$_POST['email']."</b><br/>";
  $message .= "<b>Message : </b><br/>";
  $message .= "".$_POST['message']."";

 
       
         $header = "From: ".$_POST['admin_email']." \r\n";  // jaha se email jayega
         $header .= "Cc:domin.help24@gmail.com \r\n";   // cc copy email
         $header .= "MIME-Version: 1.0\r\n";
         $header .= "Content-type: text/html\r\n";
       
         $retval = mail ($to,$subject,$message,$header);
       
         if( $retval == true ) {
            $msg =  "Message sent successfully...";
             
         }else {
           $msg =  "Message could not be sent...";
             
         }
 //echo $msg;

Sunday, 2 February 2020

Email Format Codeigniter


public function addContactCode(){

$from_email = "sunilkalla2011@gmail.com";  // jaha se email send hoga
        $to_email = $this->input->post('email');  // jisko email jana h
       
        $subject = "Alakhpurajharod : Enquiry";

$message = "<h1>Alakhpurajharod : Enquiry</h1>";
$message .= "<b>Name : ".$this->input->post('name')."</b><br/>";
$message .= "<b>Phone: ".$this->input->post('mobile')."</b><br/>";
$message .= "<b>Description : </b><br/>";
$message .= "".$this->input->post('message')."";

$header = "From:".$this->input->post('email')." \r\n";
$header1 = "MIME-Version: 1.0\r\n";
$header2 = "Content-type: text/html\r\n";

        //Load email library
        $this->load->library('email');
        $this->email->from($from_email, 'Identification');
        $this->email->to($to_email);
        $this->email->cc('sunilkalla2011@gmail.com');  // copy email id
        $this->email->cc('in.mukeshsaini@gmail.com');  // copy email id

        $this->email->subject($subject);
        $this->email->message($message);
     

        $this->email->set_header('MIME-Version', '1.0; charset=utf-8');
        $this->email->set_header('Content-type', 'text/html');


        //Send mail
        if($this->email->send()){
            $this->session->set_flashdata("email_sent","<p class='flashmessage'>Email Sent Successfully.</p>");
        }
        else{
            $this->session->set_flashdata("email_sent","<p class='flashmessage'>You have encountered an error</p>");
        }

redirect("home/index/#mail");
     

}



2 ----------------------------------------------------------------

if($data['result']) {
                $_SESSION['CartItem'] = '';
                $this->load->library('email');
                $fromemail="digicardindia2020@gmail.com";
                $toemail = $_POST['email'].",in.mukeshsaini@gmail.com,digicardindia2020@gmail.com";
                $subject = "Digi Card India : ".$_POST['bussiness'];
                $mesg = $this->load->view('front/order_confirm',$data,true);
                $_SESSION['CartItem'] = $mesg;
                $config=array(
                'charset'=>'utf-8',
                'mailtype' => 'html'
                );
                $this->email->initialize($config);
                $this->email->to($toemail);
                $this->email->from($fromemail, "Order Confirmation");
                $this->email->subject($subject);
                $this->email->message($mesg);
                $mail = $this->email->send();
                if($mail) {
                    $this->session->set_flashdata('msg', '<p class="alert alert-success">Thanks for your order.</p>');
                } else {
                   // echo 'not send';exit();
                }
           }