public function create_temporal() { $input = Input::All(); $username = $input["username"]; $domain = Config::get("constants.TEMPORAL_DOMAIN"); $email = $username . $domain; $password = $input["password"]; $passwordVerify = $input["passwordVerify"]; $success = false; if (Account::where("email", "=", $email)->count() >= 1) { $response = "El nombre de usuario ya esta registrado."; } else { if (strcmp($password, $passwordVerify) == 0) { try { $account = new Account(array("email" => $email, "password" => Hash::make($password), "role_id" => Config::get("constants.ACCOUNT_TYPE.TEMPORAL"), "activated" => true)); $account->save(); $success = true; $response = "El usuario " . $email . " se ha creado correctamente."; } catch (Exception $ex) { $response = "No se ha podido crear el usuario"; } } else { $response = "Las contraseñas no coinciden."; } } return Response::json(array("success" => $success, "response" => $response)); }
public function getAccount($userId) { if (!$this->account) { $this->account = Account::where('user_id', '=', $userId)->first(); } return $this->account; }
public function historyAllFromDb() { // youlove = 161 $ids = [1527, 2163, 1448, 14523, 1301, 14533]; //,1527,2163,1926,1247,3,6,3082]; $a = array(); $lives = Helpers::SK_liveHistoryAll(); $json = array(); $data = []; $tmp = []; $i = 0; foreach ($lives as $obj) { //$user = Account::find($id); $username = $obj['owner']; //echo $username . "<br/>"; $user = Account::where('username', $username)->get()->first(); //$url = 'http://server-a.vdomax.com:8080/record/?user='******'body']; //$json["sample_url"] = "http://server-a.vdomax.com:8080/record/youlove-310115_23:59:46.flv"; //$history = json_decode($response,true); //if($history != null) { //foreach ($history as $obj) { if ($user) { $tmp['user_id'] = $user->id; $tmp['username'] = $username; $tmp['avatar'] = "http://www.vdomax.com/" . $user->avatar; $tmp['last_thumb'] = "https://www.vdomax.com/clips/rtmp/" . $username . ".png"; $tmp['url'] = "http://server-a.vdomax.com:8080/record/" . $obj['file_name'] . ".flv"; $tmp['transcode'] = "http://server-a.vdomax.com:8080/record/transcode/" . $obj['file_name'] . ".flv-480x272.mp4"; $tmp['thumb'] = "http://server-a.vdomax.com:8080/record/" . $obj['file_name'] . ".flv.png"; $tmp['view'] = $obj['view']; $tmp['love'] = $obj['love']; $tmp['duration']['hours'] = rand(0, 1) . ""; $tmp['duration']['minutes'] = rand(10, 59) . ""; $tmp['duration']['seconds'] = rand(10, 59) . ""; $tmp['date'] = "1430227302"; } /* "hours": "00", "minutes": "33", "seconds": "24.08" */ //$tmp['duration'] = $obj['duration']; //$tmp['date'] = $obj['date']; $data[] = $tmp; //} //} } /* usort($data, function($a, $b) { //Sort the array using a user defined function return $a['date'] > $b['date'] ? -1 : 1; //Compare the scores }); */ $json['count'] = count($data); $json['history'] = $data; //$a = Helpers::SK_liveHistoryAll(); return Response::json($json); }
public function update() { $account_type = Input::get('account-type'); $email = Input::get('email'); $name = Input::get('name'); $phone = Input::get('phone'); $former_password = Input::get('former-password'); $new_password = Input::get('new-password'); $sess_email = Session::get('pb_user_email'); $fake_sess_email = "*****@*****.**"; // check if the former password matches the one in the database... $account = Account::where('email', '=', $sess_email)->first(); $user_password = $account->password; $existing_phone_number_two = $account->phone_number_two; $existing_phone_privacy = $account->phone_privacy; if ($former_password == $user_password) { $account->name = $name; $account->account_type = $account_type; $account->phone_number = $phone; $account->phone_number_two = $existing_phone_number_two; $account->phone_privacy = $existing_phone_privacy; $account->email = $email; $account->password = $new_password; $account->save(); // for security purpose mail the user... do that in later version... return Redirect::to('/settings')->with(array('welcome_back' => 'Your account has been succesfully updated.')); } else { return Redirect::to('/settings')->with(array('message' => 'Your password does not match with the one on our record.')); } }
function update_referal_signup($user_id) { try { if ($user_id != '-') { $user = User::find($user_id); if (isset($user->id)) { $month = date('m'); $year = date('Y'); $referral = Referral::where('user_id', '=', $user_id)->where(DB::raw('month(created_at)'), '=', $month)->where(DB::raw('year(created_at)'), '=', $year)->first(); if (!isset($referral->id)) { $referral = new Referral(); $referral->user_id = $user_id; } $referral->total_signup = $referral->total_signup + 1; if ($referral->proposal_gained <= 30) { $proposal = 5; $referral->proposal_gained = $referral->proposal_gained + $proposal; $account = Account::where('user_id', '=', $user_id)->first(); $account->monthly_proposal_limit = $account->monthly_proposal_limit + $proposal; $account->save(); } $referral->save(); } } } catch (Exception $e) { } }
public function home() { $this->generateAccounts(); $account = Account::where('used', '!=', 1)->first()->toArray(); $arr = $this->getAvailableOffers($account['email']); $data['email'] = $arr['email']; return View::make('home', compact('data', 'arr')); }
/** * 删除旧菜单. * * @param int $accountId 公众号id */ public function destroyMenu($accountId) { $menus = $this->all($accountId); array_map(function ($menu) { if ($menu['type'] == 'click') { $this->eventRepository->distoryByEventKey($menu['key']); } }, $menus); $this->model->where('account_id', $accountId)->delete(); }
public function savePassword() { $auth = Auth::attempt(array('username' => Session::get('username'), 'password' => Input::get('old-password'))); if ($auth) { $account = Account::where('username', '=', Session::get('username'))->first(); $account->password = Hash::make(Input::get('new-password')); $account->save(); return Response::json(array('valid' => TRUE, 'message' => 'The password is successfully changed.')); } else { return Response::json(array('valid' => FALSE, 'message' => 'The old password is incorrect.')); } }
public static function authenticate($username, $password) { // Grab the user based on username $user = self::where('username', '=', $username)->firstOrFail(); // Grab the salt based on userId $account = Account::where('userId', '=', $user->userId)->firstOrFail(); $hashedPassword = md5($account->salt . $password); if ($hashedPassword === $user->password) { return $user; } else { return null; } }
public function d3() { $message = ''; if (Auth::user()->account->isPro()) { $account = Account::where('id', '=', Auth::user()->account->id)->with(['clients.invoices.invoice_items', 'clients.contacts'])->first(); $account = $account->hideFieldsForViz(); $clients = $account->clients->toJson(); } elseif (isset($_ENV['DATA_VIZ_SAMPLE'])) { $clients = $_ENV['DATA_VIZ_SAMPLE']; $message = trans('texts.sample_data'); } else { $clients = '[]'; } $data = ['feature' => ACCOUNT_DATA_VISUALIZATIONS, 'clientes' => $clients, 'message' => $message]; return View::make('reports.d3', $data); }
public function action_sendEmails() { $accounts = Account::where('wishlistEmail', '=', '1')->get(); foreach ($accounts as $account) { $matches = array(); $tags = $account->wishlistitems()->get(); $listings = array(); $tempListings = array(); foreach ($tags as $tag) { $tagListings; $strings = explode(' ', $tag->item); if (sizeof($strings) == 1) { $tagListings = Listing::where('title', 'LIKE', "%{$tag->item}%")->or_where("description", 'LIKE', "%{$tag->item}%")->get(); } else { $string = array_pop($strings); $query = "\tSELECT *\n\t\t\t\t\t\t\t\tFROM listings\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(title LIKE '%{$string}%'\n\t\t\t\t\t\t\t\t\tOR description LIKE '%{$string}%')"; while (!empty($strings)) { $string = array_pop($strings); $query .= " AND (title LIKE '%{$string}%'\n\t\t\t\t\t\t\t\t\tOR description LIKE '%{$string}%')"; } $tagListings = DB::query($query); } foreach ($strings as $string) { } foreach ($tagListings as $listing) { $listing->location = Location::find($listing->location_id); $listing->category = Categorie::find($listing->category_id); } array_push($tempListings, $tagListings); } foreach ($tempListings as $key => $tagListings) { foreach ($tagListings as $listing) { $listings[$listing->id] = $listing; } } var_dump(sizeof($listings)); if (sizeof($listings) > 0) { $email = $account->email; $subject = 'REMARKET: Matches found on your wishlist!'; $message = "There have recently been matches found which match the tags in your wishlist. \n\n" . "Go to market319.tk/ and login to view your wishlist.\n" . "\n\n Happy buying, \n The REMARKET team"; $header = "from: REMARKET <*****@*****.**>"; $sent = mail($email, $subject, $message, $header); } } }
function index($name) { $a = new Account(); if ($name != "") { $c = new Campaign(); $c->where('nickname', $name)->get(); if ($c->id > 0) { $data['campaign_id'] = $c->id; $data['name'] = $c->name; $data['description'] = $c->description; $data['photo'] = $c->photo; $data['countryid'] = $c->countryid; $data['categoryid'] = $c->categoryid; $data['isInfo'] = $c->isInfo; $data['title'] = $c->name; /* * get comments for the campaign */ $com = new Comment(); $com->where('campaign_id', $c->id)->get(); //$comments = new ArrayObject(); $commentsStr = "["; $flag = 0; foreach ($com->all as $comment) { $usr = new Account(); $usr->where('id', $comment->user_id)->get(); $preCom = "<img src = '" . base_url() . "/images/profile/" . $usr->photo . "' align='left'><i>says </i>"; if ($flag) { $commentsStr = $commentsStr . ","; } $flag = 1; $commentsStr = $commentsStr . "\"" . $preCom . $comment->comment . "\""; //$data['comments'][] = $comment->comment; //$data['comments_uid'][] = $comment->user_id; } $commentsStr = $commentsStr . "]"; $data['commentsStr'] = $commentsStr; $data['commentsNum'] = $com->count(); } } $data['a'] = $a; $_SESSION['url'] = site_url('destination/index/' . $name); $this->load->view('destination', $data); }
/** * login: user * password: 123 */ public function login() { $data = array(); if (!empty($_POST)) { $profile = new Account(NULL); $profile->where('login', param('login'))->where('password', sha1(param('password')))->get(); // Loop through to see all related users foreach ($profile as $p) { echo 'SN: ' . $p->service_name . '<br />'; echo 'Nick: ' . $p->user->nick . '<br />'; echo 'Email: ' . $p->user->email . '<br />'; echo '<hr />'; } } else { if (is_ajax()) { } else { $this->template->render_to('content', $this->view . 'login', $data)->show(); } } }
public function showOutstandingCharges() { $user = Confide::user(); $accounts = null; if (Request::isMethod('GET')) { // send user to view search for charges outstanding return View::make('home/billing/show-outstanding-charges', compact('user', 'accounts')); } elseif (Request::isMethod('POST')) { // update balances // Search for account by name if (Input::has('list_all')) { $accounts = Account::where('balance', '>', 0)->get(); } elseif (Input::has('first_name') || Input::has('last_name')) { $patient_id = User::where('first_name', '=', trim(Input::get('first_name')))->where('last_name', '=', trim(Input::get('last_name')))->lists('id'); if (sizeof($patient_id) > 0) { $accounts = Account::where('patient_id', '=', $patient_id[0])->where('balance', '>', 0)->get(); } } elseif (Input::has('email')) { $patient_id = User::where('email', '=', trim(Input::get('email')))->lists('id'); if (sizeof($patient_id) > 0) { $accounts = Account::where('patient_id', '=', $patient_id[0])->where('balance', '>', 0)->get(); } } // Make accounts null if it is empty $accounts = sizeof($accounts) != 0 ? $accounts : null; if (!is_null($accounts)) { foreach ($accounts as $account) { $account->user = User::find($account->patient_id); } } //search for charges outstanding and will return all patients with a balance > 0 // they can either search an individual account or all patients with balances > 0 /* example Last name First name Amount due Orduno Raul $20.00 Z Jay $25,0000 */ return View::make('home/billing/show-outstanding-charges', compact('user', 'accounts')); } }
public function account_create() { $redo = Session::get('redo'); $vote_id = Session::get('vote_id'); if ($redo == 1) { Account::where('vote_id', '=', $vote_id)->delete(); } $vote_data = Session::get('vote_data'); $vote_amount = $vote_data[1]; // $table->increments('id'); // $table->string('username'); // $table->integer('vote_id')->unsigned(); for ($x = 0; $x <= $vote_amount - 1; $x++) { $str_rand = $this->GeraHash(6); $zero_str_len = strlen($vote_amount) - strlen($x); $zero_str = ''; for ($y = 1; $y <= $zero_str_len; $y++) { $zero_str .= '0'; } $index_no = $zero_str . $x; $Caracteres = 'ABCDEFGHJKLMPQRSTUVXWYZ23456789'; $index_str = ''; for ($y = 0; $y < strlen($index_no); $y++) { $index_ary[$y] = intval(substr($index_no, $y, 1)); $index_ary_insert[$y] = substr($Caracteres, $index_ary[$y] + 7, 1); $index_str .= $index_ary_insert[$y]; } //echo $index_str."**"; $str_rand = substr($str_rand, 0, 2) . $index_str . substr($str_rand, 3, 5); $username_ary[$x] = $str_rand; } for ($x = 0; $x <= $vote_amount - 1; $x++) { $account = new Account(); $account->username = $username_ary[$x]; $account->vote_id = $vote_data[0]; $account->save(); } return Redirect::route('vote.insert-second', array('vote_id' => $vote_id)); }
function loginif() { // Create a temporary Account object $u = new Account(); // Get this Accounts stored record via their email $u->where('email', $this->email)->get(); // Give this Account their stored salt $this->salt = $u->salt; // Validate and get this Account by their property values, // this will see the 'encrypt' validation run, encrypting the password with the salt $this->validate()->get(); // If the Accountname and encrypted password matched a record in the database, // this Account object would be fully populated, complete with their ID. // If there was no matching record, this Account would be completely cleared so their id would be empty. if (empty($this->id)) { return FALSE; } else { $this->login(); // Login succeeded return TRUE; } }
public function auth2() { $params = Input::all(); $username = ltrim($params['username'], '0'); $password = $params['password']; if (Auth::attempt(['username' => $username, 'password' => $params['password']]) || Auth::attempt(['email' => $username, 'password' => $params['password']]) || Auth::attempt(['phone' => $username, 'password' => $params['password']])) { $rules = array('username' => 'required', 'password' => 'required|min:6'); $validator = Validator::make($params, $rules); if ($validator->fails()) { return Response::json(array("status" => "0", "message" => "Password should has more than or equals to 6 digits")); } //$field = Validator::make(array('email' => $username, array('email' => 'email'))->passes()) ? 'email' : 'username'; //echo $field; $user = Account::where('email', $params['username'])->orWhere('username', $params['username'])->orWhere('phone', ltrim($params['username'], '0'))->first(); if (isset($user)) { $user->birthday; $user->gender; $user->avatar; $user->cover; $result = array("status" => "1", "token" => $serializedToken, "user" => $user); return Response::json($result); } } }
/** * Sets the value of fv_username. * * @param mixed $fv_username the fv_username * * @return self */ public function setUsername($fv_username) { $fv_username = trim($fv_username); if (!empty($fv_username)) { $cuenta = Account::where('id', $this->getAccount_id())->first(); if ($cuenta) { $usuarioExiste = User::where('username', $fv_username . '@' . $cuenta->domain)->first(); if ($usuarioExiste) { $this->fv_error_message = $this->fv_error_message . '<br>- Usuario ' . ERROR_DUPLICADO; return $this->fv_username = null; } return $this->fv_username = $fv_username . '@' . $cuenta->domain; } $this->fv_error_message = $this->fv_error_message . '<br>- Usuario Identificador Cuenta ' . ERROR_ID; return $this->fv_username = null; } $this->fv_error_message = $this->fv_error_message . '<br>- Usuario ' . ERROR_NULL; return $this->fv_username = null; }
public function setNit($nit) { if (!empty($nit)) { $nit = trim($nit); $nitExiste = Account::where('nit', $nit)->first(); if ($nitExiste) { $this->fv_error_message = $this->fv_error_message . '<br>- Nit ' . $nit . ERROR_DUPLICADO; return $this->fv_nit = null; } if (!is_numeric($nit)) { $this->fv_error_message = $this->fv_error_message . '<br>- Nit ' . $nit . ERROR_DATO_NUMERICO; return $this->fv_nit = null; } if ($nit < 1000) { $this->fv_error_message = $this->fv_error_message . '<br>- Nit ' . $nit . ERROR_NUMERICO_POSITIVO; return $this->fv_nit = null; } return $this->fv_nit = $nit; } $this->fv_error_message = $this->fv_error_message . '<br>- Nit ' . ERROR_NULL; return $this->fv_nit = null; }
function account_get() { $filter = $this->get('filter')["filters"]; $obj = new Account(null, $this->entity); $obj->where($filter[0]["field"], $filter[0]["value"]); $obj->get(); $data = array(); foreach ($obj as $value) { $data[] = array("id" => $value->id, "name" => $value->name); } $this->response($data, 200); }
/** * Display the specified by username. * * @param int $username * @return Response */ public function check($username) { if (filter_var($username, FILTER_VALIDATE_EMAIL)) { $user = Account::where('email', $username)->get()->first(); } else { $user = Account::where('username', $username)->get()->first(); } if ($user != null) { $user->avatar; $user->cover; $user->birthday; $user->gender; $params = Input::all(); if (isset($params['user_id'])) { $user->is_following = Helpers::SK_isFollowing($user->id, $params['user_id']); } return Response::json(array('status' => '1', 'user' => $user)); } else { return Response::json(array('status' => '0', 'user' => null, 'count' => null)); } if ($user->count() > 0) { return Response::json(array('status' => '1', 'user' => $user)); } else { return Response::json(array('status' => '0', 'message' => 'No user found')); } }
public function export() { $fecha = explode(" ", Input::get('date')); $vec = ["Ene" => '01', "Feb" => '02', "Mar" => '03', "Abr" => '04', "May" => '05', "Jun" => '06', "Jul" => '07', "Ago" => '08', "Sep" => '09', "Oct" => '10', "Nov" => '11', "Dic" => '12']; $date = $fecha[1] . "-" . $vec[substr($fecha[0], 0, 3)]; $output = fopen('php://output', 'w') or Utils::fatalError(); header('Content-Type:application/txt'); header('Content-Disposition:attachment;filename=export.txt'); $invoices = Invoice::where('account_id', Auth::user()->account_id)->where("invoice_number", "!=", "")->where("invoice_number", "!=", 0)->where('invoice_date', 'LIKE', $date . '%')->get(); $p = "|"; $sw = true; $num = 1; foreach ($invoices as $i) { $sw = false; if ($i->invoice_status_id == 6) { $i->client_nit = 0; $i->client_name = "ANULADA"; $i->importe_total = "0.00"; $i->importe_neto = "0.00"; //$i->control_code="0"; $i->discount = "0.00"; $status = "A"; } else { $status = "V"; } // $datos = $i->invoice_number.$i->client_nit.$p.$i->client_name.$p.$p.$i->account_nit.$p.$i->invoice_date.$p.$i->importe_total.$p.$i->importe_ice.$p.$i->importe_exento.$p.$i->importe_neto.$p.$i->debito_fiscal.$p.$status.$p.$i->control_code."\r\n"; $fecha = date("d/m/Y", strtotime($i->invoice_date)); $fecha = \DateTime::createFromFormat('Y-m-d', $i->invoice_date); if ($fecha == null) { $fecha = $i->invoice_date; } else { $fecha = $fecha->format('d/m/Y'); } //$doc =TypeDocumentBranch::where('branch_id',$i->branch_id)->orderBy('id','desc')->first(); $tipo = TypeDocument::where('id', $i->javascript)->first(); //echo $tipo->master_id."<br>"; $cuenta = Account::where('id', Auth::user()->account_id)->select('currency_id')->first(); $dolar = Invoice::where('account_id', Auth::user()->account_id)->select('sfc')->where('id', $i->id)->where('branch_id', $i->branch_id)->first(); if ($cuenta->currency_id == 2) { $i->importe_total = $i->importe_total * $dolar->sfc; $i->importe_total = number_format((double) $i->importe_total, 2, '.', ''); $i->importe_neto = $i->importe_neto * $dolar->sfc; $i->importe_neto = number_format((double) $i->importe_neto, 2, '.', ''); $i->discount = $i->discount * $dolar->sfc; $i->discount = number_format((double) $i->discount, 2, '.', ''); } if ($tipo->master_id == 1 || $tipo->master_id == 4) { $debito = $i->importe_neto * 0.13; $debito = number_format((double) $debito, 2, '.', ''); $datos = "3" . $p . $num . $p . $fecha . $p . $i->invoice_number . $p . $i->number_autho . $p . $status . $p . $i->client_nit . $p . $i->client_name . $p . $i->importe_total . $p . $i->importe_ice . $p . $i->importe_exento . $p . "0.00" . $p . $i->importe_total . $p . $i->discount . $p . $i->importe_neto . $p . $debito . $p . $i->control_code . "\r\n"; } if ($tipo->master_id == 3) { $datos = "3" . $p . $num . $p . $fecha . $p . $i->invoice_number . $p . $i->number_autho . $p . $status . $p . $i->client_nit . $p . $i->client_name . $p . $i->importe_total . $p . $i->importe_ice . $p . $i->importe_exento . $p . $i->importe_neto . $p . $i->importe_total . $p . $i->discount . $p . "0.00" . $p . "0.00" . $p . $i->control_code . "\r\n"; } $num++; //echo $i->invoice_number."<br>"; fputs($output, $datos); $datos = null; } //return 0; if ($sw) { fputs($output, "No se encontraron ventas en este periodo: " . Input::get('date')); } fclose($output); exit; }
public function redo($id) { $accounts = Account::where('vote_id', '=', $id)->get(); $votes = Vote::where('id', '=', $id)->get(); $school_no = $votes[0]->school_no; $vote_amount = $votes[0]->vote_amount; $redo = 1; $data = [$accounts, $school_no, $vote_amount, $redo]; $vote_data = [$id, $vote_amount]; //$redo = 1; //echo "id",$votes[0]->$id,"amount",$votes[0]->vote_amount; Session::put('vote_id', $id); Session::put('vote_data', $vote_data); Session::put('redo', 1); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $sucurasl = Branch::find(Session::get('branch_id')); if ($sucurasl->type_third != 2) { if (sizeof(Input::get('productos')) > 1) { if (Input::has('client')) { $account = Account::where('id', Auth::user()->account_id)->first(); $branch = Branch::find(Session::get('branch_id')); $tax = TaxRate::where("name", 'ICE')->first(); $invoice = Invoice::createNew(); $invoice->setBranch(Session::get('branch_id')); $invoice->setTerms(trim(Input::get('terms'))); $invoice->setPublicNotes(trim(Input::get('public_notes'))); $invoice->setInvoiceDate(trim(Input::get('invoice_date'))); $invoice->setClient(trim(Input::get('client'))); $invoice->setEconomicActivity($branch->economic_activity); $dateparser = explode("/", Input::get('due_date')); if (Input::get('due_date')) { $date = $dateparser[2] . '-' . $dateparser[1] . '-' . $dateparser[0]; $invoice->setDueDate($date); } $invoice->setDiscount(trim(Input::get('discount'))); $invoice->setClientName(trim(Input::get('razon'))); $invoice->setClientNit(trim(Input::get('nit'))); $invoice->setUser(Auth::user()->id); $dateparser = explode("/", Input::get('invoice_date')); $date = $dateparser[2] . '-' . $dateparser[1] . '-' . $dateparser[0]; $invoice->setInvoiceDate($date); $invoice->importe_neto = trim(Input::get('total')); $invoice->importe_total = trim(Input::get('subtotal')); if (Input::get('nota')) { $nota = array(); $nota[0] = ['date' => date('d-m-Y H:i:s'), 'note' => '<b>' . Auth::user()->first_name . " " . Auth::user()->last_name . "</b>: " . trim(Input::get('nota'))]; $invoice->note = json_encode($nota); } //ACCOUTN AND BRANCK $invoice->balance = trim(Input::get('total')); $invoice->discount = Input::get('descuento_send'); $invoice->setAccountName($account->name); $invoice->setAccountNit($account->nit); $invoice->setBranchName($branch->name); $invoice->setAddress1($branch->address1); $invoice->setAddress2($branch->address2); $invoice->setPhone($branch->work_phone); $invoice->setCity($branch->city); $invoice->setState($branch->state); $invoice->setNumberAutho($branch->number_autho); $invoice->setKeyDosage($branch->key_dosage); $invoice->setTypeThird($branch->type_third); $invoice->setDeadline($branch->deadline); $invoice->setLaw($branch->law); $type_document = TypeDocument::where('account_id', Auth::user()->account_id)->first(); $numAuth = $invoice->number_autho; $invoice->invoice_number = branch::getInvoiceNumber(); $numfactura = $invoice->invoice_number; $nit = $invoice->client_nit; $fechaEmision = date("Ymd", strtotime($invoice->invoice_date)); $total = $invoice->importe_neto; $llave = $branch->key_dosage; $codigoControl = Utils::getControlCode($numfactura, $nit, $fechaEmision, $total, $numAuth, $llave); //calculates ICE //$desc = $invoice->subtotal-$invoice->amount; $invoice->importe_ice = number_format(Input::get('importe_ice'), 2, '.', ''); $invoice->debito_fiscal = number_format(Input::get('importe_fiscal'), 2, '.', ''); //$invoice->discount = number_format($desc, 2, '.', ''); $invoice->setControlCode($codigoControl); $documents = TypeDocumentBranch::where('branch_id', $invoice->branch_id)->orderBy('id', 'ASC')->get(); foreach ($documents as $document) { $actual_document = TypeDocument::where('id', $document->type_document_id)->first(); if ($actual_document->master_id == 1) { $id_documento = $actual_document->id; } } $invoice->setJavascript($id_documento); if (Input::get('printer_type') == 1) { $invoice->logo = 1; } else { $invoice->logo = 0; } $invoice->sfc = $branch->sfc; $invoice->qr = $invoice->account_nit . '|' . $invoice->invoice_number . '|' . $invoice->number_autho . '|' . $invoice->invoice_date . '|' . $invoice->importe_neto . '|' . $invoice->importe_total . '|' . $invoice->client_nit . '|' . $invoice->importe_ice . '|0|0|' . $invoice->descuento_total; if ($account->is_uniper) { $invoice->account_uniper = $account->uniper; } $invoice->save(); $invoice_items = []; foreach (Input::get('productos') as $producto) { $prod = $producto; $product = Product::where('account_id', Auth::user()->account_id)->where('product_key', $producto["'product_key'"])->first(); if ($product != null) { $invoiceItem = InvoiceItem::createNew(); $invoiceItem->setInvoice($invoice->id); $invoiceItem->setProduct($product->id); $invoiceItem->setProductKey($producto["'product_key'"]); $proo = DB::table('products')->where('product_key', '=', $producto["'product_key'"])->first(); $invoiceItem->setNotes($proo->notes); $invoiceItem->setCost($producto["'cost'"]); ///$invoiceItem->setQty($producto["'qty'"]/$proo->units+$producto["'pack'"]); $invoiceItem->setQty($proo->units * $producto["'pack'"]); $invoiceItem->packs = $producto["'pack'"]; $invoiceItem->discount = $producto["'disc'"]; $invoiceItem->boni = $producto["'bonus'"]; $invoiceItem->is_web = 1; $invoiceItem->price_type_id = Auth::user()->price_type_id; $invoiceItem->subtotal = round($producto["'pack'"] * $producto["'cost'"], 2); //$invoiceItem->importe_neto=$producto["'pack'"]*$producto["'cost'"]-$producto["'bonus'"]*$producto["'cost'"]-$producto["'disc'"]; //$invoiceItem->importe_fiscal= $invoiceItem->ice = $proo->cc * $invoiceItem->getQty() / 1000 * $tax->rate; $invoiceItem->save(); $new_item = ['boni' => $producto["'bonus'"], 'desc' => $producto["'disc'"], 'qty' => $producto["'qty'"] / $proo->units + $producto["'pack'"], 'id' => $invoice->id, 'units' => 1, 'cost' => $producto["'cost'"], 'ice' => $proo->ice, 'cc' => $proo->cc * $proo->units, 'product_key' => $producto["'product_key'"], 'notes' => $proo->notes, 'packs' => $producto["'qty'"] + $proo->units * $producto["'pack'"], 'is_web' => 1]; array_push($invoice_items, $new_item); } } //adicionando cargo al cliente $cliente = Client::find($invoice->client_id); $cliente->balance = $cliente->balance + $invoice->balance; $cliente->save(); $new = ['fecha' => $invoice->invoice_date, 'name' => $invoice->client_name, 'cod_control' => $invoice->control_code, 'nit' => $invoice->client_nit, 'invoice_number' => $invoice->invoice_number, 'client_id' => $invoice->client_id . "1", 'user_id' => $invoice->user_id, 'ice' => $tax->rate, 'deadline' => $branch->deadline, 'account_id' => '1', 'branch_id' => $branch->id, 'law' => $branch->law, 'activity_pri' => $branch->economic_activity, 'activity_sec1' => "-", 'address1' => $branch->address1, 'address2' => $branch->address2, 'number_autho' => $branch->number_autho, 'postal_code' => $branch->sfc, 'city' => $branch->city, 'state' => $branch->state, 'country_id' => $branch->id, 'key_dosage' => $branch->key_dosage, 'branch' => $branch->name, 'invoice_items' => $invoice_items, 'terceros' => $branch->terceros, 'discount' => $invoice->discount]; /* return $new;*/ $array = []; array_push($array, $new); //$this->saveBackUpToMirror($array); //print_r($array); //return; $newInvoice = Invoice::where('id', '=', $invoice->getId())->first(); return Redirect::to("factura/" . $newInvoice->id); } Session::flash('error', 'por favor ingrese cliente'); return Redirect::to('factura/create'); } Session::flash('error', 'por favor ingrese productos'); return Redirect::to('factura/create'); } Session::flash('error', 'La Dosificación es para un dispositivo POS razon por la cual no se puede facturar via web'); return Redirect::to('factura'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $account = Account::where('id', '=', $id)->first(); $account->delete(); return Response::json(array('message' => 'account deleted'), 200); }
// Route::get('/account_redo_true/{id}', array('as' => 'account_redo_true', function($id) // { // //$accounts = Account::where('vote_id', '=', $id)->get(); // Account::where('vote_id', '=', $id)->delete(); // $votes = Vote::where('id', '=', $id)->get(); // // $vote_id = $vote_new[0]->id; // $vote_data=[$vote->$id,$vote->vote_amount]; // //$redo = 1; // Session::put('vote_data', $vote_data); // Session::put('redo', 1); // //$data = [$accounts,$school_no,$vote_amount,$redo]; // // return our view and Vote information // //return View::make('tasks.account_data_show',compact('data')); // })); Route::get('/account_redo_true/{id}', array('as' => 'account_redo_true', 'uses' => 'VoteController@account_create', function ($id) { Account::where('vote_id', '=', $id)->delete(); $votes = Vote::where('id', '=', $id)->get(); $vote = $votes[0]; $vote_data = [$votes[0]->{$id}, $votes[0]->vote_amount]; //$redo = 1; echo "id", $votes[0]->{$id}, "amount", $votes[0]->vote_amount; Session::put('vote_data', $vote_data); Session::put('redo', 1); })); Route::get('/account_data_del/{id}', ['as' => 'account_data_del', 'uses' => 'AccountController@clean']); // Route::get('/{id}/{s}', array('as' => 'vote.edit2', function($id,$s) // { // // return our view and Vote information // // return View::make('tasks.vote-edit') // pulls app/views/nerd-edit.blade.php // // ->with('vote', Vote::find($id)); // return View::make('tasks.vote-edit2', array('id' => $id,'s'=>$s,'vote'=>Vote::find($id)));
public function __construct(Account $account) { $this->account = $account->where('user_id', '=', Auth::user()->id); }
Route::get('logout', 'AuthController@logOut'); // Finalizar sesión Route::post('enviarCorreo', 'invoiceController@sendInvoiceByMail'); // Route::get('user/{id}', function($account, $id) // { // return Response::json(array('cuenta' => $account, 'id' => $id)); // }); Route::get('/', function ($account) { if ($account == "bolivia") { Session::put('b_user', 'facturacion'); Session::put('b_pass', 'virtual'); } if ($account == "app") { return Redirect::to("crear"); } $cuenta = Account::where('domain', '=', $account)->first(); if ($cuenta) { // return Session::get('account_id'); // $usuario = User::whereAccountId($cuenta->id)->where('username','=','temporal@'.$account)->first(); if (!$cuenta->confirmed) { // Session::put('u',$usuario->id); Session::put('account_id', $cuenta->id); return Redirect::to('paso/1'); // return Response::json($usuario); } else { return Redirect::to('sucursal'); } } Session::flash('error', ERROR_CUENTA); return Redirect::to('crear'); // return $account;
public function action_lostPassword() { if (Input::has('email')) { $email = Input::get('email'); if (Account::where('email', '=', $email)->count() > 0) { $account = Account::where('email', '=', $email)->first(); $newPassword = rand(); $account->password = Hash::make($newPassword); $account->save(); $email = $account->email; $subject = 'REMARKET: Lost Password.'; $message = "You recently submitted a lost/forgotten password request:\n\n \n\t\t\t\t\t\t\tHere is your new password: {$newPassword}\n\n\n\t\t\t\t\t\t\tThanks for your considered patronage,\n \n\t\t\t\t\t\t\tThe REMARKET Team"; $header = "from: REMARKET <*****@*****.**>"; $sent = mail($email, $subject, $message, $header); echo "Sent! Please check your email for you your new password."; } else { echo "We dont seem to have your email address on record. Please register a new account or if you believe this to be an error, feel free to contact the admin"; } } else { echo "Please provide your email address"; } }
public function store($lcnsTypes, $userStatus, $reqParams, $pcName, $accountParams) { foreach ($lcnsTypes as $typeId) { if (LicenseType::find($typeId)->name == 'SABA Publisher') { $this->pc_name = $pcName; $return = $this->validation(); if ($return) { return Redirect::back()->withErrors($return)->with('status', $userStatus)->withInput(); } } } if ($userStatus == 'existing') { $account = Account::where('username', $accountParams['username'])->first(); $this->account_id = $account->id; $this->dbStore($reqParams); } else { $account = Account::withParams($accountParams); if ($return = $account->validation()) { return Redirect::back()->withErrors($return)->with('status', $userStatus)->withInput(); } $account->store(); $this->account_id = $account->id; $account->created_from = $this->dbStore($reqParams); $account->save(); } //license types to be added foreach ($lcnsTypes as $lcnsType) { if (!in_array($lcnsType, $this->licenseTypes()->lists('id'))) { $this->licenseTypes()->attach($lcnsType); } } //license types to be removed foreach ($this->licenseTypes()->lists('id') as $id) { if (!in_array($id, $lcnsTypes)) { $this->licenseTypes()->detach($id); } } $success = Lang::get('admin/request/message.success.create'); return array('success' => 1, 'message' => $success, 'type' => $this->type); }