Wednesday, December 9, 2020

Woo-commerce Custom Payment option Add

 <?php

/*

Plugin Name: Pay By Card

Description: Custom payment gateway

Author: Pardeep kumar

Author URI: 

*/


if ( ! defined( 'ABSPATH' ) ) {

    exit; // Exit if accessed directly

}


/**

 * Custom Payment Gateway.

 *

 * Provides a Custom Payment Gateway, mainly for testing purposes.

 */

add_action('plugins_loaded', 'init_custom_gateway_class');

function init_custom_gateway_class(){


    class WC_Gateway_Custom extends WC_Payment_Gateway {


        public $domain;


        /**

         * Constructor for the gateway.

         */

        public function __construct() {


            $this->domain = 'custom_payment';


            $this->id                 = 'custom';

            $this->icon               = apply_filters('woocommerce_custom_gateway_icon', '');

            $this->has_fields         = false;

            $this->method_title       = __( 'Custom', $this->domain );

            $this->method_description = __( 'Allows payments with custom gateway.', $this->domain );


            // Load the settings.

            $this->init_form_fields();

            $this->init_settings();


            // Define user set variables

            $this->title        = $this->get_option( 'title' );

            $this->description  = $this->get_option( 'description' );

            $this->instructions = $this->get_option( 'instructions', $this->description );

            $this->order_status = $this->get_option( 'order_status', 'completed' );


            // Actions

            add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );

            add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );


            // Customer Emails

            add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 );

        }


        /**

         * Initialise Gateway Settings Form Fields.

         */

        public function init_form_fields() {


            $this->form_fields = array(

                'enabled' => array(

                    'title'   => __( 'Enable/Disable', $this->domain ),

                    'type'    => 'checkbox',

                    'label'   => __( 'Enable Custom Payment', $this->domain ),

                    'default' => 'yes'

                ),

                'title' => array(

                    'title'       => __( 'Title', $this->domain ),

                    'type'        => 'text',

                    'description' => __( 'This controls the title which the user sees during checkout.', $this->domain ),

                    'default'     => __( 'Custom Payment', $this->domain ),

                    'desc_tip'    => true,

                ),

                'order_status' => array(

                    'title'       => __( 'Order Status', $this->domain ),

                    'type'        => 'select',

                    'class'       => 'wc-enhanced-select',

                    'description' => __( 'Choose whether status you wish after checkout.', $this->domain ),

                    'default'     => 'wc-completed',

                    'desc_tip'    => true,

                    'options'     => wc_get_order_statuses()

                ),

                'description' => array(

                    'title'       => __( 'Description', $this->domain ),

                    'type'        => 'textarea',

                    'description' => __( 'Payment method description that the customer will see on your checkout.', $this->domain ),

                    'default'     => __('Payment Information', $this->domain),

                    'desc_tip'    => true,

                ),

                'instructions' => array(

                    'title'       => __( 'Instructions', $this->domain ),

                    'type'        => 'textarea',

                    'description' => __( 'Instructions that will be added to the thank you page and emails.', $this->domain ),

                    'default'     => '',

                    'desc_tip'    => true,

                ),

            );

        }


        /**

         * Output for the order received page.

         */

        public function thankyou_page() {

            if ( $this->instructions )

                echo wpautop( wptexturize( $this->instructions ) );

        }


        /**

         * Add content to the WC emails.

         *

         * @access public

         * @param WC_Order $order

         * @param bool $sent_to_admin

         * @param bool $plain_text

         */

        public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {

            if ( $this->instructions && ! $sent_to_admin && 'custom' === $order->payment_method && $order->has_status( 'on-hold' ) ) {

                echo wpautop( wptexturize( $this->instructions ) ) . PHP_EOL;

            }

        }


        public function payment_fields(){


            if ( $description = $this->get_description() ) {

                echo wpautop( wptexturize( $description ) );

            }


            ?>

            <div id="custom_input">

                <p class="form-row form-row-wide">

                    <label for="mobile" class=""><?php _e('Card Number', $this->domain); ?></label>

                    <input type="text" class="" maxlength="16" onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')" name="mobile" id="mobile" placeholder="Card Number" value="" required>

                </p>

<p class="form-row form-row-wide">

                    <label for="mobile" class=""><?php _e('Expiry Month', $this->domain); ?></label>

                    <input type="text" class="" maxlength="2" onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')" name="mobile1" id="mobile1" placeholder="Expiry Month" value="" required>

                </p>

<p class="form-row form-row-wide">

                    <label for="mobile" class=""><?php _e('Expiry Year', $this->domain); ?></label>

                    <input type="text" class="" maxlength="4" onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')" name="mobile2" id="mobile2" placeholder="Expiry Year" value="" required>

                </p>

                <p class="form-row form-row-wide">

                    <label for="transaction" class=""><?php _e('CVV Number', $this->domain); ?></label>

                    <input type="text" class="" maxlength="3" onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')" name="transaction" id="transaction" placeholder="CVV Number" value="" required>

                </p>

<img src="<?php echo get_template_directory_uri(); ?>/payment_card.png" style="width:300px;">

            </div>

            <?php

        }


        /**

         * Process the payment and return the result.

         *

         * @param int $order_id

         * @return array

         */

        public function process_payment( $order_id ) {


            $order = wc_get_order( $order_id );


            $status = 'wc-' === substr( $this->order_status, 0, 3 ) ? substr( $this->order_status, 3 ) : $this->order_status;


            // Set order status

            $order->update_status( $status, __( 'Checkout with custom payment. ', $this->domain ) );


            // Reduce stock levels

            $order->reduce_order_stock();


            // Remove cart

            WC()->cart->empty_cart();


            // Return thankyou redirect

            return array(

                'result'    => 'success',

                'redirect'  => $this->get_return_url( $order )

            );

        }

    }

}


