1. Jorge Vazquez
  2. Apmgr

Commits

rnelson  committed 71290f9

Lease Details page and some lame css for tables

  • Participants
  • Parent commits 5b7d95b
  • Branches default

Comments (0)

Files changed (12)

File application/Bootstrap.php

View file
  • Ignore whitespace
      * Integration of the history plugin
      *
      */
+    /*
     protected function _initHistory() {
         $this->bootstrap('frontcontroller');
         $this->getResource('frontcontroller')
             ->registerPlugin( new ZFHistory_Plugin_History() );
     }
+    */
 
 }
 ?>

File application/helpers/DateFormat.php

View file
  • Ignore whitespace
 	    if (!Zend_Date::isDate($date, 'Y-m-d H:i:s'))
 		  $formattedDate = $date;		  	    
 	    else
-	    {
-		  $date = new Zend_Date($date);
+	    {		  
+		  $zendDate = new Zend_Date($date, Zend_Date::ISO_8601);  
 		  
-		  if( isset($formatName) && isset($this->date_formats[$formatName]) )
-			$formattedDate = $date->toString($this->date_formats[$formatName]);			
-		  
-		  else if( isset($formatStr) )
-			$formattedDate = $date->toString($formatStr);		  
-	    }	    
+		  if( isset($formatName) && isset($this->date_formats[$formatName]) )			
+			$formattedDate = $zendDate->toString($this->date_formats[$formatName]);			
+		  		  
+		  else if( isset($formatStr) ) 
+			$formattedDate = $zendDate->toString($formatStr);					  
+	    }	   
 	    return $formattedDate;
     } 			
 }

File application/modules/unit/controllers/LeasewizardController.php

View file
  • Ignore whitespace
 	      $leaseWizardItem = $leaseWizardModel->findById( $leaseWizardId );	   
 	      $this->view->tenets = $leaseWizardItem->getTenet();
 	      
