<?php
class LogAppCrashes extends AppModel
{
    var $name='LogAppCrashes';

    function insertLogAppCrashes($inputData){

        $result = false;
       // $expense_type = substr($inputData["unique_url"], 0, 1);
        if(!isset($inputData["expense_type"])){
            $form["expense_type"] = 0;
        } else {
            $form["expense_type"] = trim($inputData["expense_type"]);
        }
        $input_request_data = $this->convertJson($inputData['request']);
        $input_response_data = $this->convertJson($inputData['response']);
        
        $form["error_code"] = trim($inputData["error_code"]);
        $form["error_desc"] = trim($inputData["error_desc"]);
        $form["request"] = $input_request_data;
        $form["response"] = $input_response_data;
        $form["crash_date"] = trim($inputData["crash_date"]);
        $form["ip"] = trim($inputData["ip"]);
        $form["device_info"] = trim($inputData["device_info"]);


        $fileds = array('expense_type','error_code','error_desc','request','response','crash_date','ip','device_info');


        $dbData["LogAppCrashes"] = $form;

        //print_r($data["Feeback"]);exit;

        if(!$this->save($dbData,false,$fileds)){
            $result = true;

        }

        return $result;
    }

    private function convertJson($input_data)
    {
        $data = trim($input_data);
        $unserialized_data = unserialize($data);
        $json_data = json_encode($unserialized_data);
        return $json_data;
    }

}