Guest User

Untitled

a guest
Nov 19th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.53 KB | None | 0 0
  1. public function search_record()
  2.  
  3. {
  4.  
  5.  
  6. $id= $this->input->get('id');
  7. $name= $this->input->get('lname');
  8. $fname= $this->input->get('fname');
  9. $pdate= $this->input->get('pdate');
  10. $adate= $this->input->get('adate');
  11. $client= $this->input->get('client');
  12. $bw= $this->input->get('bw');
  13. $color= $this->input->get('color');
  14. $digital= $this->input->get('digital');
  15. $famous= $this->input->get('famous');
  16. $place= $this->input->get('place');
  17. $concept= $this->input->get('concept');
  18. $thing= $this->input->get('thing');
  19. $oldid= $this->input->get('oldid');
  20.  
  21. $note= $this->input->get('note');
  22.  
  23.  
  24.  
  25. // $condition = array('id_photo' =>$id);
  26. // $condition2=array('lastname'=>$name);
  27. // $condition3=array('firstname'=>$fname);
  28. // $condition4=array('photo_date'=>$pdate);
  29. //
  30.  
  31. $this->db->select('photo_id,lastname,firstname,bw,color,digital,famous,place,concept,thing,client,photo_date,add_date,note,id_photo');
  32. $this->db->from('tblphotomstr');
  33. $strWhere = "";
  34. if($id != NULL){
  35. $strWhere = "id_photo like "."'%$id%'";
  36. }
  37. if($name != NULL){
  38. $opt = $this->input->get('and');
  39.  
  40.  
  41. if($opt==1)
  42. {
  43. if($strWhere != "")
  44. {
  45. $strWhere = $strWhere." and lastname like "."'%$name%'";
  46. }else{
  47. $strWhere = "lastname like "."'%$name%'";
  48. }
  49. }
  50. if($opt==2)
  51. {
  52. if($strWhere != ""){
  53. $strWhere = $strWhere." or lastname like "."'%$name%'";
  54. }else{
  55. $strWhere = "lastname like "."'%$name%'";
  56. }
  57. }
  58. }
  59. if($fname != NULL){
  60. $opt = $this->input->get('and');
  61.  
  62.  
  63. if($opt==1)
  64. {
  65. if($strWhere != "")
  66. {
  67. $strWhere = $strWhere." and firstname like "."'%$fname%'";
  68. }else{
  69. $strWhere = "firstname like "."'%$fname%'";
  70. }
  71. }
  72. if($opt==2)
  73. {
  74. if($strWhere != ""){
  75. $strWhere = $strWhere." or firstname like "."'%$fname%'";
  76. }else{
  77. $strWhere = "firstname like "."'%$fname%'";
  78. }
  79. }
  80. }
  81. if($pdate != NULL){
  82. $opt = $this->input->get('and');
  83.  
  84.  
  85. if($opt==1)
  86. {
  87. if($strWhere != "")
  88. {
  89. $strWhere = $strWhere." and photo_date like "."'%$pdate%'";
  90. }else{
  91. $strWhere = "photo_date like "."'%$pdate%'";
  92. }
  93. }
  94. if($opt==2)
  95. {
  96. if($strWhere != ""){
  97. $strWhere = $strWhere." or photo_date like "."'%$pdate%'";
  98. }else{
  99. $strWhere = "photo_date like "."'%$pdate%'";
  100. }
  101. }
  102. }
  103. if($adate != NULL){
  104. $opt = $this->input->get('and');
  105.  
  106.  
  107. if($opt==1)
  108. {
  109. if($strWhere != "")
  110. {
  111. $strWhere = $strWhere." and add_date like "."'%$adate%'";
  112. }else{
  113. $strWhere = "add_date like "."'%$adate%'";
  114. }
  115. }
  116. if($opt==2)
  117. {
  118. if($strWhere != ""){
  119. $strWhere = $strWhere." or add_date like "."'%$adate%'";
  120. }else{
  121. $strWhere = "add_date like "."'%$adate%'";
  122. }
  123. }
  124. }
  125. if($client != NULL){
  126. $opt = $this->input->get('and');
  127.  
  128.  
  129. if($opt==1)
  130. {
  131. if($strWhere != "")
  132. {
  133. $strWhere = $strWhere." and client like "."'%$client%'";
  134. }else{
  135. $strWhere = "client like "."'%$client%'";
  136. }
  137. }
  138. if($opt==2)
  139. {
  140. if($strWhere != ""){
  141. $strWhere = $strWhere." or client like "."'%$client%'";
  142. }else{
  143. $strWhere = "client like "."'%$client%'";
  144. }
  145. }
  146. }
  147. if($bw != NULL){
  148. $opt = $this->input->get('and');
  149.  
  150.  
  151. if($opt==1)
  152. {
  153. if($strWhere != "")
  154. {
  155. $strWhere = $strWhere." and client like "."'%$bw%'";
  156. }else{
  157. $strWhere = "client like "."'%$bw%'";
  158. }
  159. }
  160. if($opt==2)
  161. {
  162. if($strWhere != ""){
  163. $strWhere = $strWhere." or client like "."'%$bw%'";
  164. }else{
  165. $strWhere = "client like "."'%$bw%'";
  166. }
  167. }
  168. }
  169. if($color != NULL){
  170. $opt = $this->input->get('and');
  171.  
  172.  
  173. if($opt==1)
  174. {
  175. if($strWhere != "")
  176. {
  177. $strWhere = $strWhere." and client like "."'%$color%'";
  178. }else{
  179. $strWhere = "client like "."'%$color%'";
  180. }
  181. }
  182. if($opt==2)
  183. {
  184. if($strWhere != ""){
  185. $strWhere = $strWhere." or client like "."'%$color%'";
  186. }else{
  187. $strWhere = "client like "."'%$color%'";
  188. }
  189. }
  190. }
  191. if($digital != NULL){
  192. $opt = $this->input->get('and');
  193.  
  194.  
  195. if($opt==1)
  196. {
  197. if($strWhere != "")
  198. {
  199. $strWhere = $strWhere." and client like "."'%$digital%'";
  200. }else{
  201. $strWhere = "client like "."'%$color%'";
  202. }
  203. }
  204. if($opt==2)
  205. {
  206. if($strWhere != ""){
  207. $strWhere = $strWhere." or client like "."'%$digital%'";
  208. }else{
  209. $strWhere = "client like "."'%$digital%'";
  210. }
  211. }
  212. }
  213. if($famous != NULL){
  214. $opt = $this->input->get('and');
  215.  
  216.  
  217. if($opt==1)
  218. {
  219. if($strWhere != "")
  220. {
  221. $strWhere = $strWhere." and client like "."'%$famous%'";
  222. }else{
  223. $strWhere = "client like "."'%$famous%'";
  224. }
  225. }
  226. if($opt==2)
  227. {
  228. if($strWhere != ""){
  229. $strWhere = $strWhere." or client like "."'%$digital%'";
  230. }else{
  231. $strWhere = "client like "."'%$digital%'";
  232. }
  233. }
  234. }
  235. if($place != NULL){
  236. $opt = $this->input->get('and');
  237.  
  238.  
  239. if($opt==1)
  240. {
  241. if($strWhere != "")
  242. {
  243. $strWhere = $strWhere." and client like "."'%$place%'";
  244. }else{
  245. $strWhere = "client like "."'%$place%'";
  246. }
  247. }
  248. if($opt==2)
  249. {
  250. if($strWhere != ""){
  251. $strWhere = $strWhere." or client like "."'%$place%'";
  252. }else{
  253. $strWhere = "client like "."'%$place%'";
  254. }
  255. }
  256. }
  257. if($concept != NULL){
  258. $opt = $this->input->get('and');
  259.  
  260.  
  261. if($opt==1)
  262. {
  263. if($strWhere != "")
  264. {
  265. $strWhere = $strWhere." and client like "."'%$concept%'";
  266. }else{
  267. $strWhere = "client like "."'%$concept%'";
  268. }
  269. }
  270. if($opt==2)
  271. {
  272. if($strWhere != ""){
  273. $strWhere = $strWhere." or client like "."'%$concept%'";
  274. }else{
  275. $strWhere = "client like "."'%$concept%'";
  276. }
  277. }
  278. }
  279. if($thing != NULL){
  280. $opt = $this->input->get('and');
  281.  
  282.  
  283. if($opt==1)
  284. {
  285. if($strWhere != "")
  286. {
  287. $strWhere = $strWhere." and client like "."'%$thing%'";
  288. }else{
  289. $strWhere = "client like "."'%$thing%'";
  290. }
  291. }
  292. if($opt==2)
  293. {
  294. if($strWhere != ""){
  295. $strWhere = $strWhere." or client like "."'%$thing%'";
  296. }else{
  297. $strWhere = "client like "."'%$thing%'";
  298. }
  299. }
  300. }
  301. if($oldid != NULL){
  302. $opt = $this->input->get('and');
  303.  
  304.  
  305. if($opt==1)
  306. {
  307. if($strWhere != "")
  308. {
  309. $strWhere = $strWhere." and client like "."'%$oldid%'";
  310. }else{
  311. $strWhere = "client like "."'%$oldid%'";
  312. }
  313. }
  314. if($opt==2)
  315. {
  316. if($strWhere != ""){
  317. $strWhere = $strWhere." or client like "."'%$oldid%'";
  318. }else{
  319. $strWhere = "client like "."'%$oldid%'";
  320. }
  321. }
  322. }
  323. if($note != NULL){
  324. $opt = $this->input->get('and');
  325.  
  326.  
  327. if($opt==1)
  328. {
  329. if($strWhere != "")
  330. {
  331. $strWhere = $strWhere." and note like "."'%$note%'";
  332. }else{
  333. $strWhere = "note like "."'%$note%'";
  334. }
  335. }
  336. if($opt==2)
  337. {
  338. if($strWhere != ""){
  339. $strWhere = $strWhere." or note like "."'%$note%'";
  340. }else{
  341. $strWhere = "note like "."'%$note%'";
  342. }
  343. }
  344. }
  345.  
  346. public function search()
  347. {
  348.  
  349. print_r($this->search_model->search_record());
  350.  
  351. $limit = 1;
  352.  
  353. $config["base_url"] = base_url('Home/search');
  354.  
  355. $config['total_rows'] = $this->db->count_all('tblphotomstr');
  356. $config["per_page"] = $limit;
  357. $config['use_page_numbers'] = TRUE;
  358. $config['page_query_string'] = TRUE;
  359. $config['enable_query_strings'] = TRUE;
  360. $config['cur_tag_open'] = '&nbsp;<li class="active"><a>';
  361. $config['cur_tag_close'] = '</a></li>';
  362. $config['next_link'] = 'Next';
  363. $config['prev_link'] = 'Previous';
  364. $this->pagination->initialize($config);
  365.  
  366. $offset = 0;
  367. if (!empty($_GET['per_page'])) {
  368. $pageNo = $_GET['per_page'];
  369. $offset = ($pageNo - 1) * $limit;
  370. }
  371.  
  372. $data = array();
  373. $this->db->limit($limit, $offset);
  374.  
  375. $data['records']= $this->search_model->search_record();
  376. print_r($data);
  377. $this->template->set('title', 'Edit Record');
  378. $this->template->load('default_layout', 'contents' , 'search', $data);
  379.  
  380.  
  381.  
  382. }
Add Comment
Please, Sign In to add comment