private function saveAndDeleteMedia($type) { /** @var $model Media [ ] */ $model = new Media(); $mockRecord = $this->getMockRecord(); $instruction = Deal::model()->findByPk($mockRecord['med_row']); $this->assertNotEmpty($instruction, "instruction not exist"); $property = Property::model()->findByPk($instruction->dea_prop); $this->assertNotEmpty($property, "property not exist"); $this->assertNotNull($property->addressId, "property has no address"); $address = Address::model()->findByPk($property->addressId); $this->assertNotEmpty($address, " Address not exist"); $model->setAttributes($this->getMockRecord()); $model->file = $this->getMockCuploadedImage('image/jpeg', 1); if ($type == Media::TYPE_PHOTO) { $model->setCropFactor($this->getCropFactor()); } elseif ($type == Media::TYPE_EPC || $type == Media::TYPE_FLOORPLAN) { $model->otherMedia = $type; } $this->assertTrue($model->validate(), "record not validated"); $this->assertTrue($model->save(), "record not saved"); foreach ($model->getImageSizes() as $imageSize) { $this->assertFileExists($model->getFullPath($imageSize), $imageSize . " does not exist"); } $this->deleteMedia($model->med_id); }
public function actionSelectInstruction() { $builder = AppointmentBuilder::getCurrent(); if (isset($_POST['Deal']) && $_POST['Deal']) { // need to finish instruction info; $instruction = Deal::model()->findByPk($builder->getInstructionId()); $instruction->attributes = $_POST['Deal']; if ($instruction->save()) { $this->redirect(['InstructionSelected', 'instructionId' => $instruction->dea_id]); } else { echo "<pre style='color:blue' title='" . __FILE__ . "'>" . basename(__FILE__) . ":" . __LINE__ . "<br>"; print_r($instruction->getErrors()); echo "</pre>"; } $this->render('createInstruction', ['model' => $instruction]); return; } /** @var $property Property */ $property = Property::model()->findByPk($builder->getPropertyId()); if (!$property->instructions || isset($_GET['new'])) { // need to create one. $instruction = new Deal(); $instruction->dea_prop = $property->pro_id; $instruction->dea_status = Deal::STATUS_VALUATION; $instruction->importFromProperty($property); $instruction->save(false); $builder->setInstructionId($instruction->dea_id); $this->render('createInstruction', ['model' => $instruction]); return; } $this->render('selectInstruction', ['model' => $property]); }
public function actionIndex($execute = true) { /** @var Deal $d */ $d = Deal::model()->with(['followUpAppointment' => ['together' => true]]); $missedFollowUp = $d->missedFollowUp()->findAll('followUpAppointment.app_start >= :rollOverStartingDate', ['rollOverStartingDate' => Yii::app()->params['followUpAppointments']['rollOverStartingDate']]); $i = 0; foreach ($missedFollowUp as $key => $value) { /** @var Appointment $appointment */ if ($appointment = $value->followUpAppointment) { $this->log("DealID: {$value->dea_id}, APP_ID:" . $appointment->app_id); $this->log("Current appointment start time: " . $appointment->app_start); $this->log("Current appointment end time: " . $appointment->app_end); $appointment->app_start = date("Y-m-d") . " " . date('H:i:s', strtotime($appointment->app_start)); $appointment->app_end = date("Y-m-d") . " " . date('H:i:s', strtotime($appointment->app_end)); $this->log("Updated appointment start time: " . $appointment->app_start); $this->log("Updated appointment end time: " . $appointment->app_end); if ($execute) { $appointment->update(['app_start', 'app_end']); } $i++; } } $this->log('Appointments updated: ' . $i); if (!$execute) { $this->log('IT WAS A TEST RUN. NO APPS WERE UPDATED'); } }
/** * @param $id * @param null $model */ public function actionView($id, $model = null) { $criteria = new CDbCriteria(); if (Yii::app()->user->isGuest) { $criteria->scopes = ['onlyActive']; } $model = $this->loadModel($id, $criteria); if (isset($_POST['Place']) && $_POST['Place']) { unset($model->attributes); $model->attributes = $_POST['Place']; if (isset($_POST['Location'])) { if (!$model->location) { $model->location = new Location(); } $model->location->attributes = $_POST['Location']; } } $instructions = Deal::model()->available()->notUnderTheRadar()->findAll(); $allParks = Place::model()->findAll(['scopes' => 'onlyActive']); /** @var $device \Device */ $device = Yii::app()->device; $view = $device->isDevice('mobile') ? 'mobileDetailsView' : 'detailsView'; $smallDevice = $device->isDevice('smallDevice'); $this->render($view, ['model' => $model, 'instructions' => $instructions, 'allParks' => $allParks, 'title' => $model->title . ($model->location->postcode ? ' , ' . $model->location->postcode : ''), 'smallDevice' => $smallDevice]); }
public function loadModel($id) { $model = Deal::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionIndex() { $videoCr = new CDbCriteria(); $videoCr->order = 'displayOrder ASC'; $videoCr->scopes = ['publicAvailableInstruction']; $videoCr->limit = 6; $this->render('index', array('latestProperties' => Deal::model()->getLatest(6), 'featuredVideo' => InstructionVideo::model()->with('instruction')->findByAttributes(['featuredVideo' => 1]), 'mostViewed' => Deal::model()->getMostViewed(1, date("Y-m-d H:i:s", strtotime("-15 days"))), 'instructionVideos' => InstructionVideo::model()->with('instruction')->findAllByAttributes(['displayOnSite' => 1], $videoCr), 'propertyCategories' => PropertyCategory::model()->active()->displayOnHome()->findAll())); }
private function getDataBySearch($search) { $data = []; $clients = Client::model()->quickSearch($search); foreach ($clients as $key => $client) { $data[] = ['label' => $client->getFullName(), 'value' => $client->getFullName(), 'url' => $this->createUrl('client/update', ['id' => $client->cli_id])]; } $instructions = Deal::model()->quickSearch($search); foreach ($instructions as $key => $instr) { $title = $instr->address->line1 . ' ' . $instr->title; $data[] = ['label' => $title, 'value' => $title, 'url' => $this->createUrl('instruction/summary', ['id' => $instr->dea_id])]; } return $data; }
public function actionStatus($id, $action) { $Deal = Deal::model()->findByPk($id); switch ($action) { case 'aprove': $Deal->status = 'aprove'; $Deal->save(); break; case 'cancel': $Deal->status = 'cancel'; $Deal->save(); break; } $this->redirect('/cabinet/deal/' . $id); }
public function actionShowOfferClients($id = 0) { if ($id) { echo json_encode(array('html' => '')); Yii::app()->end(); } $instructionId = Offer::model()->findByPk($id)->off_deal; $instructionType = Deal::model()->findByPk($instructionId)->dea_type; $clientStatusType = $instructionType == 'Sales' ? 'cli_salestatus' : 'cli_letstatus'; $offerClientCriteria = new CDbCriteria(); $offerClientCriteria->compare('c2o_off', $id, false, 'AND', false); $offerClientList = ClientToOffer::model()->findAll($offerClientCriteria); $this->renderPartial('_clients', ['offerClientList' => $offerClientList, 'instructionType' => $instructionType, 'clientStatusType' => $clientStatusType]); }
/** * @param $id * @param string $mode * @throws CHttpException */ public function actionShowMap($id, $mode = 'map') { $this->layout = '//layouts/popup-iframe'; $localEvent = $this->loadModel($id); if (!$localEvent->address->latitude || !$localEvent->address->longitude) { throw new CHttpException(404, 'Event map not defined'); } $criteria = new CDbCriteria(); // $criteria->condition = "dateTo >= '" . date("Y-m-d") . "' OR (dateTo is NULL AND dateFrom >= '" . date("Y-m-d") . "')"; $criteria->order = 'dateFrom'; $criteria->scopes = ['onlyActive', 'published']; $localEvents = LocalEvent::model()->findAll($criteria); $properties = Deal::model()->publicAvailable()->notUnderTheRadar()->with('property')->findAll(); $this->render("//MapView/default", array('id' => $id, 'latitude' => $localEvent->address->latitude, 'longitude' => $localEvent->address->longitude, 'type' => 'localEvent', 'mode' => $mode, 'mapDim' => ['w' => '80%', 'h' => ''], 'properties' => $properties, 'localEvents' => $localEvents, 'nearestTransport' => true)); }
public function actionIndex() { /* gunakan layout store */ $this->layout = 'store'; /* order by id desc */ $criteria = new CDbCriteria(array('order' => 'product_id DESC')); /* count data product */ $count = Product::model()->count($criteria); /* panggil class paging */ $pages = new CPagination($count); /* elements per page */ $pages->pageSize = 8; /* terapkan limit page */ $pages->applyLimit($criteria); /* select data product * cache(1000) digunakan untuk cache data, * 1000=10menit */ $models = Product::model()->cache(1000)->findAll($criteria); $dealModel = Deal::model()->findByAttributes(array('status' => "1")); /* render ke halaman index di views/product * dengan membawa data pada $models dan data pada $pages */ $this->render('index', array('models' => $models, 'pages' => $pages, 'deal' => $dealModel)); }
/** * This got messy * * @param $instructionId * @throws CHttpException */ public function actionSendMailshot($instructionId) { $model = new Client('search'); if (isset($_POST['send']) && $_POST['send']) { $instruction = Deal::model()->findByPk($instructionId); $type = MailshotType::model()->findByPk($_POST['MailshotType']); $model->attributes = $_GET['Client']; $dataProvider = $model->search(); $dataProvider->setPagination(['pageSize' => 100]); if (!$type) { throw new CHttpException(404, 'Mailshot Type [name: ' . $_POST['MailshotType'] . '] was not found'); } if (!$instruction) { throw new CHttpException(404, 'Instruction [id: ' . $instructionId . '] was not found'); } $mailshot = new MandrillMailshot(); $mailshot->instructionId = $instruction->dea_id; $mailshot->type = $type->name; $mailshot->save(); if ($type->templatePath && file_exists($type->templatePath)) { ob_start(); include $type->templatePath; $htmlTemplate = ob_get_clean(); } else { $htmlTemplate = $this->execTemplate($type->htmlTemplate); } $textTemplate = $this->execTemplate($type->textTemplate); $mandrillMessagePreset = new MandrillMessage(); $mandrillMessagePreset->setFrom(Yii::app()->params['mailshot']['sender_email'], Yii::app()->params['mailshot']['sender_name']); $mandrillMessagePreset->setHtmlBody($htmlTemplate); $mandrillMessagePreset->setTextBody($textTemplate); $mandrillMessagePreset->setSubject($type->subject); $mandrillMessagePreset->setPreserveRecepients(false); $mandrillMessagePreset->setGlobalMergeVar('MAILSHOT_ID', $mailshot->id); $mandrillMessagePreset->setGlobalMergeVar('INSTRUCTION_ID', $instruction->dea_id); $mandrillMessagePreset->setGlobalMergeVar('INSTRUCTION_PRICE', Locale::formatCurrency($instruction->dea_marketprice)); $mandrillMessagePreset->setGlobalMergeVar('INSTRUCTION_TITLE', $instruction->title); $mandrillMessagePreset->setGlobalMergeVar('INSTRUCTION_STRAPLINE', $instruction->dea_strapline); $mandrillMessagePreset->setGlobalMergeVar('OFFICE_TITLE', $instruction->branch->office->title); $mandrillMessagePreset->setGlobalMergeVar('OFFICE_NUMBER', $instruction->branch->bra_tel); if (isset($_POST['test']) && $_POST['test']) { $mandrillMessagePreset->enableTest(); } $iterator = new DataProviderIterator($dataProvider); /** @var $mandrillMessage MandrillMessage */ $mandrillMessage = null; $x = 0; $staffEmails = array_fill_keys(Yii::app()->params['mailshot']['alwaysSendTo'], '?'); if (Yii::app()->params['mandrill']['test_run']) { $testEmails = Yii::app()->params['mandrill']['test_emails']; } /** @var $client Client */ foreach ($iterator as $client) { $email = $client->cli_email; if (isset($testEmails)) { if (!$testEmails) { break; } $email = array_shift($testEmails); } if (!$email) { continue; } //we are sending emails to our staff in a different message if (array_key_exists($email, $staffEmails)) { continue; } if ($x % Yii::app()->params['mandrill']['mails_in_message'] === 0) { if ($mandrillMessage) { $mandrillMessage->send(); $mailshot->addMessage($mandrillMessage); } $mandrillMessage = clone $mandrillMessagePreset; } $mandrillMessage->addTo($email, $client->getFullName()); $mandrillMessage->setRecepientMergeVar($email, 'CLIENT_FULLNAME', $client->getFullName()); $mandrillMessage->setRecepientMergeVar($email, 'CLIENT_SALUTATION', $client->cli_salutation); $mandrillMessage->setRecepientMergeVar($email, 'CLIENT_ID', $client->cli_id); $mandrillMessage->setRecepientMergeVar($email, 'CLIENT_EMAIL', $email); $mandrillMessage->setRecepientMetaData($email, 'clientId', $client->cli_id); $x++; } if (!$mandrillMessage->id) { $mandrillMessage->send(); $mailshot->addMessage($mandrillMessage); } /** * doing a trick. will send an email to everyone in staff list to avoid complains */ $staffMessage = clone $mandrillMessagePreset; $clients = Client::model()->findAll('cli_email IN (' . implode(', ', $staffEmails) . ')', array_keys($staffEmails)); foreach ($clients as $client) { $email = $client->cli_email; $staffMessage->addTo($email, $client->getFullName()); $staffMessage->setRecepientMergeVar($email, 'CLIENT_FULLNAME', $client->getFullName()); $staffMessage->setRecepientMergeVar($email, 'CLIENT_SALUTATION', $client->cli_salutation); $staffMessage->setRecepientMergeVar($email, 'CLIENT_ID', $client->cli_id); $staffMessage->setRecepientMergeVar($email, 'CLIENT_EMAIL', $email); $staffMessage->setRecepientMetaData($email, 'clientId', $client->cli_id); } $staffMessage->send(); $mailshot->addMessage($staffMessage); Yii::app()->user->setFlash('mailshot-sent', 'Mailshot successfully sent'); $this->redirect(['instruction/summary', 'id' => $instructionId]); } $this->render('sendMailshot'); }
public function actionInterestVendorNotified() { $dealId = isset($_POST['dealId']) ? $_POST['dealId'] : ""; $clientId = isset($_POST['clientId']) ? $_POST['clientId'] : ""; $type = isset($_POST['type']) ? $_POST['type'] : ""; $model = Deal::model()->findByPk($dealId); if (!$model) { return json_encode(['error' => true, 'message' => 'deal is not found']); } $model->registerInterest($clientId, $type); echo json_encode(['updated' => true]); }
/** * @param $id * @param string $mode * @throws CHttpException */ public function actionShowMap($id, $mode = 'map') { $this->layout = '//layouts/popup-iframe'; $instruction = $this->loadModel($id); if (!$instruction->property->getLat() || !$instruction->property->getLng()) { throw new CHttpException(404, 'Property map not defined'); } $properties = Deal::model()->publicAvailable()->notUnderTheRadar()->with('property')->findAll(); $this->render("//MapView/default", array('id' => $id, 'latitude' => $instruction->property->getLat(), 'longitude' => $instruction->property->getLng(), 'type' => 'instruction', 'mode' => $mode, 'mapDim' => ['w' => '80%', 'h' => ''], 'properties' => $properties, 'nearestTransport' => true)); }
public function setInstructions($instructions, $instantSave = true) { $instructions = (array) $instructions; if (!$instantSave || $this->isNewRecord && !$this->app_id) { $this->attachEventHandler('onAfterSave', function () use($instructions) { static $run = false; if (!$run) { $this->setInstructions($instructions); $run = true; } }); } else { $sql = "DELETE FROM link_deal_to_appointment WHERE d2a_app = :id"; Yii::app()->db->createCommand($sql)->execute(['id' => $this->app_id]); $t = []; foreach ($instructions as $instructionId) { $t[] = '(' . $this->app_id . ', ' . $instructionId . ')'; } $sql = "REPLACE INTO link_deal_to_appointment (d2a_app,d2a_dea) VALUES " . implode(',', $t); Yii::app()->db->createCommand($sql)->execute(); } $this->instructions = Deal::model()->findAllByPk($instructions); }
$criteria = new CDbCriteria(); $criteria->scopes = ['notUnderTheRadar', 'publicAvailable']; ?> <div class="row-fluid"> <div class="span12"> <fieldset> <div class="block-header"> Manage Videos Sequence </div> <div class="content sortable"> <?php foreach ($instructionVideos as $instructionVideo) { /** @var $instruction Deal[ ] */ $instruction = Deal::model()->findByPk($instructionVideo->instructionId, $criteria); if ($instruction) { $photo = $instruction->getMainImage() ? $instruction->getMainImage()->getMediaImageURIPath('_small') : ''; $info = $instruction->property->getLine(3) . ', ' . $instruction->property->getFirstPostcodePart() . ' - ' . Locale::formatPrice($instruction->dea_marketprice, $instruction->dea_type == 'Sales' ? false : true); echo '<div data-id="' . $instructionVideo->id . '" class="video-box" style="background-image: url(' . $photo . ')">'; echo '<div class="top-part">'; echo '<img src="' . Icon::PUBLIC_VIDEO_PLAY_ICON . '" style="vertical-align:middle;">'; echo '</div>'; echo '<div class="bottom-part">'; echo '<a href="' . $this->createUrl('/admin4/instruction/production/', ['id' => $instruction->dea_id]) . '##manageVideo">' . $info . '</a>'; echo '</div>'; echo '</div>'; } } ?> </div>