Monday 16 December 2019

Google Calendar API Tutorial #2 | Access Different Calendars Using PHP



Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

Hello guys, this tutorial was requested by one of my viewer who asked me how to access different google calendar other than “primary”.
Before we even start, if you don’t know how to connect PHP with Google Calendar, then click the link which is at right top corner or link is given in description.
Now, according to google, “Different Calendar” doesn’t mean they display different “user interface for different calendar”, but rather they display single page and display different color box for different calendars.
So let’s create a new calendar.
Then go to code that we created in previous tutorial, as you can see, the calendar-id is set to primary which is always the first one in the list.
If we run, the events will be display from primary calendar.
So let’s create new event of newly created calendar. Make sure that it is held in future.
After that, click on three-dots of new calendar, click on “settings and sharing”, scroll down and copy calendar-id.
Paste it at the place of calendar ID.
Then, refresh it and you will get your events.
That’s only it.
Thanks for watching.

Sunday 1 December 2019

JQuery Javascript Tutorial | Convert Static HTML Table Into PHP Array | ...



index.html


    <table id="myTable" border="1" cellspacing="0" width="40%">
        <tr>
            <td> & / MODEL</td>
            <td>5kVA-48V</td>
        </tr>
        <tr>
            <td>RATED & POWER</td>
            <td>
            5000 VA / 5000 W
            </td>
        </tr>
        <tr>
            <td>INPUT</td>
        </tr>
        <tr>
            <td>Voltage</td>
            <td>
            230 VAC
            </td>
        </tr>
        <tr>
            <td>Selectable Voltage Range</td>
            <td>
            170-280 VAC (For UPS Mode); 90-280 VAC (For Appliance Mode)
            </td>
        </tr>
        <tr>
            <td>Frequency Range</td>
            <td>
            50 Hz/60 Hz (Auto sensing)
            </td>
        </tr>
        <tr>
            <td>OUTPUT</td>
        </tr>
        <tr>
            <td>AC Voltage Regulation (Batt. Mode)</td>
            <td>
            230 VAC ± 5%
            </td>
        </tr>
        <tr>
            <td>Surge Capacity</td>
            <td>
            10000 VA
            </td>
        </tr>
        <tr>
            <td>Overload Protection</td>
            <td>
            93%
            </td>
        </tr>
        <tr>
            <td>Efficiency (Peak)</td>
            <td>
            10 ms (For UPS Mode) ; 20 ms (For Appliance Mode)
            </td>
        </tr>
        <tr>
            <td>Transfer Time</td>
            <td>
            10 ms (For UPS Mode); 20 ms (For Appliance Mode)
            </td>
        </tr>
        <tr>
            <td>Waveform</td>
            <td>
            Pure Sine Wave
            </td>
        </tr>
        <tr>
            <td>BATTERY  AC CHARGER</td>
        </tr>
        <tr>
            <td>Battery Voltage</td>
            <td>
            48 VDC
            </td>
        </tr>
        <tr>
            <td>Floating Charge Voltage</td>
            <td>
            54 VDC
            </td>
        </tr>
        <tr>
            <td>Overcharge Protection</td>
            <td>
            60 VDC
            </td>
        </tr>
        <tr>
            <td>SOLAR CHARGER</td>
        </tr>
        <tr>
            <td>Number of MPPT Trackers</td>
            <td>
            1
            </td>
        </tr>
        <tr>
            <td>Maximum AC Charge Current</td>
            <td>
            60 A
            </td>
        </tr>
        <tr>
            <td>Maximum PV Array Open Circuit Voltage</td>
            <td>
            145 VDC
            </td>
        </tr>
        <tr>
            <td>MPPT Range @ Operating Voltage</td>
            <td>
            60 ~ 115 VDC
            </td>
        </tr>
        <tr>
            <td>Maximum Solar Charging Current</td>
            <td>
            80 A
            </td>
        </tr>
        <tr>
            <td>Maximum Efficiency</td>
            <td>
            98%
            </td>
        </tr>
        <tr>
            <td>Standby Power Consumption</td>
            <td>
            2 W
            </td>
        </tr>
        <tr>
            <td>Maximum PV Array Power</td>
            <td>
            4000 W
            </td>
        </tr>
        <tr>
            <td>Monitoring</td>
        </tr>
        <tr>
            <td>Monitoring Software</td>
            <td>
            Included
            </td>
        </tr>
        <tr>
            <td>Net Weight (kgs)</td>
            <td>
            5
            </td>
            <td>
            6.3
            </td>
            <td>
            8.5
            </td>
        </tr>
        <tr>
            <td>PHYSICAL</td>
        </tr>
        <tr>
            <td>Dimension, D x W x H (mm)</td>
            <td>
            120 x 295 x 468
            </td>
        </tr>
        <tr>
            <td>Net Weight (kgs)</td>
            <td>
            11
            </td>
        </tr>
        <tr>
            <td>OPERATING ENVIRONMENT</td>
        </tr>
        <tr>
            <td>Humidity</td>
            <td>
            5% to 95% Relative Humidity(Non-condensing)
            </td>
        </tr>
        <tr>
            <td>Operating Temperature</td>
            <td>
            0°C - 55°C
            </td>
        </tr>
        <tr>
            <td>Storage Temperature</td>
            <td>
            -15°C - 60°C
            </td>
        </tr>
    </table>
    <button onclick="send_values()">Export</button>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script type="text/javascript">
    function send_values()
    {
        string="";
        tr_count=0;
        $("#myTable tr").each(function()
        {

            td_count=0;
            tr_count++;

            if(tr_count>1)
            {
                string=string+',';
            }

            each_tr_length=$(this).find("td").length;
            string=string+'"tr'+tr_count+'":{"count":"'+each_tr_length+'",';
            $(this).find("td").each(function()
            {
                td_count++;
                string=string+'"td'+td_count+'":"'+($(this).html())+'"';
                if(td_count<each_tr_length)
                {
                    string=string+',';
                }
            });
            string=string+'}';
        });
        string=('{"info":[{'+string+'}]}').replace(/&amp;/g,'%26');
        alert(string);
        window.location.href="read_url.php?data="+string;
    }
