public function activitySearch()
 {
     $customerName = Input::get('customer');
     //  $allCustomers = Customer::where('company_name', 'LIKE', "%$customerName%")  ->get();
     $allCustomers = Customer::where('company_name', 'LIKE', "%{$customerName}%")->get();
     return View::make('activities.customer-list', array('company' => $allCustomers));
 }
 public function edit_help($user)
 {
     switch ($user->type) {
         case 'customer':
             Customer::where('id', '=', $user->id)->delete();
             break;
         case 'driver':
             Driver::where('id', '=', $user->id)->delete();
             break;
         case 'business':
             Business::where('id', '=', $user->id)->delete();
             break;
         default:
             break;
     }
     $user->type = Input::get('type');
     $user->save();
     switch (Input::get('type')) {
         case 'driver':
             $driver = new Driver();
             $driver->id = $user->id;
             $driver->first_name = Input::get('first_name');
             $driver->last_name = Input::get('last_name');
             $driver->phone = Input::get('phone');
             $driver->home_address = Input::get('address');
             $driver->credit_card = Input::get('credit_card');
             $driver->cvv = Input::get('cvv');
             $driver->expiry_date = Input::get('expiry_date');
             $driver->car_type = Input::get('car_type');
             $driver->cab_no = Input::get('cab_no');
             $driver->flag = Input::get('flag');
             $driver->rate = Input::get('rate');
             $driver->hour = Input::get('hour');
             $driver->save();
             break;
         case 'customer':
             $customer = new Customer();
             $customer->id = $user->id;
             $customer->first_name = Input::get('first_name');
             $customer->last_name = Input::get('last_name');
             $customer->phone = Input::get('phone');
             $customer->home_address = Input::get('address');
             $customer->credit_card = Input::get('credit_card');
             $customer->cvv = Input::get('cvv');
             $customer->expiry_date = Input::get('expiry_date');
             $customer->save();
             break;
         case 'business':
             $business = new Business();
             $business->id = $user->id;
             $business->business_name = Input::get('business_name');
             $business->phone = Input::get('phone');
             $business->home_address = Input::get('address');
             $business->credit_card = Input::get('credit_card');
             $business->cvv = Input::get('cvv');
             $business->expiry_date = Input::get('expiry_date');
             $business->save();
             break;
     }
 }
 private function dbMailingSender()
 {
     $customers = Customer::where('is_active', '=', 1)->get();
     foreach ($customers as $customer) {
         $subject = 'Hemos añadido una nueva oferta para ti, no te la pierdas!.';
         $email = $customer->email;
         $name = $customer->customer_name;
         $title = $this->voucher->title;
         $this->mail($email, $name, $title, $subject);
     }
 }
 public function generateCustomerId()
 {
     $stop = null;
     $customer_id = null;
     do {
         $customer_id = rand(1111111, 999999) . '-' . Carbon::now()->year;
         //7 digit customer id
         $customer = Customer::where('membership_id', $customer_id)->first();
         if ($customer && !empty($customer)) {
             $stop = true;
             return $customer_id;
         }
     } while ($stop = false);
     return $customer_id;
 }
Exemple #5
0
 /**
  * Function to add a new customer to the database
  *
  * Returns customer id for appointment creation
  *
  **/
 public static function addCustomer()
 {
     // We get appointment information then set up our validator
     $info = Session::get('appointmentInfo');
     $validator = Validator::make(array('first_name' => $info['fname'], 'last_name' => $info['lname'], 'email' => $info['email']), array('first_name' => 'exists:customers,first_name', 'last_name' => 'exists:customers,last_name', 'email' => 'exists:customers,email'));
     // If the validator fails, that means the user does not exist
     // If any of those three variables don't exist, we create a new user
     // This is so that families can use the same e-mail to book, but
     // We stil create a new user for them in the database.
     if ($validator->fails()) {
         // Registering the new user
         return Customer::create(array('first_name' => $info['fname'], 'last_name' => $info['lname'], 'contact_number' => $info['number'], 'email' => $info['email'], 'wants_updates' => Session::get('updates')))->id;
     } else {
         return Customer::where('email', $info['email'])->pluck('id');
     }
 }
 public function searchCustomerToken()
 {
     $str = strtolower(Input::get('gettoken'));
     //$field = ( preg_match("/^[0-9 ]*$/", $str) !== 0 ) ? 'phone' : 'email';
     //We check to determine if we search through phone or token
     //if( $field === 'phone' ){
     $field = strlen($str) < 11 ? 'token' : 'phone';
     //}
     $tokenInfo = Customer::where($field, '=', Input::get('gettoken'))->select('id', 'name', 'token')->get()->first();
     if (!empty($tokenInfo)) {
         $data['status'] = 'success';
         $data['message'] = $tokenInfo->name . ' Token-ID found!';
         $data['detail'] = "Name: " . $tokenInfo->name . " | Token-ID: " . $tokenInfo->token . "";
     } else {
         $data['status'] = 'error';
         $data['message'] = 'Customer does not exist';
     }
     return Response::json($data);
 }
Exemple #7
0
 function list_by_parent($id, $customer_id)
 {
     $cartdetails = new Cartdetail();
     $cartdetails->order_by('id', 'desc');
     $cartdetails->where('cart_id', $id);
     $cartdetails->get();
     $customers = new Customer($customer_id);
     $customers->order_by('id', 'asc');
     $customers->where('id', $customer_id);
     $customers->get();
     $dis['base_url'] = base_url();
     $dis['view'] = "cartdetail/listbyparent";
     $dis['menu_active'] = 'Giỏ hàng';
     $dis['title'] = "Chi tiết giỏ hàng";
     $dis['title_customer'] = "Thông tin khách hàng";
     $dis['cartdetails'] = $cartdetails;
     $dis['customers'] = $customers;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}carts/list_all/", "onclick" => ""));
     $this->viewadmin($dis);
 }
Exemple #8
0
 /**
  * 修改密码
  * @return type
  */
 public function modifyPassword()
 {
     //        $oldpassword = Input::get('oldpassword');
     $newpassword = Input::get('newpassword');
     $msg = '密码修改失败';
     if (Auth::check()) {
         $name = Auth::user()->name;
         //            if (Hash::check($oldpassword, Auth::user()->password)) {
         if ($name != $newpassword) {
             $msg = '修改成功';
             $result = Customer::where('id', Auth::id())->update(['password' => Hash::make($newpassword)]);
         } else {
             $msg = '密码与账号相同,请重新输入';
         }
         //            }
     }
     if (isset($result) && $result) {
         Auth::logout();
         return Response::json(['err' => 0, 'msg' => $msg, 'success' => 1]);
     } else {
         return Response::json(['err' => 0, 'msg' => $msg, 'success' => 0]);
     }
 }
 });
 Route::get('booking', function () {
     $cpage = 'booklst';
     $r = Room::select('id', 'name')->get();
     return View::make('adminview.booking.index', compact('cpage', 'r'));
 });
 Route::get('getbookinglist', 'BookingController@bookingList');
 Route::post('getbookinglist/search', 'BookingController@searchList');
 Route::post('getbookinginfo/{id}', 'BookingController@searchBooking');
 Route::post('booking/{id}/update', 'BookingController@update');
 Route::post('booking/{id}/payment', 'BookingController@payment');
 Route::post('currentbooking/save', function () {
     $i = Input::all();
     $membershipDiscount = null;
     if (isset($i['membership_id'])) {
         $membership = Customer::where('membership_id', $i['membership_id'])->first();
         if ($membership) {
             $membershipDiscount = $membership->current_discount;
         }
     }
     $booking = Booking::where('id', $i['booking_id'])->first();
     if ($booking) {
         $booking->firstname = $i['firstname'];
         $booking->lastname = $i['lastname'];
         $booking->address = $i['address'];
         $booking->contact_number = $i['contact_no'];
         $booking->status = 1;
         $booking->save();
         $reservation = ReservedRoom::where('booking_id', $i['booking_id'])->get();
         if (count($reservation) > 0) {
             foreach ($reservation as $r) {
 /**
  * Remove the specified resource from storage.
  * DELETE /customers/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $c = Customer::where('membership_id', $id)->first();
     if ($c) {
         $c->delete();
     }
 }
 public function update_job_order_po()
 {
     $id = Input::get('id');
     /*$data['scope'] = QuotationScope::where('quotation_id', $id)->get();
     		echo "<pre>";
     		print_r($data['scope']);
     		die();*/
     $id = Input::get('id');
     $job_order = Input::all();
     $job_order_da = Input::all();
     $jo_daRules = array('created_at' => 'required', 'date_needed' => 'required', 'company_name' => 'required', 'revision_number' => 'required', 'type_of_work' => 'required', 'measurements_from' => 'required');
     $jo_daValidator = Validator::make($job_order_da, $jo_daRules);
     if ($jo_daValidator->fails()) {
         return Redirect::back()->withErrors($jo_daValidator)->withInput(Input::all());
     }
     $job_order = Quotation::find($id);
     $job_order->created_at = Input::get('created_at');
     $job_order->date_needed = Input::get('date_needed');
     $job_order->type_of_work_id = Input::get('type_of_work');
     $job_order->po_status = 'Job Order';
     $job_order->po_number = 'PO_000' . $id;
     $job_order->save();
     $job_order_id = $job_order->customer->id;
     $scope_jo = Customer::where('id', $job_order_id)->first();
     $scope_jo->name = Input::get('company_name');
     $scope_jo->save();
     return Redirect::to('production/back')->with('message', 'Job order updated successfully');
 }
Exemple #12
0
 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);
     }
 }
 public function procOrder($id)
 {
     $order = Order::findOrFail($id);
     $order->status = 2;
     $order->save();
     $items = Order::findOrFail($id)->orderItems;
     $user = Order::findOrFail($id)->user;
     $customer = Customer::where('nama', '=', $user->nama)->first();
     return View::make('admin.orders.process', compact('order', 'items', 'customer'));
 }
Exemple #14
0
 public function templateUploadZip()
 {
     set_time_limit(0);
     $files = Input::file();
     $cus_id = Auth::id();
     $temptype = Input::get("type");
     $customization = Customer::where('id', $cus_id)->pluck('customization');
     if ($customization <= 0 || $customization != 3 && $customization != $temptype) {
         return Response::json(['err' => 1001, 'msg' => '您未开启相应的高级定制,高级定制需要付费,如需要,请联系客服', 'data' => '您未开启高级定制,高级定制需要付费,如需要,请联系客服']);
     }
     $files = Input::file();
     $file = $files['upload_zip'];
     if ($file->isValid()) {
         $type = $file->getClientOriginalExtension();
         $truth_name = date('ymd') . mt_rand(100, 999) . '.' . $type;
         if ($type == "zip") {
             if (file_exists(public_path("temp_templates/{$truth_name}"))) {
                 $result = ['err' => 1000, 'msg' => '模板覆盖成功'];
             } else {
                 $up_result = $file->move(public_path("temp_templates/"), $truth_name);
                 if ($up_result) {
                     if ($temptype == 1) {
                         $name = WebsiteInfo::leftJoin('template', 'pc_tpl_id', '=', 'template.id')->where('website_info.cus_id', $cus_id)->pluck('name');
                     } else {
                         $name = WebsiteInfo::leftJoin('template', 'mobile_tpl_id', '=', 'template.id')->where('website_info.cus_id', $cus_id)->pluck('name');
                     }
                     $tpl_name = $name;
                     $result = $this->saveTemplate($truth_name, $tpl_name, $temptype);
                     $pushed = WebsiteInfo::where("cus_id", $cus_id)->pluck("pushed");
                     if ($temptype == 1) {
                         if ($pushed == 0 || $pushed == 2) {
                             $pushed = 2;
                         } else {
                             $pushed = 1;
                         }
                     } else {
                         if ($pushed == 0 || $pushed == 3) {
                             $pushed = 3;
                         } else {
                             $pushed = 1;
                         }
                     }
                     WebsiteInfo::where("cus_id", $cus_id)->update(array("pushed" => $pushed));
                 } else {
                     $result = ['err' => 1001, 'msg' => '模板覆盖失败'];
                 }
             }
         } else {
             $result = ['err' => 1002, 'msg' => '模板覆盖失败,请上传正确的文件类型'];
         }
     } else {
         $result = ['err' => 1002, 'msg' => '模板覆盖失败,请上传正确的文件类型'];
     }
     return Response::json($result);
 }
 function getFacebook()
 {
     $auth = Config::get('hybridauth');
     $config = array("base_url" => URL::to('user/google'), "providers" => array("Facebook" => array("enabled" => true, "keys" => array("id" => $auth['providers']['Facebook']['keys']['id'], "secret" => $auth['providers']['Facebook']['keys']['secret']))));
     if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
         Hybrid_Endpoint::process();
     }
     $socialAuth = new Hybrid_Auth($config);
     $provider = $socialAuth->authenticate("facebook");
     $userProfile = $provider->getUserProfile();
     $provider->logout();
     $user = Customer::where('email', '=', $userProfile->email)->first();
     return self::autoSigninCus($user, $userProfile);
     //$user =  User::where('email','=',$userProfile->email)->first();print_r($user);
     //return self::autoSignin($user);
 }
 private function _processHistory($id, $daterange)
 {
     Larasset::start('header')->css('daterangepicker');
     Larasset::start('footer')->js('moment', 'daterangepicker');
     if (strpos($daterange, '-') !== FALSE) {
         $fromandto = explode('-', $daterange);
         $from = sqldate($fromandto[0]);
         $to_plus_1day = strtotime('now') - strtotime('yesterday') + strtotime($fromandto[1]);
         $to = sqldate(date('Y/n/d', $to_plus_1day));
         $data['todate'] = $fromandto[1];
     } else {
         $from = sqldate(date('Y/n/d', strtotime('first day of this month')));
         $to = sqldate('+1day');
         $data['todate'] = $to;
     }
     $customerlog = Salelog::with(array('product' => function ($q) {
         $q->select('id', 'name', 'productcat_id')->with(array('categories' => function ($qr) {
             $qr->select('id', 'type');
         }));
     }))->where('customer_id', '=', $id)->whereBetween('created_at', array($from, $to))->orderBy('id', 'desc');
     //tt(groupThem($customerlog->get()->toArray(), 'receipt_id'));
     $customerDetails = Customer::where('id', '=', $id)->first();
     //$data['customerhistory'] = $customerlog->get()->toArray();
     $data['customerhistory'] = groupThem($customerlog->get()->toArray(), 'receipt_id');
     $data['customerdetail'] = $customerDetails;
     $data['fromdate'] = $from;
     $this->layout->title = 'Customer History';
     $this->layout->content = View::make('admin.customerhistory', $data);
 }
 /**
  * Get customers list
  *
  * @return json
  * @author Leo
  **/
 public function _getCustomerListDropdownData()
 {
     $data = Input::all();
     $hasData = false;
     if ($data) {
         $q = $data['q'];
         $customers = Customer::where('name', 'LIKE', "%{$q}%")->get(array('id', 'name'));
         if ($customers) {
             foreach ($customers as $key => $value) {
                 $hasData = true;
                 $results[] = array('id' => $value['id'], 'text' => $value['name']);
             }
         }
     }
     if (!$hasData) {
         $results[] = array('id' => " ", 'text' => "No results found, please refine your search parameter.");
     }
     return Response::json($results);
 }
Exemple #18
0
 /**
  * 推送
  * 
  * 
  */
 public function pushPrecent()
 {
     set_time_limit(0);
     if (Input::has("pushgrad") == 1) {
         echo '<script type="text/javascript">function refresh(str){parent.refresh(str);};</script>';
         if (Input::has("push_c_id")) {
             $pushcid = Input::get("push_c_id");
         }
         if (Input::has("end")) {
             $end = Input::get("end");
         }
         //            $pushcid = $this->pushcid;
         //            $end = $this->end;
         //            $this->percent=0;
         //            $this->lastpercent=0;
         //            $this->html_precent=0;
         //            $this->last_html_precent=0;
         //            $this->pcpush=0;
         //            $this->mobilepush=0;
         //            $this->quickbarpush=0;
         //            $this->mobilehomepagepush=0;
     } else {
         if (!Input::has("name")) {
             echo '<script type="text/javascript">function refresh(str){parent.refresh(str);};</script>';
         }
         if (Input::has("push_c_id")) {
             $pushcid = Input::get("push_c_id");
         }
         if (Input::has("end")) {
             $end = Input::get("end");
         }
     }
     $have_article = Articles::where('cus_id', $this->cus_id)->count();
     if (!$have_article) {
         echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
         echo '<div class="prompt">没有文章不可推送</div><script type="text/javascript">alert("没有文章不可推送");refresh("没有文章不可推送");</script>';
         ob_flush();
         flush();
         exit;
     }
     if (!isset($_GET['gradpush'])) {
         $this->needpush();
     } else {
         $pc_domain = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_domain');
         $mobile_domain = CustomerInfo::where('cus_id', $this->cus_id)->pluck('mobile_domain');
         $pc = str_replace('http://', '', $pc_domain);
         $mobile = str_replace('http://', '', $mobile_domain);
         if ($pc != '') {
             $this->pcpush = 1;
         }
         if ($mobile != '') {
             $this->mobilepush = 1;
         }
         $this->quickbarpush = 1;
         $this->mobilehomepagepush = 0;
     }
     echo '<div class="prompt">';
     var_dump('pcpush:' . $this->pcpush);
     var_dump('mobilepush:' . $this->mobilepush);
     var_dump('quickbarpush:' . $this->quickbarpush);
     var_dump('mobilehomepagepush:' . $this->mobilehomepagepush);
     echo '</div>';
     ob_flush();
     flush();
     $this->pushinit();
     if (!isset($end) || $end == 1) {
         if ($this->quickbarpush) {
             $this->pushQuickbar();
         }
         if (!$this->mobilepush) {
             if ($this->mobilehomepagepush) {
                 $this->mobilehomepage_push();
             }
         }
     }
     if ($this->pcpush || $this->mobilepush) {
         if (!$this->pcpush && $this->mobilepush) {
             $this->mobile_push();
             return true;
         }
         if (ob_get_level() == 0) {
             ob_start();
         }
         $pc_classify_ids = array();
         $mobile_classify_ids = array();
         $pc_article_ids = array();
         $mobile_article_ids = array();
         if ($this->mobilepush) {
             if (isset($pushcid)) {
                 if (!isset($end) || $end == 1) {
                     $mindexhtml = $this->homgepagehtml('mobile');
                     $msearchhtml = $this->sendData('mobile');
                 }
                 $mobile_classify_ids = array();
                 $mobile_article_ids = array();
                 $mobile_show = Classify::where('cus_id', $this->cus_id)->where("id", $pushcid)->pluck("mobile_show");
                 if ($mobile_show) {
                     $mobile_classify_ids[] = $pushcid;
                     $mobile_article_ids = Articles::where('cus_id', $this->cus_id)->where('mobile_show', 1)->where("c_id", $pushcid)->lists('id');
                 }
             } else {
                 $mindexhtml = $this->homgepagehtml('mobile');
                 $msearchhtml = $this->sendData('mobile');
                 $mobile_classify_ids = Classify::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id');
                 $mobile_article_ids = Articles::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id');
             }
         }
         if ($this->pcpush) {
             if (isset($pushcid)) {
                 if (!isset($end) || $end == 1) {
                     $indexhtml = $this->homgepagehtml('pc');
                     $searchhtml = $this->sendData('pc');
                 }
                 $pc_classify_ids = array();
                 $pc_article_ids = array();
                 $pc_show = Classify::where('cus_id', $this->cus_id)->where("id", $pushcid)->pluck("pc_show");
                 if ($pc_show) {
                     $pc_classify_ids[] = $pushcid;
                     $pc_article_ids = Articles::where('cus_id', $this->cus_id)->where('pc_show', 1)->where("c_id", $pushcid)->lists('id');
                 }
             } else {
                 $indexhtml = $this->homgepagehtml('pc');
                 $searchhtml = $this->sendData('pc');
                 $pc_classify_ids = Classify::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id');
                 $pc_article_ids = Articles::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id');
             }
         }
         $count = $this->htmlPagecount($pc_classify_ids, $mobile_classify_ids, $pc_article_ids, $mobile_article_ids);
         $this->html_precent = 70 / $count;
         if ($this->pcpush) {
             $categoryhtml = $this->categoryhtml($pc_classify_ids, 'pc');
             $articlehtml = $this->articlehtml($pc_classify_ids, 'pc');
         }
         if ($this->mobilepush) {
             $mcategoryhtml = $this->categoryhtml($mobile_classify_ids, 'mobile');
             $marticlehtml = $this->articlehtml($mobile_classify_ids, 'mobile');
         }
         $this->percent = 20 / $count;
         $path = public_path('customers/' . $this->customer . '/' . $this->customer . '.zip');
         if (file_exists($path)) {
             @unlink($path);
         }
         $zip = new ZipArchive();
         if ((!isset($end) || $end == 1) && $zip->open($path, ZipArchive::CREATE) === TRUE) {
             if ($this->pcpush) {
                 $this->addFileToZip(public_path("quickbar/"), $zip, "quickbar");
                 $zip->addFile($indexhtml, 'index.html');
                 $zip->addFile($searchhtml, 'search.html');
                 $zip->addFile(public_path('customers/' . $this->customer . '/article_data.json'), 'article_data.json');
                 $nowpercent = $this->percent + $this->lastpercent;
                 if (floor($nowpercent) != $this->lastpercent) {
                     echo '<div class="prompt">' . floor($nowpercent) . '%</div><script type="text/javascript">refresh(' . floor($nowpercent) . ');</script>';
                     ob_flush();
                     flush();
                     $this->clearpushqueue();
                 }
             }
             $this->lastpercent += 70 + $this->percent;
             if ($this->mobilepush) {
                 $this->addFileToZip(public_path("quickbar/"), $zip, "mobile/quickbar");
                 $zip->addFile($mindexhtml, 'mobile/index.html');
                 $zip->addFile($msearchhtml, 'mobile/search.html');
                 $zip->addFile(public_path('customers/' . $this->customer . '/mobile/article_data.json'), 'mobile/article_data.json');
                 $nowpercent = $this->percent + $this->lastpercent;
                 if (floor($nowpercent) != floor($this->lastpercent)) {
                     echo '<div class="prompt">' . floor($nowpercent) . '%</div><script type="text/javascript">refresh(' . floor($nowpercent) . ');</script>';
                     ob_flush();
                     flush();
                     $this->clearpushqueue();
                 }
             }
             $this->lastpercent += $this->percent;
             $zip->close();
         } else {
             $this->lastpercent += 70 + $this->percent;
         }
         if ($this->pcpush) {
             $this->compareZip($categoryhtml, 'category', $path);
             $this->compareZip($articlehtml, 'detail', $path);
         }
         if ($this->mobilepush) {
             $this->compareZip($mcategoryhtml, 'mobile/category', $path);
             $this->compareZip($marticlehtml, 'mobile/detail', $path);
         }
         if (90 > floor($this->lastpercent)) {
             echo '<div class="prompt">' . '90%</div><script type="text/javascript">refresh(90);</script>';
             ob_flush();
             flush();
             $this->clearpushqueue();
         }
         PushQueue::where('cus_id', $this->cus_id)->delete();
         $nextpush = PushQueue::where('push', 0)->first();
         if ($nextpush) {
             PushQueue::where('id', $nextpush->id)->update(['push' => 1]);
         }
         if ($zip->open($path, ZipArchive::CREATE) === TRUE) {
             if ((!isset($end) || $end == 1) && $this->pcpush) {
                 $pc_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'website_info.pc_tpl_id', '=', 'template.id')->pluck('name');
                 $aim_dir = public_path("templates/{$pc_dir}/");
                 $this->addDir($aim_dir, $zip);
             }
             if ((!isset($end) || $end == 1) && $this->mobilepush) {
                 $mobile_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'template.id', '=', 'website_info.mobile_tpl_id')->pluck('name');
                 $maim_dir = public_path("templates/{$mobile_dir}/");
                 $this->addDir($maim_dir, $zip, 'mobile/');
             }
             $zip->close();
             $customerinfo = Customer::find($this->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]);
             $del_imgs = ImgDel::where('cus_id', $this->cus_id)->get()->toArray();
             if (trim($ftp) == '1') {
                 if ($conn) {
                     ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd);
                     ftp_pasv($conn, 1);
                     if (@ftp_chdir($conn, $this->customer) == FALSE) {
                         ftp_mkdir($conn, $this->customer);
                     }
                     foreach ((array) $del_imgs as $v) {
                         $this->delimg($v);
                         @ftp_delete($conn, "/" . $this->customer . '/images/l/' . $v['target'] . '/' . $v['img']);
                         @ftp_delete($conn, "/" . $this->customer . '/images/s/' . $v['target'] . '/' . $v['img']);
                         @ftp_delete($conn, "/" . $this->customer . '/mobile/images/l/' . $v['target'] . '/' . $v['img']);
                         @ftp_delete($conn, "/" . $this->customer . '/mobile/images/s/' . $v['target'] . '/' . $v['img']);
                     }
                     ImgDel::where('cus_id', $this->cus_id)->delete();
                     if ($this->pcpush) {
                         @ftp_put($conn, "/" . $this->customer . "/search.php", public_path("packages/search.php"), FTP_ASCII);
                         //@ftp_put($conn,"/".$this->customer."/quickbar.json",public_path('customers/'.$this->customer.'/quickbar.json'),FTP_ASCII);
                     }
                     if (file_exists($path)) {
                         ftp_put($conn, "/" . $this->customer . "/site.zip", $path, FTP_BINARY);
                     }
                     ftp_put($conn, "/" . $this->customer . "/unzip.php", public_path("packages/unzip.php"), FTP_ASCII);
                     if ($this->mobilepush) {
                         ftp_put($conn, "/" . $this->customer . "/mobile/search.php", public_path("packages/search.php"), FTP_ASCII);
                         if (@ftp_chdir($conn, "/" . $this->customer . "/mobile") == FALSE) {
                             ftp_mkdir($conn, "/" . $this->customer . "/mobile");
                         }
                         //ftp_put($conn,"/".$this->customer."/mobile/quickbar.json",public_path('customers/'.$this->customer.'/mobile/quickbar.json'),FTP_ASCII);
                     }
                     ftp_close($conn);
                 }
             } else {
                 if ($conn) {
                     ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd);
                     ftp_pasv($conn, 1);
                     foreach ((array) $del_imgs as $v) {
                         $this->delimg($v);
                         @ftp_delete($conn, $ftpdir . '/images/l/' . $v['target'] . '/' . $v['img']);
                         @ftp_delete($conn, $ftpdir . '/images/s/' . $v['target'] . '/' . $v['img']);
                         @ftp_delete($conn, $ftpdir . '/mobile/images/l/' . $v['target'] . '/' . $v['img']);
                         @ftp_delete($conn, $ftpdir . '/mobile/images/s/' . $v['target'] . '/' . $v['img']);
                     }
                     ImgDel::where('cus_id', $this->cus_id)->delete();
                     if ($this->pcpush) {
                         ftp_put($conn, $ftpdir . "/search.php", public_path("packages/search.php"), FTP_ASCII);
                         //ftp_put($conn,$ftpdir."/quickbar.json",public_path('customers/'.$this->customer.'/quickbar.json'),FTP_ASCII);
                     }
                     ftp_put($conn, $ftpdir . "/unzip.php", public_path("packages/unzip.php"), FTP_ASCII);
                     if (file_exists($path)) {
                         ftp_put($conn, $ftpdir . "/site.zip", $path, FTP_BINARY);
                     }
                     if ($this->mobilepush) {
                         ftp_put($conn, $ftpdir . "/mobile/search.php", public_path("packages/search.php"), FTP_ASCII);
                         //ftp_put($conn,$ftpdir."/mobile/quickbar.json",public_path('customers/'.$this->customer.'/mobile/quickbar.json'),FTP_ASCII);
                     }
                     ftp_close($conn);
                 }
             }
             $this->folderClear();
             echo '<div class="prompt">' . '100%</div><script type="text/javascript">refresh(100);</script>';
             if (!isset($end) || $end == 1) {
                 Classify::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->update(['pushed' => 0]);
                 Articles::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->update(['pushed' => 0]);
                 WebsiteConfig::where('cus_id', $this->cus_id)->update(['pushed' => 0]);
                 WebsiteInfo::where('cus_id', $this->cus_id)->update(['pushed' => 0]);
                 MobileHomepage::where('cus_id', $this->cus_id)->update(['pushed' => 0]);
                 CustomerInfo::where('cus_id', $this->cus_id)->update(['pushed' => 0, 'lastpushtime' => date('Y-m-d H:i:s', time())]);
                 //date('Y-m-d H:i:s',time())
             }
             /**
              * pc使用本服务器自带域名推送,后期需要改进!
              */
             $weburl = Customer::where('id', $this->cus_id)->pluck('weburl');
             $suf_url = str_replace('http://c', '', $weburl);
             $cus_name = strtolower(Customer::where('id', $this->cus_id)->pluck('name'));
             if (trim($ftp) == '1') {
                 $ftp_pcdomain = "http://" . $cus_name . $suf_url;
             } else {
                 $ftp_pcdomain = $customerinfo->pc_domain;
             }
             @file_get_contents("{$ftp_pcdomain}/unzip.php");
         } else {
             echo '打包失败';
         }
         ob_end_flush();
     } else {
         echo '<div class="prompt">' . '100%</div><script type="text/javascript">refresh(100);</script>';
         if (!isset($end) || $end == 1) {
             Classify::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->update(['pushed' => 0]);
             Articles::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->update(['pushed' => 0]);
             WebsiteConfig::where('cus_id', $this->cus_id)->update(['pushed' => 0]);
             WebsiteInfo::where('cus_id', $this->cus_id)->update(['pushed' => 0]);
             MobileHomepage::where('cus_id', $this->cus_id)->update(['pushed' => 0]);
             CustomerInfo::where('cus_id', $this->cus_id)->update(['pushed' => 0, 'lastpushtime' => date('Y-m-d H:i:s', time())]);
             //date('Y-m-d H:i:s',time())
             ob_end_flush();
         }
     }
 }
 function postSave($id = 0)
 {
     $trackUri = $this->data['trackUri'];
     $rules = array();
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $data['post_note'] = Input::get('post_note');
         $ID = Input::get('post_id');
         $data_post = DB::table('post')->where('post_id', '=', $ID)->first();
         if (Input::get('active') != '') {
             $data['status'] = '1';
             $data['active'] = Input::get('active');
             $this->cus = Customer::where('customer_id', '=', $data_post->customer_id)->first();
             $link = URL::to('') . "/tin/" . $data_post->post_slug . '-' . $data_post->post_id . ".html";
             $data_mail = array('link' => $link);
             Mail::send('emails.successpost', $data_mail, function ($message) {
                 $message->from(CNF_EMAIL, 'Admin');
                 $message->to($this->cus->email, $this->cus->name)->subject('Xác nhận tin đã đăng');
             });
         } else {
             $data['status'] = Input::get('status');
         }
         DB::table('post')->where('post_id', '=', $ID)->update($data);
         // Input logs
         if (Input::get('post_id') == '') {
             $this->inputLogs("New Entry row with ID : {$ID}  , Has Been Save Successfull");
             $id = SiteHelpers::encryptID($ID);
         } else {
             $this->inputLogs(" ID : {$ID}  , Has Been Changed Successfull");
         }
         // Redirect after save
         $md = str_replace(" ", "+", Input::get('md'));
         $redirect = !is_null(Input::get('apply')) ? 'post/add/' . $id . '?md=' . $md : 'post?md=' . $md . $trackUri;
         return Redirect::to($redirect)->with('message', SiteHelpers::alert('success', Lang::get('core.note_success')));
     } else {
         return Redirect::to('post/add/' . $id)->with('message', SiteHelpers::alert('error', Lang::get('core.note_error')))->withErrors($validator)->withInput();
     }
 }
Exemple #20
0
Route::get('customer/legal_agreements', function () {
    return View::make('frontoffice.legal_agreements');
});
Route::post('customer/suscription', 'CustomerController@suscribe');
Route::post('customer/recommend', 'CustomerController@recommend');
Route::get('customer/voucher/{voucher}', function (Voucher $voucher) {
    return View::make('frontoffice.voucher')->with('voucher', $voucher);
});
Route::get('customer/unsubscribe', function () {
    return View::make('frontoffice.unsubscribe');
});
Route::post('customer/unsubscribe', function () {
    $rules = array('email' => 'required|email');
    $validator = Validator::make(Input::all(), $rules);
    if (!$validator->fails()) {
        $customer = Customer::where('email', '=', Input::get('email'))->first();
        if ($customer) {
            $customer->delete();
            Mail::send('emails.auth.unsubscribe', array('email' => Input::get('email')), function ($message) {
                $message->to(Input::get('email'), 'Invitado')->subject('Confirmación de baja.');
            });
            return Redirect::to('customer/vouchers')->with('success', 'Proceso finalizado con éxito!');
        } else {
            return Redirect::back()->with('error', 'Este usuario ya no consta dado de alta.');
        }
    } else {
        return Redirect::back()->with('error', 'Email erróneo');
    }
});
Route::get('customer/confirmation', function () {
    return View::make('frontoffice.confirmation');
Exemple #21
0
 /**
  * 获取用户信息
  */
 public function getSwitchCustomer()
 {
     $cus_id = Auth::id();
     $switch_cus_id = Customer::where('id', $cus_id)->pluck('switch_cus_id');
     if (empty($switch_cus_id)) {
         return null;
     }
     $current_cus_info = Customer::where('id', $cus_id)->first();
     $switch_cus_info = Customer::where('id', $switch_cus_id)->first();
     $data['switch_pc_domain'] = $switch_cus_info->pc_domain;
     $data['switch_mobile_domain'] = $switch_cus_info->mobile_domain;
     $data['current_pc_domain'] = $current_cus_info->pc_domain;
     $data['current_mobile_domain'] = $current_cus_info->mobile_domain;
     return $data;
 }
 public function index()
 {
     $widget = ['baru' => Penjualan::where('status', 1)->whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'poBaru' => Penjualan::whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'rls' => Penjualan::where('status', '!=', 1)->whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'orders' => Order::where('status', 1)->count(), 'agen' => Customer::where('tipe', 2)->orWhere('tipe', 3)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'mitra' => Customer::where('tipe', 1)->orWhere('tipe', 6)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'biasa' => Customer::where('tipe', 4)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'agenLastYear' => Customer::where('tipe', 2)->orWhere('tipe', 3)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count(), 'mitraLastYear' => Customer::where('tipe', 1)->orWhere('tipe', 6)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count(), 'biasaLastYear' => Customer::where('tipe', 4)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count()];
     $box = ['penjualans' => Penjualan::orderBy('tgl_order', 'DESC')->take(7)->get(), 'barangs' => Barang::orderBy('id', 'DESC')->take(4)->get(), 'customers' => Penjualan::with('customer')->orderBy('tgl_order', 'DESC')->take(8)->get(), 'followups' => Followup::orderBy('created_at', 'desc')->take(6)->get(), 'bahan' => DB::table('bahan')->where('stok', 0)->take(5)->get(), 'menipis' => DB::table('bahan')->where('stok', 0)->count()];
     // CHART =========================================================================================
     $laporanTahunan = Penjualan::select(DB::raw('MONTH(tgl_transfer) as month, count(`id`) as count, sum(`nominal`) as nominal'))->where('status', '!=', 1)->where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year)->groupBy(DB::raw('YEAR(tgl_transfer)'))->groupBy(DB::raw('MONTH(tgl_transfer)'))->orderBy('tgl_transfer', 'asc')->get();
     $total = ['thisMonth' => Penjualan::where('status', '!=', 1)->where('tgl_transfer', '>=', Carbon::now()->startOfMonth())->sum('nominal'), 'thisMonthLastYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year - 1)->where(DB::raw('MONTH(tgl_transfer)'), Carbon::now()->month)->where('status', '!=', 1)->sum('nominal'), 'lastYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year - 1)->where('status', '!=', 1)->sum('nominal'), 'thisYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year)->where('status', '!=', 1)->sum('nominal')];
     // END OF CHART =========================================================================================
     // dd($total['thisMonth']);
     return View::make('admin', compact('box', 'widget', 'total', 'laporanTahunan'));
 }
 public function clientBookingStep3()
 {
     /*
     	foreach(Session::get('reservation')['reservation_room'] as $rooms)
     	{
     	
     		$room_id = $rooms['room_details']['id'];
     		$available_rooms = [];
     		$room_qty = RoomQty::with(array('roomPrice','roomReserved'=>function($query) use($i, $room_id){
     			$query->where(function($query2) use ($i, $room_id){
     				$query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))
     				->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))
     				->orWhereRaw('"'.$i["checkin"].'" between check_in and check_out')
     				->orWhereRaw('"'.$i["checkout"].'" between check_in and check_out');
     			})->where(function($query3)
     			{
     				$query3->where('status', '!=', 5)->orWhere('status', '!=', 3);
     			});
     		}))->where('room_id', $room_id)->where('status',1)->get();
     
     		foreach($room_qty as $available)
     		{
     			if($available->roomReserved== '[]' || count($available->roomReserved) == 0)
     			{
     				array_push($available_rooms, $available);
     			}
     		}
     		if(count($available_rooms) < $rooms['quantity'])
     		{
     			return Redirect::to('booking/step2')->with('error', 'Some rooms you booked is not available');
     		}
     	} 
     */
     $i = Input::all();
     if (isset($i['membership_id'])) {
         $membership = Customer::where('membership_id', $i['membership_id'])->first();
         if ($membership) {
             Session::forget('reservation.customerdiscount');
             //unset(Session::get('reservation.customerdiscount'));
             Session::put('reservation.customerdiscount', $membership->current_discount);
         }
     }
     Session::forget('reservation.customerinformation');
     Session::put('reservation.customerinformation', $i);
     //return Session::get('reservation.customerinformation')['firstname'];
     return Redirect::to('booking/step4');
 }
 public function welcome()
 {
     $customers = Customer::where('home_page', '=', 1)->get();
     $about_us = AboutUs::orderBy('id', 'desc')->first();
     return View::make('jobs.index')->with(['customers' => $customers, 'about_us' => $about_us]);
 }
 public function deleteCustomer()
 {
     $company = Input::get('company');
     $customerDelete = Customer::where('company_name', '=', $company)->first();
     $ID = $customerDelete->c_id;
     $customer = Customer::find($ID);
     $deleted = $customer->delete();
     if ($deleted) {
         return Redirect::route('dashboard');
     } else {
         return Redirect::route('viewCustomers');
     }
 }
 public function isDuplicateCustomer($email)
 {
     $customer = Customer::where('email', '=', $email)->first();
     return is_null($customer) ? "no" : "yes";
 }
 public function export($id)
 {
     Excel::create('Customer', function ($excel) use($id) {
         $excel->sheet('Customer', function ($sheet) use($id) {
             $customers = Customer::where('tipe', $id)->get();
             $sheet->loadView('admin.customers.csv', ['customers' => $customers, 'id' => $id]);
         });
     })->export('xlsx');
 }
 public function getCustomerID($info)
 {
     if (strlen($info) > 5) {
         $explode = explode('|', $info);
         $token = extract_char($explode[1], array('int'));
         return Customer::where('token', '=', $token)->pluck('id');
     } else {
         return 0;
     }
 }
 public function post_sign_in()
 {
     $data = array();
     $data['success'] = '';
     $email = \Laravel\Input::get('email');
     $postcode = strtolower(str_replace(' ', '', \Laravel\Input::get('postcode')));
     // Ensure upper case and spaces removed for better compatability
     $customer = Customer::where('email', '=', $email)->where('postcode', '=', $postcode)->first();
     if (!$customer) {
         $data['error'] = 'Unable to locate an account matching these details!';
     } else {
         \Laravel\Session::put('quote_account_id', $customer->id);
         return Redirect::to_action('quotations/my_quotes');
     }
     return View::make('quotations.sign_in')->with('data', $data);
 }
Exemple #30
0
 /**
  * 
  * @return array
  */
 function autocomplete()
 {
     $_term = Input::get('term');
     $_aux = Input::get('aux');
     $_aux = json_decode($_aux, true);
     $response = array();
     $response = Customer::where('name', 'LIKE', "%{$_term}%")->orWhere('cpf', 'LIKE', "%{$_term}%")->get();
     return $response;
 }