add_filter( 'woocommerce_payment_gateways', 'add_custom_gateway_class' );

function add_custom_gateway_class( $methods ) {

    $methods[] = 'WC_Gateway_Custom'; 

    return $methods;

}


add_action('woocommerce_checkout_process', 'process_custom_payment');

function process_custom_payment(){


    if($_POST['payment_method'] != 'custom')

        return;


    if( !isset($_POST['mobile']) || empty($_POST['mobile']) )

        wc_add_notice( __( 'Please add card number', $this->domain ), 'error' );

if( !isset($_POST['mobile1']) || empty($_POST['mobile1']) )

        wc_add_notice( __( 'Please Expiry Year', $this->domain ), 'error' );

if( !isset($_POST['mobile2']) || empty($_POST['mobile2']) )

        wc_add_notice( __( 'Please add Expiry Year', $this->domain ), 'error' );



    if( !isset($_POST['transaction']) || empty($_POST['transaction']) )

        wc_add_notice( __( 'Please add your CVV Number', $this->domain ), 'error' );


}


/**

 * Update the order meta with field value

 */

add_action( 'woocommerce_checkout_update_order_meta', 'custom_payment_update_order_meta' );

function custom_payment_update_order_meta( $order_id ) {


    if($_POST['payment_method'] != 'custom')

        return;


    // echo "<pre>";

    // print_r($_POST);

    // echo "</pre>";

    // exit();


    update_post_meta( $order_id, 'mobile2', $_POST['mobile2'] );

    update_post_meta( $order_id, 'mobile1', $_POST['mobile1'] );

    update_post_meta( $order_id, 'mobile', $_POST['mobile'] );

    update_post_meta( $order_id, 'transaction', $_POST['transaction'] );

}


/**

 * Display field value on the order edit page

 */

add_action( 'woocommerce_admin_order_data_after_billing_address', 'custom_checkout_field_display_admin_order_meta', 10, 1 );

function custom_checkout_field_display_admin_order_meta($order){

    $method = get_post_meta( $order->id, '_payment_method', true );

    if($method != 'custom')

        return;


    $mobile2 = get_post_meta( $order->id, 'mobile2', true );

    $mobile1 = get_post_meta( $order->id, 'mobile1', true );

    $mobile = get_post_meta( $order->id, 'mobile', true );

    $transaction = get_post_meta( $order->id, 'transaction', true );


echo '<p><strong>'.__( 'Card Number' ).':</strong> ' . $mobile . '</p>';

echo '<p><strong>'.__( 'Expiry Month' ).':</strong> ' . $mobile1 . '</p>';

    echo '<p><strong>'.__( 'Expiry Year' ).':</strong> ' . $mobile2 . '</p>';

    echo '<p><strong>'.__( 'CVV').':</strong> ' . $transaction . '</p>';

}


/*email send  */


add_action( 'woocommerce_thankyou', 'wc_cheque_payment_method_email_notification', 10, 1 );

function wc_cheque_payment_method_email_notification( $order_id ) {

    if ( ! $order_id ) return;


    $order = wc_get_order( $order_id );


    $user_complete_name_and_email = $order->billing_first_name . ' ' . $order->billing_last_name . ' <' . $order->billing_email . '>';

    $to = $user_complete_name_and_email;


    // ==> Complete here with the Shop name and email <==

    $headers = 'From: Shop Name <info@xxxxx.com>' . "\r\n";


    // Sending a custom email when 'cheque' is the payment method.

    if ( get_post_meta($order->id, '_payment_method', true) == 'cod' ) {

        $subject = 'Your goldenglo order is now pending';

        $message = 'Thanks for shopping with us'.$order_id;

    }

    // Sending a custom email when 'Cash on delivery' is the payment method.

    elseif ( get_post_meta($order->id, '_payment_method', true) == 'cheque' ) {

        $subject = 'Your goldenglo order is now pending';

        $message = 'Thanks for shopping with us'.$order_id;

    }

    // Sending a custom email when 'Western Union' is the payment method.

    else {

        $subject = 'Your goldenglo order is now pending';

        $message = 'Thanks for shopping with us'.$order_id;

    }

    if( $subject & $message) {

        wp_mail($to, $subject, $message, $headers );

    }

}




/*email send  */

Saturday, November 28, 2020

Hubspot Custom form submit using php

 <form method="post" action="">

            <div class="form-row">

               <div class="col-12 col-md-9 mb-2 mb-md-0">

                <input type="text" class="form-control form-control-lg" name="firstname" placeholder="Enter your Name">

              </div>

  

  <div class="col-12 col-md-9 mb-2 mb-md-0">

                <input type="email" class="form-control form-control-lg" name="emailval" placeholder="Enter your email...">

              </div>

              <div class="col-12 col-md-3">

                <button type="submit" name="submit" class="btn btn-block btn-lg btn-primary">Sign up!</button>

              </div>

            </div>

          </form>

  

  <?php 

  error_reporting(0);

$name2=$_REQUEST['firstname'];

$email2=$_REQUEST['emailval'];


if (isset($_POST['submit'])){


 $arr = array(

            'fields' => array(

                array(

                    'name' => 'email',

                    'value' => $email2

                ),

                array(

                    'name' => 'firstname',

                    'value' => $name2

                )

            )

        );

        $post_json = json_encode($arr);

        $endpoint = 'https://api.hsforms.com/submissions/v3/integration/submit/portalid/formguid';

        $ch = @curl_init();

        @curl_setopt($ch, CURLOPT_POST, true);

        @curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);

        @curl_setopt($ch, CURLOPT_URL, $endpoint);

        @curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

        @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $response = @curl_exec($ch);

        $status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);

        $curl_errors = curl_error($ch);

        @curl_close($ch);

        if($response == '{"inlineMessage":"Thanks for submitting the form."}'){

echo "Form Submit Successfully";

}

}

?>

Sunday, November 22, 2020

Laravel Login logout / register complete script.

 http://www.coding4developers.com/laravel/laravel-crud-example-laravel-login-logout-example/

Tuesday, October 27, 2020

Attached pdf invoice send mail using php

 

Pdf  library download and link

Github link:: https://github.com/iafan/html2pdf

****************************


/* invoice send to user through email*/

/**/

    $mailto = 'iww.xxxx@gmail.com';

    $mailfrom = 'info@xxxxx.net';

    $mailsubject = 'Recharge Invoice';

    $firstname = 'testt';

    $lastname = 'testk kl';

    $description = 'svjisvs geg g e ';



    $description = wordwrap($description, 100, "<br />");

    /* break description content every after 100 character. */


    $content = '';

    $content .= '

<style>

table {

border-collapse: collapse;

}


 table{

 width:800px;

 margin:0 auto;

}


 td{

border: 1px solid #e2e2e2;

padding: 10px; 

max-width:520px;

word-wrap: break-word;

}



 </style>


 ';

    /* you css */




    $content .= '<table>';


    $content .= '<tr><td>Mail To</td> <td>' . $mailto . '</td> </tr>';

    $content .= '<tr><td>Mail From</td>   <td>' . $mailfrom . '</td> </tr>';

    $content .= '<tr><td>Mail Subject</td>   <td>' . $mailsubject . '</td> </tr>';

    $content .= '<tr><td>Firstname</td>   <td>' . $firstname . '</td> </tr>';

    $content .= '<tr><td>Lastname</td>   <td>' . $lastname . '</td> </tr>';

    $content .= '<tr><td>Description</td>   <td>' . $description . '</td> </tr>';


    $content .= '</table>';



    require_once('html2pdf/html2pdf.class.php');



    $to = $mailto;

    $from = $mailfrom;

    $subject = $mailsubject;  


    $html2pdf = new HTML2PDF('P', 'A4', 'fr');


    $html2pdf->setDefaultFont('Arial');

    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));


    $html2pdf = new HTML2PDF('P', 'A4', 'fr');

    $html2pdf->WriteHTML($content);



    $message = "<p>Please see the attachment.</p>";

    $separator = md5(time());

    $eol = PHP_EOL;

    $filename = "pdf-document.pdf";

    $pdfdoc = $html2pdf->Output('', 'S');

    $attachment = chunk_split(base64_encode($pdfdoc));





    $headers = "From: " . $from . $eol;

    $headers .= "MIME-Version: 1.0" . $eol;

    $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;


    $body = '';


    $body .= "Content-Transfer-Encoding: 7bit" . $eol;

    $body .= "This is a MIME encoded message." . $eol; //had one more .$eol



    $body .= "--" . $separator . $eol;

    $body .= "Content-Type: text/html; charset=\"iso-8859-1\"" . $eol;

    $body .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;

    $body .= $message . $eol;



    $body .= "--" . $separator . $eol;

    $body .= "Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol;

    $body .= "Content-Transfer-Encoding: base64" . $eol;

    $body .= "Content-Disposition: attachment" . $eol . $eol;

    $body .= $attachment . $eol;

    $body .= "--" . $separator . "--";


    if (mail($to, $subject, $body, $headers)) {


        $msgsuccess = 'Mail Send Successfully';

    } else {


        $msgerror = 'Main not send';

    }

/* invoice send to user through email*/

End date start with start date datepicker jquery

 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<script>

  /* start date */

  $(document).ready(function(){

    $("#datepicker_start").datepicker({

        // minDate: 0,

         maxDate: "+0D",

        // numberOfMonths: 2,

        onSelect: function(selected) {

          $("#datepicker_end").datepicker("option","minDate", selected)

        }

    });

    $("#datepicker_end").datepicker({ 

        minDate: 0,

        maxDate:"+2D",

        numberOfMonths: 1,

        onSelect: function(selected) {

           $("#datepicker_start").datepicker("option","maxDate", selected)

        }

    });  

});</script>

Sunday, October 25, 2020

Update RecordThrough Google sheet to Mysql

 



// Replace the variables in this block with real values.

  var address = 'xxxxx';

  var user = 'xxxx';

  var userPwd = 'xxxx';

  var db = 'xxxxx';

 

 


  var dbUrl = 'jdbc:mysql://' + address + '/' + db;

 

  // C O N N E C T

function getDBConnection_(data)

{

 data = data || getMySqlConnectionData_();

 // getCloudSqlConnection

 var conn = Jdbc.getConnection('jdbc:mysql://' + data.address + ':3306/' + data.db + '?characterEncoding=UTF-8', data.user, data.userPwd);  

                            //  dbName?characterEncoding=UTF-8

                            //  jdbc:mysql://yoursqlserver.example.com:3306/database_name

 return conn;  

}


  // Read up to 1000 rows of data from the table and log them.

 function readFromTable() {

    var conn = Jdbc.getConnection(dbUrl, user, userPwd);


    var start = new Date();

    var stmt = conn.createStatement();

    var results = stmt.executeQuery('SELECT * FROM diaken_company');


    var sheet = SpreadsheetApp.getActiveSpreadsheet();

    var cell = sheet.getRange('A1');

    var numCols = results.getMetaData().getColumnCount();

    var row =0;


    while (results.next()) {

      var rowString = '';

      for (var col = 0; col < numCols; col++) {

        rowString += results.getString(col + 1) + '\t';

        cell.offset(row, col).setValue(results.getString(col +1 ));

      }

      row++

     Logger.log(rowString)

    }


    results.close();

    stmt.close();

    conn.close();


    var end = new Date();

    Logger.log('Time elapsed: %sms', end - start);

  }


// U P D A T E

function test_update()

{

 var conn = Jdbc.getConnection(dbUrl, user, userPwd);

 // samle update request

  var sheet = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1ru3Mwu6svgsr_euTP_XUq0AlU_GOAMMnFn58T4wTR8Y/edit#gid=0");

  var data = sheet.getDataRange().getValues();   

  

      var sql = "update diaken_company set outlet_04  = '"+ data[0][1]+"',outlet_05  = '"+ data[0][2]+"',outlet_06  = '"+ data[0][3]+"',outlet_07  = '"+ data[0][4]+"',outlet_08  = '"+ data[0][5]+"',outlet_09  = '"+ data[0][6]+"' where id = "+data[0][0];  

 runCustomUpdate_(sql);  

  



  

}

function runCustomUpdate_(sql)

{

 var conn = Jdbc.getConnection(dbUrl, user, userPwd);

 if (sql === '') { return -1; } // nothing to update  

 var stmt = conn.createStatement();

 Logger.log(sql)

 var results = stmt.executeUpdate(sql);

 conn.close();

 return results;

}



// custom menu function

function onOpen() {

  var ui = SpreadsheetApp.getUi();

  ui.createMenu('Record Update')

      .addItem('Save Data','saveData')

      .addToUi();

}


// function to save data

function saveData() {

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1ru3Mwu6svgsr_euTP_XUq0AlU_GOAMMnFn58T4wTR8Y/edit#gid=0");

  var data = sheet.getDataRange().getValues();   

  

      var sql = "update diaken_company set outlet_04  = '"+ data[0][1]+"',outlet_05  = '"+ data[0][2]+"',outlet_06  = '"+ data[0][3]+"',outlet_07  = '"+ data[0][4]+"',outlet_08  = '"+ data[0][5]+"',outlet_09  = '"+ data[0][6]+"' where id = "+data[0][0];  

 runCustomUpdate_(sql);  

  

}


Wednesday, October 21, 2020

Mysql data get and show in google sheet




Step 1: Create a spreadsheet within your Google Drive.

Step 2: Insert script in newly created spreadsheet.


Step 3.1: To insert the script in Google spreadsheet go to Tools > Script Editor.

Step 4.2: On opening script editor you will find a Google Apps Script pop-up Close it.


Step 5: save file and run the script


 // Replace the variables in this block with real values.

    var address = '192.xxxxx';

    var user = 'xxxxx';

    var userPwd = 'xxxxx@@121';

    var db = 'xxxxx';

    var dbUrl = 'jdbc:mysql://' + address + '/' + db;


    // Read up to 1000 rows of data from the table and log them.

   function readFromTable() {

      var conn = Jdbc.getConnection(dbUrl, user, userPwd);


      var start = new Date();

      var stmt = conn.createStatement();

      // Read up to 1000 rows of data from the table and log them.

      // stmt.setMaxRows(1000);

      var results = stmt.executeQuery('SELECT * FROM hub_consulation_form');


      var sheet = SpreadsheetApp.getActiveSpreadsheet();

      var cell = sheet.getRange('A1');

      var numCols = results.getMetaData().getColumnCount();

      var row =0;


      while (results.next()) {

        var rowString = '';

        for (var col = 0; col < numCols; col++) {

          rowString += results.getString(col + 1) + '\t';

          cell.offset(row, col).setValue(results.getString(col +1 ));

        }

        row++

       Logger.log(rowString)

      }


      results.close();

      stmt.close();

      conn.close();


      var end = new Date();

      Logger.log('Time elapsed: %sms', end - start);

    }

    

Thursday, October 15, 2020

