subLane Posted June 28, 2012 Report Share Posted June 28, 2012 Здравствуйте. Необходимо в заказах в админке, сделать фильтр по периоду времени, например, выбираем период времени с 5.09.11 по 8.05.12 и у нас отображаются все заказы за данный период времени. Данный функционал очень необходим помогите реализовать пожалуйста. Quote Link to post Share on other sites
Wizard Posted June 28, 2012 Report Share Posted June 28, 2012 ты что??? такая функциональность нагрузит СИМПЛУ, это же лишний код и дополнительная обработка!неужели такие мелочи не могли быть реализованы автором - это ведь действительно удобно и необходимо.... Quote Link to post Share on other sites
subLane Posted June 28, 2012 Author Report Share Posted June 28, 2012 Не очень понял ход твоих мыслей, извини. Ты можешь помочь это реализовать? я не прошу бесплатной помощи Quote Link to post Share on other sites
Wizard Posted June 28, 2012 Report Share Posted June 28, 2012 это сарказм)))) Quote Link to post Share on other sites
subLane Posted June 28, 2012 Author Report Share Posted June 28, 2012 Данный функционал на мой взгляд достаточно полезен и будет нужен не только мне, как мне кажется Quote Link to post Share on other sites
subLane Posted June 28, 2012 Author Report Share Posted June 28, 2012 Я это понял, не понял к чему ты это, то что это очень просто сделать? Quote Link to post Share on other sites
Wizard Posted June 28, 2012 Report Share Posted June 28, 2012 это очень просто сделать...в погоне за минимализацией кода автор упускает такие мелочи... эта функциональность не просто полезна – она необходима! Quote Link to post Share on other sites
subLane Posted June 28, 2012 Author Report Share Posted June 28, 2012 дак ты сможешь помочь это реализовать? потому что сейчас мы просто засоряем тему Quote Link to post Share on other sites
subLane Posted June 28, 2012 Author Report Share Posted June 28, 2012 и с чего ты взял что занимаюсь минимализацией кода? Quote Link to post Share on other sites
Wizard Posted June 28, 2012 Report Share Posted June 28, 2012 *** я про автора Сиплыпомочь смогу, если раньше чем я освобожусь ты не решишь этот вопрос... Quote Link to post Share on other sites
subLane Posted June 28, 2012 Author Report Share Posted June 28, 2012 хорошо, тогда как освободишься напиши либо сюда решение, оно будет для всех полезно в будущем, либо в личку напиши мне. Спасибо большое. Quote Link to post Share on other sites
filth Posted June 28, 2012 Report Share Posted June 28, 2012 Присоединяюсь, очень нужно. Quote Link to post Share on other sites
Wizard Posted June 29, 2012 Report Share Posted June 29, 2012 набросал...вставляем OrdersAdmin.php после 23-й строки // Фильтр $get_filter = $this->request->get('filter'); if($get_filter['date_from']) $filter['date_from'] = date("Y-m-d 00:00:01",strtotime($get_filter['date_from'])); if($get_filter['date_to']) $filter['date_to'] = date("Y-m-d 23:59:00",strtotime($get_filter['date_to']));в Orders.php, функция get_orders if(isset($filter['date_from']) && !isset($filter['date_to'])){ $date_filter = $this->db->placehold('AND o.date > ?', $filter['date_from']); } elseif(isset($filter['date_to']) && !isset($filter['date_from'])){ $date_filter = $this->db->placehold('AND o.date < ?', $filter['date_to']); } elseif(isset($filter['date_to']) && isset($filter['date_from'])){ $date_filter = $this->db->placehold('AND (o.date BETWEEN ? AND ?)', $filter['date_from'], $filter['date_to']); }там же добавляем условие запроса к базе $date_filterв шаблон {* On document load *} {literal} <script src="design/js/jquery/datepicker/jquery.ui.datepicker-ru.js"></script> <script> $(function() { $('input[name="filter[date_from]"]').datepicker({ regional:'ru' }); $('input[name="filter[date_to]"]').datepicker({ regional:'ru' }); }); </script> <script type="text/javascript"> function show_fields() { document.getElementById("filter_fields").style.display = document.getElementById("check").checked ? 'block' : 'none'; } </script> {/literal} {* Фильтр *} <div style="display: block; width:700px; clear:both; border-radius:10px; border: 1px solid #C0C0C0; margin: 10px 0; padding: 10px"> <form method="get"> <div id='filter_check'> <input type="checkbox" name="filter[check]" id="check" value='1' {if $smarty.get.filter.check}checked{/if} onclick="show_fields();"/> <label for="check">Фильтр</label> </div> <div id='filter_fields' {if !$smarty.get.filter.check}style="display: none"{/if}> <input type="hidden" name="module" value="OrdersAdmin"> <input type="hidden" name="status" value="{$status}"> <div style="margin: 15px 0"> <label>Дата с: </label><input type=text name=filter[date_from] value='{$smarty.get.filter.date_from}'> <label>По: </label><input type=text name=filter[date_to] value='{$smarty.get.filter.date_to}'> </div> <input id="apply_action" class="button_green" type="submit" value="Применить"> </div> </form> </div> {capture name=tabs} <li {if $status===0}class="active"{/if}><a href="{url module=OrdersAdmin status=0 keyword=null filter=null id=null page=null}">Новые</a></li> <li {if $status==1}class="active"{/if}><a href="{url module=OrdersAdmin status=1 keyword=null filter=null id=null page=null}">Приняты</a></li> <li {if $status==2}class="active"{/if}><a href="{url module=OrdersAdmin status=2 keyword=null filter=null id=null page=null}">Выполнены</a></li> <li {if $status==3}class="active"{/if}><a href="{url module=OrdersAdmin status=3 keyword=null filter=null id=null page=null}">Удалены</a></li> {if $keyword} <li class="active"><a href="{url module=OrdersAdmin keyword=$keyword id=null}">Поиск</a></li> {/if} {/capture} Quote Link to post Share on other sites
kikaxa Posted June 29, 2012 Report Share Posted June 29, 2012 поставил всё ок большое спасибо Quote Link to post Share on other sites
subLane Posted June 29, 2012 Author Report Share Posted June 29, 2012 да, есть волшебники на свете))) спасибо Quote Link to post Share on other sites
filth Posted June 29, 2012 Report Share Posted June 29, 2012 Причем добрые...там же добавляем условие запроса к базе$date_filterВот этот момент не совсем понял. Quote Link to post Share on other sites
Wizard Posted June 29, 2012 Report Share Posted June 29, 2012 этот момент надо вставить в условие запроса к базе Quote Link to post Share on other sites
filth Posted June 29, 2012 Report Share Posted June 29, 2012 в условие запроса к базеМожно как для чайника? Quote Link to post Share on other sites
filth Posted June 29, 2012 Report Share Posted June 29, 2012 Просто что то не работает. Quote Link to post Share on other sites
filth Posted June 29, 2012 Report Share Posted June 29, 2012 сам разобрался. Спасибо огромное. Quote Link to post Share on other sites
Noxter Posted June 29, 2012 Report Share Posted June 29, 2012 Что-то у меня не фильтрует и выдает те же заказы что и на странице новых заказов.Разобрался, в шаблоне была ошибка.Wizard спасибо! Quote Link to post Share on other sites
Only Posted January 20, 2013 Report Share Posted January 20, 2013 Спасибо огромное, очень нужная вещь.Нашел косяк. Если регишься на сайте и нажимаешь на ник выскакивает нотис:Notice: Undefined variable: date_filter in /home/aqq9440/public_html/shurshim.ru/api/Orders.php on line 175Warning: Cannot modify header information - headers already sent by (output started at /home/aqq9440/public_html/shurshim.ru/api/Orders.php:175) in /home/aqq9440/public_html/shurshim.ru/index.php on line 26 Quote Link to post Share on other sites
Onlycj Posted October 2, 2013 Report Share Posted October 2, 2013 Никто не нашел решения? Quote Link to post Share on other sites
mart Posted October 2, 2013 Report Share Posted October 2, 2013 Orders.php, функция get_orders в самом начале добавить определение переменной $date_filter = ''; Quote Link to post Share on other sites
allon925 Posted October 8, 2013 Report Share Posted October 8, 2013 набросал... вставляем OrdersAdmin.php после 23-й строки // Фильтр $get_filter = $this->request->get('filter'); if($get_filter['date_from']) $filter['date_from'] = date("Y-m-d 00:00:01",strtotime($get_filter['date_from'])); if($get_filter['date_to']) $filter['date_to'] = date("Y-m-d 23:59:00",strtotime($get_filter['date_to']));в Orders.php, функция get_orders if(isset($filter['date_from']) && !isset($filter['date_to'])){ $date_filter = $this->db->placehold('AND o.date > ?', $filter['date_from']); } elseif(isset($filter['date_to']) && !isset($filter['date_from'])){ $date_filter = $this->db->placehold('AND o.date < ?', $filter['date_to']); } elseif(isset($filter['date_to']) && isset($filter['date_from'])){ $date_filter = $this->db->placehold('AND (o.date BETWEEN ? AND ?)', $filter['date_from'], $filter['date_to']); }там же добавляем условие запроса к базе $date_filterв шаблон {* On document load *} {literal} <script src="design/js/jquery/datepicker/jquery.ui.datepicker-ru.js"></script> <script> $(function() { $('input[name="filter[date_from]"]').datepicker({ regional:'ru' }); $('input[name="filter[date_to]"]').datepicker({ regional:'ru' }); }); </script> <script type="text/javascript"> function show_fields() { document.getElementById("filter_fields").style.display = document.getElementById("check").checked ? 'block' : 'none'; } </script> {/literal} {* Фильтр *} <div style="display: block; width:700px; clear:both; border-radius:10px; border: 1px solid #C0C0C0; margin: 10px 0; padding: 10px"> <form method="get"> <div id='filter_check'> <input type="checkbox" name="filter[check]" id="check" value='1' {if $smarty.get.filter.check}checked{/if} onclick="show_fields();"/> <label for="check">Фильтр</label> </div> <div id='filter_fields' {if !$smarty.get.filter.check}style="display: none"{/if}> <input type="hidden" name="module" value="OrdersAdmin"> <input type="hidden" name="status" value="{$status}"> <div style="margin: 15px 0"> <label>Дата с: </label><input type=text name=filter[date_from] value='{$smarty.get.filter.date_from}'> <label>По: </label><input type=text name=filter[date_to] value='{$smarty.get.filter.date_to}'> </div> <input id="apply_action" class="button_green" type="submit" value="Применить"> </div> </form> </div> {capture name=tabs} <li {if $status===0}class="active"{/if}><a href="{url module=OrdersAdmin status=0 keyword=null filter=null id=null page=null}">Новые</a></li> <li {if $status==1}class="active"{/if}><a href="{url module=OrdersAdmin status=1 keyword=null filter=null id=null page=null}">Приняты</a></li> <li {if $status==2}class="active"{/if}><a href="{url module=OrdersAdmin status=2 keyword=null filter=null id=null page=null}">Выполнены</a></li> <li {if $status==3}class="active"{/if}><a href="{url module=OrdersAdmin status=3 keyword=null filter=null id=null page=null}">Удалены</a></li> {if $keyword} <li class="active"><a href="{url module=OrdersAdmin keyword=$keyword id=null}">Поиск</a></li> {/if} {/capture}В какой шаблон нужно добавлять? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.