public function actionDelete($id) { $service = Service::model()->findAll('contractor_id=' . $id); if ($service) { foreach ($service as $serv) { WrapServTransport::Del($serv->id); ServCulture::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $food = ServFood::model()->findAll('service_id=' . $serv->id); if ($food) { foreach ($food as $mFood) { LinkFoodServ::model()->deleteAllByAttributes(array('serv_food_id' => $mFood->id)); } } ServFood::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServIntensiv::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServOther::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $personal = ServPersonal::model()->findAll('service_id=' . $serv->id); if ($personal) { foreach ($personal as $mPers) { LinkPersonalLanguage::model()->deleteAllByAttributes(array('serv_personal_id' => $mPers->id)); } } ServPersonal::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServPlatform::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServProgram::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServTicket::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $live = ServLive::model()->findAll('service_id=' . $serv->id); if ($live) { foreach ($live as $mLive) { ServLiveRoom::model()->deleteAllByAttributes(array('serv_live_id' => $mLive->id)); } } ServLive::model()->deleteAllByAttributes(array('service_id' => $serv->id)); Photo::model()->deleteAllByAttributes(array('service_id' => $serv->id)); } } Service::model()->deleteAllByAttributes(array('contractor_id' => $id)); Comment::model()->deleteAllByAttributes(array('contractor_id' => $id)); LinkCityContractor::model()->deleteAllByAttributes(array('contractor_id' => $id)); Contractor::model()->deleteByPk($id); echo "ok"; }
<?php $sTmp = ServProgram::model()->findByAttributes(array('service_id' => $serv->id)); ?> <label class="control-label" for="service-other-name">Режим работы:</label> <table class="table small times"> <thead> <tr> <td width="140px"><label class="control-label">День недели:</label></td> <td class="text-center" colspan=3><label class="control-label">Время работы:</label></td> <td class="text-center" colspan=3><label class="control-label">Перерыв:</label></td> <td class="text-center"><label class="control-label">Выходной:</label></td> </tr> </thead> <tbody> <tr> <td class="dayName"><input type="text" class="form-control input-sm" value="Понедельник" disabled></td> <td class="time pull-right"><input type="text" class="form-control input-sm" id="service-program-monday-start" name="ServProgram[monday_start]" value="<?php echo $sTmp->monday_start; ?> " disabled></td> <td class="text-center time-razd"><span class="glyphicon glyphicon-minus btn-xs"></span></td> <td class="time"><input type="text" class="form-control input-sm" id="service-program-monday-stop" name="ServProgram[monday_stop]" value="<?php echo $sTmp->monday_stop; ?> " disabled></td>