public function index() { if (Input::get('q')) { $datums = Country::select('name AS value', 'id', 'abbreviation')->where('name', 'like', '%' . Input::get('q') . '%')->take(50)->get(); foreach ($datums as $datum) { //print_r($datum->toArray()); $datum->tokens = explode(' ', $datum->value); } return Response::json($datums); } else { return Response::json(Country::select('name AS value', 'id', 'abbreviation')->orderBy('name', 'ASC')->get()); } }
<?php include_once $CFG->dirroot . "/lib/classes/" . "application/Country.Class.php5"; $CountryObj = new Country(); $GeneralObj->getRequestVars(); $section = 'Country'; if ($mode == "Update") { $CountryObj->select($iCountryId); $CountryObj->getAllVar(); } else { $mode = "Add"; } if ($file != '') { $link = "index.php?file=" . $file . "&mode=" . $mode . "&listfile=" . $listfile; } $TOP_HEADER = $mode . ' ' . $section; if ($mode == 'Update') { $TOP_HEADER = $mode . ' ' . $section; } if ($mode == 'Update') { $TOP_HEADER .= ' [' . $vCountry . ']'; } if ($eType != '') { $ExtraVal = "&eType=" . $eType; } ?> <form name="frmadd" method="post" action="index.php?file=t-country_masteradd_a" enctype="multipart/form-data" onSubmit="return validate_new(this);"> <input type="hidden" name="mode" value="<?php echo $mode; ?> ">
/** * Show a list of all the countries formatted for Datatables. * * @return Datatables JSON */ public function getCountries() { $countries = Country::select(array('id', 'country', 'created_at', 'updated_at')); return Datatables::of($countries)->add_column('actions', '<a href="{{{ URL::to(\'admin/countries/\' . $id . \'/edit\' ) }}}" class="iframe btn btn-xs btn-default">{{{ Lang::get(\'button.edit\') }}}</a> <a href="{{{ URL::to(\'admin/countries/\' . $id . \'/delete\' ) }}}" class="iframe btn btn-xs btn-danger">{{{ Lang::get(\'button.delete\') }}}</a> ')->remove_column('id')->make(); }
$iCountryId = PostVar("iCountryId"); $actionfile = GetVar("file"); /** This is for Check Duplicate Record-------------------------------------------*/ $generalobj->getRequestVars(); $redirect_file = "index.php?file={$file}&view={$view}&iCountryId={$iCountryId}"; $generalobj->checkDuplicate('iCountryId', PRJ_DB_PREFIX . "_country_master", array('vCountry' => $Data['vCountry']), $redirect_file, COUNTRY_ALREADY_EXISTS, $iCountryId); if ($view == "add") { //prints($Data);exit; $countryObj->setAllVar($Data); $id = $countryObj->insert(); if ($id) { $var_msg = "Record Added Successfully."; } else { $var_msg = "Eror-in Add."; } } else { if ($view == "edit") { $arr = $countryObj->select($iCountryId); $countryObj->setAllVar($arr); $countryObj->setAllVar($Data); $where = " iCountryId = '" . $iCountryId . "'"; $id = $countryObj->update($where); if ($id) { $var_msg = "Record Updated Successfully."; } else { $var_msg = "Eror-in Update."; } } } header("Location:index.php?file=" . $actionfile . "&view=index&AX=Yes&var_msg={$var_msg}"); exit;