-	      $nextForm    = new Unit_Form_Confirmation();	      
-	      
+	      $nextForm    = new Unit_Form_Confirmation();
+	      $nextForm->setForm();	      
 	      
 	      if( $this->getRequest()->getParam('previous') ){
 		     
 		    		     		
 		$linkId = $form->getValue('accountLinkId');
 		$referenceNumber = $form->getValue('referenceNumber');
-		$comment = $form->getValue('comment'); 
-		    		    
-		// unset on confirmation page
-		//$cache = Zend_Registry::get('cache');
-		    
-		//$leaseWizard->setWizardVariable( array('accountLinkId'=>$linkId));
-		//$leaseWizard->setWizardVariable( array('referenceNumber'=>$referenceNumber));
-		//$leaseWizard->setWizardVariable( array('comment'=>$comment));
-		
+		$comment = $form->getValue('comment');  		    
+				
 		$leaseWizardItem->setAccountLinkId( $linkId );
 		$leaseWizardItem->setReferenceNumber( $referenceNumber );
 		$leaseWizardItem->setComment( $comment );

File application/modules/unit/controllers/ViewController.php

View file
  • Ignore whitespace
  	}
  	
 	/**
+	 * View lease details for a single lease
+	 *
+	 *
+	 *  unit number
+	 *  tenets
+	 *  lease discounts
+	 *  monthly rent
+	 *  
+	 */
+	public function viewleaseAction() {
+	    $leaseId = $this->getRequest()->getParam('leaseId');
+	    
+	    // lease model with start/end dates
+	    $leaseModel = new Unit_Model_Lease();
+	    $this->view->lease = $leaseRow = $leaseModel->findById( $leaseId );
+	    //var_dump( $leaseRow );
+	    
+	    // lease schedule with discounts
+	    $leaseScheduleModel = new Unit_Model_LeaseSchedule();
+	    $this->view->leaseSchedule = $leaseScheduleRow = $leaseScheduleModel->findByKey( array( 'search'=>array('leaseId'=>$leaseId)) );
+	    //var_dump( $leaseScheduleRow );
+	    
+	    // base model price.  
+	    $modelRentScheduleItem = new Unit_Model_ModelRentScheduleItem();	
+	    $this->view->modelRentScheduleItem = $modelRentScheduleItemRow = $modelRentScheduleItem->findById( $leaseRow->getModelRentScheduleItemId() );
+	    //var_dump( $modelRentScheduleItemRow );
+	    
+	    //tenets
+	    $tenetModel = new Unit_Model_Tenet();	
+	    $this->view->tenets = $tenetModel->getTenets( $leaseId );
+	    //var_dump( $modelRentScheduleItemRow );
+	    
+	    //unit
+	}
+	
+	/**
+	 *  Display grid with current lease info, and past lease info and buttons to add new lease or cancel lease
+	 **/
+	public function viewleaselistAction() {
+	     $unitId = $this->getRequest()->getParam('unitId');
+	     
+	     $leaseModel = new Unit_Model_Lease();
+	     $leaseModel->setUnitId( $unitId );
+	     $this->view->current = $leaseModel->fetchCurrentPendingLeases();
+	     $this->view->history = $leaseModel->fetchLeaseHistory();	     
+	}
+	
+	public function getdataAction() {
+	      $this->_helper->layout()->disableLayout();
+              $this->_helper->viewRenderer->setNoRender(true);
+	  
+	  
+	     // $mydata['rows'][0]['id'] = 1;
+	      $mydata['rows'][0] = 
+		  array('id'=>"1",
+		  'invdate'=>"2001-10-01",
+		  'name'=>"test1",
+		  'note'=>"note1",
+		  'amount'=>"2001.00",
+		  'tax'=>"101.00",
+		  'total'=>"2101.00");    
+		  
+	      $mydata['rows'][1] = 
+		  array('id'=>"2",
+		  'invdate'=>"2002-10-01",
+		  'name'=>"test2",
+		  'note'=>"note2",
+		  'amount'=>"2002.00",
+		  'tax'=>"102.00",
+		  'total'=>"2102.00"); 
+	$mydata['rows'][2] = 
+		    array('id'=>"3",
+		  'invdate'=>"2003-10-01",
+		  'name'=>"test3",
+		  'note'=>"note3",
+		  'amount'=>"2003.00",
+		  'tax'=>"103.00",
+		  'total'=>"2103.00"); 
+		  
+	$mydata['rows'][3] = 
+		   array('id'=>"4",
+		  'invdate'=>"2004-10-01",
+		  'name'=>"test4",
+		  'note'=>"note4",
+		  'amount'=>"2004.00",
+		  'tax'=>"104.00",
+		  'total'=>"2104.00"); 
+		  
+	$mydata['rows'][4] = 
+		   array('id'=>"5",
+		  'invdate'=>"2005-10-01",
+		  'name'=>"test5",
+		  'note'=>"note5",
+		  'amount'=>"2005.00",
+		  'tax'=>"105.00",
+		  'total'=>"2105.00"); 
+		  
+	$mydata['rows'][5] = 
+		   array('id'=>"6",
+		  'invdate'=>"2006-10-01",
+		  'name'=>"test6",
+		  'note'=>"note6",
+		  'amount'=>"2006.00",
+		  'tax'=>"106.00",
+		  'total'=>"2106.00"); 
+		  
+		  $mydata['rows'][6] = 
+		   array('id'=>"7",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test7",
+		  'note'=>"note7",
+		  'amount'=>"2007.00",
+		  'tax'=>"10.007",
+		  'total'=>"2107.00"); 
+		  
+		  $mydata['rows'][7] = 
+		   array('id'=>"8",
+		  'invdate'=>"2008-10-01",
+		  'name'=>"test8",
+		  'note'=>"note8",
+		  'amount'=>"2008.00",
+		  'tax'=>"108.00",
+		  'total'=>"2108.00"); 
+	
+	 // $mydata['totalpages']=1;
+	//  $mydata['currpage']=1;
+	 // $mydata['records']=8;	  
+	  
+	  //{"rows":[{"id":1,"cell":{"id":"1","invdate":"2007-10-01","name":"test","note":"note","amount":"200.00","tax":"10.00","total":"210.00"}}]}
+	  $this->_helper->json($mydata);
+	  
+	  
+	      
+	      /*
+	      $mydata = array(
+		  array('id'=>"1",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test",
+		  'note'=>"note",
+		  'amount'=>"200.00",
+		  'tax'=>"10.00",
+		  'total'=>"210.00"),
+		  
+		  array('id'=>"2",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test",
+		  'note'=>"note",
+		  'amount'=>"200.00",
+		  'tax'=>"10.00",
+		  'total'=>"210.00"),
+		  
+		  array('id'=>"3",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test",
+		  'note'=>"note",
+		  'amount'=>"200.00",
+		  'tax'=>"10.00",
+		  'total'=>"210.00"),
+		  
+		  array('id'=>"4",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test",
+		  'note'=>"note",
+		  'amount'=>"200.00",
+		  'tax'=>"10.00",
+		  'total'=>"210.00"),
+		  
+		  array('id'=>"5",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test",
+		  'note'=>"note",
+		  'amount'=>"200.00",
+		  'tax'=>"10.00",
+		  'total'=>"210.00"),
+		  
+		  array('id'=>"6",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test",
+		  'note'=>"note",
+		  'amount'=>"200.00",
+		  'tax'=>"10.00",
+		  'total'=>"210.00"),
+		  
+		  array('id'=>"7",
+		  'invdate'=>"2007-10-01",
+		  'name'=>"test",
+		  'note'=>"note",
+		  'amount'=>"200.00",
+		  'tax'=>"10.00",
+		  'total'=>"210.00")
+		  
+	);
+	      */
+	    //echo Zend_Json::encode( $mydata );
+	    
+	}
+	
+	/**
 	 * Pulls  individual model schedule
 	 **/
 	public function viewmodelrentscheduleAction() {

File application/modules/unit/models/Lease.php

View file
  • Ignore whitespace
     */        
     protected $modelRentScheduleId;
     
+    /**
+    *@var modelRentScheduleItemId
+    */        
+    protected $modelRentScheduleItemId;
+    
    /**
     *@var userId
     */        
     }
     
     /**
+      *  modelRentScheduleItemId
+      **/ 
+    public function setModelRentScheduleItemId( $var ) {
+        $this->modelRentScheduleItemId = $var;
+    }
+    
+    public function getModelRentScheduleItemId() {
+        return $this->modelRentScheduleItemId;
+    }
+    
+    
+    /**
     * userId
     */ 
     public function setUserId( $var ) {
     
     public function getUserId() {
         return $this->userId;
-    } 
+    }
+    
+    // TODO:  retest with cancelled leases to make sure they are filtered out
+    public function fetchCurrentPendingLeases(){
+	$db = $this->getDbTable()->getAdapter();
+	$query = $db->select()
+            ->from( array('lease') )
+	    ->where( 'unitId=?', $this->getUnitId() )
+	    ->where( 'lastDay>=NOW()');	    
+	    
+	$results = $db->query( $query );	
+	
+	$container = array();
+	if( isset( $results ) ){
+	    foreach( $results as $id=>$row )
+	        $container[] = $row;
+	    return $container;	
+	}
+	else
+	  return null;    
+    }
+    
+    // TODO:  retest with cancelled leases to make sure they are filtered out
+    public function fetchLeaseHistory(){
+	$db = $this->getDbTable()->getAdapter();
+	$query = $db->select()
+            ->from( array('lease') )
+	    ->where( 'unitId=?', $this->getUnitId() )
+	    ->where( 'lastDay<NOW()');	    
+	    
+	$results = $db->query( $query );	
+	
+	$container = array();
+	if( isset( $results ) ){
+	    foreach( $results as $id=>$row )
+	        $container[] = $row;
+	    return $container;	
+	}
+	else
+	  return null;    
+    }
+    
+    /**
+     *  Grabs the info for the specific lease
+     */
+    public function getLeaseDetail() {
+	;
+    }	
 }
 ?>

