当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::scope方法代码示例

本文整理汇总了PHP中Client::scope方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::scope方法的具体用法?PHP Client::scope怎么用?PHP Client::scope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client::scope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $publicId = 1;
     $invoice = Invoice::scope($publicId)->with('account.country', 'client.contacts', 'client.country', 'invoice_items')->firstOrFail();
     Utils::trackViewed($invoice->invoice_number . ' - ' . $invoice->client->getDisplayName(), ENTITY_INVOICE);
     //$productos = InvoiceItem::scope(1)->get();
     $invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
     $invoice->due_date = Utils::fromSqlDate($invoice->due_date);
     $invoice->start_date = Utils::fromSqlDate($invoice->start_date);
     $invoice->end_date = Utils::fromSqlDate($invoice->end_date);
     $invoice->is_pro = Auth::user()->isPro();
     //print_r($invoice->invoice_items);
     //return Response::json($invoice);
     $contactIds = DB::table('invitations')->join('contacts', 'contacts.id', '=', 'invitations.contact_id')->where('invitations.invoice_id', '=', $invoice->id)->where('invitations.account_id', '=', Auth::user()->account_id)->where('invitations.deleted_at', '=', null)->select('contacts.public_id')->lists('public_id');
     $data = array('showBreadcrumbs' => false, 'account' => $invoice->account, 'invoice' => $invoice, 'data' => false, 'method' => 'PUT', 'invitationContactIds' => $contactIds, 'url' => 'invoices/' . $publicId, 'title' => '- ' . $invoice->invoice_number, 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->where('id', $invoice->client->id)->get(), 'client' => $invoice->client);
     $data = array_merge($data, self::getViewModel());
     // Set the invitation link on the client's contacts
     $clients = $data['clients'];
     foreach ($clients as $client) {
         if ($client->id == $invoice->client->id) {
             foreach ($invoice->invitations as $invitation) {
                 foreach ($client->contacts as $contact) {
                     if ($invitation->contact_id == $contact->id) {
                         $contact->invitation_link = $invitation->getLink();
                     }
                 }
             }
             break;
         }
     }
     //                print_r($data['invoice']);
     //                echo "<br><br><br><br><br>";
     //return View::make('invoices.edit', $data);
     return View::make('factura', $data);
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:35,代码来源:ProofController.php

示例2: edit

 public function edit($publicId)
 {
     $credit = Credit::scope($publicId)->firstOrFail();
     $credit->credit_date = Utils::fromSqlDate($credit->credit_date);
     $data = array('client' => null, 'credit' => $credit, 'method' => 'PUT', 'url' => 'credits/' . $publicId, 'title' => 'Edit Credit', 'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
     return View::make('credit.edit', $data);
 }
开发者ID:poseidonjm,项目名称:invoice-ninja,代码行数:7,代码来源:CreditController.php

示例3: edit

 public function edit($publicId)
 {
     $payment = Payment::scope($publicId)->firstOrFail();
     $payment->payment_date = Utils::fromSqlDate($payment->payment_date);
     $data = array('client' => null, 'invoice' => null, 'invoices' => Invoice::scope()->where('is_recurring', '=', false)->where('is_quote', '=', false)->with('client', 'invoice_status')->orderBy('invoice_number')->get(), 'payment' => $payment, 'method' => 'PUT', 'url' => 'payments/' . $publicId, 'title' => 'Edit Payment', 'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
     return View::make('payments.edit', $data);
 }
开发者ID:poseidonjm,项目名称:invoice-ninja,代码行数:7,代码来源:PaymentController.php

示例4: index

 public function index()
 {
     if (!Utils::isPro()) {
         return Redirect::to('/');
     }
     $clients = Client::scope()->with('contacts')->orderBy('created_at', 'desc')->get();
     $clients = Utils::remapPublicIds($clients->toArray());
     $response = json_encode($clients, JSON_PRETTY_PRINT);
     $headers = Utils::getApiHeaders(count($clients));
     return Response::make($response, 200, $headers);
 }
开发者ID:stewartadam,项目名称:invoice-ninja,代码行数:11,代码来源:ClientApiController.php

示例5: saveClient

 public function saveClient($publicId, $data, $notify = true)
 {
     if (!$publicId || $publicId == "-1") {
         $client = Client::createNew();
         $client->currency_id = 1;
         $contact = Contact::createNew();
         $contact->is_primary = true;
         $contact->send_invoice = true;
     } else {
         $client = Client::scope($publicId)->with('contacts')->first();
         $contact = $client->contacts()->where('is_primary', '=', true)->first();
     }
     if (isset($data['nit'])) {
         $client->nit = trim($data['nit']);
     }
     if (isset($data['name'])) {
         $client->name = trim($data['name']);
     }
     if (isset($data['business_name'])) {
         $client->business_name = trim($data['business_name']);
     }
     if (isset($data['work_phone'])) {
         $client->work_phone = trim($data['work_phone']);
     }
     if (isset($data['custom_value1'])) {
         $client->custom_value1 = trim($data['custom_value1']);
     }
     if (isset($data['custom_value2'])) {
         $client->custom_value2 = trim($data['custom_value2']);
     }
     if (isset($data['address1'])) {
         $client->address1 = trim($data['address1']);
     }
     if (isset($data['address2'])) {
         $client->address2 = trim($data['address2']);
     }
     if (isset($data['city'])) {
         $client->city = trim($data['city']);
     }
     if (isset($data['state'])) {
         $client->state = trim($data['state']);
     }
     if (isset($data['private_notes'])) {
         $client->private_notes = trim($data['private_notes']);
     }
     $client->save();
     $isPrimary = true;
     $contactIds = [];
     if (isset($data['contact'])) {
         $info = $data['contact'];
         if (isset($info['email'])) {
             $contact->email = trim(strtolower($info['email']));
         }
         if (isset($info['first_name'])) {
             $contact->first_name = trim($info['first_name']);
         }
         if (isset($info['last_name'])) {
             $contact->last_name = trim($info['last_name']);
         }
         if (isset($info['phone'])) {
             $contact->phone = trim($info['phone']);
         }
         $contact->is_primary = true;
         $contact->send_invoice = true;
         $client->contacts()->save($contact);
     } else {
         foreach ($data['contacts'] as $record) {
             $record = (array) $record;
             if ($publicId != "-1" && isset($record['public_id']) && $record['public_id']) {
                 $contact = Contact::scope($record['public_id'])->first();
             } else {
                 $contact = Contact::createNew();
             }
             if (isset($record['email'])) {
                 $contact->email = trim(strtolower($record['email']));
             }
             if (isset($record['first_name'])) {
                 $contact->first_name = trim($record['first_name']);
             }
             if (isset($record['last_name'])) {
                 $contact->last_name = trim($record['last_name']);
             }
             if (isset($record['phone'])) {
                 $contact->phone = trim($record['phone']);
             }
             $contact->is_primary = $isPrimary;
             $contact->send_invoice = isset($record['send_invoice']) ? $record['send_invoice'] : true;
             $isPrimary = false;
             $client->contacts()->save($contact);
             $contactIds[] = $contact->public_id;
         }
         foreach ($client->contacts as $contact) {
             if (!in_array($contact->public_id, $contactIds)) {
                 $contact->delete();
             }
         }
     }
     $client->save();
     if (!$publicId || $publicId == "-1") {
         \Activity::createClient($client, $notify);
//.........这里部分代码省略.........
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:101,代码来源:invoiceController.php

示例6: guardarFactura

 public function guardarFactura()
 {
     /* David 
         	 Guardando  factura con el siguiente formato:
         	
     			{"invoice_items":[{"qty":"2","id":"2"}],"client_id":"1"}
     			//nuevo formato para la cascada XD
     			{"invoice_items":[{"qty":"2","id":"2","boni":"1","desc":"3"}],"client_id":"1"}
     			//para version generica
     
     			{"invoice_items":[{"qty":"6","id":"11"}],"name":"Sin Nombre","nit":"0","client_id":"19"}
     
         	*/
     $input = Input::all();
     // $invoice_number = Auth::user()->account->getNextInvoiceNumber();
     $invoice_number = Auth::user()->branch->getNextInvoiceNumber();
     $client_id = $input['client_id'];
     $clientF = Client::scope($client_id)->firstOrFail();
     $client = (object) array();
     $client->id = $clientF->id;
     $client->name = $clientF->name;
     $client->nit = $clientF->nit;
     $client->public_id = $clientF->public_id;
     DB::table('clients')->where('id', $client->id)->update(array('nit' => $input['nit'], 'name' => $input['name']));
     //
     $user_id = Auth::user()->getAuthIdentifier();
     $user = DB::table('users')->select('account_id', 'branch_id', 'public_id')->where('id', $user_id)->first();
     $account = DB::table('accounts')->where('id', $user->account_id)->first();
     // //$account_id = $user->account_id;
     // // $account = DB::table('accounts')->select('num_auto','llave_dosi','fecha_limite')->where('id',$user->account_id)->first();
     // //$branch = DB::table('branches')->select('num_auto','llave_dosi','fecha_limite','address1','address2','country_id','industry_id')->where('id',$user['branch_id'])->first();
     // //$branch = DB::table('branches')->select('num_auto','llave_dosi','fecha_limite','address1','address2','country_id','industry_id')->where('id','=',$user->branch_id)->first();
     //   	// $branch = DB::table('branches')->select('number_autho','key_dosage','deadline','address1','address2','country_id','industry_id','law','activity_pri','activity_sec1','name')->where('id','=',$user->branch_id)->first();
     $branch = DB::table('branches')->where('id', '=', $user->branch_id)->first();
     $invoice_design = DB::table('invoice_designs')->select('id')->where('account_id', '=', $user->account_id)->first();
     // return Response::json($invoice_design);
     $items = $input['invoice_items'];
     // $linea ="";
     $amount = 0;
     $subtotal = 0;
     $fiscal = 0;
     $icetotal = 0;
     $bonidesc = 0;
     $productos = array();
     foreach ($items as $item) {
         # code...
         $product_id = $item['id'];
         $pr = DB::table('products')->where('products.id', "=", $product_id)->first();
         // $pr->xd ='hola';
         //me quede aqui me llego sueñito XD
         $amount = $amount + $pr->cost * $item['qty'];
         // $pr->qty = 1;
         $productos = $pr;
         // $pr = DB::table('products')->select('cost')->where('id',$product_id)->first();
         // $qty = (int) $item['qty'];
         // $cost = $pr->cost/$pr->units;
         // $st = ($cost * $qty);
         // $subtotal = $subtotal + $st;
         // $bd= ($item['boni']*$cost) + $item['desc'];
         // $bonidesc= $bonidesc +$bd;
         // $amount = $amount +$st-$bd;
         //   			// $fiscal = $fiscal +$amount;
     }
     //   	$fiscal = $amount -$bonidesc-$icetotal;
     $balance = $amount;
     $subtotal = $amount;
     //   	/////////////////////////hasta qui esta bien al parecer hacer prueba de que fuciona el join de los productos XD
     $invoice_dateCC = date("Ymd");
     $invoice_date = date("Y-m-d");
     $invoice_date_limitCC = date("Y-m-d", strtotime($branch->deadline));
     require_once app_path() . '/includes/control_code.php';
     $cod_control = codigoControl($invoice_number, $client->nit, $invoice_dateCC, $amount, $branch->number_autho, $branch->key_dosage);
     //     $ice = DB::table('tax_rates')->select('rate')->where('name','=','ice')->first();
     //     //
     //     // creando invoice
     $invoice = Invoice::createNew();
     $invoice->invoice_number = $invoice_number;
     $invoice->client_id = $client->id;
     $invoice->user_id = $user_id;
     $invoice->account_id = $user->account_id;
     $invoice->branch_id = $user->branch_id;
     $invoice->amount = number_format((double) $amount, 2, '.', '');
     $invoice->invoice_design_id = $invoice_design->id;
     //------------- hasta aqui funciona despues sale error
     $invoice->law = $branch->law;
     $invoice->balance = $balance;
     $invoice->subtotal = $subtotal;
     $invoice->control_code = $cod_control;
     $invoice->start_date = $invoice_date;
     $invoice->invoice_date = $invoice_date;
     $invoice->activity_pri = $branch->activity_pri;
     $invoice->activity_sec1 = $branch->activity_sec1;
     //     // $invoice->invoice
     $invoice->end_date = $invoice_date_limitCC;
     //     //datos de la empresa atra vez de una consulta XD
     //     /*****************error generado al intentar guardar **/
     //   	 // $invoice->branch = $branch->name;
     $invoice->address1 = $branch->address1;
     $invoice->address2 = $branch->address2;
     $invoice->number_autho = $branch->number_autho;
//.........这里部分代码省略.........
开发者ID:aleguisf,项目名称:fvdev1,代码行数:101,代码来源:InvoiceController.php

示例7: mapFile

 private function mapFile()
 {
     $file = Input::file('file');
     if ($file == null) {
         Session::flash('error', trans('texts.select_file'));
         return Redirect::to('company/import_export');
     }
     $name = $file->getRealPath();
     require_once app_path() . '/includes/parsecsv.lib.php';
     $csv = new parseCSV();
     $csv->heading = false;
     $csv->auto($name);
     if (count($csv->data) + Client::scope()->count() > Auth::user()->getMaxNumClients()) {
         $message = trans('texts.limit_clients', ['count' => Auth::user()->getMaxNumClients()]);
         Session::flash('error', $message);
         return Redirect::to('company/import_export');
     }
     Session::put('data', $csv->data);
     $headers = false;
     $hasHeaders = false;
     $mapped = array();
     $columns = array('', Client::$fieldVat_number, Client::$fieldName, Client::$fieldNit, Client::$fieldPhone, Client::$fieldAddress1, Client::$fieldAddress2, Client::$fieldNotes, Contact::$fieldFirstName, Contact::$fieldLastName, Contact::$fieldPhone, Contact::$fieldEmail);
     if (count($csv->data) > 0) {
         $headers = $csv->data[0];
         foreach ($headers as $title) {
             if (strpos(strtolower($title), 'name') > 0) {
                 $hasHeaders = true;
                 break;
             }
         }
         for ($i = 0; $i < count($headers); $i++) {
             $title = strtolower($headers[$i]);
             $mapped[$i] = '';
             if ($hasHeaders) {
                 $map = array('Nombre' => Client::$fieldVat_number, 'Razón Social' => Client::$fieldName, 'Nit' => Client::$fieldNit, 'Teléfono' => Client::$fieldPhone, 'Zona/Barrio' => Client::$fieldAddress1, 'Dirección' => Client::$fieldAddress2, 'Antecedentes' => Client::$fieldNotes, 'Nombre(s)' => Contact::$fieldFirstName, 'Apellidos' => Contact::$fieldLastName, 'Correo' => Contact::$fieldEmail, 'Celular' => Contact::$fieldPhone);
                 foreach ($map as $search => $column) {
                     foreach (explode("|", $search) as $string) {
                         if (strpos($title, 'sec') === 0) {
                             continue;
                         }
                         if (strpos($title, $string) !== false) {
                             $mapped[$i] = $column;
                             break 2;
                         }
                     }
                 }
             }
         }
     }
     $data = array('data' => $csv->data, 'headers' => $headers, 'hasHeaders' => $hasHeaders, 'columns' => $columns, 'mapped' => $mapped);
     return View::make('accounts.import_map', $data);
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:52,代码来源:AccountController.php

示例8: getViewModel

 private static function getViewModel()
 {
     return ['entityType' => ENTITY_QUOTE, 'account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels()];
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:4,代码来源:QuoteController.php

示例9: save

 private function save($publicId = null)
 {
     $rules = array('email' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $url = $publicId ? 'clients/' . $publicId . '/edit' : 'clients/create';
         return Redirect::to($url)->withErrors($validator)->withInput(Input::except('password'));
     } else {
         if ($publicId) {
             $client = Client::scope($publicId)->firstOrFail();
         } else {
             $client = Client::createNew();
         }
         $client->name = trim(Input::get('name'));
         $client->id_number = trim(Input::get('id_number'));
         $client->vat_number = trim(Input::get('vat_number'));
         $client->work_phone = trim(Input::get('work_phone'));
         $client->custom_value1 = trim(Input::get('custom_value1'));
         $client->custom_value2 = trim(Input::get('custom_value2'));
         $client->address1 = trim(Input::get('address1'));
         $client->address2 = trim(Input::get('address2'));
         $client->city = trim(Input::get('city'));
         $client->state = trim(Input::get('state'));
         $client->postal_code = trim(Input::get('postal_code'));
         $client->country_id = Input::get('country_id') ?: null;
         $client->private_notes = trim(Input::get('private_notes'));
         $client->size_id = Input::get('size_id') ?: null;
         $client->industry_id = Input::get('industry_id') ?: null;
         $client->currency_id = Input::get('currency_id') ?: null;
         $client->payment_terms = Input::get('payment_terms') ?: 0;
         $client->website = trim(Input::get('website'));
         $client->save();
         $data = json_decode(Input::get('data'));
         $contactIds = [];
         $isPrimary = true;
         foreach ($data->contacts as $contact) {
             if (isset($contact->public_id) && $contact->public_id) {
                 $record = Contact::scope($contact->public_id)->firstOrFail();
             } else {
                 $record = Contact::createNew();
             }
             $record->email = trim(strtolower($contact->email));
             $record->first_name = trim($contact->first_name);
             $record->last_name = trim($contact->last_name);
             $record->phone = trim($contact->phone);
             $record->is_primary = $isPrimary;
             $isPrimary = false;
             $client->contacts()->save($record);
             $contactIds[] = $record->public_id;
         }
         foreach ($client->contacts as $contact) {
             if (!in_array($contact->public_id, $contactIds)) {
                 $contact->delete();
             }
         }
         if ($publicId) {
             Session::flash('message', trans('texts.updated_client'));
         } else {
             Activity::createClient($client);
             Session::flash('message', trans('texts.created_client'));
         }
         return Redirect::to('clients/' . $client->public_id);
     }
 }
开发者ID:stewartadam,项目名称:invoice-ninja,代码行数:64,代码来源:ClientController.php

示例10: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($clientPublicId = 0, $invoicePublicId = 0)
 {
     $data = ['clientPublicId' => Input::old('client') ? Input::old('client') : $clientPublicId, 'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : $invoicePublicId, 'invoices' => Invoice::scope()->where('is_recurring', '=', false)->where('is_quote', '=', false)->where('invoice_status_id', '<', '5')->where('balance', '>', 0)->with('client', 'invoice_status', 'branch')->orderBy('invoice_number')->get(), 'paymentTypes' => PaymentType::orderBy('id')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), 'payment' => null, 'method' => 'POST', 'url' => 'pagos', 'title' => 'Nuevo pago'];
     return View::make('pagos.edit', $data);
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:10,代码来源:PaymentController.php

示例11: trans

    $locale = Session::get(SESSION_LOCALE);
    if ($locale == 'en') {
        return trans($text);
    } else {
        $string = trans($text);
        $english = trans($text, [], 'en');
        return $string != $english ? $string : '';
    }
}
Validator::extend('positive', function ($attribute, $value, $parameters) {
    return Utils::parseFloat($value) >= 0;
});
Validator::extend('has_credit', function ($attribute, $value, $parameters) {
    $publicClientId = $parameters[0];
    $amount = $parameters[1];
    $client = Client::scope($publicClientId)->firstOrFail();
    $credit = $client->getTotalCredit();
    return $credit >= $amount;
});
/*
// Log all SQL queries to laravel.log
Event::listen('illuminate.query', function($query, $bindings, $time, $name)
{
    $data = compact('bindings', 'time', 'name');

    // Format binding data for sql insertion
    foreach ($bindings as $i => $binding)
    {   
        if ($binding instanceof \DateTime)
        {   
            $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
开发者ID:stewartadam,项目名称:invoice-ninja,代码行数:31,代码来源:routes.php

示例12: save

 private function save($publicId = null, $isPos = null)
 {
     $rules = array('nit' => 'required');
     // $clientId =  $publicId ? Client::getPrivateId($publicId) : null;
     // 		$rules = ['nit' => 'unique:clients,nit,' . $clientId . ',id,account_id,' . Auth::user()->account_id];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         if ($isPos) {
             $datos = array('resultado' => 1, 'mensaje' => 'Nit ya ha sido registrado.');
             return Response::json($datos);
         } else {
             $url = $publicId ? 'clients/' . $publicId . '/edit' : 'clients/create';
             return Redirect::to($url)->withErrors($validator)->withInput(Input::except('password'));
         }
     } else {
         if ($publicId) {
             $client = Client::scope($publicId)->firstOrFail();
         } else {
             $client = Client::createNew();
         }
         $client->nit = trim(Input::get('nit'));
         $client->name = trim(Input::get('name'));
         $client->business_name = trim(Input::get('business_name'));
         $client->work_phone = trim(Input::get('work_phone'));
         if ($isPos) {
             $client->business_name = trim(Input::get('name'));
         }
         $client->custom_value1 = trim(Input::get('custom_value1'));
         $client->custom_value2 = trim(Input::get('custom_value2'));
         $client->custom_value3 = trim(Input::get('custom_value3'));
         $client->custom_value4 = trim(Input::get('custom_value4'));
         $client->custom_value5 = trim(Input::get('custom_value5'));
         $client->custom_value6 = trim(Input::get('custom_value6'));
         $client->custom_value7 = trim(Input::get('custom_value7'));
         $client->custom_value8 = trim(Input::get('custom_value8'));
         $client->custom_value9 = trim(Input::get('custom_value9'));
         $client->custom_value10 = trim(Input::get('custom_value10'));
         $client->custom_value11 = trim(Input::get('custom_value11'));
         $client->custom_value12 = trim(Input::get('custom_value12'));
         $client->address1 = trim(Input::get('address1'));
         $client->address2 = trim(Input::get('address2'));
         $client->city = trim(Input::get('city'));
         $client->state = trim(Input::get('state'));
         $client->private_notes = trim(Input::get('private_notes'));
         $client->save();
         if (!$isPos) {
             $data = json_decode(Input::get('data'));
             $contactIds = [];
             $isPrimary = true;
             foreach ($data->contacts as $contact) {
                 if (isset($contact->public_id) && $contact->public_id) {
                     $record = Contact::scope($contact->public_id)->firstOrFail();
                 } else {
                     $record = Contact::createNew();
                 }
                 $record->email = trim(strtolower($contact->email));
                 $record->first_name = trim($contact->first_name);
                 $record->last_name = trim($contact->last_name);
                 $record->phone = trim($contact->phone);
                 $record->is_primary = $isPrimary;
                 $isPrimary = false;
                 $client->contacts()->save($record);
                 $contactIds[] = $record->public_id;
             }
             foreach ($client->contacts as $contact) {
                 if (!in_array($contact->public_id, $contactIds)) {
                     $contact->delete();
                 }
             }
             if ($publicId) {
                 Activity::editClient($client);
                 Session::flash('message', trans('texts.updated_client'));
             } else {
                 Activity::createClient($client);
                 Session::flash('message', trans('texts.created_client'));
             }
             return Redirect::to('clients/' . $client->public_id);
         } else {
             $record = Contact::createNew();
             $record->is_primary = true;
             $client->contacts()->save($record);
             $clientPOS = array('id' => $client->id, 'public_id' => $client->public_id, 'name' => $client->name, 'nit' => $client->nit, 'business_name' => $client->business_name);
             $datos = array('resultado' => 0, 'cliente' => $clientPOS);
             return Response::json($datos);
         }
     }
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:87,代码来源:ClientController.php

示例13: mapFile

 private function mapFile()
 {
     $file = Input::file('file');
     if ($file == null) {
         Session::flash('error', trans('texts.select_file'));
         return Redirect::to('company/import_export');
     }
     $name = $file->getRealPath();
     require_once app_path() . '/includes/parsecsv.lib.php';
     $csv = new parseCSV();
     $csv->heading = false;
     $csv->auto($name);
     if (count($csv->data) + Client::scope()->count() > Auth::user()->getMaxNumClients()) {
         $message = trans('texts.limit_clients', ['count' => Auth::user()->getMaxNumClients()]);
         Session::flash('error', $message);
         return Redirect::to('company/import_export');
     }
     Session::put('data', $csv->data);
     $headers = false;
     $hasHeaders = false;
     $mapped = array();
     $columns = array('', Client::$fieldName, Client::$fieldPhone, Client::$fieldAddress1, Client::$fieldAddress2, Client::$fieldCity, Client::$fieldState, Client::$fieldPostalCode, Client::$fieldCountry, Client::$fieldNotes, Contact::$fieldFirstName, Contact::$fieldLastName, Contact::$fieldPhone, Contact::$fieldEmail);
     if (count($csv->data) > 0) {
         $headers = $csv->data[0];
         foreach ($headers as $title) {
             if (strpos(strtolower($title), 'name') > 0) {
                 $hasHeaders = true;
                 break;
             }
         }
         for ($i = 0; $i < count($headers); $i++) {
             $title = strtolower($headers[$i]);
             $mapped[$i] = '';
             if ($hasHeaders) {
                 $map = array('first' => Contact::$fieldFirstName, 'last' => Contact::$fieldLastName, 'email' => Contact::$fieldEmail, 'mobile' => Contact::$fieldPhone, 'phone' => Client::$fieldPhone, 'name|organization' => Client::$fieldName, 'street|address|address1' => Client::$fieldAddress1, 'street2|address2' => Client::$fieldAddress2, 'city' => Client::$fieldCity, 'state|province' => Client::$fieldState, 'zip|postal|code' => Client::$fieldPostalCode, 'country' => Client::$fieldCountry, 'note' => Client::$fieldNotes);
                 foreach ($map as $search => $column) {
                     foreach (explode("|", $search) as $string) {
                         if (strpos($title, 'sec') === 0) {
                             continue;
                         }
                         if (strpos($title, $string) !== false) {
                             $mapped[$i] = $column;
                             break 2;
                         }
                     }
                 }
             }
         }
     }
     $data = array('data' => $csv->data, 'headers' => $headers, 'hasHeaders' => $hasHeaders, 'columns' => $columns, 'mapped' => $mapped);
     return View::make('accounts.import_map', $data);
 }
开发者ID:stewartadam,项目名称:invoice-ninja,代码行数:52,代码来源:AccountController.php

示例14: create

 public function create($clientPublicId = 0)
 {
     $client = null;
     $invoiceNumber = Auth::user()->branch->getNextInvoiceNumber();
     $account = Account::with('country')->findOrFail(Auth::user()->account_id);
     if ($clientPublicId) {
         $client = Client::scope($clientPublicId)->firstOrFail();
     }
     $data = array('account' => $account, 'invoice' => null, 'data' => Input::old('data'), 'invoiceNumber' => $invoiceNumber, 'method' => 'POST', 'url' => 'invoices', 'title' => '- New Invoice', 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->where('id', $clientPublicId)->get(), 'client' => $client);
     $data = array_merge($data, self::getViewModel());
     return View::make('invoices.edit', $data);
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:12,代码来源:InvoiceController.php

示例15: getViewModel

 private static function getViewModel()
 {
     return ['account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'frequencies' => array(1 => 'Weekly', 2 => 'Two weeks', 3 => 'Four weeks', 4 => 'Monthly', 5 => 'Three months', 6 => 'Six months', 7 => 'Annually')];
 }
开发者ID:poseidonjm,项目名称:invoice-ninja,代码行数:4,代码来源:InvoiceController.php


注:本文中的Client::scope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。