Permalink
Browse files

add renting operations

  • Loading branch information...
1 parent 345554f commit 056ce4722b95b989d51c0f25a6ac7417241d1c94 @romaninsh romaninsh committed Oct 14, 2011
Showing with 25 additions and 9 deletions.
  1. +0 −8 lib/Model/DVD.php
  2. +8 −0 lib/Model/DVD/InStore.php
  3. +17 −1 page/video.php
View
@@ -26,12 +26,4 @@ function calculate_is_rented(){
return "if(($select) is null,'N','Y')";
}
- function rent($customer_id){
- $m=$this->add('Model_Rental')
- ->set('dvd_id',$this->get('id'))
- ->set('customer_id',$customer_id)
- ;
- $m->update();
- return $m;
- }
}
@@ -12,4 +12,12 @@ function dsql_count(){
->where('dvd.movie_id=movie.id')
;
}
+ function rent($customer_id){
+ $m=$this->add('Model_Rental')
+ ->set('dvd_id',$this->get('id'))
+ ->set('customer_id',$customer_id)
+ ;
+ $m->update();
+ return $m;
+ }
}
View
@@ -11,7 +11,23 @@ function init(){
$rental = $grid->getModel()->loadData($_GET['rent'])->rent($this->api->auth->get('id'));
$grid->js(null,
- $this->js()->reload())->univ()->successMessage('Rented successfully #'.$rental->get('id'));
+ $this->js()->reload())->univ()->successMessage('Rented successfully #'.$rental->get('id'))
+ ->execute();
+ }
+
+ $grid=$this->add('MVCGrid');
+ $grid->setModel('Rental')
+ ->addCondition('customer_id',$this->api->auth->get('id'))
+ ->addCondition('is_returned',false)
+ ;
+ $grid->addColumn('button','return');
+
+ if($_GET['return']){
+ $rental = $grid->getModel()->loadData($_GET['return'])->returnMovie();
+
+ $grid->js(null,
+ $this->js()->reload())->univ()->successMessage('Returned #'.$_GET['return'])
+ ->execute();
}
}

0 comments on commit 056ce47

Please sign in to comment.