public function actionUser() { //Customer::deleteAll(); if (isset($_POST['searchV'])) { $searchq = $_POST['searchV']; $query = CustomerSocialLogin::findBySql('select * from customer')->all(); /*for($x=1;$x<6;$x++) { $customer = Customer::get($x); var_dump($customer->customer_user_name); } */ /* $count=1; foreach($query as $q) { $customer = new Customer(); $customer->primaryKey = $count; $customer->attributes = ['customer_user_name' => $q->customer_user_name, 'customer_first_name' => $q->customer_first_name,'customer_last_name' => $q->customer_last_name]; $customer->save(); $count++; } */ //$result = Customer::find()->query(["match" => ["customer_user_name" => $searchq]])->asArray()->all(); $result = Customer::find()->query(["fuzzy_like_this" => ["fields" => ["customer_user_name"], "like_text" => $searchq, "max_query_terms" => 25]])->asArray()->all(); //var_dump($result); for ($x = 0; $x < count($result); $x++) { $val = $result[$x]; $res = $val['_source']; $res = $res['customer_user_name']; echo '<div>   <a>' . $res . '</a></div>'; } } else { echo '<div>   no results for the search</div>'; } }
public function deleteIndex() { $id = Input::get('id'); $customer = Customer::find($id); $customer->delete(); return $id; }
public function getCustomer($id) { $customer = Customer::find($id); if ($customer == null) { return Error::make("No Customer Found"); } else { return Error::success("Customer found", $customer->toArray()); } }
public function getAppointments() { $appointments = Appointment::all(); $calendarAppointments = array(); foreach ($appointments as $a) { $customer = Customer::find($a['customer_id']); $customer = $customer->first_name . ' ' . $customer->last_name; $event = array('title' => 'Appointment with ' . $customer, 'start' => $a['appointment_datetime']); array_push($calendarAppointments, $event); } return View::make('admin/appointments')->with('appointments', $calendarAppointments); }
public function update() { $inputs = Input::all(); $customer = Customer::find($inputs['pk']); $customer->{$inputs}['name'] = $inputs['value']; //tt($customer->save()); if ($customer->save()) { $data['status'] = 'success'; } else { $data['status'] = 'danger'; } return Response::json($data); }
/** * * @param type $_id * @return \Illuminate\Http\Response Description */ public function delete($_id) { $customer = Customer::find($_id); $response = array('status' => false, '_id' => $_id); $contracts = $customer->contracts(); if ($customer->delete()) { foreach ($contracts as $contract) { $contract->delete(); } $response['status'] = true; } $headers = array('Content-type' => 'application/json'); return \Illuminate\Http\Response::create($response, 200, $headers); }
public function update($id) { // Validation $input = Input::all(); try { $validate_data = $this->_validator->validate($input); } catch (ValidationException $e) { return Redirect::back()->withInput()->withErrors($e->get_errors()); } $customer = Customer::find($id); if (!$customer->update($input)) { return Redirect::back()->with('error', 'Error while trying to update Customer')->withInput(); } return Redirect::route('show_customer_path', array($customer['id']))->with('success', 'Customer updated.'); }
/** * Display the customer's profile page after successful login. */ public function profile(Customer $customer = NULL) { if (is_null($customer)) { if (Auth::check()) { //echo Auth::user()->email; $customer = Customer::find(Auth::id()); $orders = Order::where('customer_id', '=', Auth::id())->get(); $this->layout->content = View::make('customers.profile', compact('customer', 'orders')); } else { return Redirect::to('login'); } } else { $orders = Order::where('customer_id', '=', $customer->id)->get(); $this->layout->content = View::make('customers.profile', compact('customer', 'orders')); } }
public function indexAction() { if (!$this->request->isPost()) { Tag::setDefault('email', ' '); Tag::setDefault('password', ''); } else { $name = trim($this->request->getPost('name', array('string', 'striptags'))); $password = trim($this->request->getPost('password')); $password = sha1($password); $detail = Customer::find("name = " . $name); if ($password == sha1($detail->num)) { return $this->forward("search/jump"); } else { $this->flash->error("错误"); } } }
public function login() { if ($this->authData()) { $name = Input::get('name'); $id = Customer::where('name', $name)->pluck('id'); $user = Customer::find($id); Auth::login($user); if (Auth::check()) { Session::put('isAdmin', TRUE); return Redirect::to('admin/index.html'); } else { $result = ['err' => 1001, 'msg' => '登录失败']; } } else { $result = ['err' => 1001, 'msg' => '验证不通过']; } return Response::json($result); }
public function indexAction() { $numberPage = 1; $searchParams = array(); if ($this->request->isPost()) { //$query = Criteria::fromInput($this->di, "Customer", $_POST); $keyword = trim($this->request->getPost("keyword", "striptags")); if (isset($keyword) && $keyword != '') { if (strlen($keyword) == 18) { $searchParams = array("number = '" . $keyword . "'"); } else { $searchParams = array("name = '" . $keyword . "'"); } //$this->persistent->searchParams = $query->getParams(); } else { $this->flash->notice("请重新输入搜索条件"); } } else { $numberPage = $this->request->getQuery("page", "int"); if ($numberPage <= 0) { $numberPage = 1; } } $parameters = array(); if ($searchParams) { $parameters = $searchParams; } $customer = Customer::find($parameters); if (count($customer) == 0) { $this->flash->notice("没有找到对应的合同"); } $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $customer, "limit" => 10, "page" => $numberPage)); $page = $paginator->getPaginate(); $this->view->setVar("page", $page); $this->view->setVar("customer", $customer); }
/** * Remove the specified resource from storage. * DELETE /adminbuildings/{id} * * @param int $id * @return Response */ public function delete($id) { $customer = Customer::find($id); $public_path = public_path() . $this->public_path; $image_fields = $this->image_fields; for ($i = 0; $i < count($image_fields); $i++) { if (file_exists($public_path . $customer->{$image_fields}[$i])) { File::delete($public_path . $customer->{$image_fields}[$i]); } } Customer::destroy($id); return Redirect::back(); }
| | The CSRF filter is responsible for protecting your application against | cross-site request forgery attacks. If this special token in a user | session does not match the one given in this request, we'll bail. | */ Route::filter('csrf', function () { if (Session::token() !== Input::get('_token')) { throw new Illuminate\Session\TokenMismatchException(); } }); /* |-------------------------------------------------------------------------- | Admin Filter |-------------------------------------------------------------------------- | | Check to determine if currently logged in user is an Administrator, | based on the 'admin_ind' database flag. | */ Route::filter('admin', function () { if (Auth::guest()) { return Redirect::route('login')->with('message', 'You must log in to access admin area of site.'); } else { $customer = Customer::find(Auth::id()); Log::debug('Admin filter - customer: ' . print_r($customer, TRUE)); if (!$customer->admin_ind) { return Redirect::route('home')->with('message', '<strong>You are not authorized to access admin area of site.</strong>'); } } });
<li><!-- HOME --> <a href="{{URL::Route('home')}}"> HOME </a> </li> @if(Auth::check()) <?php $data = array("first_name" => "User"); $id = Auth::user()->id; switch (Auth::user()->type) { case 'driver': $data = Driver::find($id)->toArray(); break; case 'customer': $data = Customer::find($id)->toArray(); break; case 'business': $data = Business::find($id)->toArray(); break; } ?> <li><!-- HOME --> <a href="{{URL::Route('edit')}}"> Edit </a> </li> <li class="dropdown"> <a class="dropdown-toggle" href="#"> Hi! {{$data["first_name"]}}
/** * Generates quotation requests * * @param int $customerId * @return Response * @author Gat **/ public function createQuotation($customerId) { $directAward = Input::get('award') ? true : false; $customer = Customer::find($customerId); $secretary = Auth::user(); // Check if customer has a representative if ($customer->representatives->isEmpty()) { return Redirect::route('customers.edit', ['id' => $customerId])->with('message', 'Add a customer representative first')->with('alert-class', 'danger'); } // Get Initials $initialsPatern = '~\\b(\\w)|.~'; $customerInitials = preg_replace($initialsPatern, '$1', $customer->name); $secretaryInitials = preg_replace($initialsPatern, '$1', $secretary->full_name); // TEMPORARY // RFQ = Customer's Initials - DDMM - Secretary's Initials $rfq = $customerInitials . '-' . date('dm') . '-' . $secretaryInitials; // Append number if existing $quotations = Quotation::where('rfq_id', 'LIKE', "{$rfq}%"); if ($quotations->count()) { $rfq = $rfq . '-' . $quotations->count(); } // Create quotation $quotation = Quotation::create(['customer_id' => $customer->id, 'secretary_id' => $secretary->id, 'rfq_id' => $rfq, 'direct_award' => $directAward]); return Redirect::route('quotations.request', ['rfq' => Str::slug($rfq)]); }
break; case 'uploadfile': default: $config = array("pathFormat" => "/customers/{$cus_name}/images/ueditor/{time}{rand:6}", "maxSize" => $CONFIG['fileMaxSize'], "allowFiles" => $CONFIG['fileAllowFiles']); $fieldName = $CONFIG['fileFieldName']; break; } //$test=array('sta',1); //return json_encode($test); /* 生成上传实例对象并完成上传 */ $up = new Uploader($fieldName, $config, $base64); $up_result = $up->getFileInfo(); /* 同步到客户服务器 */ if ($up_result['state'] == 'SUCCESS') { //同步到客户服务器 $customerinfo = Customer::find($cus_id); $ftp_array = explode(':', $customerinfo->ftp_address); $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : '21'; $conn = ftp_connect($ftp_array[0], $ftp_array[1]); if ($conn) { ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd); /* 编辑器上传图片问题 */ ftp_pasv($conn, 1); //===扣除空间=== // customers/$cus_name/images/ueditor/ // $size = filesize(public_path('customers/' . $cus_name . '/images/ueditor/' . $up_result['title'])); // $reg=ueditor_regular(1024); // $cus = new CapacityController; // if (!$cus->change_capa($reg, 'use')) { // return Response::json(['err' => 1001, 'msg' => '容量不足', 'data' => []]); // }
/** * Show the form for creating a new cart * * @return Response */ public function create() { $customer_id = Input::get('customer_id'); $customer = Customer::find($customer_id); $cart = Cart::where('customer_id', $customer_id)->get(); return View::make('admin.carts.create')->with('customer', $customer)->with('cart', $cart); }
public function action_create($customer_id) { $customer = Customer::find($customer_id); return View::make('project.create')->with('customer', $customer); }
public function calculate_cabinet_price() { $this->autoRender = FALSE; $calculatePrice['new_row'] = ''; $resource = explode('|', trim($this->request->data['resource'])); if (isset($resource[1]) && !empty($resource[1])) { // pr($this->request->data);exit; $resource_id = $resource[0]; $resource_type = $resource[1]; $quote_id = (int) $this->request->data['quote_id']; $cabinet_color = $this->request->data['cabinet_color']; $material_id = $this->request->data['material_id']; $door_id = $this->request->data['door_id']; $door_color = $this->request->data['door_color']; $drawer_id = $this->request->data['drawer_id']; $drawer_slide_id = $this->request->data['drawer_slide']; $quantity = $this->request->data['resource_quantity']; $delivery_option = $this->request->data['delivery_option']; $cabinet_order_id = null; $door_side = $this->request->data['door_side']; $door_drilling = $this->request->data['door_drilling']; $customer_id = $this->request->data['customer_id']; App::import("Model", "CustomerManager.Customer"); $customer_model = new Customer(); $customer = $customer_model->find('first', array('conditions' => array('Customer.id' => $customer_id))); App::import("Model", "QuoteManager.Quote"); $quote_model = new Quote(); $quote_data = $quote_model->find('first', array('conditions' => array('Quote.id' => $quote_id), 'recursive' => -1)); $multi_family_pricing = 0; foreach ($customer['BuilderProject'] as $project) { if ($project['id'] == $quote_data['Quote']['project_id']) { $multi_family_pricing = $project['multi_family_pricing']; } } if ($customer['Customer']['customer_type_id'] == 2 && $multi_family_pricing == 1) { switch ($resource_type) { case 'cabinet': $calculatePrice = $this->PriceCalculation->calculateCabinetPriceForBuilder($resource_id, $cabinet_color, $material_id, $door_id, $door_color, $drawer_id, $drawer_slide_id, $quantity, $delivery_option); if (!empty($quote_id)) { $cabinet_order_id = $this->saveTempCalculationResultToPrint($quote_id, $resource_id, $calculatePrice['total_price'], $calculatePrice['debug_calculation'], $resource_type, $cabinet_color, $material_id, $door_id, $door_color, $quantity, $door_side, $door_drilling); //, $drawer_id, $drawer_slide_id); } break; case 'item': $calculatePrice = $this->PriceCalculation->calculateItemPriceForBuilder($resource_id, $quantity, $material_id, $cabinet_color); if (!empty($quote_id)) { $cabinet_order_id = $this->saveTempCalculationResultToPrint($quote_id, $resource_id, $calculatePrice['total_price'], $calculatePrice['debug_calculation'], $resource_type, null, $material_id, null, null, $quantity); //, $drawer_id, $drawer_slide_id); } break; } } else { switch ($resource_type) { case 'cabinet': $calculatePrice = $this->PriceCalculation->calculateCabinetPrice($resource_id, $cabinet_color, $material_id, $door_id, $door_color, $drawer_id, $drawer_slide_id, $quantity, $delivery_option); if (!empty($quote_id)) { $cabinet_order_id = $this->saveTempCalculationResultToPrint($quote_id, $resource_id, $calculatePrice['total_price'], $calculatePrice['debug_calculation'], $resource_type, $cabinet_color, $material_id, $door_id, $door_color, $quantity, $door_side, $door_drilling); //, $drawer_id, $drawer_slide_id); } break; case 'item': $calculatePrice = $this->PriceCalculation->calculateItemPrice($resource_id, $quantity, $material_id, $cabinet_color); if (!empty($quote_id)) { $cabinet_order_id = $this->saveTempCalculationResultToPrint($quote_id, $resource_id, $calculatePrice['total_price'], $calculatePrice['debug_calculation'], $resource_type, null, $material_id, null, null, $quantity); //, $drawer_id, $drawer_slide_id); } break; } } if ($resource_id) { /* Set up new view that won't enter the ClassRegistry */ $view = new View($this, false); $view->set('calculatePrice', $calculatePrice); $view->set('cabinet_order_id', $cabinet_order_id); $view->set('door_side', $door_side); $view->set('door_drilling', $door_drilling); /* Grab output into variable without the view actually outputting! */ $view_output = $view->render('../Elements/Forms/Order/cabinet-order-form-row'); $calculatePrice['new_row'] = $view_output; } } echo json_encode($calculatePrice); exit; }
/** * 推送 * * */ public function pushPrecent() { if (ob_get_level() == 0) { ob_start(); } $indexhtml = $this->homgepagehtml('pc'); $customer_data_get = CustomerPushfile::where('cus_id', $this->cus_id)->pluck('files'); if ($customer_data_get) { $new_data = 0; $customer_data = unserialize($customer_data_get); } else { $new_data = 1; $customer_data = []; } $mindexhtml = $this->homgepagehtml('mobile'); $pc_classify_ids = Classify::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id'); $mobile_classify_ids = Classify::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id'); $pc_article_ids = Articles::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id'); $mobile_article_ids = Articles::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id'); $count = $this->htmlPagecount($pc_classify_ids, $mobile_classify_ids, $pc_article_ids, $mobile_article_ids); $this->html_precent = 70 / $count; $categoryhtml = $this->categoryhtml($pc_classify_ids, 'pc'); $mcategoryhtml = $this->categoryhtml($mobile_classify_ids, 'mobile'); $articlehtml = $this->articlehtml($pc_article_ids, 'pc'); $marticlehtml = $this->articlehtml($mobile_article_ids, 'mobile'); $this->percent = 20 / $count; $path = public_path('customers/' . $this->customer . '/' . $this->customer . '.zip'); $template = new PrintController('online', 'mobile'); $quickbar_json = $template->quickBarJson(); $zip = new ZipArchive(); if ($zip->open($path, ZipArchive::CREATE) === TRUE) { $zip->addFile($indexhtml, 'index.html'); $nowpercent = $this->percent + $this->lastpercent; if (floor($nowpercent) != $this->lastpercent) { echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />'; ob_flush(); flush(); } $this->lastpercent += 70 + $this->percent; $zip->addFile($mindexhtml, 'mobile/index.html'); $nowpercent = $this->percent + $this->lastpercent; if (floor($nowpercent) != floor($this->lastpercent)) { echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />'; ob_flush(); flush(); } $this->lastpercent += $this->percent; $zip->close(); } //$customer_data = $this->compareZip($categoryhtml,$customer_data,'p','category',$path); //$customer_data = $this->compareZip($mcategoryhtml,$customer_data,'m','mobile/category',$path); //$customer_data = $this->compareZip($articlehtml,$customer_data,'pf','detail',$path); //$customer_data = $this->compareZip($marticlehtml,$customer_data,'mf','mobile/detail',$path); $this->compareZip($categoryhtml, $customer_data, 'p', 'category', $path); $this->compareZip($mcategoryhtml, $customer_data, 'm', 'mobile/category', $path); $this->compareZip($articlehtml, $customer_data, 'pf', 'detail', $path); $this->compareZip($marticlehtml, $customer_data, 'mf', 'mobile/detail', $path); if (90 > floor($this->lastpercent)) { echo '90%<script type="text/javascript">parent.refresh(90);</script><br />'; ob_flush(); flush(); } if ($zip->open($path, ZipArchive::CREATE) === TRUE) { $pc_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'website_info.pc_tpl_id', '=', 'template.id')->pluck('name'); $mobile_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'template.id', '=', 'website_info.mobile_tpl_id')->pluck('name'); $aim_dir = public_path("templates/{$pc_dir}/"); $maim_dir = public_path("templates/{$mobile_dir}/"); //$images_dir=public_path("customers/".$this->customer."/images/"); $this->addDir($aim_dir, $zip); //$this->addDir($images_dir,$zip,'images/'); $this->addDir($maim_dir, $zip, 'mobile/'); $zip->close(); $data = serialize($customer_data); if ($new_data) { $customerpushfile = new CustomerPushfile(); $customerpushfile->cus_id = $this->cus_id; $customerpushfile->files = $data; $customerpushfile->save(); } else { CustomerPushfile::where('cus_id', $this->cus_id)->update(['files' => $data]); } $customerinfo = Customer::find($this->cus_id); $ftp_array = explode(':', $customerinfo->ftp_address); $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : '21'; $conn = ftp_connect($ftp_array[0], $ftp_array[1]); if ($conn) { ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd); ftp_pasv($conn, 1); ftp_put($conn, "site.zip", $path, FTP_BINARY); ftp_put($conn, "unzip.php", public_path("packages/unzip.php"), FTP_ASCII); ftp_put($conn, "quickbar.json", public_path('customers/' . $this->customer . '/quickbar.json'), FTP_ASCII); ftp_put($conn, "mobile/quickbar.json", public_path('customers/' . $this->customer . '/quickbar.json'), FTP_ASCII); ftp_close($conn); } echo '100%<script type="text/javascript">parent.refresh(100);</script><br />'; Classify::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]); Articles::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]); $search_data = new TemplatesController(); $search_data->sendData(); $pc_domain = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_domain'); @file_get_contents("{$pc_domain}/unzip.php"); } else { echo '打包失败'; } ob_end_flush(); }
public function editRepresentative($id) { $data['customer'] = Customer::find($id)->load(['contactInfo', 'representatives']); $data['industryTypeList'] = $this->lookupSelect('industry_type'); $data['customerStatusList'] = $this->lookupSelect('customer_status'); $data['contactNumberTypeList'] = $this->lookupSelect('contact_no_type'); return View::make('customers.representatives.edit', $data); }
private function CreateAllDir() { $customer = Auth::user()->name; $cus_id = Auth::id(); $weburl = Customer::where('id', $cus_id)->pluck('weburl'); $suf_url = str_replace('http://c', '', $weburl); if (!file_exists(public_path('customers/' . $customer))) { mkdir(public_path('customers/' . $customer)); } $zip = new ZipArchive(); //新建一个ZipArchive的对象 if ($zip->open(public_path('packages/customernull.zip')) === TRUE) { $zip->extractTo(public_path('customers/' . $customer)); } $zip->close(); $customerinfo = Customer::find($cus_id); $ftp_array = explode(':', $customerinfo->ftp_address); $port = $customerinfo->ftp_port; $ftpdir = $customerinfo->ftp_dir; $ftp = $customerinfo->ftp; $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : $port; $conn = ftp_connect($ftp_array[0], $ftp_array[1]); if ($conn) { ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd); ftp_pasv($conn, 1); if (trim($ftp) == '1') { if (ftp_nlist($conn, $customer) === FALSE) { ftp_mkdir($conn, $customer); } ftp_put($conn, $customer . "/unzip.php", public_path("packages/unzip.php"), FTP_ASCII); ftp_put($conn, $customer . "/site.zip", public_path('packages/customernull.zip'), FTP_BINARY); @file_get_contents('http://' . $customer . $suf_url . "/unzip.php"); } else { if (ftp_nlist($conn, $ftpdir) === FALSE) { ftp_mkdir($conn, $ftpdir); } if (ftp_nlist($conn, $ftpdir . '/mobile') === FALSE) { ftp_mkdir($conn, $ftpdir . '/mobile'); } $domain = strlen(str_replace('http://', '', $customerinfo->pc_domain)) > 0 ? $customerinfo->pc_domain . '/mobile' : $customerinfo->mobile_domain; ftp_put($conn, $ftpdir . "/mobile/m_unzip.php", public_path("packages/m_unzip.php"), FTP_ASCII); ftp_put($conn, $ftpdir . "/mobile/site.zip", public_path('packages/customernull.zip'), FTP_BINARY); @file_get_contents("{$domain}/m_unzip.php"); } ftp_close($conn); } }
function findCustomer($id) { App::uses("Customer", "CustomerManager.Model"); $Customer_model = new Customer(); $customer->recursive = 0; $customers = $Customer_model->find("first", array('conditions' => array('Customer.id' => $id))); return $customers['Customer']['last_name']; }
/** @return void|Braintree\Customer */ public function vaultCustomer() { $customerId = $this->customerDetails->id; if (empty($customerId)) { return null; } else { return Customer::find($customerId); } }
public function action_read($id) { $customer = Customer::find($id)->with('projects')->with('todos'); // Get all customers that belong to an user return View::make('customer.read')->with('customer', $customer); }
/** * 推送 * * */ public function pushPrecent() { if (ob_get_level() == 0) { ob_start(); } $indexhtml = $this->homgepagehtml('pc'); $customer_data_get = CustomerPushfile::where('cus_id', $this->cus_id)->pluck('files'); if ($customer_data_get) { $new_data = 0; $customer_data = unserialize($customer_data_get); } else { $new_data = 1; $customer_data = []; } $mindexhtml = $this->homgepagehtml('mobile'); //$mindexhtml = $this->mhomgepagehtml(); $pc_classify_ids = Classify::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id'); $mobile_classify_ids = Classify::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id'); $pc_article_ids = Articles::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id'); $mobile_article_ids = Articles::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id'); $count = $this->htmlPagecount($pc_classify_ids, $mobile_classify_ids, $pc_article_ids, $mobile_article_ids); $this->html_precent = 70 / $count; $categoryhtml = $this->categoryhtml($pc_classify_ids); $mcategoryhtml = $this->mcategoryhtml($mobile_classify_ids); $articlehtml = $this->articlehtml($pc_article_ids); $marticlehtml = $this->marticlehtml($mobile_article_ids); $this->percent = 20 / $count; $path = public_path('customers/' . $this->customer . '/' . $this->customer . '.zip'); $zip = new ZipArchive(); if ($zip->open($path, ZipArchive::CREATE) === TRUE) { $zip->addFile($indexhtml, 'index.html'); $nowpercent = $this->percent + $this->lastpercent; if (floor($nowpercent) != $this->lastpercent) { echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />'; ob_flush(); flush(); } $this->lastpercent += 70 + $this->percent; $zip->addFile($mindexhtml, 'm/index.html'); $nowpercent = $this->percent + $this->lastpercent; if (floor($nowpercent) != floor($this->lastpercent)) { echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />'; ob_flush(); flush(); } $this->lastpercent += $this->percent; $zip->close(); } $customer_data = $this->compareZip($categoryhtml, $customer_data, 'p', 'category', $path); $customer_data = $this->compareZip($mcategoryhtml, $customer_data, 'm', 'm/category', $path); $customer_data = $this->compareZip($articlehtml, $customer_data, 'pf', 'detail', $path); $customer_data = $this->compareZip($marticlehtml, $customer_data, 'mf', 'm/detail', $path); if (90 < floor($this->lastpercent)) { echo '90%<script type="text/javascript">parent.refresh(90);</script><br />'; ob_flush(); flush(); } if ($zip->open($path, ZipArchive::CREATE) === TRUE) { $aim_dir = public_path('templates/GP006/'); $maim_dir = public_path('templates/GM001/'); $this->addDir($aim_dir, $zip); $this->addDir($maim_dir, $zip, 'm/'); $zip->close(); $data = serialize($customer_data); if ($new_data) { } else { CustomerPushfile::where('cus_id', $this->cus_id)->update(['files' => $data]); } $customerinfo = Customer::find($this->cus_id); $ftp_array = explode(':', $customerinfo->ftp_address); $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : '21'; $conn = ftp_connect($ftp_array[0], $ftp_array[1]); if ($conn) { ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd); ftp_put($conn, "site.zip", $path, FTP_BINARY); ftp_put($conn, "unzip.php", $path, FTP_BINARY); ftp_close($conn); } echo '100%<script type="text/javascript">parent.refresh(100);</script><br />'; Classify::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]); Articles::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]); } else { echo '打包失败'; } ob_end_flush(); }
/** * Show the form for editing the specified customer. * * @param int $id * @return Response */ public function edit($id) { $customer = Customer::find($id); return View::make('admin.customers.edit', compact('customer')); }
public function fileRead() { $customer = Auth::user()->name; $cus_id = Auth::id(); $target = Input::get('target'); $this->check_dir($target, $customer); $files = Input::file(); $destinationPath = public_path('customers/' . $customer . '/images/'); if ($files) { $data = array(); $i = 0; foreach ($files as $file) { if ($file->isValid()) { $type = $file->getClientOriginalExtension(); $fileName = time() . str_random(4) . '.' . $type; $up_result = $file->move($destinationPath . '/l/' . $target . '/', $fileName); if ($up_result) { $s_path = $destinationPath . '/s/' . $target . '/' . $fileName; $img_info = getimagesize($destinationPath . '/l/' . $target . '/' . $fileName); switch ($img_info[2]) { case 1: $type = 'gif'; break; case 2: $type = 'jpg'; break; case 3: $type = 'png'; break; } $this->resizeImage($destinationPath . '/l/' . $target . '/' . $fileName, $type, $s_path, 400, 400); copy($destinationPath . '/s/' . $target . '/' . $fileName, public_path('customers/' . $customer . '/mobile/images/l/' . $target . '/' . $fileName)); $mobile_s_path = public_path('customers/' . $customer . '/mobile/images/s/') . $target . '/' . $fileName; $this->resizeImage(public_path('customers/' . $customer . '/mobile/images/l/') . $target . '/' . $fileName, $type, $mobile_s_path, 400, 400); //同步到客户服务器 $customerinfo = Customer::find($cus_id); $ftp_array = explode(':', $customerinfo->ftp_address); $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : '21'; $conn = ftp_connect($ftp_array[0], $ftp_array[1]); if ($conn) { ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd); ftp_pasv($conn, 1); ftp_put($conn, 'images/l/' . $target . '/' . $fileName, $destinationPath . '/l/' . $target . '/' . $fileName, FTP_BINARY); ftp_put($conn, 'images/s/' . $target . '/' . $fileName, $destinationPath . '/s/' . $target . '/' . $fileName, FTP_BINARY); ftp_put($conn, 'mobile/images/l/' . $target . '/' . $fileName, public_path('customers/' . $customer . '/mobile/images/l/') . $target . '/' . $fileName, FTP_BINARY); ftp_put($conn, 'mobile/images/s/' . $target . '/' . $fileName, public_path('customers/' . $customer . '/mobile/images/s/') . $target . '/' . $fileName, FTP_BINARY); ftp_close($conn); } $data[$i]['name'] = $fileName; $data[$i]['url'] = asset('customers/' . $customer . '/images/l/' . $target . '/' . $fileName); $i++; } } } return Response::json(['err' => 0, 'msg' => '', 'data' => $data]); } else { $file = Input::get('image'); if (strpos($file, 'jpeg')) { $type = 'jpg'; } else { $type = 'png'; } $fileName = time() . str_random(4) . '.' . $type; if (strpos($file, 'jpeg')) { $upload = file_put_contents($destinationPath . '/l/' . $target . '/' . $fileName, base64_decode(preg_replace('/data\\:image\\/jpeg\\;base64\\,/i', '', $file))); } else { $upload = file_put_contents($destinationPath . '/l/' . $target . '/' . $fileName, base64_decode(preg_replace('/data\\:image\\/png\\;base64\\,/i', '', $file))); } if ($upload) { $s_path = $destinationPath . '/s/' . $target . '/' . $fileName; $img_info = getimagesize($destinationPath . '/l/' . $target . '/' . $fileName); switch ($img_info[2]) { case 1: $type = 'gif'; break; case 2: $type = 'jpg'; break; case 3: $type = 'png'; break; } $this->resizeImage($destinationPath . '/l/' . $target . '/' . $fileName, $type, $s_path, 400, 400); copy($destinationPath . '/s/' . $target . '/' . $fileName, public_path('customers/' . $customer . '/mobile/images/l/' . $target . '/' . $fileName)); $mobile_s_path = public_path('customers/' . $customer . '/mobile/images/s/') . $target . '/' . $fileName; $this->resizeImage(public_path('customers/' . $customer . '/mobile/images/l/') . $target . '/' . $fileName, $type, $mobile_s_path, 400, 400); //同步到客户服务器 $customerinfo = Customer::find($cus_id); $ftp_array = explode(':', $customerinfo->ftp_address); $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : '21'; $conn = ftp_connect($ftp_array[0], $ftp_array[1]); if ($conn) { ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd); ftp_pasv($conn, 1); ftp_put($conn, 'images/l/' . $target . '/' . $fileName, $destinationPath . '/l/' . $target . '/' . $fileName, FTP_BINARY); ftp_put($conn, 'images/s/' . $target . '/' . $fileName, $destinationPath . '/s/' . $target . '/' . $fileName, FTP_BINARY); ftp_put($conn, 'mobile/images/l/' . $target . '/' . $fileName, public_path('customers/' . $customer . '/mobile/images/l/') . $target . '/' . $fileName, FTP_BINARY); ftp_put($conn, 'mobile/images/s/' . $target . '/' . $fileName, public_path('customers/' . $customer . '/mobile/images/s/') . $target . '/' . $fileName, FTP_BINARY); ftp_close($conn); } return Response::json(['err' => 0, 'msg' => '', 'data' => ['name' => $fileName, 'url' => asset('customers/' . $customer . '/images/l/' . $target . '/' . $fileName)]]); } else { return Response::json(['err' => 1001, 'msg' => '上传文件失败', 'data' => []]); } } }
private function loadQuote(Quotation $quote) { // Find layout $layout = Layout::find($quote->quotation_layouts_id); $customer = Customer::find($quote->customer_id); // Init \Laravel\Session::put('quote_id', $quote->id); \Laravel\Session::put('quote_email', $customer->email); \Laravel\Session::put('quote_layout', $layout); \Laravel\Session::put('quote_layout_id', $layout->id); \Laravel\Session::put('quote_size', $layout->size_x . 'x' . $layout->size_y); \Laravel\Session::put('quote_postcode', $quote->postcode); //Customise \Laravel\Session::put('quote_customise_swap_window', $quote->quote_customise_swap_window); \Laravel\Session::put('quote_customise_swap_wall', $quote->quote_customise_swap_wall); \Laravel\Session::put('quote_customise_extra_door', $quote->quote_customise_extra_door); \Laravel\Session::put('quote_customise_fanlight', $quote->quote_customise_fanlight); \Laravel\Session::put('quote_customise_half_window', $quote->quote_customise_half_window); \Laravel\Session::put('quote_customise_picture_window', $quote->quote_customise_picture_window); //Decking & floyover \Laravel\Session::put('quote_decking_composite_deck_910_910', $quote->quote_decking_composite_deck_910_910); \Laravel\Session::put('quote_decking_composite_deck_910_1820', $quote->quote_decking_composite_deck_910_1820); \Laravel\Session::put('quote_decking_composite_deck_910_2730', $quote->quote_decking_composite_deck_910_2730); \Laravel\Session::put('quote_decking_flyover_roof_910_910', $quote->quote_decking_flyover_roof_910_910); \Laravel\Session::put('quote_decking_flyover_roof_910_1820', $quote->quote_decking_flyover_roof_910_1820); \Laravel\Session::put('quote_decking_flyover_roof_910_2730', $quote->quote_decking_flyover_roof_910_2730); // Electrics \Laravel\Session::put('quote_electrics_double_sockets_450', $quote->quote_electrics_double_sockets_450); \Laravel\Session::put('quote_electrics_double_sockets_1150', $quote->quote_electrics_double_sockets_1150); \Laravel\Session::put('quote_electrics_light_switch', $quote->quote_electrics_light_switch); \Laravel\Session::put('quote_electrics_panel_heater', $quote->quote_electrics_panel_heater); \Laravel\Session::put('quote_electrics_double_floor_socket', $quote->quote_electrics_double_floor_socket); \Laravel\Session::put('quote_electrics_fused_spur_socket', $quote->quote_electrics_fused_spur_socket); // Internals \Laravel\Session::put('quote_internals_silver_aluminium_venitian_blind_no_screws', $quote->quote_internals_silver_aluminium_venitian_blind_no_screws); \Laravel\Session::put('quote_internals_recessed_blinds', $quote->quote_internals_recessed_blinds); \Laravel\Session::put('quote_internals_internal_910_partition_wall', $quote->quote_internals_internal_910_partition_wall); \Laravel\Session::put('quote_internals_internal_door_dividing_studio', $quote->quote_internals_internal_door_dividing_studio); \Laravel\Session::put('quote_internals_internal_wall_corner_post', $quote->quote_internals_internal_wall_corner_post); // Other \Laravel\Session::put('quote_other_decoupled_floor', $quote->quote_other_decoupled_floor); \Laravel\Session::put('quote_other_aquastep_oak_floor', $quote->quote_other_aquastep_oak_floor); \Laravel\Session::put('quote_other_walls_to_timber', $quote->quote_other_walls_to_timber); \Laravel\Session::put('quote_other_taller_walls', $quote->quote_other_taller_walls); \Laravel\Session::put('quote_other_entry_steps', $quote->quote_other_entry_steps); \Laravel\Session::put('quote_other_entry_handrail', $quote->quote_other_entry_handrail); \Laravel\Session::put('quote_other_skirt', $quote->quote_other_skirt); }
} //connect to database $pdo = new PDO('mysql:host=localhost;dbname=test', 'test', ''); //create a database token storage $tokenStorage = new \cdyweb\Shopify\OAuth\PDOTokenStorage($pdo); //create the Shopify API client $client = new \cdyweb\Shopify\Shopify($config, $tokenStorage); //if the request is a shopify callback, a temporary "code" is provided in the query string if (isset($_GET['code'])) { //finalize the oauth process by requesting a permanent access token $client->authorizeCallback(); //reload this page header('HTTP/1.1 302 Found'); header('Location: ' . $config['redirect_uri']); exit; } //if we haven't connected to Shopify yet, let's redirect to the Authorize page if (!$client->hasAccessToken()) { header('HTTP/1.1 302 Found'); header('Location: ' . $client->getAuthorizeUri()); exit; } //at this point, oauth is successfully set up, so we can start using the API $pages = Page::find('all'); foreach ($pages as $page) { var_dump($page->getSchema()->getValues()); } $customers = Customer::find('all'); foreach ($customers as $customer) { var_dump($customer->getSchema()->getValues()); }