/** Get My Booth list */ public function actionGetmybooth() { if (Yii::$app->request->post()) { $connection = Yii::$app->db; $value = \Yii::$app->request->post(); if (!empty($value['attendee_id']) && !empty($value['congress'])) { $userid = User::findOne(['id' => $value['attendee_id']]); if ($userid) { $sql = "SELECT b.id as id,b.congress_id as congress_id,b.booth_name as booth_name,b.phone as phone ,b.from_time as from_time,b.to_time as to_time,b.to_time as to_time,b.date as date, b.location as location, b.Area as Area FROM booths b inner join booth_schedules bs on b.id = bs.booth_id where b.congress_id= {$value['congress']} and bs.attendee_id= {$userid->attendee_id} order by b.date asc,b.from_time asc"; $data = $connection->createCommand($sql)->queryAll(); $finalvalue = array(); foreach ($data as $value) { $modelbooth = $connection->createCommand("SELECT DISTINCT ms.attendee_id,a.Name as Name, a.title as title, wc.function_value AS Funame, wc.costcenter_value AS Cost_Center, a.phone as phone, a.speciality as speciality,'sdaattendee' as type\n FROM booth_schedules ms\n INNER JOIN amgen_contact_list a ON ms.attendee_id = a.id\n LEFT JOIN workforce_contacts wc ON wc.id = a.workforce_id\n WHERE ms.booth_id = {$value['id']}\n "); $attendee = $modelbooth->queryAll(); $finalvalue[$value['congress_id']][$value['date']][] = array('id' => $value['id'], 'congress' => CongressDetails::findOne($value['congress_id'])->name, 'title' => $value['booth_name'], 'phone' => $value['phone'], 'start_time' => date("g:i a", strtotime($value['from_time'])), 'end_time' => date("g:i a", strtotime($value['to_time'])), 'date' => $value['date'], 'location' => $value['location'], 'area' => $value['Area'], 'attendee' => $attendee); } return $finalvalue; } else { echo "User is not exist in Contect List"; } } else { print "done"; } } }
/** * @return \yii\db\ActiveQuery */ public function getCongress() { return $this->hasOne(CongressDetails::className(), ['id' => 'congress_id']); }
/** * Updates an existing Booths model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $modelsBoothSchedules = $model->boothSchedules; if ($model->load(Yii::$app->request->post())) { //Load data from post $oldIDs = ArrayHelper::map($modelsBoothSchedules, 'id', 'id'); $modelsBoothSchedules = Model::createMultiple(BoothSchedules::classname(), $modelsBoothSchedules); Model::loadMultiple($modelsBoothSchedules, Yii::$app->request->post()); $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsBoothSchedules, 'id', 'id'))); $model->date = \DateTime::createFromFormat('m-d-Y', $model->date)->format('Y-m-d'); // validate all models $valid = $model->validate(); if ($valid || !$valid) { $transaction = \Yii::$app->db->beginTransaction(); try { if ($flag = $model->save(false)) { if (!empty($deletedIDs)) { BoothSchedules::deleteAll(['id' => $deletedIDs]); } foreach ($modelsBoothSchedules as $modelBoothSchedule) { if (!empty($modelBoothSchedule->attendee_id)) { $attendeeDetails = $modelBoothSchedule->attendee; if (empty($modelBoothSchedule->booth_id)) { $modelBoothSchedule->booth_id = $model->id; //Below two lines can be removed $modelBoothSchedule->function_id = $attendeeDetails->function_Id; $modelBoothSchedule->cost_center_id = $attendeeDetails->group_Id; $modelBoothSchedule->isNewRecord = true; } $flag = $modelBoothSchedule->save(false); if (!$flag) { //If data is not saved then rollback the transaction and break the loop $transaction->rollBack(); break; } } } } if ($flag) { //If data is not saved then rollback the transaction and redirect to view page $transaction->commit(); return $this->redirect(['view', 'id' => $model->id]); } } catch (\Exception $e) { $transaction->rollBack(); } } } else { //Booth date should be between congress start date and end date $congressDetail = CongressDetails::findOne($model->congress_id); $congressStartDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->start_date)->format('m-d-Y'); $congressEndDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->end_date)->format('m-d-Y'); return $this->render('update', ['model' => $model, 'modelsBoothSchedules' => empty($modelsBoothSchedules) ? [new BoothSchedules()] : $modelsBoothSchedules, 'congressStartDate' => $congressStartDate, 'congressEndDate' => $congressEndDate]); } }
<?php use yii\bootstrap\ActiveForm; use yii\helpers\Html; use backend\models\CongressDetails; $this->title = 'Upload meeting with schedule'; $this->params['breadcrumbs'][] = $this->title; $congid = $_REQUEST['congress']; $congress = CongressDetails::findOne($congid); if ($congress) { $this->params['blueTitle'] = 'Upload meeting with schedule:' . $congress->name; } else { $this->params['blueTitle'] = 'Upload meeting with schedule'; } ?> <div id="row" style="background-color:#ccc;height:250px;margin-top: 80px;padding: 20px;"> <div class="m15 m-0-40"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'csvfile')->fileInput(); ?> <?php echo Html::submitButton('Upload', ['class' => 'btn btn-primary', 'name' => 'login-button']); ?> <?php ActiveForm::end(); ?> </div> </div>
<?php use backend\models\CongressDetails; /* @var $this yii\web\View */ /* @var $model backend\models\MeetingDetails */ $congress = CongressDetails::findOne($model->congress_id); if ($congress) { $this->params['blueTitle'] = 'Congress Schedule:' . $congress->name; } else { $this->params['blueTitle'] = 'Congress Schedule'; } $this->title = 'Update Meeting Details: ' . ' ' . $model->title; $this->params['breadcrumbs'][] = ['label' => 'Meeting Details', 'url' => ['index', 'id' => $model->congress_id]]; $this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Update'; ?> <div class="meeting-details-update"> <?php echo $this->render('_form', ['model' => $model, 'modelMeetingSchedules' => $modelMeetingSchedules, 'congressStartDate' => $congressStartDate, 'congressEndDate' => $congressEndDate]); ?> </div>
<div class="btn-group" role="group" aria-label="First group" style="width:33%; float:left"> <?php echo Html::a(' <button class="btn_booths float_left" type="button">Congress Details</button>', ['congress/view', 'id' => $id], ['class' => 'profile-link']); ?> </div> <div id="row" style="background-color:#ccc;height:250px;margin-top: 80px; padding: 20px;"> <div id="login"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <div class="col-xs-6 col-sm-4 p5" style="width:100%"> <div class="ml20" style="margin-left:-15px;"> <label class="f18" for="name">Congress</label> <?php echo $form->field($model, 'id', array('labelOptions' => array('class' => 'f18')))->dropDownList(ArrayHelper::map(CongressDetails::find()->orderBy(['name' => SORT_ASC])->asArray()->all(), 'id', 'name'), ['id' => 'name', 'class' => 'form-control intp'])->label(FALSE); ?> </div> </div> <div class="form-group"> <label class="f18" for="name">File</label> <?php echo $form->field($model, 'fileName')->fileInput()->label(FALSE); ?> <div class="form-group"> <div class="form-group"> <?php echo Html::submitButton('Upload', ['class' => 'btn btn-primary', 'name' => 'login-button']);
/** * Advanced search in iPAd * @return mixed */ public function actionSdasearch() { $connection = Yii::$app->db; if (Yii::$app->request->post()) { $value = \Yii::$app->request->post(); $formData['title'] = $value['title']; $formData['date'] = $value['date']; $formData['authors'] = $value['authors']; $formData['session_id'] = $value['session_id']; $formData['poster_board_no'] = $value['poster_board_no']; $formData['session'] = $value['session']; $formData['abstract_id'] = $value['abstract_id']; $formData['abstract'] = $value['abstract']; $formData['presenter'] = $value['presenter']; $formData['sda_type'] = $value['sda_type']; $formData['presentation_no'] = $value['presentation_no']; $formData['team'] = $value['team']; $formData['congress_id'] = $value['congress']; $formData['product'] = $value['product']; //User id can be used for searching for data on the basis of user's id $formData['user_id'] = (int) isset($value['user_id']) ? $value['user_id'] : false; $finalvalue = array(); $sql = "SELECT sda.* FROM sda "; if ($formData['user_id'] > 0) { $user = User::findOne(['id' => $formData['user_id']]); if ($user) { $sql .= " INNER JOIN sda_schedules on sda_schedules.sda_id = sda.id and sda_schedules.attendee_id = " . $user->attendee_id; } else { echo "Incorrect method"; } } $sql .= " INNER JOIN products on products.id = sda.product"; $sql .= " WHERE 1 "; $sql .= " AND sda.is_active = 1 "; $sql .= isset($formData['title']) && !empty($formData['title']) ? " AND sda.title LIKE '%" . $formData['title'] . "%'" : ''; $sql .= isset($formData['date']) && !empty($formData['date']) ? " AND sda.date='" . $formData['date'] . "'" : ''; $sql .= isset($formData['authors']) && !empty($formData['authors']) ? " AND sda.authors LIKE '%" . $formData['authors'] . "%'" : ''; $sql .= isset($formData['session_id']) && !empty($formData['session_id']) ? " AND sda.session_id='" . $formData['session_id'] . "'" : ''; $sql .= isset($formData['poster_board_no']) && !empty($formData['poster_board_no']) ? " AND sda.poster_board_no='" . $formData['poster_board_no'] . "'" : ''; $sql .= isset($formData['session']) && !empty($formData['session']) ? " AND sda.session LIKE '%" . $formData['session'] . "%'" : ''; $sql .= isset($formData['abstract_id']) && !empty($formData['abstract_id']) ? " AND sda.abstract_id='" . $formData['abstract_id'] . "'" : ''; $sql .= isset($formData['abstract']) && !empty($formData['abstract']) ? " AND sda.abstract LIKE '%" . $formData['abstract'] . "%'" : ''; $sql .= isset($formData['presenter']) && !empty($formData['presenter']) ? " AND sda.presenter LIKE '%" . $formData['presenter'] . "%'" : ''; if ($sdaTypeRow = \backend\models\SdaTypes::find()->where(['sda_name' => $formData['sda_type']])->one()) { $sql .= isset($formData['sda_type']) && !empty($formData['sda_type']) ? " AND sda_type_id='" . $sdaTypeRow->id . "'" : ''; } $sql .= isset($formData['product']) && !empty($formData['product']) ? " AND products.name='" . $formData['product'] . "'" : ''; $sql .= isset($formData['presentation_no']) && !empty($formData['presentation_no']) ? " AND sda.presentation_no='" . $formData['presentation_no'] . "'" : ''; $sql .= isset($formData['team']) && !empty($formData['team']) ? " AND sda.team LIKE '%" . $formData['team'] . "%'" : ''; $sql .= isset($formData['congress_id']) && !empty($formData['congress_id']) ? " AND sda.congress_id='" . $formData['congress_id'] . "'" : ''; $sql .= " order by date asc,session_start_time asc"; $model = Sda::findBySql($sql)->all(); if (!empty($model)) { foreach ($model as $key => $value) { $modelsda = $connection->createCommand("SELECT DISTINCT ms.attendee_id,a.Name as Name, a.title as title, f.Name AS Funame, c.Group_name AS Cost_Center, a.phone as phone, a.speciality as speciality,'sdaattendee' as type\n FROM sda_schedules ms\n INNER JOIN amgen_contact_list a ON ms.attendee_id = a.id\n LEFT JOIN functions f ON f.ID = a.function_id LEFT JOIN cost_center c ON c.id = a.group_id\n WHERE ms.sda_id = {$value->id}"); $attendee = $modelsda->queryAll(); $finalvalue[] = array('id' => $value['id'], 'congress' => CongressDetails::findOne($value['congress_id'])->name, 'product' => $value['product'] ? Products::findOne($value['product'])->name : null, 'title' => $value['title'], 'abstract_id' => $value['abstract_id'], 'priority' => SdaPriority::findOne($value['priority'])->priority_name, 'abstract' => $value['abstract'], 'date' => $value['date'], 'start_time' => date("g:i a", strtotime($value['session_start_time'])), 'end_time' => date("g:i a", strtotime($value['session_end_time'])), 'session_start_time' => !empty($value['session_start_time']) ? date("g:i a", strtotime($value['session_start_time'])) : "", 'session_end_time' => !empty($value['session_end_time']) ? date("g:i a", strtotime($value['session_end_time'])) : "", 'presentation_start_time' => !empty($value['presentation_start_time']) ? date("g:i a", strtotime($value['presentation_start_time'])) : "", 'presentation_end_time' => !empty($value['presentation_end_time']) ? date("g:i a", strtotime($value['presentation_end_time'])) : "", 'presenter' => $value['presenter'], 'sda_type' => \backend\models\SdaTypes::findOne($value['sda_type_id'])->sda_name, 'location' => $value['location'], 'session_id' => $value['session_id'], 'session' => $value['session'], 'authors' => $value['authors'], 'company' => \backend\models\CompanyDetails::findOne($value['company_id'])->name, 'team' => $value['team'], 'linktoposter' => $value['link_to_poster'], 'posterboadnno' => $value['poster_board_no'], 'presentation_no' => $value['presentation_no'], 'attendee' => $attendee, 'type' => 'SDA', 'category' => $value['category']); } } return $finalvalue; } else { echo "Incorrect method"; } }
/** * Display meeting assigned to a individual * @return mixed */ public function actionMymeeting() { $connection = Yii::$app->db; if (Yii::$app->request->post()) { $value = \Yii::$app->request->post(); $user = (int) $value['userid']; $congress = (int) $value['congress']; $user = User::findOne(['id' => $value['userid']]); $finaldata = array(); if ($user) { $sql = "SELECT mds.id as id,msd.congress_id as congress_id,mds.title as title,mds.start_time as start_time ,mds.stop_time as stop_time, mds.date as date,mds.location,mds.event_type, mds.rsr, mds.ol_consultant,mds.meeting_approval, mds.ol_catering, mds.notes, mds.ol_profile_id FROM meeting_schedules as msd INNER JOIN meeting_details as mds ON msd.meeting_id = mds.id WHERE msd.congress_id = {$congress} AND msd.attendee_id = {$user->attendee_id} order by mds.date ASC,mds.start_time ASC"; $modelmeeting = $connection->createCommand($sql)->queryAll(); $finalvalue = array(); if ($modelmeeting) { foreach ($modelmeeting as $value) { $sql = "SELECT DISTINCT ms.attendee_id,a.Name as Name, a.title as title, f.Name AS Funame, c.Group_name AS Cost_Center, a.phone as phone, a.speciality as speciality\n FROM meeting_schedules ms\n INNER JOIN amgen_contact_list a ON ms.attendee_id = a.id\n LEFT JOIN functions f ON f.ID = a.function_id LEFT JOIN cost_center c ON c.id = a.group_id\n WHERE ms.meeting_id ={$value['id']}"; $attendee = $connection->createCommand($sql)->queryAll(); $modelolattendee = $connection->createCommand("SELECT ola.user_type_id,ola.first_name,ola.last_name,ola.name,ola.ol_bio,ola.ol_phone_no,ola.ol_email FROM `meeting_schedules` msd INNER JOIN ol_attendees ola ON msd.ol_attendee_id = ola.id WHERE msd.meeting_id = {$value['id']}")->queryAll(); $data = array('meetingid' => $value['id'], 'congress' => \backend\models\CongressDetails::findOne($value['congress_id'])->name, 'title' => $value['title'], 'date' => $value['date'], 'start_time' => date("g:i a", strtotime($value['start_time'])), 'end_time' => date("g:i a", strtotime($value['stop_time'])), 'location' => $value['location'], 'eventtype' => \backend\models\MeetingTypes::findOne($value['event_type'])->type, 'attendee' => $attendee, 'olattendee' => $modelolattendee, 'rsr' => $value['rsr'], 'ol_consultant' => $value['ol_consultant'], 'meeting_approval' => $value['meeting_approval'], 'ol_catering' => $value['ol_catering'], 'notes' => $value['notes']); if (!empty($value['ol_profile_id'])) { $data['ol_profile'] = \backend\models\OlProfiles::findOne($value['ol_profile_id'])->name; } $finaldata[] = $data; } return $finaldata; } else { echo "Meeting is not found"; } } else { echo "Contact is not founnd in contact list"; } } }
/** * Updates an existing MeetingDetails model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $modelMeetingSchedules = $model->meetingSchedules; if ($model->load(Yii::$app->request->post())) { $oldIDs = ArrayHelper::map($modelMeetingSchedules, 'id', 'id'); $modelMeetingSchedules = Model::createMultiple(MeetingSchedules::classname(), $modelMeetingSchedules); Model::loadMultiple($modelMeetingSchedules, Yii::$app->request->post()); $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelMeetingSchedules, 'id', 'id'))); // ajax validation if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ArrayHelper::merge(ActiveForm::validateMultiple($modelMeetingSchedules), ActiveForm::validate($model)); } $model->date = \DateTime::createFromFormat('m-d-Y', $model->date)->format('Y-m-d'); // validate all models $valid = $model->validate(); if ($valid) { $transaction = \Yii::$app->db->beginTransaction(); try { if ($flag = $model->save(false)) { if (!empty($deletedIDs)) { MeetingSchedules::deleteAll(['id' => $deletedIDs]); } foreach ($modelMeetingSchedules as $modelMeetingSchedule) { if (empty($modelMeetingSchedule->congress_id)) { $modelMeetingSchedule->meeting_id = $model->id; $modelMeetingSchedule->congress_id = $model->congress_id; $modelMeetingSchedule->isNewRecord = true; } if ($modelMeetingSchedule->attendee_id > 0 || $modelMeetingSchedule->ol_attendee_id > 0) { $flag = $modelMeetingSchedule->save(false); } } $postData = \Yii::$app->request->post(); $olAttendeeData = isset($postData['OlAttendees']) ? $postData['OlAttendees'] : []; foreach ($olAttendeeData as $olAttendeeInfo) { // print_r($olAttendeeInfo); if (!empty($olAttendeeInfo['name']) && (!isset($olAttendeeInfo['id']) || empty($olAttendeeInfo['id']))) { $olAttendeeModel = new \backend\models\OlAttendees(); $olAttendeeModel->user_type_id = 1; $parts = explode(" ", $olAttendeeInfo['name']); $lastname = array_pop($parts); $firstname = implode(" ", $parts); $olAttendeeModel->first_name = $firstname; $olAttendeeModel->last_name = $lastname; $olAttendeeModel->name = $olAttendeeInfo['name']; $olAttendeeModel->ol_bio = $olAttendeeInfo['ol_bio']; $olAttendeeModel->ol_phone_no = $olAttendeeInfo['ol_phone_no']; $olAttendeeModel->ol_email = $olAttendeeInfo['ol_email']; $olAttendeeModel->is_active = 1; $olAttendeeModel->isNewRecord = true; if ($olAttendeeModel->validate()) { if ($flag = $olAttendeeModel->save(false)) { $olAttendeeId = $olAttendeeModel->id; $meetingScheduleModel = new MeetingSchedules(); $meetingScheduleModel->meeting_id = $model->id; $meetingScheduleModel->congress_id = $model->congress_id; $meetingScheduleModel->ol_attendee_id = $olAttendeeId; $meetingScheduleModel->isNewRecord = true; $flag = $meetingScheduleModel->save(false); if (!$flag) { $transaction->rollBack(); break; } } } } } } if ($flag) { $transaction->commit(); return $this->redirect(['view', 'id' => $model->id]); } } catch (\Exception $e) { $transaction->rollBack(); } } } else { //Meeting date should be between congress start date and end date $congressDetail = CongressDetails::findOne($model->congress_id); $congressStartDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->start_date)->format('m-d-Y'); $congressEndDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->end_date)->format('m-d-Y'); return $this->render('update', ['model' => $model, 'modelMeetingSchedules' => empty($modelMeetingSchedules) ? [new MeetingSchedules()] : $modelMeetingSchedules, 'congressStartDate' => $congressStartDate, 'congressEndDate' => $congressEndDate]); } }
/** * Uploads the attachement and redirects to the home page * @param int $id */ public function actionAttachment($id) { $model1 = new CongressDetails(); if ($model1->load(Yii::$app->request->post())) { $model1->attachment = UploadedFile::getInstance($model1, 'attachment'); if ($model1->attachment) { if ($model1->attachment->saveAs('uploads/' . $model1->attachment->baseName . '.' . $model1->attachment->extension)) { $attachment = "uploads/" . $model1->attachment->name; Yii::$app->db->createCommand("UPDATE congress_details SET attachment='{$attachment}' WHERE id={$id}")->execute(); } } return $this->redirect(array('site/index')); } }
use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $model backend\models\SdaFeedback */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="sda-feedback-form"> <?php $form = ActiveForm::begin(); ?> <?php $congress_ids = \backend\models\CongressDetails::find()->all(); $listData = ArrayHelper::map($congress_ids, 'id', 'name'); echo $form->field($model, 'congress_id')->dropDownList($listData, ['prompt' => 'Select...']); ?> <?php $sda_ids = \backend\models\Sda::find()->all(); $listDatas = ArrayHelper::map($sda_ids, 'id', 'title'); echo $form->field($model, 'sda_id')->dropDownList($listDatas, ['prompt' => 'Select...']); ?> <?php $listData = ArrayHelper::map($sda_ids, 'session_id', 'session_id'); echo $form->field($model, 'session_id')->dropDownList($listData, ['prompt' => 'Select...']); ?> <?php echo $form->field($model, 'audience_size')->textInput();
/** Get the list of all attachments */ public function actionAllattachment() { if (Yii::$app->request->post()) { $value = \Yii::$app->request->post(); $congress = $value['congress']; $sda_id = isset($value['sda_id']) && $value['sda_id'] > 0 ? $value['sda_id'] : ""; if ($congress) { if ($sda_id > 0) { $records_sda = \backend\models\SdaAttachments::find()->where(['congress_id' => $congress, 'sda_id' => $sda_id, 'sda_feedback_id' => null])->all(); } else { $records_sda = \backend\models\SdaAttachments::find()->where(['congress_id' => $congress])->all(); } $records_meeting = \backend\models\MeetingAttachments::find()->where(['congress_id' => $_POST['congress']])->all(); $return = []; $data = []; foreach ($records_sda as $row) { $protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'https://'; $host = $_SERVER['HTTP_HOST']; $congressname = CongressDetails::findOne($row['congress_id'])->name; unset($row['sda_feedback_id']); unset($row['session_id']); $row = $row->toArray(); $filename = explode("/", $row['path']); $filenames = end(explode(".", $filename[1])); $data['filename'] = str_replace($filenames, "", $filename[1]); $data['filename'] = str_replace(".", "", $filename[1]); $data['filetype'] = $filenames; $data['path'] = $protocol . $host . "/rest/backend/web/" . $row['path']; $data['exits'] = file_exists($_SERVER['DOCUMENT_ROOT'] . '/rest/backend/web/' . $row['path']); $return['sda'][] = $data; } $data2 = []; foreach ($records_meeting as $row) { $protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'https://'; $host = $_SERVER['HTTP_HOST']; $row = $row->toArray(); $type = \backend\models\MeetingTypes::findOne($row['meeting_type_id']); $congressname = CongressDetails::findOne($row['congress_id'])->name; unset($row['meeting_type_id']); $filename = explode("/", $row['path']); $filenames = end(explode(".", $filename[1])); $data2['filename'] = str_replace($filenames, "", $filename[1]); $data2['filename'] = str_replace(".", "", $filename[1]); $data2['filetype'] = $filenames; $data2['path'] = $protocol . $host . "/rest/backend/web/" . $row['path']; $data2['exits'] = file_exists($_SERVER['DOCUMENT_ROOT'] . '/rest/backend/web/' . $row['path']); $return['meeting'][] = $data2; } return $return; } else { return "parameter missing"; } } else { return 'invalid method'; } }
/** * Updates an existing Sda model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $modelsSdaSchedules = $model->sdaSchedules; if ($model->load(Yii::$app->request->post())) { $oldIDs = ArrayHelper::map($modelsSdaSchedules, 'id', 'id'); $modelsSdaSchedules = Model::createMultiple(SdaSchedules::classname(), $modelsSdaSchedules); Model::loadMultiple($modelsSdaSchedules, Yii::$app->request->post()); $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsSdaSchedules, 'id', 'id'))); // ajax validation if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ArrayHelper::merge(ActiveForm::validateMultiple($modelsSdaSchedules), ActiveForm::validate($model)); } $model->date = \DateTime::createFromFormat('m-d-Y', $model->date)->format('Y-m-d'); // validate all models $valid = $model->validate(); if ($valid || !$valid) { //change condition for update without being validate $transaction = \Yii::$app->db->beginTransaction(); try { if ($flag = $model->save(false)) { if (!empty($deletedIDs)) { SdaSchedules::deleteAll(['id' => $deletedIDs]); } foreach ($modelsSdaSchedules as $modelSdaSchedule) { if (!empty($modelSdaSchedule->attendee_id)) { if (empty($modelSdaSchedule->congress_id)) { $modelSdaSchedule->sda_id = $model->id; $modelSdaSchedule->congress_id = $model->congress_id; $modelSdaSchedule->assigned = 0; $modelSdaSchedule->isNewRecord = true; } $flag = $modelSdaSchedule->save(false); if (!$flag) { $transaction->rollBack(); break; } } } } if ($flag) { $transaction->commit(); return $this->redirect(['view', 'id' => $model->id]); } } catch (Exception $e) { $transaction->rollBack(); } } } else { $congressDetail = CongressDetails::findOne($model->congress_id); $congressStartDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->start_date)->format('m-d-Y'); $congressEndDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->end_date)->format('m-d-Y'); return $this->render('update', ['model' => $model, 'modelsSdaSchedules' => empty($modelsSdaSchedules) ? [new SdaSchedules()] : $modelsSdaSchedules, 'congressStartDate' => $congressStartDate, 'congressEndDate' => $congressEndDate]); } }
/** * Finds the CongressDetails model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CongressDetails the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CongressDetails::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }