function actionModify()
 {
     $id = (int) $this->_context->get('id');
     $rs = Account::find('user_id = ?', $id)->getOne();
     if (!$rs->id()) {
         return $this->msg($tip = '参数错误', url('manage::account'));
     }
     $form = Form_Common::createForm('', 'manage/profile');
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         $post = $form->values();
         $user_mail = $post['user_mail'];
         $user_pass = $post['user_pass'];
         $is_locked = $post['is_locked'] ? '1' : '0';
         #dump($post);
         if ($user_pass) {
             $user_pass = sha1(md5('sike' . $post['user_pass'] . Q::ini('appini/secret_key')));
             $rs->user_pass;
         }
         $rs->user_mail = $user_mail;
         $rs->is_locked = $is_locked;
         $rs->save();
         return $this->msg($tip = '修改成功', url('manage::account/modify', array('id' => $id)));
     }
     $form->import($rs->toArray());
     $form->element('user_pass')->value = '';
     $form->element('is_locked')->checked = $rs->is_locked;
     #dump($form->element('is_locked'));
     $this->_view['form'] = $form;
     $this->_view['rs'] = $rs;
     $order = Order::find('user_id = ?', $id)->order('created DESC')->getAll();
     $this->_view['order'] = $order;
     $this->_view['_UDI'] = 'manage::account/index';
 }
 function get_account(){
     if($this->user_id){
         return Account::find($this->user_id);
     } else {
         return new Account(array('username' => 'GUEST', 'email'=>'*****@*****.**'),true);
     }
 }
Beispiel #3
0
 public function action_delete($id)
 {
     if (Session::has('id')) {
         $account = Account::find(Session::get('id'));
         $location = Location::find($id);
         $owner = Account::find($location->account_id);
         if ($account->id == $owner->id) {
             $listings = Listing::where_location_id($location->id);
             // foreach($listings as $listing)
             // {
             // 	$images = Image::where_listing_id($listing->id);
             // 	foreach($images as $image)
             // 	{
             // 		$image->delete();
             // 	}
             // 	$listing->delete();
             // }
             $location->delete();
             return Redirect::to('/account/myLocations/');
         } else {
             return Redirect::to('/');
         }
     } else {
         return Redirect::to('/');
     }
 }
Beispiel #4
0
 private function createPayment($invitation, $ref, $payerId = null)
 {
     $invoice = $invitation->invoice;
     $accountGateway = $invoice->client->account->account_gateways[0];
     if ($invoice->account->account_key == NINJA_ACCOUNT_KEY) {
         $account = Account::find($invoice->client->public_id);
         $account->pro_plan_paid = date_create()->format('Y-m-d');
         $account->save();
     }
     if ($invoice->is_quote) {
         $invoice = $this->invoiceRepo->cloneInvoice($invoice, $invoice->id);
     }
     $payment = Payment::createNew($invitation);
     $payment->invitation_id = $invitation->id;
     $payment->account_gateway_id = $accountGateway->id;
     $payment->invoice_id = $invoice->id;
     $payment->amount = $invoice->amount;
     $payment->client_id = $invoice->client_id;
     $payment->contact_id = $invitation->contact_id;
     $payment->transaction_reference = $ref;
     $payment->payment_date = date_create()->format('Y-m-d');
     if ($payerId) {
         $payment->payer_id = $payerId;
     }
     $payment->save();
     Event::fire('invoice.paid', $payment);
     return $payment;
 }
 function create($params){
     if(isset($params['partner']) && !empty($params['partner'])){
         $partner_name_or_id = $params['partner'];
         if(is_numeric($partner_name_or_id)){
             $partner = Account::find($partner_name_or_id);
         } else {
             $partner = Account::find()->where(array('username' => $partner_name_or_id))->first();
         }
         
         if(isset($params['temp'])){
             $params['until'] = mktime(
                     $params['hours_select'], 
                     $params['minute_select'],
                     0, 
                     $params['month_select'], 
                     $params['day_select'], 
                     $params['year_select']
                     );
         }
         
         if($partner){
             $params['partner_id'] = $partner->id;
             if(AccountPartner::create($params, $accpartner)){
                 $this->render_ajax('success', 'Partner created');
                 Event::trigger(Event::TYPE_ACCOUNT_PARTNER_ADD, User::$current, $partner);
             } else {
                 $this->render_ajax('error', 'Creation failed with ' . $accpartner->errors[0]);
             }
         } else {
             $this->render_ajax('error', 'Partner-Account not found!');
         }
     } else {
         $this->render_ajax('error', 'No Partner-ID or -Name!');
     }
 }
Beispiel #6
0
 public function __construct()
 {
     // Asset::add('jquery.dropdown.css', 'css/jquery.dropdown.css');
     Asset::add('bootstrap', 'css/bootstrap.min.css');
     Asset::add('bootstrap-responsive', 'css/bootstrap-responsive.css');
     Asset::add('common', 'css/common.css');
     // Asset::add('style', 'css/style.css');
     Asset::add('fontawsome', 'css/fontawesome.css');
     Asset::add('flickcss', 'css/flick/jquery-ui-1.10.2.custom.css');
     Asset::add('jquery', 'js/jquery-1.9.1.js');
     Asset::add('jquery-migrate-1.1.1.js', 'js/jquery-migrate-1.1.1.js');
     Asset::add('bootstrap-js', 'js/bootstrap.js');
     Asset::add('jqueryui', 'js/jquery-ui-1.10.2.custom.min.js');
     Asset::add('jquery.tablesorter.js', 'js/jquery.tablesorter.js');
     Asset::add('jquery.tablesorter.pager.js', 'js/jquery.tablesorter.pager.js');
     // $files = glob("public/css/pikachoose/*.css", GLOB_BRACE);
     // foreach($files as $file)
     // {
     // 	Asset::add($file, substr($file, 7));
     // }
     if (Session::has('id') && Auth::check()) {
         $account = Account::find(Session::get('id'));
         if ($account->admin == 1) {
             Session::put('admin', '1');
         } else {
             Session::put('admin', '0');
         }
         if ($account->blocked == 1) {
             Session::put('alert', "Your account has been banned. Please contact the admin for more details");
             Session::forget('id');
             Auth::logout();
         } else {
         }
     }
 }
 public function update()
 {
     $param = Input::all();
     $emp_id = Employee::where('ssn', '=', $param['ssn'])->pluck('id');
     $user = Account::find($param['id']);
     $res = $user->edit(array('username' => $param['username'], 'password' => $param['password'], 'emp' => $emp_id, 'role' => $param['role']));
     return Response::json(array('valid' => $res));
 }
Beispiel #8
0
 public function action_delete()
 {
     if (Input::has('tag_id') && Auth::check() && Session::has('id')) {
         $account = Account::find(Session::get('id'));
         $wishlistitem = WishlistItem::find(Input::get('tag_id'));
         $wishlistitem->delete();
     }
 }
Beispiel #9
0
 protected function _before_execute()
 {
     parent::_before_execute();
     $this->_user = Account::find('user_id = ?', $this->_user_id)->getOne();
     if (!$this->_user->id()) {
         return $this->msg('请先登陆', url('default::default/signin'));
     }
 }
Beispiel #10
0
 /**
  * Tests that a single account may be located by id.
  *
  * @return void
  */
 public function testFindSingleAccount()
 {
     $accounts = $this->createAccounts(3);
     $response = $this->call('GET', "/account/{$accounts[1]->id}");
     $expectedResponse = Account::find($accounts[1]->id)->toJson();
     $this->cleanUp();
     $this->assertEquals($expectedResponse, $response->getContent());
 }
Beispiel #11
0
 protected function _before_execute()
 {
     parent::_before_execute();
     $this->_user = Account::find('user_id = ?', $this->_user_id)->getOne();
     if (!in_array($this->_user->user_mail, Q::ini('appini/managers'))) {
         return $this->msg('请先登陆', url('default::default/signin'));
     }
 }
Beispiel #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     if (Auth::user()->is_admin) {
         $branches = Account::find(Auth::user()->account_id)->branches;
         return View::make('sucursales.index')->with('sucursales', $branches);
     }
     return Redirect::to('/inicio');
 }
Beispiel #13
0
 public function dashboard()
 {
     $sucursales = Branch::where('account_id', Auth::user()->account_id)->get();
     $usuarios = Account::find(Auth::user()->account_id)->users;
     $clientes = Account::find(Auth::user()->account_id)->clients;
     $productos = Account::find(Auth::user()->account_id)->products;
     $informacionCuenta = array('sucursales' => sizeof($sucursales), 'usuarios' => sizeof($usuarios), 'clientes' => sizeof($clientes), 'productos' => sizeof($productos));
     // return Response::json($informacionCuenta);
     return View::make('cuentas.dashboard')->with('cuenta', $informacionCuenta);
 }
    function index($params){
        /*if(isset($params['id']) && $params['id'] == ''){
            $this->render_error(404);
            return;
        }*/
        $from = time();
        $to = time();

        if(!empty($params['bannedby']) && !is_numeric($params['bannedby'])){
            $bannedby = Account::find()->where(array('username' => $params['bannedby']))->first();
            if(is_object($bannedby))
                $params['bannedby'] = $bannedby->id;
        }

        $bans = AccountBan::find()->where($params)->order('bandate DESC');

        if(isset($params['page'])) $bans->page($params['page']);

        if(empty($params['render_type']))
            $params['render_type'] = 'html';

        if(isset($params['filter_time']) && $params['filter_time'] == '1'){
            $from = mktime(
                $params['from_hours_select'],
                $params['from_minute_select'],
                0,
                $params['from_month_select'],
                $params['from_day_select'],
                $params['from_year_select']
            );
            $to = mktime(
                $params['to_hours_select'],
                $params['to_minute_select'],
                0,
                $params['to_month_select'],
                $params['to_day_select'],
                $params['to_year_select']
            );

            $bans->where(array("bandate >= :from AND bandate <= :to", 'from' => $from, 'to' => $to));
        }

        $data = array(
            'from' => $from,
            'to' => $to,
            'bans' => $bans->all(),
            'bans_count' => $bans->count(),
        );
        
        if(isset($params['partial'])){
            $this->render_partial('shared/bans', $data);
        } else {
            $this->render($data, $params['render_type']);
        }
    }
 public function demo()
 {
     $demoAccountId = Utils::getDemoAccountId();
     if (!$demoAccountId) {
         return Redirect::to('/');
     }
     $account = Account::find($demoAccountId);
     $user = $account->users()->first();
     Auth::login($user, true);
     return Redirect::to('invoices/create');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Palette $palette)
 {
     $input = array_except(Input::all(), '_method');
     $input['user_id'] = Auth::user()->id;
     $validation = Validator::make($input, Palette::$rules);
     if ($validation->passes() && Account::find($input['account_id'])->isMember(Auth::user())) {
         $palette->update($input);
         return Redirect::route($this->namespace . '.show', $palette->id);
     }
     return Redirect::back()->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
Beispiel #17
0
 public function CRUDTransaction($event)
 {
     if (!defined('LESSEVENTS')) {
         $account = Account::find($event->account_id);
         if ($account) {
             $account->balancedatapoints()->where('date', '>=', $event->date)->delete();
         }
         // also delete other stuff?
         $this->flushCache();
     }
 }
Beispiel #18
0
 public function action_delete()
 {
     if (Session::has('id') && Auth::check() && Input::has('file') && Input::has('listing_id')) {
         $account = Account::find(Session::get('id'));
         $listing = Listing::find(Input::get('listing_id'));
         $location = Location::find($listing->location_id);
         if ($account->id == $location->account_id) {
             unlink(Input::get('file'));
         } else {
             die("Image does not belogn to user");
         }
     }
 }
Beispiel #19
0
 /**
  * @expectedException     InvalidArgumentException
  */
 public function testFindThrowsAnRuntimeExceptionWithInvalidId()
 {
     // mock result from Adapter#select, empty array (not found)
     $mockResult = array();
     // our mock adapter
     $adapter = $this->adapterMock;
     // prepare out mock to return an empty array on call
     $adapter->expects($this->once())->method('select')->will($this->returnValue($mockResult));
     // perform the test
     $accountsTable = new Account($adapter);
     // getInstance doesn't work well in testing
     $accountsTable->find(1);
 }
 function create($params) {
     if(empty($params['title'])){
        $this->render_ajax('error', 'Title missing');
     } else {
         if(!isset($params['content'])){
             $params['content'] = '';
         }
         $params['created_at'] = '#NOW';
         if(Comment::create($params, $obj)){
             $account = Account::find()->where(array('id' => $params['account_id']))->first();
             Event::trigger(Event::TYPE_ACCOUNT_COMMENT, User::$current->account, $account, $account->username);
             $this->render_ajax('success', 'Comment Created');
         } else {
             $this->render_ajax('error','Error! ' . $obj->errors[0]);
         }
         
     }
 }
Beispiel #21
0
 public function delete_temporal()
 {
     $input = Input::All();
     $temporal_id = $input["id"];
     $email = $input["email"];
     $success = true;
     try {
         $account = Account::find($temporal_id);
         if ($account->isTemporal()) {
             $account->delete();
             $response = "Se ha eliminado correctamente la cuenta temporal: " . $email;
         } else {
             $response = "La cuenta a borrar no es una cuenta temporal.";
         }
     } catch (ModelNotFoundException $ex) {
         $success = false;
         $response = "Cuenta temporal no encontrada. Error - " . $ex->getMessage();
     }
     return Response::json(array("success" => $success, "response" => $response));
 }
Beispiel #22
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $cuenta = Account::find(Auth::user()->account_id);
     // $branch = DB::table('branches')->where('account_id',Auth::user()->account_id)->where('id','=',Auth::user()->branch_id)->first();
     // $user->branch = $branch->name;
     // $branches =$cuenta->branches;
     if (Auth::user()->is_admin) {
         $branches = Account::find(Auth::user()->account_id)->branches;
         // $sucursales = Branch::find(Auth::user()->account_id);
         $sucursales = array();
         foreach ($branches as $branch) {
             # code...
             $sucursales[] = array('branch_id' => $branch->id, 'name' => $branch->name);
         }
         // return View::make('users.selectBranch')->with('sucursales',$sucursales);
         // return Response::json($sucursales);
     } else {
         $sucursales = UserBranch::getSucursales(Auth::user()->id);
     }
     // return $branches;
     // $categories = DB::table('categories')->where('account_id',Auth::user()->account_id)->get(array('name'));
     $categories = $cuenta->categories;
     // return $categories;
     $cats = $categories;
     $categories2 = $cuenta->categories;
     // $categories2 = DB::table('categories')->where('account_id',Auth::user()->account_id)->get();
     $products2 = $cuenta->products;
     // $products2 = DB::table('products')->where('account_id','=',Auth::user()->account_id)->get();
     $aux = array();
     foreach ($categories2 as $category) {
         foreach ($products2 as $product) {
             $pts = DB::table('products')->where('category_id', $category->id)->where('account_id', '=', Auth::user()->account_id)->get(array('id', 'product_key', 'notes', 'cost'));
             $prod = array($category->name => $pts);
         }
         $aux += $prod;
     }
     $mensaje = array('productos' => $aux, 'categorias' => $categories, 'first_name' => Auth::user()->first_name, 'last_name' => Auth::user()->last_name, 'branch' => $sucursales, 'name' => $cuenta->name, 'subdominio' => $cuenta->domain);
     return Response::json($mensaje);
 }
 public function showPatientBalance($patient = null)
 {
     $user = Confide::user();
     if (!$user->isStaff()) {
         $patient = $user;
     }
     $acct_id = DB::table('account')->where('patient_id', '=', $patient->id)->select('id')->get()[0]->id;
     $account = Account::find($acct_id);
     $payments = DB::table('payment')->where('payment.acct_id', '=', $acct_id)->leftJoin('procedure', 'procedure.acct_id', '=', 'payment.created_at')->select('payment.id', 'payment.created_at', 'procedure.provider', 'procedure.description', 'procedure.charge', 'payment.amount');
     $accountEntries = DB::table('procedure')->where('procedure.acct_id', '=', $acct_id)->leftJoin('payment', 'payment.acct_id', '=', 'procedure.created_at')->select('procedure.id', 'procedure.created_at', 'procedure.provider', 'procedure.description', 'procedure.charge', 'payment.amount')->union($payments)->orderBy('created_at')->get();
     // 1.) use sql join table Payment, Procedure desc from date
     //$date
     //$provider
     //$description
     //$charge
     //$payment
     //$balanceAfterEachPayment
     //$totalDue
     $entries = array();
     $currentBalance = 0;
     $index = 0;
     foreach ($accountEntries as $accountEntry) {
         $entries[$index] = (object) array();
         $entry = $entries[$index];
         $index++;
         $entry->date = $accountEntry->created_at;
         $entry->provider = isset($accountEntry->provider) ? $accountEntry->provider : '-';
         $entry->description = isset($accountEntry->description) ? $accountEntry->description : 'Thank you for your payment';
         $entry->charge = !is_null($accountEntry->charge) ? $accountEntry->charge : '-';
         $entry->payment = !is_null($accountEntry->amount) ? $accountEntry->amount : '-';
         $currentBalance = $currentBalance + $entry->charge + -1 * $entry->payment;
         $entry->balance = $currentBalance;
     }
     $balance = $currentBalance;
     $account->balance = $balance;
     $account->save();
     return View::make('home/billing/show-patient-balance', compact('user', 'entries', 'balance'));
 }
