Posts

Showing posts from 2017

Tracking Number Generation Process

$trackingPrefix = "PI" . date("dmY"); $processTypeId = 1; $updatePurchaseTrackingNo = DB::statement("update  ins_purchase_invoice, ins_purchase_invoice as table2 SET ins_purchase_invoice.tracking_no=(    select concat('$trackingPrefix',     LPAD( IFNULL(MAX(SUBSTR(table2.tracking_no,-4,4) )+1,0),4,'0')                   ) as tracking_no    from (select * from ins_purchase_invoice ) as table2    where table2.id !=  $purchaseData->id and table2.tracking_no like '$trackingPrefix%'    ) where ins_purchase_invoice.id = $purchaseData->id and table2.id = $purchaseData->id");

AJAX IMAGE UPLOADING.....

1. index.php <body>     <span id="msg" style="color:red"></span><br/>     <input type="file" id="photo"><br/>   <script type="text/javascript" src="jquery-3.2.1.min.js"></script>   <script type="text/javascript">     $(document).ready(function(){       $(document).on('change','#photo',function(){         var property = document.getElementById('photo').files[0];         var image_name = property.name;         var image_extension = image_name.split('.').pop().toLowerCase();         if(jQuery.inArray(image_extension,['gif','jpg','jpeg','']) == -1){           alert("Invalid image file");         }         var form_data = new FormData();         form_data.append("file",property);         $.ajax({           url:'upload.php',           method:'POST',  

Virtual Host setup in XAMPP

1. xampp\apache\conf\extra\httpd-vhosts.conf <VirtualHost *:80>     ServerAdmin hasib.dev     DocumentRoot "C:/xampp/htdocs/hasib/"     ServerName hasib.dev </VirtualHost> 2.Windows\System32\drivers\etc\hosts 127.0.0.1 hasib.dev

Date Time Picker for Warranty Start, Warranty End, Invoice Date in Same Page

var today = new Date(); var yyyy = today.getFullYear(); $('.purchase_date').datetimepicker({     viewMode: 'years',     format: 'DD-MMM-YYYY',     extraFormats: [ 'DD.MM.YY', 'DD.MM.YYYY' ],     maxDate: today,     minDate: '01/01/' + (yyyy - 60) }); $('.datepicker').datetimepicker({     viewMode: 'years',     format: 'DD-MMM-YYYY',     extraFormats: [ 'DD.MM.YY', 'DD.MM.YYYY' ] }); $('#warrantyStart').datetimepicker(); $('#warrantyEnd').datetimepicker({     useCurrent: false //Important! See issue #1075 }); $("#warrantyStart").on("dp.change", function (e) {     $('#warrantyEnd').data("DateTimePicker").minDate(e.date); }); $("#warrantyEnd").on("dp.change", function (e) {     $('#warrantyStart').data("DateTimePicker").maxDate(e.date); });

Access Auth Protect MongoDB Database From Terminal

->mongo ->use databaseName ->db.auth("userName","userPassword"); Now you can access ->db.showCollections();

MongoDB Secured Connection

<?php date_default_timezone_set("Asia/Dhaka"); $host = '192.168.0.1'; $pass = 'databasePassword'; $user = 'databaseUsername'; $dbName = 'databaseName'; $nameOfCollection = 'collectionName'; $connection = new MongoClient("mongodb://${user}:${pass}@$host", array ("db" => $dbName)); $db = $connection->selectDB($dbName); $COLL_collection = new MongoCollection($db, $ nameOfCollection );

After DOM Load in body

$.validator.addMethod("bd_phone",function(phone){   var reg = /(^(\+88|0088)?(01){1}[56789]{1}(\d){8})$/;     if(reg.test(phone)){         return true;     }     return false; },""); if($(document.body).find('.minor').length){     $("#publicReg").validate({         rules: {             birth_date: "required",             district: "required",             gender: "required",             police_station: "required",             full_name_bangla: "required",             village_ward: "required",             full_name_english: "required",             post_code: "required",             father_name: "required",             mother_name: "required",             occupation: "required",             per_district: "required",             mobile: {               required:true,               bd

Google chrome installation in ubuntu 14.4 by terminal command

1-> wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -  2-> sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'  3-> sudo apt-get update  4-> sudo apt-get install google-chrome-stable

Google Login Adding In Laravel

.env file: GOOGLE_LOGIN_CLIENT_ID= 4682799 66203- 3c47dfkknjj28irumub6c7vtp3dph2 oq.apps.googleusercontent.com GOOGLE_LOGIN_SECRET_KEY= vfXcMYMWPHkR3wjKhVikaCDY composer.json file :  "laravel/socialite": "^2.0" composer update config/app.php file: Provider: //  Laravel Auth Login service provider         Laravel\Socialite\ SocialiteServiceProvider:: class, Alias: // Socialite         'Socialite' => Laravel\Socialite\Facades\ Socialite::class, config/services.php file: 'google' => [         'client_id' => env('GOOGLE_LOGIN_CLIENT_ID'),         'client_secret' => env('GOOGLE_LOGIN_SECRET_KEY') ,         'redirect' => ' http://localhost:8000/auth/ google/callback ',     ],

MongoDB Auth User DB Access ACL

CASE 1 : Red Hat Server  Directory : /etc/mongod.conf Before : #security : Before :  security:     authorization: enable CASE 2 : Other Linux Directory :  /etc/mongod.conf Before :  #auth=true After : auth=true

Linux Terminal Commad (Move,Delete,Edit,Rename)

Move sudo su mv /home/your-local-file.txt /your-server-destination-path/your-local-file.txt Edit vim mongod.conf :qw or :q Delete rm x_mongod.conf Rename mv mongod.conf x_mongod.conf

Auth User From Terminal to access MongoDB Database

mongo -u userName -p userPassword localhost/databaseName

MongoDB Connection From PHP

By Authenticate User :  $user = 'testUser'; $pass = '123456'; $connection = new MongoClient("mongodb://${user}:${pass}@localhost", array("db" => "testDB")); Without Authenticate User: $host = 'localhost'; $nidCollection = 'nids'; $connection = new MongoClient("mongodb://{$host}"); $db = $connection->nidservice; $COLL_nid = $db->$nidCollection;

MongoDB Create User

use reporting db . createUser ( { user : "reportsUser" , pwd : "12345678" , roles : [ { role : "read" , db : "reporting" }, { role : "read" , db : "products" }, { role : "read" , db : "sales" }, { role : "readWrite" , db : "accounts" } ] } ) Authenticate User Creation for Single Database use products db . createUser ( { user : "accountUser" , pwd : "password" , roles : [ "readWrite" , "dbAdmin" ] } )

Git remote URL information details by terminal command

1. Only the URL that a local Git repository was originally cloned from. git config --get remote.origin.url 2. Remote Information Details git remote show origin

AJAX Request and Response for Datatable

$(document).ready(function () {     $(function () {         $('#agency-list').DataTable({             processing: true,             serverSide: true,             iDisplayLength: 25,             ajax: {                 url: '{{url("agency/get-list")}}',                 method: 'POST',                 headers: {                     'X-CSRF-TOKEN': '{{ csrf_token() }}'                 }             },             columns: [                 {data: 'rownum', name: 'rownum'},                 {data: 'license_no', name: 'license_no'},                 {data: 'agency_name', name: 'agency_name'},                 {data: 'mobile', name: 'mobile'},                 {data: 'license_expire_date', name: 'license_expire_date'},                 {data: 'action', name: 'action'}             ],             "aaSorting": []         });

API Related Links

1. https://maps.googleapis.com/maps/api/js?address=dhaka 2. https://developers.google.com/maps/documentation/geocoding/intro 3. https://developers.google.com/maps/documentation/javascript/ 4. http://jsoneditoronline.org/ 5. https://maps.googleapis.com/maps/api/geocode/json?address=azom+road+mohammadpur+dhaka 6. http://api.jquery.com/jquery.getjson/ 7. https://maps.googleapis.com/maps/api/geocode/json?address=1000

yajra data table process

1.  public function viewList () { try { return view( "LocalSalesPermit::list" ) ; } catch (\Exception $e ) { Session:: flash ( 'error' , CommonFunction:: showErrorPublic ( $e -> getMessage ())) ; return Redirect:: back ()-> withInput () ; } } 2. $ ( document ). ready ( function () { $ ( function () { var t = $ ( '#list' ). DataTable ({ "columnDefs" : [ { "searchable" : false , "orderable" : false , "targets" : 0 } ] , "order" : [[ 0 , 'asc' ]] , processing : true , serverSide : true , iDisplayLength : 25 , ajax : { url : ' {{url( "local-sales-permit/get-list" )}} ' , method : 'POST' , headers : { 'X-CSRF-TOKEN' : ' {{ c

Bangla UniBijoy installing in Ubuntu OS

sudo apt-get install ibus-m17n m17n-db m17n-contrib ibus-gtk ibus-daemon -xdr https://www.youtube.com/watch?v=0jYQZ6PSpbs

Loop

$x=1; do{  echo $x;  $x++; }while($x<=10); //At first code will be executed in do{} and then will be continuing checking condition if condition true then will go inside in do{} to execute code otherwise not. An important thing about do{}while() is At the very first execution is not depend on condition but from the second execution depend on condition. $x=1; while($x<=10){  echo $x;  $x++; } //At the beginning check the condition if condition is true then execute otherwise not. The characteristic of this loop is this loop run clock wise. for($i=1; $i<=10; $i++){  echo $i; } // This loop run anti-clock wise first initiate value, then check condition if condition is true then go to execution, after completing the execution go to the third parameter to increment initialized value. continue; //Use to skip a single execution in loop break; //Use to get out from a loop;

Putty and Filefizlla installation on Fedora

Putty Installation on Fedora su- yum install putty Filezilla Installation on Fedora yum -y install filezilla

Form page on view mode by JavaScript

$(document).ready(function(){   $('#myForm :input').attr('disabled','true');   $('#myForm :input[type=submit]').hide(); });

DB::statement(); for serial in table

DB::statement(DB::raw('set @serial=0')); $list = Designation::orderBy('id','desc')          ->get([          'id',          'title',          DB::raw('@serial := @serial +1 as serial')           ]);

Getting key from an array by value

if(in_array($data['question_type],$questionTypes)){    $examTypeId = array_search($data['question_type'],$questionTypes); }

Object to array conversion

$examTypes = ExamType::lsits('exam_name','id'); $questionTypes = json_decode(json_encode($examTypes), True );

List Query for select box in Laravel

ExamType::lists('exam_name','id');

Git credentials storing in cache

Windows git config --global credential.helper wincred git pull origin <enter your branch> Username: <type your username> Password: <type your password> Ubuntu git config credential.helper store git pull origin <enter your branch> Username: <type your username> Password: <type your password> Fedora git config --global credential.helper gnome-keyring git pull origin <enter your branch> Username: <type your username> Password: <type your password>

MySQL Commands

-> To set set primary key in a table alter table tableName add primary key(id); -> To remove primary key from a table alter table tableName drop primary key; -> To set a default value for column alter table tableName alter column fieldName set default AnyDefaultValue.

Run project in custom host and custom port

Running Laravel Project php artisan serve --host=192.168.200.100 --port=8000 Normally php -S localhost:8080 -t public

Git configuration related essential command

Set user email and name after removing previous all :   git config --global --replace-all user.email "new@mail.com" git config --global --replace-all user.name "newname" Set user email and name :  git config --global --user.name "setname" git config --global --user.email "set@mail.com" Show current user email and name :  git config --global --user.name git config --global --user.email

MySQL table creation command

CREATE TABLE `std`(`id` int(11) NOT NULL AUTO_INCREMENT,`name` VARCHAR(20) DEFAULT NULL, PRIMARY KEY(`id`));

Project run on port [PHP]

Generally :  php -S localhost:8000 Laravel :  php artisan serve  [Port number will be atomically 8000] php artisan serve --port=8888 [Run on custom port]  php artisan serve --host=192.168.152.160 --port=8800  [Run on custom IP and custom port] 

MySQL-> Multiple same values from a field will be sum and the new field name will be as how I define

Question Explanation : There is a table named people and there is information stored of different people from different country. Now how we can we see how many people form Bangladesh,Canada,Italy or few others country as table view ? SELECT SUM(CASE WHEN country_name ='Bangladesh' THEN 1 ELSE 0 END) as Bangladesh, SUM(CASE WHEN country_name ='Canada' THEN 1 ELSE 0 END) as Canada from people;

MySQL Query -> get first_name and last_name from a field where is user_full_name

SELECT SUBSTRING_INDEX(user_full_name,' ',1) as first_name, SUBSTRING_INDEX(user_full_name,' ',-1) as last_name FROM users WHERE id=1;

jQuery form validation (CUSTOM VALIDATION)

Code Structure :  $.validator.addMethod("field_name","function(value){}","Message"); jQuery Custom NID Validation :  $.validator.addMethod("nid_valid",function(value){    if(value.length == 10 || value.length == 13 || value.length == 17){       return true;    }else{       return false;    } },"NID number length 10, 13, 17 is valid");

LARAVEL CUSTOM VALIDATION

NID Validation :) 1> app/Providers/AppServiceProvider.php public function boot(){    $this->app['validator']->extend('nid',function($attribute,$value,$parameters){    $length = strlen($value);    if(in_array($length,[10,13,17])){        return true;    }else{        return false;    } }); } 2> resources/lang/en/validation.php return [    'nid' => 'The :attribute valid NID must be 10 | 13 | 17', ];