コード例 #1
0
 /**
  * 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');
     }
 }
コード例 #2
0
ファイル: DealController.php プロジェクト: saifurrahman/dev
 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);
 }
コード例 #3
0
 protected function processDirectory($dir)
 {
     try {
         $path = $dir['path'];
         $dirName = substr($path, strrpos($path, '/') + 1);
         if ($this->processingEtlExists($dirName)) {
             $this->log($this->processingEtlKey($dirName) . " key exists, directory already processing");
             return;
         }
         $this->lockProcessingEtl($dirName);
         $this->log("locked folder with " . $this->processingEtlKey($dirName));
         if (!$this->doneExists($dirName)) {
             $this->log($this->doneEtlKey($dirName) . " not found directory not processable yet, removed key " . $this->processingEtlKey($dirName));
             //                $this->dropbox->delete($directory . "/.processing_etl");
             $this->deleteProcessingEtl($dirName);
             return;
         }
         $this->log("Processing directory {$path}");
         $dropboxMetadata = $this->dropbox->getMetadataWithChildren($path);
         $fileList = $dropboxMetadata['contents'];
         $this->log('Read data.json');
         $dataFile = $this->getDataFile($path);
         $dataJson = $this->dropboxReadFile($dataFile);
         $data = json_decode($dataJson, true);
         $this->log('check authorization');
         if (isset($data['payeeId'])) {
             $token = $data['payeeId'];
             $authorized = AuthorizationToken::findByToken($token, "User");
         } else {
             $token = isset($data['companyId']) ? $data['companyId'] : $data['publisherId'];
             $authorized = AuthorizationToken::findByToken($token, "Company");
         }
         if (empty($authorized)) {
             $this->log("authorization token failed");
             $this->deleteProcessingEtl($dirName);
             return;
         }
         if (isset($data['payeeId'])) {
             $payee = User::find($authorized->model_id);
             $companyId = $payee->company_id;
             $payeeCode = $payee->code;
         } else {
             $companyId = $authorized->model_id;
             $payeeCode = null;
         }
         $this->log("authorization succeeded");
         $publisherAdmins = User::publisherAdmins($companyId);
         $this->log('check credits');
         if (!Company::hasCredits($companyId)) {
             $this->log("no credits available");
             $this->deleteProcessingEtl($dirName);
             $this->sendEmailToPublisherAdminsNoCredits($publisherAdmins, $companyId);
             return;
         }
         $this->log("company has credits");
         if (true || !isset($data['dealId'])) {
             $this->log('No deal id found, creating deal');
             $dealName = isset($data["dealName"]) && !empty($data["dealName"]) ? $data["dealName"] : $dirName;
             $deal = $this->createDeal($data, $dealName, $companyId, $payeeCode);
             $data['dealId'] = $deal->id;
             $this->log("Will upload to {$dataFile}");
             $this->dropbox->uploadFileFromString($dataFile, \Dropbox\WriteMode::force(), json_encode($data));
         } else {
             $deal = Deal::find($data['dealId']);
         }
         $this->log('Deal id is ' . $deal->id);
         $statementList = $data['files'];
         foreach ($statementList as $filename => $metadata) {
             $this->processFile($filename, $metadata, $fileList, $deal, $path);
             //            break;
         }
         $deal->etl_status = 'processed';
         $deal->save();
         $decremented = Company::decrementCredits($companyId);
         $this->log("decrement credits " . $decremented);
         if (count($publisherAdmins)) {
             $this->sendEmailToPublisherAdmins($publisherAdmins, $deal);
             $this->log("email sent to publisher");
         } else {
             $this->log("no publisher admins found");
         }
         $moveTo = $this->getDropboxProcessedPath() . '/' . $dirName;
         $this->dropbox->move($path, $moveTo);
         $this->log("moved to {$moveTo}");
         $this->log("start executing rollups");
         RollupEvent::EXECUTE_ROLLUP_TABLES($deal->id);
         $this->log("end executing rollups");
         $this->deleteProcessingEtl($dirName);
         $this->log("folder unlocked");
     } catch (Dropbox\Exception $e) {
         $this->log('dropbox error: ' . get_class($e) . ' - ' . $e->getMessage() . " FILE " . $e->getFile() . " LINE " . $e->getLine());
         $this->deleteProcessingEtl($dirName);
         $this->log("folder unlocked");
         $this->sendErrorEmailToAdmin($dir, get_class($e) . ' - ' . $e->getMessage() . " FILE " . $e->getFile() . " LINE " . $e->getLine());
     } catch (Exception $e) {
         $this->log('something bad happened: ' . get_class($e) . ' - ' . $e->getMessage() . " FILE " . $e->getFile() . " LINE " . $e->getLine());
         $this->sendErrorEmailToAdmin($dir, get_class($e) . ' - ' . $e->getMessage() . " FILE " . $e->getFile() . " LINE " . $e->getLine());
     }
 }
コード例 #4
0
 /**
  * Show the form for editing the specified deal.
  *
  * @param  int  $id
  * @return Response
  */
 public function editDeal($id)
 {
     $title = 'Edit Deal';
     $deal = Deal::find($id);
     $services = Service::select(array('services.name', 'services.id'))->lists('name', 'id');
     return View::make('admin.deals.edit', compact('deal', 'services', 'title'));
 }
コード例 #5
0
ファイル: Deal.php プロジェクト: alternativex/Backend-app
 public static function apiSendAdviserContactEmail($id)
 {
     $deal = Deal::find($id);
     $user = User::apiUserByPayeeCode($deal->payee_code);
     Mail::send('emails.deal.adviser_contact_email', ['deal' => $deal, "user" => $user], function ($message) {
         $message->from('*****@*****.**')->to(Config::get("mail.advisers"))->subject('Royalty Analysis - Publisher Contact Request');
     });
     return ['success' => true];
 }
コード例 #6
0
ファイル: OutletsController.php プロジェクト: EricBui0512/FYP
 /**
  * Show the form for editing the specified service.
  *
  * @param  int  $id
  * @return Response
  */
 public function editDeal($id)
 {
     $deal = Deal::find($id);
     $services = Service::select(array('services.name', 'services.id'))->owner()->lists('name', 'id');
     $dealType = array(DealRepository::DEAL_TYPE_HOT_DEAL => DealRepository::DEAL_TYPE_HOT_DEAL, DealRepository::DEAL_TYPE_SERVICE => DealRepository::DEAL_TYPE_SERVICE);
     return View::make('site.deals.edit', compact('deal', 'services', 'dealType'));
 }