Beispiel #24
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  * @return Response
  */
 public function edit($publicId)
 {
     $client = Client::scope($publicId)->withTrashed()->with('contacts')->first();
     if ($client) {
         if ($client->deleted_at != null) {
             $client->restore();
         }
         $contacts = $client->contacts;
         $contactos = array();
         foreach ($contacts as $contact) {
             # code...
             $contactos[] = array('id' => $contact->id, 'nombres' => $contact->first_name, 'apellidos' => $contact->last_name, 'email' => $contact->email, 'phone' => $contact->phone, 'position' => $contact->position);
             //
         }
         $data = ['client' => $client, 'contactos' => $contactos, 'url' => 'clientes/' . $publicId, 'title' => 'Editar Cliente'];
         $account = Account::find(Auth::user()->account_id);
         //data = array_merge($data, self::getViewModel());
         $data = array_merge($data, array('cuenta' => $account));
         // return Response::json($data);
         return View::make('clientes.edit', $data);
     }
     Session::flash('error', 'No existe el usuario');
     return Redirect::to('clientes');
 }
Beispiel #25
0
    //        $votes = Vote::where('school_no', '=', $id)->get();
    //        $school_no = $votes[0]->school_no;
    //        $vote_amount = $votes[0]->vote_amount;
    //        $redo = 0;
    //        $data = [$accounts,$school_no,$vote_amount,$redo];
    //$data_test = "test";
    // return our view and Vote information
    return View::make('tasks.votes_from_whom', compact('accounts'));
}));
Route::get('/candidates_select_result/', array('as' => 'candidates_select_result', function () {
    $cadidates_checked = Input::get('candidate');
    if (is_array($cadidates_checked)) {
        $account_id = Session::get('account_id', '這是預設值,沒設定過就用這個囉!!');
        //echo $account_id;
        //dd('5');
        $account = Account::find($account_id);
        $vote = Vote::find($account->vote_id);
        if (count($cadidates_checked) > $vote->can_select) {
            $can_select = $vote->can_select;
            $candidates = Candidate::where('vote_id', '=', $account->vote_id)->get();
            $account_id = Session::get('account_id', '這是預設值,沒設定過就用這個囉!!');
            $err_msg = '超過可選數目';
            return View::make('tasks.candidate_select', compact('candidates', 'account_id', 'err_msg', 'can_select'));
        } else {
            echo "投票完成!<br>您選擇的是:<br>";
            foreach ($cadidates_checked as $candidate_id) {
                $candidate = Candidate::find($candidate_id);
                echo $candidate->cname;
                echo "<br>";
                $candidate->accounts()->save($account);
                $candidate->total_count++;
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $this->account->find($id)->delete();
     return Redirect::route('accounts.index');
 }
Beispiel #27
0
 public function copia($id)
 {
     $invoice = Invoice::where('id', $id)->first(array('id', 'account_name', 'account_nit', 'account_uniper', 'account_uniper', 'address1', 'address2', 'terms', 'importe_neto', 'importe_total', 'branch_name', 'city', 'client_id', 'client_name', 'client_nit', 'control_code', 'deadline', 'discount', 'economic_activity', 'end_date', 'invoice_date', 'invoice_status_id', 'invoice_number', 'number_autho', 'phone', 'public_notes', 'qr', 'logo', 'public_id', 'note', 'sfc', 'type_third', 'branch_id', 'state', 'law', 'phone', 'javascript'));
     $account = Account::find(Auth::user()->account_id);
     //return $invoice['id'];
     $products = InvoiceItem::where('invoice_id', $invoice->id)->get();
     $invoice['invoice_items'] = $products;
     $invoice['third'] = $invoice->type_third;
     $invoice['is_uniper'] = $account->is_uniper;
     $invoice['uniper'] = $account->uniper;
     $invoice['logo'] = $invoice->getLogo();
     $client_id = $invoice->getClient();
     $client = DB::table('clients')->where('id', '=', $client_id)->first();
     $contacts = Contact::where('client_id', $client->id)->get(array('id', 'is_primary', 'first_name', 'last_name', 'email'));
     $status = InvoiceStatus::where('id', $invoice->invoice_status_id)->first();
     //echo $client_id;
     //print_r($contacts);
     //	return 0;
     if ($invoice->note == "") {
         $nota = [];
     } else {
         $nota = json_decode($invoice['note']);
     }
     $data = array('invoice' => $invoice, 'account' => $account, 'products' => $products, 'contacts' => $contacts, 'nota' => $nota, 'copia' => 1, 'matriz' => Branch::scope(1)->first(), 'status' => $status->name == "Parcial" ? "Parcialmente Pagado" : $status->name);
     // return Response::json($data);
     return View::make('factura.show', $data);
 }
 /**
  * Display suggestion list.
  *
  * @return Response
  */
 public function follow_suggestion($userId)
 {
     $user = Account::find($userId);
     $url = "";
     //if($user != null)
     $url = 'http://candychat.net/request.php?t=search&a=follow-suggestions-mobile&user_id=' . $user->id . "&user_pass="******"&token=asdffdsa&q=a";
     $api_response = cURL::get($url);
     $response = $api_response->toArray();
     $response = $response['body'];
     $json = json_decode($response, true);
     //return Response::json($json);
     $total_account = sizeof($json["suggestion"]);
     $users = array();
     foreach ($json["suggestion"] as $user) {
         $the_user = Account::find((int) $user["id"]);
         $the_user->avatar;
         $the_user->cover;
         $the_user->gender;
         $the_user->birthday;
         $the_user->is_following = Helpers::SK_isFollowing($the_user->id, $userId);
         $users[] = $the_user;
     }
     $response = array('status' => '1', 'total' => $total_account, 'users' => $users);
     return Response::json($response);
 }
Beispiel #29
0
 /**
  * Sets the value of fv_account_id.
  *
  * @param mixed $fv_account_id the fv_account_id
  *
  * @return self
  */
 public function setAccountId($account_id)
 {
     if (!empty($account_id)) {
         if (!is_numeric($account_id)) {
             $this->fv_error_message = $this->fv_error_message . '<br>- Identificador Cuenta ' . ERROR_DATO_NUMERICO;
             return $this->fv_account_id = null;
         }
         $account_idExiste = Account::find($account_id);
         if (!$account_idExiste) {
             $this->fv_error_message = $this->fv_error_message . '<br>- Identificador Cuenta ' . ERROR_ID;
             return $this->fv_account_id = null;
         }
         return $this->fv_account_id = $account_id;
     }
     $this->fv_error_message = $this->fv_error_message . '<br>- Identificador Cuenta ' . ERROR_NULL;
     return $this->fv_account_id = null;
 }
Beispiel #30
0
 public function viewer($id)
 {
     $params = array('id' => $id);
     $user = Account::find($id);
     return Response::json(Helpers::checkViewer($user->username));
 }