diff --git a/include/controllers/default/quick/home/index.php b/include/controllers/default/quick/home/index.php index a6c87d59a..a04fb3647 100644 --- a/include/controllers/default/quick/home/index.php +++ b/include/controllers/default/quick/home/index.php @@ -1,9 +1,8 @@ layout( 'layout/html' ); if( c::db()->escape( c::getPagePiece( 0 ) ) ){ @@ -24,29 +23,65 @@ class Controller_home extends Crunchbutton_Controller_Account { public function miniRouter(){ c::view()->menu = true; switch ( c::getPagePiece( 0 ) ) { - case 'shifts': - c::view()->actual = 'list-shift'; - $this->showShifts(); + case 'shifts-list': + switch ( c::getPagePiece( 1 ) ) { + case 'all': + $this->showAllShifts(); + break; + case 'mine': + default: + $this->showMineShifts(); + break; + } break; - + case 'orders-list': default: - $this->showList(); + switch ( c::getPagePiece( 1 ) ) { + case 'all': + $this->showAllOrders(); + break; + case 'mine': + default: + $this->showMineOrders(); + break; + } break; } } - public function showShifts(){ - c::view()->shifts = Crunchbutton_Community_Shift::nextShiftsByAdmin( c::admin()->id_admin ); - c::view()->display( 'shifts/index' ); + public function showAllShifts(){ + c::view()->actual = 'shifts-all'; + $communities = c::admin()->communitiesHeDeliveriesFor(); + $list = []; + foreach( $communities as $community ){ + $list[] = $community->id_community; + } + c::view()->shifts = Crunchbutton_Community_Shift::nextShiftsByCommunities( $list ); + c::view()->display( 'shifts/all' ); } - public function showList(){ + public function showMineShifts(){ + c::view()->actual = 'shifts-mine'; + c::view()->shifts = Crunchbutton_Community_Shift::nextShiftsByAdmin( c::admin()->id_admin ); + c::view()->display( 'shifts/mine' ); + } - $justMineOrders = ( c::db()->escape( c::getPagePiece( 0 ) ) == 'mine' ); + public function showAllOrders(){ + c::view()->actual = 'orders-all'; + c::view()->orders = $this->getOrdersList( true ); + c::view()->display( 'orders/index' ); + } - $hours = c::getPagePiece( 1 ) ? c::getPagePiece( 1 ) : 12; + public function showMineOrders(){ + c::view()->actual = 'orders-mine'; + c::view()->orders = $this->getOrdersList(); + c::view()->display( 'orders/index' ); + } + + public function getOrdersList( $all = false ){ - $orders = Order::deliveryOrders( $hours, ( c::db()->escape( c::getPagePiece( 0 ) ) == 'all' ) ); + $hours = 120; + $orders = Order::deliveryOrders( $hours, $all ); $list = []; foreach ( $orders as $order ) { @@ -70,17 +105,7 @@ class Controller_home extends Crunchbutton_Controller_Account { return ( $a->lastStatus[ 'order' ] > $b->lastStatus[ 'order' ] ); } ); - - if( $justMineOrders ){ - c::view()->actual = 'list-mine'; - } else { - c::view()->actual = 'list-all'; - } - - c::view()->justMineOrders = $justMineOrders; - c::view()->hours = $hours; - c::view()->orders = $list; - c::view()->display( 'home/index' ); + return $list; } } \ No newline at end of file diff --git a/include/library/Crunchbutton/Community/Shift.php b/include/library/Crunchbutton/Community/Shift.php index 39b80f544..c9c36617d 100644 --- a/include/library/Crunchbutton/Community/Shift.php +++ b/include/library/Crunchbutton/Community/Shift.php @@ -57,10 +57,21 @@ class Crunchbutton_Community_Shift extends Cana_Table { $query = 'SELECT cs.* FROM admin_shift_assign ass INNER JOIN community_shift cs ON cs.id_community_shift = ass.id_community_shift WHERE ass.id_admin = "' . $id_admin . '" AND - DATE_FORMAT( cs.date_start, "%Y-%m-%d" ) >= "' . $now->format( 'Y-m-d' ) . '" ORDER BY cs.date_start ASC LIMIT 20'; + DATE_FORMAT( cs.date_start, "%Y-%m-%d" ) >= "' . $now->format( 'Y-m-d' ) . '" ORDER BY cs.date_start ASC LIMIT 20'; return Crunchbutton_Community_Shift::q( $query ); } + public function nextShiftsByCommunities( $communities ){ + if( count( $communities ) > 0 ){ + $now = new DateTime( 'now', new DateTimeZone( c::config()->timezone ) ); + $query = 'SELECT cs.* FROM community_shift cs + WHERE cs.id_community IN( ' . join( ',', $communities ) . ' ) AND + DATE_FORMAT( cs.date_start, "%Y-%m-%d" ) >= "' . $now->format( 'Y-m-d' ) . '" ORDER BY cs.date_start ASC LIMIT 20'; + return Crunchbutton_Community_Shift::q( $query ); + } + return false; + } + public function shiftsByDay( $date ){ Crunchbutton_Community_Shift::createRecurringEvent( $date ); return Crunchbutton_Community_Shift::q( 'SELECT cs.* FROM community_shift cs INNER JOIN community c ON c.id_community = cs.id_community WHERE DATE_FORMAT( cs.date_start, "%Y-%m-%d" ) = "' . $date . '" ORDER BY c.name, cs.date_start ASC' ); diff --git a/include/views/default/quick/layout/html.phtml b/include/views/default/quick/layout/html.phtml index 384484777..f1d2940d9 100644 --- a/include/views/default/quick/layout/html.phtml +++ b/include/views/default/quick/layout/html.phtml @@ -430,12 +430,27 @@ input[type="submit"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner, .warning{ - color: red; - font-style: italic; + color: #c09853; + font-family: 'Open Sans', HelveticaNeue, Helvetica, Arial; font-size: 1.2em; line-height: 1.4em; margin-bottom:1.1em; margin-top:1.1em; + border: 1px solid #f1d276; + background-color: #f7e6b4; + background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(249, 236, 196)), to(rgb(246, 225, 165))); + background-image: -webkit-linear-gradient(top, rgb(249, 236, 196), rgb(246, 225, 165)); + background-image: -moz-linear-gradient(top, rgb(249, 236, 196), rgb(246, 225, 165)); + background-image: -o-linear-gradient(top, rgb(249, 236, 196), rgb(246, 225, 165)); + background-image: -ms-linear-gradient(top, rgb(249, 236, 196), rgb(246, 225, 165)); + background-image: linear-gradient(top, rgb(249, 236, 196), rgb(246, 225, 165)); + filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#f9ecc4', EndColorStr='#f6e1a5'); + -webkit-border-radius: .4em; + -moz-border-radius: .4em; + border-radius: .4em; + padding: .5em; + text-shadow: rgba(255, 255, 255, 0.498039) 0px 1px 0px; + box-shadow: rgb(249, 237, 201) 0px 1px 2px 0px inset, rgb(223, 223, 223) 0px 1px 1px 0px; } .order-list-item a{ color: #FFF; @@ -526,11 +541,14 @@ input[type="submit"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner, .pickedup .order-list-action .button{ color:#505050; } .menu-bar{ - font-size: 1.8em; + font-size: 1.7em; } .shifts-list-item{ background: #6d6d6d; } + .shifts-list-item.mine{ + background: #00957f; + } .shifts-list-item-date{ font-size: 1.7em; } @@ -547,9 +565,43 @@ input[type="submit"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner, text-align: right; } .menu-bar a.actual{ - color: #000; + color: #666; text-decoration: none; } + .menu-bar ul{ + list-style-type: none; + margin: 0; + padding: 0; + } + .menu-bar li{ + display: inline-block; + margin: 0 0.2em; + padding: 0; + } + .menu-bar li.title{ + margin-left: 0; + } + .menu-bar li.title.shifts{ + margin-left: 1em; + } +.shifts-list-item .drivers{ + margin: 0; + margin-top: 1em; + padding: 0; + list-style-type: none; +} + .shifts-list-item .drivers li{ + font-size: 1.3em; + line-height: 1.5em; + } + .shifts-list-item .drivers li.no-drivers{ + font-size: 1em; + opacity: .7; + font-style: italic; + } + .shifts-list-item a{ + color: #FFF; + } @@ -558,24 +610,29 @@ input[type="submit"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner,