private function createFiles($quantity = 0)
 {
     for ($i = 1; $i <= $quantity; $i++) {
         $Voucher = new Voucher();
         $Voucher->storage();
     }
 }
 /**
  * loadCampaign function.
  *
  * @access public
  *
  * @param string $urn
  *
  * @return Campaign
  */
 public function loadCampaign($urn)
 {
     $campaign = $this->model->where('urn', '=', $urn)->first();
     if ($campaign) {
         return $campaign;
     }
     return false;
 }
 public static function generate($input)
 {
     $res = [];
     $plan = Plan::findOrFail($input['plan_id']);
     $voucher['expires_on'] = self::_makeExpiry($input['validity'], $input['validity_unit']);
     $voucher['created_at'] = time();
     $voucher['plan_name'] = $plan->name;
     $voucher['plan_type'] = $plan->plan_type;
     $voucher['sim_sessions'] = $plan->sim_sessions;
     $voucher['interim_updates'] = $plan->interim_updates;
     $voucher['price'] = $plan->price;
     $voucher['validity'] = $plan->validity;
     $voucher['validity_unit'] = $plan->validity_unit;
     $voucher['policy_type'] = $plan->policy_type;
     if ($plan->plan_type == 1) {
         //if limited
         $limit = $plan->limit->toArray();
         if ($plan->limit->aq_access == 1) {
             // $limit['aq_access'] = 1;
             $aq_policy = Policy::findOrFail($plan->limit->aq_policy);
             $limit['aq_policy'] = mikrotikRateLimit($aq_policy->toArray());
         }
         $voucher_limit = VoucherLimit::create($limit);
         $voucher['limit_id'] = $voucher_limit->id;
     }
     if ($plan->policy_type == 'Policy') {
         $policy = new VoucherPolicy(['bw_policy' => mikrotikRateLimit($plan->policy->toArray())]);
         $policy->save();
     } elseif ($plan->policy_type == 'PolicySchema') {
         $days = ['mo' => 'monday', 'tu' => 'tuesday', 'we' => 'wednesday', 'th' => 'thursday', 'fr' => 'friday', 'sa' => 'saturday', 'su' => 'sunday'];
         foreach ($days as $d => $day) {
             $tpl = $plan->policy->{$day}->toArray();
             $type = ['bw_policy', 'pr_policy', 'sec_policy'];
             foreach ($type as $t) {
                 if (!is_null($tpl[$t])) {
                     $policy = Policy::find($tpl[$t])->toArray();
                     $tpl[$t] = mikrotikRateLimit($policy);
                 }
             }
             $template = VoucherPolicySchemaTemplate::create($tpl);
             $schema[$d] = $template->id;
         }
         $policy = VoucherPolicySchema::create($schema);
     }
     $voucher['policy_id'] = $policy->id;
     for ($i = 0; $i < $input['count']; $i++) {
         $voucher['pin'] = self::generatePin();
         $voucher['expires_on'] = self::_makeExpiry($input['validity'], $input['validity_unit']);
         $v = new Voucher($voucher);
         if (!$v->save()) {
             return FALSE;
         }
         $res[] = $v->pin;
     }
     return $res;
 }
Esempio n. 4
0
 public function show($id)
 {
     $student = Issue::with('placements', 'placement', 'receivable.installments', 'educations', 'education', 'earnings', 'punishments', 'returnments', 'presences', 'points', 'retrievals', 'timelines', 'masteries')->find($id);
     $periods = Teach::with(array('presences' => function ($q) use($id) {
         $q->where('issue_id', '=', $id);
     }))->select(DB::raw('month(course_date) as months'), DB::raw('year(course_date) as years'))->groupBy(DB::raw('month(course_date)'))->get();
     $presences = array();
     foreach ($periods as $period) {
         $presences[] = array('month' => $period->months, 'year' => $period->years, 'presences' => $this->countPresences($id, $period->months, $period->years), 'presents' => $this->countPresents($id, $period->months, $period->years), 'absents' => $this->countAbsents($id, $period->months, $period->years), 'sicks' => $this->countSicks($id, $period->months, $period->years), 'permits' => $this->countPermits($id, $period->months, $period->years));
     }
     $points = array();
     foreach ($student->points as $point) {
         if ($point->pointable_type == 'Activity') {
             $points[] = array('date' => $point->pointable->agenda, 'event' => $point->pointable->name, 'point' => $point->point, 'lowest' => $this->getLowest($point->pointable_id), 'highest' => $this->getHighest($point->pointable_id));
         }
     }
     $handbooks = Handbook::where('project_id', '=', Auth::user()->curr_project_id)->where('generation_id', '=', $student->generation_id)->get();
     $courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get();
     $discounts = Discount::all();
     $promotions = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $vouchers = Voucher::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $charges = Charge::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $menu = 'student';
     return View::make('students.show', compact('student', 'handbooks', 'courses', 'discounts', 'promotions', 'vouchers', 'charges', 'presences', 'points', 'menu'));
 }
 private static function _generatePin()
 {
     $number = false;
     do {
         $number = mt_rand(1111111, 99999999999);
         $exists = Voucher::where('pin', '=', $number)->count();
     } while ($exists);
     return $number;
 }
Esempio n. 6
0
 public static function getTotalVoucherAmount($booking)
 {
     $total = 0.0;
     foreach ($booking->voucher as $voucher) {
         if ($voucher->val == 1) {
             $total += Voucher::getVoucherAmount($voucher);
         }
     }
     return $total;
 }
Esempio n. 7
0
 public static function getHotelVoucherAmount($voucher)
 {
     $voucherAmount = 0.0;
     $check_in = $voucher->check_in;
     $check_out = $voucher->check_out;
     foreach ($voucher->roomBooking as $roomBooking) {
         $voucherAmount += $roomBooking->unit_cost_price * $roomBooking->room_count * Voucher::getNights($check_in, $check_out)->days + $roomBooking->unit_supplement_price;
     }
     return $voucherAmount;
 }
Esempio n. 8
0
 public function destroy($id)
 {
     $voucher = Voucher::with('reductions')->find($id);
     if ($voucher->reductions->count() > 0) {
         Session::flash('message', 'Tidak bisa menghapus Voucher. Voucher ini telah digunakan!');
     } else {
         Voucher::destroy($id);
         Session::flash('message', 'Sukses menghapus voucher');
     }
 }
 public function actionSave()
 {
     if ($_POST) {
         $trans = Yii::app()->db->beginTransaction();
         try {
             $redeem = new Redeem();
             $autonumber = $redeem->autonumber();
             $table_length = $_POST['table_length'];
             $point = 0;
             $member_name = '';
             $voucher_list = array();
             if ($table_length < 1) {
                 throw new Exception('Rollback Table Length');
             }
             if (empty($_POST['id_member'])) {
                 throw new Exception('Rollback ID Member');
             }
             $redeem->id_redeem = $autonumber;
             $redeem->redeem_point = $_POST['redeem_point'];
             $redeem->username = Yii::app()->user->getId();
             $redeem->redeem_date = date('Y-m-d');
             $redeem->id_member = $_POST['id_member'];
             if (!$redeem->validate() or !$redeem->save()) {
                 throw new Exception('Rollback Redeem');
             }
             for ($i = 0; $i < $table_length; $i++) {
                 $detail_redeem = new DetailRedeem();
                 $detail_redeem->id_redeem = $autonumber;
                 $detail_redeem->id_voucher = $_POST['id_voucher_list'][$i];
                 $detail_redeem->voucher_number = $_POST['number_voucher_list'][$i];
                 // mendapatkan nama voucher dan jumlah voucher yang diredeem untuk dicetak distruk
                 $voucher = Voucher::model()->findByPk($_POST['id_voucher_list'][$i]);
                 $voucher_list[] = array($voucher->voucher_name, $_POST['number_voucher_list'][$i]);
                 if ($detail_redeem->validate() and $detail_redeem->save()) {
                     $member = Member::model()->findByPk($_POST['id_member']);
                     $member_name = $member->first_name . ' ' . $member->family_name;
                     $member->point -= $_POST['total_redeem_list'][$i];
                     if (!$member->update()) {
                         throw new Exception('Rollback Update Point Member');
                     }
                     $point = $member->point;
                 } else {
                     throw new Exception('Rollback Detail Redeem');
                 }
             }
             $trans->commit();
             $get_name = User::model()->findByPk(Yii::app()->user->getId());
             $dataRedeem = $this->renderPartial('_receipt', array('id_member' => $_POST['id_member'], 'member_name' => $member_name, 'point' => $point + $redeem->redeem_point, 'redeem_point' => $redeem->redeem_point, 'remaining' => $point, 'vouchers' => $voucher_list, 'name' => $get_name->name), true, false);
             echo CJSON::encode(array('message' => 'Transaction redeem point has been saved Successfully!', 'receipt' => $dataRedeem));
         } catch (CDbException $e) {
             $trans->rollback();
         }
     }
 }
Esempio n. 10
0
 public static function online($user_id, $plan_id)
 {
     $input = ['plan_id' => $plan_id, 'validity' => 1, 'validity_unit' => 'Day', 'count' => 1];
     try {
         DB::transaction(function () use($input, $user_id) {
             $pins = Voucher::generate($input);
             return self::now(current($pins), $user_id, 'online');
         });
     } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         Notification::error($e->getMessage());
     }
 }
Esempio n. 11
0
 public function make_new($type, $game)
 {
     $v = Voucher::create();
     do {
         $v->generate_code();
         $result = $this->get_by_field('code', $v->code);
     } while ($result);
     $v->type = $type;
     $v->game = $game;
     $v->active = True;
     $v->save();
     return $v;
 }
 public function create()
 {
     $menu = 'registration';
     $generations = Generation::all();
     $classifications = Classification::where('category', '=', 'Registration')->get();
     $locations = Location::where('id', '<>', Auth::user()->location_id)->get();
     $employees = Employee::all();
     $courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('availability', '=', 1)->where('active', '=', 1)->get();
     $discounts = Discount::all();
     $promotions = Promotion::all();
     $vouchers = Voucher::all();
     $charges = Charge::all();
     $partners = Partner::where('location_id', '=', Auth::user()->location_id)->get();
     return View::make('registrations.create', compact('classifications', 'locations', 'employees', 'generations', 'courses', 'charges', 'discounts', 'promotions', 'vouchers', 'partners', 'menu'));
 }
Esempio n. 13
0
 public static function getInvoiceAmount($booking)
 {
     $total = 0;
     /**
      *  Hotel Booking Amount
      */
     if (count($booking->voucher)) {
         foreach ($booking->voucher as $voucher) {
             $total += Voucher::getVoucherAmount($voucher);
         }
     }
     /**
      *  Transportation Bookings
      */
     return $total;
 }
