Пример #1
0
 private function setEquipment($equipmentIds, $model)
 {
     if (!empty($equipmentIds) && $model->id > 0 && $model->code != '') {
         // delete excess equipment
         $excessIds = array_diff($model->equipment, $equipmentIds);
         if (!empty($excessIds)) {
             foreach ($excessIds as $excessId) {
                 EquipmentStatus::deleteAll(['equipment_id' => $excessId, 'station_id' => $model->id]);
             }
         }
         // add new equipment
         $newIds = array_diff($equipmentIds, $model->equipment);
         if (!empty($newIds)) {
             foreach ($newIds as $newId) {
                 $data[] = [$newId, $model->id, $model->code];
             }
             Yii::$app->db->createCommand()->batchInsert('equipment_status', ['equipment_id', 'station_id', 'station_code'], $data)->execute();
         }
     }
 }
Пример #2
0
 public function getEquipmentStatuses()
 {
     return $this->hasMany(EquipmentStatus::className(), ['station_code' => 'code']);
 }
Пример #3
0
        $hrefAuto = $changeUrl . '?part=equip&id=' . $equipment['id'] . '&station_id=' . $model->id . '&configure=' . EquipmentStatus::CONFIGURE_AUTO . '&status=' . $equipment['status'];
        ?>
            <tr>
                <th style="text-align: center"><?php 
        echo $no;
        ?>
</th>
                <td>
                    <div class="kv-attribute"><?php 
        echo $equipment['name'];
        ?>
</div>
                </td>
                <td>
                    <div class="kv-attribute"><?php 
        echo EquipmentStatus::getStatus($equipment['status']);
        ?>
</div>
                </td>
                <td>
                    <div id="equip-<?php 
        echo $equipment['id'];
        ?>
" class="kv-attribute">
                        <?php 
        $underOn = 0;
        $underOff = 0;
        $underAuto = 0;
        if ($equipment['configure'] == EquipmentStatus::CONFIGURE_AUTO) {
            $underAuto = 1;
        }