<?php

/*
*
* INFOATCLUSTER TECHNOLABS LLP ("COMPANY") CONFIDENTIAL
* Copyright (c) 2016-2017 INFOATCLUSTER TECHNOLABS LLP, All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains the property of INFOATCLUSTER TECHNOLABS LLP. The intellectual and technical concepts contained
* herein are proprietary to INFOATCLUSTER TECHNOLABS LLP and may be covered by Indian and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained
* from COMPANY.  Access to the source code contained herein is hereby forbidden to anyone except current COMPANY employees, managers or contractors who have executed 
* Confidentiality and Non-disclosure agreements explicitly covering such access.
*
* The copyright notice above does not evidence any actual or intended publication or disclosure  of  this source code, which includes  
* information that is confidential and/or proprietary, and is a trade secret, of  COMPANY.   ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC  PERFORMANCE, 
* OR PUBLIC DISPLAY OF OR THROUGH USE  OF THIS  SOURCE CODE  WITHOUT  THE EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE 
* LAWS AND INTERNATIONAL TREATIES.  THE RECEIPT OR POSSESSION OF  THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS  
* TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT  MAY DESCRIBE, IN WHOLE OR IN PART.                
*
*
* @author Mohammed Shayas M K
* 
*/

Class Helper
{
    function changeSerialzeArrayValues($data, $type = null)
    {
        $return = array();
        foreach($data AS $key => $value)
        {
            if(trim($value['value']) == null)
            {
                $return[$value['name']] = '';
            }
            else
            {
                $return[$value['name']] = $value['value'];
            }
            
        }
        
        return $return;
    }
    
    function addUuid()
    {
        return Uuid::generate()->string;
    }
    
    function checkFields($inputFields, $requiredFields)
    {
      
        foreach($requiredFields AS $field)
        {
            if(!isset($inputFields[$field]))
            {
                if(!is_null($inputFields[$field]))
                {
                    return 'Something Went Wrong';
                    exit;
                }
            }
        }
//        
//        $requiredFieldsFlip = array_flip($requiredFields);
//        foreach($inputFields AS $key => $field)
//        {
//            if(!isset($requiredFieldsFlip[$key]))
//            {
//                return 'Something Went Wrong1';
//                exit;
//            }
//        }
    }

    function getCourierCharge($weight)
    {
        if(LANGUAGE == 'lv')
        {
            if($weight < 500)
            {
                $price = 3.80;
            }
            else if($weight >=500 && $weight < 3000)
            {
                $price = 4.00;
            }
            else if($weight >=3000 && $weight < 5000)
            {
                $price = 4.40;
            }
            else if($weight >=5000 && $weight < 10000)
            {
                $price = 4.90;
            }
            else if($weight >=10000 && $weight < 20000)
            {
                $price = 5.90;
            }
            else if($weight >=20000 && $weight < 31500)
            {
                $price = 7.50;
            }
            else if($weight >=31500 && $weight < 50000)
            {
                $price = 10.40;
            }
            else if($weight >=50000 && $weight < 75000)
            {
                $price = 11.60;
            }
            else if($weight >=75000 && $weight < 100000)
            {
                $price = 12.80;
            }
            else if($weight >=100000 && $weight < 200000)
            {
                $price = 25;
            }
            else if($weight >=200000 && $weight < 300000)
            {
                $price = 36;
            }
            else if($weight >=300000 && $weight < 400000)
            {
                $price = 40;
            }
            else if($weight >=400000 && $weight < 500000)
            {
                $price = 48;
            }
        }
        else if(LANGUAGE == 'lt')
        {
            if($weight < 500)
            {
                $price = 3.80;
            }
            else if($weight >=500 && $weight < 3000)
            {
                $price = 4.00;
            }
            else if($weight >=3000 && $weight < 5000)
            {
                $price = 4.40;
            }
            else if($weight >=5000 && $weight < 10000)
            {
                $price = 4.90;
            }
            else if($weight >=10000 && $weight < 20000)
            {
                $price = 5.90;
            }
            else if($weight >=20000 && $weight < 31500)
            {
                $price = 7.50;
            }
            else if($weight >=31500 && $weight < 50000)
            {
                $price = 10.40;
            }
            else if($weight >=50000 && $weight < 75000)
            {
                $price = 11.60;
            }
            else if($weight >=75000 && $weight < 100000)
            {
                $price = 12.80;
            }
            else if($weight >=100000 && $weight < 200000)
            {
                $price = 25;
            }
            else if($weight >=200000 && $weight < 300000)
            {
                $price = 36;
            }
            else if($weight >=300000 && $weight < 400000)
            {
                $price = 40;
            }
            else if($weight >=400000 && $weight < 500000)
            {
                $price = 48;
            }
        }
        else if(LANGUAGE == 'ee')
        {
            if($weight < 500)
            {
                $price = 3.80;
            }
            else if($weight >=500 && $weight < 3000)
            {
                $price = 4.00;
            }
            else if($weight >=3000 && $weight < 5000)
            {
                $price = 4.40;
            }
            else if($weight >=5000 && $weight < 10000)
            {
                $price = 4.90;
            }
            else if($weight >=10000 && $weight < 20000)
            {
                $price = 5.90;
            }
            else if($weight >=20000 && $weight < 31500)
            {
                $price = 7.50;
            }
            else if($weight >=31500 && $weight < 50000)
            {
                $price = 10.40;
            }
            else if($weight >=50000 && $weight < 75000)
            {
                $price = 11.60;
            }
            else if($weight >=75000 && $weight < 100000)
            {
                $price = 12.80;
            }
            else if($weight >=100000 && $weight < 200000)
            {
                $price = 25;
            }
            else if($weight >=200000 && $weight < 300000)
            {
                $price = 36;
            }
            else if($weight >=300000 && $weight < 400000)
            {
                $price = 40;
            }
            else if($weight >=400000 && $weight < 500000)
            {
                $price = 48;
            }
        }
        else if(LANGUAGE == 'fi')
        {
            
            if($weight < 500)
            {
                $price = 3.80;
            }
            else if($weight >=500 && $weight < 3000)
            {
                $price = 4.00;
            }
            else if($weight >=3000 && $weight < 5000)
            {
                $price = 4.40;
            }
            else if($weight >=5000 && $weight < 10000)
            {
                $price = 4.90;
            }
            else if($weight >=10000 && $weight < 20000)
            {
                $price = 5.90;
            }
            else if($weight >=20000 && $weight < 31500)
            {
                $price = 7.50;
            }
            else if($weight >=31500 && $weight < 50000)
            {
                $price = 10.40;
            }
            else if($weight >=50000 && $weight < 75000)
            {
                $price = 11.60;
            }
            else if($weight >=75000 && $weight < 100000)
            {
                $price = 12.80;
            }
            else if($weight >=100000 && $weight < 200000)
            {
                $price = 25;
            }
            else if($weight >=200000 && $weight < 300000)
            {
                $price = 36;
            }
            else if($weight >=300000 && $weight < 400000)
            {
                $price = 40;
            }
            else if($weight >=400000 && $weight < 500000)
            {
                $price = 48;
            }
        }
        else
        {
            
            if($weight < 500)
            {
                $price = 3.80;
            }
            else if($weight >=500 && $weight < 3000)
            {
                $price = 4.00;
            }
            else if($weight >=3000 && $weight < 5000)
            {
                $price = 4.40;
            }
            else if($weight >=5000 && $weight < 10000)
            {
                $price = 4.90;
            }
            else if($weight >=10000 && $weight < 20000)
            {
                $price = 5.90;
            }
            else if($weight >=20000 && $weight < 31500)
            {
                $price = 7.50;
            }
            else if($weight >=31500 && $weight < 50000)
            {
                $price = 10.40;
            }
            else if($weight >=50000 && $weight < 75000)
            {
                $price = 11.60;
            }
            else if($weight >=75000 && $weight < 100000)
            {
                $price = 12.80;
            }
            else if($weight >=100000 && $weight < 200000)
            {
                $price = 25;
            }
            else if($weight >=200000 && $weight < 300000)
            {
                $price = 36;
            }
            else if($weight >=300000 && $weight < 400000)
            {
                $price = 40;
            }
            else if($weight >=400000 && $weight < 500000)
            {
                $price = 48;
            }
        }
        
        return $price;
    }

    function getCountryCodes()
    {
        return array(
            'Latvija' => 'LV',
            'Austria' => 'AU',
            'Italu' => 'IT',
            'Belgium' => 'BE',
            'Bulgaria' => 'BG',
            'Lithuania' => 'LT',
            'Croati' => 'HR',
            'Luxembourg' => 'LU',
            'Cyprus' => 'CY',
            'Malta' => 'MT',
            'Czechia' => 'CZ',
            'Netherlands' => 'NL',
            'Denmark' => 'DK',
            'Poland' => 'PL',
            'Estonia' => 'EE',
            'Portugal' => 'PT',
            'Finland' => 'FI',
            'Romania' => 'RO',


             'France' => 'FR',
            'Slovakia' => 'SK',
            'Germany' => 'DE',
            'Slovenia' => 'SI',
            'Greece' => 'GR',
            'Spain' => 'ES',
            'Hungary' => 'HU',
            'Sweden' => 'SE',
            'Ireland' => 'IE',
            'United Kingdom' => 'GB',
            'India' => 'IN'
        );
    }
}