Pages

11 Apr 2016

Auto Save PHP Form Using Jquery Autoave Funtion - Codiginter Framework

Jquery Script

<script type="text/javascript">
// JQUERY: Plugin "autoSumbit"
(function($) {
$.fn.autoSubmit = function(options) {
return $.each(this, function() {
// VARIABLES: Input-specific
var input = $(this);
var column = input.attr('name');
$('.alert-success').hide();
// VARIABLES: Form-specific
var form = input.parents('form');
var method = $('#form_profile_1').attr('method');//form.attr('method');
var action = $('#form_profile_1').attr('action'); //form.attr('action');

// VARIABLES: Where to update in database
var where_val =$('#where').val();
var where_col = $('#where').attr('name');

// ONBLUR: Dynamic value send through Ajax
input.bind('change', function(event) {
// Get latest value
var value = input.val();
// AJAX: Send values
$.ajax({
url: action,
type: method,
data: {
val: value,
col: column,
w_col: where_col,
w_val: where_val
},
cache: false,
timeout: 10000,
success: function(data) {
// Alert if update failed
if (data) {
alert(data);
}
// Load output into a P
else {
//alert('hear');
$('.alert-success').show();
//$('.alert-success').text('Updated');
//$('.alert-success').fadeOut();
$(".alert-success").fadeIn('slow').delay(5000).fadeOut('slow');
}
}
});
// Prevent normal submission of form
return false;
})
});
}
})(jQuery);
// JQUERY: Run .autoSubmit() on all INPUT fields within form
$(function(){
$('#form_profile INPUT').autoSubmit();
});
</script>



Controller



 public function update()
{
if (count($_POST))
{
 
$col= $this->input->post('col');
$val= $this->input->post('val');
$w_col= $this->input->post('w_col');
$w_val= $this->input->post('w_val');
$update_data= array(
$col => $val
);
// $update_query="update tbl_employee set ".$col."='".$val."' where ".$w_col."='".$w_val."'";
// echo $update_query;
// $this->db->update($update_query);
$this->db->where($w_col,$w_val);
$this->db->update('tbl_employee',$update_data);
}

}


View


<div >
 
<input id="where" type="hidden" value="<?=$r->id?>" name="id">
<input type="text" class="form-control input-sm" value="<?=$r->emp_firstname?>" id="emp_firstname" name="emp_firstname" style="width:60%" placeholder="First Name" autocomplete="off">
                                                    
                                                         
<input type='text' name="emp_middle_name" value="<?=$r->emp_middle_name?>" id="emp_middle_name" class="form-control input-sm" style="width:60%" placeholder="Middle Name" />
 
</div>



19 Mar 2016

C# 6.0 Language Features

 C# 6.0 Language Features

1) Expression Bodied Methods

How many times have you had to write a method just for one line of code? Now, with C# 6 you can simply create an expression bodied member with only the expression and without the curly braces or explicit returns.
class Employee
{
   // Method with only the expression
   public static int
      CalculateMonthlyPay(int dailyWage)
      => dailyWage * 30;
}
2) ?—Conditional Access Operator
In earlier versions of the C# language, you always had to write the explicit if condition NULL checks before using an object or its property, as shown below.
private void GetMiddleName(Employee employee)
{
   string employeeMiddleName = "N/A";
 
   if (employee != null && employee.EmployeeProfile
      != null)
      employeeMiddleName =
         employee.EmployeeProfile.MiddleName;
}
The same can be converted into a one-liner by using the Conditional Access Operator in C# 6.
private void GetMiddleName(Employee employee)
{
   string employeeMiddleName =
      employee?.EmployeeProfile?.MiddleName ?? "N/A";
}

3) Auto-Property Initializers

With the Auto-Property initialization feature, the developer can initialize properties without using a private set or the need for a local variable. Following is the sample source code.
class PeopleManager
{
   public List Roles { get; } =
      new List() { "Employee", "Managerial"};
}

4) Primary Constructor

Primary Constructor is a feature in which you are allowed to pass the constructor parameters at the class declaration level instead of writing a separate constructor. The scope of the primary constructor parameters values is class level and will be available only at the time of class initialization. It comes to good use when it is used with the Auto-Property initializers.
// Primary constructor
class Basket(string item, int price)
{
   // Using primary constructor parameter values
   // to do auto property initialization.
   public string Item { get; } = item;
   public int Price { get; } = price;
}

5) OUT Parameter Declaration During Method Call

This is one of my favorites because I was feeling something not good about the separate declaration of the OUT parameter before the method call. This feature allows you to declare the OUT parameter during the method call, as shown below.
public bool ConvertToIntegerAndCheckForGreaterThan10
   (string value)
{
   if (int.TryParse(value, out int convertedValue)
      && convertedValue > 10)
   {
      return true;
   }
 
   return false;
}

6) Await in the Catch Block

This is an important non-syntactic enhancement that will be available in C# 6. The await keyword can be called inside the catch and finally blocks. This opens up the way to perform an async exception handling or fallback process in case an exception happened during an async process call.
public async void Process()
{
   try
   {
      Processor processor = new Processor();
      await processor.ProccessAsync();
   }
   catch (Exception exception)
   {
      ExceptionLogger logger = new ExceptionLogger();
      // Catch operation also can be aync now!!
      await logger.HandleExceptionAsync(exception);
   }
}

7) Exception Filters

Exceptions can be filtered in the catch blocks with ease and cleanly with C# 6. Following is a sample source code where the intention is to handle all Exceptions except the SqlException type.
public async void Process()
{
   try
   {
      DataProcessor processor = ne
   }
   // Catches and handles only non sql exceptions
   catch (Exception exception) if(exception.GetType()
      != typeof(SqlException))
   {
      ExceptionLogger logger = new ExceptionLogger();
      logger.HandleException(exception);
   }
}

