<?php
//$this->breadcrumbs = array(
//    'Companies' => array('index'),
//    'Manage',
//);
$user_id = Yii::app()->user->getState('__userid');
$userStatus = Yii::app()->user->getState('__statusAdmin');
if ($userStatus == 'Admin') {
    $this->menu = array(
        array('label' => 'Create Company', 'url' => array('/company/create/')),
        array('label' => 'Manage Companies', 'url' => array('/company/admin/')),
        array('label' => 'Upload Companies', 'url' => array('/user/uploadcompany/')),
    );
} else {

    $this->menu = array(
        array('label' => 'List Company', 'url' => array('/company/usercompany/', 'id' => $user_id)),
        array('label' => 'Create Company', 'url' => array('/company/createusercompany/', 'id' => $user_id)),
        array('label' => 'Upload Companies', 'url' => array('/user/uploadcompany/')),
    );
}
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#company-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<h4>Manage Companies</h4>

<?php
$Criteria = new CDbCriteria();
$mymodel = Company::model()->findAll($Criteria);
if ($mymodel == NULL) {
    echo'No records found';
} else {
    ?>
    <div class="span2 right">
    <?php
    echo CHtml::submitButton('Export Report', array('submit' => array('/user/exportexceluser/'), 'class' => 'btn btn-secondary'));
    ?>
    </div>
    <div class="span1 right">
    <?php
    $user_id = Yii::app()->user->getState('__userid');
    echo CHtml::submitButton('Delete All', array('submit' => array('/company/deletealluser/'. $user_id), 'class' => 'btn btn-secondary'));
    ?>
    </div>
    <div style="height:20px;"></div>
    <?php
}
?>


<div style="height:20px;"></div>
<?php // echo CHtml::link('Advanced Search','#',array('class'=>'search-button'));      ?>
<div class="search-form" style="display:none">
    <?php
//    $this->renderPartial('_search', array(
//        'model' => $model,
//    ));
    ?>
</div><!-- search-form -->

<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'company-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        'id',
        //'user_id',
        'name',
        'adress',
        'phone',
        'city',
        /*
          'state',
          'zip',
          'contacts',
         */
        array(
            'class' => 'CButtonColumn',
        ),
    ),
));
?>