File application/modules/unit/models/LeaseSchedule.php

View file
  • Ignore whitespace
 class Unit_Model_LeaseSchedule extends ZFModel_ParentModel {        
         
     /**
-    *@var modelRentScheduleId
+    *@var month
     */        
     protected $month;
     

File application/modules/unit/models/LeaseWizard.php

View file
  • Ignore whitespace
 	    $lease->setEffectiveDate( $this->getEffectiveDate() );
 	    $lease->setUnitId( $this->getUnitId() );
 	    $lease->setModelRentScheduleId( $this->getModelRentScheduleId()  );
+	    $lease->setModelRentScheduleItemId( $this->getModelRentScheduleItemId() );
 	    $lease->setLastDay( $endDate->toString('YYYY-MM-dd') );
 		
 	    $billCreation = new Financial_Model_BillCreation( array( 'db'=>$db ) );	

File application/modules/unit/models/Tenet.php

View file
  • Ignore whitespace
     
     public function getLeaseId() {
         return $this->leaseId;
-    }    
-    
-    // Set/ Get user and unit objects
-    /*
-    public function setUser( $obj ) {
-        $this->user = $obj;
-    }
-    
-    public function getUser() {
-        return $this->user;
-    }
-    
-     public function setUnit( $obj ) {
-        $this->unit = $obj;
-    }
-    
-    public function getUnit() {
-        return $this->unit;
-    }
-    */
-    
-    /**
-    *Saves a record in this model
-    */
-    /*
-    public function save() {	
-    	
-    	//print 'here'; die;
-    	
-		$result = false;
-		$data = array ('unitId'=>$this->getUnitId(), 'userId'=>$this->getUserId() );		
-           
-		if (null === ($id = $this->getId())) {   
-			unset ($data['id']);
-			$data['dateCreated'] = date('Y-m-d H:i:s');
-			$result =(int) $this->getDbTable()->insert($data);
-		} 
-		//  Editing existing unit
-		else {
-        	$data['dateUpdated'] = date('Y-m-d H:i:s');
-	    	$result = $this->getDbTable()->update($data, array ('id = ?' => $this->getId() ),integer);
-		}
-		return $result;
-    }
-    */
-
-/**
-    *Deletes a record in this model
-    *@return integer The number of deleted rows
-    */
-/*
-    public function delete($id) {
-        $result = false;	
-	
-        if ( $id ) {
-        	$db = $this->getDbTable()->getAdapter();
-        	$where = $db->quoteInto("id=?",$id,integer);
-            $result = $this->getDbTable()->delete($where,'unitUser');
-        }
-        return $result;
-    }
-*/
+    }      
  
- /*
- 	public function getUnitTenets( $by, $sort, $unitId ){
- 		
- 		if( !$sort) $sort='ASC';
- 		if( !$by) $by= 'LastName'; 
- 		 		
-		$db = $this->getDbTable()->getAdapter();
-		$query = $db->select()
-            ->from( array('uu'=>'unitUser'), 
-                    array( 'id'=>'uu.userId', 'uu.unitId' ) 
-                  )              
-            ->join( array('u'=>'user'),'uu.userId=u.id',array('u.firstName', 'u.lastName' ))        
-            ->join( array('un'=>'unit'),'uu.unitId=un.id',array('number'=>'un.number')  )
-            ->where('uu.unitId=?', $unitId)
-            ->order( "$by $sort" );            
- 	
- 	
- 		$resultSet = $db->query( $query );
+ 
+    public function getTenets( $leaseId ){
+        $db = $this->getDbTable()->getAdapter();
+	$query = $db->select()
+            ->from( array('t'=>'tenet'), array('t.userId') )              
+            ->join( array('u'=>'user'),'t.userId=u.id',array('u.firstName', 'u.lastName' ))                    
+            ->where('t.leaseId=?', $leaseId);                
+ 	 	
+ 	    $resultSet = $db->query( $query );
  				
- 		$container = null;	
- 		foreach ($resultSet as $row)
-			$container[] = $row;			
+ 	    $container = null;	
+ 	    foreach ($resultSet as $row)
+		$container[] = $row;			
 				
-		return $container; 	
+	    return $container; 	
  }
- */
+ 
 
 }  // end class
 ?>

File application/modules/unit/views/scripts/leasewizard/searchaddtenet.phtml

View file
  • Ignore whitespace
  * @package application.modules.user.views.scripts.tenet
  */
  echo $this->headLink()->appendStylesheet('/css/panel.css');
- echo $this->crudBar('user');
+ echo $this->headScript()->appendFile('/javascript/scriptaculous/lib/prototype.js');
 ?>
 
