예제 #1
0
 public function getPostPage()
 {
     $obj = new BaseController();
     $campusid = $this->getDevice();
     if ($campusid == 0) {
         $countryname = $obj->getCountryName();
         if ($countryname == 'NONE') {
             return Redirect::route('selectcampus-get');
         } else {
             //check whether the country name exists inthe db
             $locationcountry = Country::where('name', '=', $countryname);
             if ($locationcountry->count()) {
                 $locationcountrycode = $locationcountry->first()->code;
                 $locationcountrycode = strtolower($locationcountrycode);
                 return Redirect::route('selectcountryid', $locationcountrycode);
             } else {
                 return Redirect::route('selectcampus-get');
             }
         }
     }
     $college = Institution::whereHas('Branch', function ($query) use($campusid) {
         $query->where('id', '=', $campusid);
     })->first();
     View::share('college', $college);
     $mycampus = Branch::where('id', '=', $campusid)->first();
     View::share('mycampus', $mycampus);
     if (Auth::user()) {
         return View::make('member.post');
     }
     return View::make('guest.post');
 }
예제 #2
0
 public static function buscar($public_id)
 {
     if (Auth::check()) {
         $account_id = Auth::user()->account_id;
     } else {
         $account_id = Session::get('account_id');
     }
     $branch = Branch::where('public_id', $public_id)->scope(false, $account_id)->first();
     return $branch;
 }
예제 #3
0
 public function dashboard()
 {
     $sucursales = Branch::where('account_id', Auth::user()->account_id)->get();
     $usuarios = Account::find(Auth::user()->account_id)->users;
     $clientes = Account::find(Auth::user()->account_id)->clients;
     $productos = Account::find(Auth::user()->account_id)->products;
     $informacionCuenta = array('sucursales' => sizeof($sucursales), 'usuarios' => sizeof($usuarios), 'clientes' => sizeof($clientes), 'productos' => sizeof($productos));
     // return Response::json($informacionCuenta);
     return View::make('cuentas.dashboard')->with('cuenta', $informacionCuenta);
 }
 public function getUpdate($business_id, $field, $value)
 {
     $first_branch = Branch::where('business_id', '=', $business_id)->first();
     $first_service = Service::where('branch_id', '=', $first_branch->branch_id)->first();
     if (QueueSettings::serviceExists($first_service->service_id)) {
         QueueSettings::updateQueueSetting($first_service->service_id, $field, $value);
     } else {
         QueueSettings::createQueueSetting(['service_id' => $first_service->service_id, 'date' => mktime(0, 0, 0, date('m'), date('d'), date('Y')), $field => $value]);
     }
     return json_encode(['success' => 1]);
 }
예제 #5
0
 public function getIndex()
 {
     if (Auth::user()->grade == 1) {
         $branch = Branch::take(10)->get();
     } else {
         $branch = Branch::where('user_id', Auth::user()->id)->take(10)->get();
     }
     // 提醒
     //
     $notice = Notice::where('user_id', Auth::user()->id)->where('read', '0')->orderBy('timeline', 'desc')->take(10)->get();
     return View::make('index')->with('goods', Good::orderBy('store')->take(10)->get())->with('branch', $branch)->with('notice', $notice);
 }
예제 #6
0
 public function getIndex()
 {
     // 区域
     //
     $area = Area::all();
     // 线路
     //
     $line = Line::all();
     // 客户类型
     //
     $type = Type::all();
     $whereRaw = ' 1=1 ';
     $type_id = Input::get('type_id');
     $area_id = Input::get('area_id');
     $line_id = Input::get('line_id');
     $name = Input::get('name');
     $code = Input::get('code');
     $contact = Input::get('contact');
     if ($type_id) {
         $whereRaw .= "and type_id = {$type_id} ";
     }
     if ($area_id) {
         $whereRaw .= "and area_id = {$area_id} ";
     }
     if ($line_id) {
         $whereRaw .= "and line_id = {$line_id} ";
     }
     if ($name) {
         $whereRaw .= "and name like '%{$name}%' ";
     }
     if ($code) {
         $whereRaw .= "and code like '%{$code}%' ";
     }
     if ($contact) {
         $whereRaw .= "and contact like '%{$contact}%' ";
     }
     // 管理员
     //
     if (Auth::user()->grade == 10) {
         $branch = Branch::where('user_id', Auth::user()->id)->whereRaw($whereRaw)->paginate();
         $count = Branch::where('user_id', Auth::user()->id)->whereRaw($whereRaw)->count();
     } else {
         $branch = Branch::whereRaw($whereRaw)->paginate();
         $count = Branch::whereRaw($whereRaw)->count();
     }
     return View::make('branch.index')->with(compact('area'))->with(compact('line'))->with(compact('type'))->with('branch', $branch)->with(compact('count'));
 }
예제 #7
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($public_id)
 {
     if (Auth::user()->is_admin) {
         $branch = Branch::where('id', $public_id)->first();
         $documents = $this->getWorkingDocuments();
         if ($branch->type_third == 0) {
             $type = "Facturación Web";
         }
         if ($branch->type_third == 1) {
             $type = "Facturación por Terceros";
         }
         if ($branch->type_third == 2) {
             $type = "Facturación POS";
         }
         $data = ['sucursal' => $branch, 'documents' => $documents, 'type' => $type];
         return View::make('sucursales.show', $data);
     }
     return Redirect::to('/inicio');
 }
 public function postImportEmp()
 {
     if (\Request::ajax()) {
         $efile = \Input::file('upload');
         /* Validation of file */
         $validate = \Validator::make(array('file' => $efile), array('file' => 'required|mimes:xls,csv|max:2000|min:1'));
         if ($validate->fails()) {
             $error = array('error' => $validate->messages()->first());
             echo json_encode($error);
             return;
         } else {
             $handle = file($efile->getRealPath());
             /* Call Excel Class */
             $objPHPExcel = \PHPExcel_IOFactory::load($efile->getRealPath());
             $mainArr = array();
             foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
                 // Sheet names
                 switch ($worksheet->getTitle()) {
                     case 'User':
                         $index = 'users';
                         break;
                     case 'PersonalDetails':
                         $index = 'PersonalDetails';
                         break;
                     case 'ContactInfo':
                         $index = 'ContactInfo';
                         break;
                     case 'IdentificationandBankInfo':
                         $index = 'IdentificationandBankInfo';
                         break;
                     case 'PFandESIInformation':
                         $index = 'PFandESIInformation';
                         break;
                     case 'JobDetails':
                         $index = 'JobDetails';
                         break;
                     case 'EducationalBackground':
                         $index = 'EducationalBackground';
                         break;
                     case 'WorkExperience':
                         $index = 'WorkExperience';
                         break;
                 }
                 // Getting all cells
                 $subArr = array();
                 $rows = $worksheet->getRowIterator();
                 foreach ($rows as $row) {
                     $cells = $row->getCellIterator();
                     // cells store into data array
                     $data = array();
                     foreach ($cells as $cell) {
                         $data[] = $cell->getCalculatedValue();
                     }
                     if ($data) {
                         // one set of row stored in indexed array
                         $arr[$index] = $data;
                         // indexed array store into subarr
                         $subArr[] = $arr;
                         // remove indexd array for optimiced douplicated
                         unset($arr);
                     }
                 }
                 // every sheet of array store in main Arr
                 $mainArr[$index] = $subArr;
                 unset($subArr);
             }
             $emails = array_fetch($mainArr['users'], 'users.1');
             // Validate emails
             foreach ($emails as $value) {
                 if (preg_match("/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}\$/", $value)) {
                 } else {
                     $error = array('error' => "{$value} InValid Email");
                     echo json_encode($error);
                     return;
                 }
             }
             // validation email unique from excel
             if (count($emails) != count(array_unique($emails))) {
                 $error = array('error' => "Douplicate emails are available");
                 echo json_encode($error);
                 return;
             }
             //end email unique in excel
             //Check Email Id is unique or not
             $user = \User::withTrashed()->whereIn('email', $emails)->first();
             if ($user) {
                 $error = array('error' => "{$user->email} already registered");
                 echo json_encode($error);
                 return;
             }
             // Database insertion starts here
             $users = $mainArr['users'];
             $PersonalDetails = $mainArr['PersonalDetails'];
             $ContactInfo = $mainArr['ContactInfo'];
             $IdentificationandBankInfo = $mainArr['IdentificationandBankInfo'];
             $PFandESIInformation = $mainArr['PFandESIInformation'];
             $JobDetails = $mainArr['JobDetails'];
             $EducationalBackground = $mainArr['EducationalBackground'];
             $WorkExperience = $mainArr['WorkExperience'];
             // Create UserId
             $userID = \Auth::user()->id;
             $branch = \Branch::where('user_id', '=', $userID)->first();
             $prifix = $branch->branch_code;
             // branch prifix code
             $count = \BranchEmp::withTrashed()->where('branch_id', '=', $userID)->count();
             // count all registered user of this branch
             $i = 0;
             foreach ($users as $val) {
                 \DB::beginTransaction();
                 $temp = $count + 1;
                 // increase one
                 $count++;
                 $postfix = sprintf('%04d', $temp);
                 // manupulate 000$temp
                 $username = $prifix . $postfix;
                 $password = str_random(10);
                 $hashPassword = \Hash::make($password);
                 $email = $val['users'][1];
                 $uId = \User::insertGetId(array('username' => $username, 'password' => $hashPassword, 'displayname' => $val['users'][0], 'email' => $val['users'][1], 'profilesId' => 4, 'active' => 'Y'));
                 //create branch employee
                 $branchEmployee = \BranchEmp::insertGetId(array('branch_id' => $userID, 'emp_id' => $uId));
                 // Insert Personal detail
                 $empId = \Employee::insertGetId(array('user_id' => $uId, 'firstname' => $PersonalDetails[$i]['PersonalDetails'][0], 'lastname' => $PersonalDetails[$i]['PersonalDetails'][2], 'middlename' => $PersonalDetails[$i]['PersonalDetails'][1], 'fathername' => $PersonalDetails[$i]['PersonalDetails'][3], 'mothermaiden' => $PersonalDetails[$i]['PersonalDetails'][8], 'dateofbirth' => $PersonalDetails[$i]['PersonalDetails'][4], 'maritialstatus' => $PersonalDetails[$i]['PersonalDetails'][5], 'spousename' => $PersonalDetails[$i]['PersonalDetails'][6], 'sibling' => $PersonalDetails[$i]['PersonalDetails'][8], 'bloodgroup' => $PersonalDetails[$i]['PersonalDetails'][9]));
                 // Contact Information
                 $contact = \UserContact::insertGetId(array('user_id' => $uId, 'address' => $ContactInfo[$i]['ContactInfo'][0], 'city' => $ContactInfo[$i]['ContactInfo'][1], 'state' => $ContactInfo[$i]['ContactInfo'][2], 'pin' => $ContactInfo[$i]['ContactInfo'][3], 'p_address' => $ContactInfo[$i]['ContactInfo'][4], 'p_city' => $ContactInfo[$i]['ContactInfo'][5], 'p_state' => $ContactInfo[$i]['ContactInfo'][6], 'p_pin' => $ContactInfo[$i]['ContactInfo'][7], 'mobile' => $ContactInfo[$i]['ContactInfo'][8], 'phone' => $ContactInfo[$i]['ContactInfo'][9], 'alt_mobile' => $ContactInfo[$i]['ContactInfo'][10], 'alt_email' => $ContactInfo[$i]['ContactInfo'][11]));
                 //IdentificationandBankInfo
                 $identification = \EmpIdentification::insertGetId(array('user_id' => $uId, 'pan' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][0], 'passport_no' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][1], 'adhar_no' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][2], 'voter_id' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][3], 'driving_licence' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][4]));
                 // Bank Detail
                 $bankDetails = \EmpBankDetail::insertGetId(array('user_id' => $uId, 'account_no' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][5], 'bank_name' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][6], 'branch' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][7], 'IFSC' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][8], 'micrno' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][9]));
                 // Esi and PF Detail
                 $PfEsi = \PfEsi::insertGetId(array('user_id' => $uId, 'isPF' => $PFandESIInformation[$i]['PFandESIInformation'][0], 'pfno' => $PFandESIInformation[$i]['PFandESIInformation'][1], 'pfenno' => $PFandESIInformation[$i]['PFandESIInformation'][2], 'epfno' => $PFandESIInformation[$i]['PFandESIInformation'][3], 'relationship' => $PFandESIInformation[$i]['PFandESIInformation'][4], 'isESI' => $PFandESIInformation[$i]['PFandESIInformation'][5], 'esino' => $PFandESIInformation[$i]['PFandESIInformation'][6]));
                 // Job details
                 $jobdetailsId = \JobDetails::insertGetId(array('user_id' => $uId, 'joining_date' => $JobDetails[$i]['JobDetails'][0], 'job_type' => $JobDetails[$i]['JobDetails'][1], 'designation' => $JobDetails[$i]['JobDetails'][2], 'department' => $JobDetails[$i]['JobDetails'][3], 'reporting_manager' => $JobDetails[$i]['JobDetails'][4], 'payment_mode' => $JobDetails[$i]['JobDetails'][5], 'hr_verification' => $JobDetails[$i]['JobDetails'][6], 'police_verification' => $JobDetails[$i]['JobDetails'][7], 'emp_type' => $JobDetails[$i]['JobDetails'][8], 'client_id' => $JobDetails[$i]['JobDetails'][9]));
                 //EducationalBackground
                 $eduction = \EmpEducation::insertGetId(array('user_id' => $uId, 'school_name' => $EducationalBackground[$i]['EducationalBackground'][0], 'school_location' => $EducationalBackground[$i]['EducationalBackground'][1], 'school_percentage' => $EducationalBackground[$i]['EducationalBackground'][2], 'puc_name' => $EducationalBackground[$i]['EducationalBackground'][3], 'puc_location' => $EducationalBackground[$i]['EducationalBackground'][4], 'puc_percentage' => $EducationalBackground[$i]['EducationalBackground'][5], 'diploma_name' => $EducationalBackground[$i]['EducationalBackground'][6], 'diploma_location' => $EducationalBackground[$i]['EducationalBackground'][7], 'diploma_percentage' => $EducationalBackground[$i]['EducationalBackground'][8], 'degree_name' => $EducationalBackground[$i]['EducationalBackground'][9], 'degree_location' => $EducationalBackground[$i]['EducationalBackground'][10], 'degree_percentage' => $EducationalBackground[$i]['EducationalBackground'][11], 'master_name' => $EducationalBackground[$i]['EducationalBackground'][12], 'master_location' => $EducationalBackground[$i]['EducationalBackground'][13], 'master_percentage' => $EducationalBackground[$i]['EducationalBackground'][14]));
                 // Experiance
                 $companyDetails = \WorkExperiance::insertGetId(array('user_id' => $uId, 'company_name' => $WorkExperience[$i]['WorkExperience'][0], 'location' => $WorkExperience[$i]['WorkExperience'][1], 'designation' => $WorkExperience[$i]['WorkExperience'][2], 'last_ctc' => $WorkExperience[$i]['WorkExperience'][3], 'join_date' => $WorkExperience[$i]['WorkExperience'][4], 'leaving_date' => $WorkExperience[$i]['WorkExperience'][5]));
                 \DB::commit();
                 \Mail::send('emails.user_credential', array('name' => $val['users'][0], 'username' => $username, 'password' => $password), function ($message) use($email, $username) {
                     $message->to($email, $username)->subject('User Credential');
                 });
                 $i++;
             }
             // end foreach of database insertion
             // success message
             $success = array('success' => "Successfully uploaded your Employees");
             echo json_encode($success);
             return;
         }
         // end else part
     }
     // end ajax condition
 }
예제 #9
0
 public function factura2()
 {
     // return  Response::json(Input::all());
     $account = DB::table('accounts')->where('id', '=', Auth::user()->account_id)->first();
     //$matriz = Branch::where('number_branch','=',0)->first();
     $matriz = Branch::where('id', 2)->first();
     $branch = Branch::where('id', '=', Session::get('branch_id'))->first();
     $type_document = TypeDocument::where('account_id', Auth::user()->account_id)->where('master_id', Input::get('invoice_type'))->orderBy('id', 'DESC')->first();
     if (Input::get('printer_type') == 1) {
         $js = $type_document->javascript_web;
     } else {
         $js = $type_document->javascript_pos;
     }
     $client = Client::where('id', Input::get('client'))->first();
     $invoice = (object) ['id' => '0', 'account_name' => $account->name, 'account_nit' => $account->nit, 'account_uniper' => $account->uniper, 'address1' => $branch->address1, 'address2' => $branch->address2, 'terms' => Input::get('terms'), 'importe_neto' => Input::get('total'), 'importe_total' => Input::get('subtotal'), 'discount' => number_format(Input::get('subtotal') - Input::get('total'), 2, '.', ''), 'importe_ice' => number_format(Input::get('importe_ice'), 2, '.', ''), 'debito_fiscal' => number_format(Input::get('importe_fiscal'), 2, '.', ''), 'branch_name' => $branch->name, 'city' => $branch->city, 'client_id' => Input::get('client'), 'client_name' => Input::get('nombre'), 'client_nit' => Input::get('nit'), 'control_code' => '00-00-00-00', 'deadline' => $branch->deadline, 'descuento_total' => Input::get('discount'), 'economic_activity' => $branch->economic_activity, 'end_date' => Input::get('due_date'), 'invoice_date' => Input::get('invoice_date'), 'invoice_number' => 0, 'number_autho' => $branch->number_autho, 'phone' => $branch->work_phone, 'public_notes' => Input::get('public_notes'), 'logo' => $type_document->logo, 'sfc' => $branch->sfc, 'type_third' => $branch->type_third, 'branch_id' => $branch->id, 'state' => $branch->state, 'law' => $branch->law, 'javascript' => $js, 'document_number' => 0, 'extralabel' => $client->custom_value1];
     //                $document=  TypeDocument::where("id",$invoice->javascript)->first();
     //                $invoice->logo = $document->logo;
     //                $invoice->javascript = $invoice->logo?$document->javascript_web:$document->javascript_pos;
     $user = Auth::user();
     $products = array();
     foreach (Input::get('productos') as $producto) {
         $product = Product::where('account_id', Auth::user()->account_id)->where('product_key', $producto["'product_key'"])->first();
         if ($product != null) {
             $prod = (object) ['product_key' => $producto["'product_key'"], 'notes' => $product->notes, 'cost' => $producto["'cost'"], 'qty' => $producto["'qty'"] + $product->units * $producto["'pack'"], 'packs' => $producto["'qty'"] / $product->units + $producto["'pack'"]];
             array_push($products, $prod);
         }
     }
     // $invoice = Input::all();
     $template = TypeDocumentBranch::where('branch_id', $invoice->branch_id)->select('template')->first();
     //return 0;
     $data = array('invoice' => $invoice, 'account' => $account, 'products' => $products, 'copia' => 0, 'matriz' => $matriz, 'user' => $user, 'template' => $template);
     //                if(Input::get('printer_type')==0)
     //                    return View::make('factura.ver2',$data);
     return View::make('factura.ver', $data);
 }
예제 #10
0
 public function do_select_branch()
 {
     if (Input::get('branch_id')) {
         $branch_id = Input::get('branch_id');
         $branch = Branch::where('account_id', '=', Auth::user()->account_id)->where('public_id', $branch_id)->first();
         $user = Auth::user();
         $user->branch_id = $branch->id;
         $user->save();
         return Redirect::intended('/');
     }
 }
예제 #11
0
 private function save($publicId = null)
 {
     $action = Input::get('action');
     $entityType = Input::get('entityType');
     if ($action == 'archive' || $action == 'delete' || $action == 'mark') {
         return InvoiceController::bulk($entityType);
     }
     $input = json_decode(Input::get('data'));
     $invoice = $input->invoice;
     if (Utils::isAdmin()) {
         $branch_id = $input->invoice->branch_id;
         $branch = Branch::where('account_id', '=', Auth::user()->account_id)->where('public_id', $branch_id)->first();
         // $branch = DB::table('branches')->where('id',$branch_id)->first();
     } else {
         $branch = Auth::user()->branch;
         $branch_id = $branch->id;
         $branch = DB::table('branches')->where('id', $branch_id)->first();
     }
     $today = new DateTime('now');
     $today = $today->format('Y-m-d');
     $datelimit = DateTime::createFromFormat('Y-m-d', $branch->deadline);
     $datelimit = $datelimit->format('Y-m-d');
     $valoresPrimera = explode("-", $datelimit);
     $valoresSegunda = explode("-", $today);
     $diaPrimera = $valoresPrimera[2];
     $mesPrimera = $valoresPrimera[1];
     $anyoPrimera = $valoresPrimera[0];
     $diaSegunda = $valoresSegunda[2];
     $mesSegunda = $valoresSegunda[1];
     $anyoSegunda = $valoresSegunda[0];
     $a = gregoriantojd($mesPrimera, $diaPrimera, $anyoPrimera);
     $b = gregoriantojd($mesSegunda, $diaSegunda, $anyoSegunda);
     $errorS = "Expiró la fecha límite de " . $branch->name;
     if ($a - $b < 0) {
         Session::flash('error', $errorS);
         return Redirect::to("{$entityType}s/create")->withInput();
     } else {
         $last_invoice = Invoice::where('account_id', '=', Auth::user()->account_id)->first();
         if ($last_invoice) {
             $yesterday = $last_invoice->invoice_date;
             $today = date("Y-m-d", strtotime($invoice->invoice_date));
             $errorD = "La fecha de la factura es incorrecta";
             $yesterday = new DateTime($yesterday);
             $today = new DateTime($today);
             if ($yesterday > $today) {
                 Session::flash('error', $errorD);
                 return Redirect::to("{$entityType}s/create")->withInput();
             }
         }
         if ($errors = $this->invoiceRepo->getErrors($invoice)) {
             Session::flash('error', trans('texts.invoice_error'));
             return Redirect::to("{$entityType}s/create")->withInput()->withErrors($errors);
         } else {
             $this->taxRateRepo->save($input->tax_rates);
             $clientData = (array) $invoice->client;
             $clientData['branch'] = $branch->id;
             $client = $this->clientRepo->save($invoice->client->public_id, $clientData);
             $invoiceData = (array) $invoice;
             $invoiceData['branch_id'] = $branch->id;
             $invoiceData['client_id'] = $client->id;
             $invoiceData['client_nit'] = $client->nit;
             $invoiceData['client_name'] = $client->name;
             $invoiceData['action'] = $action;
             $invoice = $this->invoiceRepo->save($publicId, $invoiceData, $entityType);
             $account = Auth::user()->account;
             // if ($account->invoice_taxes != $input->invoice_taxes
             // 			|| $account->invoice_item_taxes != $input->invoice_item_taxes
             // 			|| $account->invoice_design_id != $input->invoice->invoice_design_id)
             // {
             // 	$account->invoice_taxes = $input->invoice_taxes;
             // 	$account->invoice_item_taxes = $input->invoice_item_taxes;
             // 	$account->invoice_design_id = $input->invoice->invoice_design_id;
             // 	$account->save();
             // }
             $client->load('contacts');
             $sendInvoiceIds = [];
             foreach ($client->contacts as $contact) {
                 if ($contact->send_invoice || count($client->contacts) == 1) {
                     $sendInvoiceIds[] = $contact->id;
                 }
             }
             foreach ($client->contacts as $contact) {
                 $invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
                 if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
                     $invitation = Invitation::createNew();
                     $invitation->invoice_id = $invoice->id;
                     $invitation->contact_id = $contact->id;
                     $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
                     $invitation->save();
                 } else {
                     if (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
                         $invitation->delete();
                     }
                 }
             }
             $invoice_date = date("d/m/Y", strtotime($invoice->invoice_date));
             require_once app_path() . '/includes/BarcodeQR.php';
             // $ice = $invoice->amount-$invoice->fiscal;
             $desc = $invoice->subtotal - $invoice->amount;
             $subtotal = number_format($invoice->subtotal, 2, '.', '');
             $amount = number_format($invoice->amount, 2, '.', '');
             $fiscal = number_format($invoice->fiscal, 2, '.', '');
             // $icef = number_format($ice, 2, '.', '');
             $descf = number_format($desc, 2, '.', '');
             // if($icef=="0.00"){
             //   $icef = 0;
             // }
             if ($descf == "0.00") {
                 $descf = 0;
             }
             $icef = 0;
             $qr = new BarcodeQR();
             $datosqr = $invoice->account_nit . '|' . $invoice->invoice_number . '|' . $invoice->number_autho . '|' . $invoice_date . '|' . $subtotal . '|' . $amount . '|' . $invoice->control_code . '|' . $invoice->client_nit . '|' . $icef . '|0|0|' . $descf;
             $qr->text($datosqr);
             $qr->draw(150, 'qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.png');
             $input_file = 'qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.png';
             $output_file = 'qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.jpg';
             $inputqr = imagecreatefrompng($input_file);
             list($width, $height) = getimagesize($input_file);
             $output = imagecreatetruecolor($width, $height);
             $white = imagecolorallocate($output, 255, 255, 255);
             imagefilledrectangle($output, 0, 0, $width, $height, $white);
             imagecopy($output, $inputqr, 0, 0, 0, 0, $width, $height);
             imagejpeg($output, $output_file);
             $invoice->qr = HTML::image_data('qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.jpg');
             $invoice->save();
             $message = trans($publicId ? "texts.updated_{$entityType}" : "texts.created_{$entityType}");
             if ($input->invoice->client->public_id == '-1') {
                 $message = $message . ' ' . trans('texts.and_created_client');
                 $url = URL::to('clients/' . $client->public_id);
                 Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
             }
             if ($action == 'clone') {
                 return $this->cloneInvoice($publicId);
             } else {
                 if ($action == 'convert') {
                     return $this->convertQuote($publicId);
                 } else {
                     if ($action == 'email') {
                         $aux = 0;
                         foreach ($client->contacts as $contact) {
                             if ($contact->email) {
                                 $aux = 1;
                             }
                         }
                         if ($aux == 0) {
                             $errorMessage = trans('El cliente no tiene Correo Electrónico.');
                             Session::flash('error', $errorMessage);
                         } else {
                             if (Auth::user()->confirmed && !Auth::user()->isDemo()) {
                                 $message = trans("texts.emailed_{$entityType}");
                                 $this->mailer->sendInvoice($invoice);
                                 Session::flash('message', $message);
                             } else {
                                 $errorMessage = trans(Auth::user()->registered ? 'texts.confirmation_required' : 'texts.registration_required');
                                 Session::flash('error', $errorMessage);
                                 Session::flash('message', $message);
                             }
                         }
                     } else {
                         if ($action == 'savepay') {
                             $payment = Payment::createNew();
                             $payment->client_id = $client->id;
                             $payment->invoice_id = $invoice->id;
                             $payment->payment_type_id = 1;
                             $payment->payment_date = $invoice->invoice_date;
                             $payment->amount = $invoice->amount;
                             $payment->save();
                             $message = trans("texts.savepay_{$entityType}");
                             Session::flash('message', $message);
                         } else {
                             if ($action == 'savepaycredit') {
                                 $payment = Payment::createNew();
                                 $credits = Credit::scope()->where('client_id', '=', $client->id)->where('balance', '>', 0)->orderBy('created_at')->get();
                                 $applied = 0;
                                 foreach ($credits as $credit) {
                                     $applied += $credit->apply($invoice->amount);
                                     if ($applied >= $invoice->amount) {
                                         break;
                                     }
                                 }
                                 $payment->client_id = $client->id;
                                 $payment->invoice_id = $invoice->id;
                                 $payment->payment_type_id = 2;
                                 $payment->payment_date = $invoice->invoice_date;
                                 $payment->amount = $invoice->amount;
                                 $payment->save();
                                 $message = trans("texts.savepay_{$entityType}");
                                 Session::flash('message', $message);
                             } else {
                                 Session::flash('message', $message);
                             }
                         }
                     }
                 }
             }
             $url = "{$entityType}s/" . $invoice->public_id . '/edit';
             return Redirect::to($url);
         }
     }
 }