</script>

read_url.php


<?php
//echo $_REQUEST['data'];
$json_arr=json_decode($_GET['data'],true);
//print_r($json_arr['info']);

foreach($json_arr['info'][0] as $key => $value) {
    for($i=1; $i <= intval($value['count']); $i++) {
        echo "</div>".$value['td'.$i]."</div>";
    }
}

?>

Description:


Hey guys, this is UNPOSSIBLE POG.
In this video, I shall explain how to use JQUERY javascript to convert static html table into Backend language.
In my case, the backend language is PHP.
The main reason to use this code is when client gives some static table which is vary large that it will take a lot of time to insert into database table one by one.
Let’s get started.
First requirement is to add ajax jquery link in code.
As you can see, I already created a sample table.
Table’s id will be “mytable”.
Lets create a script tag, and call the function onclick event of button.
Let’s verify if it is working.
Now, the main challenge is to find how many rows and columns are present it table.
Now, we are using jquery syntax to find jump to each “tr” tag.
The second task is to find how many columns are there in each row.
So type this code.
We are finding each column, then jump in each column by using each function.
Now, we are table to get each value within each column.
Now, we have to make a JSON of each value by appending a string.
We are getting tr and td count.
Lets make only two columns in second row.
We get two in second output so we are on right track.
We have to carefully make json as single mistake destroys JSON structure.
We put count of each columns in the beginning of JSON.
Let’s put that outside.
We shall separate it by commas.
Also, we have to make teach tr with unique id to avoid conflict.
Now, each tr have their own array.
Now we are going to add the data in each column.
We have completed the task of creating a JSON. Now the next task it so send those values in URL.
So for that, we shall using basic location function of javascript.
As you can see, I already created a file which decodes the JSON data.
Let’s run it.
As you can see, the data is coming.
Now lets test the code by increasing the data.
Although the task doesn’t end here. The special character called “ampersand” creates a problem while sending data.
Lets add ampersand.
You can see, ampersand is automatically converted into this, and it is creating a problem.
The solution is very easy.
We have to replace ampersand with ‘%26‘
Don’t give any quote in pattern.
And as you can see. The data is submitted.