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


PHP Client::createNew方法代码示例

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


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

示例1: llenarClients

 public function llenarClients()
 {
     for ($i = 0; $i < 50; $i++) {
         $client = Client::createNew();
         $client->setNit($i);
         $client->setName('cliente' . $i);
         $client->setBussinesName('nuevo' . $i);
         $client->setWorkPhone('22454545');
         $client->save();
     }
     return $client;
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:12,代码来源:SearchController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // return Response::json(Input::all());
     $client = Client::createNew();
     $client->setNit(trim(Input::get('nit')));
     $client->setName(trim(Input::get('name')));
     $client->setBussinesName(trim(Input::get('business_name')));
     $client->setWorkPhone(trim(Input::get('work_phone')));
     $client->setCustomValue1(trim(Input::get('l1')));
     $client->setCustomValue2(trim(Input::get('l2')));
     $client->setCustomValue3(trim(Input::get('l3')));
     $client->setCustomValue4(trim(Input::get('l4')));
     $client->setCustomValue5(trim(Input::get('l5')));
     $client->setCustomValue6(trim(Input::get('l6')));
     $client->setCustomValue7(trim(Input::get('l7')));
     $client->setCustomValue8(trim(Input::get('l8')));
     $client->setCustomValue9(trim(Input::get('l9')));
     $client->setCustomValue10(trim(Input::get('l10')));
     $client->setCustomValue11(trim(Input::get('l11')));
     $client->setCustomValue12(trim(Input::get('l12')));
     //  $client->setCustomValue7(trim(Input::get('custom_value7')));
     //  $client->setCustomValue8(trim(Input::get('custom_value8')));
     //  $client->setCustomValue9(trim(Input::get('custom_value9')));
     //  $client->setCustomValue10(trim(Input::get('custom_value10')));
     //  $client->setCustomValue11(trim(Input::get('custom_value11')));
     //  $client->setCustomValue12(trim(Input::get('custom_value12')));
     $client->setAddress1(trim(Input::get('address1')));
     $client->setAddress2(trim(Input::get('address2')));
     $client->setPrivateNotes(trim(Input::get('private_notes')));
     $resultado = $client->guardar();
     // $new_contacts = json_decode(Input::get('data'));
     if (Input::get('json') == "1") {
         $client->save();
         return Response::json($client);
     }
     if (!$resultado) {
         $message = "Cliente creado con éxito";
         //  echo "producto salvado";
         $client->save();
     } else {
         $url = 'clientes/create';
         Session::flash('error', $resultado);
         return Redirect::to($url)->withInput();
     }
     $isPrimary = true;
     $contactos = Utils::parseContactos(Input::get('contactos'));
     if ($contactos) {
         foreach ($contactos as $contacto) {
             # code...
             // $contador++;
             $contact_new = Contact::createNew();
             $contact_new->client_id = $client->getId();
             $contact_new->setFirstName(trim($contacto['first_name']));
             $contact_new->setLastName(trim($contacto['last_name']));
             $contact_new->setEmail(trim(strtolower($contacto['email'])));
             $contact_new->setPhone(trim(strtolower($contacto['phone'])));
             $contact_new->setPosition(trim($contacto['position']));
             $contact_new->setIsPrimary($isPrimary);
             $isPrimary = false;
             $resultado = $contact_new->guardar();
             //print_r($resultado);
             $client->contacts()->save($contact_new);
         }
     }
     Session::flash('message', $message);
     return Redirect::to('clientes');
 }
开发者ID:Vrian7ipx,项目名称:firstmed,代码行数:72,代码来源:ClientController.php

示例3: 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

