public function actionIndex()
 {
     $tickets = tickets::find()->all();
     $cartridge_types = cartridgeType::find()->orderBy('used DESC')->all();
     $departments = department::find()->where(['active' => 1])->orderBy('value ASC')->all();
     $carts = cartridgeHistory::find()->where(['add_date' => date('Y-m-d')])->orderBy('id DESC')->all();
     return $this->render('index', ['tickets' => $tickets, 'cartridge_types' => $cartridge_types, 'departments' => $departments, 'carts' => $carts]);
 }
Exemple #2
0
 public function actionGetDepartmentRef()
 {
     $departments = department::find()->orderBy('value ASC')->All();
     foreach ($departments as $department) {
         if ($department->active) {
             printf('<option value = %s>%s</option>', $department->id, $department->value);
         } else {
             printf('<option value = %s>%s&nbsp(неактивен)</option>', $department->id, $department->value);
         }
     }
 }
    public function actionGetCartridgeStat($from_date, $till_date)
    {
        $cart_types = CartridgeType::find()->orderBy('used DESC')->all();
        $departments = department::find()->where(['active' => 1])->orderBy('value ASC')->all();
        if ($from_date && $till_date) {
            $cart_history = CartridgeHistory::find()->where(['>=', 'add_date', $from_date])->andWhere(['<=', 'add_date', $till_date])->all();
        } else {
            $cart_history = CartridgeHistory::find()->all();
        }
        echo '<table class = "table table-hover table-condensed"><tr><td>Подразделение / Картридж</td>';
        foreach ($cart_types as $type) {
            echo '<td>' . $type->type . '</td>';
        }
        echo '<td>Все</td>';
        echo '</tr>';
        foreach ($departments as $dep) {
            echo '<tr>
					<td>' . $dep->value . '</td>';
            $all_type_count = 0;
            foreach ($cart_types as $type) {
                $type_count = 0;
                foreach ($cart_history as $cart) {
                    // if ( $cart -> room_id != null ){
                    // $cart_build = building::findOne($cart -> room_id);
                    // // $cart_build_id = $cart_build -> id;
                    // $cart_dep = department::findOne($cart_build['id']);
                    // $cart_dep_id = $cart_dep['id'];
                    // }
                    // else{
                    // if( $cart -> building_id != null ){
                    // $cart_dep = department::findOne( $cart -> building_id );
                    // $cart_dep_id = $cart_dep -> id;
                    // }
                    // else{
                    // if($cart -> department_id != null ){
                    // $cart_dep_id = $cart -> department_id;
                    // }
                    // }
                    // }
                    if ($cart->department_id == $dep->id && $cart->cartridge_type == $type->type) {
                        // if ( $cart_dep_id == $dep -> id && $cart -> cartridge_type == $type -> type ){
                        $type_count++;
                        $all_type_count++;
                    }
                }
                echo $type_count ? '<td style = "color : red"><strong>' . $type_count . '</strong></td>' : '<td>' . $type_count . '</td>';
            }
            echo $all_type_count ? '<td style = "color : red"><strong>' . $all_type_count . '</strong></td>' : '<td>' . $all_type_count . '</td>';
            echo '</tr>';
        }
        echo '<tr><td>Все</td>';
        foreach ($cart_types as $type) {
            $type_count = 0;
            foreach ($cart_history as $cart) {
                if ($cart->cartridge_type == $type->type) {
                    $type_count++;
                }
            }
            echo $type_count ? '<td style = "color : red"><strong>' . $type_count . '</strong></td>' : '<td>' . $type_count . '</td>';
        }
        echo '<td style = "color : red"><strong>' . count($cart_history) . '</strong></td>';
        '</tr>';
        echo '</table>';
    }
Exemple #4
0
//$phonesQuery = Phonebook::find()->where(['room_id'=>room::find('id')->where(['building_id'=>building::find('id')->where(['department_id'=>$dep])])]);
//$depp = findOne('5');
//$bb = depp
//print_r(building::find() -> where(['department.id' => '5']) -> all());
//$pp = phonebook::find()->innerJoin()->all();
//print_r($pp->getRoom());
//print_r(phonebook::find() ->with('department') -> where(['department' => '5']) -> all());
//print_r(phonebook::find()->with('room')->with('building')->with('department')->where(['id' => '1'])->all());
?>
	
	
	<table class="table table-responsive">
		<thead>
			<tr class = "active">
				<td>Подразделение<?php 
echo Html::dropDownList('', $dep, ArrayHelper::map(department::find()->asArray()->all(), 'id', 'value'), ['class' => 'form-control', 'id' => 'department_filter', 'prompt' => 'Выберите подразделение']);
?>
</td>
				<td>Здание<?php 
echo Html::dropDownList('building_filter', $build, ArrayHelper::map(building::find()->where(['department_id' => $dep])->asArray()->all(), 'id', 'value'), ['class' => 'form-control', 'id' => 'building_filter', 'prompt' => 'Выберите здание']);
?>
</td>
				<td>Кабинет<?php 
echo Html::dropDownList('room_filter', $room, ArrayHelper::map(room::find()->where(['building_id' => $build])->asArray()->all(), 'id', 'value'), ['class' => 'form-control', 'id' => 'room_filter', 'prompt' => 'Выберите кабинет']);
?>
</td>
				<td>Внешний номер<br>
					<input type = "text" class = "form-control" id ="long-number_filter"></input>
				</td>
				<td>Внутренний номер<br>
					<input type = "text" class = "form-control" id ="short-number_filter"></input>