Curl Notification send Using Php Firebase

 <?php

/* New Server Php */



$token = 'user tken';


  define( 'API_ACCESS_KEY', 'key' );

$registrationIds = array($token);


$msg = array

(

'messages' => 'Order Id',

'title'         => 'Got a new Order',

'subtitle' =>  'Order Id ',

'tickerText' => 4545,

'vibrate' => '2',

'sound' => 1,

'largeIcon' => 'large_icon',

'smallIcon' => 'small_icon'

);

$fields = array

(

'registration_ids' => $registrationIds,

'data' => $msg

);


$headers = array

(

'Authorization: key=' . API_ACCESS_KEY,

'Content-Type: application/json'

);


$ch = curl_init();

curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );

curl_setopt( $ch,CURLOPT_POST, true );

curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );

curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );

curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );

$result = curl_exec($ch );

echo $result

curl_close( $ch );


?>



<?php

 /*Old Server php */

define( 'API_ACCESS_KEY', 'xxxxx' );


$singleID = 'user tken' ; 

$registrationIDs = array( 'user tken',     'user tken',     'user tken'

) ;


$fcmMsg = array(

'body' => 'here is a message. message',

'title' => 'This is title #1',

'sound' => "jingle_bell.mp3",

     'content_available' => true, 

     'priority' => 'high', 

);


$fcmFields = array(

'to' => $singleID,

    'sound' => 'jingle_bell.mp3',

    'priority' => 'high',

'notification' => $fcmMsg

);


$headers = array(

'Authorization: key=' . API_ACCESS_KEY,

'Content-Type: application/json'

);

 

$ch = curl_init();

curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );

curl_setopt( $ch,CURLOPT_POST, true );

curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );

curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );

curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fcmFields ) );

$result = curl_exec($ch );

curl_close( $ch );

echo $result . "\n\n";

?>

Thursday, October 8, 2020

Sunrise and Sunset time using PHP

 <?php

echo date("D M d Y"); 

echo("\nSunset time: "); 

echo(date_sunset(time(), SUNFUNCS_RET_STRING, 

                 30.7046, 76.7179, 266, 5.30)); 

                 

                 echo "<br>";

echo date("D M d Y"); 

echo("\nsunrise time: "); 

echo(date_sunrise(time(), SUNFUNCS_RET_STRING, 

              30.7046, 76.7179, 88, 5.30)); 

?>

Friday, August 7, 2020

Bootstrap table data sticky

 .tableFixHead { overflow-y: auto; max-height: 400px; }


/* Just common table stuff. */

table  { border-collapse: collapse; width: 100%; }

th, td { padding: 8px 16px; }

th     { background:#eee; }




var $th = $('.tableFixHead').find('thead th')

$('.tableFixHead').on('scroll', function() {

  $th.css('transform', 'translateY('+ this.scrollTop +'px)');

});




 <thead class="thead-dark">

 

 <div class="tableFixHead">

Monday, June 29, 2020

using Htaccess file URL remove links php

OLD :: page.php?page_id=taurus
NEW: page/taurus



RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?page/(.*?)/?$ /page.php?page_id=$1 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /page\.php\?page_id=([^\&\ ]+)
RewriteRule ^/?page\.php$ /page/%1? [L,R=301]

Thursday, June 25, 2020

Time Difference script using PHP

<?php

$date1 = strtotime("2016-06-01 22:45:00"); 
$date2 = strtotime("2018-09-21 10:44:01"); 
  
$diff = abs($date2 - $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));
  

$hours = floor(($diff - $years * 365*60*60*24 
       - $months*30*60*60*24 - $days*60*60*24)
                                   / (60*60)); 
$minutes = floor(($diff - $years * 365*60*60*24 
         - $months*30*60*60*24 - $days*60*60*24 
                          - $hours*60*60)/ 60); 
  

$seconds = floor(($diff - $years * 365*60*60*24 
         - $months*30*60*60*24 - $days*60*60*24
                - $hours*60*60 - $minutes*60)); 
  
// Print the result
printf("%d years, %d months, %d days, %d hours, "
     . "%d minutes, %d seconds", $years, $months,
             $days, $hours, $minutes, $seconds); 
?>