Esempio n. 14
0
 public function getVendor($distribution_id)
 {
     $distribution = Distribution::model()->findByPk($distribution_id);
     if (!$distribution) {
         return 0;
     }
     $criteria = "(0";
     foreach ($distribution->subdistributions as $subdistribution) {
         foreach ($subdistribution->distributionVouchers as $distributionVoucher) {
             $criteria .= "," . $distributionVoucher->id;
         }
     }
     $criteria .= ")";
     $voucher = Voucher::model()->find("ben_id = " . $this->id . " and distribution_voucher_id in " . $criteria);
     if ($voucher->vendor_id == null) {
         return 0;
     }
     return $voucher->vendor_id;
 }
Esempio n. 15
0
 public function actionPrint($id)
 {
     $distributionVouchers = DistributionVoucher::model()->findAll("subdistribution_id = :subdistribution_id", array(":subdistribution_id" => $id));
     $criteria = new CDbCriteria();
     $criteria_string = "distribution_voucher_id in (0";
     foreach ($distributionVouchers as $voucher_type) {
         $criteria_string = $criteria_string . ", " . $voucher_type->id;
     }
     $criteria_string = $criteria_string . ")";
     $criteria->addCondition($criteria_string);
     $vouchers = Voucher::model()->findAll($criteria);
     Yii::import('application.controllers.VoucherController');
     $obj = new VoucherController("");
     $html = '';
     foreach ($vouchers as $voucher) {
         $html .= $obj->actionPrint($voucher->id);
     }
     return $html;
 }
 public function postPrint()
 {
     Session::reflash();
     $result = NULL;
     $tpl_id = Input::get('template', 0);
     $count = Input::get('count', 1);
     $type = Input::get('type');
     $voucher_ids = Session::get('vouchers', ['0']);
     $parser = new TemplateParser();
     $template = VoucherTemplate::find($tpl_id);
     switch ($type) {
         case 'prepaid_voucher':
             $vouchers = Voucher::variables($voucher_ids);
             break;
         case 'refill_coupon':
             $vouchers = refillcoupons::variables($voucher_ids);
             break;
         default:
             throw new Exception("Could not determine form type. Could not proceed.");
             break;
     }
     $i = 1;
     foreach ($vouchers as $voucher) {
         $parser->initData((array) $voucher);
         $result .= $parser->parseTemplateData($template->body);
         if ($i % $count == 0) {
             $result .= "<br />";
         } else {
             $result .= "&nbsp;";
         }
         $i++;
     }
     if ($i > 1) {
         $result .= "<br />" . Form::button('Print This Page', ['onclick' => 'window.print()', 'class' => 'btn btn-primary col-lg-offset-1']);
     } else {
         $result = "Please select atleast one voucher";
     }
     return View::make('admin.vouchers.print')->with('vouchers', $result);
 }
 public function showVouchersPage()
 {
     $voucher = new Voucher();
     $vouchers = Voucher::orderBy('id', 'ASC')->where('is_active', '=', 1)->where('finishes_at', '>=', new DateTime('today'))->paginate(10);
     return View::make('frontoffice.vouchers')->with('vouchers', $vouchers)->with('voucher', $voucher);
 }
Esempio n. 18
0
echo $form->textField($model, 'deleted_at');
?>
		<?php 
echo $form->error($model, 'deleted_at');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'value');
?>
		<?php 
echo $form->textField($model, 'value');
?>
		<?php 
echo $form->error($model, 'value');
?>
		</div><!-- row -->

		<label><?php 
echo GxHtml::encode($model->getRelationLabel('vouchers'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'vouchers', GxHtml::encodeEx(GxHtml::listDataEx(Voucher::model()->findAllAttributes(null, true)), false, true));
?>

<?php 
echo GxHtml::submitButton(Yii::t('app', 'Save'));
$this->endWidget();
?>
</div><!-- form -->
Esempio n. 19
0
 public static function inscricao()
 {
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Cache-Control: pre-check=0, post-check=0, max-age=0');
     header('Pragma: no-cache');
     if (!empty($_POST)) {
         $participante = new Participante();
         if (empty($_POST['nome'])) {
             $erro .= 'nr|';
         }
         if (empty($_POST['email'])) {
             $erro .= 'er|';
         }
         if (!preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\\._-]+@([a-zA-Z0-9\\._-]+\\.)[a-zA-Z-0-9]{2}/', $_POST['email']) && !empty($_POST['email'])) {
             $erro .= 'ei|';
         }
         if ($participante->count('email = \'' . $_POST['email'] . '\'') > 0 && !empty($_POST['email'])) {
             $erro .= 'ee|';
         }
         if (empty($_POST['telefone'])) {
             $erro .= 'tr|';
         }
         if (empty($_POST['data_nascimento'])) {
             $erro .= 'dnr|';
         }
         if (!empty($_POST['data_nascimento'])) {
             $data_nascimento = explode("/", $_POST['data_nascimento']);
             if ($data_nascimento[1] == 2 && $data_nascimento[0] > 29 || in_array($data_nascimento[1], array(4, 6, 9, 11)) && $data_nascimento[0] > 30 || $data_nascimento[0] > 31 || $data_nascimento[1] > 12 || $data_nascimento[2] . $data_nascimento[1] . $data_nascimento > date('Ymd')) {
                 $erro .= 'dni|';
             }
         }
         if (empty($_POST['sexo'])) {
             $erro .= 'sr|';
         }
         if (empty($_POST['cpf'])) {
             $erro .= 'cr|';
         }
         if (!preg_match('/\\d{3}[\\.]\\d{3}[\\.]\\d{3}[\\-]\\d{2}/', $_POST['cpf']) && !empty($_POST['cpf'])) {
             $erro .= 'ci|';
         }
         if ($participante->count('cpf = \'' . $_POST['cpf'] . '\'') > 0 && !empty($_POST['cpf'])) {
             $erro .= 'ce|';
         }
         if (!empty($_POST['cep']) && !preg_match('/\\d{5}[\\-]\\d{3}/', $_POST['cep'])) {
             $erro .= 'cei|';
         }
         if (!isset($_POST['estado']) || empty($_POST['estado'])) {
             $erro .= 'esr|';
         }
         if (!isset($_POST['cidade']) || empty($_POST['cidade'])) {
             $erro .= 'cir|';
         }
         if (!isset($_POST['bairro']) || empty($_POST['bairro'])) {
             $erro .= 'br|';
         }
         if (!isset($_POST['logradouro']) || empty($_POST['logradouro'])) {
             $erro .= 'lr|';
         }
         if (!isset($_POST['numero']) || empty($_POST['numero'])) {
             $erro .= 'nr|';
         }
         if (!empty($_POST['numero']) && !preg_match('/\\d+/', $_POST['numero'])) {
             $erro .= 'ni|';
         }
         if (!isset($_POST['instituicao']) || empty($_POST['instituicao'])) {
             $erro .= 'ir|';
         }
         if (!isset($_POST['area_atuacao']) || empty($_POST['area_atuacao'])) {
             $erro .= 'ar|';
         }
         if (!isset($_POST['profissao']) || empty($_POST['profissao'])) {
             $erro .= 'pr|';
         }
         if ($_POST['profissao'] == 770 && (!isset($_POST['outra_profissao']) || empty($_POST['outra_profissao']))) {
             $erro .= 'opr|';
         }
         if (!isset($_POST['grau_instrucao']) || empty($_POST['grau_instrucao'])) {
             $erro .= 'gir|';
         }
         if (!isset($_POST['tamanho_camisa']) || empty($_POST['tamanho_camisa'])) {
             $erro .= 'tcr|';
         }
         if (isset($_POST['voucher']) && !empty($_POST['voucher'])) {
             //TODO Voucher
             $voucher = new Voucher();
             $listaDeVouchers = $voucher->listar("hash LIKE '" . trim($_POST['voucher']) . "'");
             if (count($listaDeVouchers) <= 0) {
                 $erro .= 'vch|';
             }
             //Testa se ja foi usado
             $voucher2 = new Voucher();
             $listaDeVouchers2 = $voucher2->listar("hash LIKE '" . trim($_POST['voucher']) . "' AND usado = 0 ");
             if (count($listaDeVouchers2) <= 0) {
                 $erro .= 'vch2|';
             }
         }
         if (!empty($erro)) {
             $_SESSION['dados'] = $_POST;
             if (strpos($_SERVER['HTTP_REFERER'], '?') !== false) {
                 $caminho = explode("?", $_SERVER['HTTP_REFERER']);
                 $caminho = $caminho[0];
             } else {
                 $caminho = $_SERVER['HTTP_REFERER'];
             }
             header('Location: ' . Configuracao::$baseUrl . 'inscricao' . Configuracao::$extensaoPadrao . '?e=' . $erro);
             exit;
         }
         $participante->nome = trim($_POST['nome']);
         $participante->funcao = trim($_POST['funcao']);
         $participante->email = trim($_POST['email']);
         $participante->sexo = trim($_POST['sexo']);
         $participante->data_nascimento = trim($_POST['data_nascimento']);
         $participante->cpf = trim($_POST['cpf']);
         $participante->rg = trim($_POST['rg']);
         $participante->orgao_emissor = trim($_POST['orgao_emissor']);
         $participante->cep = trim($_POST['cep']);
         $participante->telefone = trim($_POST['telefone']);
         $participante->estado = $_POST['estado'];
         $participante->cidade = $_POST['cidade'];
         $participante->bairro = trim($_POST['bairro']);
         $participante->logradouro = trim($_POST['logradouro']);
         $participante->numero = trim($_POST['numero']);
         $participante->profissao = trim($_POST['profissao']);
         $participante->outra_profissao = trim($_POST['outra_profissao']);
         $participante->grau_instrucao = trim($_POST['grau_instrucao']);
         $participante->instituicao = trim($_POST['instituicao']);
         $participante->area_atuacao = trim($_POST['area_atuacao']);
         $participante->tamanho_camisa = trim($_POST['tamanho_camisa']);
         if (isset($_POST['voucher']) && !empty($_POST['voucher'])) {
             $participante->voucher = $_POST['voucher'];
         }
         /*
         TODO BOLETO POR WEBSERVICE
         */
         if ($participante->funcao == 'participante') {
             $cURL = curl_init('url do ws');
             curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
             $post = array('post' => array('nome' => $participante->nome, 'cpf' => $participante->cpf, 'cep' => $participante->cep, 'logradouro' => $participante->logradouro, 'num' => $participante->numero, 'bairro' => $participante->bairro, 'cidade' => $participante->getCidade()->nome, 'estado' => $participante->getEstado()->nome, 'complemento' => $participante->complemento, 'voucher' => @$listaDeVouchers[0]->desconto, 'email' => $participante->email), 1 => 1);
             curl_setopt($cURL, CURLOPT_POST, true);
             curl_setopt($cURL, CURLOPT_POSTFIELDS, http_build_query($post));
             $resposta = curl_exec($cURL);
             curl_close($cURL);
             $resposta = json_decode($resposta);
             $participante->nossonumero = $resposta->nossonumero;
         }
         if ($participante->salvar() && $participante->funcao == 'participante') {
             if (isset($_POST['voucher']) && !empty($_POST['voucher'])) {
                 $voucher3 = new Voucher();
                 $voucher3->selecionarPorId(@$listaDeVouchers[0]->id);
                 $voucher3->usado = 1;
                 $voucher3->salvar();
             }
             echo '<meta charset="UTF-8">';
             echo "<script>alert('Você cadastrou-se com sucesso!'); document.location.href='" . Configuracao::$baseUrl . 'confirmacaoCadastro' . Configuracao::$extensaoPadrao . '?nn=' . $participante->nossonumero . "';</script>";
             exit;
         } else {
             echo '<meta charset="UTF-8">';
             echo "<script>alert('Você cadastrou-se com sucesso!'); document.location.href='" . Configuracao::$baseUrl . 'confirmacaoCadastro' . Configuracao::$extensaoPadrao . "';</script>";
             exit;
         }
     }
     $listaFuncoes = Listas::getFuncao();
     $listaSexos = Listas::getSexo();
     $listaAreasAtuacao = Listas::getAreaAtuacao();
     $listaGrausIntrucao = Listas::getGrauInstrucao();
     $listaTamanhosCamisa = Listas::getTamanhoCamisa();
     $profissao = new Profissao();
     $listaProfissoes = $profissao->listar(null, 'nome');
     $estado = new Estado();
     $listaEstados = $estado->listar(null, 'nome');
     $texto = new Texto();
     $texto->selecionarPorId(10);
     self::$corpo = "inscricao";
     self::$variaveis = array('texto' => $texto, 'listaFuncoes' => $listaFuncoes, 'listaSexos' => $listaSexos, 'listaAreasAtuacao' => $listaAreasAtuacao, 'listaGrausInstrucao' => $listaGrausIntrucao, 'listaTamanhosCamisa' => $listaTamanhosCamisa, 'listaProfissoes' => $listaProfissoes, 'listaEstados' => $listaEstados);
     self::renderizar(self::$viewController);
 }
Esempio n. 20
0
 <br>
                        <?php 
    echo $roomBooking->room_count;
    ?>
 <br>
                        USD <?php 
    echo number_format($roomBooking->room_count * $roomBooking->unit_price * Voucher::getNights($voucher->check_in, $voucher->check_out)->days, 2);
    ?>
                    </td>

                </tr>
            <?php 
}
?>

            <tr style="background: lightgrey">
                <th>Total Amount</th>
                <td>USD <?php 
echo number_format(Voucher::getVoucherAmount($voucher), 2);
?>
</td>
            </tr>


        </table>
    </div>

</div>
<br/>
<?php 
require_once 'emailStructure/footer.php';
Esempio n. 21
0
<?php

$this->breadcrumbs = array(Voucher::label(2), Yii::t('app', 'Index'));
$this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . Voucher::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . Voucher::label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode(Voucher::label(2));
?>
</h1>

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
Esempio n. 22
0
 /**
  * Fifth sequence
  * Method untuk membuat autonumber
  */
 public function actionAutonumber()
 {
     $model = new Voucher();
     echo CJSON::encode(array($model->autonumber()));
 }
Esempio n. 23
0
Route::group(array('before' => 'auth|admin'), function () {
    Route::get('admin/panel', function () {
        return View::make('admin.admin');
    });
    Route::get('admin/voucher/new', 'AdminController@newVoucherView');
    Route::get('admin/voucher/edit/{voucher}', 'AdminController@editVoucherView');
    Route::post('admin/voucher_process', 'AdminController@create');
    Route::put('admin/voucher_process/{voucher}', 'AdminController@edit');
    // Route::get('admin/vouchers', 'AdminController@showVouchersPage');
    Route::get('admin/delete/{voucher}', 'AdminController@delteConfirmation');
    // Route::get('admin/firstPreview/{voucher}', 'AdminController@firstPreview');
    Route::delete('admin/voucher_process/{voucher}', 'AdminController@delete');
    Route::get('admin/reminder/{voucher}', 'AdminController@sendRemainders');
    Route::post('admin/update_note', function () {
        $id = intval($_GET['id']);
        $voucher = Voucher::find($id);
        $voucher->note = trim($_GET['value']);
        $voucher->save();
    });
    Route::get('admin/settings/', function () {
        return View::make('admin/settings');
    });
    //gestion usuarios
    Route::get('admin/users/', 'AdminController@users');
    Route::post('admin/user_process', 'AdminController@new_user');
    Route::put('admin/user_process/{user}', 'AdminController@edit_user');
    Route::delete('admin/user_process/{user}', 'AdminController@deleteUser');
    Route::get('admin/user/create', function () {
        $user = new User();
        return View::make('admin.user_form')->with('user', $user)->with('method', 'post');
    });
Esempio n. 24
0
 public function storeAllData()
 {
     $data = Session::pull('MyBookingData');
     if (Session::has('rate_box_details') || Session::has('transport_cart_box') || Session::has('predefined_transport') || Session::has('excursion_cart_details')) {
         if ($booking = Booking::create($data)) {
             $ehi_users = User::getEhiUsers();
             if (Auth::check()) {
                 //DB::table('booking_user')->insert(array('booking_id' => $booking->id, 'user_id' => $user->id));
                 if (Session::has('client-list')) {
                     $clients = Session::pull('client-list');
                     foreach ($clients as $client) {
                         $client['booking_id'] = $booking->id;
                         $client['gender'] === 'male' ? $client['gender'] = 1 : ($client['gender'] = 0);
                         Client::create($client);
                     }
                 }
                 $flight_data = [];
                 $flight_data['booking_id'] = $booking->id;
                 $flight_data['date'] = $data['date_arrival'];
                 $flight_data['time'] = $data['arrival_time'];
                 $flight_data['flight'] = $data['arrival_flight'];
                 $flight_data['flight_type'] = 1;
                 FlightDetail::create($flight_data);
                 //departure flight data
                 $flight_data['date'] = $data['date_departure'];
                 $flight_data['time'] = $data['departure_time'];
                 $flight_data['flight'] = $data['departure_flight'];
                 $flight_data['flight_type'] = 0;
                 FlightDetail::create($flight_data);
             }
             /**
              *  transport - custom trips
              */
             $a = 0;
             if (Session::has('transport_cart_box')) {
                 $custom_trips = Session::pull('transport_cart_box');
                 $a++;
                 $x = 1;
                 foreach ($custom_trips as $custom_trip) {
                     $custom_trip['from'] = date('Y-m-d H:i', strtotime($custom_trip['pick_up_date'] . ' ' . $custom_trip['pick_up_time_hour'] . ':' . $custom_trip['pick_up_time_minutes']));
                     $custom_trip['to'] = date('Y-m-d H:i', strtotime($custom_trip['drop_off_date'] . ' ' . $custom_trip['drop_off_time_hour'] . ':' . $custom_trip['drop_off_time_minutes']));
                     $custom_trip['reference_number'] = 'TR' . ($booking->reference_number * 1000 + $x++);
                     $custom_trip['booking_id'] = $booking->id;
                     $custom_trip['locations'] = $custom_trip['destination_1'] . ',' . $custom_trip['destination_2'] or '' . ',' . $custom_trip['destination_3'];
                     $custom_trip['amount'] = rand(100, 200);
                     CustomTrip::create($custom_trip);
                 }
             }
             /**
              *  predefined package bookings
              */
             if (Session::has('predefined_transport')) {
                 $a++;
                 $predefined_packages = Session::pull('predefined_transport');
                 foreach ($predefined_packages as $predefined_package) {
                     $package = [];
                     $package['transport_package_id'] = $predefined_package['predefine_id'];
                     $package['booking_id'] = $booking->id;
                     $package['pick_up_date_time'] = $predefined_package['check_in_date'];
                     $package['amount'] = TransportPackage::find($predefined_package['predefine_id'])->rate;
                     PredefinedTrip::create($package);
                 }
             }
             /**
              * Send Transportation Email to All EHI users
              */
             $pdf = PDF::loadView('emails/transport', array('booking' => $booking));
             $pdf->save('public/temp-files/transport' . $booking->id . '.pdf');
             //                if ($a > 0) {
             //                    Mail::send('emails/transport-mail', array(
             //                        'booking' => Booking::find($booking->id)
             //                    ), function ($message) use ($booking, $ehi_users) {
             //                        $message->attach('public/temp-files/transport.pdf')
             //                            ->subject('New Transfer : ' . $booking->reference_number)
             //                            ->from('*****@*****.**', 'SriLankaHotels.Travel')
             //                            ->bcc('*****@*****.**');
             //                        if (!empty($ehi_users))
             //                            foreach ($ehi_users as $ehi_user) {
             //                                $message->to($ehi_user->email, $ehi_user->first_name);
             //                            }
             //                    });
             //                }
             /**
              * Excursions
              */
             if (Session::has('excursion_cart_details')) {
                 $excursions = Session::pull('excursion_cart_details');
                 $x = 1;
                 foreach ($excursions as $excursion) {
                     $excursionBooking = ExcursionRate::with(array('city', 'excursion', 'excursionTransportType'))->where('city_id', $excursion['city_id'])->where('excursion_transport_type_id', $excursion['excursion_transport_type'])->where('excursion_id', $excursion['excursion'])->first();
                     $excursionBookingData = array('booking_id' => $booking->id, 'city_id' => $excursionBooking->city_id, 'excursion_transport_type_id' => $excursionBooking->excursion_transport_type_id, 'excursion_id' => $excursionBooking->excursion_id, 'unit_price' => $excursionBooking->rate, 'pax' => $excursion['excursion_pax'], 'date' => $excursion['excursion_date'], 'reference_number' => 'EX' . ($booking->reference_number * 1000 + $x++));
                     ExcursionBooking::create($excursionBookingData);
                 }
                 $pdf = PDF::loadView('emails/excursion', array('booking' => $booking));
                 $pdf->save('public/temp-files/excursions.pdf');
                 //                    Mail::send('emails/excursion-mail', array(
                 //                        'booking' => $booking
                 //                    ), function ($message) use ($booking, $ehi_users) {
                 //                        $message->attach('public/temp-files/excursions.pdf')
                 //                            ->subject('New Excursions : ' . $booking->reference_number)
                 //                            ->from('*****@*****.**', 'SriLankaHotels.Travel');
                 //
                 //                        $message->to('*****@*****.**', 'Excursions');
                 //                        $message->bcc('*****@*****.**', 'Admin');
                 //                        if (!empty($ehi_users))
                 //                            foreach ($ehi_users as $ehi_user) {
                 //                                $message->to($ehi_user->email, $ehi_user->first_name);
                 //                            }
                 //                    });
             }
             /**
              *  hotel bookings
              */
             if (Session::has('rate_box_details')) {
                 $bookings = Session::pull('rate_box_details');
                 $vouchers = Voucher::arrangeHotelBookingsVoucherwise($bookings, $booking->id);
                 foreach ($vouchers as $voucher) {
                     $created_voucher = Voucher::create($voucher);
                     for ($c = 0; $c < count($voucher) - 6; $c++) {
                         $voucher[$c]['voucher_id'] = $created_voucher->id;
                         $RoomBooking = RoomBooking::create($voucher[$c]);
                     }
                     // voucher
                     $pdf = PDF::loadView('emails/voucher', array('voucher' => $created_voucher));
                     $pdf->save('public/temp-files/voucher' . $created_voucher->id . '.pdf');
                     //                        $hotel_users = DB::table('users')->leftJoin('hotel_user', 'users.id', '=', 'hotel_user.user_id')
                     //                            ->where('hotel_user.hotel_id', $created_voucher->hotel_id)
                     //                            ->get();
                     //
                     //                        Mail::send('emails/voucher-mail', array(
                     //                            'voucher' => Voucher::find($created_voucher->id)
                     //                        ), function ($message) use ($booking, $hotel_users,$created_voucher) {
                     //                            $message->attach('public/temp-files/voucher'.$created_voucher->id.'.pdf')
                     //                                ->subject('Booking Voucher : ' . $booking->reference_number)
                     //                                ->from('*****@*****.**', 'SriLankaHotels.Travel')
                     //                                ->bcc('*****@*****.**', 'SriLankaHotels.Travel');
                     //                            if (!empty($hotel_users))
                     //                                foreach ($hotel_users as $hotel_user) {
                     //                                    $message->to($hotel_user->email, $hotel_user->first_name);
                     //                                }
                     //                        });
                 }
             }
             //Booking details
             //                $pdf = PDF::loadView('emails/booking', array('booking' => $booking));
             //                $pdf->save('public/temp-files/booking'.$booking->id.'.pdf');
             //
             $ehi_users = User::getEhiUsers();
             //
             $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
             //
             //                Mail::send('emails/booking-mail', array(
             //                    'booking' => Booking::getBookingData($booking->id)
             //                ), function ($message) use ($booking, $emails, $ehi_users) {
             //                    $message->attach('public/temp-files/booking'.$booking->id.'.pdf')
             //                        ->subject('New Booking: ' . $booking->reference_number)
             //                        ->from('*****@*****.**', 'SriLankaHotels.Travel')
             //                        ->bcc('*****@*****.**', 'Admin');
             //                    foreach ($emails as $emailaddress) {
             //                        $message->to($emailaddress, 'Admin');
             //                    }
             //
             //                    if (!empty($ehi_users)) {
             //                        foreach ($ehi_users as $ehi_user) {
             //                            $message->to($ehi_user->email, $ehi_user->first_name);
             //                        }
             //                    }
             //                });
             Invoice::create(array('booking_id' => $booking->id, 'amount' => Booking::getTotalBookingAmount($booking), 'count' => 1));
             //Invoice
             $pdf = PDF::loadView('emails/invoice', array('booking' => $booking));
             $pdf->save('public/temp-files/invoice' . $booking->id . '.pdf');
             $pdf = PDF::loadView('emails/service-voucher', array('booking' => $booking));
             $pdf->save('public/temp-files/service-voucher.pdf');
             //                if ($user = $booking->user) {
             //                    Mail::send('emails/invoice-mail', array(
             //                        'booking' => Booking::getBookingData($booking->id)
             //                    ), function ($message) use ($user, $booking, $emails) {
             //                        $message->subject('Booking Invoice : ' . $booking->reference_number)
             //                            ->attach('public/temp-files/invoice'.$booking->id.'.pdf');
             //                        $message->to($user->email, $user->first_name . ' ' . $user->last_name);
             //                        $message->to('*****@*****.**', 'Accounts');
             //                        if (!empty($ehi_users)) {
             //                            foreach ($ehi_users as $ehi_user) {
             //                                $message->to($ehi_user->email, $ehi_user->first_name);
             //                            }
             //                        }
             //
             //                    });
             //
             //                } else {
             //
             //                    Mail::send('emails/invoice-mail', array(
             //                        'booking' => Booking::getBookingData($booking->id)
             //                    ), function ($message) use ($booking, $emails) {
             //                        $message->to($booking->email, $booking->name)
             //                            ->subject('Booking Created : ' . $booking->reference_number)
             //                            ->attach('public/temp-files/invoice'.$booking->id.'.pdf');
             //                        $message->to('*****@*****.**', 'Accounts');
             //                        if (!empty($ehi_users)) {
             //                            foreach ($ehi_users as $ehi_user) {
             //                                $message->to($ehi_user->email, $ehi_user->first_name);
             //                            }
             //                        }
             //                    });
             //                }
             if (!Auth::check()) {
                 Session::flash('global', 'Emails have been sent to the Respective parties');
                 return View::make('pages.message');
             }
         }
         return $booking;
     } else {
         return Redirect::back();
     }
     return Redirect::route('bookings.index');
 }
Esempio n. 25
0
 public static function CreateReceiptVoucher($receipt)
 {
     $rcpt = new Voucher($receipt->id, $receipt->transactionType->name, $receipt->transactionId, $receipt->amount->amount, $receipt->description, $receipt->date, $receipt->stamp);
     $rcpt->persist();
     $rcpt->setClient($receipt->clientId);
     return $rcpt;
 }
Esempio n. 26
0
 public function cancelVoucher($voucherid)
 {
     $percentage_charged = 0;
     $voucher = Voucher::findOrFail($voucherid);
     $daysToBooking = Voucher::getDaysToBooking($voucher)->days;
     $cancellation_policies = CancellationPolicy::where('hotel_id', $voucher->hotel_id)->get();
     foreach ($cancellation_policies as $policy) {
         if ($daysToBooking >= $policy->from && $daysToBooking <= $policy->to) {
             $percentage_charged = $policy->percentage_charged;
             break;
         } else {
             if (empty($policy->to)) {
                 $percentage_charged = $policy->percentage_charged;
                 break;
             }
         }
     }
     $bookingAmount = Voucher::getVoucherAmount($voucher);
     $cancellation_amount = $bookingAmount * $percentage_charged * 0.01;
     $voucher->val = 0;
     $voucher->cancellation_amount = $cancellation_amount;
     $voucher->save();
     $agent_user = $voucher->booking->user;
     $pdf = PDF::loadView('emails/cancellation-voucher', array('voucher' => $voucher));
     $pdf->save(public_path() . '/temp-files/cancellation-voucher.pdf');
     $hotel = Hotel::findOrFail($voucher->hotel_id);
     $hotel_users = $hotel->user;
     Mail::send('emails/cancellation-voucher-mail', array('voucher' => $voucher), function ($message) use($voucher, $agent_user, $hotel_users) {
         $message->attach(public_path() . '/temp-files/cancellation-voucher.pdf')->subject('Cancellation Voucher :' . $voucher->reference_number)->from('*****@*****.**');
         if (!empty($hotel_users)) {
             foreach ($hotel_users as $hotel_user) {
                 $message->to($hotel_user->email, $hotel_user->first_name);
             }
         }
         if (!empty($agent_user)) {
             $message->to($agent_user->email, $agent_user->first_name);
         }
     });
     Booking::getTotalBookingAmount($voucher->booking);
     return Redirect::back();
 }
 public function getActiveServices($user_id)
 {
     $profile = Subscriber::findOrFail($user_id);
     $plan = Subscriber::getActiveServices($profile);
     $framedIP = SubnetIP::where('user_id', $user_id)->first();
     $framedRoute = UserRoute::where('user_id', $user_id)->first();
     switch ($profile->plan_type) {
         case FREE_PLAN:
         case PREPAID_PLAN:
             $rc_history = Voucher::where('user_id', $user_id)->leftJoin('voucher_limits as l', 'l.id', '=', 'limit_id')->paginate(5);
             return View::make("admin.accounts.services")->with('profile', $profile)->with('rc_history', $rc_history)->with('plan', $plan)->with('framedIP', $framedIP)->with('framedRoute', $framedRoute);
             break;
         case ADVANCEPAID_PLAN:
             $rproducts = APRecurringProduct::where('user_id', $profile->id)->get();
             $nrproducts = APNonRecurringProduct::where('user_id', $profile->id)->get();
             return View::make('admin.accounts.services-ap2')->with('profile', $profile)->with('plan', $plan)->with('framedIP', $framedIP)->with('framedRoute', $framedRoute)->with('rproducts', $rproducts)->with('nrproducts', $nrproducts);
             break;
     }
 }
echo $voucher->check_in;
?>
</td>
                </tr>
                <tr>
                    <th>Checkout</th>
                    <td>: <?php 
echo $voucher->check_out;
?>
</td>
                </tr>
                <tr>
                    <th>#Nights</th>
                    <td>
                        : <?php 
echo Voucher::getNights($voucher->check_out, $voucher->check_in)->days;
?>
                    </td>
                </tr>
                <tr>
                    <th>Rooms</th>
                    <td>
                        <?php 
foreach ($voucher->roomBooking as $roomBooking) {
    ?>
                           : <?php 
    echo $roomBooking->room_count . ' ' . $roomBooking->roomSpecification->room_specification . ' ' . $roomBooking->roomType->room_type . 's on ' . $roomBooking->mealBasis->meal_basis . ' basis';
    ?>
<br>
                        <?php 
}
Esempio n. 29
0
 public static function excluir()
 {
     $voucher = new Voucher();
     $voucher->selecionarPorId($_POST['id']);
     $voucher->excluir();
 }
Esempio n. 30
0
 public function loadReductions($what)
 {
     switch ($what) {
         case 'Promotion':
             $responses = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
         case 'Voucher':
             $responses = Voucher::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
         case 'Discount':
             $responses = Discount::all();
             break;
         case 'Charge':
             $responses = Charge::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
         default:
             $responses = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
     }
     return $responses;
 }