Ejemplo n.º 1
0
 public function testSaveDelete()
 {
     Deal::truncate();
     $d = new Deal();
     $d->name = "asasdasd";
     $d->save();
     $this->assertTrue($d->id != 0);
     $this->assertTrue($d->created != null);
     $this->assertTrue($d->updated != null);
     //        $this->assertTrue($rp["deleted"] == 0);
     $d->delete();
     $this->assertTrue($d->deleted == 1);
     Deal::truncate();
 }
Ejemplo n.º 2
0
 public static function getFeaturedService()
 {
     $deals = Deal::select(array('deals.id', 'deals.title', 'deals.amount', 'deals.discount', 'images.image_path'))->leftJoin('services', 'services.id', '=', 'deals.service_id')->leftJoin('images', function ($join) {
         $join->on('images.ref_id', '=', 'services.id')->where('images.image_type', '=', 'service');
     })->where('featured', 1)->get();
     return $deals;
 }
 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');
     }
 }
Ejemplo n.º 4
0
 public static function destroy($outlets, $id = null)
 {
     $serviceIds = $dealIds = $outletIds = [];
     if (!empty($outlets)) {
         if ($id) {
             array_push($outletIds, $id);
         } else {
             foreach ($outlets as $key => $outlet) {
                 array_push($outletIds, $outlet->id);
             }
         }
         $services = Service::whereIn('outlet_id', $outletIds)->get();
         foreach ($services as $key => $service) {
             array_push($serviceIds, $service->id);
         }
         // delete deal
         $deals = Deal::whereIn('service_id', $serviceIds)->get();
         foreach ($deals as $key => $deal) {
             array_push($dealIds, $deal->id);
         }
         // delete deal transaction
         DealTransaction::whereIn('deal_id', $dealIds)->delete();
         Deal::whereIn('id', $dealIds)->delete();
         Service::whereIn('id', $serviceIds)->delete();
         Outlet::whereIn('id', $outletIds)->delete();
     }
 }
