Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by ERUCK! ( 14 years ago )
<?php

/***** MODEL *****/


class Company extends AppModel {

/**
 * Display field
 *
 * @var string
 */
 public $displayField = 'name';


 //The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
 public $belongsTo = array(
  'Owner' => array(
   'className' => 'User',
   'foreignKey' => 'owner_id',
   'conditions' => '',
   'fields' => '',
   'order' => ''
  )
 );

/**
 * hasMany associations
 *
 * @var array
 */
 public $hasMany = array(
  'Did' => array(
   'className' => 'Did',
   'foreignKey' => 'company_id',
   'dependent' => false,
   'conditions' => '',
   'fields' => '',
   'order' => '',
   'limit' => '',
   'offset' => '',
   'exclusive' => '',
   'finderQuery' => '',
   'counterQuery' => ''
  ),
  'Extension' => array(
   'className' => 'Extension',
   'foreignKey' => 'company_id',
   'dependent' => false,
   'conditions' => '',
   'fields' => '',
   'order' => '',
   'limit' => '',
   'offset' => '',
   'exclusive' => '',
   'finderQuery' => '',
   'counterQuery' => ''
  ),
  'Hour' => array(
   'className' => 'Hour',
   'foreignKey' => 'company_id',
   'dependent' => false,
   'conditions' => '',
   'fields' => '',
   'order' => '',
   'limit' => '',
   'offset' => '',
   'exclusive' => '',
   'finderQuery' => '',
   'counterQuery' => ''
  ),
  'MenuEntry' => array(
   'className' => 'MenuEntry',
   'foreignKey' => 'company_id',
   'dependent' => false,
   'conditions' => '',
   'fields' => '',
   'order' => '',
   'limit' => '',
   'offset' => '',
   'exclusive' => '',
   'finderQuery' => '',
   'counterQuery' => ''
  ),
  'Queue' => array(
   'className' => 'Queue',
   'foreignKey' => 'company_id',
   'dependent' => false,
   'conditions' => '',
   'fields' => '',
   'order' => '',
   'limit' => '',
   'offset' => '',
   'exclusive' => '',
   'finderQuery' => '',
   'counterQuery' => ''
  ),
  'User' => array(
   'className' => 'User',
   'foreignKey' => 'company_id',
   'dependent' => false,
   'conditions' => '',
   'fields' => '',
   'order' => '',
   'limit' => '',
   'offset' => '',
   'exclusive' => '',
   'finderQuery' => '',
   'counterQuery' => ''
  )
 );

}


/***** END MODEL *****/

/***** CONTROLLER *****/

 public function view($id = null) {
  $this->Company->id = $id;
  if (!$this->Company->exists()) {
   throw new NotFoundException(__('Invalid company'));
  }
  $this->set('company', $this->Company->read(null, $id));
 }
        
        

/***** END CONTROLLER *****/


/***** VIEW *****/

<div class="related">
    <h3><?php echo __('Company Extensions'); ?></h3>
    <?php if (!empty($company['Extension'])): ?>
        <table cellpadding = "0" cellspacing = "0">
            <tr>
                <th><?php echo __('User'); ?></th>
                <th><?php echo __('Company Id'); ?></th>
                <th><?php echo __('Number'); ?></th>
            </tr>
            <?php
            $i = 0;
            foreach ($company['Extension'] as $extension):
                ?>
                <tr>
                    <td><?php echo $results['0']['users']['firstname']; ?></td>
                    <td><?php echo $extension['company_id']; ?></td>
                    <td><?php echo $extension['number']; ?></td>
                </tr>
            <?php endforeach; ?>
        </table>
    <?php endif; ?>

    <div class="actions">
        <ul>
            <li><?php echo $this->Html->link(__('New Extension'), array('controller' => 'extensions', 'action' => 'add')); ?> </li>
        </ul>
    </div>
</div>

/***** END VIEW *****/

?>

 

Revise this Paste

Parent: 58946
Your Name: Code Language: