public function testCreate()
 {
     $business = new Business();
     $business->setAttributes(array('name' => "Test Hotel", 'description' => "Test Hotels Description"));
     $this->assertTrue($business->save(false));
     return $business;
 }
示例#2
0
	public function actionGetForm()
	{
		if(isset($_POST['Custom'])){
			$aduit = intval($_POST['Custom']['aduit']);
			$child = intval($_POST['Custom']['child']);
			if(empty($_POST['Custom']['name'])|| empty($_POST['Custom']['first']) || empty($_POST['Custom']['namepy'])|| empty($_POST['Custom']['email'])|| empty($_POST['Custom']['tel'])){
				Yii::app()->user->setFlash('alertmsg','联系人姓,名,姓名拼音,电话,邮箱必须填写!');
				$this->redirect('index');
				exit;
			}
				
			$model = new Business;
				
			$model->type = strip_tags($_POST['Custom']['type']);
			$model->addr_from = strip_tags($_POST['Custom']['addr_from']);
			$model->addr_to = strip_tags($_POST['Custom']['addr_to']);
			$model->departuretime = strtotime($_POST['Custom']['departuretime']);
			$model->budget = floatval($_POST['Custom']['budget']);
			$model->daynumber = intval($_POST['Custom']['daynumber']);
			$model->aduit = $aduit;
			$model->child = $child;
			$model->language = strip_tags($_POST['Custom']['language']);
			$model->ticket = strip_tags($_POST['Custom']['ticket']);
			$model->cartype = strip_tags($_POST['Custom']['cartype']);
			$model->hotel = strip_tags($_POST['Custom']['hotel']);
			$model->eat = strip_tags($_POST['Custom']['eat']);
			$model->attractions = strip_tags($_POST['Custom']['attractions']);
			/* $model->shop = strip_tags($_POST['Custom']['shop']); */
			$model->meet = strip_tags($_POST['Custom']['meet']);
			$model->gender = strip_tags($_POST['Custom']['gender']);
			$model->name = strip_tags($_POST['Custom']['name']);
			$model->first = strip_tags($_POST['Custom']['first']);
			$model->namepy = strip_tags($_POST['Custom']['namepy']);
			$model->tel = strip_tags($_POST['Custom']['tel']);
			$model->qq = strip_tags($_POST['Custom']['wechat']);
			$model->wechat = strip_tags($_POST['Custom']['qq']);
			$model->email = strip_tags($_POST['Custom']['email']);
			$model->replytime = strip_tags($_POST['Custom']['replytime']);
			$model->prireply = strip_tags($_POST['Custom']['prireply']);
			$model->additionmesg = strip_tags($_POST['Custom']['additionmesg']);
			if($model->save(false)){
				Yii::app()->user->setFlash('alertmsg','提交成功,我们会尽快联系您!');
				$this->redirect('index');
			}else{
				Yii::app()->user->setFlash('alertmsg','提交失败,请重试!');
				$this->redirect('index');
			}
				
		}else{
			$this->redirect('index');
		}
		die('没有任何数据!');
	}
示例#3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Business();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Business'])) {
         $model->attributes = $_POST['Business'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Business();
     $paymentMethods = array('Cash' => 'Cash', 'Credit Cards' => 'Credit Cards');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Business'])) {
         $model->attributes = $_POST['Business'];
         if (is_array($model->payment)) {
             $model->payment = implode(', ', $model->payment);
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'paymentMethods' => $paymentMethods));
 }
 public function actionImport()
 {
     $total_records = 0;
     $inserted_records = 0;
     $msg = "";
     $model = new Business();
     $model->setScenario('importFile');
     //$file = CUploadedFile::getInstance($model,'csv_file');
     if (isset($_POST['Business'])) {
         //                          echo $_POST['Business']['import_option']; die();
         if (!empty($_FILES['Business']['tmp_name']['import_file'])) {
             $file = CUploadedFile::getInstance($model, 'import_file');
             $fp = fopen($file->tempName, 'r');
             $row = 1;
             if ($fp) {
                 $line = fgetcsv($fp, 1000, ";");
                 $first_time = true;
                 $c = 1;
                 if ($_POST['Business']['import_option'] == "Insert") {
                     do {
                         if ($first_time == true) {
                             $first_time = false;
                             $headerLine = $line;
                             continue;
                         }
                         //$data = explode(",",$line);
                         //$data = $line[0];
                         //   $data = explode(';',$line);
                         $fData = array_combine($headerLine, $line);
                         //echo '<pre>'; var_dump($fData); echo '</pre>'; die();
                         $email_id = $fData['business_email_id1'];
                         $modelObj = Business::model()->findByAttributes(array('business_email_id1' => $email_id));
                         if (isset($modelObj->business_email_id1)) {
                             $modelObj = new Business();
                             $modelObj->setIsNewRecord(true);
                             $modelObj->attributes = $fData;
                             $modelObj->logo_photo_name = $fData['logo_photo_name'];
                             $modelObj->cover_photo_name = $fData['cover_photo_name'];
                             //     echo '<pre>'; var_dump($modelObj); echo '</pre>'; die();
                             if ($modelObj->validate()) {
                                 $modelObj->save();
                                 var_dump($model->getErrors());
                             } else {
                                 die(CVarDumper::dump($modelObj->errors, 10, true));
                             }
                             $modelObj->business_id;
                             $inserted_records = $inserted_records + 1;
                         }
                         $total_records = $total_records + 1;
                     } while (($line = fgetcsv($fp, 1000, ";")) != FALSE);
                     $msg = $inserted_records . " records are inserted" . " out of " . $total_records;
                     $this->render('import', array('model' => $model, 'total_records' => $total_records, 'inserted_records' => $inserted_records, 'msg' => $msg));
                 }
                 if ($_POST['Business']['import_option'] == "Update") {
                     do {
                         if ($first_time == true) {
                             $first_time = false;
                             $headerLine = $line;
                             continue;
                         }
                         //$data = explode(",",$line);
                         $data = $line[0];
                         $data = explode(',', $data);
                         //echo '<pre>'; var_dump($headerLine); echo '</pre>'; die();
                         $fData = array_combine($headerLine, $data);
                         $email_id = $fData['business_email_id1'];
                         $modelObj = Business::model()->find('business_email_id1=:business_email_id1', array(':business_email_id1' => $email_id));
                         //  echo '<pre>'; var_dump($modelObj); echo '</pre>'; die();
                         //                                                echo var_dump($modelObj);
                         if ($modelObj) {
                             $modelObj->attributes = $fData;
                             $modelObj->logo_photo_name = $fData['logo_photo_name'];
                             $modelObj->cover_photo_name = $fData['cover_photo_name'];
                             //   echo '<pre>'; var_dump($modelObj); echo '</pre>'; die();
                             $modelObj->save();
                             $modelObj->business_id;
                             $inserted_records = $inserted_records + 1;
                         }
                         $total_records = $total_records + 1;
                     } while (($line = fgetcsv($fp, 1000, ";")) != FALSE);
                     // echo "count:".$inserted_records.'---'.$total_records; die();
                     $msg = $inserted_records . " records are updated" . " out of " . $total_records;
                     $this->render('import', array('model' => $model, 'total_records' => $total_records, 'inserted_records' => $inserted_records, 'msg' => $msg));
                     //$this->redirect('././view');
                 }
             }
             $msg = "Please select insert or update option for import file.";
             $this->render('import', array('model' => $model, 'total_records' => $total_records, 'inserted_records' => $inserted_records, 'msg' => $msg));
         }
         $msg = "Please upload file.";
         $this->render('import', array('model' => $model, 'total_records' => $total_records, 'inserted_records' => $inserted_records, 'msg' => $msg));
     }
     $this->render('import', array('model' => $model, 'total_records' => $total_records, 'inserted_records' => $inserted_records, 'msg' => $msg));
 }
 public function postSetupBusiness()
 {
     if (Auth::check() && Helper::isNotAnOwner(Helper::userId())) {
         // PAG added permission checking
         $business_data = $_POST;
         $business = new Business();
         $business_check = Business::businessExistsByNameByAddress($business_data['business_name'], $business_data['business_address']);
         if (count($business_check) != 1) {
             $business->name = $business_data['business_name'];
             $business->local_address = $business_data['business_address'];
             $business->industry = $business_data['industry'];
             $business->longitude = $business_data['longitude'];
             $business->latitude = $business_data['latitude'];
             $time_open_arr = Helper::parseTime($business_data['time_open']);
             $business->open_hour = $time_open_arr['hour'];
             $business->open_minute = $time_open_arr['min'];
             $business->open_ampm = $time_open_arr['ampm'];
             $time_close_arr = Helper::parseTime($business_data['time_close']);
             $business->close_hour = $time_close_arr['hour'];
             $business->close_minute = $time_close_arr['min'];
             $business->close_ampm = $time_close_arr['ampm'];
             /*
              * @author CSD
              * @description:
              * set default num terminals to 3 when creating a business
              * set default queue limit to 9999 max
              */
             $business->queue_limit = 9999;
             $business->num_terminals = 1;
             $business->save();
             $business_user = new UserBusiness();
             $business_user->user_id = $business_data['user_id'];
             $business_user->business_id = $business->business_id;
             $business->timezone = $business_data['timezone'];
             /* Timezone is already set in config/app.php
                date_default_timezone_set("Asia/Manila"); // Manila Timezone for now but this depends on business location
                */
             $contents = '
             {
               "box1": {
                 "number": "1",
                 "terminal": "",
                 "rank": ""
               },
               "box2": {
                 "number": "2",
                 "terminal": "",
                 "rank": ""
               },
               "box3": {
                 "number": "3",
                 "terminal": "",
                 "rank": ""
               },
               "box4": {
                 "number": "4",
                 "terminal": "",
                 "rank": ""
               },
               "box5": {
                 "number": "5",
                 "terminal": "",
                 "rank": ""
               },
               "box6": {
                 "number": "6",
                 "terminal": "",
                 "rank": ""
               },
               "get_num": " ",
               "display": "1-6",
               "show_issued": true,
               "ad_image": "",
               "ad_video": "\\/\\/www.youtube.com\\/embed\\/EMnDdH8fdEc",
               "ad_type": "image",
               "turn_on_tv": false,
               "tv_channel": "",
               "date": "' . date("mdy") . '",
               "ticker_message" : "",
               "ticker_message2" : "",
               "ticker_message3" : "",
               "ticker_message4" : "",
               "ticker_message5" : ""
             }
         ';
             File::put(public_path() . '/json/' . $business->business_id . '.json', $contents);
             $business_user->save();
             $branch_id = Branch::createBusinessBranch($business->business_id, $business->name);
             $service_id = Service::createBranchService($branch_id, $business->name);
             /* @CSD Auto issue on business create */
             $issueController = new IssueNumberController();
             $issueController->getMultiple($service_id, 10);
             /* Auto issue end */
             $terminals = Terminal::createBranchServiceTerminal(Auth::user()->user_id, $service_id, $business->num_terminals);
             if ($business->save()) {
                 return json_encode(['success' => 1, 'terminals' => $terminals]);
             } else {
                 return json_encode(['success' => 0, 'error' => 'Something went wrong while saving your business.']);
             }
         } else {
             $error = "Business name already exists with the same business address.";
             return json_encode(['success' => 0, 'error' => $error]);
         }
     } else {
         return json_encode(array('success' => 0, 'error' => 'You are not allowed to access this function or you already have a business account.'));
     }
 }
示例#7
0
    return $app['twig']->render('business.html.twig', array('business' => $business, 'all_activities' => Activity::getAll()));
});
//View a list of all businesses
$app->get("/businesshome", function () use($app) {
    return $app['twig']->render('businesshome.html.twig', array('businesses' => Business::getAll()));
});
//add a new business to businesses from business home
$app->post("/businesshome", function () use($app) {
    $business_name = $_POST['business_name'];
    $business_phone = $_POST['business_phone'];
    $business_contact = $_POST['business_contact'];
    $business_website = $_POST['business_website'];
    $business_address = $_POST['business_address'];
    $business_contact_email = $_POST['business_contact_email'];
    $business = new Business($business_name, $business_phone, $business_contact, $business_website, $business_address, $business_contact_email, $id = null);
    $business->save();
    return $app['twig']->render('businesshome.html.twig', array('businesses' => Business::getAll()));
});
//specific business viewing page to be viewed by the user.
//(NEED TO FINALIZE ARRAY!!!)
$app->get("/business/{id}", function ($id) use($app) {
    $business = Business::find($id);
    return $app['twig']->render('business.html.twig', array('business' => $business, 'all_activities' => Activity::getAll()));
});
//Path to update business info --- NOT FINISHED AND NEEDS PROPER THINGS!
$app->get("/updatebusiness/{id}", function () use($app) {
    return $app['twig']->render('updatebusiness.html.twig', array('business' => $business));
});
//path to userhome for viewing current users and adding new
$app->get("/userhome", function () use($app) {
    return $app['twig']->render('userhome.html.twig', array('users' => User::getAll()));
 public function store()
 {
     $data = array("first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email"), "username" => Input::get("username"), "phone" => Input::get("phone"), "picture" => Input::file("picture"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation"));
     $rules = array("first_name" => 'required|min:1|max:255', "last_name" => 'required|min:1|max:100', "email" => 'required|email|unique:users', "username" => 'required|min:5|unique:users', "phone" => 'required|min:1|max:100', "picture" => 'mimes:jpeg,gif,png', 'password' => 'confirmed|min:6');
     $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png', 'unique' => 'El :attribute ingresado ya esta siendo usaddo por otro usuario.', 'confirmed' => 'La confirmación del :attribute no coincide');
     $validation = Validator::make(Input::all(), $rules, $messages);
     //si la validación falla redirigimos al formulario de registro con los errores
     //y con los campos que nos habia llenado el usuario
     if ($validation->fails()) {
         return Redirect::to('/clinic/doctors/create')->withErrors($validation)->withInput();
     } else {
         $user = new User();
         $user->first_name = Input::get("first_name");
         $user->last_name = Input::get("last_name");
         $user->email = Input::get("email");
         $user->username = Input::get("username");
         $user->password = Input::get("password");
         $user->save();
         $doctorUser = Sentry::getUserProvider()->findByLogin($user->email);
         $doctorsyGroup = Sentry::getGroupProvider()->findByName('Doctors');
         $doctorUser->addGroup($doctorsyGroup);
         $doctor = new Doctor();
         $doctor->user_id = $user->id;
         $doctor->clinic_id = Clinic::getClinicId();
         $doctor->specialty_id = Input::get("specialty_id");
         if (Input::file('picture') != NULL) {
             //agrega imagen de logo
             $file_logo = Input::file('picture');
             $ext = Input::file('picture')->getClientOriginalExtension();
             $nameIMG = date('YmdHis');
             $logo = $nameIMG . '.' . $ext;
             $logo = 'assets/doctor/images/profile_pic/profile_' . $logo;
             $file_logo->move("assets/doctor/images/profile_pic/", $logo);
             $doctor->picture = $logo;
         }
         $doctor->save();
         $clinic = Clinic::find(Clinic::getClinicId());
         $address_id = $clinic->address_id;
         $agenda = new Agenda();
         $agenda->doctor_id = $doctor->id;
         $agenda->name = "Agenda " . Input::get("first_name") . ' ' . Input::get("last_name");
         $agenda->description = 'Nuevo';
         $agenda->save();
         $busines = new Business();
         $busines->doctor_id = $doctor->id;
         $busines->agenda_id = $agenda->id;
         $busines->addresses_id = $address_id;
         $busines->name = 'Local # ';
         $busines->save();
         if (!$logo) {
             $logo = "";
         }
         $profile = new Profile();
         $profile->user_id = $user->id;
         $profile->lang = Input::get("lang");
         $profile->phone = Input::get("phone");
         $profile->picture = $logo;
         $profile->save();
         if ($profile) {
             return Redirect::to('/clinic/doctors/')->withFlash_message("Guardado Exitosamente");
         } else {
             return Redirect::to('/clinic/doctors/create')->withErrors("Error")->withInput();
         }
     }
 }
 function testGetActivities()
 {
     //Arrange
     $business_name = "IBM";
     $business_phone = "5033133131";
     $business_contact = "john";
     $business_website = "walkins.com";
     $business_address = "123 fake st";
     $business_contact_email = "*****@*****.**";
     $id = 1;
     $test_business = new Business($business_name, $business_phone, $business_contact, $business_website, $business_address, $business_contact_email, $id);
     $test_business->save();
     $activity_name = "Activity One";
     $activity_date = '2016-01-01';
     $activity_location = "Location";
     $activity_description = "Description of Activity One";
     $activity_price = "Price of Activity One";
     $activity_quantity = 10;
     $business_id = 11;
     $activity_category_id = 12;
     $id = 1;
     $test_activity = new Activity($activity_name, $activity_date, $activity_location, $activity_description, $activity_price, $activity_quantity, $business_id, $activity_category_id, $id = null);
     $test_activity->save();
     $activity_name2 = "Activity Two";
     $activity_date2 = '2016-02-02';
     $activity_location2 = "Location Two";
     $activity_description2 = "Description of Activity Two";
     $activity_price2 = "Price of Activity Two";
     $activity_quantity2 = 20;
     $business_id2 = 21;
     $activity_category_id2 = 22;
     $id2 = 2;
     $test_activity2 = new Activity($activity_name2, $activity_date2, $activity_location2, $activity_description2, $activity_price2, $activity_quantity2, $business_id2, $activity_category_id2, $id2 = null);
     $test_activity2->save();
     //Act
     $test_business->addActivity($test_activity);
     $test_business->addActivity($test_activity2);
     $result = $test_business->getActivities();
     //Assert
     $this->assertEquals([$test_activity, $test_activity2], $result);
 }
 function testAddBusiness()
 {
     //Arrange
     $activity_name = "Activity One";
     $activity_date = '2016-01-01';
     $activity_location = "Location";
     $activity_description = "Description of Activity One";
     $activity_price = "Price of Activity One";
     $activity_quantity = 10;
     $business_id = 11;
     $activity_category_id = 12;
     $id = 1;
     $test_activity = new Activity($activity_name, $activity_date, $activity_location, $activity_description, $activity_price, $activity_quantity, $business_id, $activity_category_id, $id = null);
     $test_activity->save();
     $business_name = "IBM";
     $business_phone = "5033133131";
     $business_contact = "john";
     $business_website = "walkins.com";
     $business_address = "123 fake st";
     $business_contact_email = "*****@*****.**";
     $business_category_id = 14;
     $id = 1;
     $test_business = new Business($business_name, $business_phone, $business_contact, $business_website, $business_address, $business_contact_email, $business_category_id, $id);
     $test_business->save();
     //Act
     $test_activity->addBusiness($test_business);
     //Assert
     $this->assertEquals([$test_business], $test_activity->getBusinesses());
 }
 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;
     }
 }
 public function actionCsvForm()
 {
     $model = new Business();
     // uncomment the following code to enable ajax-based validation
     /*
     if(isset($_POST['ajax']) && $_POST['ajax']==='business-csvForm-form')
     {
     	echo CActiveForm::validate($model);
     	Yii::app()->end();
     }
     */
     $msg = '';
     $type = '';
     $r = 0;
     if (isset($_POST['Business']) && $_POST['Business']['uploadmode'] == 1) {
         unset($_POST['Business']['uploadmode']);
         //echo '<pre>'; var_dump($_POST['Business']); echo '</pre>';	die();
         $file = CUploadedFile::getInstance($model, 'csv_file');
         if (!empty($file)) {
             $fp = fopen($file->tempName, 'r');
             $row = 1;
             $headerLine = 1;
             $r = 0;
             $dataHead = array();
             try {
                 $flag = false;
                 $duplicate = 0;
                 if ($fp !== FALSE) {
                     while (($data = fgetcsv($fp)) !== FALSE) {
                         $num = count($data);
                         if ($row !== $headerLine) {
                             if (count($dataHead) == count($data)) {
                                 $newData = array_combine($dataHead, $data);
                                 $modelObj = new Business();
                                 $modelObj->setIsNewRecord(true);
                                 $modelObj->attributes = $newData;
                                 $modelObj->logo_photo_name = $newData['logo_photo_name'];
                                 $modelObj->logo_photo_name = $newData['cover_photo_name'];
                                 $result = $modelObj->model()->countByAttributes(array('business_email_id1' => $newData['business_email_id1']));
                                 if (!$result) {
                                     if ($modelObj->validate()) {
                                         if ($modelObj->save()) {
                                             $flag = true;
                                             $r++;
                                         }
                                     } else {
                                         die(CVarDumper::dump($modelObj->errors, 10, true));
                                     }
                                 } else {
                                     $duplicate++;
                                     $flag = true;
                                 }
                             }
                         } else {
                             $dataHead = $data;
                         }
                         $row++;
                         $type = 'new';
                     }
                 }
                 if ($flag) {
                     $msg .= $r . '  row(s) inserted successfully';
                     Yii::app()->user->setFlash('success', $msg);
                     //$this->render('csvForm',array('model'=>$model));
                     //$this->render('index', array('model' => $model,'msg'=>$r,'duplicaterow'=>$duplicate));
                 }
             } catch (Exception $error) {
                 throw new CHttpException(404, 'File can\'t upload. Please check your file');
             }
         }
         // end if of file is not empty
     }
     /*
      * Update record by csv
      */
     if (isset($_POST['Business']) && isset($_POST['Business']['uploadmode']) && $_POST['Business']['uploadmode'] == 2) {
         $r = $this->_update($_POST['Business']);
         $msg .= $r . ' row(s) updated successfully';
         Yii::app()->user->setFlash('success', $msg);
     }
     $this->render('csvForm', array('model' => $model));
 }