Ejemplo n.º 5
0
 /**
  * @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]);
 }
Ejemplo n.º 6
0
 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 findOrCreateDeal($user)
 {
     $deal = Deal::where("payee_code", "=", $user->code)->where("payment_analysis", "=", 1)->first();
     if ($deal == null) {
         $deal = Deal::create(["name" => "Statement Analysis for " . $user->name, "payee_code" => $user->code, "etl_status" => "processed", "payment_analysis" => 1, "company_id" => $user->company_id]);
     }
     return $deal;
 }
Ejemplo n.º 8
0
 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()));
 }
Ejemplo n.º 9
0
 public function loadModel($id)
 {
     $model = Deal::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 10
0
 public function updatePart()
 {
     $completedDeals = Deal::findBy(array('OrderId' => $this->id, 'Done' => 1));
     $volumes = array_map(function ($deals) {
         return $deals['Volume'];
     }, $completedDeals);
     $volumes = array_sum($volumes);
     $this->part = $volumes / $this->volume;
 }
 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;
 }
Ejemplo n.º 12
0
 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);
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // $fields->addFieldToTab('Root.Main', $f = new TextField($name = 'Description'));
     $fields->addFieldToTab('Root.Main', LiteralField::create('OldID', "<b>OLDID:</b>" . $this->OldID));
     $fields->addFieldToTab('Root.Main', DateField::create('Sold', ' Sold')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', TextField::create('Quantity'));
     $fields->addFieldToTab('Root.Main', TextareaField::create('Comment'));
     $fields->addFieldToTab('Root.Main', TextField::create('SellPrice'));
     $fields->addFieldToTab('Root.Main', TextField::create('BuyPrice'));
     $fields->addFieldToTab('Root.Main', DateField::create('SoldDate')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('Sold'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('ForSaleInWebshop'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('OnHold'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('ShowInList'));
     //        $fields->addFieldToTab('Root.Main', S::create('Deal'));  TODO!!!
     $fields->addFieldToTab('Root.Main', DropdownField::create('DealID', 'Deal', Deal::get()->map('ID', 'Title'))->setEmptyString('(Select one)'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('InStock'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('IsForSale'));
     $fields->addFieldToTab('Root.Main', TextField::create('Quantity'));
     $fields->addFieldToTab('Root.Main', TextField::create('Showdate'));
     $fields->addFieldToTab('Root.Main', TextField::create('IndateStamp'));
     $fields->addFieldToTab('Root.Main', TextField::create('SC_FK'));
     $fields->addFieldToTab('Root.Main', TextField::create('DatumCode'));
     $fields->addFieldToTab('Root.Main', TextField::create('OriginalCode'));
     $fields->addFieldToTab('Root.Main', TextField::create('SortKey'));
     $fields->addFieldToTab('Root.Main', TextField::create('AllRow'));
     $fields->addFieldToTab('Root.Main', TextField::create('OldCat'));
     $fields->addFieldToTab('Root.Main', DateField::create('SortDate')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', DateField::create('NewOfDate')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', NumericField::create('NewSubCatFK'));
     //$fields->addFieldToTab('Root.Main', UploadField::create('Photos'));
     $imageField = new SortableUploadField('Photos', 'Images');
     $fields->addFieldToTab('Root.Main', $imageField);
     $map = SubCategoryPage::get()->map("ID", "ParentAndTitle")->toArray();
     //            Debug::show($map);
     $CategoryPages = new MultiSelect2Field('SubCategoryPages', 'SubCategoryPages', $map, null, 0, true);
     $fields->addFieldToTab('Root.SubCategoryPages', $CategoryPages);
     #LINKS
     $gridFieldConfig1 = GridFieldConfig::create()->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldAddNewButton('toolbar-header-right'))->addComponent(new GridFieldSortableHeader())->addComponent(new GridFieldDataColumns())->addComponent(new GridFieldPaginator(50))->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldDetailForm());
     $fields->addFieldToTab('Root.ProductLinks', $grid = new GridField('ProductLinks', 'Links', $this->ProductLinks(), $gridFieldConfig1));
     //        new GridField
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Ejemplo n.º 14
0
 public function getOutletStatData()
 {
     $outletsArray = array();
     $dealsArray = array();
     $outlets = Outlet::owner()->get();
     $deals = Deal::dashboardDeal();
     foreach ($outlets as $outlet) {
         $dealsArray = array();
         foreach ($deals as $deal) {
             if ($outlet->id == $deal->outlet_id) {
                 $dealsArray[] = $deal;
             }
         }
         if (count($dealsArray)) {
             $outletsArray[$outlet->id] = array('name' => $outlet->name, 'deal' => $dealsArray);
         }
     }
     return $outletsArray;
 }
Ejemplo n.º 15
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     // first api only accepts posts
     if ($request->getMethod() != "POST") {
         $this->getResponse()->setStatusCode(405);
         return $this->renderPartial("wrong_method");
     }
     $access_token = $request->getParameter("access_token");
     // check access token
     if (!$access_token) {
         $this->getResponse()->setStatusCode(401);
         return $this->renderPartial("authentication_error");
     }
     $user = Doctrine_Core::getTable('sfGuardUser')->createQuery('u')->where('u.access_token = ?', $access_token)->addWhere('u.is_active = ?', true)->fetchOne();
     // check access token
     if (!$user) {
         $this->getResponse()->setStatusCode(401);
         return $this->renderPartial("authentication_error");
     }
     // check if account was setup properly
     // @todo add publisher commission
     if (!$user->getApiPriceLike() || !$user->getApiPriceMediaPenetration() || !$user->getApiPaymentMethod() || !$user->getApiCommissionPercentage()) {
         $this->getResponse()->setStatusCode(403);
         return $this->renderPartial("setup_failure");
     }
     // get json post
     $json_content = file_get_contents("php://input");
     sfContext::getInstance()->getLogger()->notice($json_content);
     $deal = new Deal();
     $deal->setSfGuardUser($user);
     $deal->setPaymentMethod($user->getApiPaymentMethod());
     $data = json_decode($json_content, true);
     // check if data is valid json
     if (!$data) {
         $this->getResponse()->setStatusCode(406);
         return $this->renderPartial("wrong_mimetype");
     }
     $deal->fromApiArray($data);
     // set commission values
     $deal->setCommissionPercentage($user->getApiCommissionPercentage());
     $pot = round($deal->getPrice() * $user->getApiCommissionPercentage() / 100, 2, PHP_ROUND_HALF_UP);
     $deal->setCommissionPot($pot);
     $unit = round($pot / $deal->getTargetQuantity(), 2, PHP_ROUND_HALF_UP);
     $deal->setCommissionPerUnit($unit);
     // validate request
     $validate = $deal->validate();
     if ($validate !== true) {
         $this->getResponse()->setStatusCode(406);
         return $this->renderPartial("deals/wrong_fields", array("errors" => $validate));
     } else {
         $deal->save();
         $deal->complete_campaign();
         $deal->complete_share();
         $deal->complete_coupon();
         $deal->complete_billing();
         $deal->submit();
         if (array_key_exists('activate', $data) && $data['activate'] === true) {
             $deal->approve();
         }
     }
 }
 public function testEmptyLinesInFile()
 {
     $this->resetEvents();
     $fileName = "with_empty_lines.csv";
     $path = $this->copyFileToTemp($fileName);
     $s = $this->service();
     $companyId = rand(1000, 1000000);
     $fileDetails = ["year" => 2015, "month" => 7];
     $rpf = $s->process($path, $companyId, $fileDetails);
     $this->assertTrue($rpf->status == RoyaltyPaymentFile::STATUS_PAYMENTS_PROCESSED);
     $rpf = $s->processRoyaltyStreams($rpf);
     $this->assertTrue($rpf->status == RoyaltyPaymentFile::STATUS_PROCESSED);
     $payments = RoyaltyPayment::all();
     $this->assertTrue(count($payments) == 4);
     $this->assertTrue($payments[0]->payee_code == 1128);
     $this->assertTrue($payments[1]->payee_code == 1111);
     $this->assertTrue($payments[2]->payee_code == 1545);
     $this->assertTrue($payments[3]->payee_code == 1332);
     $clients = Client::all();
     $this->assertTrue(count($clients) == 4);
     $payeePayments = PayeePayment::all();
     $this->assertTrue(count($payments) == 4);
     $deals = Deal::all();
     $this->assertTrue(count($deals) == 4);
     $streams = RoyaltyStream::all();
     $this->assertTrue(count($streams) == 4);
     $this->assertTrue($streams[0]->song_number == 33959);
     $this->assertTrue($streams[1]->song_number == 14402);
     $this->assertTrue($streams[2]->song_number == 12043);
     $this->assertTrue($streams[3]->song_number == 51311);
     $streamFiles = RoyaltyStreamFile::all();
     $this->assertTrue(count($streamFiles) == 4);
     $this->resetEvents();
 }
Ejemplo n.º 17
0
                                <h4 class="cf9">
                                <span class="fa-stack fa-lg">
                                    <i class="fa fa-circle fa-stack-2x"></i>
                                    <i class="fa fa-map-marker fa-stack-1x fa-inverse"></i>
                                </span>
                                <b>{{DB::table('outlets')->count()}}</b> Spa locations</h4>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="mb20 cf1 pa10 bgMain"><i class="fa fa-leaf"></i>  Featured services</h4>
                    </div>
                    <?php 
$featured_services = Deal::getFeaturedService();
?>
                    @foreach ($featured_services as $key => $deal)
                    <div class="col-sm-12">
                        <div class="thumbnail">
                            <img src="{{$deal->image_path}}" alt="...">
                            <div class="caption">
                                <h3 class="cfMain">{{$deal->title}}</h3>
                                <p class="mt5 mb5">From {{$deal->amount}} SGD</p>
                                <p><a href="/detail/{{$deal->id}}" class="btn btn-primary" role="button">Detail</a></p>
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
Ejemplo n.º 18
0
echo $model->valuationDate ?: 'N/A';
?>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label"><?php 
echo $form->controlLabel($model, 'dea_marketprice');
?>
</label>

		<div class="controls">
			<?php 
echo $form->textField($model, 'dea_marketprice', ['class' => 'input-xsmall', 'value' => Locale::formatCurrency($model->dea_marketprice, true, false)]);
?>
			<?php 
echo $form->dropDownList($model, 'dea_qualifier', Deal::getQualifiers(), ['class' => 'input-xsmall']);
?>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label"><?php 
echo $form->controlLabel($model, 'dea_commission');
?>
</label>

		<div class="controls">
			<?php 
echo $form->textField($model, 'dea_commission', ['class' => 'input-xsmall']);
?>
			<?php 
echo $form->dropDownList($model, 'dea_commissiontype', Util::enumItem($model, 'dea_commissiontype'), ['class' => 'input-xsmall']);
Ejemplo n.º 19
0
 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]);
 }
Ejemplo n.º 20
0
 * @var $form  AdminForm
 */
$form = $this->beginWidget('AdminForm', ['id' => 'custom-mailshot-form', 'htmlOptions' => array('enctype' => 'multipart/form-data')]);
$propTitle = $model->property->getShortAddressString(', ', true);
$price = Locale::formatPrice($model->dea_marketprice, $model->dea_type == 'Sales' ? false : true);
?>
<div class="row-fluid">
	<div class="span12">
		<fieldset>
			<div class="block-header">Send custom mailshot</div>
			<div class="clearfix"></div>
			<div class="control-group">
				<label class="control-label" for="">mailshot type</label>

				<div class="controls"><?php 
echo CHtml::dropDownList('mailshot[type]', 'new', Deal::getMailshotTypes());
?>
</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="">mailshot Text</label>

				<div class="controls"><?php 
echo CHtml::textArea('mailshot[body]', '', array('class' => 'input-xxlarge'));
?>
</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="">attachement</label>

				<div class="controls"><?php 
Ejemplo n.º 21
0
 /**
  * Queryes the groupon API for results
  * 
  * @param Deal|Divison|WebClient $type
  * 
  */
 public function query($type)
 {
     if (!$this->Gdriver instanceof APQ\Driver\GDriver) {
         throw new \Exception("Driver object for API connection not recognized.");
     }
     if ($this->getWebClient() !== null && $this->getWebClient()->getIP() !== null) {
         $this->Gdriver->addHeader("X-Forwarded-For", $this->getWebClient()->getIP());
     }
     $this->Gdriver->setUrl($type->getUrl());
     $this->Gdriver->connect();
     return $this->Gdriver->get();
 }
 /**
  * @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));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $validation = Validate::DealValidation(Input::all());
     if ($validation->fails()) {
         return Redirect::to('ofertas/create')->withErrors($validation)->withInput();
     } else {
         $deal = Deal::find($id);
         if ($deal->image != "") {
             unlink($deal->image);
         }
         $deal->title = Input::get('title');
         $deal->description = Input::get('description');
         $deal->from = Input::get('from');
         $deal->to = Input::get('to');
         $deal->price = Input::get('price');
         $destinationPath = 'img/deals/' . $deal->id . "/";
         $filename = $deal->id . "." . Input::file('image')->getClientOriginalExtension();
         Input::file('image')->move($destinationPath, $filename);
         $deal->image = $destinationPath . $filename;
         $deal->save();
         return Redirect::to('ofertas');
     }
 }
Ejemplo n.º 24
0
 public function testDealFromApiArray()
 {
     $d = new Deal();
     $data = json_decode(self::$VALID_TEST_JSON, true);
     $d->fromApiArray($data);
     $this->assertEquals($data['name'], $d->getName());
     $this->assertEquals($data['motivation']['title'], $d->getMotivationTitle());
     $this->assertEquals($data['motivation']['text'], $d->getMotivationText());
     $this->assertEquals($data['spread']['title'], $d->getSpreadTitle());
     $this->assertEquals($data['spread']['text'], $d->getSpreadText());
     $this->assertEquals($data['spread']['url'], $d->getSpreadUrl());
     $this->assertEquals($data['spread']['img'], $d->getSpreadImg());
     $this->assertEquals($data['spread']['tos'], $d->getSpreadTos());
     $this->assertEquals($data['coupon']['type'], $d->getCouponType());
     $this->assertEquals($data['coupon']['title'], $d->getCouponTitle());
     $this->assertEquals($data['coupon']['text'], $d->getCouponText());
     $this->assertEquals($data['coupon']['code'], $d->getCouponCode());
     $this->assertEquals($data['coupon']['url'], $d->getCouponUrl());
     $this->assertEquals($data['coupon']['webhook_url'], $d->getCouponWebhookUrl());
     $this->assertEquals($data['coupon']['redeem_url'], $d->getCouponRedeemUrl());
     $this->assertEquals($data['billing']['type'], $d->getBillingType());
     $this->assertEquals($data['billing']['target_quantity'], $d->getTargetQuantity());
 }
Ejemplo n.º 25
0
 public function updateInstructions()
 {
     foreach ($this->instructions as $instruction) {
         if ($instruction->statusInList(Deal::getActiveStatuses())) {
             $instruction->importFromProperty($this);
             $instruction->save(false);
         }
     }
 }
Ejemplo n.º 26
0
 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));
 }
 protected function createDeal($data, $name, $company_id, $payeeCode = null)
 {
     $dealData = ['status' => Deal::STATUS_UNREVIEWED, 'name' => $name, 'payee_code' => $payeeCode, 'etl_status' => Deal::ETL_STATUS_PROCESSING, 'company_id' => $company_id, 'percentage' => 100];
     isset($data['firstName']) && isset($data['lastName']) ? $dealData['writer_name'] = $data['firstName'] . ' ' . $data['lastName'] : null;
     isset($data['email']) ? $dealData['writer_email'] = $data['email'] : null;
     isset($data['phone']) ? $dealData['writer_phone'] = $data['phone'] : null;
     $deal = Deal::create($dealData);
     return $deal;
 }
Ejemplo n.º 28
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDeals()
 {
     return $this->hasMany(Deal::className(), ['user_id' => 'id']);
 }
Ejemplo n.º 29
0
 public function postUpdatedeal()
 {
     $id = Input::get('id');
     $user_id = Session::get('user_id');
     $update = Deal::find($id);
     $update->client_id = Input::get('client_id');
     $update->agency_id = Input::get('agency_id');
     $update->from_date = Input::get('from_date');
     $update->to_date = Input::get('to_date');
     $update->rate = Input::get('rate');
     $update->amount = Input::get('amount');
     $update->duration = Input::get('duration');
     $update->executive_id = Input::get('executive_id');
     $update->time_slot = Input::get('time_slot');
     $update->item_id = Input::get('item_id');
     $update->ro_number = Input::get('ro_number');
     $update->ro_date = Input::get('ro_date');
     $update->remark = Input::get('remark');
     $update->user_id = $user_id;
     $update->save();
     return Response::json($update);
 }
Ejemplo n.º 30
0
 /**
  * Remove the specified outlet from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroyDeal($id)
 {
     DealTransaction::where('deal_id', $id)->delete();
     Deal::destroy($id);
     return Redirect::to('admin/deals');
 }