예제 #12
0
 private function mapFileInvoice()
 {
     $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);
     Session::put('data', $csv->data);
     $headers = false;
     $hasHeaders = false;
     $mapped = array();
     $columns = array('', Invoice::$fieldCodClient, Invoice::$fieldProduct, Invoice::$fieldAmount);
     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('cod_client' => Invoice::$fieldCodClient, 'product' => Invoice::$fieldProduct, 'amount' => Invoice::$fieldAmount);
                 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);
     $data['branches'] = Branch::where('account_id', '=', Auth::user()->account_id)->orderBy('id')->get();
     return View::make('accounts.import_map_invoice', $data);
 }
예제 #13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     \DB::beginTransaction();
     $branch = \Branch::where('id', '=', $id)->with('contact')->firstOrFail();
     $user = \User::where('id', '=', $branch->user_id)->firstOrFail();
     $contact = \BranchContact::where('branch_id', '=', $id)->firstOrFail();
     // $branchEmp=\BranchEmp::where('branch_id','=',$id)->firstOrFail();
     if (!$user->delete()) {
         \DB::rollback();
         return \Redirect::back()->with('error', 'Failed to delete');
     }
     if (!$branch->delete()) {
         \DB::rollback();
         return \Redirect::back()->with('error', 'Failed to delete');
     }
     if (!$contact->delete()) {
         \DB::rollback();
         return \Redirect::back()->with('error', 'Failed to delete');
     } else {
         \DB::commit();
         return \Redirect::back()->with('success', 'Successfully deleted');
     }
 }
예제 #14
0
 public function getMoreHomePageSqueeb($lastid)
 {
     $campusid = $this->getDevice();
     $obj = new BaseController();
     $campusid = $this->getDevice();
     if ($campusid == 0) {
         $countryname = $obj->getCountryName();
         if ($countryname == 'NONE') {
             return Redirect::route('selectcampus-get');
         } else {
             //check whether the country name exists inthe db
             $locationcountry = Country::where('name', '=', $countryname);
             if ($locationcountry->count()) {
                 $locationcountrycode = $locationcountry->first()->code;
                 $locationcountrycode = strtolower($locationcountrycode);
                 return Redirect::route('selectcountryid', $locationcountrycode);
             } else {
                 return Redirect::route('selectcampus-get');
             }
         }
     }
     $more = true;
     $college = Institution::whereHas('Branch', function ($query) use($campusid) {
         $query->where('id', '=', $campusid);
     })->first();
     $collegeid = $college->id;
     $countryid = Country::where('id', '=', $college->country_id)->first()->id;
     //get the top squeeb to display
     $newsqueebs = Squeeb::where('active', '=', TRUE)->where('branch_id', '=', $campusid)->orderBy('id', 'DESC')->take(self::TOP_SQUEEB_LIMIT)->get();
     View::share('newsqueebs', $newsqueebs);
     $squeebs = Notice::whereHas('Squeeb', function ($query) use($campusid, $lastid) {
         $query->where('branch_id', '=', $campusid)->where('id', '<', $lastid)->where('active', '=', TRUE);
     })->orwhereHas('Squeeb', function ($query) use($lastid) {
         $query->where('branch_id', '=', 0)->where('world', '=', TRUE)->where('id', '<', $lastid)->where('active', '=', TRUE);
     })->orwhereHas('Squeeb', function ($query) use($lastid, $countryid) {
         $query->where('branch_id', '=', 0)->where('country', '=', $countryid)->where('id', '<', $lastid)->where('active', '=', TRUE);
     })->orwhereHas('Squeeb', function ($query) use($lastid, $collegeid) {
         $query->where('branch_id', '=', 0)->where('college', '=', $collegeid)->where('id', '<', $lastid)->where('active', '=', TRUE);
     });
     $last = $squeebs;
     $squeebs = $squeebs->orderBy('id', 'DESC')->take(self::SQUEEB_LIMIT)->get();
     if ($squeebs->count()) {
         $last_id = $last->orderBy('id', 'DESC')->take(self::SQUEEB_LIMIT)->get()->last()->Squeeb()->first()->id;
     }
     View::share('last_id', $last_id);
     View::share('squeebs', $squeebs);
     //get the top squeeb to display
     $topsqueebs = Squeeb::where('active', '=', TRUE)->where('model', '=', 'Notice')->where('branch_id', '=', $campusid)->orderBy('views', 'DESC')->take(self::TOP_SQUEEB_LIMIT)->get();
     View::share('topsqueebs', $topsqueebs);
     if ($lastid <= 0 or $squeebs->count() != self::SQUEEB_LIMIT) {
         $more = false;
     }
     $college = Institution::whereHas('Branch', function ($query) use($campusid) {
         $query->where('id', '=', $campusid);
     })->first();
     View::share('college', $college);
     View::share('more', $more);
     $mycampus = Branch::where('id', '=', $campusid)->first();
     View::share('mycampus', $mycampus);
     return View::make('guest.home');
 }
예제 #15
0
 public function loginpos()
 {
     // $branch = DB::table('branches')->where('id','=',$user->branch_id)->first();
     // $clients = DB::table('clients')->select('id','name','nit')->where('account_id',$user->account_id)->get(array('id','name','nit'));
     // $account = DB::table('accounts')->where('id',$user->account_id) 	->first();
     $products = DB::table('products')->where('account_id', '=', Auth::user()->account_id)->get(array('id', 'product_key', 'notes', 'cost'));
     // $ice = DB::table('tax_rates')->select('rate')
     // 							 // ->where('account_id','=',$user->account_id)
     // 							 ->where('name','=','ice')
     // 							 ->first();
     // if(Auth::user()->is_admin){
     $branches = Branch::where('account_id', Auth::user()->account_id)->select('id', 'name')->get();
     // }else
     // {
     // }
     $mensaje = array('productos' => $products, 'sucursales' => $branches);
     return Response::json($mensaje);
 }
예제 #16
0
 private static function getViewModel()
 {
     return ['branches' => Branch::where('account_id', '=', Auth::user()->account_id)->where('public_id', '>', 0)->orderBy('public_id')->get(), 'price_types' => PriceType::orderBy('id')->get(), 'allgroups' => Group::orderBy('id')->get(array('id', 'name'))];
 }
예제 #17
0
 function update()
 {
     $this->filter_access('Branch', 'roled_edit', 'branches/index');
     $branch = new Branch();
     $branch->where('branch_id', $this->input->post('id'))->update('branch_name', $this->input->post('branch_name'));
     $this->session->set_flashdata('message', 'Branch Update successfuly.');
     redirect('branches/');
 }
예제 #18
0
 public function postGuestPostsCollege2()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Type' => 'required|in:Notice,Eventsq,Job,Offer', 'Title' => 'required|max:40', 'Description' => 'required', 'Name' => 'required|max:120', 'Email' => 'required|email|max:60', 'Pic' => 'image|max:3000', 'College' => 'required'));
     if ($validator->fails()) {
         return Redirect::route('advanced_squeeb-get')->withErrors($validator)->withInput()->with('global', 'Sorry!! Your Squeeb was not posted, please retry.');
     } else {
         $type = Input::get('Type');
         $title = Input::get('Title');
         $description = Input::get('Description');
         $description = $this->MakeUrls($description);
         $squeeb = substr(strip_tags($description), 0, 300);
         $name = Input::get('Name');
         $email = Input::get('Email');
         $file = Input::file('Pic');
         $package = Input::get('Package');
         $collegeid = Input::get('College');
         $campuses = Branch::where('institutions_id', '=', $collegeid)->select('id')->get();
         //check whether the user with this email existed before
         $user = User::where('email', '=', $email);
         $firstname = NULL;
         $lastname = NULL;
         //extract the firstname and last name from the name
         if (preg_match('/\\s/', $name)) {
             $names = explode(" ", $name);
             $firstname = $names[0];
             $lastname = $names[1];
         } else {
             $firstname = $name;
         }
         if ($user->count()) {
             $user = $user->orderBy('id', 'DESC')->first();
         } else {
             //store the user details
             $user = User::create(array('email' => $email, 'firstname' => $firstname, 'lastname' => $lastname));
         }
         //get the model name
         $model = $type;
         $result = $this->postUploadPhoto($type, $file);
         $the_squeeb_array = array();
         foreach ($campuses as $campus) {
             $the_squeeb = Squeeb::create(array('model' => $model, 'views' => 0, 'branch_id' => $campus->id, 'create_day' => date("Y-m-d")));
             array_push($the_squeeb_array, $the_squeeb->id);
             //create the post details
             $squeeb_id = 0;
             $squeeb_id = $this->createSqueeb($model, $the_squeeb->id, $user->id, $title, $description, $squeeb);
             //finally post the squeebe photo
             if ($squeeb_id) {
                 if ($result != FALSE) {
                     //photos validation
                     $modelname = $type;
                     $tablename = lcfirst($modelname) . 's';
                     $modelphoto = $modelname . 'Photo';
                     $savesuccess = $modelphoto::create(array($tablename . '_id' => $squeeb_id, 'name' => $result));
                 }
             }
         }
         if ($user && $the_squeeb) {
             if ($squeeb_id) {
                 $squeeb = Squeeb::where('id', '=', $the_squeeb->id)->first();
                 View::share('squeeb', $squeeb);
                 view::share('model', $type);
                 $the_squeeb_array = implode(",", $the_squeeb_array);
                 View::share('the_squeeb_array', $the_squeeb_array);
                 return View::make('guest.advanced_squeeb_preview');
             }
         }
     }
     return Redirect::route('advanced_squeeb-get')->with('global', 'Some Error Occured, Please try again');
 }
 public function run()
 {
     DB::table('categories')->truncate();
     //1
     $category = new Category();
     $category->name = "Street Style";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //2
     $category = new Category();
     $category->name = "Running-training";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //3
     $category = new Category();
     $category->name = "Basketball";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //4
     $category = new Category();
     $category->name = "Tennis";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //5
     $category = new Category();
     $category->name = "Sandal";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //6
     $category = new Category();
     $category->name = "Dép";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //7
     $category = new Category();
     $category->name = "Adix";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //8
     $category = new Category();
     $category->name = "Asics Gel";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //9
     $category = new Category();
     $category->name = "Neo";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //10
     $category = new Category();
     $category->name = "NB";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //11
     $category = new Category();
     $category->name = "Rade";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //12
     $category = new Category();
     $category->name = "Rade R2";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //13
     $category = new Category();
     $category->name = "Zx";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //14
     $category = new Category();
     $category->name = "F1";
     $category->parent_id = 1;
     $category->root_category_id = 1;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //15
     $category = new Category();
     $category->name = "Flex";
     $category->parent_id = 2;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //16
     $category = new Category();
     $category->name = "Giày Cut";
     $category->parent_id = 2;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //17
     $category = new Category();
     $category->name = "Asics Training";
     $category->parent_id = 2;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //18
     $category = new Category();
     $category->name = "Baseketrade";
     $category->parent_id = 3;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //19
     $category = new Category();
     $category->name = "Giày Cut";
     $category->parent_id = 3;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //20
     $category = new Category();
     $category->name = "Adi Tennis";
     $category->parent_id = 4;
     $category->root_category_id = 4;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //21
     $category = new Category();
     $category->name = "Flex Training";
     $category->parent_id = 15;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //22
     $category = new Category();
     $category->name = "Flex Pro";
     $category->parent_id = 15;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //23
     $category = new Category();
     $category->name = "Dual Fusion";
     $category->parent_id = 16;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //24
     $category = new Category();
     $category->name = "Flex Supreme";
     $category->parent_id = 16;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //25
     $category = new Category();
     $category->name = "T Lite MM";
     $category->parent_id = 16;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //26
     $category = new Category();
     $category->name = "Season";
     $category->parent_id = 16;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //27
     $category = new Category();
     $category->name = "Air Max";
     $category->parent_id = 16;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //28
     $category = new Category();
     $category->name = "Maori";
     $category->parent_id = 16;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //29
     $category = new Category();
     $category->name = "GT";
     $category->parent_id = 17;
     $category->root_category_id = 2;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //30
     $category = new Category();
     $category->name = "Crazy Beat";
     $category->parent_id = 18;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //31
     $category = new Category();
     $category->name = "Dual Fusion Basketball";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //32
     $category = new Category();
     $category->name = "Prime Hype";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //33
     $category = new Category();
     $category->name = "Visi Pro";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //34
     $category = new Category();
     $category->name = "Air Premier";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //35
     $category = new Category();
     $category->name = "Zoom";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //36
     $category = new Category();
     $category->name = "Jordan";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //37
     $category = new Category();
     $category->name = "Overplay";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //38
     $category = new Category();
     $category->name = "Kobe";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //39
     $category = new Category();
     $category->name = "Kobe";
     $category->parent_id = 19;
     $category->root_category_id = 3;
     $category->Branch()->associate(Branch::where('name', '=', 'Giày dép')->first());
     $category->save();
     //40
     $category = new Category();
     $category->name = "Áo thun";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //41
     $category = new Category();
     $category->name = "Áo khoác";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //42
     $category = new Category();
     $category->name = "Quần Jogger";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //43
     $category = new Category();
     $category->name = "Quần Sweat";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //44
     $category = new Category();
     $category->name = "Quần short";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //45
     $category = new Category();
     $category->name = "Balance";
     $category->parent_id = 40;
     $category->root_category_id = 40;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //46
     $category = new Category();
     $category->name = "Long Tee";
     $category->parent_id = 40;
     $category->root_category_id = 40;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //47
     $category = new Category();
     $category->name = "Raglan";
     $category->parent_id = 40;
     $category->root_category_id = 40;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //48
     $category = new Category();
     $category->name = "Tank Top";
     $category->parent_id = 40;
     $category->root_category_id = 40;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //49
     $category = new Category();
     $category->name = "Print Tee";
     $category->parent_id = 40;
     $category->root_category_id = 40;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //50
     $category = new Category();
     $category->name = "Sport Shirt";
     $category->parent_id = 40;
     $category->root_category_id = 40;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //51
     $category = new Category();
     $category->name = "Hoodie";
     $category->parent_id = 41;
     $category->root_category_id = 41;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //52
     $category = new Category();
     $category->name = "Bomber";
     $category->parent_id = 41;
     $category->root_category_id = 41;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //53
     $category = new Category();
     $category->name = "Jacket";
     $category->parent_id = 41;
     $category->root_category_id = 41;
     $category->Branch()->associate(Branch::where('name', '=', 'Áo quần')->first());
     $category->save();
     //54
     $category = new Category();
     $category->name = "Balo";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //55
     $category = new Category();
     $category->name = "Túi Gym";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //56
     $category = new Category();
     $category->name = "Túi trống lớn";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //57
     $category = new Category();
     $category->name = "Túi xách";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //58
     $category = new Category();
     $category->name = "Túi rút";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //59
     $category = new Category();
     $category->name = "Hộp";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //60
     $category = new Category();
     $category->name = "Vớ";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //61
     $category = new Category();
     $category->name = "Dây";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
     //62
     $category = new Category();
     $category->name = "Nón";
     $category->parent_id = 0;
     $category->Branch()->associate(Branch::where('name', '=', 'Phụ kiện')->first());
     $category->save();
 }