diff --git a/api/application/composer.json b/api/application/composer.json index e8590837..2addfdaf 100644 --- a/api/application/composer.json +++ b/api/application/composer.json @@ -16,7 +16,9 @@ "smalot/pdfparser": "^0.13.2", "monolog/monolog": "^1.23", "ddeboer/tesseract": "^1.1", - "aws/aws-sdk-php": "^3.64" + "aws/aws-sdk-php": "^3.64", + "amphp/amp": "^1.2" + }, "suggest": { "paragonie/random_compat": "Provides better randomness in PHP 5.x" diff --git a/api/application/composer.lock b/api/application/composer.lock index f4487454..408aead2 100644 --- a/api/application/composer.lock +++ b/api/application/composer.lock @@ -4,8 +4,65 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bfa621df7472a3d505dd26af8163a985", + "content-hash": "b4b72b09cfc21e95dae4ddb7c00d11d6", "packages": [ + { + "name": "amphp/amp", + "version": "v1.2.2", + "source": { + "type": "git", + "url": "https://github.com/amphp/amp.git", + "reference": "4f2161da5f68f274f116985635aea63b5c0f54d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/amp/zipball/4f2161da5f68f274f116985635aea63b5c0f54d2", + "reference": "4f2161da5f68f274f116985635aea63b5c0f54d2", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "fabpot/php-cs-fixer": "~1.9", + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Amp\\": "lib/" + }, + "files": [ + "lib/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net", + "role": "Creator / Lead Developer" + } + ], + "description": "A non-blocking concurrency framework for PHP applications", + "homepage": "https://github.com/amphp/amp", + "keywords": [ + "async", + "concurrency", + "event", + "non-blocking", + "promise" + ], + "time": "2016-05-12T12:54:59+00:00" + }, { "name": "aws/aws-sdk-php", "version": "3.64.15", diff --git a/api/application/config/autoload.php b/api/application/config/autoload.php index 3bc3135b..a0804199 100644 --- a/api/application/config/autoload.php +++ b/api/application/config/autoload.php @@ -58,7 +58,7 @@ $autoload['packages'] = array(); | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array('database','form_validation', 'format'); +$autoload['libraries'] = array('database','format'); /* | ------------------------------------------------------------------- @@ -89,7 +89,7 @@ $autoload['drivers'] = array(); | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array('url', 'form', 'jwt', "authorization", "date","mylog","myocr"); +$autoload['helper'] = array('url', 'form', 'jwt', "authorization", "date","mylog","myocr","mydb"); /* | ------------------------------------------------------------------- diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 47db11f9..c5e2e380 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -85,48 +85,17 @@ defined('EXIT__AUTO_MIN') OR define('EXIT__AUTO_MIN', 9); // lowest automat defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code // define login route name for token verification -defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'login'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getListOfMaster'); // no errors +defined('ROUTE_LOGIN2') OR define('ROUTE_LOGIN2', 'login2'); // no errors +defined('ROUTE_LOGIN3') OR define('ROUTE_LOGIN3', 'login3'); // no errors //encript database table name -defined('LOGIN') OR define('LOGIN','T_Login'); -defined('BRANCH') OR define('BRANCH','T_BranchMaster'); -defined('STAFF') OR define('STAFF','T_StaffDetails'); -defined('STAFF_BRANCH') OR define('STAFF_BRANCH','T_Staff_BranchAccess'); -defined('UNIVERSITY') OR define('UNIVERSITY','T_UniversityMaster'); -defined('COURSE') OR define('COURSE','T_CourseMaster'); -defined('COURSE_FEES') OR define('COURSE_FEES','T_Course_Fees_Details'); -defined('LEAD_DETAILS') OR define('LEAD_DETAILS','T_Lead_Details'); -defined('LEAD_TRACKING') OR define('LEAD_TRACKING','T_Lead_Tracking'); -defined('LEAD_TRACKING_FOLLOWUP') OR define('LEAD_TRACKING_FOLLOWUP','T_Lead_Tracking_Followup'); -defined('PICK_LIST_DETAILS') OR define('PICK_LIST_DETAILS','T_PickListDetails'); -defined('BATCH') OR define('BATCH','T_BatchMaster'); -defined('STUDENTCOURSE') OR define('STUDENTCOURSE','T_Student_CourseDetails'); -defined('STUDENTS') OR define('STUDENTS','T_StudentDetails'); -defined('ANNOUNCEMENT') OR define('ANNOUNCEMENT','T_AnnouncementDetails'); -defined('ACTIVITY') OR define('ACTIVITY','T_ActivityMaster'); -defined('ACTIVITY_STATUS') OR define('ACTIVITY_STATUS','T_Activity_Status'); -defined('ANSWER_BOOKLET') OR define('ANSWER_BOOKLET','T_AnswerBookletStatus'); -defined('APPLICATION_STATUS') OR define('APPLICATION_STATUS','T_ApplicationStatus'); -defined('CERTIFICATION_STATUS') OR define('CERTIFICATION_STATUS','T_CertificationStatus'); -defined('STUDENTS_FEES_STATUS') OR define('STUDENTS_FEES_STATUS','T_Students_Fees_Status'); -defined('STUDENTS_FEES_PAID') OR define('STUDENTS_FEES_PAID','T_Students_Fees_PaidDetails'); -defined('STUDY_MATERIAL_STATUS') OR define('STUDY_MATERIAL_STATUS','T_StudyMaterialStatus'); -defined('CERTIFICATION') OR define('CERTIFICATION','T_CertificationMaster'); -defined('DEFAULTACTIVITY') OR define('DEFAULTACTIVITY','T_StatusMaster'); -defined('CERTIFICATION_MASTER') OR define('CERTIFICATION_MASTER','T_CertificationMaster'); -defined('DAYBOOKMASTER') OR define('DAYBOOKMASTER','T_DayBookMaster'); -defined('INCOMEOUTCOMEMASTER') OR define('INCOMEOUTCOMEMASTER','T_Income_Outcome_Master'); -defined('FEES_INSTALLMENT') OR define('FEES_INSTALLMENT','T_Fees_Installments'); -defined('CENTER') OR define('CENTER','T_CenterMaster'); -defined('SUBJECTMASTER') OR define('SUBJECTMASTER','T_SubjectMaster'); -defined('SESSIONMASTER') OR define('SESSIONMASTER','T_Session_Master'); -defined('SESSIONDETAILS') OR define('SESSIONDETAILS','T_SessionDetails'); -defined('COURSESUBJECT') OR define('COURSESUBJECT','T_CourseSubject_Details'); -defined('SESSIONSCHEDULE') OR define('SESSIONSCHEDULE','T_SessionSchedule_Master'); -defined('SESSIONSCHEDULEDETAILS') OR define('SESSIONSCHEDULEDETAILS','T_SessionSchedule_Details'); -defined('STUDENTDOCUMENTDETAILS') OR define('STUDENTDOCUMENTDETAILS','T_StudentDocumentsDetails'); -defined('STUDENTDOCUMENTTRACKDETAILS') OR define('STUDENTDOCUMENTTRACKDETAILS','T_Student_DocumentTrack_Details'); \ No newline at end of file +defined('INDUSTRYCLASSIFICATION') OR define('INDUSTRYCLASSIFICATION','m_industry_classification'); +defined('INDUSTRYCLASSIFICATIONID') OR define('INDUSTRYCLASSIFICATIONID','industry_classification_id'); + +defined('PRODUCTS') OR define('PRODUCTS','m_products'); +defined('PRODUCTSID') OR define('PRODUCTSID','product_id'); diff --git a/api/application/config/customconfig_one.php b/api/application/config/customconfig_one.php index cb102b94..648c7c7b 100644 --- a/api/application/config/customconfig_one.php +++ b/api/application/config/customconfig_one.php @@ -1,5 +1,9 @@ '', 'hostname' => 'sine-edge-dev.cya6cheplup2.ap-south-1.rds.amazonaws.com', - 'username' => 'sparqdev_mas001', + //'hostname' => 'localhost', + 'username' => 'sparqdev_mas001', + //'username' => 'root', 'password' => 'sparqvenba', + // 'password' => '', 'database' => 'sine_edge_dev', 'dbdriver' => 'mysqli', 'dbprefix' => '', diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 159f8c9f..2cce80ce 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -53,6 +53,60 @@ $route['default_controller'] = 'welcome'; $route['autenticadors'] = 'autenticador/index'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; -$route['login'] = 'Branch_Controller/testAWSS3'; -$route['getBranchDetails'] = 'Branch_Controller/getBranchDetails'; -$route['fileUpload'] = 'Branch_Controller/uploadFiles'; + +/* +| ------------------------------------------------------------------------- +| SineEdge REST API Routes +| ------------------------------------------------------------------------- +*/ +/* Routes regards Common Masters CRUD operations*/ + +$route['getListOfMasters'] = 'Common_Masters_Controller/getListOfMasters'; + +$route['getListOfIndustryClassifications'] = 'Common_Masters_Controller/getListOfIndustryClassifications'; +$route['saveIndustryClassification'] = 'Common_Masters_Controller/saveIndustryClassification'; + +$route['getListOfProducts'] = 'Common_Masters_Controller/getListOfProducts'; +$route['saveProducts'] = 'Common_Masters_Controller/saveProducts'; + +$route['getListOfSubProducts'] = 'Common_Masters_Controller/getListOfSubProducts'; +$route['saveSubProducts'] = 'Common_Masters_Controller/saveSubProducts'; + +$route['getListOfUOM'] = 'Common_Masters_Controller/getListOfUOM'; +$route['saveUOM'] = 'Common_Masters_Controller/saveUOM'; + +$route['getListOfOccupationNonEarningMembers'] = 'Common_Masters_Controller/getListOfOccupationNonEarningMembers'; +$route['saveOccupationNonEarningMembers'] = 'Common_Masters_Controller/saveOccupationNonEarningMembers'; + +$route['getListOfTypeOfActivities'] = 'Common_Masters_Controller/getListOfTypeOfActivities'; +$route['saveTypeOfActivity'] = 'Common_Masters_Controller/saveTypeOfActivity'; + +$route['getListOfTitles'] = 'Common_Masters_Controller/getListOfTitles'; +$route['saveTitle'] = 'Common_Masters_Controller/saveTitle'; + +$route['getListOfRelationships'] = 'Common_Masters_Controller/getListOfRelationships'; +$route['saveRelationship'] = 'Common_Masters_Controller/saveRelationship'; + +$route['getListOfFrequencies'] = 'Common_Masters_Controller/getListOfFrequencies'; +$route['saveFrequency'] = 'Common_Masters_Controller/saveFrequency'; + +$route['getListOfCustomerBehaviours'] = 'Common_Masters_Controller/getListOfCustomerBehaviours'; +$route['saveCustomerBehaviour'] = 'Common_Masters_Controller/saveCustomerBehaviour'; + +$route['getListOfRegions'] = 'Common_Masters_Controller/getListOfRegions'; +$route['saveRegion'] = 'Common_Masters_Controller/saveRegion'; + +$route['getListOfCites'] = 'Common_Masters_Controller/getListOfCites'; +$route['saveCity'] = 'Common_Masters_Controller/saveCity'; + +$route['getListOfCites'] = 'Common_Masters_Controller/getListOfCites'; +$route['saveCity'] = 'Common_Masters_Controller/saveCity'; + +$route['getListOfBranches'] = 'Common_Masters_Controller/getListOfBranches'; +$route['saveBranch'] = 'Common_Masters_Controller/saveBranch'; + +$route['getListOfMaster'] = 'Common_Masters_Controller/getListOfMaster'; +$route['saveMaster'] = 'Common_Masters_Controller/saveMaster'; + +//$route['login'] = 'User_Management_Controller/saveNewUser'; + diff --git a/api/application/controllers/Branch_Controller.php b/api/application/controllers/Branch_Controller.php index 83e3b2c0..86d8c460 100644 --- a/api/application/controllers/Branch_Controller.php +++ b/api/application/controllers/Branch_Controller.php @@ -38,7 +38,7 @@ class Branch_Controller extends REST_Controller { $this->load->model('Branch_model', 'branch_model'); //$this->load->library('AWS_S3'); //$this->load->library('AWS_SNS'); - $this->load->library('AWS_SES'); + //$this->load->library('AWS_SES'); } /* * get branch details @@ -115,8 +115,46 @@ class Branch_Controller extends REST_Controller { /* GET FILE FROM S3*/ - echo "SNS"; + /* + $id = MYDB::saveRecords(array('city_name'=>'salem'),'t_city_master'); + print_r($id); + */ + /* + $where_condition_array = array(); + $id = MYDB::selectRecords($where_condition_array,'t_city_master',$print_query = ''); + print_r($id); + */ + + + //$data = MYDB::updateRecords($record_data = array(),$table_name,$where_condition_array = array(),$print_query = '') + + /* + $where= array('city_name'=>'chennai','fk_state_id'=>'1'); + + $or_where = array('city_name'=>'salem','fk_state_id'=>'4'); + $or_where_total[] = $or_where; + $or_where = array('city_name'=>'erode'); + $or_where_total[] = $or_where; + + $fields = array('city_name','fk_state_id'); + $id = MYDB::selectCustomRecords($fields , $where,$or_where_total,$table = 't_city_master', $limit = '', $order_by_colum_name = 'fk_state_id', $order_by = '',$group_by = 'fk_state_id',$print_query = ''); + print_r($id); + */ + + /* + $columns = array('city_name','state_name'); + $table = 't_states_master'; + $joins = array( + array( + 'table' => 't_city_master', + 'condition' => 't_city_master.fk_state_id = t_states_master.state_id', + 'jointype' => 'INNER' + ), + ); + $id = MYDB::getJoinRecords($columns,$table,$joins,$print_query = ''); + print_r($id); + */ } public function testPDF_get() diff --git a/api/application/controllers/Common_masters_Controller.php b/api/application/controllers/Common_masters_Controller.php new file mode 100644 index 00000000..39499571 --- /dev/null +++ b/api/application/controllers/Common_masters_Controller.php @@ -0,0 +1,1057 @@ +load->model('Common_Masters_Model'); + + } + + /* Get List Of Mastsers for DropDown */ + public function getListOfMasters_get() + { + $result = $this->Common_Masters_Model->getListOfMasters(); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + + } + + /* Industry Classification Masters */ + + + public function getListOfIndustryClassifications_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_industry_classification'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveIndustryClassification_post() + { + $industryClassifications = $this->post('industryClassifications'); + + if($industryClassifications['industry_classification_id']) //Update Record + { + $where_condition_array = array('industry_classification_id'=>$industryClassificationData['industry_classification_id']); + + $result = $this->Common_Masters_Model->updateRecords($industryClassifications,'m_industry_classification',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($industryClassifications,'m_industry_classification'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + /* End Of Industry Classification Masters */ + + + + + /* Producsts Masters */ + + public function getListOfProducts_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_products'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveProducts_post() + { + $products = $this->post('products'); + + if($products['product_id']) //Update Record + { + $where_condition_array = array('product_id'=>$products['product_id']); + + $result = $this->Common_Masters_Model->updateRecords($products,'m_products',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($products,'m_products'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Producsts Masters */ + + + + + /* Sub - producsts Master */ + + public function getListOfSubProducts_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_subproducts'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveSubProducts_post() + { + $subproducts = $this->post('subproducts'); + + if($subproducts['subproduct_id']) //Update Record + { + $where_condition_array = array('subproduct_id'=>$subproducts['subproduct_id']); + + $result = $this->Common_Masters_Model->updateRecords($subproducts,'m_subproducts',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($subproducts,'m_subproducts'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Sub - producsts Master */ + + + + /* UOM Master */ + + public function getListOfUOM_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_uom'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveUOM_post() + { + $uom = $this->post('uom'); + + if($uom['uom_id']) //Update Record + { + $where_condition_array = array('uom_id'=>$uom['uom_id']); + + $result = $this->Common_Masters_Model->updateRecords($uom,'m_uom',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($uom,'m_uom'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + /* End Of UOM Master */ + + + + /* Occupation_non_earning_members Master */ + + + public function getListOfOccupationNonEarningMembers_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_occupation_non_earning_members'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveOccupationNonEarningMembers_post() + { + $occupationnonearningmembers = $this->post('occupationnonearningmembers'); + + if($occupationnonearningmembers['occupation_non_earning_member_id']) //Update Record + { + $where_condition_array = array('occupation_non_earning_member_id'=>$occupationnonearningmembers['occupation_non_earning_member_id']); + + $result = $this->Common_Masters_Model->updateRecords($occupationnonearningmembers,'m_occupation_non_earning_members',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($occupationnonearningmembers,'m_occupation_non_earning_members'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Occupation_non_earning_members Master */ + + + /* Type Of Activity Master */ + + + public function getListOfTypeOfActivities_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_type_of_activity'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveTypeOfActivity_post() + { + $typeofactivity = $this->post('typeofactivity'); + + if($typeofactivity['type_of_activity_id']) //Update Record + { + $where_condition_array = array('type_of_activity_id'=>$typeofactivity['type_of_activity_id']); + + $result = $this->Common_Masters_Model->updateRecords($typeofactivity,'m_type_of_activity',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($typeofactivity,'m_type_of_activity'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Type Of Activity Master */ + + + /* Titles Master */ + + + public function getListOfTitles_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_titles'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveTitle_post() + { + $title = $this->post('title'); + + if($title['title_id']) //Update Record + { + $where_condition_array = array('title_id'=>$title['title_id']); + + $result = $this->Common_Masters_Model->updateRecords($title,'m_titles',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($title,'m_titles'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Titles Master */ + + + + /* Relationships Master */ + + + public function getListOfRelationships_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_relationships'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveRelationship_post() + { + $relationship = $this->post('relationship'); + + if($relationship['relationship_id']) //Update Record + { + $where_condition_array = array('relationships'=>$relationship['relationship_id']); + + $result = $this->Common_Masters_Model->updateRecords($relationship,'m_relationship',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($relationship,'m_relationship'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Relationships Master */ + + + + /* Frequency Master */ + + + public function getListOfFrequencies_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_frequency'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveFrequency_post() + { + $frequency = $this->post('frequency'); + + if($frequency['frequency_id']) //Update Record + { + $where_condition_array = array('frequency_id'=>$frequency['frequency_id']); + + $result = $this->Common_Masters_Model->updateRecords($frequency,'m_frequency',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($frequency,'m_frequency'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Frequency Master */ + + + /* Customer Behaviour Master */ + + + public function getListOfCustomerBehaviours_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_customer_behaviour'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveCustomerBehaviour_post() + { + $customerbehaviour = $this->post('customerbehaviour'); + + if($customerbehaviour['customer_behaviour_id']) //Update Record + { + $where_condition_array = array('customer_behaviour_id'=>$customerbehaviour['customer_behaviour_id']); + + $result = $this->Common_Masters_Model->updateRecords($customerbehaviour,'m_customer_behaviour',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($customerbehaviour,'m_customer_behaviour'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Customer Behaviour Master */ + + + + /* Zonal/Regional Master */ + + + public function getListOfRegions_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_regions'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveRegion_post() + { + $region = $this->post('region'); + + if($region['region_id']) //Update Record + { + $where_condition_array = array('region_id'=>$region['region_id']); + + $result = $this->Common_Masters_Model->updateRecords($region,'m_regions',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($region,'m_regions'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Zonal/Regional Master */ + + + + /* States Master */ + + + public function getListOfStates_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_states'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveState_post() + { + $state = $this->post('state'); + + if($state['state_id']) //Update Record + { + $where_condition_array = array('state_id'=>$state['state_id']); + + $result = $this->Common_Masters_Model->updateRecords($state,'m_states',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($state,'m_states'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of States Master */ + + + /* City Master */ + + + public function getListOfCites_get() + { + $result = $this->Common_Masters_Model->selectRecords('m_city'); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveCity_post() + { + $city = $this->post('city'); + + if($city['city_id']) //Update Record + { + $where_condition_array = array('city_id'=>$city['city_id']); + + $result = $this->Common_Masters_Model->updateRecords($city,'m_city',$where_condition_array); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + $result = $this->Common_Masters_Model->saveRecords($city,'m_city'); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of City Master */ + + + + /* Branch Master */ + + + public function getListOfMaster_post() + { + + $table_name = $this->post('master_name'); + //echo $table_name; + $result = $this->Common_Masters_Model->selectRecords(constant($table_name)); + //print_r($result); + die(); + if(count($result) > 0) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } + } + + public function saveMaster_post() + { + $records = $this->post('records'); + $table_name = $this->post('master_name'); + + + if(false !== array_key_exists(constant($table_name.'ID'),$records)) //Update Record + { + + $where_condition_array = array(constant($table_name.'ID') => $records[constant($table_name.'ID')]); + + $result = $this->Common_Masters_Model->updateRecords($records,constant($table_name),$where_condition_array); + + if($result) + { + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + } + } + else // Insert Record + { + + $result = $this->Common_Masters_Model->saveRecords($records,constant($table_name)); + + if($result) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; + $this->response($data,REST_Controller::HTTP_SERVICE_UNAVAILABLE); + } + } + + } + + + + /* End Of Branch Master */ + + + +} \ No newline at end of file diff --git a/api/application/controllers/Test.php b/api/application/controllers/Test.php new file mode 100644 index 00000000..b9ec5e73 --- /dev/null +++ b/api/application/controllers/Test.php @@ -0,0 +1,75 @@ +load->helper(array('form', 'url')); + //$this->load->model('test_model'); + $this->load->library('asynclibrary'); + + } + + /** + * @desc : Function to perform multiple task in background + * @param :void + * @return : void + */ + public function ind_get(){ + //echo base_url(); + print_r(getallheaders()); + $url = base_url()."test/sendmail"; + $urls = base_url()."test/insert"; + + $param = array('email' => "jagroop@gmail.com" ); + $param1 = array('name' => "Jagroop Singh", + 'email' => "jagroop@gmail.com" ); + + // $async1 = $this->asynclibrary->do_in_background($url, $param); + // $async2 = $this->asynclibrary->do_in_background($urls, $param1); + // print_r($async1); + // print_r($async2); + + + } + + /** + * @desc : Function to send mail + * @param :void + * @return : void + */ + public function sendmail_post(){ + + // $this->load->library('email'); + $user_email = $_POST['email']; + // $message = "Testing"; + + // $this->email->from('wolfy@gmail.com', 'Wolfy Singh'); + // $this->email->to($user_email); + // $this->email->subject("test"); + // $this->email->message($message); + // $this->email->send(); + $id = $this->db->insert('t_city_master',array('city_name'=> $user_email)); + // echo $user_email; + // print_r($id); + } + + /** + * @desc : Function to call insert() method + * of test_model to insert data in database + * @param :void + * @return : void + */ + public function insert_post(){ + $user_email = $_POST['name']; + $this->db->insert('t_city_master',array('city_name'=>$user_email)); + // $email = $this->input->post('email'); + // $name = $this->input->post('name'); + // $this->test_model->insert($email, $name); + //echo "insert"; + } +} \ No newline at end of file diff --git a/api/application/controllers/User_Management_Controller.php b/api/application/controllers/User_Management_Controller.php new file mode 100644 index 00000000..cec489c8 --- /dev/null +++ b/api/application/controllers/User_Management_Controller.php @@ -0,0 +1,46 @@ +load->model('User_Management_Model'); + + } + + public function listAllUsers_get() + { + + } + + public function saveNewUser_post() + { + echo "saveNewUser_post"; + $data = $this->post('data'); + + //$file = $_FILES['myfile']; + print_r($data);//print_r($file); + } + + public function updateExistUser_post() + { + + } + + + + +} \ No newline at end of file diff --git a/api/application/helpers/mydb_helper.php b/api/application/helpers/mydb_helper.php new file mode 100644 index 00000000..a4273956 --- /dev/null +++ b/api/application/helpers/mydb_helper.php @@ -0,0 +1,117 @@ +db->insert($table_name,$record_data); + if($print_query == 1) + { + print_r($CI->db->last_query()); + } + return $CI->db->insert_id(); + //print_r($CI->db); + } + + public static function selectRecords($where_condition_array = array(),$table_name,$print_query = '') + { + $CI =&get_instance(); + $data = $CI->db->get_where($table_name,$where_condition_array)->result_array();//only AND condition + if($print_query == 1) + { + print_r($CI->db->last_query()); + } + return $data; + } + + public static function updateRecords($record_data = array(),$table_name,$where_condition_array = array(),$print_query = '') + { + $CI =&get_instance(); + $data = $CI->db->update($table_name,$record_data,$where_condition_array)->result_array(); + if($print_query == 1) + { + print_r($CI->db->last_query()); + } + return $data; + } + + public static function selectCustomRecords($fields = '', $where = array(), $or_where_total = array(),$table = '', $limit = '', $order_by_colum_name = '', $order_by = 'ASC', $group_by = '',$print_query = '') { + + $CI =&get_instance(); + + //$data = array(); + if ($fields != '') { + $CI->db->select($fields); + } + + if (count($where)) { + $CI->db->where($where); + } + + if (count($or_where_total)) { + + foreach($or_where_total as $or_where) + { + $CI->db->or_where($or_where); + } + } + + if ($table != '') { + $CI->table_name = $table; + } + + if ($limit != '') { + $CI->db->limit($limit); + } + + if ($order_by_colum_name != '') { + $CI->db->order_by($order_by_colum_name,$order_by); + } + + if ($group_by != '') { + $CI->db->group_by($group_by); + } + + + $data = $CI->db->get($CI->table_name)->result_array(); + + if ($print_query == '1') { + print_r($CI->db->last_query()); + } + return $data; + + + } + + public static function getJoinRecords($columns,$table,$joins,$print_query = '') + { + $CI =&get_instance(); + + $CI->db->select($columns)->from($table); + if (is_array($joins) && count($joins) > 0) + { + foreach($joins as $k => $join) + { + $CI->db->join($join['table'], $join['condition'], $join['jointype']); + } + } + + + $data = $CI->db->get()->result_array(); + + if ($print_query != '') { + print_r($CI->db->last_query()); + } + + return $data; + } + + +} + +?> \ No newline at end of file diff --git a/api/application/libraries/AMP.php b/api/application/libraries/AMP.php new file mode 100644 index 00000000..ff828d1c --- /dev/null +++ b/api/application/libraries/AMP.php @@ -0,0 +1,45 @@ +setOption(Amp\Artax\Client::OP_DISCARD_BODY, true); + + try { + foreach ($uris as $uri) { + $promises[$uri] = $client->request($uri); + } + + $responses = yield $promises; + + foreach ($responses as $uri => $response) { + print $uri . " - " . $response->getStatus() . $response->getReason() . PHP_EOL; + } + } catch (Amp\Artax\HttpException $error) { + // If something goes wrong Amp will throw the exception where the promise was yielded. + // The Client::request() method itself will never throw directly, but returns a promise. + print $error->getMessage() . PHP_EOL; + } + }); + } + +} + +?> \ No newline at end of file diff --git a/api/application/libraries/Asynclibrary.php b/api/application/libraries/Asynclibrary.php new file mode 100644 index 00000000..349e4150 --- /dev/null +++ b/api/application/libraries/Asynclibrary.php @@ -0,0 +1,58 @@ +ci =& get_instance(); + } + + function do_in_background($url, $params) + { + //echo "\n\nURL\n\n"; + //print_r($url); + ///echo "\n\params\n\n"; + //print_r($params); + + $post_string = http_build_query($params); + $parts = parse_url($url); + + // echo "\n\post_string\n\n"; + // print_r($post_string); + // echo "\n\parts\n\n"; + // print_r($parts); + + $errno = 0; + $errstr = ""; + + //Use SSL & port 443 for secure servers + //Use otherwise for localhost and non-secure servers + //For secure server + //$fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : 443, $errno, $errstr, 30); + + //For localhost and un-secure server + $fp = fsockopen($parts['host'], isset($parts['port']) ? 9999 : 9999, $errno, $errstr, 30); + // echo "FP";print_r($fp); + if(!$fp) + { + echo "Something Went Wrong"; + } + $out = "POST ".$parts['path']." HTTP/1.1\r\n"; + $out.= "Host: ".$parts['host']."\r\n"; + $out.= "Authorization:"."sparqvenba2018"."\r\n"; + $out.= "Content-Type: application/x-www-form-urlencoded\r\n"; + $out.= "Content-Length: ".strlen($post_string)."\r\n"; + $out.= "Connection: Close\r\n\r\n"; + //print_r($out); + if (isset($post_string)) $out.= $post_string; + //echo "isset"; + fwrite($fp, $out); + // while (!feof($fp)) { + // echo fgets($fp, 128); + // } + + fclose($fp); + } +} +?> \ No newline at end of file diff --git a/api/application/libraries/SPARQ_Model.php b/api/application/libraries/SPARQ_Model.php new file mode 100644 index 00000000..9be45c5e --- /dev/null +++ b/api/application/libraries/SPARQ_Model.php @@ -0,0 +1,125 @@ +load->database(); + + } + + public function saveRecords($record_data = array(),$table_name,$print_query = '') + { + + $this->db->insert($table_name,$record_data); + if($print_query == 1) + { + print_r($this->db->last_query()); + } + return $this->db->insert_id(); + + } + + public function selectRecords($table_name,$where_condition_array = array(),$print_query = '') + { + echo $print_query; + echo $table_name; + + $data = $this->db->get_where($table_name,$where_condition_array)->result_array();//only AND condition + print_r($data); + if($print_query == 1) + { + print_r($this->db->last_query()); + } + return $data; + } + + public function updateRecords($record_data = array(),$table_name,$where_condition_array = array(),$print_query = '') + { + + $data = $this->db->update($table_name,$record_data,$where_condition_array); + if($print_query == 1) + { + print_r($this->db->last_query()); + } + return $data; + } + + public function selectCustomRecords($fields = '', $where = array(), $or_where_total = array(),$table = '', $limit = '', $order_by_colum_name = '', $order_by = 'ASC', $group_by = '',$print_query = '') { + + + + //$data = array(); + if ($fields != '') { + $this->db->select($fields); + } + + if (count($where)) { + $this->db->where($where); + } + + if (count($or_where_total)) { + + foreach($or_where_total as $or_where) + { + $this->db->or_where($or_where); + } + } + + if ($table != '') { + $this->table_name = $table; + } + + if ($limit != '') { + $this->db->limit($limit); + } + + if ($order_by_colum_name != '') { + $this->db->order_by($order_by_colum_name,$order_by); + } + + if ($group_by != '') { + $this->db->group_by($group_by); + } + + + $data = $this->db->get($this->table_name)->result_array(); + + if ($print_query == '1') { + print_r($this->db->last_query()); + } + return $data; + + + } + + public function getJoinRecords($columns,$table,$joins,$print_query = '') + { + + + $this->db->select($columns)->from($table); + if (is_array($joins) && count($joins) > 0) + { + foreach($joins as $k => $join) + { + $this->db->join($join['table'], $join['condition'], $join['jointype']); + } + } + + + $data = $this->db->get()->result_array(); + + if ($print_query != '') { + print_r($this->db->last_query()); + } + + return $data; + } + + +} diff --git a/api/application/models/Branch_model.php b/api/application/models/Branch_model.php index 97c99415..7780894e 100644 --- a/api/application/models/Branch_model.php +++ b/api/application/models/Branch_model.php @@ -1,151 +1,12 @@ upload_image($imageSource, $target); - $imageNameDb = $getUploadStatus['imageName']; - $arrayDetails['LogoPath'] = $getUploadStatus == true ? "logo/".$imageNameDb : ''; -// print_r($arrayDetails['IsActive']);exit(); - $this->db->select('BranchCode'); - $this->db->where('BranchCode', $arrayDetails['BranchCode']); - if($this->db->get(BRANCH)->first_row()){ - $result['BranchStatus'] = false; - $result['message'] = "This branch code is already exist!"; - } else { - $this->db->select('BranchName'); - $this->db->where('BranchName', $arrayDetails['BranchName']); - if($this->db->get(BRANCH)->first_row()){ - $result['BranchStatus'] = false; - $result['message'] = "This branch name is already exist!"; - } else{ - $this->db->insert(BRANCH, $arrayDetails); - if($this->db->affected_rows() == '1'){ - - $result['branchStatus'] = true; - $result['message'] = "Successfully branch details added"; - } - - else { - $result['branchStatus'] = false; - $result['message'] = "Something went wrong.please try again"; - } - } +class Branch_model extends SPARQ_Model { + public function __construct() { + parent::__construct(); } - - - - return $result; - - } - /* - * get branch details - * parama id - * created by kms - * */ - - public function getBranch() - { - $this->db->select('BranchCode,BranchName,LogoPath,MobileNumber,AlternateNumber,LandlineNumber,Address,EmailID,CreatedOn,IsActive,FeesReceiptTitle as feesTitle'); - $this->db->order_by('CreatedOn','DESC'); - $branchDetails = $this->db->get(BRANCH); - - if($branchDetails->result()){ - - $result['branchStatus'] = true; - $result['details'] = $branchDetails->result(); - } - else { - $result['branchStatus'] = false; - $result['message'] = "No records found!"; - } - - return $result; - - } - /* - * update branch details - * created by kms - * */ - - public function updateBranch($arrayDetails=null,$branchCode=null, $imageSource, $imageStat) - { - if( $imageStat == 1 ) { - $target = "../images/logo/"; - $getUploadStatus = $this-> upload_image($imageSource, $target); - $imageNameDb = $getUploadStatus['imageName']; - $arrayDetails['LogoPath'] = $getUploadStatus == true ? "logo/".$imageNameDb : null; - } else { - - } - -// print_r($arrayDetails['IsActive']);exit(); - - $this->db->where('BranchCode',$branchCode); - $upateStatus=$this->db->update(BRANCH, $arrayDetails); - if($upateStatus){ - $result['branchStatus'] = true; - $result['message'] = "Successfully branch details updated"; - } - - else { - $result['branchStatus'] = false; - $result['message'] = "Something went wrong.please try again"; - - } - - - return $result; - - } - - // image upload in taget path - public function upload_image( $imageSource, $target ) { - $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 12); - $new_regNo = "Dri_" . $key2 . "." . 'jpeg'; - $targetPlace = $target . $new_regNo; - // echo $targetPlace;exit(); - if(!move_uploaded_file($imageSource , $targetPlace)) - { - return $result['status'] = false; - } else { - $result['status'] = true; - $result['imageName'] = $new_regNo; - return $result; - } - } - // student document upload target path - public function uploadFiles($resource=null) { - $target="myDocs/"; - $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 12); - $new_regNo = "Dri_".$key2."_".$resource['doc_name']; - $targetPlace = $target . $new_regNo; - // echo $targetPlace;exit(); - if (!move_uploaded_file($resource['doc_source'], $targetPlace)) { - return $result['uploadStatus'] = false; - } else { - $result['uploadStatus'] = true; - $result['sourceName'] = $new_regNo; - return $result; - } - } } \ No newline at end of file diff --git a/api/application/models/Common_Masters_Model.php b/api/application/models/Common_Masters_Model.php new file mode 100644 index 00000000..6d17f34b --- /dev/null +++ b/api/application/models/Common_Masters_Model.php @@ -0,0 +1,20 @@ +selectRecords('m_list_of_masters'); + } + + +} \ No newline at end of file diff --git a/api/application/models/User_Management_Model.php b/api/application/models/User_Management_Model.php new file mode 100644 index 00000000..f5966453 --- /dev/null +++ b/api/application/models/User_Management_Model.php @@ -0,0 +1,15 @@ + Welcome to CodeIgniter +