-<script script type="text/javascript">
+<script type="text/javascript">
     function addUserToList( $id ) {
         var info = new Ajax.Request("<?=$this->url( array('module'=>'unit',
                                                           'controller'=>'leasewizard',
 </script>
 
 <div class="details">
-<div id='currentTitle'>    
-<h1> Current Tenet List </h1>
-</div>
+    <div id='currentTitle'>    
+    <h1> Current Tenet List </h1>
+    </div>
     <table id="currentTenets">
         <?php if( $this->tenets )
                   foreach( $this->tenets as $id=>$tenet ) {  ?>
         <?php } else echo '<tr><td>No Tenets Selected</td></tr>';?>
             
     </table>
-   <?php echo $this->nextForm;?> </div>
+    
+   <?php echo $this->nextForm;?>
+</div>
 
 <div class="details">
     <h1>Search Users</h1>

File application/modules/unit/views/scripts/view/index.phtml

View file
  • Ignore whitespace
 ?>
 
 <div class="details">
-	
-	<h1>Unit Section</h1>
-	<h3>View Unit</h3>
+	<h3>Unit Details</h3>
 	<div class="results">
 		<?php 
 			if ( $this->resultCheck($this->unit) ){
 		</table>
 		<?php
 		     }
-		?>	
-				
-		<a href="<?=$this->serverUrl('/unit/tenet/viewunittenet/unitId/'. $this->unit->getId());?>">View Tenets</a>		
-		<a href="<?=$this->serverUrl('/unit/tenet/searchaddtenet/unitId/'. $this->unit->getId());?>">Add Tenet</a>		
+		?>			
+		<a href="<?=$this->serverUrl('/unit/view/viewleaselist/unitId/'. $this->unit->getId());?>">View Lease Information</a>		
 		
 			<?php
 			}

File application/modules/unit/views/scripts/view/viewlease.phtml

View file
  • Ignore whitespace
+<?php
+/**
+ * Created on Mar 28, 2010 by rnelson
+ * @name apmgr view
+ * @package application.modules.unit.views.scripts.view
+ * <p>View page for an apartment </p>
+ */
+
+echo $this->headLink()->prependStylesheet('/css/table.css');
+echo $this->headScript()->appendFile('/javascript/jquery/jquery.js');
+echo $this->headScript()->appendFile('/javascript/tablecss/tablecss.js');
+?> 
+<table>	
+            <caption>Lease Details</caption>
+            <tr>
+		<th>Base Rent Amount </th>
+		<th>Number of Months </th>
+		<th>Effective Date </th>
+		<th>Last Day </th>
+		
+	    </tr>
+	    <tr> 	
+		<td> <?php echo $this->modelRentScheduleItem->getRentAmount(); ?></td>
+		<td> <?php echo $this->modelRentScheduleItem->getNumMonths(); ?></td>
+		<td> <?php echo $this->dateFormat($this->lease->getEffectiveDate(), 'mdy'); ?></td>
+		<td> <?php echo $this->dateFormat($this->lease->getLastDay(), 'mdy'); ?></td>
+	    </tr>	    	    	    
+</table>
+
+
+<?php if( $this->leaseSchedule ) {?>
+<table>
+    <caption>Rent Discounts</caption>
+    <tr>
+        <th>Month </th>
+	<th>Discount Amount</th>		
+    </tr>
+    
+    <?php foreach( $this->leaseSchedule as $id=>$item ){ ?>
+    <tr>		
+        <td> <?php echo $item->getMonth(); ?></td>
+	<td> <?php echo $item->getDiscount(); ?></td>
+    </tr>
+    <?php } ?> 
+</table>	    
+<?php } ?>
+
+<?php if( $this->tenets ) {?>
+<table>
+    <caption>Tenets</caption>
+    <?php foreach( $this->tenets as $id=>$item ){ ?>
+    <tr>
+        <th>Name </th>
+    </tr>
+    <tr>
+	<td> <?php echo $item['firstName'] . ' ' . $item['lastName']; ?> </td>
+    </tr>   
+    <?php } ?> 
+</table>	    
+<?php } ?>
+
+

File application/modules/unit/views/scripts/view/viewleaselist.phtml

View file
  • Ignore whitespace
+<?php
+/**
+ * Created on Mar 28, 2010 by rnelson
+ * @name apmgr view
+ * @package application.modules.unit.views.scripts.view
+ * <p>View page for an apartment </p>
+ */ 
+?>
+<div>
+<div>
+   <h1>Current Pending / Lease</h1>   
+</div>
+
+<table>
+     <?php if( $this->current ) {?>
+            <tr>
+		<th> Effective Date </th>
+		<th> Last Day </th>
+		<th> Details </th>
+	    </tr>
+                  <?php foreach( $this->current as $id=>$row ) {  ?>
+            <tr>                
+                <td> <?php echo $this->dateFormat($row['effectiveDate'], 'mdy'); ?></td>
+                <td> <?php echo $this->dateFormat($row['lastDay'], 'mdy'); ?></td>
+		<td><a href="<?php echo $this->serverUrl('/unit/view/viewlease/leaseId/'. $row['id']); ?>">
+		        <img width="24" height="24" src="/images/search_48.png" />
+		   </a>
+		</td>
+            </tr>
+        <?php } ?>
+	    
+	<?php } else echo '<tr><td>No Rows</td></tr>';?>    
+</table>	
+</div>
+
+<div>
+<div>
+   <h1>Lease History</h1>   
+</div>
+
+<table>
+     <?php if( $this->history ) {?>
+            <tr>
+		<th> Effective Date </th>
+		<th> Last Day </th>
+		<th> Details </th>
+	    </tr>
+                  <?php foreach( $this->history as $id=>$row ) {  ?>
+            <tr>                
+                <td> <?php echo $this->dateFormat($row['effectiveDate'], 'mdy'); ?></td>
+                <td> <?php echo $this->dateFormat($row['lastDay'], 'mdy'); ?></td>
+		<td><a href="<?php echo $this->serverUrl('/unit/view/viewlease/leaseId/'. $row['id']); ?>">
+		        <img width="24" height="24" src="/images/search_48.png" />
+		   </a>
+		</td>
+            </tr>
+        <?php } ?>
+	    
+	<?php } else echo '<tr><td>No Rows</td></tr>';?>    
+</table>	
+</div>
+ 
+
+