8) Using Is Allowed

This feature is something to make your code less cluttered and will reduce duplications. As with the namespaces, you can include a static class in the using statement similar to a namespace.
using System;
// A static class inclusion
using System.Console;
 
namespace CSharp6Demo
{
   class Program
   {
      static void Main(string[] args)
      {
         WriteLine("Console. is not required
            as it is included in the usings!");
      }
   }
}

9) String Interpolation

It can be looked at as an improvement to the String.Format functionality where, instead of the place holders, you can directly mention the string expressions or variables.
static void Main(string[] args)
{
   string name = "Robert";
   string car = "Audi";
   WriteLine("\{name}'s favourite car is
      {car}!");
}



UWP New features for developer

Here is the  list of what's new in Windows 10.
  • Application model
    • File Explorer
    • Shared Storage
    • Settings
  • Controls
    • WebView updates
    • Client-side data validation for user input
    • Windows core text APIs
    • Input updates
    • Maps
  • Devices
    • New Location method
    • AllJoyn support
    • Battery APIs
    • Support for MIDI devices
    • Custom sensor support
  • Graphics and games
    • Support for DirectX 12
  • Media
    • HTTP live streaming
    • Media Foundation Transcode Video Processor (XVP) support for Media Foundation Transforms (MFTs)
    • New Transcoding API
    • Updated MediaElement
    • Media transport controls for desktop apps
      Random access JPEF encoding and decoding
    • Support for Overlays for media compositions
    • New effects framework
  • Networking
    • Socket updates
    • New APIs for Background transfer post-processing tasks
    • Bluetooth support for ads
    • Wifi Direct API upcate
    • Improvements in JSON support
  • Security
    • ECC encryption
  • System services
    • Power change notifications
    • Version Helper functions
  • Storage
    • File-search APIs for Windows Phone
  • Tools and performance
    • Property-change notifications
    • Trace logging
  • User Experience
    • List scrolling virtualization
    • Drag-and-drop capabilities between different application platforms
    • Keyboard acceleration support for keystroke navigation
  • Internet Explorer
    • Support for Edge mode (living document mode) for maximum interoperability with other modern browsers

8 Mar 2016

Freeing Disk Space on C:\ Windows Server 2008

Freeing Disk Space on C:\ Windows Server 2008


I just spent the last little while trying to clear space on our servers in order to install .NET 4.5. Decided to post so my future self can find the information when I next have to do this.
I performed all the usual tasks:

  • Deleting any files/folders from C:\windows\temp and C:\Users\%UserName%\AppData\Local\Temp
  • Delete all EventViewer logs
    • Save to another Disk if you want to keep them
  • Remove any unused programs, e.g. Firefox
  • Remove anything in C:\inetpub\logs
  • Remove any file/folders C:\Windows\System32\LogFiles
  • Remove any file/folders from C:\Users\%UserName%\Downloads
  • Remove any file/folders able to be removed from C:\Users\%UserName%\Desktop
  • Remove any file/folders able to be removed from C:\Users\%UserName%\My Documents
  • Stop Windows Update service and remove all files/folders from C:\Windows\SoftwareDistribution
  • Deleting an Event Logs
  • Run COMPCLN.exe
  • Move the Virtual Memory file to another disk

12 Feb 2016

My SQL Database table record export to excel and send mail with attachmnet -Using PHP Codeigniter Framework


Send mail with attachmnet - PHP Codeigniter Framework

function export()
    {
$this->load->helper('date');
$params= $this->input->post('params');
        $query = $this->db->query("select * from tbl_order where orderid in ($params)");

        if(!$query)
            return false;
        // Starting the PHPExcel library
        $this->load->library('PHPExcel');
        //$this->load->library('PHPExcel/IOFactory/PHPExcel_IOFactory');
        $objPHPExcel = new PHPExcel();
        $objPHPExcel->getProperties()->setTitle("export")->setDescription("none");
        $objPHPExcel->setActiveSheetIndex(0);
        // Field names in the first row
        $fields = $query->list_fields();
        $col = 0;
        foreach ($fields as $field)
        {
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
            $col++;
        }
        // Fetching the table data
        $row = 2;
        foreach($query->result() as $data)
        {
            $col = 0;
            foreach ($fields as $field)
            {
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $data->$field);
                $col++;
            }

            $row++;
        }
        $objPHPExcel->setActiveSheetIndex(0);

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$filepath=site_url('css/'.date('dMy').'.xls');
$dateposted = date("Ymdhis");   
$objWriter->save(str_replace(__FILE__, $dateposted.'.xls', __FILE__));
echo "<script>alert('File saved at drive C')</script>";

//Send mail attachment
$this->load->library('email'); // load email library
$this->email->from('info@domainname.com', 'Subject');
$this->email->to('toemmail@domain.com');
$this->email->cc('ccemail@domian.com'); 
$this->email->subject('Subject');
$this->email->attach($dateposted.'.xls');
$this->email->send();
 
    }

Delete or remove temp data and free up space in c drive- Windows Server 2008 R2

We would like to inform you that kindly login to the server and delete temp data and free up space in c drive.
1) Open run and type %temp%  to locate temp file. Delete all files.

2) Open run type services.msc  locate the service “windows updates” stop the service  àopen the location(C:\Windows\SoftwareDistribution) and delete all files à Open run type services.msc  locate the service “windows updates” start the service 

10 Dec 2015

Operation not yet implemented error in PDF export - Issue resolved

Operation not yet implemented error in PDF export



Microsoft updates (KB3102429) un-install form your computer or on your on-line server.