示例4: importFile

 private function importFile()
 {
     $data = Session::get('data');
     Session::forget('data');
     $map = Input::get('map');
     $count = 0;
     $hasHeaders = Input::get('header_checkbox');
     $countries = Country::remember(DEFAULT_QUERY_CACHE)->get();
     $countryMap = [];
     foreach ($countries as $country) {
         $countryMap[strtolower($country->name)] = $country->id;
     }
     foreach ($data as $row) {
         if ($hasHeaders) {
             $hasHeaders = false;
             continue;
         }
         $client = Client::createNew();
         $contact = Contact::createNew();
         $contact->is_primary = true;
         $contact->send_invoice = true;
         $count++;
         foreach ($row as $index => $value) {
             $field = $map[$index];
             $value = trim($value);
             if ($field == Client::$fieldVat_number && !$client->vat_number) {
                 $client->vat_number = $value;
             } else {
                 if ($field == Client::$fieldName && !$client->name) {
                     $client->name = $value;
                 } else {
                     if ($field == Client::$fieldNit && !$client->nit) {
                         $client->nit = $value;
                     } else {
                         if ($field == Client::$fieldPhone && !$client->work_phone) {
                             $client->work_phone = $value;
                         } else {
                             if ($field == Client::$fieldAddress1 && !$client->address1) {
                                 $client->address1 = $value;
                             } else {
                                 if ($field == Client::$fieldAddress2 && !$client->address2) {
                                     $client->address2 = $value;
                                 } else {
                                     if ($field == Client::$fieldNotes && !$client->private_notes) {
                                         $client->private_notes = $value;
                                     } else {
                                         if ($field == Contact::$fieldFirstName && !$contact->first_name) {
                                             $contact->first_name = $value;
                                         } else {
                                             if ($field == Contact::$fieldLastName && !$contact->last_name) {
                                                 $contact->last_name = $value;
                                             } else {
                                                 if ($field == Contact::$fieldPhone && !$contact->phone) {
                                                     $contact->phone = $value;
                                                 } else {
                                                     if ($field == Contact::$fieldEmail && !$contact->email) {
                                                         $contact->email = strtolower($value);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $client->save();
         $client->contacts()->save($contact);
         $client->save();
         Activity::createClient($client, false);
     }
     $message = Utils::pluralize('created_client', $count);
     Session::flash('message', $message);
     return Redirect::to('clients');
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:78,代码来源:AccountController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //print_r(Input::all());return 0;
     $client = Client::createNew();
     $client->setNit(trim(Input::get('nit')));
     $client->setName(trim(Input::get('name')));
     $client->setBussinesName(trim(Input::get('business_name')));
     $client->setWorkPhone(trim(Input::get('work_phone')));
     $client->setCustomValue1(trim(Input::get('l1')));
     $client->setCustomValue2(trim(Input::get('l2')));
     $client->setCustomValue3(trim(Input::get('l3')));
     $client->setCustomValue4(trim(Input::get('l4')));
     $client->setCustomValue5(trim(Input::get('l5')));
     $client->setCustomValue6(trim(Input::get('l6')));
     $client->setAddress1(trim(Input::get('address1')));
     $client->setAddress2(trim(Input::get('address2')));
     $client->setPrivateNotes(trim(Input::get('private_notes')));
     $client->setZone(trim(Input::get('zone')));
     $client->other = trim(Input::get('other'));
     $client->setCity(trim(Input::get('city')));
     $client->setGroup(trim(Input::get('group')));
     $client->setBusiness_type_id(trim(Input::get('business')));
     // $client->city=Input::get('city');
     // $client->group_id = Input::get('group');
     // $client->business_type_id = Input::get('business');
     $dias = "";
     for ($i = 1; $i < 8; $i++) {
         if (Input::get('d' . $i)) {
             $dias .= "1";
         } else {
             $dias .= "0";
         }
     }
     //frecuency es handed with 0 and 1
     $client->frecuency = $dias;
     $resultado = $client->guardar();
     if (Input::get('json') == "1") {
         $client->save();
         return json_encode(0);
     }
     if (!$resultado) {
         $message = "Cliente con Nit " . $client->nit . "&nbsp; y Razón Social &nbsp;" . $client->business_name . " &nbsp; creado con éxito";
         $client->save();
     } else {
         $url = 'clientes/create';
         Session::flash('error', $resultado);
         return Redirect::to($url)->withInput();
     }
     $isPrimary = true;
     $contactos = Utils::parseContactos(Input::get('contactos'));
     if ($contactos) {
         foreach ($contactos as $contacto) {
             # code...
             // $contador++;
             $contact_new = Contact::createNew();
             $contact_new->client_id = $client->getId();
             $contact_new->setFirstName(trim($contacto['first_name']));
             $contact_new->setLastName(trim($contacto['last_name']));
             $contact_new->setEmail(trim(strtolower($contacto['email'])));
             $contact_new->setPhone(trim(strtolower($contacto['phone'])));
             $contact_new->setIsPrimary($isPrimary);
             $isPrimary = false;
             $resultado = $contact_new->guardar();
             //print_r($resultado);
             $client->contacts()->save($contact_new);
         }
     }
     Session::flash('message', $message);
     return Redirect::to('clientes');
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:75,代码来源:ClientController.php

示例6: 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

示例7: 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

示例8: doImportClients

 public function doImportClients()
 {
     $data = Session::get('data');
     Session::forget('data');
     $map = Input::get('map');
     $count = 0;
     $first = true;
     foreach ($data as $row) {
         if ($first) {
             $first = false;
             continue;
         }
         $client = Client::createNew();
         $contact = Contact::createNew();
         $contact->is_primary = true;
         $contact->send_invoice = true;
         $count++;
         foreach ($row as $index => $value) {
             $field = $map[$index];
             $value = trim($value);
             if ($field == Client::$fieldName && !$client->name) {
                 $client->name = $value;
             } else {
                 if ($field == Client::$fieldBusinessName && !$client->business_name) {
                     $client->business_name = $value;
                 } else {
                     if ($field == Client::$fieldNit && !$client->nit) {
                         $client->nit = $value;
                     } else {
                         if ($field == Client::$fieldAddress1 && !$client->address1) {
                             $client->address1 = $value;
                         } else {
                             if ($field == Client::$fieldAddress2 && !$client->address2) {
                                 $client->address2 = $value;
                             } else {
                                 if ($field == Client::$fieldWorkPhone && !$client->work_phone) {
                                     $client->work_phone = $value;
                                 } else {
                                     if ($field == Client::$fieldPrivateNotes && !$client->private_notes) {
                                         $client->private_notes = $value;
                                     } else {
                                         if ($field == Contact::$fieldFirstName && !$contact->first_name) {
                                             $contact->first_name = $value;
                                         } else {
                                             if ($field == Contact::$fieldLastName && !$contact->last_name) {
                                                 $contact->last_name = $value;
                                             } else {
                                                 if ($field == Contact::$fieldPhone && !$contact->phone) {
                                                     $contact->phone = $value;
                                                 } else {
                                                     if ($field == Contact::$fieldEmail && !$contact->email) {
                                                         $contact->email = strtolower($value);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $client->save();
         $client->contacts()->save($contact);
         $client->save();
         // Activity::createClient($client, false);
     }
     $message = $count == 1 ? 'cliente creado con éxito' : $count . 'clientes creados con éxito';
     Session::flash('message', $message);
     return Redirect::to('clientes');
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:73,代码来源:ImportController.php

示例9: guardarCliente

 public function guardarCliente()
 {
     $client = Client::createNew();
     $client->setNit(trim(Input::get('nit')));
     $client->setName(trim(Input::get('name')));
     $client->setBussinesName(trim(Input::get('name')));
     $client->save();
     //$client = Client::where()->first();
     $client2 = Client::where('id', $client->id)->first();
     $clientPOS = array('id' => $client2->id, 'public_id' => $client2->public_id, 'name' => $client2->name, 'nit' => $client2->nit, 'business_name' => $client2->business_name);
     $datos = array('resultado' => 0, 'cliente' => $clientPOS);
     return Response::json($datos);
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:13,代码来源:PosController.php

示例10: fire

 public function fire()
 {
     $this->info(date('Y-m-d') . ' Running CreateRandomData...');
     $user = User::first();
     if (!$user) {
         $this->error("Error: please create user account by logging in");
         return;
     }
     $productNames = ['Arkansas', 'New York', 'Arizona', 'California', 'Colorado', 'Alabama', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'Alaska', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
     $clientNames = ['IBM', 'Nestle', 'Mitsubishi UFJ Financial', 'Vodafone', 'Eni', 'Procter & Gamble', 'Johnson & Johnson', 'American International Group', 'Banco Santander', 'BHP Billiton', 'Pfizer', 'Itaú Unibanco Holding', 'Ford Motor', 'BMW Group', 'Commonwealth Bank', 'EDF', 'Statoil', 'Google', 'Siemens', 'Novartis', 'Royal Bank of Canada', 'Sumitomo Mitsui Financial', 'Comcast', 'Sberbank', 'Goldman Sachs Group', 'Westpac Banking Group', 'Nippon Telegraph & Tel', 'Ping An Insurance Group', 'Banco Bradesco', 'Anheuser-Busch InBev', 'Bank of Communications', 'China Life Insurance', 'General Motors', 'Telefónica', 'MetLife', 'Honda Motor', 'Enel', 'BASF', 'Softbank', 'National Australia Bank', 'ANZ', 'ConocoPhillips', 'TD Bank Group', 'Intel', 'UBS', 'Hewlett-Packard', 'Coca-Cola', 'Cisco Systems', 'UnitedHealth Group', 'Boeing', 'Zurich Insurance Group', 'Hyundai Motor', 'Sanofi', 'Credit Agricole', 'United Technologies', 'Roche Holding', 'Munich Re', 'PepsiCo', 'Oracle', 'Bank of Nova Scotia'];
     foreach ($productNames as $i => $value) {
         $product = Product::createNew($user);
         $product->id = $i + 1;
         $product->product_key = $value;
         $product->save();
     }
     foreach ($clientNames as $i => $value) {
         $client = Client::createNew($user);
         $client->name = $value;
         $client->save();
         $contact = Contact::createNew($user);
         $contact->email = "client@aol.com";
         $contact->is_primary = 1;
         $client->contacts()->save($contact);
         $numInvoices = rand(1, 25);
         if ($numInvoices == 4 || $numInvoices == 10 || $numInvoices == 25) {
             // leave these
         } else {
             if ($numInvoices % 3 == 0) {
                 $numInvoices = 1;
             } else {
                 if ($numInvoices > 10) {
                     $numInvoices = $numInvoices % 2;
                 }
             }
         }
         $paidUp = rand(0, 1) == 1;
         for ($j = 1; $j <= $numInvoices; $j++) {
             $price = rand(10, 1000);
             if ($price < 900) {
                 $price = rand(10, 150);
             }
             $invoice = Invoice::createNew($user);
             $invoice->invoice_number = $user->account->getNextInvoiceNumber();
             $invoice->amount = $invoice->balance = $price;
             $invoice->created_at = date('Y-m-d', strtotime(date("Y-m-d") . ' - ' . rand(1, 100) . ' days'));
             $client->invoices()->save($invoice);
             $productId = rand(0, 40);
             if ($productId > 20) {
                 $productId = $productId % 2 + rand(0, 2);
             }
             $invoiceItem = InvoiceItem::createNew($user);
             $invoiceItem->product_id = $productId + 1;
             $invoiceItem->product_key = $productNames[$invoiceItem->product_id];
             $invoiceItem->cost = $invoice->amount;
             $invoiceItem->qty = 1;
             $invoice->invoice_items()->save($invoiceItem);
             if ($paidUp || rand(0, 2) > 1) {
                 $payment = Payment::createNew($user);
                 $payment->invoice_id = $invoice->id;
                 $payment->amount = $invoice->amount;
                 $client->payments()->save($payment);
             }
         }
     }
 }
开发者ID:njmube,项目名称:invoice-ninja,代码行数:66,代码来源:CreateRandomData.php

示例11: saveLote2

 private function saveLote2($factura)
 {
     //print_r($factura);
     //return;
     $account = DB::table('accounts')->where('id', '=', Auth::user()->account_id)->first();
     $branch = Branch::find(Session::get('branch_id'));
     $client = Client::where('account_id', '=', Auth::user()->account_id)->where('name', $factura['name'])->where('nit', $factura['nit'])->first();
     if (!$client) {
         ///echo "creo";
         $client = Client::createNew();
         $client->setNit(trim($factura['nit']));
         $client->setName(trim($factura['name']));
         $client->setBussinesName(trim($factura['razon']));
         $alt = $client->guardar();
         $client->save();
         //echo $alt;
     }
     //echo $client->id."<<";
     //return ;
     //  $client=  Client::where('account_id','=', Auth::user()->account_id)->where('public_id',$factura['id'])->first();
     //if(!$client)
     //   return $factura['nit'];
     $invoice = Invoice::createNew();
     $invoice->setPublicNotes("");
     $invoice->setBranch(Session::get('branch_id'));
     $invoice->setInvoiceDate("2016-02-11");
     $invoice->setClient($client->id);
     $invoice->setEconomicActivity($branch->economic_activity);
     $invoice->setDiscount(0);
     $invoice->setClientName($client->business_name);
     $invoice->setClientNit($client->nit);
     $invoice->setUser(Auth::user()->id);
     $total_cost = 0;
     /*foreach ($factura['products'] as $producto)
       {            
           $total_cost+= $producto['cost'];
       }*/
     $invoice->importe_neto = trim($factura['total']);
     $invoice->importe_total = trim($factura['total']);
     $invoice->debito_fiscal = trim($factura['total']);
     //$invoice->note = trim(Input::get('nota'));
     $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)->firstOrFail();
     $invoice->invoice_number = branch::getInvoiceNumber();
     $numAuth = $invoice->number_autho;
     $numfactura = $invoice->invoice_number;
     $nit = $invoice->client_nit;
     $fechaEmision = date("Ymd", strtotime($invoice->invoice_date));
     $total = $invoice->importe_total;
     $llave = $branch->key_dosage;
     $codigoControl = Utils::getControlCode($numfactura, $nit, $fechaEmision, $total, $numAuth, $llave);
     $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);
     $invoice->logo = 1;
     $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->logo = $type_document->logo;
     $invoice->save();
     //foreach ($factura['products']  as $producto)
     //{
     $product = Product::where('account_id', Auth::user()->account_id)->where('product_key', $factura['code'])->first();
     if ($product != null) {
         $invoiceItem = InvoiceItem::createNew();
         $invoiceItem->setInvoice($invoice->id);
         $invoiceItem->setProduct($product->id);
         $invoiceItem->setProductKey($product->product_key);
         $invoiceItem->setNotes($product->notes);
         $invoiceItem->setCost($factura['total']);
         $invoiceItem->setQty($factura['qty']);
         $invoiceItem->save();
     }
     $this->sendInvoiceByMailLocal($client->name, $client->business_name, $invoice->id, $invoice->invoice_date, $client->nit);
     //}
 }
开发者ID:Vrian7ipx,项目名称:firstmed,代码行数:96,代码来源:invoiceController.php

示例12: registrarCliente

 public function registrarCliente()
 {
     $data = Input::all();
     // $data  = array('hola' => 'mundo' );
     $client = Client::createNew();
     $contact = Contact::createNew();
     $contact->is_primary = true;
     $client->name = trim($data['name']);
     $client->nit = trim($data['nit']);
     $client->save();
     $email = $data['email'];
     if ($email == 'sinemail') {
         // $email = "david@david.corp";
         $user_id = Auth::user()->getAuthIdentifier();
         $user = DB::table('users')->select('account_id')->where('id', $user_id)->first();
         $account_id = $user->account_id;
         $account = DB::table('accounts')->select('work_email')->where('id', $account_id)->first();
         $email = $account->work_email;
     }
     $isPrimary = true;
     $contact->email = trim(strtolower($email));
     $contact->phone = trim($data['phone']);
     $contact->is_primary = $isPrimary;
     $client->contacts()->save($contact);
     $cliente = DB::table('clients')->select('id', 'name', 'nit')->where('account_id', $client->account_id)->where('nit', $client->nit)->first();
     $datos = array('resultado' => 0, 'cliente' => $cliente);
     return Response::json($datos);
     // return Response::json($client);
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:29,代码来源:ClientController.php


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